Backing out these changes since they appear to have caused a Txul regression on some tinderboxes (not all... weird...)

This commit is contained in:
caillon%returnzero.com 2002-12-11 05:11:02 +00:00
Родитель 5c7d132e58
Коммит 7ca2c28686
30 изменённых файлов: 374 добавлений и 472 удалений

Просмотреть файл

@ -93,8 +93,7 @@
#include "nsIAnonymousContentCreator.h"
#include "nsIFrameManager.h"
#include "nsIAttributeContent.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIPref.h"
#include "nsLegendFrame.h"
#include "nsIContentIterator.h"
#include "nsBoxLayoutState.h"
@ -4232,10 +4231,10 @@ nsCSSFrameConstructor::HasGfxScrollbars()
#endif
// Get the Prefs
if (!mGotGfxPrefs) {
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefBranch) {
nsCOMPtr<nsIPref> pref(do_GetService(NS_PREF_CONTRACTID));
if (pref) {
PRBool hasGfxScroll = PR_FALSE; // use a temp since we have a PRPackedBool
prefBranch->GetBoolPref("nglayout.widget.gfxscrollbars", &hasGfxScroll);
pref->GetBoolPref("nglayout.widget.gfxscrollbars", &hasGfxScroll);
mHasGfxScrollbars = hasGfxScroll;
mGotGfxPrefs = PR_TRUE;
} else {
@ -4252,10 +4251,10 @@ PRBool
nsCSSFrameConstructor::UseXBLForms()
{
if (!mGotXBLFormPrefs) {
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefBranch) {
nsCOMPtr<nsIPref> pref(do_GetService(NS_PREF_CONTRACTID));
if (pref) {
PRBool useXBLForms = PR_FALSE; // use a temp since we have a PRPackedBool
prefBranch->GetBoolPref("nglayout.debug.enable_xbl_forms", &useXBLForms);
pref->GetBoolPref("nglayout.debug.enable_xbl_forms", &useXBLForms);
mUseXBLForms = useXBLForms;
mGotXBLFormPrefs = PR_TRUE;
}

Просмотреть файл

@ -75,6 +75,7 @@
#ifdef IBMBIDI
//-------------------------------IBM BIDI--------------------------------------
// Mamdouh : Modifiaction of the caret to work with Bidi in the LTR and RTL
#include "nsIPref.h"
#include "nsLayoutAtoms.h"
//------------------------------END OF IBM BIDI--------------------------------
#endif //IBMBIDI

Просмотреть файл

@ -37,9 +37,7 @@
#include "nsCOMPtr.h"
#include "nsPresContext.h"
#include "nsIPresShell.h"
#include "nsIPrefService.h"
#include "nsIPrefBranchInternal.h"
#include "nsISupportsPrimitives.h"
#include "nsIPref.h"
#include "nsILinkHandler.h"
#include "nsIDocShellTreeItem.h"
#include "nsIStyleSet.h"
@ -97,6 +95,18 @@ MakeColorPref(const char *colstr)
return colorref;
}
int PR_CALLBACK
nsPresContext::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
}
#ifdef IBMBIDI
PRBool
IsVisualCharset(const nsAutoString& aCharset)
@ -213,22 +223,23 @@ nsPresContext::~nsPresContext()
if (mEventManager)
mEventManager->SetPresContext(nsnull); // unclear if this is needed, but can't hurt
// Unregister preference observers
nsCOMPtr<nsIPrefBranchInternal> prefInternal(do_QueryInterface(mPrefBranch));
if (prefInternal) {
prefInternal->RemoveObserver("browser.anchor_color", this);
prefInternal->RemoveObserver("browser.display.", this);
prefInternal->RemoveObserver("browser.underline_anchors", this);
prefInternal->RemoveObserver("browser.visited_color", this);
prefInternal->RemoveObserver("font.", this);
prefInternal->RemoveObserver("image.animation_mode", this);
prefInternal->RemoveObserver("network.image.imageBehavior", this);
// Unregister preference callbacks
if (mPrefs) {
mPrefs->UnregisterCallback("font.", nsPresContext::PrefChangedCallback, (void*)this);
mPrefs->UnregisterCallback("browser.display.", nsPresContext::PrefChangedCallback, (void*)this);
mPrefs->UnregisterCallback("browser.underline_anchors", nsPresContext::PrefChangedCallback, (void*)this);
mPrefs->UnregisterCallback("browser.anchor_color", nsPresContext::PrefChangedCallback, (void*)this);
mPrefs->UnregisterCallback("browser.visited_color", nsPresContext::PrefChangedCallback, (void*)this);
mPrefs->UnregisterCallback("network.image.imageBehavior", nsPresContext::PrefChangedCallback, (void*)this);
mPrefs->UnregisterCallback("image.animation_mode", nsPresContext::PrefChangedCallback, (void*)this);
#ifdef IBMBIDI
prefInternal->RemoveObserver("bidi.", this);
mPrefs->UnregisterCallback("bidi.", PrefChangedCallback, (void*)this);
#endif
}
#ifdef IBMBIDI
delete mBidiUtils;
if (mBidiUtils) {
delete mBidiUtils;
}
#endif // IBMBIDI
}
@ -251,7 +262,7 @@ static const char* const kGenericFont[] = {
void
nsPresContext::GetFontPreferences()
{
if (!mPrefBranch || !mLanguage)
if (!mPrefs || !mLanguage)
return;
/* Fetch the font prefs to be used -- see bug 61883 for details.
@ -281,12 +292,13 @@ nsPresContext::GetFontPreferences()
langGroupAtom->ToString(langGroup);
nsCAutoString pref;
nsXPIDLString value;
nsXPIDLCString cvalue;
// get the current applicable font-size unit
enum {eUnit_unknown = -1, eUnit_px, eUnit_pt};
PRInt32 unit = eUnit_px;
nsresult rv = mPrefBranch->GetCharPref("font.size.unit", getter_Copies(cvalue));
nsresult rv = mPrefs->CopyCharPref("font.size.unit", getter_Copies(cvalue));
if (NS_SUCCEEDED(rv)) {
if (!PL_strcmp(cvalue.get(), "px")) {
unit = eUnit_px;
@ -302,9 +314,8 @@ nsPresContext::GetFontPreferences()
// get font.minimum-size.[langGroup]
PRInt32 size;
pref.Assign("font.minimum-size.");
pref.Append(NS_ConvertUCS2toUTF8(langGroup));
rv = mPrefBranch->GetIntPref(pref.get(), &size);
pref.Assign("font.minimum-size."); pref.Append(NS_ConvertUCS2toUTF8(langGroup));
rv = mPrefs->GetIntPref(pref.get(), &size);
if (NS_SUCCEEDED(rv)) {
if (unit == eUnit_px) {
mMinimumFontSize = NSFloatPixelsToTwips((float)size, p2t);
@ -320,7 +331,7 @@ nsPresContext::GetFontPreferences()
generic_dot_langGroup.Assign(kGenericFont[eType]);
generic_dot_langGroup.Append(NS_ConvertUCS2toUTF8(langGroup));
nsFont* font = nsnull;
nsFont* font;
switch (eType) {
case eDefaultFont_Variable: font = &mDefaultVariableFont; break;
case eDefaultFont_Fixed: font = &mDefaultFixedFont; break;
@ -336,19 +347,14 @@ nsPresContext::GetFontPreferences()
// in GFX and will be queried there when hunting for alternative fonts)
if (eType == eDefaultFont_Variable) {
MAKE_FONT_PREF_KEY(pref, "font.name", generic_dot_langGroup);
nsCOMPtr<nsISupportsString> prefString;
mPrefBranch->GetComplexValue(pref.get(),
NS_GET_IID(nsISupportsString),
getter_AddRefs(prefString));
if (prefString) {
prefString->GetData(font->name);
rv = mPrefs->CopyUnicharPref(pref.get(), getter_Copies(value));
if (NS_SUCCEEDED(rv)) {
font->name.Assign(value);
}
else {
mPrefBranch->GetComplexValue("font.default",
NS_GET_IID(nsISupportsString),
getter_AddRefs(prefString));
if (prefString) {
prefString->GetData(mDefaultVariableFont.name);
rv = mPrefs->CopyUnicharPref("font.default", getter_Copies(value));
if (NS_SUCCEEDED(rv)) {
mDefaultVariableFont.name.Assign(value);
}
}
}
@ -375,7 +381,7 @@ nsPresContext::GetFontPreferences()
// get font.size.[generic].[langGroup]
// size=0 means 'Auto', i.e., generic fonts retain the size of the variable font
MAKE_FONT_PREF_KEY(pref, "font.size", generic_dot_langGroup);
rv = mPrefBranch->GetIntPref(pref.get(), &size);
rv = mPrefs->GetIntPref(pref.get(), &size);
if (NS_SUCCEEDED(rv) && size > 0) {
if (unit == eUnit_px) {
font->size = NSFloatPixelsToTwips((float)size, p2t);
@ -388,7 +394,7 @@ nsPresContext::GetFontPreferences()
// get font.size-adjust.[generic].[langGroup]
// XXX only applicable on GFX ports that handle |font-size-adjust|
MAKE_FONT_PREF_KEY(pref, "font.size-adjust", generic_dot_langGroup);
rv = mPrefBranch->GetCharPref(pref.get(), getter_Copies(cvalue));
rv = mPrefs->CopyCharPref(pref.get(), getter_Copies(cvalue));
if (NS_SUCCEEDED(rv)) {
font->sizeAdjust = (float)atof(cvalue.get());
}
@ -415,15 +421,15 @@ nsPresContext::GetDocumentColorPreferences()
usePrefColors = PR_FALSE;
}
if (usePrefColors) {
if (NS_SUCCEEDED(mPrefBranch->GetBoolPref("browser.display.use_system_colors", &boolPref))) {
if (NS_SUCCEEDED(mPrefs->GetBoolPref("browser.display.use_system_colors", &boolPref))) {
usePrefColors = !boolPref;
}
}
if (usePrefColors) {
if (NS_SUCCEEDED(mPrefBranch->GetCharPref("browser.display.foreground_color", getter_Copies(colorStr)))) {
if (NS_SUCCEEDED(mPrefs->CopyCharPref("browser.display.foreground_color", getter_Copies(colorStr)))) {
mDefaultColor = MakeColorPref(colorStr);
}
if (NS_SUCCEEDED(mPrefBranch->GetCharPref("browser.display.background_color", getter_Copies(colorStr)))) {
if (NS_SUCCEEDED(mPrefs->CopyCharPref("browser.display.background_color", getter_Copies(colorStr)))) {
mDefaultBackgroundColor = MakeColorPref(colorStr);
}
}
@ -439,7 +445,7 @@ nsPresContext::GetDocumentColorPreferences()
}
}
if (NS_SUCCEEDED(mPrefBranch->GetBoolPref("browser.display.use_document_colors", &boolPref))) {
if (NS_SUCCEEDED(mPrefs->GetBoolPref("browser.display.use_document_colors", &boolPref))) {
mUseDocumentColors = boolPref;
}
}
@ -447,13 +453,13 @@ nsPresContext::GetDocumentColorPreferences()
void
nsPresContext::GetUserPreferences()
{
PRInt32 prefInt = 0;
PRInt32 prefInt;
if (NS_SUCCEEDED(mPrefBranch->GetIntPref("browser.display.base_font_scaler", &prefInt))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("browser.display.base_font_scaler", &prefInt))) {
mFontScaler = prefInt;
}
if (NS_SUCCEEDED(mPrefBranch->GetIntPref("nglayout.widget.mode", &prefInt))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("nglayout.widget.mode", &prefInt))) {
mWidgetRenderingMode = (enum nsWidgetRendering)prefInt; // bad cast
}
@ -462,75 +468,78 @@ nsPresContext::GetUserPreferences()
// * link colors
PRBool boolPref;
nsXPIDLCString stringPref;
if (NS_SUCCEEDED(mPrefBranch->GetBoolPref("browser.underline_anchors", &boolPref))) {
nsXPIDLCString colorStr;
if (NS_SUCCEEDED(mPrefs->GetBoolPref("browser.underline_anchors", &boolPref))) {
mUnderlineLinks = boolPref;
}
if (NS_SUCCEEDED(mPrefBranch->GetCharPref("browser.anchor_color", getter_Copies(stringPref)))) {
mLinkColor = MakeColorPref(stringPref);
if (NS_SUCCEEDED(mPrefs->CopyCharPref("browser.anchor_color", getter_Copies(colorStr)))) {
mLinkColor = MakeColorPref(colorStr);
}
if (NS_SUCCEEDED(mPrefBranch->GetCharPref("browser.visited_color", getter_Copies(stringPref)))) {
mVisitedLinkColor = MakeColorPref(stringPref);
if (NS_SUCCEEDED(mPrefs->CopyCharPref("browser.visited_color", getter_Copies(colorStr)))) {
mVisitedLinkColor = MakeColorPref(colorStr);
}
if (NS_SUCCEEDED(mPrefBranch->GetBoolPref("browser.display.use_focus_colors", &boolPref))) {
if (NS_SUCCEEDED(mPrefs->GetBoolPref("browser.display.use_focus_colors", &boolPref))) {
mUseFocusColors = boolPref;
mFocusTextColor = mDefaultColor;
mFocusBackgroundColor = mDefaultBackgroundColor;
if (NS_SUCCEEDED(mPrefBranch->GetCharPref("browser.display.focus_text_color", getter_Copies(stringPref)))) {
mFocusTextColor = MakeColorPref(stringPref);
if (NS_SUCCEEDED(mPrefs->CopyCharPref("browser.display.focus_text_color", getter_Copies(colorStr)))) {
mFocusTextColor = MakeColorPref(colorStr);
}
if (NS_SUCCEEDED(mPrefBranch->GetCharPref("browser.display.focus_background_color", getter_Copies(stringPref)))) {
mFocusBackgroundColor = MakeColorPref(stringPref);
if (NS_SUCCEEDED(mPrefs->CopyCharPref("browser.display.focus_background_color", getter_Copies(colorStr)))) {
mFocusBackgroundColor = MakeColorPref(colorStr);
}
}
if (NS_SUCCEEDED(mPrefBranch->GetIntPref("browser.display.focus_ring_width", &prefInt))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("browser.display.focus_ring_width", &prefInt))) {
mFocusRingWidth = prefInt;
}
if (NS_SUCCEEDED(mPrefBranch->GetBoolPref("browser.display.focus_ring_on_anything", &boolPref))) {
if (NS_SUCCEEDED(mPrefs->GetBoolPref("browser.display.focus_ring_on_anything", &boolPref))) {
mFocusRingOnAnything = boolPref;
}
// * use fonts?
if (NS_SUCCEEDED(mPrefBranch->GetIntPref("browser.display.use_document_fonts", &prefInt))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("browser.display.use_document_fonts", &prefInt))) {
mUseDocumentFonts = prefInt == 0 ? PR_FALSE : PR_TRUE;
}
GetFontPreferences();
// * image animation
nsresult rv = mPrefBranch->GetCharPref("image.animation_mode", getter_Copies(stringPref));
if (NS_SUCCEEDED(rv)) {
if (stringPref.Equals("normal"))
char* animatePref = 0;
nsresult rv = mPrefs->CopyCharPref("image.animation_mode", &animatePref);
if (NS_SUCCEEDED(rv) && animatePref) {
if (!nsCRT::strcmp(animatePref, "normal"))
mImageAnimationModePref = imgIContainer::kNormalAnimMode;
else if (stringPref.Equals("none"))
else if (!nsCRT::strcmp(animatePref, "none"))
mImageAnimationModePref = imgIContainer::kDontAnimMode;
else if (stringPref.Equals("once"))
else if (!nsCRT::strcmp(animatePref, "once"))
mImageAnimationModePref = imgIContainer::kLoopOnceAnimMode;
nsMemory::Free(animatePref);
}
#ifdef IBMBIDI
if (NS_SUCCEEDED(mPrefBranch->GetIntPref("bidi.direction", &prefInt))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("bidi.direction", &prefInt))) {
SET_BIDI_OPTION_DIRECTION(mBidi, prefInt);
}
if (NS_SUCCEEDED(mPrefBranch->GetIntPref("bidi.texttype", &prefInt))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("bidi.texttype", &prefInt))) {
SET_BIDI_OPTION_TEXTTYPE(mBidi, prefInt);
}
if (NS_SUCCEEDED(mPrefBranch->GetIntPref("bidi.controlstextmode", &prefInt))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("bidi.controlstextmode", &prefInt))) {
SET_BIDI_OPTION_CONTROLSTEXTMODE(mBidi, prefInt);
}
if (NS_SUCCEEDED(mPrefBranch->GetIntPref("bidi.clipboardtextmode", &prefInt))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("bidi.clipboardtextmode", &prefInt))) {
SET_BIDI_OPTION_CLIPBOARDTEXTMODE(mBidi, prefInt);
}
if (NS_SUCCEEDED(mPrefBranch->GetIntPref("bidi.numeral", &prefInt))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("bidi.numeral", &prefInt))) {
SET_BIDI_OPTION_NUMERAL(mBidi, prefInt);
}
if (NS_SUCCEEDED(mPrefBranch->GetIntPref("bidi.support", &prefInt))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("bidi.support", &prefInt))) {
SET_BIDI_OPTION_SUPPORT(mBidi, prefInt);
}
if (NS_SUCCEEDED(mPrefBranch->GetIntPref("bidi.characterset", &prefInt))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("bidi.characterset", &prefInt))) {
SET_BIDI_OPTION_CHARACTERSET(mBidi, prefInt);
}
#endif
@ -625,19 +634,18 @@ nsPresContext::Init(nsIDeviceContext* aDeviceContext)
mDeviceContext = dont_QueryInterface(aDeviceContext);
mLangService = do_GetService(NS_LANGUAGEATOMSERVICE_CONTRACTID);
mPrefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
nsCOMPtr<nsIPrefBranchInternal> prefInternal(do_QueryInterface(mPrefBranch));
if (prefInternal) {
// Register observers so we're notified when the preferences change
prefInternal->AddObserver("browser.anchor_color", this, PR_FALSE);
prefInternal->AddObserver("browser.display.", this, PR_FALSE);
prefInternal->AddObserver("browser.underline_anchors", this, PR_FALSE);
prefInternal->AddObserver("browser.visited_color", this, PR_FALSE);
prefInternal->AddObserver("font.", this, PR_FALSE);
prefInternal->AddObserver("image.animation_mode", this, PR_FALSE);
prefInternal->AddObserver("network.image.imageBehavior", this, PR_FALSE);
mPrefs = do_GetService(NS_PREF_CONTRACTID);
if (mPrefs) {
// Register callbacks so we're notified when the preferences change
mPrefs->RegisterCallback("font.", nsPresContext::PrefChangedCallback, (void*)this);
mPrefs->RegisterCallback("browser.display.", nsPresContext::PrefChangedCallback, (void*)this);
mPrefs->RegisterCallback("browser.underline_anchors", nsPresContext::PrefChangedCallback, (void*)this);
mPrefs->RegisterCallback("browser.anchor_color", nsPresContext::PrefChangedCallback, (void*)this);
mPrefs->RegisterCallback("browser.visited_color", nsPresContext::PrefChangedCallback, (void*)this);
mPrefs->RegisterCallback("network.image.imageBehavior", nsPresContext::PrefChangedCallback, (void*)this);
mPrefs->RegisterCallback("image.animation_mode", nsPresContext::PrefChangedCallback, (void*)this);
#ifdef IBMBIDI
prefInternal->AddObserver("bidi.", this, PR_FALSE);
mPrefs->RegisterCallback("bidi.", PrefChangedCallback, (void*)this);
#endif
// Initialize our state from the user preferences
@ -743,11 +751,6 @@ nsPresContext::Observe(nsISupports* aSubject,
return NS_OK;
}
if (!nsCRT::strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID)) {
PreferenceChanged(NS_LossyConvertUCS2toASCII(aData).get());
return NS_OK;
}
NS_WARNING("unrecognized topic in nsPresContext::Observe");
return NS_ERROR_FAILURE;
}

Просмотреть файл

@ -60,6 +60,7 @@ class nsIFrame;
class nsIImage;
class nsILinkHandler;
class nsIPresShell;
class nsIPref;
class nsIStyleContext;
class nsIAtom;
class nsString;

Просмотреть файл

@ -57,8 +57,7 @@
#include "prinrval.h"
#include "nsVoidArray.h"
#include "nsHashtable.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIPref.h"
#include "nsIViewObserver.h"
#include "nsContainerFrame.h"
#include "nsIDeviceContext.h"
@ -198,6 +197,7 @@ static nsresult CtlStyleWatch(PRUint32 aCtlValue, nsIStyleSet *aStyleSet);
static NS_DEFINE_CID(kFrameSelectionCID, NS_FRAMESELECTION_CID);
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
static NS_DEFINE_CID(kViewCID, NS_VIEW_CID);
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
#undef NOISY
@ -1694,11 +1694,10 @@ PresShell::Init(nsIDocument* aDocument,
gAsyncReflowDuringDocLoad = PR_TRUE;
// Get the prefs service
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefBranch) {
prefBranch->GetIntPref("layout.reflow.timeslice", &gMaxRCProcessingTime);
prefBranch->GetBoolPref("layout.reflow.async.duringDocLoad",
&gAsyncReflowDuringDocLoad);
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID, &result));
if (NS_SUCCEEDED(result)) {
prefs->GetIntPref("layout.reflow.timeslice", &gMaxRCProcessingTime);
prefs->GetBoolPref("layout.reflow.async.duringDocLoad", &gAsyncReflowDuringDocLoad);
}
}
@ -1717,19 +1716,16 @@ PresShell::Init(nsIDocument* aDocument,
#endif
#ifdef MOZ_REFLOW_PERF
if (mReflowCountMgr) {
// Get the prefs service
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefBranch) {
// Get the prefs service
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID, &result));
if (NS_SUCCEEDED(result)) {
if (mReflowCountMgr != nsnull) {
PRBool paintFrameCounts = PR_FALSE;
PRBool dumpFrameCounts = PR_FALSE;
PRBool dumpFrameByFrameCounts = PR_FALSE;
prefBranch->GetBoolPref("layout.reflow.showframecounts",
&paintFrameCounts);
prefBranch->GetBoolPref("layout.reflow.dumpframecounts",
&dumpFrameCounts);
prefBranch->GetBoolPref("layout.reflow.dumpframebyframecounts",
&dumpFrameByFrameCounts);
prefs->GetBoolPref("layout.reflow.showframecounts", &paintFrameCounts);
prefs->GetBoolPref("layout.reflow.dumpframecounts", &dumpFrameCounts);
prefs->GetBoolPref("layout.reflow.dumpframebyframecounts", &dumpFrameByFrameCounts);
mReflowCountMgr->SetDumpFrameCounts(dumpFrameCounts);
mReflowCountMgr->SetDumpFrameByFrameCounts(dumpFrameByFrameCounts);
@ -2858,9 +2854,9 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
else {
// Initialize the timer.
PRInt32 delay = PAINTLOCK_EVENT_DELAY; // Use this value if we fail to get the pref value.
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefBranch)
prefBranch->GetIntPref("nglayout.initialpaint.delay", &delay);
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID));
if (prefs)
prefs->GetIntPref("nglayout.initialpaint.delay", &delay);
nsCOMPtr<nsITimerInternal> ti = do_QueryInterface(mPaintSuppressionTimer);
ti->SetIdle(PR_FALSE);
@ -4008,9 +4004,9 @@ PresShell::GoToAnchor(const nsAString& aAnchorName)
// Should we select the target?
// This action is controlled by a preference: the default is to not select.
PRBool selectAnchor = PR_FALSE;
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefBranch) {
prefBranch->GetBoolPref("layout.selectanchor", &selectAnchor);
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID,&rv));
if (NS_SUCCEEDED(rv) && prefs) {
prefs->GetBoolPref("layout.selectanchor",&selectAnchor);
}
// Even if select anchor pref is false, we must still move the caret there.
// That way tabbing will start from the new location

Просмотреть файл

@ -60,6 +60,7 @@ class nsIFrame;
class nsIImage;
class nsILinkHandler;
class nsIPresShell;
class nsIPref;
class nsIStyleContext;
class nsIAtom;
class nsString;

Просмотреть файл

@ -60,6 +60,7 @@ class nsIFrame;
class nsIImage;
class nsILinkHandler;
class nsIPresShell;
class nsIPref;
class nsIStyleContext;
class nsIAtom;
class nsString;

Просмотреть файл

@ -75,6 +75,7 @@
#ifdef IBMBIDI
//-------------------------------IBM BIDI--------------------------------------
// Mamdouh : Modifiaction of the caret to work with Bidi in the LTR and RTL
#include "nsIPref.h"
#include "nsLayoutAtoms.h"
//------------------------------END OF IBM BIDI--------------------------------
#endif //IBMBIDI

Просмотреть файл

@ -37,9 +37,7 @@
#include "nsCOMPtr.h"
#include "nsPresContext.h"
#include "nsIPresShell.h"
#include "nsIPrefService.h"
#include "nsIPrefBranchInternal.h"
#include "nsISupportsPrimitives.h"
#include "nsIPref.h"
#include "nsILinkHandler.h"
#include "nsIDocShellTreeItem.h"
#include "nsIStyleSet.h"
@ -97,6 +95,18 @@ MakeColorPref(const char *colstr)
return colorref;
}
int PR_CALLBACK
nsPresContext::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
}
#ifdef IBMBIDI
PRBool
IsVisualCharset(const nsAutoString& aCharset)
@ -213,22 +223,23 @@ nsPresContext::~nsPresContext()
if (mEventManager)
mEventManager->SetPresContext(nsnull); // unclear if this is needed, but can't hurt
// Unregister preference observers
nsCOMPtr<nsIPrefBranchInternal> prefInternal(do_QueryInterface(mPrefBranch));
if (prefInternal) {
prefInternal->RemoveObserver("browser.anchor_color", this);
prefInternal->RemoveObserver("browser.display.", this);
prefInternal->RemoveObserver("browser.underline_anchors", this);
prefInternal->RemoveObserver("browser.visited_color", this);
prefInternal->RemoveObserver("font.", this);
prefInternal->RemoveObserver("image.animation_mode", this);
prefInternal->RemoveObserver("network.image.imageBehavior", this);
// Unregister preference callbacks
if (mPrefs) {
mPrefs->UnregisterCallback("font.", nsPresContext::PrefChangedCallback, (void*)this);
mPrefs->UnregisterCallback("browser.display.", nsPresContext::PrefChangedCallback, (void*)this);
mPrefs->UnregisterCallback("browser.underline_anchors", nsPresContext::PrefChangedCallback, (void*)this);
mPrefs->UnregisterCallback("browser.anchor_color", nsPresContext::PrefChangedCallback, (void*)this);
mPrefs->UnregisterCallback("browser.visited_color", nsPresContext::PrefChangedCallback, (void*)this);
mPrefs->UnregisterCallback("network.image.imageBehavior", nsPresContext::PrefChangedCallback, (void*)this);
mPrefs->UnregisterCallback("image.animation_mode", nsPresContext::PrefChangedCallback, (void*)this);
#ifdef IBMBIDI
prefInternal->RemoveObserver("bidi.", this);
mPrefs->UnregisterCallback("bidi.", PrefChangedCallback, (void*)this);
#endif
}
#ifdef IBMBIDI
delete mBidiUtils;
if (mBidiUtils) {
delete mBidiUtils;
}
#endif // IBMBIDI
}
@ -251,7 +262,7 @@ static const char* const kGenericFont[] = {
void
nsPresContext::GetFontPreferences()
{
if (!mPrefBranch || !mLanguage)
if (!mPrefs || !mLanguage)
return;
/* Fetch the font prefs to be used -- see bug 61883 for details.
@ -281,12 +292,13 @@ nsPresContext::GetFontPreferences()
langGroupAtom->ToString(langGroup);
nsCAutoString pref;
nsXPIDLString value;
nsXPIDLCString cvalue;
// get the current applicable font-size unit
enum {eUnit_unknown = -1, eUnit_px, eUnit_pt};
PRInt32 unit = eUnit_px;
nsresult rv = mPrefBranch->GetCharPref("font.size.unit", getter_Copies(cvalue));
nsresult rv = mPrefs->CopyCharPref("font.size.unit", getter_Copies(cvalue));
if (NS_SUCCEEDED(rv)) {
if (!PL_strcmp(cvalue.get(), "px")) {
unit = eUnit_px;
@ -302,9 +314,8 @@ nsPresContext::GetFontPreferences()
// get font.minimum-size.[langGroup]
PRInt32 size;
pref.Assign("font.minimum-size.");
pref.Append(NS_ConvertUCS2toUTF8(langGroup));
rv = mPrefBranch->GetIntPref(pref.get(), &size);
pref.Assign("font.minimum-size."); pref.Append(NS_ConvertUCS2toUTF8(langGroup));
rv = mPrefs->GetIntPref(pref.get(), &size);
if (NS_SUCCEEDED(rv)) {
if (unit == eUnit_px) {
mMinimumFontSize = NSFloatPixelsToTwips((float)size, p2t);
@ -320,7 +331,7 @@ nsPresContext::GetFontPreferences()
generic_dot_langGroup.Assign(kGenericFont[eType]);
generic_dot_langGroup.Append(NS_ConvertUCS2toUTF8(langGroup));
nsFont* font = nsnull;
nsFont* font;
switch (eType) {
case eDefaultFont_Variable: font = &mDefaultVariableFont; break;
case eDefaultFont_Fixed: font = &mDefaultFixedFont; break;
@ -336,19 +347,14 @@ nsPresContext::GetFontPreferences()
// in GFX and will be queried there when hunting for alternative fonts)
if (eType == eDefaultFont_Variable) {
MAKE_FONT_PREF_KEY(pref, "font.name", generic_dot_langGroup);
nsCOMPtr<nsISupportsString> prefString;
mPrefBranch->GetComplexValue(pref.get(),
NS_GET_IID(nsISupportsString),
getter_AddRefs(prefString));
if (prefString) {
prefString->GetData(font->name);
rv = mPrefs->CopyUnicharPref(pref.get(), getter_Copies(value));
if (NS_SUCCEEDED(rv)) {
font->name.Assign(value);
}
else {
mPrefBranch->GetComplexValue("font.default",
NS_GET_IID(nsISupportsString),
getter_AddRefs(prefString));
if (prefString) {
prefString->GetData(mDefaultVariableFont.name);
rv = mPrefs->CopyUnicharPref("font.default", getter_Copies(value));
if (NS_SUCCEEDED(rv)) {
mDefaultVariableFont.name.Assign(value);
}
}
}
@ -375,7 +381,7 @@ nsPresContext::GetFontPreferences()
// get font.size.[generic].[langGroup]
// size=0 means 'Auto', i.e., generic fonts retain the size of the variable font
MAKE_FONT_PREF_KEY(pref, "font.size", generic_dot_langGroup);
rv = mPrefBranch->GetIntPref(pref.get(), &size);
rv = mPrefs->GetIntPref(pref.get(), &size);
if (NS_SUCCEEDED(rv) && size > 0) {
if (unit == eUnit_px) {
font->size = NSFloatPixelsToTwips((float)size, p2t);
@ -388,7 +394,7 @@ nsPresContext::GetFontPreferences()
// get font.size-adjust.[generic].[langGroup]
// XXX only applicable on GFX ports that handle |font-size-adjust|
MAKE_FONT_PREF_KEY(pref, "font.size-adjust", generic_dot_langGroup);
rv = mPrefBranch->GetCharPref(pref.get(), getter_Copies(cvalue));
rv = mPrefs->CopyCharPref(pref.get(), getter_Copies(cvalue));
if (NS_SUCCEEDED(rv)) {
font->sizeAdjust = (float)atof(cvalue.get());
}
@ -415,15 +421,15 @@ nsPresContext::GetDocumentColorPreferences()
usePrefColors = PR_FALSE;
}
if (usePrefColors) {
if (NS_SUCCEEDED(mPrefBranch->GetBoolPref("browser.display.use_system_colors", &boolPref))) {
if (NS_SUCCEEDED(mPrefs->GetBoolPref("browser.display.use_system_colors", &boolPref))) {
usePrefColors = !boolPref;
}
}
if (usePrefColors) {
if (NS_SUCCEEDED(mPrefBranch->GetCharPref("browser.display.foreground_color", getter_Copies(colorStr)))) {
if (NS_SUCCEEDED(mPrefs->CopyCharPref("browser.display.foreground_color", getter_Copies(colorStr)))) {
mDefaultColor = MakeColorPref(colorStr);
}
if (NS_SUCCEEDED(mPrefBranch->GetCharPref("browser.display.background_color", getter_Copies(colorStr)))) {
if (NS_SUCCEEDED(mPrefs->CopyCharPref("browser.display.background_color", getter_Copies(colorStr)))) {
mDefaultBackgroundColor = MakeColorPref(colorStr);
}
}
@ -439,7 +445,7 @@ nsPresContext::GetDocumentColorPreferences()
}
}
if (NS_SUCCEEDED(mPrefBranch->GetBoolPref("browser.display.use_document_colors", &boolPref))) {
if (NS_SUCCEEDED(mPrefs->GetBoolPref("browser.display.use_document_colors", &boolPref))) {
mUseDocumentColors = boolPref;
}
}
@ -447,13 +453,13 @@ nsPresContext::GetDocumentColorPreferences()
void
nsPresContext::GetUserPreferences()
{
PRInt32 prefInt = 0;
PRInt32 prefInt;
if (NS_SUCCEEDED(mPrefBranch->GetIntPref("browser.display.base_font_scaler", &prefInt))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("browser.display.base_font_scaler", &prefInt))) {
mFontScaler = prefInt;
}
if (NS_SUCCEEDED(mPrefBranch->GetIntPref("nglayout.widget.mode", &prefInt))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("nglayout.widget.mode", &prefInt))) {
mWidgetRenderingMode = (enum nsWidgetRendering)prefInt; // bad cast
}
@ -462,75 +468,78 @@ nsPresContext::GetUserPreferences()
// * link colors
PRBool boolPref;
nsXPIDLCString stringPref;
if (NS_SUCCEEDED(mPrefBranch->GetBoolPref("browser.underline_anchors", &boolPref))) {
nsXPIDLCString colorStr;
if (NS_SUCCEEDED(mPrefs->GetBoolPref("browser.underline_anchors", &boolPref))) {
mUnderlineLinks = boolPref;
}
if (NS_SUCCEEDED(mPrefBranch->GetCharPref("browser.anchor_color", getter_Copies(stringPref)))) {
mLinkColor = MakeColorPref(stringPref);
if (NS_SUCCEEDED(mPrefs->CopyCharPref("browser.anchor_color", getter_Copies(colorStr)))) {
mLinkColor = MakeColorPref(colorStr);
}
if (NS_SUCCEEDED(mPrefBranch->GetCharPref("browser.visited_color", getter_Copies(stringPref)))) {
mVisitedLinkColor = MakeColorPref(stringPref);
if (NS_SUCCEEDED(mPrefs->CopyCharPref("browser.visited_color", getter_Copies(colorStr)))) {
mVisitedLinkColor = MakeColorPref(colorStr);
}
if (NS_SUCCEEDED(mPrefBranch->GetBoolPref("browser.display.use_focus_colors", &boolPref))) {
if (NS_SUCCEEDED(mPrefs->GetBoolPref("browser.display.use_focus_colors", &boolPref))) {
mUseFocusColors = boolPref;
mFocusTextColor = mDefaultColor;
mFocusBackgroundColor = mDefaultBackgroundColor;
if (NS_SUCCEEDED(mPrefBranch->GetCharPref("browser.display.focus_text_color", getter_Copies(stringPref)))) {
mFocusTextColor = MakeColorPref(stringPref);
if (NS_SUCCEEDED(mPrefs->CopyCharPref("browser.display.focus_text_color", getter_Copies(colorStr)))) {
mFocusTextColor = MakeColorPref(colorStr);
}
if (NS_SUCCEEDED(mPrefBranch->GetCharPref("browser.display.focus_background_color", getter_Copies(stringPref)))) {
mFocusBackgroundColor = MakeColorPref(stringPref);
if (NS_SUCCEEDED(mPrefs->CopyCharPref("browser.display.focus_background_color", getter_Copies(colorStr)))) {
mFocusBackgroundColor = MakeColorPref(colorStr);
}
}
if (NS_SUCCEEDED(mPrefBranch->GetIntPref("browser.display.focus_ring_width", &prefInt))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("browser.display.focus_ring_width", &prefInt))) {
mFocusRingWidth = prefInt;
}
if (NS_SUCCEEDED(mPrefBranch->GetBoolPref("browser.display.focus_ring_on_anything", &boolPref))) {
if (NS_SUCCEEDED(mPrefs->GetBoolPref("browser.display.focus_ring_on_anything", &boolPref))) {
mFocusRingOnAnything = boolPref;
}
// * use fonts?
if (NS_SUCCEEDED(mPrefBranch->GetIntPref("browser.display.use_document_fonts", &prefInt))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("browser.display.use_document_fonts", &prefInt))) {
mUseDocumentFonts = prefInt == 0 ? PR_FALSE : PR_TRUE;
}
GetFontPreferences();
// * image animation
nsresult rv = mPrefBranch->GetCharPref("image.animation_mode", getter_Copies(stringPref));
if (NS_SUCCEEDED(rv)) {
if (stringPref.Equals("normal"))
char* animatePref = 0;
nsresult rv = mPrefs->CopyCharPref("image.animation_mode", &animatePref);
if (NS_SUCCEEDED(rv) && animatePref) {
if (!nsCRT::strcmp(animatePref, "normal"))
mImageAnimationModePref = imgIContainer::kNormalAnimMode;
else if (stringPref.Equals("none"))
else if (!nsCRT::strcmp(animatePref, "none"))
mImageAnimationModePref = imgIContainer::kDontAnimMode;
else if (stringPref.Equals("once"))
else if (!nsCRT::strcmp(animatePref, "once"))
mImageAnimationModePref = imgIContainer::kLoopOnceAnimMode;
nsMemory::Free(animatePref);
}
#ifdef IBMBIDI
if (NS_SUCCEEDED(mPrefBranch->GetIntPref("bidi.direction", &prefInt))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("bidi.direction", &prefInt))) {
SET_BIDI_OPTION_DIRECTION(mBidi, prefInt);
}
if (NS_SUCCEEDED(mPrefBranch->GetIntPref("bidi.texttype", &prefInt))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("bidi.texttype", &prefInt))) {
SET_BIDI_OPTION_TEXTTYPE(mBidi, prefInt);
}
if (NS_SUCCEEDED(mPrefBranch->GetIntPref("bidi.controlstextmode", &prefInt))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("bidi.controlstextmode", &prefInt))) {
SET_BIDI_OPTION_CONTROLSTEXTMODE(mBidi, prefInt);
}
if (NS_SUCCEEDED(mPrefBranch->GetIntPref("bidi.clipboardtextmode", &prefInt))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("bidi.clipboardtextmode", &prefInt))) {
SET_BIDI_OPTION_CLIPBOARDTEXTMODE(mBidi, prefInt);
}
if (NS_SUCCEEDED(mPrefBranch->GetIntPref("bidi.numeral", &prefInt))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("bidi.numeral", &prefInt))) {
SET_BIDI_OPTION_NUMERAL(mBidi, prefInt);
}
if (NS_SUCCEEDED(mPrefBranch->GetIntPref("bidi.support", &prefInt))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("bidi.support", &prefInt))) {
SET_BIDI_OPTION_SUPPORT(mBidi, prefInt);
}
if (NS_SUCCEEDED(mPrefBranch->GetIntPref("bidi.characterset", &prefInt))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("bidi.characterset", &prefInt))) {
SET_BIDI_OPTION_CHARACTERSET(mBidi, prefInt);
}
#endif
@ -625,19 +634,18 @@ nsPresContext::Init(nsIDeviceContext* aDeviceContext)
mDeviceContext = dont_QueryInterface(aDeviceContext);
mLangService = do_GetService(NS_LANGUAGEATOMSERVICE_CONTRACTID);
mPrefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
nsCOMPtr<nsIPrefBranchInternal> prefInternal(do_QueryInterface(mPrefBranch));
if (prefInternal) {
// Register observers so we're notified when the preferences change
prefInternal->AddObserver("browser.anchor_color", this, PR_FALSE);
prefInternal->AddObserver("browser.display.", this, PR_FALSE);
prefInternal->AddObserver("browser.underline_anchors", this, PR_FALSE);
prefInternal->AddObserver("browser.visited_color", this, PR_FALSE);
prefInternal->AddObserver("font.", this, PR_FALSE);
prefInternal->AddObserver("image.animation_mode", this, PR_FALSE);
prefInternal->AddObserver("network.image.imageBehavior", this, PR_FALSE);
mPrefs = do_GetService(NS_PREF_CONTRACTID);
if (mPrefs) {
// Register callbacks so we're notified when the preferences change
mPrefs->RegisterCallback("font.", nsPresContext::PrefChangedCallback, (void*)this);
mPrefs->RegisterCallback("browser.display.", nsPresContext::PrefChangedCallback, (void*)this);
mPrefs->RegisterCallback("browser.underline_anchors", nsPresContext::PrefChangedCallback, (void*)this);
mPrefs->RegisterCallback("browser.anchor_color", nsPresContext::PrefChangedCallback, (void*)this);
mPrefs->RegisterCallback("browser.visited_color", nsPresContext::PrefChangedCallback, (void*)this);
mPrefs->RegisterCallback("network.image.imageBehavior", nsPresContext::PrefChangedCallback, (void*)this);
mPrefs->RegisterCallback("image.animation_mode", nsPresContext::PrefChangedCallback, (void*)this);
#ifdef IBMBIDI
prefInternal->AddObserver("bidi.", this, PR_FALSE);
mPrefs->RegisterCallback("bidi.", PrefChangedCallback, (void*)this);
#endif
// Initialize our state from the user preferences
@ -743,11 +751,6 @@ nsPresContext::Observe(nsISupports* aSubject,
return NS_OK;
}
if (!nsCRT::strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID)) {
PreferenceChanged(NS_LossyConvertUCS2toASCII(aData).get());
return NS_OK;
}
NS_WARNING("unrecognized topic in nsPresContext::Observe");
return NS_ERROR_FAILURE;
}

Просмотреть файл

@ -43,7 +43,7 @@
#include "nsFont.h"
#include "nsCRT.h"
#include "nsCOMPtr.h"
#include "nsIPrefBranch.h"
#include "nsIPref.h"
#include "nsICharsetConverterManager.h"
#include "nsILanguageAtomService.h"
#include "nsIURL.h"
@ -206,7 +206,7 @@ protected:
// class, please make the ownership explicit (pinkerton, scc).
nsIPresShell* mShell; // [WEAK]
nsCOMPtr<nsIPrefBranch> mPrefBranch;
nsCOMPtr<nsIPref> mPrefs;
nsRect mVisibleArea;
nsCOMPtr<nsIDeviceContext> mDeviceContext; // could be weak, but better safe than sorry. Cannot reintroduce cycles
// since there is no dependency from gfx back to layout.
@ -289,6 +289,7 @@ protected:
void SetImgAnimations(nsCOMPtr<nsIContent>& aParent, PRUint16 aMode);
private:
static int PR_CALLBACK PrefChangedCallback(const char*, void*);
void PreferenceChanged(const char* aPrefName);
// these are private, use the list in nsFont.h if you want a public list

Просмотреть файл

@ -88,8 +88,7 @@
#include "nsIPercentHeightObserver.h"
// For triple-click pref
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIPref.h"
#include "nsIServiceManager.h"
#include "nsISelectionImageService.h"
#include "imgIContainer.h"
@ -99,6 +98,7 @@
#include "nsWidgetsCID.h" // for NS_LOOKANDFEEL_CID
#include "nsLayoutErrors.h"
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);//for triple click pref
static NS_DEFINE_CID(kSelectionImageService, NS_SELECTIONIMAGESERVICE_CID);
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
@ -1527,9 +1527,9 @@ nsFrame::HandleMultiplePress(nsIPresContext* aPresContext,
selectPara = PR_TRUE;
else if (me->clickCount == 3)
{
nsCOMPtr<nsIPrefBranch> prefBranch( do_GetService(NS_PREFSERVICE_CONTRACTID) );
if (prefBranch)
prefBranch->GetBoolPref("browser.triple_click_selects_paragraph", &selectPara);
nsCOMPtr<nsIPref> prefsService( do_GetService(kPrefCID, &rv) );
if (NS_SUCCEEDED(rv) && prefsService)
prefsService->GetBoolPref("browser.triple_click_selects_paragraph", &selectPara);
}
else
return NS_OK;

Просмотреть файл

@ -68,6 +68,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIDocumentLoader.h"
#include "nsIPref.h"
#include "nsFrameSetFrame.h"
#include "nsIDOMHTMLFrameElement.h"
#include "nsIDOMHTMLIFrameElement.h"

Просмотреть файл

@ -48,10 +48,7 @@
#include "nsBlockFrame.h"
#include "nsLineBox.h"
#include "nsImageFrame.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "nsIPrefBranchInternal.h"
#include "nsIObserver.h"
#include "nsIPref.h"
#include "nsIServiceManager.h"
#include "nsIPercentHeightObserver.h"
#ifdef IBMBIDI
@ -1628,81 +1625,44 @@ nsHTMLReflowState::ComputeContainingBlockRectangle(nsIPresContext* aPre
}
}
class BlinkPrefObserver : public nsIObserver
// Prefs callback to pick up changes
static int PR_CALLBACK PrefsChanged(const char *aPrefName, void *instance)
{
public:
BlinkPrefObserver();
virtual ~BlinkPrefObserver();
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
};
BlinkPrefObserver::BlinkPrefObserver()
{
NS_INIT_ISUPPORTS();
}
BlinkPrefObserver::~BlinkPrefObserver()
{
}
NS_IMPL_ISUPPORTS1(BlinkPrefObserver, nsIObserver)
NS_IMETHODIMP
BlinkPrefObserver::Observe(nsISupports *aSubject, const char *aTopic,
const PRUnichar *aData)
{
NS_ASSERTION(!nsCRT::strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID),
"We only handle pref changes");
NS_ASSERTION(nsDependentString(aData) ==
NS_LITERAL_STRING("browser.blink_allowed"),
"We only handle the blink pref");
nsCOMPtr<nsIPrefBranch> prefBranch(do_QueryInterface(aSubject));
PRBool boolPrefValue = PR_TRUE;
prefBranch->GetBoolPref("browser.blink_allowed", &boolPrefValue);
sBlinkIsAllowed = boolPrefValue;
return NS_OK;
nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID);
if (prefs) {
PRBool boolPref;
if (NS_SUCCEEDED(prefs->GetBoolPref("browser.blink_allowed", &boolPref)))
sBlinkIsAllowed = boolPref;
}
return 0; /* PREF_OK */
}
// Check to see if |text-decoration: blink| is allowed. The first time
// called, register the observer and then force-load the pref. After that,
// called, register the callback and then force-load the pref. After that,
// just use the cached value.
static
PRBool BlinkIsAllowed()
static PRBool BlinkIsAllowed(void)
{
if (!sPrefIsLoaded) {
// Set up an observer and check the initial value
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
if (prefBranch) {
PRBool boolPrefValue = PR_TRUE;
prefBranch->GetBoolPref("browser.blink_allowed", &boolPrefValue);
sBlinkIsAllowed = boolPrefValue;
nsCOMPtr<nsIObserver> observer = new BlinkPrefObserver();
if (observer) {
nsCOMPtr<nsIPrefBranchInternal> pbi = do_QueryInterface(prefBranch);
if (pbi) {
pbi->AddObserver("browser.blink_allowed", observer, PR_FALSE);
}
}
// Set up a listener and check the initial value
nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID);
if (prefs) {
prefs->RegisterCallback("browser.blink_allowed", PrefsChanged,
nsnull);
}
PrefsChanged(nsnull, nsnull);
sPrefIsLoaded = PR_TRUE;
}
return sBlinkIsAllowed;
}
static eNormalLineHeightControl GetNormalLineHeightCalcControl(void)
{
if (sNormalLineHeightControl == eUninitialized) {
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID);
PRInt32 intPref;
// browser.display.normal_lineheight_calc_control is not user changable, so
// no need to register callback for it.
if (prefBranch && NS_SUCCEEDED(prefBranch->GetIntPref(
if (prefs && NS_SUCCEEDED(prefs->GetIntPref(
"browser.display.normal_lineheight_calc_control", &intPref)))
sNormalLineHeightControl = NS_STATIC_CAST(eNormalLineHeightControl, intPref);
else

Просмотреть файл

@ -94,8 +94,7 @@
#include "nsIDOMWindow.h"
#include "nsIDOMDocument.h"
#include "nsCSSFrameConstructor.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIPref.h"
#ifdef DEBUG
#undef NOISY_IMAGE_LOADING
@ -2271,21 +2270,21 @@ void nsImageFrame::IconLoad::GetPrefs(nsIPresContext *aPresContext)
NS_ASSERTION(aPresContext, "null presContext is not allowed in GetAltModePref");
// NOTE: the presContext could be used to fetch a cached pref if needed, but is not for now
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
if (prefBranch) {
nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID);
if (prefs) {
PRBool boolPref;
PRInt32 intPref;
if (NS_SUCCEEDED(prefBranch->GetBoolPref("browser.display.force_inline_alttext", &boolPref))) {
if (NS_SUCCEEDED(prefs->GetBoolPref("browser.display.force_inline_alttext", &boolPref))) {
mPrefForceInlineAltText = boolPref;
} else {
mPrefForceInlineAltText = PR_FALSE;
}
if (NS_SUCCEEDED(prefBranch->GetIntPref("network.image.imageBehavior", &intPref)) && intPref == 2) {
if (NS_SUCCEEDED(prefs->GetIntPref("network.image.imageBehavior", &intPref)) && intPref == 2) {
mPrefAllImagesBlocked = PR_TRUE;
} else {
mPrefAllImagesBlocked = PR_FALSE;
}
if (NS_SUCCEEDED(prefBranch->GetBoolPref("browser.display.show_image_placeholders", &boolPref))) {
if (NS_SUCCEEDED(prefs->GetBoolPref("browser.display.show_image_placeholders", &boolPref))) {
mPrefShowPlaceholders = boolPref;
} else {
mPrefShowPlaceholders = PR_TRUE;

Просмотреть файл

@ -114,8 +114,7 @@
#include "jsapi.h"
// XXX temporary for Mac double buffering pref
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIPref.h"
// XXX For temporary paint code
#include "nsIStyleContext.h"
@ -140,6 +139,9 @@
#include "nsContentCID.h"
static NS_DEFINE_CID(kRangeCID, NS_RANGE_CID);
// XXX temporary for Mac double buffering pref
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
/* X headers suck */
#ifdef KeyPress
#undef KeyPress
@ -795,12 +797,10 @@ nsObjectFrame::CreateWidget(nsIPresContext* aPresContext,
// Turn off double buffering on the Mac. This depends on bug 49743 and partially
// fixes 32327, 19931 amd 51787
#if defined(XP_MAC) || defined(XP_MACOSX)
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID));
PRBool doubleBuffer = PR_FALSE;
if (prefBranch) {
prefBranch->GetBoolPref("plugin.enable_double_buffer", &doubleBuffer);
}
prefs ? prefs->GetBoolPref("plugin.enable_double_buffer", &doubleBuffer) : 0;
viewMan->AllowDoubleBuffering(doubleBuffer);
#endif

Просмотреть файл

@ -54,9 +54,7 @@
#include "nsRegion.h"
#include "nsLayoutAtoms.h"
// for header/footer gap & ExtraMargin for Print Preview
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIPref.h" // for header/footer gap & ExtraMargin for Print Preview
// DateTime Includes
#include "nsDateTimeFormatCID.h"
@ -218,30 +216,23 @@ nsSimplePageSequenceFrame::CreateContinuingPageFrame(nsIPresContext* aPresContex
return rv;
}
void
nsSimplePageSequenceFrame::GetEdgePaperMarginCoord(char* aPrefName,
nscoord& aCoord)
void nsSimplePageSequenceFrame::GetEdgePaperMarginCoord(nsIPref* aPref, char* aPrefName, nscoord& aCoord)
{
nsresult rv = mPageData->mPrintOptions->
GetPrinterPrefInt(mPageData->mPrintSettings,
NS_ConvertASCIItoUCS2(aPrefName).get(),
&aCoord);
if (NS_SUCCEEDED(rv)) {
if (NS_SUCCEEDED(mPageData->mPrintOptions->GetPrinterPrefInt(mPageData->mPrintSettings,
NS_ConvertASCIItoUCS2(aPrefName).get(), &aCoord))) {
nscoord inchInTwips = NS_INCHES_TO_TWIPS(1.0);
aCoord = PR_MAX(NS_INCHES_TO_TWIPS(float(aCoord)/100.0f), 0);
aCoord = PR_MIN(aCoord, inchInTwips); // an inch is still probably excessive
}
}
void
nsSimplePageSequenceFrame::GetEdgePaperMargin(nsMargin& aMargin)
void nsSimplePageSequenceFrame::GetEdgePaperMargin(nsIPref* aPref, nsMargin& aMargin)
{
aMargin.SizeTo(0,0,0,0);
GetEdgePaperMarginCoord("print_edge_top", aMargin.top);
GetEdgePaperMarginCoord("print_edge_left", aMargin.left);
GetEdgePaperMarginCoord("print_edge_bottom", aMargin.bottom);
GetEdgePaperMarginCoord("print_edge_right", aMargin.right);
GetEdgePaperMarginCoord(aPref, "print_edge_top", aMargin.top);
GetEdgePaperMarginCoord(aPref, "print_edge_left", aMargin.left);
GetEdgePaperMarginCoord(aPref, "print_edge_bottom", aMargin.bottom);
GetEdgePaperMarginCoord(aPref, "print_edge_right", aMargin.right);
}
NS_IMETHODIMP
@ -318,12 +309,12 @@ nsSimplePageSequenceFrame::Reflow(nsIPresContext* aPresContext,
aPresContext->GetPageDim(&pageSize, &adjSize);
nscoord extraGap = 0;
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
if (prefBranch) {
GetEdgePaperMargin(mPageData->mEdgePaperMargin);
nsCOMPtr<nsIPref> pref = do_GetService(NS_PREF_CONTRACTID);
if (pref) {
GetEdgePaperMargin(pref, mPageData->mEdgePaperMargin);
nscoord extraThreshold = PR_MAX(pageSize.width, pageSize.height)/10;
PRInt32 gapInTwips;
if (NS_SUCCEEDED(prefBranch->GetIntPref("print.print_extra_margin", &gapInTwips))) {
if (NS_SUCCEEDED(pref->GetIntPref("print.print_extra_margin", &gapInTwips))) {
gapInTwips = PR_MAX(gapInTwips, 0);
gapInTwips = PR_MIN(gapInTwips, extraThreshold); // clamp to 1/10 of the largest dim of the page
extraGap = nscoord(gapInTwips);

Просмотреть файл

@ -153,8 +153,8 @@ protected:
void SetPageNumberFormat(PRUnichar * aFormatStr, PRBool aForPageNumOnly);
void SetPageSizes(const nsRect& aRect, const nsMargin& aMarginRect);
void GetEdgePaperMarginCoord(char* aPrefName, nscoord& aCoord);
void GetEdgePaperMargin(nsMargin& aMargin);
void GetEdgePaperMarginCoord(nsIPref* aPref, char* aPrefName, nscoord& aCoord);
void GetEdgePaperMargin(nsIPref* aPref, nsMargin& aMargin);
NS_IMETHOD_(nsrefcnt) AddRef(void) {return nsContainerFrame::AddRef();}
NS_IMETHOD_(nsrefcnt) Release(void) {return nsContainerFrame::Release();}

Просмотреть файл

@ -83,8 +83,7 @@
#include "nsILineIterator.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIPref.h"
#include "nsIServiceManager.h"
#ifdef ACCESSIBILITY
#include "nsIAccessible.h"
@ -106,6 +105,8 @@
#include "nsILE.h"
#endif /* SUNCTL */
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
#ifdef NS_DEBUG
#undef NOISY_BLINK
#undef DEBUG_WORD_WRAPPING
@ -1364,10 +1365,10 @@ nsTextFrame::nsTextFrame()
{
// read in our global word selection prefs
if ( !sWordSelectPrefInited ) {
nsCOMPtr<nsIPrefBranch> prefBranch ( do_GetService(NS_PREFSERVICE_CONTRACTID) );
if ( prefBranch ) {
nsCOMPtr<nsIPref> prefService ( do_GetService(NS_PREF_CONTRACTID) );
if ( prefService ) {
PRBool temp = PR_FALSE;
prefBranch->GetBoolPref("layout.word_select.eat_space_to_next_word", &temp);
prefService->GetBoolPref("layout.word_select.eat_space_to_next_word", &temp);
sWordSelectEatSpaceAfter = temp;
}
sWordSelectPrefInited = PR_TRUE;
@ -2640,12 +2641,12 @@ nsTextFrame::GetPositionSlowly(nsIPresContext* aPresContext,
ComputeExtraJustificationSpacing(*aRendContext, ts, paintBuffer.mBuffer, textLength, numSpaces);
//IF STYLE SAYS TO SELECT TO END OF FRAME HERE...
nsCOMPtr<nsIPrefBranch> prefBranch( do_GetService(NS_PREFSERVICE_CONTRACTID) );
nsCOMPtr<nsIPref> prefs( do_GetService(kPrefCID, &rv) );
PRInt32 prefInt = 0;
PRBool outofstylehandled = PR_FALSE;
if (prefBranch)
if (NS_SUCCEEDED(rv) && prefs)
{
if (NS_SUCCEEDED(prefBranch->GetIntPref("browser.drag_out_of_frame_style", &prefInt)) && prefInt)
if (NS_SUCCEEDED(prefs->GetIntPref("browser.drag_out_of_frame_style", &prefInt)) && prefInt)
{
if (aPoint.y < origin.y)//above rectangle
{
@ -3528,12 +3529,12 @@ nsTextFrame::GetPosition(nsIPresContext* aCX,
GetOffsetFromView(aCX, origin, &view);
//IF STYLE SAYS TO SELECT TO END OF FRAME HERE...
nsCOMPtr<nsIPrefBranch> prefBranch( do_GetService(NS_PREFSERVICE_CONTRACTID) );
nsCOMPtr<nsIPref> prefs( do_GetService(kPrefCID, &rv) );
PRInt32 prefInt = 0;
PRBool outofstylehandled = PR_FALSE;
if (prefBranch)
if (NS_SUCCEEDED(rv) && prefs)
{
if (NS_SUCCEEDED(prefBranch->GetIntPref("browser.drag_out_of_frame_style", &prefInt)) && prefInt)
if (NS_SUCCEEDED(prefs->GetIntPref("browser.drag_out_of_frame_style", &prefInt)) && prefInt)
{
if ((aPoint.y - origin.y) < 0)//above rectangle
{

Просмотреть файл

@ -49,8 +49,7 @@
#include "nsUnicharUtils.h"
#include "nsICaseConversion.h"
#include "prenv.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIPref.h"
#ifdef IBMBIDI
#include "nsLayoutAtoms.h"
#endif
@ -115,11 +114,10 @@ nsTextTransformer::Initialize()
// read in our global word selection prefs
if ( !sWordSelectPrefInited ) {
nsCOMPtr<nsIPrefBranch> prefBranch =
do_GetService( NS_PREFSERVICE_CONTRACTID );
if ( prefBranch ) {
nsCOMPtr<nsIPref> prefService ( do_GetService(NS_PREF_CONTRACTID) );
if ( prefService ) {
PRBool temp = PR_FALSE;
prefBranch->GetBoolPref("layout.word_select.stop_at_punctuation", &temp);
prefService->GetBoolPref("layout.word_select.stop_at_punctuation", &temp);
sWordSelectStopAtPunctuation = temp;
}
sWordSelectPrefInited = PR_TRUE;

Просмотреть файл

@ -88,8 +88,7 @@
#include "nsIPercentHeightObserver.h"
// For triple-click pref
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIPref.h"
#include "nsIServiceManager.h"
#include "nsISelectionImageService.h"
#include "imgIContainer.h"
@ -99,6 +98,7 @@
#include "nsWidgetsCID.h" // for NS_LOOKANDFEEL_CID
#include "nsLayoutErrors.h"
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);//for triple click pref
static NS_DEFINE_CID(kSelectionImageService, NS_SELECTIONIMAGESERVICE_CID);
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
@ -1527,9 +1527,9 @@ nsFrame::HandleMultiplePress(nsIPresContext* aPresContext,
selectPara = PR_TRUE;
else if (me->clickCount == 3)
{
nsCOMPtr<nsIPrefBranch> prefBranch( do_GetService(NS_PREFSERVICE_CONTRACTID) );
if (prefBranch)
prefBranch->GetBoolPref("browser.triple_click_selects_paragraph", &selectPara);
nsCOMPtr<nsIPref> prefsService( do_GetService(kPrefCID, &rv) );
if (NS_SUCCEEDED(rv) && prefsService)
prefsService->GetBoolPref("browser.triple_click_selects_paragraph", &selectPara);
}
else
return NS_OK;

Просмотреть файл

@ -48,10 +48,7 @@
#include "nsBlockFrame.h"
#include "nsLineBox.h"
#include "nsImageFrame.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "nsIPrefBranchInternal.h"
#include "nsIObserver.h"
#include "nsIPref.h"
#include "nsIServiceManager.h"
#include "nsIPercentHeightObserver.h"
#ifdef IBMBIDI
@ -1628,81 +1625,44 @@ nsHTMLReflowState::ComputeContainingBlockRectangle(nsIPresContext* aPre
}
}
class BlinkPrefObserver : public nsIObserver
// Prefs callback to pick up changes
static int PR_CALLBACK PrefsChanged(const char *aPrefName, void *instance)
{
public:
BlinkPrefObserver();
virtual ~BlinkPrefObserver();
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
};
BlinkPrefObserver::BlinkPrefObserver()
{
NS_INIT_ISUPPORTS();
}
BlinkPrefObserver::~BlinkPrefObserver()
{
}
NS_IMPL_ISUPPORTS1(BlinkPrefObserver, nsIObserver)
NS_IMETHODIMP
BlinkPrefObserver::Observe(nsISupports *aSubject, const char *aTopic,
const PRUnichar *aData)
{
NS_ASSERTION(!nsCRT::strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID),
"We only handle pref changes");
NS_ASSERTION(nsDependentString(aData) ==
NS_LITERAL_STRING("browser.blink_allowed"),
"We only handle the blink pref");
nsCOMPtr<nsIPrefBranch> prefBranch(do_QueryInterface(aSubject));
PRBool boolPrefValue = PR_TRUE;
prefBranch->GetBoolPref("browser.blink_allowed", &boolPrefValue);
sBlinkIsAllowed = boolPrefValue;
return NS_OK;
nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID);
if (prefs) {
PRBool boolPref;
if (NS_SUCCEEDED(prefs->GetBoolPref("browser.blink_allowed", &boolPref)))
sBlinkIsAllowed = boolPref;
}
return 0; /* PREF_OK */
}
// Check to see if |text-decoration: blink| is allowed. The first time
// called, register the observer and then force-load the pref. After that,
// called, register the callback and then force-load the pref. After that,
// just use the cached value.
static
PRBool BlinkIsAllowed()
static PRBool BlinkIsAllowed(void)
{
if (!sPrefIsLoaded) {
// Set up an observer and check the initial value
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
if (prefBranch) {
PRBool boolPrefValue = PR_TRUE;
prefBranch->GetBoolPref("browser.blink_allowed", &boolPrefValue);
sBlinkIsAllowed = boolPrefValue;
nsCOMPtr<nsIObserver> observer = new BlinkPrefObserver();
if (observer) {
nsCOMPtr<nsIPrefBranchInternal> pbi = do_QueryInterface(prefBranch);
if (pbi) {
pbi->AddObserver("browser.blink_allowed", observer, PR_FALSE);
}
}
// Set up a listener and check the initial value
nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID);
if (prefs) {
prefs->RegisterCallback("browser.blink_allowed", PrefsChanged,
nsnull);
}
PrefsChanged(nsnull, nsnull);
sPrefIsLoaded = PR_TRUE;
}
return sBlinkIsAllowed;
}
static eNormalLineHeightControl GetNormalLineHeightCalcControl(void)
{
if (sNormalLineHeightControl == eUninitialized) {
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID);
PRInt32 intPref;
// browser.display.normal_lineheight_calc_control is not user changable, so
// no need to register callback for it.
if (prefBranch && NS_SUCCEEDED(prefBranch->GetIntPref(
if (prefs && NS_SUCCEEDED(prefs->GetIntPref(
"browser.display.normal_lineheight_calc_control", &intPref)))
sNormalLineHeightControl = NS_STATIC_CAST(eNormalLineHeightControl, intPref);
else

Просмотреть файл

@ -94,8 +94,7 @@
#include "nsIDOMWindow.h"
#include "nsIDOMDocument.h"
#include "nsCSSFrameConstructor.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIPref.h"
#ifdef DEBUG
#undef NOISY_IMAGE_LOADING
@ -2271,21 +2270,21 @@ void nsImageFrame::IconLoad::GetPrefs(nsIPresContext *aPresContext)
NS_ASSERTION(aPresContext, "null presContext is not allowed in GetAltModePref");
// NOTE: the presContext could be used to fetch a cached pref if needed, but is not for now
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
if (prefBranch) {
nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID);
if (prefs) {
PRBool boolPref;
PRInt32 intPref;
if (NS_SUCCEEDED(prefBranch->GetBoolPref("browser.display.force_inline_alttext", &boolPref))) {
if (NS_SUCCEEDED(prefs->GetBoolPref("browser.display.force_inline_alttext", &boolPref))) {
mPrefForceInlineAltText = boolPref;
} else {
mPrefForceInlineAltText = PR_FALSE;
}
if (NS_SUCCEEDED(prefBranch->GetIntPref("network.image.imageBehavior", &intPref)) && intPref == 2) {
if (NS_SUCCEEDED(prefs->GetIntPref("network.image.imageBehavior", &intPref)) && intPref == 2) {
mPrefAllImagesBlocked = PR_TRUE;
} else {
mPrefAllImagesBlocked = PR_FALSE;
}
if (NS_SUCCEEDED(prefBranch->GetBoolPref("browser.display.show_image_placeholders", &boolPref))) {
if (NS_SUCCEEDED(prefs->GetBoolPref("browser.display.show_image_placeholders", &boolPref))) {
mPrefShowPlaceholders = boolPref;
} else {
mPrefShowPlaceholders = PR_TRUE;

Просмотреть файл

@ -114,8 +114,7 @@
#include "jsapi.h"
// XXX temporary for Mac double buffering pref
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIPref.h"
// XXX For temporary paint code
#include "nsIStyleContext.h"
@ -140,6 +139,9 @@
#include "nsContentCID.h"
static NS_DEFINE_CID(kRangeCID, NS_RANGE_CID);
// XXX temporary for Mac double buffering pref
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
/* X headers suck */
#ifdef KeyPress
#undef KeyPress
@ -795,12 +797,10 @@ nsObjectFrame::CreateWidget(nsIPresContext* aPresContext,
// Turn off double buffering on the Mac. This depends on bug 49743 and partially
// fixes 32327, 19931 amd 51787
#if defined(XP_MAC) || defined(XP_MACOSX)
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID));
PRBool doubleBuffer = PR_FALSE;
if (prefBranch) {
prefBranch->GetBoolPref("plugin.enable_double_buffer", &doubleBuffer);
}
prefs ? prefs->GetBoolPref("plugin.enable_double_buffer", &doubleBuffer) : 0;
viewMan->AllowDoubleBuffering(doubleBuffer);
#endif

Просмотреть файл

@ -57,8 +57,7 @@
#include "prinrval.h"
#include "nsVoidArray.h"
#include "nsHashtable.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIPref.h"
#include "nsIViewObserver.h"
#include "nsContainerFrame.h"
#include "nsIDeviceContext.h"
@ -198,6 +197,7 @@ static nsresult CtlStyleWatch(PRUint32 aCtlValue, nsIStyleSet *aStyleSet);
static NS_DEFINE_CID(kFrameSelectionCID, NS_FRAMESELECTION_CID);
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
static NS_DEFINE_CID(kViewCID, NS_VIEW_CID);
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
#undef NOISY
@ -1694,11 +1694,10 @@ PresShell::Init(nsIDocument* aDocument,
gAsyncReflowDuringDocLoad = PR_TRUE;
// Get the prefs service
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefBranch) {
prefBranch->GetIntPref("layout.reflow.timeslice", &gMaxRCProcessingTime);
prefBranch->GetBoolPref("layout.reflow.async.duringDocLoad",
&gAsyncReflowDuringDocLoad);
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID, &result));
if (NS_SUCCEEDED(result)) {
prefs->GetIntPref("layout.reflow.timeslice", &gMaxRCProcessingTime);
prefs->GetBoolPref("layout.reflow.async.duringDocLoad", &gAsyncReflowDuringDocLoad);
}
}
@ -1717,19 +1716,16 @@ PresShell::Init(nsIDocument* aDocument,
#endif
#ifdef MOZ_REFLOW_PERF
if (mReflowCountMgr) {
// Get the prefs service
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefBranch) {
// Get the prefs service
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID, &result));
if (NS_SUCCEEDED(result)) {
if (mReflowCountMgr != nsnull) {
PRBool paintFrameCounts = PR_FALSE;
PRBool dumpFrameCounts = PR_FALSE;
PRBool dumpFrameByFrameCounts = PR_FALSE;
prefBranch->GetBoolPref("layout.reflow.showframecounts",
&paintFrameCounts);
prefBranch->GetBoolPref("layout.reflow.dumpframecounts",
&dumpFrameCounts);
prefBranch->GetBoolPref("layout.reflow.dumpframebyframecounts",
&dumpFrameByFrameCounts);
prefs->GetBoolPref("layout.reflow.showframecounts", &paintFrameCounts);
prefs->GetBoolPref("layout.reflow.dumpframecounts", &dumpFrameCounts);
prefs->GetBoolPref("layout.reflow.dumpframebyframecounts", &dumpFrameByFrameCounts);
mReflowCountMgr->SetDumpFrameCounts(dumpFrameCounts);
mReflowCountMgr->SetDumpFrameByFrameCounts(dumpFrameByFrameCounts);
@ -2858,9 +2854,9 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
else {
// Initialize the timer.
PRInt32 delay = PAINTLOCK_EVENT_DELAY; // Use this value if we fail to get the pref value.
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefBranch)
prefBranch->GetIntPref("nglayout.initialpaint.delay", &delay);
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID));
if (prefs)
prefs->GetIntPref("nglayout.initialpaint.delay", &delay);
nsCOMPtr<nsITimerInternal> ti = do_QueryInterface(mPaintSuppressionTimer);
ti->SetIdle(PR_FALSE);
@ -4008,9 +4004,9 @@ PresShell::GoToAnchor(const nsAString& aAnchorName)
// Should we select the target?
// This action is controlled by a preference: the default is to not select.
PRBool selectAnchor = PR_FALSE;
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefBranch) {
prefBranch->GetBoolPref("layout.selectanchor", &selectAnchor);
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID,&rv));
if (NS_SUCCEEDED(rv) && prefs) {
prefs->GetBoolPref("layout.selectanchor",&selectAnchor);
}
// Even if select anchor pref is false, we must still move the caret there.
// That way tabbing will start from the new location

Просмотреть файл

@ -54,9 +54,7 @@
#include "nsRegion.h"
#include "nsLayoutAtoms.h"
// for header/footer gap & ExtraMargin for Print Preview
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIPref.h" // for header/footer gap & ExtraMargin for Print Preview
// DateTime Includes
#include "nsDateTimeFormatCID.h"
@ -218,30 +216,23 @@ nsSimplePageSequenceFrame::CreateContinuingPageFrame(nsIPresContext* aPresContex
return rv;
}
void
nsSimplePageSequenceFrame::GetEdgePaperMarginCoord(char* aPrefName,
nscoord& aCoord)
void nsSimplePageSequenceFrame::GetEdgePaperMarginCoord(nsIPref* aPref, char* aPrefName, nscoord& aCoord)
{
nsresult rv = mPageData->mPrintOptions->
GetPrinterPrefInt(mPageData->mPrintSettings,
NS_ConvertASCIItoUCS2(aPrefName).get(),
&aCoord);
if (NS_SUCCEEDED(rv)) {
if (NS_SUCCEEDED(mPageData->mPrintOptions->GetPrinterPrefInt(mPageData->mPrintSettings,
NS_ConvertASCIItoUCS2(aPrefName).get(), &aCoord))) {
nscoord inchInTwips = NS_INCHES_TO_TWIPS(1.0);
aCoord = PR_MAX(NS_INCHES_TO_TWIPS(float(aCoord)/100.0f), 0);
aCoord = PR_MIN(aCoord, inchInTwips); // an inch is still probably excessive
}
}
void
nsSimplePageSequenceFrame::GetEdgePaperMargin(nsMargin& aMargin)
void nsSimplePageSequenceFrame::GetEdgePaperMargin(nsIPref* aPref, nsMargin& aMargin)
{
aMargin.SizeTo(0,0,0,0);
GetEdgePaperMarginCoord("print_edge_top", aMargin.top);
GetEdgePaperMarginCoord("print_edge_left", aMargin.left);
GetEdgePaperMarginCoord("print_edge_bottom", aMargin.bottom);
GetEdgePaperMarginCoord("print_edge_right", aMargin.right);
GetEdgePaperMarginCoord(aPref, "print_edge_top", aMargin.top);
GetEdgePaperMarginCoord(aPref, "print_edge_left", aMargin.left);
GetEdgePaperMarginCoord(aPref, "print_edge_bottom", aMargin.bottom);
GetEdgePaperMarginCoord(aPref, "print_edge_right", aMargin.right);
}
NS_IMETHODIMP
@ -318,12 +309,12 @@ nsSimplePageSequenceFrame::Reflow(nsIPresContext* aPresContext,
aPresContext->GetPageDim(&pageSize, &adjSize);
nscoord extraGap = 0;
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
if (prefBranch) {
GetEdgePaperMargin(mPageData->mEdgePaperMargin);
nsCOMPtr<nsIPref> pref = do_GetService(NS_PREF_CONTRACTID);
if (pref) {
GetEdgePaperMargin(pref, mPageData->mEdgePaperMargin);
nscoord extraThreshold = PR_MAX(pageSize.width, pageSize.height)/10;
PRInt32 gapInTwips;
if (NS_SUCCEEDED(prefBranch->GetIntPref("print.print_extra_margin", &gapInTwips))) {
if (NS_SUCCEEDED(pref->GetIntPref("print.print_extra_margin", &gapInTwips))) {
gapInTwips = PR_MAX(gapInTwips, 0);
gapInTwips = PR_MIN(gapInTwips, extraThreshold); // clamp to 1/10 of the largest dim of the page
extraGap = nscoord(gapInTwips);

Просмотреть файл

@ -153,8 +153,8 @@ protected:
void SetPageNumberFormat(PRUnichar * aFormatStr, PRBool aForPageNumOnly);
void SetPageSizes(const nsRect& aRect, const nsMargin& aMarginRect);
void GetEdgePaperMarginCoord(char* aPrefName, nscoord& aCoord);
void GetEdgePaperMargin(nsMargin& aMargin);
void GetEdgePaperMarginCoord(nsIPref* aPref, char* aPrefName, nscoord& aCoord);
void GetEdgePaperMargin(nsIPref* aPref, nsMargin& aMargin);
NS_IMETHOD_(nsrefcnt) AddRef(void) {return nsContainerFrame::AddRef();}
NS_IMETHOD_(nsrefcnt) Release(void) {return nsContainerFrame::Release();}

Просмотреть файл

@ -83,8 +83,7 @@
#include "nsILineIterator.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIPref.h"
#include "nsIServiceManager.h"
#ifdef ACCESSIBILITY
#include "nsIAccessible.h"
@ -106,6 +105,8 @@
#include "nsILE.h"
#endif /* SUNCTL */
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
#ifdef NS_DEBUG
#undef NOISY_BLINK
#undef DEBUG_WORD_WRAPPING
@ -1364,10 +1365,10 @@ nsTextFrame::nsTextFrame()
{
// read in our global word selection prefs
if ( !sWordSelectPrefInited ) {
nsCOMPtr<nsIPrefBranch> prefBranch ( do_GetService(NS_PREFSERVICE_CONTRACTID) );
if ( prefBranch ) {
nsCOMPtr<nsIPref> prefService ( do_GetService(NS_PREF_CONTRACTID) );
if ( prefService ) {
PRBool temp = PR_FALSE;
prefBranch->GetBoolPref("layout.word_select.eat_space_to_next_word", &temp);
prefService->GetBoolPref("layout.word_select.eat_space_to_next_word", &temp);
sWordSelectEatSpaceAfter = temp;
}
sWordSelectPrefInited = PR_TRUE;
@ -2640,12 +2641,12 @@ nsTextFrame::GetPositionSlowly(nsIPresContext* aPresContext,
ComputeExtraJustificationSpacing(*aRendContext, ts, paintBuffer.mBuffer, textLength, numSpaces);
//IF STYLE SAYS TO SELECT TO END OF FRAME HERE...
nsCOMPtr<nsIPrefBranch> prefBranch( do_GetService(NS_PREFSERVICE_CONTRACTID) );
nsCOMPtr<nsIPref> prefs( do_GetService(kPrefCID, &rv) );
PRInt32 prefInt = 0;
PRBool outofstylehandled = PR_FALSE;
if (prefBranch)
if (NS_SUCCEEDED(rv) && prefs)
{
if (NS_SUCCEEDED(prefBranch->GetIntPref("browser.drag_out_of_frame_style", &prefInt)) && prefInt)
if (NS_SUCCEEDED(prefs->GetIntPref("browser.drag_out_of_frame_style", &prefInt)) && prefInt)
{
if (aPoint.y < origin.y)//above rectangle
{
@ -3528,12 +3529,12 @@ nsTextFrame::GetPosition(nsIPresContext* aCX,
GetOffsetFromView(aCX, origin, &view);
//IF STYLE SAYS TO SELECT TO END OF FRAME HERE...
nsCOMPtr<nsIPrefBranch> prefBranch( do_GetService(NS_PREFSERVICE_CONTRACTID) );
nsCOMPtr<nsIPref> prefs( do_GetService(kPrefCID, &rv) );
PRInt32 prefInt = 0;
PRBool outofstylehandled = PR_FALSE;
if (prefBranch)
if (NS_SUCCEEDED(rv) && prefs)
{
if (NS_SUCCEEDED(prefBranch->GetIntPref("browser.drag_out_of_frame_style", &prefInt)) && prefInt)
if (NS_SUCCEEDED(prefs->GetIntPref("browser.drag_out_of_frame_style", &prefInt)) && prefInt)
{
if ((aPoint.y - origin.y) < 0)//above rectangle
{

Просмотреть файл

@ -49,8 +49,7 @@
#include "nsUnicharUtils.h"
#include "nsICaseConversion.h"
#include "prenv.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIPref.h"
#ifdef IBMBIDI
#include "nsLayoutAtoms.h"
#endif
@ -115,11 +114,10 @@ nsTextTransformer::Initialize()
// read in our global word selection prefs
if ( !sWordSelectPrefInited ) {
nsCOMPtr<nsIPrefBranch> prefBranch =
do_GetService( NS_PREFSERVICE_CONTRACTID );
if ( prefBranch ) {
nsCOMPtr<nsIPref> prefService ( do_GetService(NS_PREF_CONTRACTID) );
if ( prefService ) {
PRBool temp = PR_FALSE;
prefBranch->GetBoolPref("layout.word_select.stop_at_punctuation", &temp);
prefService->GetBoolPref("layout.word_select.stop_at_punctuation", &temp);
sWordSelectStopAtPunctuation = temp;
}
sWordSelectPrefInited = PR_TRUE;

Просмотреть файл

@ -68,6 +68,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIDocumentLoader.h"
#include "nsIPref.h"
#include "nsFrameSetFrame.h"
#include "nsIDOMHTMLFrameElement.h"
#include "nsIDOMHTMLIFrameElement.h"

Просмотреть файл

@ -93,8 +93,7 @@
#include "nsIAnonymousContentCreator.h"
#include "nsIFrameManager.h"
#include "nsIAttributeContent.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIPref.h"
#include "nsLegendFrame.h"
#include "nsIContentIterator.h"
#include "nsBoxLayoutState.h"
@ -4232,10 +4231,10 @@ nsCSSFrameConstructor::HasGfxScrollbars()
#endif
// Get the Prefs
if (!mGotGfxPrefs) {
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefBranch) {
nsCOMPtr<nsIPref> pref(do_GetService(NS_PREF_CONTRACTID));
if (pref) {
PRBool hasGfxScroll = PR_FALSE; // use a temp since we have a PRPackedBool
prefBranch->GetBoolPref("nglayout.widget.gfxscrollbars", &hasGfxScroll);
pref->GetBoolPref("nglayout.widget.gfxscrollbars", &hasGfxScroll);
mHasGfxScrollbars = hasGfxScroll;
mGotGfxPrefs = PR_TRUE;
} else {
@ -4252,10 +4251,10 @@ PRBool
nsCSSFrameConstructor::UseXBLForms()
{
if (!mGotXBLFormPrefs) {
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefBranch) {
nsCOMPtr<nsIPref> pref(do_GetService(NS_PREF_CONTRACTID));
if (pref) {
PRBool useXBLForms = PR_FALSE; // use a temp since we have a PRPackedBool
prefBranch->GetBoolPref("nglayout.debug.enable_xbl_forms", &useXBLForms);
pref->GetBoolPref("nglayout.debug.enable_xbl_forms", &useXBLForms);
mUseXBLForms = useXBLForms;
mGotXBLFormPrefs = PR_TRUE;
}