Re-landing these because I don't believe this are responsible for the Txul spike.

Bug 181975 - Convert layout to use nsIPrefService, nsIPrefBranch, and friends.
r/sr=roc+moz
This commit is contained in:
caillon%returnzero.com 2002-12-11 14:05:41 +00:00
parent d2698e7f7e
commit 0dffa137af
22 changed files with 182 additions and 154 deletions

View File

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

View File

@ -75,7 +75,6 @@
#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

View File

@ -57,7 +57,8 @@
#include "prinrval.h"
#include "nsVoidArray.h"
#include "nsHashtable.h"
#include "nsIPref.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIViewObserver.h"
#include "nsContainerFrame.h"
#include "nsIDeviceContext.h"
@ -197,7 +198,6 @@ 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,10 +1694,11 @@ PresShell::Init(nsIDocument* aDocument,
gAsyncReflowDuringDocLoad = PR_TRUE;
// Get the prefs service
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID, &result));
if (NS_SUCCEEDED(result)) {
prefs->GetIntPref("layout.reflow.timeslice", &gMaxRCProcessingTime);
prefs->GetBoolPref("layout.reflow.async.duringDocLoad", &gAsyncReflowDuringDocLoad);
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefBranch) {
prefBranch->GetIntPref("layout.reflow.timeslice", &gMaxRCProcessingTime);
prefBranch->GetBoolPref("layout.reflow.async.duringDocLoad",
&gAsyncReflowDuringDocLoad);
}
}
@ -1716,16 +1717,19 @@ PresShell::Init(nsIDocument* aDocument,
#endif
#ifdef MOZ_REFLOW_PERF
// Get the prefs service
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID, &result));
if (NS_SUCCEEDED(result)) {
if (mReflowCountMgr != nsnull) {
if (mReflowCountMgr) {
// Get the prefs service
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefBranch) {
PRBool paintFrameCounts = PR_FALSE;
PRBool dumpFrameCounts = PR_FALSE;
PRBool dumpFrameByFrameCounts = PR_FALSE;
prefs->GetBoolPref("layout.reflow.showframecounts", &paintFrameCounts);
prefs->GetBoolPref("layout.reflow.dumpframecounts", &dumpFrameCounts);
prefs->GetBoolPref("layout.reflow.dumpframebyframecounts", &dumpFrameByFrameCounts);
prefBranch->GetBoolPref("layout.reflow.showframecounts",
&paintFrameCounts);
prefBranch->GetBoolPref("layout.reflow.dumpframecounts",
&dumpFrameCounts);
prefBranch->GetBoolPref("layout.reflow.dumpframebyframecounts",
&dumpFrameByFrameCounts);
mReflowCountMgr->SetDumpFrameCounts(dumpFrameCounts);
mReflowCountMgr->SetDumpFrameByFrameCounts(dumpFrameByFrameCounts);
@ -2854,9 +2858,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<nsIPref> prefs(do_GetService(kPrefServiceCID));
if (prefs)
prefs->GetIntPref("nglayout.initialpaint.delay", &delay);
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefBranch)
prefBranch->GetIntPref("nglayout.initialpaint.delay", &delay);
nsCOMPtr<nsITimerInternal> ti = do_QueryInterface(mPaintSuppressionTimer);
ti->SetIdle(PR_FALSE);
@ -4004,9 +4008,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<nsIPref> prefs(do_GetService(kPrefServiceCID,&rv));
if (NS_SUCCEEDED(rv) && prefs) {
prefs->GetBoolPref("layout.selectanchor",&selectAnchor);
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefBranch) {
prefBranch->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

View File

@ -75,7 +75,6 @@
#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

View File

@ -88,7 +88,8 @@
#include "nsIPercentHeightObserver.h"
// For triple-click pref
#include "nsIPref.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIServiceManager.h"
#include "nsISelectionImageService.h"
#include "imgIContainer.h"
@ -98,7 +99,6 @@
#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<nsIPref> prefsService( do_GetService(kPrefCID, &rv) );
if (NS_SUCCEEDED(rv) && prefsService)
prefsService->GetBoolPref("browser.triple_click_selects_paragraph", &selectPara);
nsCOMPtr<nsIPrefBranch> prefBranch( do_GetService(NS_PREFSERVICE_CONTRACTID) );
if (prefBranch)
prefBranch->GetBoolPref("browser.triple_click_selects_paragraph", &selectPara);
}
else
return NS_OK;

View File

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

View File

@ -94,7 +94,8 @@
#include "nsIDOMWindow.h"
#include "nsIDOMDocument.h"
#include "nsCSSFrameConstructor.h"
#include "nsIPref.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#ifdef DEBUG
#undef NOISY_IMAGE_LOADING
@ -2270,21 +2271,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<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID);
if (prefs) {
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
if (prefBranch) {
PRBool boolPref;
PRInt32 intPref;
if (NS_SUCCEEDED(prefs->GetBoolPref("browser.display.force_inline_alttext", &boolPref))) {
if (NS_SUCCEEDED(prefBranch->GetBoolPref("browser.display.force_inline_alttext", &boolPref))) {
mPrefForceInlineAltText = boolPref;
} else {
mPrefForceInlineAltText = PR_FALSE;
}
if (NS_SUCCEEDED(prefs->GetIntPref("network.image.imageBehavior", &intPref)) && intPref == 2) {
if (NS_SUCCEEDED(prefBranch->GetIntPref("network.image.imageBehavior", &intPref)) && intPref == 2) {
mPrefAllImagesBlocked = PR_TRUE;
} else {
mPrefAllImagesBlocked = PR_FALSE;
}
if (NS_SUCCEEDED(prefs->GetBoolPref("browser.display.show_image_placeholders", &boolPref))) {
if (NS_SUCCEEDED(prefBranch->GetBoolPref("browser.display.show_image_placeholders", &boolPref))) {
mPrefShowPlaceholders = boolPref;
} else {
mPrefShowPlaceholders = PR_TRUE;

View File

@ -114,7 +114,8 @@
#include "jsapi.h"
// XXX temporary for Mac double buffering pref
#include "nsIPref.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
// XXX For temporary paint code
#include "nsIStyleContext.h"
@ -139,9 +140,6 @@
#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
@ -797,10 +795,12 @@ 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<nsIPref> prefs(do_GetService(kPrefServiceCID));
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
PRBool doubleBuffer = PR_FALSE;
prefs ? prefs->GetBoolPref("plugin.enable_double_buffer", &doubleBuffer) : 0;
if (prefBranch) {
prefBranch->GetBoolPref("plugin.enable_double_buffer", &doubleBuffer);
}
viewMan->AllowDoubleBuffering(doubleBuffer);
#endif

View File

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

View File

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

View File

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

View File

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

View File

@ -88,7 +88,8 @@
#include "nsIPercentHeightObserver.h"
// For triple-click pref
#include "nsIPref.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIServiceManager.h"
#include "nsISelectionImageService.h"
#include "imgIContainer.h"
@ -98,7 +99,6 @@
#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<nsIPref> prefsService( do_GetService(kPrefCID, &rv) );
if (NS_SUCCEEDED(rv) && prefsService)
prefsService->GetBoolPref("browser.triple_click_selects_paragraph", &selectPara);
nsCOMPtr<nsIPrefBranch> prefBranch( do_GetService(NS_PREFSERVICE_CONTRACTID) );
if (prefBranch)
prefBranch->GetBoolPref("browser.triple_click_selects_paragraph", &selectPara);
}
else
return NS_OK;

View File

@ -94,7 +94,8 @@
#include "nsIDOMWindow.h"
#include "nsIDOMDocument.h"
#include "nsCSSFrameConstructor.h"
#include "nsIPref.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#ifdef DEBUG
#undef NOISY_IMAGE_LOADING
@ -2270,21 +2271,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<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID);
if (prefs) {
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
if (prefBranch) {
PRBool boolPref;
PRInt32 intPref;
if (NS_SUCCEEDED(prefs->GetBoolPref("browser.display.force_inline_alttext", &boolPref))) {
if (NS_SUCCEEDED(prefBranch->GetBoolPref("browser.display.force_inline_alttext", &boolPref))) {
mPrefForceInlineAltText = boolPref;
} else {
mPrefForceInlineAltText = PR_FALSE;
}
if (NS_SUCCEEDED(prefs->GetIntPref("network.image.imageBehavior", &intPref)) && intPref == 2) {
if (NS_SUCCEEDED(prefBranch->GetIntPref("network.image.imageBehavior", &intPref)) && intPref == 2) {
mPrefAllImagesBlocked = PR_TRUE;
} else {
mPrefAllImagesBlocked = PR_FALSE;
}
if (NS_SUCCEEDED(prefs->GetBoolPref("browser.display.show_image_placeholders", &boolPref))) {
if (NS_SUCCEEDED(prefBranch->GetBoolPref("browser.display.show_image_placeholders", &boolPref))) {
mPrefShowPlaceholders = boolPref;
} else {
mPrefShowPlaceholders = PR_TRUE;

View File

@ -114,7 +114,8 @@
#include "jsapi.h"
// XXX temporary for Mac double buffering pref
#include "nsIPref.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
// XXX For temporary paint code
#include "nsIStyleContext.h"
@ -139,9 +140,6 @@
#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
@ -797,10 +795,12 @@ 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<nsIPref> prefs(do_GetService(kPrefServiceCID));
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
PRBool doubleBuffer = PR_FALSE;
prefs ? prefs->GetBoolPref("plugin.enable_double_buffer", &doubleBuffer) : 0;
if (prefBranch) {
prefBranch->GetBoolPref("plugin.enable_double_buffer", &doubleBuffer);
}
viewMan->AllowDoubleBuffering(doubleBuffer);
#endif

View File

@ -57,7 +57,8 @@
#include "prinrval.h"
#include "nsVoidArray.h"
#include "nsHashtable.h"
#include "nsIPref.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIViewObserver.h"
#include "nsContainerFrame.h"
#include "nsIDeviceContext.h"
@ -197,7 +198,6 @@ 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,10 +1694,11 @@ PresShell::Init(nsIDocument* aDocument,
gAsyncReflowDuringDocLoad = PR_TRUE;
// Get the prefs service
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID, &result));
if (NS_SUCCEEDED(result)) {
prefs->GetIntPref("layout.reflow.timeslice", &gMaxRCProcessingTime);
prefs->GetBoolPref("layout.reflow.async.duringDocLoad", &gAsyncReflowDuringDocLoad);
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefBranch) {
prefBranch->GetIntPref("layout.reflow.timeslice", &gMaxRCProcessingTime);
prefBranch->GetBoolPref("layout.reflow.async.duringDocLoad",
&gAsyncReflowDuringDocLoad);
}
}
@ -1716,16 +1717,19 @@ PresShell::Init(nsIDocument* aDocument,
#endif
#ifdef MOZ_REFLOW_PERF
// Get the prefs service
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID, &result));
if (NS_SUCCEEDED(result)) {
if (mReflowCountMgr != nsnull) {
if (mReflowCountMgr) {
// Get the prefs service
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefBranch) {
PRBool paintFrameCounts = PR_FALSE;
PRBool dumpFrameCounts = PR_FALSE;
PRBool dumpFrameByFrameCounts = PR_FALSE;
prefs->GetBoolPref("layout.reflow.showframecounts", &paintFrameCounts);
prefs->GetBoolPref("layout.reflow.dumpframecounts", &dumpFrameCounts);
prefs->GetBoolPref("layout.reflow.dumpframebyframecounts", &dumpFrameByFrameCounts);
prefBranch->GetBoolPref("layout.reflow.showframecounts",
&paintFrameCounts);
prefBranch->GetBoolPref("layout.reflow.dumpframecounts",
&dumpFrameCounts);
prefBranch->GetBoolPref("layout.reflow.dumpframebyframecounts",
&dumpFrameByFrameCounts);
mReflowCountMgr->SetDumpFrameCounts(dumpFrameCounts);
mReflowCountMgr->SetDumpFrameByFrameCounts(dumpFrameByFrameCounts);
@ -2854,9 +2858,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<nsIPref> prefs(do_GetService(kPrefServiceCID));
if (prefs)
prefs->GetIntPref("nglayout.initialpaint.delay", &delay);
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefBranch)
prefBranch->GetIntPref("nglayout.initialpaint.delay", &delay);
nsCOMPtr<nsITimerInternal> ti = do_QueryInterface(mPaintSuppressionTimer);
ti->SetIdle(PR_FALSE);
@ -4004,9 +4008,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<nsIPref> prefs(do_GetService(kPrefServiceCID,&rv));
if (NS_SUCCEEDED(rv) && prefs) {
prefs->GetBoolPref("layout.selectanchor",&selectAnchor);
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefBranch) {
prefBranch->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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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