1998-04-14 00:24:54 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
1999-02-12 20:45:58 +03:00
|
|
|
#include "nsCOMPtr.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsPresContext.h"
|
|
|
|
#include "nsIPresShell.h"
|
1998-07-31 09:54:59 +04:00
|
|
|
#include "nsIPref.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsILinkHandler.h"
|
|
|
|
#include "nsIStyleSet.h"
|
1998-05-12 02:56:58 +04:00
|
|
|
#include "nsFrameImageLoader.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsIImageGroup.h"
|
|
|
|
#include "nsIFrame.h"
|
|
|
|
#include "nsIRenderingContext.h"
|
1998-06-24 01:53:02 +04:00
|
|
|
#include "nsEventStateManager.h"
|
1998-09-05 07:52:40 +04:00
|
|
|
#include "nsIURL.h"
|
1998-10-02 01:44:16 +04:00
|
|
|
#include "nsIURLGroup.h"
|
1998-09-05 07:52:40 +04:00
|
|
|
#include "nsIDocument.h"
|
1998-11-06 19:16:01 +03:00
|
|
|
#include "nsIFrame.h"
|
|
|
|
#include "nsIStyleContext.h"
|
1998-12-02 03:32:20 +03:00
|
|
|
#include "nsLayoutAtoms.h"
|
1998-11-06 19:16:01 +03:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-11-23 20:18:34 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
#undef NOISY_IMAGES
|
|
|
|
#else
|
|
|
|
#undef NOISY_IMAGES
|
|
|
|
#endif
|
1998-05-12 05:30:15 +04:00
|
|
|
|
1998-11-06 20:24:08 +03:00
|
|
|
int
|
1998-11-06 19:16:01 +03:00
|
|
|
PrefChangedCallback(const char* aPrefName, void* instance_data)
|
|
|
|
{
|
|
|
|
nsPresContext* presContext = (nsPresContext*)instance_data;
|
|
|
|
|
|
|
|
NS_ASSERTION(nsnull != presContext, "bad instance data");
|
|
|
|
if (nsnull != presContext) {
|
|
|
|
presContext->PreferenceChanged(aPrefName);
|
|
|
|
}
|
|
|
|
return 0; // PREF_OK
|
|
|
|
}
|
|
|
|
|
1998-05-09 07:22:01 +04:00
|
|
|
static NS_DEFINE_IID(kIPresContextIID, NS_IPRESCONTEXT_IID);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
nsPresContext::nsPresContext()
|
1998-11-26 21:10:10 +03:00
|
|
|
: mDefaultFont("Times", NS_FONT_STYLE_NORMAL,
|
1998-04-14 00:24:54 +04:00
|
|
|
NS_FONT_VARIANT_NORMAL,
|
|
|
|
NS_FONT_WEIGHT_NORMAL,
|
|
|
|
0,
|
1998-08-01 03:34:45 +04:00
|
|
|
NSIntPointsToTwips(12)),
|
1998-07-17 09:41:41 +04:00
|
|
|
mDefaultFixedFont("Courier", NS_FONT_STYLE_NORMAL,
|
|
|
|
NS_FONT_VARIANT_NORMAL,
|
|
|
|
NS_FONT_WEIGHT_NORMAL,
|
|
|
|
0,
|
1998-08-01 03:34:45 +04:00
|
|
|
NSIntPointsToTwips(10))
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
NS_INIT_REFCNT();
|
1998-12-02 03:32:20 +03:00
|
|
|
nsLayoutAtoms::AddrefAtoms();
|
1998-07-31 09:54:59 +04:00
|
|
|
mCompatibilityMode = eCompatibility_NavQuirks;
|
1998-07-25 05:11:49 +04:00
|
|
|
|
1998-11-06 19:16:01 +03:00
|
|
|
#ifdef _WIN32
|
|
|
|
// XXX This needs to be elsewhere, e.g., part of nsIDeviceContext
|
|
|
|
mDefaultColor = ::GetSysColor(COLOR_WINDOWTEXT);
|
|
|
|
mDefaultBackgroundColor = ::GetSysColor(COLOR_WINDOW);
|
|
|
|
#else
|
1998-07-17 09:41:41 +04:00
|
|
|
mDefaultColor = NS_RGB(0x00, 0x00, 0x00);
|
|
|
|
mDefaultBackgroundColor = NS_RGB(0xFF, 0xFF, 0xFF);
|
1998-11-06 19:16:01 +03:00
|
|
|
#endif
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsPresContext::~nsPresContext()
|
|
|
|
{
|
|
|
|
mShell = nsnull;
|
|
|
|
|
1998-11-26 21:10:10 +03:00
|
|
|
Stop();
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
if (nsnull != mImageGroup) {
|
1998-08-18 05:43:35 +04:00
|
|
|
// Interrupt any loading images. This also stops all looping
|
|
|
|
// image animations.
|
|
|
|
mImageGroup->Interrupt();
|
1998-04-14 00:24:54 +04:00
|
|
|
NS_RELEASE(mImageGroup);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IF_RELEASE(mLinkHandler);
|
|
|
|
NS_IF_RELEASE(mContainer);
|
1998-11-18 08:25:26 +03:00
|
|
|
|
|
|
|
if (nsnull != mEventManager) {
|
|
|
|
mEventManager->SetPresContext(nsnull);
|
|
|
|
NS_RELEASE(mEventManager);
|
|
|
|
}
|
|
|
|
|
1998-06-25 08:24:45 +04:00
|
|
|
NS_IF_RELEASE(mDeviceContext);
|
1998-11-06 19:16:01 +03:00
|
|
|
// Unregister preference callbacks
|
1998-11-13 05:47:33 +03:00
|
|
|
if (nsnull != mPrefs) {
|
|
|
|
mPrefs->UnregisterCallback("browser.", PrefChangedCallback, (void*)this);
|
|
|
|
mPrefs->UnregisterCallback("intl.font2.", PrefChangedCallback, (void*)this);
|
|
|
|
}
|
1998-07-31 09:54:59 +04:00
|
|
|
NS_IF_RELEASE(mPrefs);
|
1998-09-05 07:52:40 +04:00
|
|
|
NS_IF_RELEASE(mBaseURL);
|
1998-12-02 03:32:20 +03:00
|
|
|
nsLayoutAtoms::ReleaseAtoms();
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-05-09 07:22:01 +04:00
|
|
|
nsrefcnt
|
|
|
|
nsPresContext::AddRef(void)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
return ++mRefCnt;
|
|
|
|
}
|
|
|
|
|
1998-05-09 07:22:01 +04:00
|
|
|
nsrefcnt
|
|
|
|
nsPresContext::Release(void)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(0 != mRefCnt, "bad refcnt");
|
|
|
|
if (--mRefCnt == 0) {
|
|
|
|
delete this;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return mRefCnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_QUERY_INTERFACE(nsPresContext, kIPresContextIID);
|
|
|
|
|
1998-11-06 19:16:01 +03:00
|
|
|
void
|
|
|
|
nsPresContext::GetUserPreferences()
|
|
|
|
{
|
1999-04-03 00:41:58 +04:00
|
|
|
PRInt32 prefInt;
|
1998-11-06 19:16:01 +03:00
|
|
|
char prefChar[512];
|
|
|
|
int charSize = sizeof(prefChar);
|
|
|
|
|
|
|
|
if (NS_OK == mPrefs->GetIntPref("browser.base_font_scaler", &prefInt)) {
|
|
|
|
mFontScaler = prefInt;
|
|
|
|
}
|
|
|
|
|
1999-02-17 18:52:02 +03:00
|
|
|
|
|
|
|
if (NS_OK == mPrefs->GetIntPref("intl.character_set", &prefInt)) {
|
|
|
|
prefInt &= 0x07ff;
|
|
|
|
} else {
|
|
|
|
prefInt = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoString startKey("intl.font");
|
|
|
|
startKey.Append((PRInt32)prefInt, 10);
|
|
|
|
|
|
|
|
char keychar[256];
|
|
|
|
|
1998-11-06 19:16:01 +03:00
|
|
|
// XXX these font prefs strings don't take font encoding into account
|
1999-02-17 18:52:02 +03:00
|
|
|
// with the following change, it will depend on the intl.character_set to load the font face name and size
|
|
|
|
// It still need to be improve, but now QA can have change the intl.character_set value to switch different default font face
|
|
|
|
|
|
|
|
nsAutoString key(startKey);
|
|
|
|
key.Append(".win.prop_font");
|
|
|
|
|
|
|
|
key.ToCString(keychar, 256);
|
|
|
|
if (NS_OK == mPrefs->GetCharPref(keychar, &(prefChar[0]), &charSize)) {
|
1998-11-06 19:16:01 +03:00
|
|
|
mDefaultFont.name = prefChar;
|
|
|
|
}
|
1999-02-17 18:52:02 +03:00
|
|
|
|
|
|
|
key = startKey;
|
|
|
|
key.Append(".win.prop_size");
|
|
|
|
key.ToCString(keychar, 256);
|
|
|
|
if (NS_OK == mPrefs->GetIntPref(keychar, &prefInt)) {
|
1998-11-06 19:16:01 +03:00
|
|
|
mDefaultFont.size = NSIntPointsToTwips(prefInt);
|
|
|
|
}
|
1999-02-17 18:52:02 +03:00
|
|
|
|
|
|
|
key = startKey;
|
|
|
|
key.Append(".win.fixed_font");
|
|
|
|
key.ToCString(keychar, 256);
|
|
|
|
|
|
|
|
if (NS_OK == mPrefs->GetCharPref(keychar, &(prefChar[0]), &charSize)) {
|
1998-11-06 19:16:01 +03:00
|
|
|
mDefaultFixedFont.name = prefChar;
|
|
|
|
}
|
1999-02-17 18:52:02 +03:00
|
|
|
|
|
|
|
key = startKey;
|
|
|
|
key.Append(".win.fixed_size");
|
|
|
|
key.ToCString(keychar, 256);
|
|
|
|
if (NS_OK == mPrefs->GetIntPref(keychar, &prefInt)) {
|
1998-11-06 19:16:01 +03:00
|
|
|
mDefaultFixedFont.size = NSIntPointsToTwips(prefInt);
|
|
|
|
}
|
1999-02-17 18:52:02 +03:00
|
|
|
|
1998-11-06 19:16:01 +03:00
|
|
|
if (NS_OK == mPrefs->GetIntPref("nglayout.compatibility.mode", &prefInt)) {
|
|
|
|
mCompatibilityMode = (enum nsCompatibility)prefInt; // bad cast
|
|
|
|
}
|
|
|
|
|
1999-03-03 01:43:26 +03:00
|
|
|
if (NS_OK == mPrefs->GetIntPref("nglayout.widget.mode", &prefInt)) {
|
|
|
|
mWidgetRenderingMode = (enum nsWidgetRendering)prefInt; // bad cast
|
|
|
|
}
|
|
|
|
|
1998-11-06 19:16:01 +03:00
|
|
|
PRBool usePrefColors = PR_TRUE;
|
|
|
|
#ifdef _WIN32
|
1999-04-03 00:41:58 +04:00
|
|
|
PRBool boolPref;
|
1998-11-06 19:16:01 +03:00
|
|
|
// XXX Is Windows the only platform that uses this?
|
|
|
|
if (NS_OK == mPrefs->GetBoolPref("browser.wfe.use_windows_colors", &boolPref)) {
|
1999-04-03 00:41:58 +04:00
|
|
|
usePrefColors = !boolPref;
|
1998-11-06 19:16:01 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (usePrefColors) {
|
1999-04-03 00:41:58 +04:00
|
|
|
PRUint32 colorPref;
|
1998-11-06 19:16:01 +03:00
|
|
|
if (NS_OK == mPrefs->GetColorPrefDWord("browser.foreground_color", &colorPref)) {
|
|
|
|
mDefaultColor = (nscolor)colorPref;
|
|
|
|
}
|
|
|
|
if (NS_OK == mPrefs->GetColorPrefDWord("browser.background_color", &colorPref)) {
|
|
|
|
mDefaultBackgroundColor = (nscolor)colorPref;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsPresContext::PreferenceChanged(const char* aPrefName)
|
|
|
|
{
|
|
|
|
// Initialize our state from the user preferences
|
|
|
|
GetUserPreferences();
|
|
|
|
|
|
|
|
// Have the root frame's style context remap its style based on the
|
|
|
|
// user preferences
|
|
|
|
nsIFrame* rootFrame;
|
|
|
|
nsIStyleContext* rootStyleContext;
|
|
|
|
|
1999-02-12 20:45:58 +03:00
|
|
|
mShell->GetRootFrame(&rootFrame);
|
1998-11-06 19:16:01 +03:00
|
|
|
if (nsnull != rootFrame) {
|
1999-02-10 03:42:56 +03:00
|
|
|
rootFrame->GetStyleContext(&rootStyleContext);
|
1998-11-06 19:16:01 +03:00
|
|
|
rootStyleContext->RemapStyle(this);
|
|
|
|
NS_RELEASE(rootStyleContext);
|
|
|
|
|
|
|
|
// Force a reflow of the root frame
|
1998-11-06 19:24:21 +03:00
|
|
|
// XXX We really should only do a reflow if a preference that affects
|
|
|
|
// formatting changed, e.g., a font change. If it's just a color change
|
|
|
|
// then we only need to repaint...
|
1998-11-06 19:16:01 +03:00
|
|
|
mShell->StyleChangeReflow();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-11-26 21:10:10 +03:00
|
|
|
NS_IMETHODIMP
|
1998-07-31 09:54:59 +04:00
|
|
|
nsPresContext::Init(nsIDeviceContext* aDeviceContext, nsIPref* aPrefs)
|
1998-06-25 08:24:45 +04:00
|
|
|
{
|
|
|
|
NS_ASSERTION(!(mInitialized == PR_TRUE), "attempt to reinit pres context");
|
|
|
|
|
|
|
|
mDeviceContext = aDeviceContext;
|
|
|
|
NS_IF_ADDREF(mDeviceContext);
|
|
|
|
|
1998-07-31 09:54:59 +04:00
|
|
|
mPrefs = aPrefs;
|
|
|
|
NS_IF_ADDREF(mPrefs);
|
|
|
|
|
1998-11-06 19:16:01 +03:00
|
|
|
if (nsnull != mPrefs) {
|
|
|
|
// Register callbacks so we're notified when the preferences change
|
|
|
|
mPrefs->RegisterCallback("browser.", PrefChangedCallback, (void*)this);
|
|
|
|
mPrefs->RegisterCallback("intl.font2.", PrefChangedCallback, (void*)this);
|
1998-07-31 09:54:59 +04:00
|
|
|
|
1998-11-06 19:16:01 +03:00
|
|
|
// Initialize our state from the user preferences
|
|
|
|
GetUserPreferences();
|
1998-07-31 09:54:59 +04:00
|
|
|
}
|
|
|
|
|
1998-06-25 08:24:45 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
mInitialized = PR_TRUE;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// Note: We don't hold a reference on the shell; it has a reference to
|
|
|
|
// us
|
1998-11-26 21:10:10 +03:00
|
|
|
NS_IMETHODIMP
|
1998-05-09 07:22:01 +04:00
|
|
|
nsPresContext::SetShell(nsIPresShell* aShell)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-09-05 07:52:40 +04:00
|
|
|
NS_IF_RELEASE(mBaseURL);
|
1998-04-14 00:24:54 +04:00
|
|
|
mShell = aShell;
|
1998-09-05 07:52:40 +04:00
|
|
|
if (nsnull != mShell) {
|
1999-02-12 20:45:58 +03:00
|
|
|
nsCOMPtr<nsIDocument> doc;
|
|
|
|
if (NS_SUCCEEDED(mShell->GetDocument(getter_AddRefs(doc)))) {
|
1999-02-12 21:41:26 +03:00
|
|
|
NS_ASSERTION(doc, "expect document here");
|
|
|
|
if (doc) {
|
1999-02-12 20:45:58 +03:00
|
|
|
doc->GetBaseURL(mBaseURL);
|
|
|
|
}
|
1998-09-05 07:52:40 +04:00
|
|
|
}
|
|
|
|
}
|
1998-11-26 21:10:10 +03:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetShell(nsIPresShell** aResult)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_PRECONDITION(nsnull != aResult, "null ptr");
|
|
|
|
if (nsnull == aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
*aResult = mShell;
|
1998-05-09 07:22:01 +04:00
|
|
|
NS_IF_ADDREF(mShell);
|
1999-02-12 20:45:58 +03:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-07-31 09:54:59 +04:00
|
|
|
NS_IMETHODIMP
|
1999-02-12 20:45:58 +03:00
|
|
|
nsPresContext::GetPrefs(nsIPref** aResult)
|
1998-07-31 09:54:59 +04:00
|
|
|
{
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_PRECONDITION(nsnull != aResult, "null ptr");
|
|
|
|
if (nsnull == aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
*aResult = mPrefs;
|
|
|
|
NS_IF_ADDREF(mPrefs);
|
1998-07-31 09:54:59 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-02-12 20:45:58 +03:00
|
|
|
nsPresContext::GetCompatibilityMode(nsCompatibility* aResult)
|
1998-07-31 09:54:59 +04:00
|
|
|
{
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_PRECONDITION(nsnull != aResult, "null ptr");
|
|
|
|
if (nsnull == aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
*aResult = mCompatibilityMode;
|
1998-07-31 09:54:59 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-03-03 01:43:26 +03:00
|
|
|
|
1998-07-31 09:54:59 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::SetCompatibilityMode(nsCompatibility aMode)
|
|
|
|
{
|
|
|
|
mCompatibilityMode = aMode;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-03-03 01:43:26 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetWidgetRenderingMode(nsWidgetRendering* aResult)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aResult, "null ptr");
|
|
|
|
if (nsnull == aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
*aResult = mWidgetRenderingMode;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::SetWidgetRenderingMode(nsWidgetRendering aMode)
|
|
|
|
{
|
|
|
|
mWidgetRenderingMode = aMode;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-09-05 07:52:40 +04:00
|
|
|
NS_IMETHODIMP
|
1999-02-12 20:45:58 +03:00
|
|
|
nsPresContext::GetBaseURL(nsIURL** aResult)
|
1998-09-05 07:52:40 +04:00
|
|
|
{
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_PRECONDITION(nsnull != aResult, "null ptr");
|
|
|
|
if (nsnull == aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
*aResult = mBaseURL;
|
1998-09-05 07:52:40 +04:00
|
|
|
NS_IF_ADDREF(mBaseURL);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-02-11 18:53:26 +03:00
|
|
|
NS_IMETHODIMP
|
1998-04-14 00:24:54 +04:00
|
|
|
nsPresContext::ResolveStyleContextFor(nsIContent* aContent,
|
1998-11-03 23:20:07 +03:00
|
|
|
nsIStyleContext* aParentContext,
|
1999-02-12 20:45:58 +03:00
|
|
|
PRBool aForceUnique,
|
|
|
|
nsIStyleContext** aResult)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_PRECONDITION(nsnull != aResult, "null ptr");
|
|
|
|
if (nsnull == aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-02-12 20:45:58 +03:00
|
|
|
nsIStyleContext* result = nsnull;
|
|
|
|
nsCOMPtr<nsIStyleSet> set;
|
|
|
|
nsresult rv = mShell->GetStyleSet(getter_AddRefs(set));
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
1999-02-12 21:41:26 +03:00
|
|
|
if (set) {
|
1999-02-12 20:45:58 +03:00
|
|
|
result = set->ResolveStyleFor(this, aContent, aParentContext,
|
|
|
|
aForceUnique);
|
|
|
|
if (nsnull == result) {
|
|
|
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*aResult = result;
|
|
|
|
return rv;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-02-11 18:53:26 +03:00
|
|
|
NS_IMETHODIMP
|
1998-11-03 23:20:07 +03:00
|
|
|
nsPresContext::ResolvePseudoStyleContextFor(nsIContent* aParentContent,
|
|
|
|
nsIAtom* aPseudoTag,
|
|
|
|
nsIStyleContext* aParentContext,
|
1999-02-12 20:45:58 +03:00
|
|
|
PRBool aForceUnique,
|
|
|
|
nsIStyleContext** aResult)
|
1998-05-19 01:06:33 +04:00
|
|
|
{
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_PRECONDITION(nsnull != aResult, "null ptr");
|
|
|
|
if (nsnull == aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
1998-05-19 01:06:33 +04:00
|
|
|
}
|
|
|
|
|
1999-02-12 20:45:58 +03:00
|
|
|
nsIStyleContext* result = nsnull;
|
|
|
|
nsCOMPtr<nsIStyleSet> set;
|
|
|
|
nsresult rv = mShell->GetStyleSet(getter_AddRefs(set));
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
1999-02-12 21:41:26 +03:00
|
|
|
if (set) {
|
1999-02-12 20:45:58 +03:00
|
|
|
result = set->ResolvePseudoStyleFor(this, aParentContent, aPseudoTag,
|
|
|
|
aParentContext, aForceUnique);
|
|
|
|
if (nsnull == result) {
|
|
|
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*aResult = result;
|
|
|
|
return rv;
|
1998-05-19 01:06:33 +04:00
|
|
|
}
|
|
|
|
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_IMETHODIMP
|
1998-11-03 23:20:07 +03:00
|
|
|
nsPresContext::ProbePseudoStyleContextFor(nsIContent* aParentContent,
|
|
|
|
nsIAtom* aPseudoTag,
|
|
|
|
nsIStyleContext* aParentContext,
|
1999-02-12 20:45:58 +03:00
|
|
|
PRBool aForceUnique,
|
|
|
|
nsIStyleContext** aResult)
|
1998-05-19 01:06:33 +04:00
|
|
|
{
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_PRECONDITION(nsnull != aResult, "null ptr");
|
|
|
|
if (nsnull == aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
1998-05-19 01:06:33 +04:00
|
|
|
}
|
|
|
|
|
1999-02-12 20:45:58 +03:00
|
|
|
nsIStyleContext* result = nsnull;
|
|
|
|
nsCOMPtr<nsIStyleSet> set;
|
|
|
|
nsresult rv = mShell->GetStyleSet(getter_AddRefs(set));
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
1999-02-12 21:41:26 +03:00
|
|
|
if (set) {
|
1999-02-12 20:45:58 +03:00
|
|
|
result = set->ProbePseudoStyleFor(this, aParentContent, aPseudoTag,
|
|
|
|
aParentContext, aForceUnique);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*aResult = result;
|
|
|
|
return rv;
|
1998-05-19 01:06:33 +04:00
|
|
|
}
|
|
|
|
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetMetricsFor(const nsFont& aFont, nsIFontMetrics** aResult)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_PRECONDITION(nsnull != aResult, "null ptr");
|
|
|
|
if (nsnull == aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1998-08-28 00:43:04 +04:00
|
|
|
|
1999-02-12 20:45:58 +03:00
|
|
|
nsIFontMetrics* metrics = nsnull;
|
|
|
|
if (nsnull != mDeviceContext) {
|
1998-08-28 00:43:04 +04:00
|
|
|
mDeviceContext->GetMetricsFor(aFont, metrics);
|
|
|
|
}
|
1999-02-12 20:45:58 +03:00
|
|
|
*aResult = metrics;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetDefaultFont(nsFont& aResult)
|
|
|
|
{
|
|
|
|
aResult = mDefaultFont;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetDefaultFixedFont(nsFont& aResult)
|
|
|
|
{
|
|
|
|
aResult = mDefaultFixedFont;
|
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-05-09 07:22:01 +04:00
|
|
|
const nsFont&
|
1999-02-12 20:45:58 +03:00
|
|
|
nsPresContext::GetDefaultFontDeprecated()
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
return mDefaultFont;
|
|
|
|
}
|
|
|
|
|
1998-07-17 09:41:41 +04:00
|
|
|
const nsFont&
|
1999-02-12 20:45:58 +03:00
|
|
|
nsPresContext::GetDefaultFixedFontDeprecated()
|
1998-07-17 09:41:41 +04:00
|
|
|
{
|
|
|
|
return mDefaultFixedFont;
|
|
|
|
}
|
|
|
|
|
1998-11-26 21:10:10 +03:00
|
|
|
NS_IMETHODIMP
|
1999-02-12 20:45:58 +03:00
|
|
|
nsPresContext::GetFontScaler(PRInt32* aResult)
|
1998-07-25 05:11:49 +04:00
|
|
|
{
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_PRECONDITION(nsnull != aResult, "null ptr");
|
|
|
|
if (nsnull == aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aResult = mFontScaler;
|
1998-11-26 21:10:10 +03:00
|
|
|
return NS_OK;
|
1998-07-25 05:11:49 +04:00
|
|
|
}
|
|
|
|
|
1998-11-26 21:10:10 +03:00
|
|
|
NS_IMETHODIMP
|
1998-07-25 05:11:49 +04:00
|
|
|
nsPresContext::SetFontScaler(PRInt32 aScaler)
|
|
|
|
{
|
|
|
|
mFontScaler = aScaler;
|
1998-11-26 21:10:10 +03:00
|
|
|
return NS_OK;
|
1998-07-25 05:11:49 +04:00
|
|
|
}
|
|
|
|
|
1998-07-31 09:54:59 +04:00
|
|
|
NS_IMETHODIMP
|
1999-02-12 20:45:58 +03:00
|
|
|
nsPresContext::GetDefaultColor(nscolor* aResult)
|
1998-07-17 09:41:41 +04:00
|
|
|
{
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_PRECONDITION(nsnull != aResult, "null ptr");
|
|
|
|
if (nsnull == aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aResult = mDefaultColor;
|
1998-07-17 09:41:41 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-31 09:54:59 +04:00
|
|
|
NS_IMETHODIMP
|
1999-02-12 20:45:58 +03:00
|
|
|
nsPresContext::GetDefaultBackgroundColor(nscolor* aResult)
|
1998-07-17 09:41:41 +04:00
|
|
|
{
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_PRECONDITION(nsnull != aResult, "null ptr");
|
|
|
|
if (nsnull == aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aResult = mDefaultBackgroundColor;
|
1998-07-17 09:41:41 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-31 09:54:59 +04:00
|
|
|
NS_IMETHODIMP
|
1999-02-12 20:45:58 +03:00
|
|
|
nsPresContext::SetDefaultColor(nscolor aColor)
|
1998-07-23 21:57:00 +04:00
|
|
|
{
|
|
|
|
mDefaultColor = aColor;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-31 09:54:59 +04:00
|
|
|
NS_IMETHODIMP
|
1999-02-12 20:45:58 +03:00
|
|
|
nsPresContext::SetDefaultBackgroundColor(nscolor aColor)
|
1998-07-23 21:57:00 +04:00
|
|
|
{
|
|
|
|
mDefaultBackgroundColor = aColor;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-11-26 21:10:10 +03:00
|
|
|
NS_IMETHODIMP
|
1998-05-22 22:36:40 +04:00
|
|
|
nsPresContext::GetVisibleArea(nsRect& aResult)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-05-22 22:36:40 +04:00
|
|
|
aResult = mVisibleArea;
|
1998-11-26 21:10:10 +03:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-11-26 21:10:10 +03:00
|
|
|
NS_IMETHODIMP
|
1998-05-09 07:22:01 +04:00
|
|
|
nsPresContext::SetVisibleArea(const nsRect& r)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
mVisibleArea = r;
|
1998-11-26 21:10:10 +03:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetPixelsToTwips(float* aResult) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_PRECONDITION(nsnull != aResult, "null ptr");
|
|
|
|
if (nsnull == aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
float p2t = 1.0f;
|
1998-05-09 07:22:01 +04:00
|
|
|
if (nsnull != mDeviceContext) {
|
1998-08-28 02:45:35 +04:00
|
|
|
mDeviceContext->GetDevUnitsToAppUnits(p2t);
|
1998-05-09 07:22:01 +04:00
|
|
|
}
|
1999-02-12 20:45:58 +03:00
|
|
|
*aResult = p2t;
|
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetTwipsToPixels(float* aResult) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_PRECONDITION(nsnull != aResult, "null ptr");
|
|
|
|
if (nsnull == aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
float app2dev = 1.0f;
|
1998-05-09 07:22:01 +04:00
|
|
|
if (nsnull != mDeviceContext) {
|
1998-08-28 02:45:35 +04:00
|
|
|
mDeviceContext->GetAppUnitsToDevUnits(app2dev);
|
1998-05-09 07:22:01 +04:00
|
|
|
}
|
1999-02-12 20:45:58 +03:00
|
|
|
*aResult = app2dev;
|
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetScaledPixelsToTwips(float* aResult) const
|
1998-11-14 04:52:27 +03:00
|
|
|
{
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_PRECONDITION(nsnull != aResult, "null ptr");
|
|
|
|
if (nsnull == aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
float scale = 1.0f;
|
1998-11-14 04:52:27 +03:00
|
|
|
if (nsnull != mDeviceContext)
|
|
|
|
{
|
1999-02-12 20:45:58 +03:00
|
|
|
float p2t;
|
1998-11-14 04:52:27 +03:00
|
|
|
mDeviceContext->GetDevUnitsToAppUnits(p2t);
|
|
|
|
mDeviceContext->GetCanonicalPixelScale(scale);
|
1999-02-12 20:45:58 +03:00
|
|
|
scale = p2t * scale;
|
1998-11-14 04:52:27 +03:00
|
|
|
}
|
1999-02-12 20:45:58 +03:00
|
|
|
*aResult = scale;
|
1998-11-14 04:52:27 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetDeviceContext(nsIDeviceContext** aResult) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_PRECONDITION(nsnull != aResult, "null ptr");
|
|
|
|
if (nsnull == aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
*aResult = mDeviceContext;
|
1998-04-14 00:24:54 +04:00
|
|
|
NS_IF_ADDREF(mDeviceContext);
|
1999-02-12 20:45:58 +03:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-07-31 09:54:59 +04:00
|
|
|
NS_IMETHODIMP
|
1999-02-12 20:45:58 +03:00
|
|
|
nsPresContext::GetImageGroup(nsIImageGroup** aResult)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_PRECONDITION(nsnull != aResult, "null ptr");
|
|
|
|
if (nsnull == aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsnull == mImageGroup) {
|
1998-05-09 07:22:01 +04:00
|
|
|
// Create image group
|
1998-05-12 02:56:58 +04:00
|
|
|
nsresult rv = NS_NewImageGroup(&mImageGroup);
|
1998-05-09 07:22:01 +04:00
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initialize the image group
|
1998-12-16 08:40:20 +03:00
|
|
|
nsIURLGroup* urlGroup;
|
|
|
|
rv = mBaseURL->GetURLGroup(&urlGroup);
|
|
|
|
if (rv == NS_OK)
|
|
|
|
rv = mImageGroup->Init(mDeviceContext, urlGroup);
|
1998-10-02 01:44:16 +04:00
|
|
|
NS_IF_RELEASE(urlGroup);
|
1998-05-09 07:22:01 +04:00
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1999-02-12 20:45:58 +03:00
|
|
|
|
|
|
|
*aResult = mImageGroup;
|
1998-05-12 02:56:58 +04:00
|
|
|
NS_IF_ADDREF(mImageGroup);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-07-31 09:54:59 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::StartLoadImage(const nsString& aURL,
|
|
|
|
const nscolor* aBackgroundColor,
|
|
|
|
nsIFrame* aTargetFrame,
|
1999-02-26 20:02:37 +03:00
|
|
|
const nsSize& aDesiredSize,
|
1998-09-26 22:36:59 +04:00
|
|
|
nsFrameImageLoaderCB aCallBack,
|
1998-07-31 09:54:59 +04:00
|
|
|
PRBool aNeedSizeUpdate,
|
1999-02-04 20:03:46 +03:00
|
|
|
PRBool aNeedErrorNotification,
|
1999-02-12 20:45:58 +03:00
|
|
|
nsIFrameImageLoader** aLoaderResult)
|
1998-05-12 02:56:58 +04:00
|
|
|
{
|
1998-11-26 21:10:10 +03:00
|
|
|
if (mStopped) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-11-23 20:18:34 +03:00
|
|
|
#ifdef NOISY_IMAGES
|
|
|
|
nsIDocument* doc = mShell->GetDocument();
|
|
|
|
if (nsnull != doc) {
|
|
|
|
nsIURL* url = doc->GetDocumentURL();
|
|
|
|
if (nsnull != url) {
|
|
|
|
printf("%s: ", url->GetSpec());
|
|
|
|
NS_RELEASE(url);
|
|
|
|
}
|
|
|
|
NS_RELEASE(doc);
|
|
|
|
}
|
1998-11-26 21:10:10 +03:00
|
|
|
printf("%p: start load for %p (", this, aTargetFrame);
|
1998-11-23 20:18:34 +03:00
|
|
|
fputs(aURL, stdout);
|
|
|
|
printf(")\n");
|
|
|
|
#endif
|
|
|
|
|
1999-02-12 20:45:58 +03:00
|
|
|
*aLoaderResult = nsnull;
|
1998-07-31 09:54:59 +04:00
|
|
|
|
1998-05-12 02:56:58 +04:00
|
|
|
// Lookup image request in our loaders array. Note that we need
|
|
|
|
// to get a loader that is observing the same image and that has
|
|
|
|
// the same value for aNeedSizeUpdate.
|
1998-05-09 07:22:01 +04:00
|
|
|
PRInt32 i, n = mImageLoaders.Count();
|
1998-05-12 02:56:58 +04:00
|
|
|
nsIFrameImageLoader* loader;
|
|
|
|
nsAutoString loaderURL;
|
1998-05-09 07:22:01 +04:00
|
|
|
for (i = 0; i < n; i++) {
|
1998-05-12 02:56:58 +04:00
|
|
|
loader = (nsIFrameImageLoader*) mImageLoaders.ElementAt(i);
|
|
|
|
nsIFrame* targetFrame;
|
|
|
|
loader->GetTargetFrame(targetFrame);
|
|
|
|
if (targetFrame == aTargetFrame) {
|
|
|
|
loader->GetURL(loaderURL);
|
|
|
|
// XXX case doesn't matter for all of the url so using Equals
|
|
|
|
// isn't quite right
|
|
|
|
if (aURL.Equals(loaderURL)) {
|
|
|
|
// Make sure the size update flags are the same, if not keep looking
|
|
|
|
PRIntn status;
|
|
|
|
loader->GetImageLoadStatus(status);
|
|
|
|
PRBool wantSize = 0 != (status & NS_IMAGE_LOAD_STATUS_SIZE_REQUESTED);
|
|
|
|
if (aNeedSizeUpdate == wantSize) {
|
|
|
|
NS_ADDREF(loader);
|
1999-02-12 20:45:58 +03:00
|
|
|
*aLoaderResult = loader;
|
1998-05-12 02:56:58 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create image group if needed
|
|
|
|
nsresult rv;
|
|
|
|
if (nsnull == mImageGroup) {
|
1999-02-12 20:45:58 +03:00
|
|
|
nsCOMPtr<nsIImageGroup> group;
|
|
|
|
rv = GetImageGroup(getter_AddRefs(group));
|
1998-05-12 02:56:58 +04:00
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-05-09 07:22:01 +04:00
|
|
|
// We haven't seen that image before. Create a new loader and
|
|
|
|
// start it going.
|
1998-05-12 02:56:58 +04:00
|
|
|
rv = NS_NewFrameImageLoader(&loader);
|
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
1998-08-19 22:07:27 +04:00
|
|
|
mImageLoaders.AppendElement(loader);
|
1998-06-03 02:05:45 +04:00
|
|
|
|
1998-07-16 08:34:59 +04:00
|
|
|
rv = loader->Init(this, mImageGroup, aURL, aBackgroundColor, aTargetFrame,
|
1999-02-26 20:02:37 +03:00
|
|
|
aDesiredSize, aCallBack, aNeedSizeUpdate,
|
|
|
|
aNeedErrorNotification);
|
1998-06-03 02:05:45 +04:00
|
|
|
if (NS_OK != rv) {
|
1998-08-19 22:07:27 +04:00
|
|
|
mImageLoaders.RemoveElement(loader);
|
1998-08-18 05:43:35 +04:00
|
|
|
NS_RELEASE(loader);
|
1998-06-03 02:05:45 +04:00
|
|
|
return rv;
|
|
|
|
}
|
1999-02-12 20:45:58 +03:00
|
|
|
|
1998-08-18 05:43:35 +04:00
|
|
|
// Return the loader
|
|
|
|
NS_ADDREF(loader);
|
1999-02-12 20:45:58 +03:00
|
|
|
*aLoaderResult = loader;
|
1998-05-09 07:22:01 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-11-26 21:10:10 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::Stop(void)
|
|
|
|
{
|
|
|
|
PRInt32 n = mImageLoaders.Count();
|
|
|
|
for (PRInt32 i = 0; i < n; i++) {
|
|
|
|
nsIFrameImageLoader* loader;
|
|
|
|
loader = (nsIFrameImageLoader*) mImageLoaders.ElementAt(i);
|
|
|
|
loader->StopImageLoad();
|
|
|
|
NS_RELEASE(loader);
|
|
|
|
}
|
|
|
|
mImageLoaders.Clear();
|
|
|
|
mStopped = PR_TRUE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-31 09:54:59 +04:00
|
|
|
NS_IMETHODIMP
|
1998-05-09 07:22:01 +04:00
|
|
|
nsPresContext::StopLoadImage(nsIFrame* aForFrame)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-05-12 02:56:58 +04:00
|
|
|
nsIFrameImageLoader* loader;
|
1998-05-09 07:22:01 +04:00
|
|
|
PRInt32 i, n = mImageLoaders.Count();
|
|
|
|
for (i = 0; i < n;) {
|
1998-05-12 02:56:58 +04:00
|
|
|
loader = (nsIFrameImageLoader*) mImageLoaders.ElementAt(i);
|
|
|
|
nsIFrame* loaderFrame;
|
|
|
|
loader->GetTargetFrame(loaderFrame);
|
|
|
|
if (loaderFrame == aForFrame) {
|
1998-11-23 20:18:34 +03:00
|
|
|
#ifdef NOISY_IMAGES
|
|
|
|
nsIDocument* doc = mShell->GetDocument();
|
|
|
|
if (nsnull != doc) {
|
|
|
|
nsIURL* url = doc->GetDocumentURL();
|
|
|
|
if (nsnull != url) {
|
|
|
|
printf("%s: ", url->GetSpec());
|
|
|
|
NS_RELEASE(url);
|
|
|
|
}
|
|
|
|
NS_RELEASE(doc);
|
|
|
|
}
|
1998-11-26 21:10:10 +03:00
|
|
|
printf("%p: stop load for %p\n", this, aForFrame);
|
1998-11-23 20:18:34 +03:00
|
|
|
#endif
|
1998-05-12 05:30:15 +04:00
|
|
|
loader->StopImageLoad();
|
1998-05-12 02:56:58 +04:00
|
|
|
NS_RELEASE(loader);
|
|
|
|
mImageLoaders.RemoveElementAt(i);
|
|
|
|
n--;
|
|
|
|
continue;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
1998-05-09 07:22:01 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::SetLinkHandler(nsILinkHandler* aHandler)
|
1998-04-17 01:51:16 +04:00
|
|
|
{ // XXX should probably be a WEAK reference
|
1998-04-14 00:24:54 +04:00
|
|
|
NS_IF_RELEASE(mLinkHandler);
|
|
|
|
mLinkHandler = aHandler;
|
|
|
|
NS_IF_ADDREF(aHandler);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-05-09 07:22:01 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetLinkHandler(nsILinkHandler** aResult)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aResult, "null ptr");
|
|
|
|
if (nsnull == aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
*aResult = mLinkHandler;
|
|
|
|
NS_IF_ADDREF(mLinkHandler);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-05-09 07:22:01 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::SetContainer(nsISupports* aHandler)
|
1998-04-17 01:51:16 +04:00
|
|
|
{ // XXX should most likely be a WEAK reference
|
1998-04-14 00:24:54 +04:00
|
|
|
NS_IF_RELEASE(mContainer);
|
|
|
|
mContainer = aHandler;
|
|
|
|
NS_IF_ADDREF(aHandler);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-05-09 07:22:01 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetContainer(nsISupports** aResult)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aResult, "null ptr");
|
|
|
|
if (nsnull == aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
*aResult = mContainer;
|
|
|
|
NS_IF_ADDREF(mContainer);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-06-24 01:53:02 +04:00
|
|
|
|
1998-07-31 09:54:59 +04:00
|
|
|
NS_IMETHODIMP
|
1998-06-24 01:53:02 +04:00
|
|
|
nsPresContext::GetEventStateManager(nsIEventStateManager** aManager)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aManager, "null ptr");
|
|
|
|
if (nsnull == aManager) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nsnull == mEventManager) {
|
|
|
|
nsresult rv = NS_NewEventStateManager(&mEventManager);
|
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-11-18 08:25:26 +03:00
|
|
|
//Not refcnted, set null in destructor
|
|
|
|
mEventManager->SetPresContext(this);
|
|
|
|
|
1998-06-24 01:53:02 +04:00
|
|
|
*aManager = mEventManager;
|
|
|
|
NS_IF_ADDREF(mEventManager);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-09-10 23:32:14 +04:00
|
|
|
|