1998-04-14 00:24:54 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/NPL/
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1998-04-14 00:24:54 +04:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 06:40:37 +03:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
2000-03-21 18:51:59 +03:00
|
|
|
* IBM Corporation
|
|
|
|
*
|
|
|
|
* This Original Code has been modified by IBM Corporation.
|
|
|
|
* Modifications made by IBM described herein are
|
|
|
|
* Copyright (c) International Business Machines
|
|
|
|
* Corporation, 2000
|
|
|
|
*
|
|
|
|
* Modifications to Mozilla code or documentation
|
|
|
|
* identified per MPL Section 3.3
|
|
|
|
*
|
|
|
|
* Date Modified by Description of modification
|
|
|
|
* 03/20/2000 IBM Corp. BiDi - ability to change the default direction of the browser
|
|
|
|
*
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
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"
|
1999-09-04 03:35:41 +04:00
|
|
|
#include "nsIFrameManager.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsIImageGroup.h"
|
2000-12-30 22:22:22 +03:00
|
|
|
#include "nsIContent.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsIFrame.h"
|
|
|
|
#include "nsIRenderingContext.h"
|
1998-09-05 07:52:40 +04:00
|
|
|
#include "nsIURL.h"
|
|
|
|
#include "nsIDocument.h"
|
1998-11-06 19:16:01 +03:00
|
|
|
#include "nsIStyleContext.h"
|
1998-12-02 03:32:20 +03:00
|
|
|
#include "nsLayoutAtoms.h"
|
1999-09-10 09:51:08 +04:00
|
|
|
#include "nsILookAndFeel.h"
|
|
|
|
#include "nsWidgetsCID.h"
|
|
|
|
#include "nsIComponentManager.h"
|
2000-02-15 07:49:32 +03:00
|
|
|
#include "nsIURIContentListener.h"
|
|
|
|
#include "nsIInterfaceRequestor.h"
|
2000-03-02 10:13:02 +03:00
|
|
|
#include "nsIServiceManager.h"
|
2000-04-25 11:10:48 +04:00
|
|
|
#include "nsBoxLayoutState.h"
|
|
|
|
#include "nsIBox.h"
|
2000-05-16 02:05:45 +04:00
|
|
|
#include "nsIDOMElement.h"
|
|
|
|
#include "nsContentPolicyUtils.h"
|
2001-03-09 06:13:03 +03:00
|
|
|
#ifdef IBMBIDI
|
|
|
|
#include "nsBidiPresUtils.h"
|
|
|
|
#endif // IBMBIDI
|
2000-02-15 07:49:32 +03: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
|
|
|
|
}
|
|
|
|
|
2001-03-09 06:13:03 +03:00
|
|
|
#ifdef IBMBIDI
|
|
|
|
PRBool
|
|
|
|
IsVisualCharset(const nsAutoString& aCharset)
|
|
|
|
{
|
|
|
|
if (aCharset.EqualsIgnoreCase("ibm864") // Arabic//ahmed
|
|
|
|
|| aCharset.EqualsIgnoreCase("ibm862") // Hebrew
|
|
|
|
|| aCharset.EqualsIgnoreCase("iso-8859-8") ) { // Hebrew
|
|
|
|
return PR_TRUE; // visual text type
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return PR_FALSE; // logical text type
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // IBMBIDI
|
|
|
|
|
2000-07-29 02:12:45 +04:00
|
|
|
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
2001-02-20 00:50:04 +03:00
|
|
|
#include "nsContentCID.h"
|
|
|
|
static NS_DEFINE_CID(kEventStateManagerCID, NS_EVENTSTATEMANAGER_CID);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
nsPresContext::nsPresContext()
|
1999-12-08 02:27:52 +03:00
|
|
|
: mDefaultFont("serif", 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)),
|
1999-12-08 02:27:52 +03:00
|
|
|
mDefaultFixedFont("monospace", NS_FONT_STYLE_NORMAL,
|
1998-07-17 09:41:41 +04:00
|
|
|
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();
|
1999-07-07 05:21:25 +04:00
|
|
|
mCompatibilityMode = eCompatibility_Standard;
|
|
|
|
mCompatibilityLocked = PR_FALSE;
|
1999-09-09 23:43:27 +04:00
|
|
|
mWidgetRenderingMode = eWidgetRendering_Gfx;
|
2000-05-13 05:39:20 +04:00
|
|
|
mImageAnimationMode = eImageAnimation_Normal;
|
2001-01-10 02:55:27 +03:00
|
|
|
mImageAnimationModePref = eImageAnimation_Normal;
|
2000-09-21 05:20:00 +04:00
|
|
|
|
|
|
|
mStopped = PR_FALSE;
|
|
|
|
mStopChrome = PR_TRUE;
|
2000-05-13 05:39:20 +04:00
|
|
|
|
1999-11-19 10:29:13 +03:00
|
|
|
mShell = nsnull;
|
1998-07-25 05:11:49 +04:00
|
|
|
|
1998-07-17 09:41:41 +04:00
|
|
|
mDefaultColor = NS_RGB(0x00, 0x00, 0x00);
|
|
|
|
mDefaultBackgroundColor = NS_RGB(0xFF, 0xFF, 0xFF);
|
2001-01-30 07:41:49 +03:00
|
|
|
nsILookAndFeel* look = nsnull;
|
|
|
|
if (NS_SUCCEEDED(GetLookAndFeel(&look)) && look) {
|
|
|
|
look->GetColor(nsILookAndFeel::eColor_WindowForeground, mDefaultColor);
|
|
|
|
look->GetColor(nsILookAndFeel::eColor_WindowBackground, mDefaultBackgroundColor);
|
|
|
|
NS_RELEASE(look);
|
|
|
|
}
|
2000-10-11 12:33:01 +04:00
|
|
|
|
|
|
|
mUseDocumentColors = PR_TRUE;
|
|
|
|
mUseDocumentFonts = PR_TRUE;
|
|
|
|
|
|
|
|
mLinkColor = NS_RGB(0x33, 0x33, 0xFF);
|
|
|
|
mVisitedLinkColor = NS_RGB(0x66, 0x00, 0xCC);
|
|
|
|
mUnderlineLinks = PR_TRUE;
|
|
|
|
|
2001-04-10 02:17:11 +04:00
|
|
|
mUseFocusColors = PR_FALSE;
|
|
|
|
mFocusTextColor = mDefaultColor;
|
|
|
|
mFocusBackgroundColor = mDefaultBackgroundColor;
|
|
|
|
mFocusRingWidth = 1;
|
|
|
|
mFocusRingOnAnything = PR_FALSE;
|
|
|
|
|
1999-06-13 02:31:15 +04:00
|
|
|
mDefaultBackgroundImageAttachment = NS_STYLE_BG_ATTACHMENT_SCROLL;
|
|
|
|
mDefaultBackgroundImageRepeat = NS_STYLE_BG_REPEAT_XY;
|
|
|
|
mDefaultBackgroundImageOffsetX = mDefaultBackgroundImageOffsetY = 0;
|
2000-03-21 18:51:59 +03:00
|
|
|
mDefaultDirection = NS_STYLE_DIRECTION_LTR;
|
2000-09-21 02:59:20 +04:00
|
|
|
mLanguageSpecificTransformType = eLanguageSpecificTransformType_Unknown;
|
2001-01-27 17:09:34 +03:00
|
|
|
mIsRenderingOnlySelection = PR_FALSE;
|
2001-03-09 06:13:03 +03:00
|
|
|
#ifdef IBMBIDI
|
|
|
|
mIsVisual = PR_FALSE;
|
|
|
|
mBidiUtils = nsnull;
|
|
|
|
mIsBidiSystem = PR_FALSE;
|
|
|
|
mBidi = 0;
|
|
|
|
#endif // IBMBIDI
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsPresContext::~nsPresContext()
|
|
|
|
{
|
2000-06-02 03:12:26 +04:00
|
|
|
if (mShell) {
|
|
|
|
nsCOMPtr<nsIDocument> doc;
|
|
|
|
mShell->GetDocument(getter_AddRefs(doc));
|
|
|
|
if (doc) {
|
|
|
|
doc->RemoveCharSetObserver(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
mShell = nsnull;
|
|
|
|
|
1998-11-26 21:10:10 +03:00
|
|
|
Stop();
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-04-30 13:04:36 +04:00
|
|
|
if (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
|
|
|
}
|
|
|
|
|
1999-04-30 13:04:36 +04:00
|
|
|
if (mEventManager)
|
|
|
|
mEventManager->SetPresContext(nsnull); // unclear if this is needed, but can't hurt
|
1998-11-18 08:25:26 +03:00
|
|
|
|
1998-11-06 19:16:01 +03:00
|
|
|
// Unregister preference callbacks
|
1999-04-30 13:04:36 +04:00
|
|
|
if (mPrefs) {
|
2000-01-12 19:10:48 +03:00
|
|
|
mPrefs->UnregisterCallback("font.", PrefChangedCallback, (void*)this);
|
2000-06-22 09:41:11 +04:00
|
|
|
mPrefs->UnregisterCallback("browser.display.", PrefChangedCallback, (void*)this);
|
2000-10-11 12:33:01 +04:00
|
|
|
mPrefs->UnregisterCallback("browser.underline_anchors", PrefChangedCallback, (void*)this);
|
2001-03-29 11:16:06 +04:00
|
|
|
mPrefs->UnregisterCallback("browser.anchor_color", PrefChangedCallback, (void*)this);
|
2000-10-11 12:33:01 +04:00
|
|
|
mPrefs->UnregisterCallback("browser.visited_color", PrefChangedCallback, (void*)this);
|
2001-03-29 11:16:06 +04:00
|
|
|
mPrefs->UnregisterCallback("network.image.imageBehavior", PrefChangedCallback, (void*)this);
|
2001-01-10 02:55:27 +03:00
|
|
|
mPrefs->UnregisterCallback("image.animation_mode", PrefChangedCallback, (void*)this);
|
1998-11-13 05:47:33 +03:00
|
|
|
}
|
2001-03-09 06:13:03 +03:00
|
|
|
#ifdef IBMBIDI
|
|
|
|
if (mBidiUtils) {
|
|
|
|
delete mBidiUtils;
|
|
|
|
}
|
|
|
|
#endif // IBMBIDI
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2000-06-02 03:12:26 +04:00
|
|
|
NS_IMPL_ISUPPORTS2(nsPresContext, nsIPresContext, nsIObserver)
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2000-01-12 19:10:48 +03:00
|
|
|
void
|
|
|
|
nsPresContext::GetFontPreferences()
|
|
|
|
{
|
|
|
|
if (mPrefs) {
|
|
|
|
char* value = nsnull;
|
|
|
|
mPrefs->CopyCharPref("font.default", &value);
|
|
|
|
if (value) {
|
2000-04-03 15:20:35 +04:00
|
|
|
mDefaultFont.name.AssignWithConversion(value);
|
2000-06-03 13:46:12 +04:00
|
|
|
nsMemory::Free(value);
|
2000-01-12 19:10:48 +03:00
|
|
|
value = nsnull;
|
|
|
|
}
|
2000-05-06 01:04:36 +04:00
|
|
|
if (mLanguage) {
|
2000-04-03 15:20:35 +04:00
|
|
|
nsAutoString pref; pref.AssignWithConversion("font.size.variable.");
|
2000-01-12 19:10:48 +03:00
|
|
|
const PRUnichar* langGroup = nsnull;
|
2000-05-06 01:04:36 +04:00
|
|
|
nsCOMPtr<nsIAtom> langGroupAtom;
|
|
|
|
mLanguage->GetLanguageGroup(getter_AddRefs(langGroupAtom));
|
|
|
|
langGroupAtom->GetUnicode(&langGroup);
|
2000-01-12 19:10:48 +03:00
|
|
|
pref.Append(langGroup);
|
|
|
|
char name[128];
|
|
|
|
pref.ToCString(name, sizeof(name));
|
2000-01-20 04:20:11 +03:00
|
|
|
PRInt32 variableSize = 16;
|
|
|
|
mPrefs->GetIntPref(name, &variableSize);
|
2000-04-03 15:20:35 +04:00
|
|
|
pref.AssignWithConversion("font.size.fixed.");
|
2000-01-20 04:20:11 +03:00
|
|
|
pref.Append(langGroup);
|
|
|
|
pref.ToCString(name, sizeof(name));
|
2000-02-26 02:01:36 +03:00
|
|
|
PRInt32 fixedSize = 13;
|
2000-01-20 04:20:11 +03:00
|
|
|
mPrefs->GetIntPref(name, &fixedSize);
|
|
|
|
char* unit = nsnull;
|
|
|
|
mPrefs->CopyCharPref("font.size.unit", &unit);
|
|
|
|
char* defaultUnit = "px";
|
|
|
|
if (!unit) {
|
|
|
|
unit = defaultUnit;
|
2000-01-15 19:30:13 +03:00
|
|
|
}
|
2000-01-20 04:20:11 +03:00
|
|
|
if (!PL_strcmp(unit, "px")) {
|
2000-01-15 19:30:13 +03:00
|
|
|
float p2t;
|
|
|
|
GetScaledPixelsToTwips(&p2t);
|
2000-01-20 04:20:11 +03:00
|
|
|
mDefaultFont.size = NSFloatPixelsToTwips((float) variableSize, p2t);
|
|
|
|
mDefaultFixedFont.size = NSFloatPixelsToTwips((float) fixedSize, p2t);
|
2000-01-15 19:30:13 +03:00
|
|
|
}
|
2000-01-20 04:20:11 +03:00
|
|
|
else if (!PL_strcmp(unit, "pt")) {
|
|
|
|
mDefaultFont.size = NSIntPointsToTwips(variableSize);
|
|
|
|
mDefaultFixedFont.size = NSIntPointsToTwips(fixedSize);
|
2000-01-15 19:30:13 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
float p2t;
|
|
|
|
GetScaledPixelsToTwips(&p2t);
|
2000-01-20 04:20:11 +03:00
|
|
|
mDefaultFont.size = NSFloatPixelsToTwips((float) variableSize, p2t);
|
|
|
|
mDefaultFixedFont.size = NSFloatPixelsToTwips((float) fixedSize, p2t);
|
2000-01-15 19:30:13 +03:00
|
|
|
}
|
2000-01-20 04:20:11 +03:00
|
|
|
if (unit != defaultUnit) {
|
2000-06-03 13:46:12 +04:00
|
|
|
nsMemory::Free(unit);
|
2000-01-20 04:20:11 +03:00
|
|
|
unit = nsnull;
|
2000-01-15 19:30:13 +03:00
|
|
|
}
|
2000-01-12 19:10:48 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2001-04-10 02:17:11 +04:00
|
|
|
if (NS_SUCCEEDED(mPrefs->GetIntPref("browser.display.base_font_scaler", &prefInt))) {
|
1998-11-06 19:16:01 +03:00
|
|
|
mFontScaler = prefInt;
|
|
|
|
}
|
|
|
|
|
2001-04-10 02:17:11 +04:00
|
|
|
if (NS_SUCCEEDED(mPrefs->GetIntPref("nglayout.compatibility.mode", &prefInt))) {
|
1999-08-08 05:14:50 +04:00
|
|
|
// XXX this should really be a state on the webshell instead of using prefs
|
1999-07-07 05:21:25 +04:00
|
|
|
switch (prefInt) {
|
|
|
|
case 1:
|
|
|
|
mCompatibilityLocked = PR_TRUE;
|
|
|
|
mCompatibilityMode = eCompatibility_Standard;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
mCompatibilityLocked = PR_TRUE;
|
|
|
|
mCompatibilityMode = eCompatibility_NavQuirks;
|
|
|
|
break;
|
|
|
|
case 0: // auto
|
|
|
|
default:
|
|
|
|
mCompatibilityLocked = PR_FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mCompatibilityLocked = PR_FALSE; // auto
|
1998-11-06 19:16:01 +03:00
|
|
|
}
|
|
|
|
|
2001-04-10 02:17:11 +04:00
|
|
|
if (NS_SUCCEEDED(mPrefs->GetIntPref("nglayout.widget.mode", &prefInt))) {
|
1999-03-03 01:43:26 +03:00
|
|
|
mWidgetRenderingMode = (enum nsWidgetRendering)prefInt; // bad cast
|
1999-05-04 01:32:15 +04:00
|
|
|
}
|
1999-03-03 01:43:26 +03:00
|
|
|
|
2000-10-11 12:33:01 +04:00
|
|
|
// * document colors
|
1998-11-06 19:16:01 +03:00
|
|
|
PRBool usePrefColors = PR_TRUE;
|
2000-10-11 12:33:01 +04:00
|
|
|
PRUint32 colorPref;
|
1999-04-03 00:41:58 +04:00
|
|
|
PRBool boolPref;
|
2001-04-10 02:17:11 +04:00
|
|
|
if (NS_SUCCEEDED(mPrefs->GetBoolPref("browser.display.use_system_colors", &boolPref))) {
|
1999-04-03 00:41:58 +04:00
|
|
|
usePrefColors = !boolPref;
|
1998-11-06 19:16:01 +03:00
|
|
|
}
|
|
|
|
if (usePrefColors) {
|
2001-04-10 02:17:11 +04:00
|
|
|
if (NS_SUCCEEDED(mPrefs->GetColorPrefDWord("browser.display.foreground_color", &colorPref))) {
|
1998-11-06 19:16:01 +03:00
|
|
|
mDefaultColor = (nscolor)colorPref;
|
|
|
|
}
|
2001-04-10 02:17:11 +04:00
|
|
|
if (NS_SUCCEEDED(mPrefs->GetColorPrefDWord("browser.display.background_color", &colorPref))) {
|
1998-11-06 19:16:01 +03:00
|
|
|
mDefaultBackgroundColor = (nscolor)colorPref;
|
|
|
|
}
|
|
|
|
}
|
2001-03-29 11:16:06 +04:00
|
|
|
else {
|
|
|
|
// Without this here, checking the "use system colors" checkbox
|
|
|
|
// has no affect until the constructor is called again
|
|
|
|
mDefaultColor = NS_RGB(0x00, 0x00, 0x00);
|
|
|
|
mDefaultBackgroundColor = NS_RGB(0xFF, 0xFF, 0xFF);
|
|
|
|
nsCOMPtr<nsILookAndFeel> look;
|
|
|
|
if (NS_SUCCEEDED(GetLookAndFeel(getter_AddRefs(look))) && look) {
|
|
|
|
look->GetColor(nsILookAndFeel::eColor_WindowForeground, mDefaultColor);
|
|
|
|
look->GetColor(nsILookAndFeel::eColor_WindowBackground, mDefaultBackgroundColor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-04-10 02:17:11 +04:00
|
|
|
if (NS_SUCCEEDED(mPrefs->GetBoolPref("browser.display.use_document_colors", &boolPref))) {
|
2000-10-11 12:33:01 +04:00
|
|
|
mUseDocumentColors = boolPref;
|
|
|
|
}
|
|
|
|
// * link colors
|
2001-04-10 02:17:11 +04:00
|
|
|
if (NS_SUCCEEDED(mPrefs->GetBoolPref("browser.underline_anchors", &boolPref))) {
|
2000-10-11 12:33:01 +04:00
|
|
|
mUnderlineLinks = boolPref;
|
|
|
|
}
|
2001-04-10 02:17:11 +04:00
|
|
|
if (NS_SUCCEEDED(mPrefs->GetColorPrefDWord("browser.anchor_color", &colorPref))) {
|
2000-10-11 12:33:01 +04:00
|
|
|
mLinkColor = (nscolor)colorPref;
|
|
|
|
}
|
2001-04-10 02:17:11 +04:00
|
|
|
if (NS_SUCCEEDED(mPrefs->GetColorPrefDWord("browser.visited_color", &colorPref))) {
|
2000-10-11 12:33:01 +04:00
|
|
|
mVisitedLinkColor = (nscolor)colorPref;
|
|
|
|
}
|
|
|
|
|
2001-04-10 02:17:11 +04:00
|
|
|
|
|
|
|
if (NS_SUCCEEDED(mPrefs->GetBoolPref("browser.display.use_focus_colors", &boolPref))) {
|
|
|
|
mUseFocusColors = boolPref;
|
|
|
|
mFocusTextColor = mDefaultColor;
|
|
|
|
mFocusBackgroundColor = mDefaultBackgroundColor;
|
|
|
|
if (NS_SUCCEEDED(mPrefs->GetColorPrefDWord("browser.display.focus_text_color", &colorPref))) {
|
|
|
|
mFocusTextColor = (nscolor)colorPref;
|
|
|
|
}
|
|
|
|
if (NS_SUCCEEDED(mPrefs->GetColorPrefDWord("browser.display.focus_background_color", &colorPref))) {
|
|
|
|
mFocusBackgroundColor = (nscolor)colorPref;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(mPrefs->GetIntPref("browser.display.focus_ring_width", &prefInt))) {
|
|
|
|
mFocusRingWidth = prefInt;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(mPrefs->GetBoolPref("browser.display.focus_ring_on_anything", &boolPref))) {
|
|
|
|
mFocusRingOnAnything = boolPref;
|
|
|
|
}
|
|
|
|
|
2000-10-11 12:33:01 +04:00
|
|
|
// * use fonts?
|
2001-04-10 02:17:11 +04:00
|
|
|
if (NS_SUCCEEDED(mPrefs->GetIntPref("browser.display.use_document_fonts", &prefInt))) {
|
2000-10-11 12:33:01 +04:00
|
|
|
mUseDocumentFonts = prefInt == 0 ? PR_FALSE : PR_TRUE;
|
|
|
|
}
|
|
|
|
// * direction
|
2001-04-10 02:17:11 +04:00
|
|
|
if (NS_SUCCEEDED(mPrefs->GetIntPref("browser.display.direction", &prefInt))) {
|
2000-03-21 18:51:59 +03:00
|
|
|
mDefaultDirection = prefInt;
|
|
|
|
}
|
2000-10-11 12:33:01 +04:00
|
|
|
|
2000-01-12 19:10:48 +03:00
|
|
|
GetFontPreferences();
|
2001-01-10 02:55:27 +03:00
|
|
|
|
|
|
|
// * image animation
|
|
|
|
char* animatePref = 0;
|
|
|
|
nsresult rv = mPrefs->CopyCharPref("image.animation_mode", &animatePref);
|
|
|
|
if (NS_SUCCEEDED(rv) && animatePref) {
|
|
|
|
if (!nsCRT::strcmp(animatePref, "normal"))
|
|
|
|
mImageAnimationModePref = eImageAnimation_Normal;
|
|
|
|
else if (!nsCRT::strcmp(animatePref, "none"))
|
|
|
|
mImageAnimationModePref = eImageAnimation_None;
|
|
|
|
else if (!nsCRT::strcmp(animatePref, "once"))
|
|
|
|
mImageAnimationModePref = eImageAnimation_LoopOnce;
|
|
|
|
nsMemory::Free(animatePref);
|
|
|
|
}
|
1998-11-06 19:16:01 +03:00
|
|
|
}
|
|
|
|
|
2000-10-11 12:33:01 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetCachedBoolPref(PRUint32 prefType, PRBool &aValue)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
switch(prefType) {
|
|
|
|
case kPresContext_UseDocumentFonts :
|
|
|
|
aValue = mUseDocumentFonts;
|
|
|
|
rv = NS_OK;
|
|
|
|
break;
|
|
|
|
case kPresContext_UseDocumentColors:
|
|
|
|
aValue = mUseDocumentColors;
|
|
|
|
rv = NS_OK;
|
|
|
|
break;
|
|
|
|
case kPresContext_UnderlineLinks:
|
|
|
|
aValue = mUnderlineLinks;
|
|
|
|
rv = NS_OK;
|
|
|
|
break;
|
|
|
|
default :
|
|
|
|
rv = NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2000-04-03 01:52:17 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::RemapStyleAndReflow()
|
1998-11-06 19:16:01 +03:00
|
|
|
{
|
1999-09-15 02:16:42 +04:00
|
|
|
if (mShell) {
|
|
|
|
// Have the root frame's style context remap its style based on the
|
|
|
|
// user preferences
|
|
|
|
nsIFrame* rootFrame;
|
|
|
|
|
|
|
|
mShell->GetRootFrame(&rootFrame);
|
|
|
|
if (rootFrame) {
|
|
|
|
nsIStyleContext* rootStyleContext;
|
|
|
|
|
|
|
|
rootFrame->GetStyleContext(&rootStyleContext);
|
|
|
|
rootStyleContext->RemapStyle(this);
|
|
|
|
NS_RELEASE(rootStyleContext);
|
2000-04-25 11:10:48 +04:00
|
|
|
|
|
|
|
// boxes know how to coelesce style changes. So if our root frame is a box
|
|
|
|
// then tell it to handle it. If its a block we are stuck with a full top to bottom
|
|
|
|
// reflow. -EDV
|
|
|
|
nsIFrame* child = nsnull;
|
|
|
|
rootFrame->FirstChild(this, nsnull, &child);
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIBox> box = do_QueryInterface(child, &rv);
|
|
|
|
if (NS_SUCCEEDED(rv) && box) {
|
|
|
|
nsBoxLayoutState state(this);
|
|
|
|
box->MarkStyleChange(state);
|
|
|
|
} else {
|
|
|
|
// Force a reflow of the root frame
|
|
|
|
// 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...
|
|
|
|
mShell->StyleChangeReflow();
|
|
|
|
}
|
1999-09-15 02:16:42 +04:00
|
|
|
}
|
1998-11-06 19:16:01 +03:00
|
|
|
}
|
2000-04-03 01:52:17 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsPresContext::PreferenceChanged(const char* aPrefName)
|
|
|
|
{
|
|
|
|
// Initialize our state from the user preferences
|
|
|
|
GetUserPreferences();
|
2000-10-11 12:33:01 +04:00
|
|
|
|
|
|
|
// update the presShell: tell it to set the preference style rules up
|
|
|
|
if (mShell) {
|
|
|
|
mShell->SetPreferenceStyleRules(PR_TRUE);
|
|
|
|
}
|
|
|
|
|
2000-04-03 01:52:17 +04:00
|
|
|
if (mDeviceContext) {
|
|
|
|
mDeviceContext->FlushFontCache();
|
|
|
|
RemapStyleAndReflow();
|
|
|
|
}
|
1998-11-06 19:16:01 +03:00
|
|
|
}
|
|
|
|
|
1998-11-26 21:10:10 +03:00
|
|
|
NS_IMETHODIMP
|
2000-03-02 10:13:02 +03:00
|
|
|
nsPresContext::Init(nsIDeviceContext* aDeviceContext)
|
1998-06-25 08:24:45 +04:00
|
|
|
{
|
|
|
|
NS_ASSERTION(!(mInitialized == PR_TRUE), "attempt to reinit pres context");
|
|
|
|
|
1999-04-30 13:04:36 +04:00
|
|
|
mDeviceContext = dont_QueryInterface(aDeviceContext);
|
1998-07-31 09:54:59 +04:00
|
|
|
|
2000-09-14 03:57:52 +04:00
|
|
|
mLangService = do_GetService(NS_LANGUAGEATOMSERVICE_CONTRACTID);
|
|
|
|
mPrefs = do_GetService(NS_PREF_CONTRACTID);
|
1999-04-30 13:04:36 +04:00
|
|
|
if (mPrefs) {
|
1998-11-06 19:16:01 +03:00
|
|
|
// Register callbacks so we're notified when the preferences change
|
2000-01-12 19:10:48 +03:00
|
|
|
mPrefs->RegisterCallback("font.", PrefChangedCallback, (void*)this);
|
2000-06-22 09:41:11 +04:00
|
|
|
mPrefs->RegisterCallback("browser.display.", PrefChangedCallback, (void*)this);
|
2000-10-11 12:33:01 +04:00
|
|
|
mPrefs->RegisterCallback("browser.underline_anchors", PrefChangedCallback, (void*)this);
|
2001-03-29 11:16:06 +04:00
|
|
|
mPrefs->RegisterCallback("browser.anchor_color", PrefChangedCallback, (void*)this);
|
2000-10-11 12:33:01 +04:00
|
|
|
mPrefs->RegisterCallback("browser.visited_color", PrefChangedCallback, (void*)this);
|
2001-03-29 11:16:06 +04:00
|
|
|
mPrefs->RegisterCallback("network.image.imageBehavior", PrefChangedCallback, (void*)this);
|
2001-01-10 02:55:27 +03:00
|
|
|
mPrefs->RegisterCallback("image.animation_mode", 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
|
|
|
{
|
|
|
|
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-04-30 13:04:36 +04:00
|
|
|
doc->GetBaseURL(*getter_AddRefs(mBaseURL));
|
2001-01-10 02:55:27 +03:00
|
|
|
|
|
|
|
if (mBaseURL) {
|
2001-01-31 04:33:03 +03:00
|
|
|
PRBool isChrome = PR_FALSE;
|
|
|
|
PRBool isRes = PR_FALSE;
|
2001-03-13 05:02:05 +03:00
|
|
|
mBaseURL->SchemeIs("chrome", &isChrome);
|
|
|
|
mBaseURL->SchemeIs("resource", &isRes);
|
2001-01-31 04:33:03 +03:00
|
|
|
|
|
|
|
if (!isChrome && !isRes)
|
2001-01-10 02:55:27 +03:00
|
|
|
mImageAnimationMode = mImageAnimationModePref;
|
|
|
|
else
|
|
|
|
mImageAnimationMode = eImageAnimation_Normal;
|
|
|
|
}
|
|
|
|
|
2000-05-06 01:04:36 +04:00
|
|
|
if (mLangService) {
|
1999-12-08 02:27:52 +03:00
|
|
|
nsAutoString charset;
|
2000-06-02 03:12:26 +04:00
|
|
|
doc->AddCharSetObserver(this);
|
1999-12-08 02:27:52 +03:00
|
|
|
doc->GetDocumentCharacterSet(charset);
|
2000-09-21 02:59:20 +04:00
|
|
|
UpdateCharSet(charset.GetUnicode());
|
1999-12-08 02:27:52 +03:00
|
|
|
}
|
1999-02-12 20:45:58 +03:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2000-09-21 02:59:20 +04:00
|
|
|
void
|
|
|
|
nsPresContext::UpdateCharSet(const PRUnichar* aCharSet)
|
|
|
|
{
|
|
|
|
if (mLangService) {
|
|
|
|
mLangService->LookupCharSet(aCharSet, getter_AddRefs(mLanguage));
|
|
|
|
GetFontPreferences();
|
|
|
|
if (mLanguage) {
|
|
|
|
nsCOMPtr<nsIAtom> langGroupAtom;
|
|
|
|
mLanguage->GetLanguageGroup(getter_AddRefs(langGroupAtom));
|
|
|
|
NS_ASSERTION(langGroupAtom, "non-NULL language group atom expected");
|
|
|
|
if (langGroupAtom.get() == nsLayoutAtoms::Japanese) {
|
|
|
|
mLanguageSpecificTransformType =
|
|
|
|
eLanguageSpecificTransformType_Japanese;
|
|
|
|
}
|
|
|
|
else if (langGroupAtom.get() == nsLayoutAtoms::Korean) {
|
|
|
|
mLanguageSpecificTransformType =
|
|
|
|
eLanguageSpecificTransformType_Korean;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mLanguageSpecificTransformType =
|
|
|
|
eLanguageSpecificTransformType_None;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-03-09 06:13:03 +03:00
|
|
|
#ifdef IBMBIDI
|
|
|
|
//ahmed
|
|
|
|
mCharset=aCharSet;
|
|
|
|
|
|
|
|
SetVisualMode(IsVisualCharset(mCharset) );
|
|
|
|
#endif // IBMBIDI
|
2000-09-21 02:59:20 +04:00
|
|
|
}
|
|
|
|
|
2000-06-02 03:12:26 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::Observe(nsISupports* aSubject, const PRUnichar* aTopic,
|
|
|
|
const PRUnichar* aData)
|
|
|
|
{
|
2000-09-21 02:59:20 +04:00
|
|
|
if (nsAutoString(aTopic).EqualsWithConversion("charset")) {
|
|
|
|
UpdateCharSet(aData);
|
2000-06-02 03:12:26 +04:00
|
|
|
}
|
2000-09-21 02:59:20 +04:00
|
|
|
else {
|
|
|
|
NS_WARNING("unrecognized topic in nsPresContext::Observe");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2000-06-02 03:12:26 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-31 09:54:59 +04:00
|
|
|
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)
|
|
|
|
{
|
1999-07-07 05:21:25 +04:00
|
|
|
if (! mCompatibilityLocked) {
|
|
|
|
mCompatibilityMode = aMode;
|
|
|
|
}
|
2000-06-03 01:45:06 +04:00
|
|
|
|
2000-06-22 00:44:59 +04:00
|
|
|
// enable/disable the QuirkSheet
|
|
|
|
NS_ASSERTION(mShell, "PresShell must be set on PresContext before calling nsPresContext::SetCompatibilityMode");
|
|
|
|
if (mShell) {
|
|
|
|
nsCOMPtr<nsIStyleSet> set;
|
|
|
|
nsresult rv = mShell->GetStyleSet(getter_AddRefs(set));
|
|
|
|
if (NS_SUCCEEDED(rv) && set) {
|
|
|
|
set->EnableQuirkStyleSheet((mCompatibilityMode != eCompatibility_Standard) ? PR_TRUE : PR_FALSE);
|
|
|
|
}
|
2000-06-03 01:45:06 +04:00
|
|
|
}
|
1998-07-31 09:54:59 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-03-03 01:43:26 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetWidgetRenderingMode(nsWidgetRendering* aResult)
|
|
|
|
{
|
2000-05-13 05:39:20 +04:00
|
|
|
NS_ENSURE_ARG_POINTER(aResult);
|
1999-03-03 01:43:26 +03:00
|
|
|
*aResult = mWidgetRenderingMode;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::SetWidgetRenderingMode(nsWidgetRendering aMode)
|
|
|
|
{
|
|
|
|
mWidgetRenderingMode = aMode;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-05-13 05:39:20 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetImageAnimationMode(nsImageAnimation* aModeResult)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aModeResult);
|
|
|
|
*aModeResult = mImageAnimationMode;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::SetImageAnimationMode(nsImageAnimation aMode)
|
|
|
|
{
|
|
|
|
mImageAnimationMode = aMode;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-08-04 02:30:47 +04:00
|
|
|
/* This function has now been depricated. It is no longer necesary to
|
|
|
|
* hold on to presContext just to get a nsLookAndFeel. nsLookAndFeel is
|
|
|
|
* now a service provided by ServiceManager.
|
|
|
|
*/
|
1999-09-10 09:51:08 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetLookAndFeel(nsILookAndFeel** aLookAndFeel)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aLookAndFeel, "null ptr");
|
|
|
|
if (nsnull == aLookAndFeel) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
nsresult result = NS_OK;
|
|
|
|
if (! mLookAndFeel) {
|
2000-07-29 02:12:45 +04:00
|
|
|
mLookAndFeel = do_GetService(kLookAndFeelCID,&result);
|
1999-09-10 09:51:08 +04:00
|
|
|
}
|
|
|
|
*aLookAndFeel = mLookAndFeel;
|
2000-07-29 02:12:45 +04:00
|
|
|
NS_IF_ADDREF(*aLookAndFeel);
|
1999-09-10 09:51:08 +04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1998-09-05 07:52:40 +04:00
|
|
|
NS_IMETHODIMP
|
1999-06-23 07:29:44 +04:00
|
|
|
nsPresContext::GetBaseURL(nsIURI** 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;
|
1999-04-30 13:04:36 +04:00
|
|
|
NS_IF_ADDREF(*aResult);
|
1998-09-05 07:52:40 +04:00
|
|
|
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)
|
2001-02-16 00:24:47 +03:00
|
|
|
{
|
|
|
|
return ResolvePseudoStyleWithComparator(aParentContent, aPseudoTag, aParentContext,
|
|
|
|
aForceUnique, nsnull, aResult);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::ResolvePseudoStyleWithComparator(nsIContent* aParentContent,
|
|
|
|
nsIAtom* aPseudoTag,
|
|
|
|
nsIStyleContext* aParentContext,
|
|
|
|
PRBool aForceUnique,
|
|
|
|
nsICSSPseudoComparator* aComparator,
|
|
|
|
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,
|
2001-02-16 00:24:47 +03:00
|
|
|
aParentContext, aForceUnique, aComparator);
|
1999-02-12 20:45:58 +03:00
|
|
|
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-09-04 03:35:41 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::ReParentStyleContext(nsIFrame* aFrame,
|
|
|
|
nsIStyleContext* aNewParentContext)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aFrame, "null ptr");
|
|
|
|
if (! aFrame) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIFrameManager> manager;
|
|
|
|
nsresult rv = mShell->GetFrameManager(getter_AddRefs(manager));
|
|
|
|
if (NS_SUCCEEDED(rv) && manager) {
|
1999-11-24 09:03:41 +03:00
|
|
|
rv = manager->ReParentStyleContext(this, aFrame, aNewParentContext);
|
1999-09-04 03:35:41 +04:00
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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;
|
1999-04-30 13:04:36 +04:00
|
|
|
if (mDeviceContext) {
|
2000-05-06 01:04:36 +04:00
|
|
|
nsCOMPtr<nsIAtom> langGroup;
|
|
|
|
if (mLanguage) {
|
|
|
|
mLanguage->GetLanguageGroup(getter_AddRefs(langGroup));
|
|
|
|
}
|
|
|
|
mDeviceContext->GetMetricsFor(aFont, langGroup, metrics);
|
1998-08-28 00:43:04 +04:00
|
|
|
}
|
1999-02-12 20:45:58 +03:00
|
|
|
*aResult = metrics;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetDefaultFont(nsFont& aResult)
|
|
|
|
{
|
|
|
|
aResult = mDefaultFont;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-06-13 02:31:15 +04:00
|
|
|
NS_IMETHODIMP
|
2000-01-25 17:33:03 +03:00
|
|
|
nsPresContext::SetDefaultFont(const nsFont& aFont)
|
1999-06-13 02:31:15 +04:00
|
|
|
{
|
|
|
|
mDefaultFont = aFont;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetDefaultFixedFont(nsFont& aResult)
|
|
|
|
{
|
|
|
|
aResult = mDefaultFixedFont;
|
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-06-13 02:31:15 +04:00
|
|
|
NS_IMETHODIMP
|
2000-01-25 17:33:03 +03:00
|
|
|
nsPresContext::SetDefaultFixedFont(const nsFont& aFont)
|
1999-06-13 02:31:15 +04:00
|
|
|
{
|
|
|
|
mDefaultFixedFont = aFont;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1999-06-13 02:31:15 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetDefaultBackgroundImage(nsString& aImage)
|
|
|
|
{
|
|
|
|
aImage = mDefaultBackgroundImage;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetDefaultBackgroundImageRepeat(PRUint8* aRepeat)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aRepeat, "null ptr");
|
|
|
|
if (nsnull == aRepeat) { return NS_ERROR_NULL_POINTER; }
|
|
|
|
*aRepeat = mDefaultBackgroundImageRepeat;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetDefaultBackgroundImageOffset(nscoord* aX, nscoord* aY)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION((nsnull != aX) && (nsnull != aY), "null ptr");
|
|
|
|
if (!aX || !aY) { return NS_ERROR_NULL_POINTER; }
|
|
|
|
*aX = mDefaultBackgroundImageOffsetX;
|
|
|
|
*aY = mDefaultBackgroundImageOffsetY;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetDefaultBackgroundImageAttachment(PRUint8* aAttachment)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aAttachment, "null ptr");
|
|
|
|
if (nsnull == aAttachment) { return NS_ERROR_NULL_POINTER; }
|
|
|
|
*aAttachment = mDefaultBackgroundImageAttachment;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-10-11 12:33:01 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetDefaultLinkColor(nscolor* aColor)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aColor, "null argument");
|
|
|
|
if (aColor) {
|
|
|
|
*aColor = mLinkColor;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetDefaultVisitedLinkColor(nscolor* aColor)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aColor, "null argument");
|
|
|
|
if (aColor) {
|
|
|
|
*aColor = mVisitedLinkColor;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
2001-04-10 02:17:11 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetFocusRingOnAnything(PRBool& aFocusRingOnAnything)
|
|
|
|
{
|
|
|
|
aFocusRingOnAnything = mFocusRingOnAnything;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetUseFocusColors(PRBool& aUseFocusColors)
|
|
|
|
{
|
|
|
|
aUseFocusColors = mUseFocusColors;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetFocusTextColor(nscolor* aColor)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aColor, "null argument");
|
|
|
|
if (aColor) {
|
|
|
|
*aColor = mFocusTextColor;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetFocusBackgroundColor(nscolor* aColor)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aColor, "null argument");
|
|
|
|
if (aColor) {
|
|
|
|
*aColor = mFocusBackgroundColor;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetFocusRingWidth(PRUint8 *aFocusRingWidth)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aFocusRingWidth, "null argument");
|
|
|
|
if (aFocusRingWidth) {
|
|
|
|
*aFocusRingWidth = mFocusRingWidth;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1999-06-13 02:31:15 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::SetDefaultBackgroundImage(const nsString& aImage)
|
|
|
|
{
|
|
|
|
mDefaultBackgroundImage = aImage;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::SetDefaultBackgroundImageRepeat(PRUint8 aRepeat)
|
|
|
|
{
|
|
|
|
mDefaultBackgroundImageRepeat = aRepeat;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::SetDefaultBackgroundImageOffset(nscoord aX, nscoord aY)
|
|
|
|
{
|
|
|
|
mDefaultBackgroundImageOffsetX = aX;
|
|
|
|
mDefaultBackgroundImageOffsetY = aY;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::SetDefaultBackgroundImageAttachment(PRUint8 aAttachment)
|
|
|
|
{
|
|
|
|
mDefaultBackgroundImageAttachment = aAttachment;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-10-11 12:33:01 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::SetDefaultLinkColor(nscolor aColor)
|
|
|
|
{
|
|
|
|
mLinkColor = aColor;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::SetDefaultVisitedLinkColor(nscolor aColor)
|
|
|
|
{
|
|
|
|
mVisitedLinkColor = 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;
|
1999-04-30 13:04:36 +04:00
|
|
|
if (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;
|
1999-04-30 13:04:36 +04:00
|
|
|
if (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;
|
1999-04-30 13:04:36 +04:00
|
|
|
if (mDeviceContext)
|
1998-11-14 04:52:27 +03:00
|
|
|
{
|
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;
|
1999-04-30 13:04:36 +04:00
|
|
|
NS_IF_ADDREF(*aResult);
|
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;
|
|
|
|
}
|
|
|
|
|
1999-04-30 13:04:36 +04:00
|
|
|
if (!mImageGroup) {
|
1998-05-09 07:22:01 +04:00
|
|
|
// Create image group
|
1999-04-30 13:04:36 +04:00
|
|
|
nsresult rv = NS_NewImageGroup(getter_AddRefs(mImageGroup));
|
1998-05-09 07:22:01 +04:00
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initialize the image group
|
2000-02-15 07:49:32 +03:00
|
|
|
nsCOMPtr<nsIURIContentListener> loadHandler (do_GetInterface(mContainer, &rv));
|
|
|
|
if (NS_SUCCEEDED(rv) && loadHandler)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsISupports> loadContext;
|
|
|
|
loadHandler->GetLoadCookie(getter_AddRefs(loadContext));
|
|
|
|
rv = mImageGroup->Init(mDeviceContext, loadContext);
|
1999-07-03 12:56:26 +04:00
|
|
|
}
|
2000-02-15 07:49:32 +03:00
|
|
|
|
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;
|
1999-04-30 13:04:36 +04:00
|
|
|
NS_IF_ADDREF(*aResult);
|
1998-05-12 02:56:58 +04:00
|
|
|
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,
|
1999-04-14 01:49:28 +04:00
|
|
|
const nsSize* aDesiredSize,
|
1998-07-31 09:54:59 +04:00
|
|
|
nsIFrame* aTargetFrame,
|
1999-04-14 01:49:28 +04:00
|
|
|
nsIFrameImageLoaderCB aCallBack,
|
|
|
|
void* aClosure,
|
2000-09-01 11:05:08 +04:00
|
|
|
void* aKey,
|
1999-04-14 01:49:28 +04:00
|
|
|
nsIFrameImageLoader** aResult)
|
1998-05-12 02:56:58 +04:00
|
|
|
{
|
1998-11-26 21:10:10 +03:00
|
|
|
if (mStopped) {
|
2000-09-21 05:20:00 +04:00
|
|
|
// if we are stopped and the image is not chrome
|
|
|
|
// don't load.
|
|
|
|
// If we are chrome don't load if we
|
|
|
|
// were told to stop chrome
|
|
|
|
if (!aURL.EqualsWithConversion("chrome:", PR_TRUE, 7) || mStopChrome) {
|
|
|
|
if (aResult) {
|
|
|
|
*aResult = nsnull;
|
|
|
|
}
|
2000-09-22 00:17:04 +04:00
|
|
|
return NS_OK;
|
2000-09-21 05:20:00 +04:00
|
|
|
}
|
1998-11-26 21:10:10 +03:00
|
|
|
}
|
1998-11-23 20:18:34 +03:00
|
|
|
|
1999-05-07 04:06:03 +04:00
|
|
|
// Allow for a null target frame argument (for precached images)
|
2000-05-13 05:39:20 +04:00
|
|
|
if (aTargetFrame) {
|
1999-05-07 04:06:03 +04:00
|
|
|
// Mark frame as having loaded an image
|
|
|
|
nsFrameState state;
|
|
|
|
aTargetFrame->GetFrameState(&state);
|
|
|
|
state |= NS_FRAME_HAS_LOADED_IMAGES;
|
|
|
|
aTargetFrame->SetFrameState(state);
|
|
|
|
}
|
1999-04-14 01:49:28 +04:00
|
|
|
|
|
|
|
// Lookup image request in our loaders array (maybe the load request
|
|
|
|
// has already been made for that url at the desired size).
|
1998-05-09 07:22:01 +04:00
|
|
|
PRInt32 i, n = mImageLoaders.Count();
|
1998-05-12 02:56:58 +04:00
|
|
|
nsIFrameImageLoader* loader;
|
1998-05-09 07:22:01 +04:00
|
|
|
for (i = 0; i < n; i++) {
|
1999-04-14 01:49:28 +04:00
|
|
|
PRBool same;
|
1998-05-12 02:56:58 +04:00
|
|
|
loader = (nsIFrameImageLoader*) mImageLoaders.ElementAt(i);
|
1999-04-14 01:49:28 +04:00
|
|
|
loader->IsSameImageRequest(aURL, aBackgroundColor, aDesiredSize, &same);
|
|
|
|
if (same) {
|
|
|
|
// This is pretty sick, but because we can get a notification
|
|
|
|
// *before* the caller has returned we have to store into
|
|
|
|
// aResult before calling the AddFrame method.
|
|
|
|
if (aResult) {
|
|
|
|
NS_ADDREF(loader);
|
|
|
|
*aResult = loader;
|
1998-05-12 02:56:58 +04:00
|
|
|
}
|
1999-04-14 01:49:28 +04:00
|
|
|
|
|
|
|
// Add frame to list of interested frames for this loader
|
2000-09-01 11:05:08 +04:00
|
|
|
loader->AddFrame(aTargetFrame, aCallBack, aClosure, aKey);
|
1999-04-14 01:49:28 +04:00
|
|
|
return NS_OK;
|
1998-05-12 02:56:58 +04:00
|
|
|
}
|
|
|
|
}
|
2000-05-16 02:05:45 +04:00
|
|
|
|
|
|
|
// Check with the content-policy things to make sure this load is permitted.
|
|
|
|
PRBool shouldLoad = PR_TRUE; // default permit
|
|
|
|
nsCOMPtr<nsIContent> content;
|
|
|
|
nsCOMPtr<nsIDOMElement> element;
|
|
|
|
if (aTargetFrame &&
|
|
|
|
NS_SUCCEEDED(aTargetFrame->GetContent(getter_AddRefs(content)))) {
|
|
|
|
element = do_QueryInterface(content);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(NS_CheckContentLoadPolicy(nsIContentPolicy::CONTENT_IMAGE,
|
|
|
|
aURL, element, &shouldLoad))
|
|
|
|
&& !shouldLoad) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-05-12 02:56:58 +04:00
|
|
|
|
|
|
|
// Create image group if needed
|
|
|
|
nsresult rv;
|
1999-04-30 13:04:36 +04:00
|
|
|
if (!mImageGroup) {
|
1999-02-12 20:45:58 +03:00
|
|
|
nsCOMPtr<nsIImageGroup> group;
|
1999-04-30 13:04:36 +04:00
|
|
|
rv = GetImageGroup(getter_AddRefs(group)); // sets mImageGroup as side effect
|
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
|
|
|
|
1999-04-14 01:49:28 +04:00
|
|
|
// This is pretty sick, but because we can get a notification
|
|
|
|
// *before* the caller has returned we have to store into aResult
|
|
|
|
// before calling the loaders init method.
|
|
|
|
if (aResult) {
|
|
|
|
*aResult = loader;
|
|
|
|
NS_ADDREF(loader);
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = loader->Init(this, mImageGroup, aURL, aBackgroundColor, aDesiredSize,
|
2000-09-01 11:05:08 +04:00
|
|
|
aTargetFrame, mImageAnimationMode, aCallBack, aClosure,
|
|
|
|
aKey);
|
1998-06-03 02:05:45 +04:00
|
|
|
if (NS_OK != rv) {
|
1998-08-19 22:07:27 +04:00
|
|
|
mImageLoaders.RemoveElement(loader);
|
1999-04-23 23:57:49 +04:00
|
|
|
loader->StopImageLoad();
|
1998-08-18 05:43:35 +04:00
|
|
|
NS_RELEASE(loader);
|
1999-04-14 01:49:28 +04:00
|
|
|
|
|
|
|
// Undo premature store of reslut
|
|
|
|
if (aResult) {
|
|
|
|
*aResult = nsnull;
|
|
|
|
NS_RELEASE(loader);
|
|
|
|
}
|
1998-06-03 02:05:45 +04:00
|
|
|
return rv;
|
|
|
|
}
|
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
|
2000-09-21 05:20:00 +04:00
|
|
|
nsPresContext::Stop(PRBool aStopChrome)
|
1998-11-26 21:10:10 +03:00
|
|
|
{
|
2000-09-21 05:20:00 +04:00
|
|
|
mStopChrome = aStopChrome;
|
1998-11-26 21:10:10 +03:00
|
|
|
PRInt32 n = mImageLoaders.Count();
|
2000-09-22 00:17:04 +04:00
|
|
|
for (PRInt32 i = n-1; i >= 0; i--) {
|
1998-11-26 21:10:10 +03:00
|
|
|
nsIFrameImageLoader* loader;
|
|
|
|
loader = (nsIFrameImageLoader*) mImageLoaders.ElementAt(i);
|
2000-09-22 00:17:04 +04:00
|
|
|
if (NS_SUCCEEDED(loader->StopImageLoad(aStopChrome))) {
|
|
|
|
mImageLoaders.RemoveElementAt(i);
|
|
|
|
NS_RELEASE(loader);
|
|
|
|
}
|
1998-11-26 21:10:10 +03:00
|
|
|
}
|
2000-09-22 00:17:04 +04:00
|
|
|
|
1998-11-26 21:10:10 +03:00
|
|
|
mStopped = PR_TRUE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-31 09:54:59 +04:00
|
|
|
NS_IMETHODIMP
|
2000-09-01 11:05:08 +04:00
|
|
|
nsPresContext::StopLoadImage(void* aKey, nsIFrameImageLoader* aLoader)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-05-09 07:22:01 +04:00
|
|
|
PRInt32 i, n = mImageLoaders.Count();
|
1999-04-14 01:49:28 +04:00
|
|
|
nsIFrameImageLoader* loader;
|
|
|
|
for (i = 0; i < n; i++) {
|
1998-05-12 02:56:58 +04:00
|
|
|
loader = (nsIFrameImageLoader*) mImageLoaders.ElementAt(i);
|
1999-04-14 01:49:28 +04:00
|
|
|
if (loader == aLoader) {
|
|
|
|
// Remove frame from list of interested frames for this loader
|
2000-09-01 11:05:08 +04:00
|
|
|
loader->RemoveFrame(aKey);
|
1999-04-14 01:49:28 +04:00
|
|
|
|
|
|
|
// If loader is no longer loading for anybody and its safe to
|
|
|
|
// nuke it, nuke it.
|
|
|
|
PRBool safe;
|
|
|
|
loader->SafeToDestroy(&safe);
|
|
|
|
if (safe) {
|
1999-04-23 23:57:49 +04:00
|
|
|
loader->StopImageLoad();
|
1999-04-14 01:49:28 +04:00
|
|
|
NS_RELEASE(loader);
|
|
|
|
mImageLoaders.RemoveElementAt(i);
|
|
|
|
n--;
|
|
|
|
i--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2000-09-01 11:05:08 +04:00
|
|
|
nsPresContext::StopAllLoadImagesFor(nsIFrame* aTargetFrame, void *aKey)
|
1999-04-14 01:49:28 +04:00
|
|
|
{
|
|
|
|
nsFrameState state;
|
|
|
|
aTargetFrame->GetFrameState(&state);
|
|
|
|
if (NS_FRAME_HAS_LOADED_IMAGES & state) {
|
|
|
|
nsIFrameImageLoader* loader;
|
|
|
|
PRInt32 i, n = mImageLoaders.Count();
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
PRBool safe;
|
|
|
|
loader = (nsIFrameImageLoader*) mImageLoaders.ElementAt(i);
|
2000-09-01 11:05:08 +04:00
|
|
|
loader->RemoveFrame(aKey);
|
1999-04-14 01:49:28 +04:00
|
|
|
loader->SafeToDestroy(&safe);
|
|
|
|
if (safe) {
|
1999-04-23 23:57:49 +04:00
|
|
|
loader->StopImageLoad();
|
1999-04-14 01:49:28 +04:00
|
|
|
NS_RELEASE(loader);
|
|
|
|
mImageLoaders.RemoveElementAt(i);
|
|
|
|
n--;
|
|
|
|
i--;
|
1998-11-23 20:18:34 +03:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
1998-05-09 07:22:01 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::SetLinkHandler(nsILinkHandler* aHandler)
|
1999-04-30 13:04:36 +04:00
|
|
|
{
|
1998-04-14 00:24:54 +04:00
|
|
|
mLinkHandler = 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)
|
1999-04-30 13:04:36 +04:00
|
|
|
{
|
1998-04-14 00:24:54 +04:00
|
|
|
mContainer = 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;
|
|
|
|
}
|
|
|
|
|
1999-04-30 13:52:22 +04:00
|
|
|
if (!mEventManager) {
|
2001-02-20 00:50:04 +03:00
|
|
|
nsresult rv;
|
|
|
|
mEventManager = do_CreateInstance(kEventStateManagerCID,&rv);
|
|
|
|
if (NS_FAILED(rv)) {
|
1998-06-24 01:53:02 +04:00
|
|
|
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;
|
1999-04-30 13:04:36 +04:00
|
|
|
NS_IF_ADDREF(*aManager);
|
1998-06-24 01:53:02 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-03-21 18:51:59 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetDefaultDirection(PRUint8* aDirection)
|
|
|
|
{
|
|
|
|
*aDirection = mDefaultDirection;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-03-09 06:13:03 +03:00
|
|
|
#ifdef IBMBIDI
|
|
|
|
//ahmed
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::IsArabicEncoding(PRBool& aResult)
|
|
|
|
{
|
|
|
|
aResult=PR_FALSE;
|
|
|
|
if ( (mCharset.EqualsIgnoreCase("ibm864") )||(mCharset.EqualsIgnoreCase("ibm864i") )||(mCharset.EqualsIgnoreCase("windows-1256") )||(mCharset.EqualsIgnoreCase("iso-8859-6") ))
|
|
|
|
aResult=PR_TRUE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::IsVisRTL(PRBool& aResult)
|
|
|
|
{
|
|
|
|
aResult=PR_FALSE;
|
|
|
|
if ( (mIsVisual)&&(GET_BIDI_OPTION_DIRECTION(mBidi) == IBMBIDI_TEXTDIRECTION_RTL) )
|
|
|
|
aResult=PR_TRUE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::BidiEnabled(PRBool& aBidiEnabled) const
|
|
|
|
{
|
|
|
|
aBidiEnabled = PR_FALSE;
|
|
|
|
NS_ASSERTION(mShell, "PresShell must be set on PresContext before calling nsPresContext::BidiEnabled");
|
|
|
|
if (mShell) {
|
|
|
|
nsCOMPtr<nsIDocument> doc;
|
|
|
|
mShell->GetDocument(getter_AddRefs(doc) );
|
|
|
|
NS_ASSERTION(doc, "PresShell has no document in nsPresContext::BidiEnabled");
|
|
|
|
if (doc) {
|
|
|
|
doc->BidiEnabled(aBidiEnabled);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::EnableBidi() const
|
|
|
|
{
|
|
|
|
if (mShell) {
|
|
|
|
nsCOMPtr<nsIDocument> doc;
|
|
|
|
mShell->GetDocument(getter_AddRefs(doc) );
|
|
|
|
if (doc) {
|
|
|
|
doc->EnableBidi();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::SetVisualMode(PRBool aIsVisual)
|
|
|
|
{
|
|
|
|
mIsVisual = aIsVisual;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::IsVisualMode(PRBool& aIsVisual) const
|
|
|
|
{
|
|
|
|
aIsVisual = mIsVisual;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetBidiUtils(nsBidiPresUtils** aBidiUtils)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
if (!mBidiUtils) {
|
|
|
|
mBidiUtils = new nsBidiPresUtils;
|
|
|
|
if (!mBidiUtils) {
|
|
|
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*aBidiUtils = mBidiUtils;
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsPresContext::SetBidi(nsBidiOptions aSource, PRBool aForceReflow)
|
|
|
|
{
|
|
|
|
mBidi = aSource;
|
|
|
|
if (IBMBIDI_TEXTDIRECTION_RTL == GET_BIDI_OPTION_DIRECTION(mBidi)
|
|
|
|
|| IBMBIDI_NUMERAL_HINDI == GET_BIDI_OPTION_NUMERAL(mBidi)) {
|
|
|
|
EnableBidi();
|
|
|
|
}
|
|
|
|
if (IBMBIDI_TEXTTYPE_VISUAL == GET_BIDI_OPTION_TEXTTYPE(mBidi)) {
|
|
|
|
SetVisualMode(PR_TRUE);
|
|
|
|
}
|
|
|
|
else if (IBMBIDI_TEXTTYPE_LOGICAL == GET_BIDI_OPTION_TEXTTYPE(mBidi)) {
|
|
|
|
SetVisualMode(PR_FALSE);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
SetVisualMode(IsVisualCharset(mCharset) );
|
|
|
|
}
|
|
|
|
if (mShell && aForceReflow) {
|
|
|
|
RemapStyleAndReflow();
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP nsPresContext::GetBidi(nsBidiOptions * aDest)
|
|
|
|
{
|
|
|
|
if (aDest)
|
|
|
|
*aDest = mBidi;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Mohamed 17-1-01
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::SetIsBidiSystem(PRBool aIsBidi)
|
|
|
|
{
|
|
|
|
mIsBidiSystem = aIsBidi;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetIsBidiSystem(PRBool& aResult) const
|
|
|
|
{
|
|
|
|
aResult = mIsBidiSystem;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetBidiCharset(nsAutoString &aCharSet)
|
|
|
|
{
|
|
|
|
aCharSet = mCharset;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
//Mohamed End
|
|
|
|
|
|
|
|
#endif //IBMBIDI
|
2000-03-21 18:51:59 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::SetDefaultDirection(PRUint8 aDirection)
|
|
|
|
{
|
|
|
|
mDefaultDirection = aDirection;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-04-21 18:59:47 +04:00
|
|
|
|
2000-05-06 01:04:36 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetLanguage(nsILanguageAtom** aLanguage)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aLanguage);
|
|
|
|
|
|
|
|
*aLanguage = mLanguage;
|
|
|
|
NS_IF_ADDREF(*aLanguage);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-09-21 02:59:20 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::GetLanguageSpecificTransformType(
|
|
|
|
nsLanguageSpecificTransformType* aType)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aType);
|
|
|
|
*aType = mLanguageSpecificTransformType;
|
2000-10-11 12:33:01 +04:00
|
|
|
|
2000-09-21 02:59:20 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-27 17:09:34 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::IsRenderingOnlySelection(PRBool* aResult)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aResult);
|
|
|
|
*aResult = mIsRenderingOnlySelection;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-04-21 18:59:47 +04:00
|
|
|
#ifdef MOZ_REFLOW_PERF
|
|
|
|
NS_IMETHODIMP
|
2001-02-22 16:58:17 +03:00
|
|
|
nsPresContext::CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame)
|
2000-04-21 18:59:47 +04:00
|
|
|
{
|
|
|
|
if (mShell) {
|
2001-02-22 16:58:17 +03:00
|
|
|
mShell->CountReflows(aName, aType, aFrame);
|
2000-04-21 18:59:47 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-03-13 04:47:22 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPresContext::PaintCount(const char * aName, nsIRenderingContext* aRenderingContext, nsIFrame * aFrame, PRUint32 aColor)
|
|
|
|
{
|
|
|
|
if (mShell) {
|
|
|
|
mShell->PaintCount(aName, aRenderingContext, this, aFrame, aColor);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-04-21 18:59:47 +04:00
|
|
|
#endif
|