From 43628f9edf94e2faf1dc92503a558da7f206e482 Mon Sep 17 00:00:00 2001 From: "bryner%brianryner.com" Date: Sun, 29 Aug 2004 03:08:44 +0000 Subject: [PATCH] More nsIPresShell deCOMtamination: - Made Get/SetAuthorStyleDisabled and ReconstructStyleData non-virtual when called internally. - Inlined GetFrameSelection and renamed it to FrameSelection. - Removed non-inline version of GetViewManager. - Removed unused EnablePrefStyleRules and ArePrefStyleRulesEnabled. Bug 253889, r+sr=roc. git-svn-id: svn://10.0.0.236/trunk@161442 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/src/nsDocumentViewer.cpp | 8 +- mozilla/content/base/src/nsRuleNode.cpp | 10 -- .../events/src/nsEventStateManager.cpp | 33 ++--- mozilla/dom/src/base/nsGlobalWindow.cpp | 10 +- .../accessproxy/nsAccessProxy.cpp | 6 +- mozilla/layout/base/nsCaret.cpp | 24 +--- mozilla/layout/base/nsDocumentViewer.cpp | 8 +- mozilla/layout/base/nsIPresShell.h | 42 +++--- mozilla/layout/base/nsPresContext.h | 10 +- mozilla/layout/base/nsPresShell.cpp | 123 +++--------------- mozilla/layout/base/public/nsIPresShell.h | 42 +++--- mozilla/layout/base/public/nsPresContext.h | 10 +- mozilla/layout/base/src/nsCaret.cpp | 24 +--- mozilla/layout/generic/nsBlockFrame.cpp | 15 +-- mozilla/layout/generic/nsFrame.cpp | 110 ++++++---------- mozilla/layout/generic/nsTextFrame.cpp | 101 +++++++------- mozilla/layout/html/base/src/nsBlockFrame.cpp | 15 +-- mozilla/layout/html/base/src/nsFrame.cpp | 110 ++++++---------- mozilla/layout/html/base/src/nsPresShell.cpp | 123 +++--------------- mozilla/layout/html/base/src/nsTextFrame.cpp | 101 +++++++------- .../html/table/src/nsTableCellFrame.cpp | 80 ++++++------ .../mathml/base/src/nsMathMLmoFrame.cpp | 9 +- mozilla/layout/style/nsRuleNode.cpp | 10 -- .../layout/svg/base/src/nsSVGGlyphFrame.cpp | 2 +- mozilla/layout/tables/nsTableCellFrame.cpp | 80 ++++++------ .../webshell/tests/viewer/nsBrowserWindow.cpp | 6 +- .../webshell/tests/viewer/nsXPBaseWindow.cpp | 3 +- 27 files changed, 418 insertions(+), 697 deletions(-) diff --git a/mozilla/content/base/src/nsDocumentViewer.cpp b/mozilla/content/base/src/nsDocumentViewer.cpp index 06c9ec4b1ea..d9173c5d5f0 100644 --- a/mozilla/content/base/src/nsDocumentViewer.cpp +++ b/mozilla/content/base/src/nsDocumentViewer.cpp @@ -2368,8 +2368,7 @@ NS_IMETHODIMP DocumentViewerImpl::SetAuthorStyleDisabled(PRBool aStyleDisabled) { if (mPresShell) { - nsresult rv = mPresShell->SetAuthorStyleDisabled(aStyleDisabled); - if (NS_FAILED(rv)) return rv; + mPresShell->SetAuthorStyleDisabled(aStyleDisabled); } return CallChildren(SetChildAuthorStyleDisabled, &aStyleDisabled); } @@ -2377,9 +2376,10 @@ DocumentViewerImpl::SetAuthorStyleDisabled(PRBool aStyleDisabled) NS_IMETHODIMP DocumentViewerImpl::GetAuthorStyleDisabled(PRBool* aStyleDisabled) { - *aStyleDisabled = PR_FALSE; if (mPresShell) { - return mPresShell->GetAuthorStyleDisabled(aStyleDisabled); + *aStyleDisabled = mPresShell->GetAuthorStyleDisabled(); + } else { + *aStyleDisabled = PR_FALSE; } return NS_OK; } diff --git a/mozilla/content/base/src/nsRuleNode.cpp b/mozilla/content/base/src/nsRuleNode.cpp index 70b8ddb1114..a9f2a179470 100644 --- a/mozilla/content/base/src/nsRuleNode.cpp +++ b/mozilla/content/base/src/nsRuleNode.cpp @@ -2019,16 +2019,6 @@ nsRuleNode::ComputeFontData(nsStyleStruct* aStartStruct, // then we use the document fonts anyway useDocumentFonts = mPresContext->GetCachedBoolPref(kPresContext_UseDocumentFonts); - if (!useDocumentFonts) { - // check if the prefs have been disabled for this shell - // - if prefs are disabled then we use the document fonts anyway (yet another override) - PRBool prefsEnabled = PR_TRUE; - nsIPresShell *shell = mPresContext->GetPresShell(); - if (shell) - shell->ArePrefStyleRulesEnabled(prefsEnabled); - if (!prefsEnabled) - useDocumentFonts = PR_TRUE; - } } // See if we are in the chrome diff --git a/mozilla/content/events/src/nsEventStateManager.cpp b/mozilla/content/events/src/nsEventStateManager.cpp index a44ea6b4eeb..da12d87d03b 100644 --- a/mozilla/content/events/src/nsEventStateManager.cpp +++ b/mozilla/content/events/src/nsEventStateManager.cpp @@ -827,10 +827,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext, } // disable selection mousedown state on activation - nsCOMPtr frameSel; - shell->GetFrameSelection(getter_AddRefs(frameSel)); - if (frameSel) - frameSel->SetMouseDownState(PR_FALSE); + shell->FrameSelection()->SetMouseDownState(PR_FALSE); } } } @@ -1419,7 +1416,7 @@ nsEventStateManager::GetSelection(nsIFrame* inFrame, if (! frameSel) { nsIPresShell *shell = inPresContext->GetPresShell(); if (shell) - shell->GetFrameSelection(getter_AddRefs(frameSel)); + frameSel = shell->FrameSelection(); } *outSelection = frameSel.get(); @@ -1950,11 +1947,7 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext, ret = CheckForAndDispatchClick(aPresContext, (nsMouseEvent*)aEvent, aStatus); nsIPresShell *shell = aPresContext->GetPresShell(); if (shell) { - nsCOMPtr frameSel; - nsresult rv = shell->GetFrameSelection(getter_AddRefs(frameSel)); - if (NS_SUCCEEDED(rv) && frameSel){ - frameSel->SetMouseDownState(PR_FALSE); - } + shell->FrameSelection()->SetMouseDownState(PR_FALSE); } } break; @@ -4414,9 +4407,9 @@ nsEventStateManager::GetDocSelectionLocation(nsIContent **aStartContent, if (mPresContext) shell = mPresContext->GetPresShell(); - nsCOMPtr frameSelection; + nsIFrameSelection *frameSelection = nsnull; if (shell) - rv = shell->GetFrameSelection(getter_AddRefs(frameSelection)); + frameSelection = shell->FrameSelection(); nsCOMPtr domSelection; if (frameSelection) @@ -4755,15 +4748,14 @@ nsEventStateManager::MoveCaretToFocus() if (shell) { // rangeDoc is a document interface we can create a range with nsCOMPtr rangeDoc(do_QueryInterface(mDocument)); - nsCOMPtr currentFocusNode(do_QueryInterface(mCurrentFocus)); - nsCOMPtr frameSelection; - shell->GetFrameSelection(getter_AddRefs(frameSelection)); - if (frameSelection && rangeDoc) { + if (rangeDoc) { nsCOMPtr domSelection; - frameSelection->GetSelection(nsISelectionController::SELECTION_NORMAL, - getter_AddRefs(domSelection)); + shell->FrameSelection()-> + GetSelection(nsISelectionController::SELECTION_NORMAL, + getter_AddRefs(domSelection)); if (domSelection) { + nsCOMPtr currentFocusNode(do_QueryInterface(mCurrentFocus)); // First clear the selection domSelection->RemoveAllRanges(); if (currentFocusNode) { @@ -4826,14 +4818,15 @@ nsEventStateManager::SetContentCaretVisible(nsIPresShell* aPresShell, nsCOMPtr caret; aPresShell->GetCaret(getter_AddRefs(caret)); - nsCOMPtr frameSelection, docFrameSelection; + nsCOMPtr frameSelection; if (aFocusedContent) { nsIFrame *focusFrame = nsnull; aPresShell->GetPrimaryFrameFor(aFocusedContent, &focusFrame); GetSelection(focusFrame, mPresContext, getter_AddRefs(frameSelection)); } - aPresShell->GetFrameSelection(getter_AddRefs(docFrameSelection)); + + nsIFrameSelection *docFrameSelection = aPresShell->FrameSelection(); if (docFrameSelection && caret && (frameSelection == docFrameSelection || !aFocusedContent)) { diff --git a/mozilla/dom/src/base/nsGlobalWindow.cpp b/mozilla/dom/src/base/nsGlobalWindow.cpp index 87b101ed7c4..b178df462b1 100644 --- a/mozilla/dom/src/base/nsGlobalWindow.cpp +++ b/mozilla/dom/src/base/nsGlobalWindow.cpp @@ -3788,14 +3788,8 @@ GlobalWindowImpl::GetSelection(nsISelection** aSelection) if (!presShell) return NS_OK; - nsCOMPtr selection; - presShell->GetFrameSelection(getter_AddRefs(selection)); - - if (!selection) - return NS_OK; - - return selection->GetSelection(nsISelectionController::SELECTION_NORMAL, - aSelection); + return presShell->FrameSelection()-> + GetSelection(nsISelectionController::SELECTION_NORMAL, aSelection); } // Non-scriptable version of window.find(), part of nsIDOMWindowInternal diff --git a/mozilla/extensions/access-builtin/accessproxy/nsAccessProxy.cpp b/mozilla/extensions/access-builtin/accessproxy/nsAccessProxy.cpp index 7a2cce96010..c49063e2450 100644 --- a/mozilla/extensions/access-builtin/accessproxy/nsAccessProxy.cpp +++ b/mozilla/extensions/access-builtin/accessproxy/nsAccessProxy.cpp @@ -148,12 +148,8 @@ NS_IMETHODIMP nsAccessProxy::HandleEvent(nsIDOMEvent* aEvent) //return NS_OK; /* if (presShell && eventNameStr.EqualsLiteral("click")) { - nsCOMPtr frameSelection; - presShell->GetFrameSelection(getter_AddRefs(frameSelection)); - if (!frameSelection) - return NS_OK; nsCOMPtr domSelection; - frameSelection->GetSelection(nsISelectionController::SELECTION_NORMAL, + presShell->FrameSelection()->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(domSelection)); if (!domSelection) return NS_OK; diff --git a/mozilla/layout/base/nsCaret.cpp b/mozilla/layout/base/nsCaret.cpp index 422b0ac35be..1d629151787 100644 --- a/mozilla/layout/base/nsCaret.cpp +++ b/mozilla/layout/base/nsCaret.cpp @@ -303,16 +303,6 @@ NS_IMETHODIMP nsCaret::GetCaretCoordinates(EViewCoordinates aRelativeToType, nsI if (!contentNode) return NS_ERROR_FAILURE; - //get frame selection and find out what frame to use... - nsCOMPtr frameSelection; - nsCOMPtr presShell = do_QueryReferent(mPresShell); - if (presShell) - err = presShell->GetFrameSelection(getter_AddRefs(frameSelection)); - else - return NS_ERROR_FAILURE; - if (NS_FAILED(err) || !frameSelection) - return err?err : NS_ERROR_FAILURE; - // find the frame that contains the content node that has focus nsIFrame* theFrame = nsnull; PRInt32 theFrameOffset = 0; @@ -323,7 +313,12 @@ NS_IMETHODIMP nsCaret::GetCaretCoordinates(EViewCoordinates aRelativeToType, nsI hint = nsIFrameSelection::HINTRIGHT; else hint = nsIFrameSelection::HINTLEFT; - err = frameSelection->GetFrameForNodeOffset(contentNode, focusOffset, hint, &theFrame, &theFrameOffset); + + nsCOMPtr presShell = do_QueryReferent(mPresShell); + err = presShell->FrameSelection()->GetFrameForNodeOffset(contentNode, + focusOffset, hint, + &theFrame, + &theFrameOffset); if (NS_FAILED(err) || !theFrame) return err; @@ -532,12 +527,7 @@ PRBool nsCaret::SetupDrawingFrameAndOffset(nsIDOMNode* aNode, PRInt32 aOffset, n if (!presShell) return PR_FALSE; - nsCOMPtr frameSelection; - presShell->GetFrameSelection(getter_AddRefs(frameSelection)); - if (!frameSelection) - return PR_FALSE; - - + nsIFrameSelection *frameSelection = presShell->FrameSelection(); nsIFrame* theFrame = nsnull; PRInt32 theFrameOffset = 0; diff --git a/mozilla/layout/base/nsDocumentViewer.cpp b/mozilla/layout/base/nsDocumentViewer.cpp index 06c9ec4b1ea..d9173c5d5f0 100644 --- a/mozilla/layout/base/nsDocumentViewer.cpp +++ b/mozilla/layout/base/nsDocumentViewer.cpp @@ -2368,8 +2368,7 @@ NS_IMETHODIMP DocumentViewerImpl::SetAuthorStyleDisabled(PRBool aStyleDisabled) { if (mPresShell) { - nsresult rv = mPresShell->SetAuthorStyleDisabled(aStyleDisabled); - if (NS_FAILED(rv)) return rv; + mPresShell->SetAuthorStyleDisabled(aStyleDisabled); } return CallChildren(SetChildAuthorStyleDisabled, &aStyleDisabled); } @@ -2377,9 +2376,10 @@ DocumentViewerImpl::SetAuthorStyleDisabled(PRBool aStyleDisabled) NS_IMETHODIMP DocumentViewerImpl::GetAuthorStyleDisabled(PRBool* aStyleDisabled) { - *aStyleDisabled = PR_FALSE; if (mPresShell) { - return mPresShell->GetAuthorStyleDisabled(aStyleDisabled); + *aStyleDisabled = mPresShell->GetAuthorStyleDisabled(); + } else { + *aStyleDisabled = PR_FALSE; } return NS_OK; } diff --git a/mozilla/layout/base/nsIPresShell.h b/mozilla/layout/base/nsIPresShell.h index e891a212b84..25b9871bbbc 100644 --- a/mozilla/layout/base/nsIPresShell.h +++ b/mozilla/layout/base/nsIPresShell.h @@ -90,8 +90,8 @@ class nsIStyleSheet; class nsCSSFrameConstructor; #define NS_IPRESSHELL_IID \ -{ 0x16c9c6ee, 0xd9c0, 0x463d, \ - {0xbc, 0x5e, 0x4d, 0xdf, 0x60, 0xdd, 0x73, 0xfc} } +{ 0x3b864134, 0x4e25, 0x4cd0, \ + {0xa6, 0x9e, 0x34, 0x14, 0x13, 0x18, 0x39, 0x58} } // Constants uses for ScrollFrameIntoView() function #define NS_PRESSHELL_SCROLL_TOP 0 @@ -167,7 +167,6 @@ public: nsPresContext* GetPresContext() { return mPresContext; } - NS_IMETHOD GetViewManager(nsIViewManager** aResult) = 0; nsIViewManager* GetViewManager() { return mViewManager; } #ifdef _IMPL_NS_LAYOUT @@ -185,6 +184,7 @@ public: #endif + // These two methods are used only by viewer NS_IMETHOD GetActiveAlternateStyleSheet(nsString& aSheetTitle) = 0; NS_IMETHOD SelectAlternateStyleSheet(const nsString& aSheetTitle) = 0; @@ -193,15 +193,23 @@ public: /* Enable/disable author style level. Disabling author style disables the entire * author level of the cascade, including the HTML preshint level. */ - NS_IMETHOD SetAuthorStyleDisabled(PRBool aStyleDisabled) = 0; - NS_IMETHOD GetAuthorStyleDisabled(PRBool* aStyleDisabled) = 0; + // XXX these could easily be inlined, but there is a circular #include + // problem with nsStyleSet. + NS_HIDDEN_(void) SetAuthorStyleDisabled(PRBool aDisabled); + NS_HIDDEN_(PRBool) GetAuthorStyleDisabled(); /* * Called when stylesheets are added/removed/enabled/disabled to rebuild * all style data for a given pres shell without necessarily reconstructing * all of the frames. */ - NS_IMETHOD ReconstructStyleData() = 0; + virtual NS_HIDDEN_(void) ReconstructStyleDataExternal(); + NS_HIDDEN_(void) ReconstructStyleDataInternal(); +#ifdef _IMPL_NS_LAYOUT + void ReconstructStyleData() { ReconstructStyleDataInternal(); } +#else + void ReconstructStyleData() { ReconstructStyleDataExternal(); } +#endif /** Setup all style rules required to implement preferences * - used for background/text/link colors and link underlining @@ -213,16 +221,6 @@ public: */ NS_IMETHOD SetPreferenceStyleRules(PRBool aForceReflow) = 0; - /** Allow client to enable and disable the use of the preference style rules, - * by type. - * NOTE: type argument is currently ignored, but is in the API for - * future refinement - * - * - initially created for bugs 31816, 20760, 22963 - */ - NS_IMETHOD EnablePrefStyleRules(PRBool aEnable, PRUint8 aPrefType=0xFF) = 0; - NS_IMETHOD ArePrefStyleRulesEnabled(PRBool& aEnabled) = 0; - /** * Gather titles of all selectable (alternate and preferred) style sheets * fills void array with nsString* caller must free strings @@ -230,10 +228,11 @@ public: NS_IMETHOD ListAlternateStyleSheets(nsStringArray& aTitleList) = 0; /** - * GetFrameSelection will return the Frame based selection API you - * cannot go back and forth anymore with QI with nsIDOM sel and nsIFrame sel. + * FrameSelection will return the Frame based selection API. + * You cannot go back and forth anymore with QI between nsIDOM sel and + * nsIFrame sel. */ - NS_IMETHOD GetFrameSelection(nsIFrameSelection** aSelection) = 0; + nsIFrameSelection* FrameSelection() { return mSelection; } // Make shell be a document observer NS_IMETHOD BeginObservingDocument() = 0; @@ -672,11 +671,14 @@ protected: // these are the same Document and PresContext owned by the DocViewer. // we must share ownership. nsIDocument* mDocument; // [STRONG] - nsPresContext* mPresContext; // [STRONG] + nsPresContext* mPresContext; // [STRONG] nsStyleSet* mStyleSet; // [OWNS] nsCSSFrameConstructor* mFrameConstructor; // [OWNS] nsIViewManager* mViewManager; // [WEAK] docViewer owns it so I don't have to + nsIFrameSelection* mSelection; nsFrameManagerBase mFrameManager; // [OWNS] + + PRPackedBool mStylesHaveChanged; }; /** diff --git a/mozilla/layout/base/nsPresContext.h b/mozilla/layout/base/nsPresContext.h index 9427646f649..48756c5a151 100644 --- a/mozilla/layout/base/nsPresContext.h +++ b/mozilla/layout/base/nsPresContext.h @@ -185,7 +185,7 @@ public: * Access the image animation mode for this context */ PRUint16 ImageAnimationMode() const { return mImageAnimationMode; } - virtual void SetImageAnimationModeExternal(PRUint16 aMode); + virtual NS_HIDDEN_(void) SetImageAnimationModeExternal(PRUint16 aMode); NS_HIDDEN_(void) SetImageAnimationModeInternal(PRUint16 aMode); #ifdef _IMPL_NS_LAYOUT void SetImageAnimationMode(PRUint16 aMode) @@ -227,7 +227,7 @@ public: /** * Get the font metrics for a given font. */ - virtual already_AddRefed + virtual NS_HIDDEN_(already_AddRefed) GetMetricsForExternal(const nsFont& aFont); NS_HIDDEN_(already_AddRefed) GetMetricsForInternal(const nsFont& aFont); @@ -243,7 +243,7 @@ public: * Get the default font correponding to the given ID. This object is * read-only, you must copy the font to modify it. */ - virtual const nsFont* GetDefaultFontExternal(PRUint8 aFontID) const; + virtual NS_HIDDEN_(const nsFont*) GetDefaultFontExternal(PRUint8 aFontID) const; NS_HIDDEN_(const nsFont*) GetDefaultFontInternal(PRUint8 aFontID) const; #ifdef _IMPL_NS_LAYOUT const nsFont* GetDefaultFont(PRUint8 aFontID) const @@ -328,7 +328,7 @@ public: NS_HIDDEN_(void) SetContainer(nsISupports* aContainer); - virtual already_AddRefed GetContainerExternal(); + virtual NS_HIDDEN_(already_AddRefed) GetContainerExternal(); NS_HIDDEN_(already_AddRefed) GetContainerInternal(); #ifdef _IMPL_NS_LAYOUT already_AddRefed GetContainer() @@ -462,7 +462,7 @@ public: * * @lina 07/12/2000 */ - virtual PRBool BidiEnabledExternal() const; + virtual NS_HIDDEN_(PRBool) BidiEnabledExternal() const; NS_HIDDEN_(PRBool) BidiEnabledInternal() const; #ifdef _IMPL_NS_LAYOUT PRBool BidiEnabled() const { return BidiEnabledInternal(); } diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index cd5b64ddf18..c243e21331b 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -1085,17 +1085,10 @@ public: NS_IMETHOD AllocateStackMemory(size_t aSize, void** aResult); NS_IMETHOD GetPresContext(nsPresContext** aResult); - NS_IMETHOD GetViewManager(nsIViewManager** aResult); - nsIViewManager* GetViewManager() { return mViewManager; } NS_IMETHOD GetActiveAlternateStyleSheet(nsString& aSheetTitle); NS_IMETHOD SelectAlternateStyleSheet(const nsString& aSheetTitle); NS_IMETHOD ListAlternateStyleSheets(nsStringArray& aTitleList); - NS_IMETHOD GetAuthorStyleDisabled(PRBool* aStyleDisabled); - NS_IMETHOD SetAuthorStyleDisabled(PRBool aStyleDisabled); - NS_IMETHOD ReconstructStyleData(); NS_IMETHOD SetPreferenceStyleRules(PRBool aForceReflow); - NS_IMETHOD EnablePrefStyleRules(PRBool aEnable, PRUint8 aPrefType=0xFF); - NS_IMETHOD ArePrefStyleRulesEnabled(PRBool& aEnabled); NS_IMETHOD GetSelection(SelectionType aType, nsISelection** aSelection); @@ -1103,7 +1096,6 @@ public: NS_IMETHOD GetDisplaySelection(PRInt16 *aToggle); NS_IMETHOD ScrollSelectionIntoView(SelectionType aType, SelectionRegion aRegion, PRBool aIsSynchronous); NS_IMETHOD RepaintSelection(SelectionType aType); - NS_IMETHOD GetFrameSelection(nsIFrameSelection** aSelection); NS_IMETHOD BeginObservingDocument(); NS_IMETHOD EndObservingDocument(); @@ -1395,14 +1387,12 @@ protected: nsVoidArray mReflowCommands; PLDHashTable mReflowCommandTable; - PRPackedBool mEnablePrefStyleSheet; PRPackedBool mDocumentLoading; PRPackedBool mIsReflowing; PRPackedBool mIsDestroying; PRPackedBool mDidInitialReflow; PRPackedBool mIgnoreFrameDestruction; - PRPackedBool mStylesHaveChanged; PRPackedBool mHaveShutDown; nsIFrame* mCurrentEventFrame; @@ -1416,7 +1406,6 @@ protected: nsIView* mCurrentTargetView; #endif - nsCOMPtr mSelection; nsCOMPtr mCaret; PRInt16 mSelectionFlags; PRPackedBool mBatchReflows; // When set to true, the pres shell batches reflow commands. @@ -1607,12 +1596,12 @@ NS_NewPresShell(nsIPresShell** aInstancePtrResult) (void **) aInstancePtrResult); } -PresShell::PresShell(): +PresShell::PresShell() #ifdef IBMBIDI - mBidiLevel(BIDI_LEVEL_UNDEFINED), + : mBidiLevel(BIDI_LEVEL_UNDEFINED) #endif - mEnablePrefStyleSheet(PR_TRUE) { + mSelection = nsnull; #ifdef MOZ_REFLOW_PERF mReflowCountMgr = new ReflowCountMgr(); mReflowCountMgr->SetPresContext(mPresContext); @@ -1662,6 +1651,7 @@ PresShell::~PresShell() NS_IF_RELEASE(mPresContext); NS_IF_RELEASE(mDocument); + NS_IF_RELEASE(mSelection); } /** @@ -1740,7 +1730,7 @@ PresShell::Init(nsIDocument* aDocument, // before creating any frames. SetPreferenceStyleRules(PR_FALSE); - mSelection = do_CreateInstance(kFrameSelectionCID, &result); + result = CallCreateInstance(kFrameSelectionCID, &mSelection); if (NS_FAILED(result)) { mStyleSet = nsnull; return result; @@ -2026,18 +2016,6 @@ PresShell::GetPresContext(nsPresContext** aResult) return NS_OK; } -NS_IMETHODIMP -PresShell::GetViewManager(nsIViewManager** aResult) -{ - NS_PRECONDITION(nsnull != aResult, "null ptr"); - if (nsnull == aResult) { - return NS_ERROR_NULL_POINTER; - } - *aResult = mViewManager; - NS_IF_ADDREF(mViewManager); - return NS_OK; -} - NS_IMETHODIMP PresShell::GetActiveAlternateStyleSheet(nsString& aSheetTitle) { // first non-html sheet in style set that has title @@ -2096,7 +2074,7 @@ PresShell::SelectAlternateStyleSheet(const nsString& aSheetTitle) } mStyleSet->EndUpdate(); - return ReconstructStyleData(); + ReconstructStyleData(); } return NS_OK; } @@ -2129,61 +2107,19 @@ PresShell::ListAlternateStyleSheets(nsStringArray& aTitleList) return NS_OK; } -NS_IMETHODIMP -PresShell::SetAuthorStyleDisabled(PRBool aStyleDisabled) +void +nsIPresShell::SetAuthorStyleDisabled(PRBool aStyleDisabled) { if (aStyleDisabled != mStyleSet->GetAuthorStyleDisabled()) { - nsresult rv = mStyleSet->SetAuthorStyleDisabled(aStyleDisabled); - if (NS_FAILED(rv)) return rv; - return ReconstructStyleData(); + mStyleSet->SetAuthorStyleDisabled(aStyleDisabled); + ReconstructStyleData(); } - return NS_OK; } -NS_IMETHODIMP -PresShell::GetAuthorStyleDisabled(PRBool* aStyleDisabled) +PRBool +nsIPresShell::GetAuthorStyleDisabled() { - *aStyleDisabled = mStyleSet->GetAuthorStyleDisabled(); - return NS_OK; -} - -NS_IMETHODIMP -PresShell::EnablePrefStyleRules(PRBool aEnable, PRUint8 aPrefType/*=0xFF*/) -{ - nsresult result = NS_OK; - - // capture change in state - PRBool bChanging = (mEnablePrefStyleSheet != aEnable) ? PR_TRUE : PR_FALSE; - // set to desired state - mEnablePrefStyleSheet = aEnable; - -#ifdef DEBUG_attinasi - printf("PrefStyleSheet %s %s\n", - mEnablePrefStyleSheet ? "ENABLED" : "DISABLED", - bChanging ? "(state toggled)" : "(state unchanged)"); -#endif - - // deal with changing state - if(bChanging){ - switch (mEnablePrefStyleSheet){ - case PR_TRUE: - // was off, now on, so create the rules - result = SetPreferenceStyleRules(PR_TRUE); - break; - default : - // was on, now off, so clear the rules - result = ClearPreferenceStyleRules(); - break; - } - } - return result; -} - -NS_IMETHODIMP -PresShell::ArePrefStyleRulesEnabled(PRBool& aEnabled) -{ - aEnabled = mEnablePrefStyleSheet; - return NS_OK; + return mStyleSet->GetAuthorStyleDisabled(); } NS_IMETHODIMP @@ -2208,16 +2144,6 @@ PresShell::SetPreferenceStyleRules(PRBool aForceReflow) if (mPresContext) { nsresult result = NS_OK; - // zeroth, make sure this feature is enabled - // XXX: may get more granularity later - // (i.e. each pref may be controlled independently) - if (!mEnablePrefStyleSheet) { -#ifdef DEBUG_attinasi - printf("PrefStyleSheet disabled\n"); -#endif - return PR_TRUE; - } - // first, make sure this is not a chrome shell nsCOMPtr container = mPresContext->GetContainer(); if (container) { @@ -2615,17 +2541,6 @@ PresShell::RepaintSelection(SelectionType aType) return mSelection->RepaintSelection(mPresContext, aType); } -NS_IMETHODIMP -PresShell::GetFrameSelection(nsIFrameSelection** aSelection) -{ - if (!aSelection || !mSelection) - return NS_ERROR_NULL_POINTER; - *aSelection = mSelection; - (*aSelection)->AddRef(); - return NS_OK; -} - - // Make shell be a document observer NS_IMETHODIMP PresShell::BeginObservingDocument() @@ -5269,14 +5184,14 @@ PresShell::ReconstructFrames(void) return rv; } -NS_IMETHODIMP -PresShell::ReconstructStyleData() +void +nsIPresShell::ReconstructStyleDataInternal() { mStylesHaveChanged = PR_FALSE; nsIFrame* rootFrame = FrameManager()->GetRootFrame(); if (!rootFrame) - return NS_OK; + return; nsStyleChangeList changeList; FrameManager()->ComputeStyleChangeFor(rootFrame, &changeList, @@ -5285,8 +5200,12 @@ PresShell::ReconstructStyleData() mFrameConstructor->ProcessRestyledFrames(changeList, mPresContext); VERIFY_STYLE_TREE; +} - return NS_OK; +void +nsIPresShell::ReconstructStyleDataExternal() +{ + ReconstructStyleDataInternal(); } void diff --git a/mozilla/layout/base/public/nsIPresShell.h b/mozilla/layout/base/public/nsIPresShell.h index e891a212b84..25b9871bbbc 100644 --- a/mozilla/layout/base/public/nsIPresShell.h +++ b/mozilla/layout/base/public/nsIPresShell.h @@ -90,8 +90,8 @@ class nsIStyleSheet; class nsCSSFrameConstructor; #define NS_IPRESSHELL_IID \ -{ 0x16c9c6ee, 0xd9c0, 0x463d, \ - {0xbc, 0x5e, 0x4d, 0xdf, 0x60, 0xdd, 0x73, 0xfc} } +{ 0x3b864134, 0x4e25, 0x4cd0, \ + {0xa6, 0x9e, 0x34, 0x14, 0x13, 0x18, 0x39, 0x58} } // Constants uses for ScrollFrameIntoView() function #define NS_PRESSHELL_SCROLL_TOP 0 @@ -167,7 +167,6 @@ public: nsPresContext* GetPresContext() { return mPresContext; } - NS_IMETHOD GetViewManager(nsIViewManager** aResult) = 0; nsIViewManager* GetViewManager() { return mViewManager; } #ifdef _IMPL_NS_LAYOUT @@ -185,6 +184,7 @@ public: #endif + // These two methods are used only by viewer NS_IMETHOD GetActiveAlternateStyleSheet(nsString& aSheetTitle) = 0; NS_IMETHOD SelectAlternateStyleSheet(const nsString& aSheetTitle) = 0; @@ -193,15 +193,23 @@ public: /* Enable/disable author style level. Disabling author style disables the entire * author level of the cascade, including the HTML preshint level. */ - NS_IMETHOD SetAuthorStyleDisabled(PRBool aStyleDisabled) = 0; - NS_IMETHOD GetAuthorStyleDisabled(PRBool* aStyleDisabled) = 0; + // XXX these could easily be inlined, but there is a circular #include + // problem with nsStyleSet. + NS_HIDDEN_(void) SetAuthorStyleDisabled(PRBool aDisabled); + NS_HIDDEN_(PRBool) GetAuthorStyleDisabled(); /* * Called when stylesheets are added/removed/enabled/disabled to rebuild * all style data for a given pres shell without necessarily reconstructing * all of the frames. */ - NS_IMETHOD ReconstructStyleData() = 0; + virtual NS_HIDDEN_(void) ReconstructStyleDataExternal(); + NS_HIDDEN_(void) ReconstructStyleDataInternal(); +#ifdef _IMPL_NS_LAYOUT + void ReconstructStyleData() { ReconstructStyleDataInternal(); } +#else + void ReconstructStyleData() { ReconstructStyleDataExternal(); } +#endif /** Setup all style rules required to implement preferences * - used for background/text/link colors and link underlining @@ -213,16 +221,6 @@ public: */ NS_IMETHOD SetPreferenceStyleRules(PRBool aForceReflow) = 0; - /** Allow client to enable and disable the use of the preference style rules, - * by type. - * NOTE: type argument is currently ignored, but is in the API for - * future refinement - * - * - initially created for bugs 31816, 20760, 22963 - */ - NS_IMETHOD EnablePrefStyleRules(PRBool aEnable, PRUint8 aPrefType=0xFF) = 0; - NS_IMETHOD ArePrefStyleRulesEnabled(PRBool& aEnabled) = 0; - /** * Gather titles of all selectable (alternate and preferred) style sheets * fills void array with nsString* caller must free strings @@ -230,10 +228,11 @@ public: NS_IMETHOD ListAlternateStyleSheets(nsStringArray& aTitleList) = 0; /** - * GetFrameSelection will return the Frame based selection API you - * cannot go back and forth anymore with QI with nsIDOM sel and nsIFrame sel. + * FrameSelection will return the Frame based selection API. + * You cannot go back and forth anymore with QI between nsIDOM sel and + * nsIFrame sel. */ - NS_IMETHOD GetFrameSelection(nsIFrameSelection** aSelection) = 0; + nsIFrameSelection* FrameSelection() { return mSelection; } // Make shell be a document observer NS_IMETHOD BeginObservingDocument() = 0; @@ -672,11 +671,14 @@ protected: // these are the same Document and PresContext owned by the DocViewer. // we must share ownership. nsIDocument* mDocument; // [STRONG] - nsPresContext* mPresContext; // [STRONG] + nsPresContext* mPresContext; // [STRONG] nsStyleSet* mStyleSet; // [OWNS] nsCSSFrameConstructor* mFrameConstructor; // [OWNS] nsIViewManager* mViewManager; // [WEAK] docViewer owns it so I don't have to + nsIFrameSelection* mSelection; nsFrameManagerBase mFrameManager; // [OWNS] + + PRPackedBool mStylesHaveChanged; }; /** diff --git a/mozilla/layout/base/public/nsPresContext.h b/mozilla/layout/base/public/nsPresContext.h index 9427646f649..48756c5a151 100644 --- a/mozilla/layout/base/public/nsPresContext.h +++ b/mozilla/layout/base/public/nsPresContext.h @@ -185,7 +185,7 @@ public: * Access the image animation mode for this context */ PRUint16 ImageAnimationMode() const { return mImageAnimationMode; } - virtual void SetImageAnimationModeExternal(PRUint16 aMode); + virtual NS_HIDDEN_(void) SetImageAnimationModeExternal(PRUint16 aMode); NS_HIDDEN_(void) SetImageAnimationModeInternal(PRUint16 aMode); #ifdef _IMPL_NS_LAYOUT void SetImageAnimationMode(PRUint16 aMode) @@ -227,7 +227,7 @@ public: /** * Get the font metrics for a given font. */ - virtual already_AddRefed + virtual NS_HIDDEN_(already_AddRefed) GetMetricsForExternal(const nsFont& aFont); NS_HIDDEN_(already_AddRefed) GetMetricsForInternal(const nsFont& aFont); @@ -243,7 +243,7 @@ public: * Get the default font correponding to the given ID. This object is * read-only, you must copy the font to modify it. */ - virtual const nsFont* GetDefaultFontExternal(PRUint8 aFontID) const; + virtual NS_HIDDEN_(const nsFont*) GetDefaultFontExternal(PRUint8 aFontID) const; NS_HIDDEN_(const nsFont*) GetDefaultFontInternal(PRUint8 aFontID) const; #ifdef _IMPL_NS_LAYOUT const nsFont* GetDefaultFont(PRUint8 aFontID) const @@ -328,7 +328,7 @@ public: NS_HIDDEN_(void) SetContainer(nsISupports* aContainer); - virtual already_AddRefed GetContainerExternal(); + virtual NS_HIDDEN_(already_AddRefed) GetContainerExternal(); NS_HIDDEN_(already_AddRefed) GetContainerInternal(); #ifdef _IMPL_NS_LAYOUT already_AddRefed GetContainer() @@ -462,7 +462,7 @@ public: * * @lina 07/12/2000 */ - virtual PRBool BidiEnabledExternal() const; + virtual NS_HIDDEN_(PRBool) BidiEnabledExternal() const; NS_HIDDEN_(PRBool) BidiEnabledInternal() const; #ifdef _IMPL_NS_LAYOUT PRBool BidiEnabled() const { return BidiEnabledInternal(); } diff --git a/mozilla/layout/base/src/nsCaret.cpp b/mozilla/layout/base/src/nsCaret.cpp index 422b0ac35be..1d629151787 100644 --- a/mozilla/layout/base/src/nsCaret.cpp +++ b/mozilla/layout/base/src/nsCaret.cpp @@ -303,16 +303,6 @@ NS_IMETHODIMP nsCaret::GetCaretCoordinates(EViewCoordinates aRelativeToType, nsI if (!contentNode) return NS_ERROR_FAILURE; - //get frame selection and find out what frame to use... - nsCOMPtr frameSelection; - nsCOMPtr presShell = do_QueryReferent(mPresShell); - if (presShell) - err = presShell->GetFrameSelection(getter_AddRefs(frameSelection)); - else - return NS_ERROR_FAILURE; - if (NS_FAILED(err) || !frameSelection) - return err?err : NS_ERROR_FAILURE; - // find the frame that contains the content node that has focus nsIFrame* theFrame = nsnull; PRInt32 theFrameOffset = 0; @@ -323,7 +313,12 @@ NS_IMETHODIMP nsCaret::GetCaretCoordinates(EViewCoordinates aRelativeToType, nsI hint = nsIFrameSelection::HINTRIGHT; else hint = nsIFrameSelection::HINTLEFT; - err = frameSelection->GetFrameForNodeOffset(contentNode, focusOffset, hint, &theFrame, &theFrameOffset); + + nsCOMPtr presShell = do_QueryReferent(mPresShell); + err = presShell->FrameSelection()->GetFrameForNodeOffset(contentNode, + focusOffset, hint, + &theFrame, + &theFrameOffset); if (NS_FAILED(err) || !theFrame) return err; @@ -532,12 +527,7 @@ PRBool nsCaret::SetupDrawingFrameAndOffset(nsIDOMNode* aNode, PRInt32 aOffset, n if (!presShell) return PR_FALSE; - nsCOMPtr frameSelection; - presShell->GetFrameSelection(getter_AddRefs(frameSelection)); - if (!frameSelection) - return PR_FALSE; - - + nsIFrameSelection *frameSelection = presShell->FrameSelection(); nsIFrame* theFrame = nsnull; PRInt32 theFrameOffset = 0; diff --git a/mozilla/layout/generic/nsBlockFrame.cpp b/mozilla/layout/generic/nsBlockFrame.cpp index da6a7e6f985..218a5ed4748 100644 --- a/mozilla/layout/generic/nsBlockFrame.cpp +++ b/mozilla/layout/generic/nsBlockFrame.cpp @@ -5657,7 +5657,7 @@ nsBlockFrame::HandleEvent(nsPresContext* aPresContext, frameSelection = do_QueryInterface(selCon); } else - shell->GetFrameSelection(getter_AddRefs(frameSelection)); + frameSelection = shell->FrameSelection(); if (!frameSelection || NS_FAILED(frameSelection->GetMouseDownState(&mouseDown)) || !mouseDown) return NS_OK;//do not handle } @@ -5733,14 +5733,13 @@ nsBlockFrame::HandleEvent(nsPresContext* aPresContext, if (displayresult == nsISelectionController::SELECTION_OFF) return NS_OK;//nothing to do we cannot affect selection from here } - nsCOMPtr frameselection; - shell->GetFrameSelection(getter_AddRefs(frameselection)); PRBool mouseDown = aEvent->message == NS_MOUSE_MOVE; - if (frameselection) - { - result = frameselection->HandleClick(pos.mResultContent, pos.mContentOffset, - pos.mContentOffsetEnd, mouseDown || me->isShift, PR_FALSE, pos.mPreferLeft); - } + result = shell->FrameSelection()->HandleClick(pos.mResultContent, + pos.mContentOffset, + pos.mContentOffsetEnd, + mouseDown || me->isShift, + PR_FALSE, + pos.mPreferLeft); } else result = resultFrame->HandleEvent(aPresContext, aEvent, aEventStatus);//else let the frame/container do what it needs diff --git a/mozilla/layout/generic/nsFrame.cpp b/mozilla/layout/generic/nsFrame.cpp index aac1f82dec9..7562603ebe4 100644 --- a/mozilla/layout/generic/nsFrame.cpp +++ b/mozilla/layout/generic/nsFrame.cpp @@ -829,11 +829,9 @@ nsFrame::Paint(nsPresContext* aPresContext, frameSelection = do_QueryInterface(selCon); //this MAY implement } if (!frameSelection) - result = shell->GetFrameSelection(getter_AddRefs(frameSelection)); - if (NS_SUCCEEDED(result) && frameSelection){ - result = frameSelection->LookUpSelection(newContent, offset, - 1, &details, PR_FALSE);//look up to see what selection(s) are on this frame - } + frameSelection = shell->FrameSelection(); + result = frameSelection->LookUpSelection(newContent, offset, + 1, &details, PR_FALSE);//look up to see what selection(s) are on this frame } if (details) @@ -1327,7 +1325,7 @@ nsFrame::HandlePress(nsPresContext* aPresContext, frameselection = do_QueryInterface(selCon); //this MAY implement if (!frameselection)//if we must get it from the pres shell's - rv = shell->GetFrameSelection(getter_AddRefs(frameselection)); + frameselection = shell->FrameSelection(); if (!frameselection) return NS_ERROR_FAILURE; @@ -1667,11 +1665,7 @@ nsFrame::PeekBackwardAndForward(nsSelectionAmount aAmountBack, // maintain selection nsCOMPtr frameselection = do_QueryInterface(selcon); //this MAY implement if (!frameselection) - { - rv = aPresContext->PresShell()->GetFrameSelection(getter_AddRefs(frameselection)); - if (NS_FAILED(rv) || !frameselection) - return NS_OK; // return NS_OK; we don't care if this fails - } + frameselection = aPresContext->PresShell()->FrameSelection(); return frameselection->MaintainSelection(); } @@ -1695,7 +1689,8 @@ NS_IMETHODIMP nsFrame::HandleDrag(nsPresContext* aPresContext, nsEventStatus* aEventStatus) { PRBool selectable; - IsSelectable(&selectable, nsnull); + PRUint8 selectStyle; + IsSelectable(&selectable, &selectStyle); if (!selectable) return NS_OK; if (DisplaySelection(aPresContext) == nsISelectionController::SELECTION_OFF) { @@ -1713,60 +1708,47 @@ NS_IMETHODIMP nsFrame::HandleDrag(nsPresContext* aPresContext, frameselection = do_QueryInterface(selCon); //this MAY implement } if (!frameselection) - result = presShell->GetFrameSelection(getter_AddRefs(frameselection)); + frameselection = presShell->FrameSelection(); - if (NS_SUCCEEDED(result) && frameselection) - { - PRBool mouseDown = PR_FALSE; - if (NS_SUCCEEDED(frameselection->GetMouseDownState(&mouseDown)) && !mouseDown) - return NS_OK; + PRBool mouseDown = PR_FALSE; + if (NS_SUCCEEDED(frameselection->GetMouseDownState(&mouseDown)) && !mouseDown) + return NS_OK; - // check whether style allows selection - // if not, don't tell selection the mouse event even occurred. - PRBool selectable; - PRUint8 selectStyle; - result = IsSelectable(&selectable, &selectStyle); - if (NS_FAILED(result)) - return result; + frameselection->StopAutoScrollTimer(); + // Check if we are dragging in a table cell + nsCOMPtr parentContent; + PRInt32 contentOffset; + PRInt32 target; + nsMouseEvent *me = (nsMouseEvent *)aEvent; + result = GetDataForTableSelection(frameselection, presShell, me, + getter_AddRefs(parentContent), + &contentOffset, &target); - // check for select: none - if (selectable) - { - frameselection->StopAutoScrollTimer(); - // Check if we are dragging in a table cell - nsCOMPtr parentContent; - PRInt32 contentOffset; - PRInt32 target; - nsMouseEvent *me = (nsMouseEvent *)aEvent; - result = GetDataForTableSelection(frameselection, presShell, me, getter_AddRefs(parentContent), &contentOffset, &target); + if (NS_SUCCEEDED(result) && parentContent) + frameselection->HandleTableSelection(parentContent, contentOffset, target, me); + else + frameselection->HandleDrag(aPresContext, this, aEvent->point); - if (NS_SUCCEEDED(result) && parentContent) - frameselection->HandleTableSelection(parentContent, contentOffset, target, me); - else - frameselection->HandleDrag(aPresContext, this, aEvent->point); - - nsIView* captureView = GetNearestCapturingView(this); - if (captureView) { - // Get the view that aEvent->point is relative to. This is disgusting. - nsPoint dummyPoint; - nsIView* eventView; - GetOffsetFromView(aPresContext, dummyPoint, &eventView); - nsPoint pt = aEvent->point; - nsIView* view = eventView; - while (view && view != captureView) { - pt += view->GetPosition(); - view = view->GetParent(); - } - if (!view) { - // Hmm. Maybe captureView is a child of eventView? Recover by - // subtracting the global offset of eventView. - for (view = eventView; view; view = view->GetParent()) { - pt -= view->GetPosition(); - } - } - frameselection->StartAutoScrollTimer(aPresContext, captureView, pt, 30); + nsIView* captureView = GetNearestCapturingView(this); + if (captureView) { + // Get the view that aEvent->point is relative to. This is disgusting. + nsPoint dummyPoint; + nsIView* eventView; + GetOffsetFromView(aPresContext, dummyPoint, &eventView); + nsPoint pt = aEvent->point; + nsIView* view = eventView; + while (view && view != captureView) { + pt += view->GetPosition(); + view = view->GetParent(); + } + if (!view) { + // Hmm. Maybe captureView is a child of eventView? Recover by + // subtracting the global offset of eventView. + for (view = eventView; view; view = view->GetParent()) { + pt -= view->GetPosition(); } } + frameselection->StartAutoScrollTimer(aPresContext, captureView, pt, 30); } return NS_OK; @@ -1796,13 +1778,7 @@ NS_IMETHODIMP nsFrame::HandleRelease(nsPresContext* aPresContext, if (NS_SUCCEEDED(result) && selCon) frameselection = do_QueryInterface(selCon); //this MAY implement if (!frameselection) - result = presShell->GetFrameSelection(getter_AddRefs(frameselection)); - - if (NS_FAILED(result)) - return result; - - if (!frameselection) - return NS_ERROR_FAILURE; + frameselection = presShell->FrameSelection(); NS_ENSURE_ARG_POINTER(aEventStatus); if (nsEventStatus_eConsumeNoDefault != *aEventStatus) { diff --git a/mozilla/layout/generic/nsTextFrame.cpp b/mozilla/layout/generic/nsTextFrame.cpp index b9768c5d068..4452ef9fb29 100644 --- a/mozilla/layout/generic/nsTextFrame.cpp +++ b/mozilla/layout/generic/nsTextFrame.cpp @@ -2128,18 +2128,19 @@ nsTextFrame::IsTextInSelection(nsPresContext* aPresContext, nsresult rv = NS_OK; //if that failed get it from the pres shell if (!frameSelection) - rv = shell->GetFrameSelection(getter_AddRefs(frameSelection)); + frameSelection = shell->FrameSelection(); nsCOMPtr content; - if (NS_SUCCEEDED(rv) && frameSelection){ - PRInt32 offset; - PRInt32 length; + PRInt32 offset; + PRInt32 length; - rv = GetContentAndOffsetsForSelection(aPresContext,getter_AddRefs(content),&offset,&length); - if (NS_SUCCEEDED(rv) && content){ - rv = frameSelection->LookUpSelection(content, mContentOffset, - mContentLength , &details, PR_FALSE); - } + rv = GetContentAndOffsetsForSelection(aPresContext, + getter_AddRefs(content), + &offset, &length); + if (NS_SUCCEEDED(rv) && content) { + rv = frameSelection->LookUpSelection(content, mContentOffset, + mContentLength, &details, + PR_FALSE); } //where are the selection points "really" @@ -2314,19 +2315,19 @@ nsTextFrame::PaintUnicodeText(nsPresContext* aPresContext, //if that failed get it from the pres shell nsresult rv = NS_OK; if (!frameSelection) - rv = shell->GetFrameSelection(getter_AddRefs(frameSelection)); + frameSelection = shell->FrameSelection(); nsCOMPtr content; - if (NS_SUCCEEDED(rv) && frameSelection){ - PRInt32 offset; - PRInt32 length; + PRInt32 offset; + PRInt32 length; - rv = GetContentAndOffsetsForSelection(aPresContext,getter_AddRefs(content),&offset,&length); - if (NS_SUCCEEDED(rv) && content){ - rv = frameSelection->LookUpSelection(content, mContentOffset, - mContentLength , &details, PR_FALSE); - } + rv = GetContentAndOffsetsForSelection(aPresContext, + getter_AddRefs(content), + &offset, &length); + if (NS_SUCCEEDED(rv) && content) { + rv = frameSelection->LookUpSelection(content, mContentOffset, + mContentLength, &details, + PR_FALSE); } - //where are the selection points "really" SelectionDetails *sdptr = details; @@ -2992,19 +2993,18 @@ nsTextFrame::PaintTextSlowly(nsPresContext* aPresContext, nsresult rv = NS_OK; frameSelection = do_QueryInterface(selCon); //this MAY implement if (!frameSelection)//if that failed get it from the presshell - rv = shell->GetFrameSelection(getter_AddRefs(frameSelection)); + frameSelection = shell->FrameSelection(); nsCOMPtr content; - if (NS_SUCCEEDED(rv) && frameSelection) - { - PRInt32 offset; - PRInt32 length; + PRInt32 offset; + PRInt32 length; - rv = GetContentAndOffsetsForSelection(aPresContext,getter_AddRefs(content),&offset,&length); - if (NS_SUCCEEDED(rv)) - { - rv = frameSelection->LookUpSelection(content, mContentOffset, - mContentLength , &details, PR_FALSE); - } + rv = GetContentAndOffsetsForSelection(aPresContext, + getter_AddRefs(content), + &offset, &length); + if (NS_SUCCEEDED(rv)) { + rv = frameSelection->LookUpSelection(content, mContentOffset, + mContentLength, &details, + PR_FALSE); } //where are the selection points "really" @@ -3218,17 +3218,18 @@ nsTextFrame::PaintAsciiText(nsPresContext* aPresContext, frameSelection = do_QueryInterface(selCon); //this MAY implement nsresult rv = NS_OK; if (!frameSelection)//if that failed get it from the presshell - rv = shell->GetFrameSelection(getter_AddRefs(frameSelection)); + frameSelection = shell->FrameSelection(); nsCOMPtr content; - if (NS_SUCCEEDED(rv) && frameSelection){ - PRInt32 offset; - PRInt32 length; + PRInt32 offset; + PRInt32 length; - rv = GetContentAndOffsetsForSelection(aPresContext, getter_AddRefs(content),&offset,&length); - if (NS_SUCCEEDED(rv)){ - rv = frameSelection->LookUpSelection(content, mContentOffset, - mContentLength , &details, PR_FALSE); - } + rv = GetContentAndOffsetsForSelection(aPresContext, + getter_AddRefs(content), + &offset, &length); + if (NS_SUCCEEDED(rv)) { + rv = frameSelection->LookUpSelection(content, mContentOffset, + mContentLength, &details, + PR_FALSE); } //where are the selection points "really" @@ -3650,19 +3651,19 @@ nsTextFrame::SetSelected(nsPresContext* aPresContext, frameSelection = do_QueryInterface(selCon); //this MAY implement } if (!frameSelection) - rv = shell->GetFrameSelection(getter_AddRefs(frameSelection)); - if (NS_SUCCEEDED(rv) && frameSelection){ - nsCOMPtr content; - PRInt32 offset; - PRInt32 length; + frameSelection = shell->FrameSelection(); - rv = GetContentAndOffsetsForSelection(aPresContext, getter_AddRefs(content),&offset,&length); - if (NS_SUCCEEDED(rv) && content){ - rv = frameSelection->LookUpSelection(content, offset, - length , &details, PR_TRUE); -// PR_TRUE last param used here! we need to see if we are still selected. so no shortcut + nsCOMPtr content; + PRInt32 offset; + PRInt32 length; - } + rv = GetContentAndOffsetsForSelection(aPresContext, + getter_AddRefs(content), + &offset, &length); + if (NS_SUCCEEDED(rv) && content) { + rv = frameSelection->LookUpSelection(content, offset, + length, &details, PR_TRUE); + // PR_TRUE last param used here! we need to see if we are still selected. so no shortcut } } if (!details) diff --git a/mozilla/layout/html/base/src/nsBlockFrame.cpp b/mozilla/layout/html/base/src/nsBlockFrame.cpp index da6a7e6f985..218a5ed4748 100644 --- a/mozilla/layout/html/base/src/nsBlockFrame.cpp +++ b/mozilla/layout/html/base/src/nsBlockFrame.cpp @@ -5657,7 +5657,7 @@ nsBlockFrame::HandleEvent(nsPresContext* aPresContext, frameSelection = do_QueryInterface(selCon); } else - shell->GetFrameSelection(getter_AddRefs(frameSelection)); + frameSelection = shell->FrameSelection(); if (!frameSelection || NS_FAILED(frameSelection->GetMouseDownState(&mouseDown)) || !mouseDown) return NS_OK;//do not handle } @@ -5733,14 +5733,13 @@ nsBlockFrame::HandleEvent(nsPresContext* aPresContext, if (displayresult == nsISelectionController::SELECTION_OFF) return NS_OK;//nothing to do we cannot affect selection from here } - nsCOMPtr frameselection; - shell->GetFrameSelection(getter_AddRefs(frameselection)); PRBool mouseDown = aEvent->message == NS_MOUSE_MOVE; - if (frameselection) - { - result = frameselection->HandleClick(pos.mResultContent, pos.mContentOffset, - pos.mContentOffsetEnd, mouseDown || me->isShift, PR_FALSE, pos.mPreferLeft); - } + result = shell->FrameSelection()->HandleClick(pos.mResultContent, + pos.mContentOffset, + pos.mContentOffsetEnd, + mouseDown || me->isShift, + PR_FALSE, + pos.mPreferLeft); } else result = resultFrame->HandleEvent(aPresContext, aEvent, aEventStatus);//else let the frame/container do what it needs diff --git a/mozilla/layout/html/base/src/nsFrame.cpp b/mozilla/layout/html/base/src/nsFrame.cpp index aac1f82dec9..7562603ebe4 100644 --- a/mozilla/layout/html/base/src/nsFrame.cpp +++ b/mozilla/layout/html/base/src/nsFrame.cpp @@ -829,11 +829,9 @@ nsFrame::Paint(nsPresContext* aPresContext, frameSelection = do_QueryInterface(selCon); //this MAY implement } if (!frameSelection) - result = shell->GetFrameSelection(getter_AddRefs(frameSelection)); - if (NS_SUCCEEDED(result) && frameSelection){ - result = frameSelection->LookUpSelection(newContent, offset, - 1, &details, PR_FALSE);//look up to see what selection(s) are on this frame - } + frameSelection = shell->FrameSelection(); + result = frameSelection->LookUpSelection(newContent, offset, + 1, &details, PR_FALSE);//look up to see what selection(s) are on this frame } if (details) @@ -1327,7 +1325,7 @@ nsFrame::HandlePress(nsPresContext* aPresContext, frameselection = do_QueryInterface(selCon); //this MAY implement if (!frameselection)//if we must get it from the pres shell's - rv = shell->GetFrameSelection(getter_AddRefs(frameselection)); + frameselection = shell->FrameSelection(); if (!frameselection) return NS_ERROR_FAILURE; @@ -1667,11 +1665,7 @@ nsFrame::PeekBackwardAndForward(nsSelectionAmount aAmountBack, // maintain selection nsCOMPtr frameselection = do_QueryInterface(selcon); //this MAY implement if (!frameselection) - { - rv = aPresContext->PresShell()->GetFrameSelection(getter_AddRefs(frameselection)); - if (NS_FAILED(rv) || !frameselection) - return NS_OK; // return NS_OK; we don't care if this fails - } + frameselection = aPresContext->PresShell()->FrameSelection(); return frameselection->MaintainSelection(); } @@ -1695,7 +1689,8 @@ NS_IMETHODIMP nsFrame::HandleDrag(nsPresContext* aPresContext, nsEventStatus* aEventStatus) { PRBool selectable; - IsSelectable(&selectable, nsnull); + PRUint8 selectStyle; + IsSelectable(&selectable, &selectStyle); if (!selectable) return NS_OK; if (DisplaySelection(aPresContext) == nsISelectionController::SELECTION_OFF) { @@ -1713,60 +1708,47 @@ NS_IMETHODIMP nsFrame::HandleDrag(nsPresContext* aPresContext, frameselection = do_QueryInterface(selCon); //this MAY implement } if (!frameselection) - result = presShell->GetFrameSelection(getter_AddRefs(frameselection)); + frameselection = presShell->FrameSelection(); - if (NS_SUCCEEDED(result) && frameselection) - { - PRBool mouseDown = PR_FALSE; - if (NS_SUCCEEDED(frameselection->GetMouseDownState(&mouseDown)) && !mouseDown) - return NS_OK; + PRBool mouseDown = PR_FALSE; + if (NS_SUCCEEDED(frameselection->GetMouseDownState(&mouseDown)) && !mouseDown) + return NS_OK; - // check whether style allows selection - // if not, don't tell selection the mouse event even occurred. - PRBool selectable; - PRUint8 selectStyle; - result = IsSelectable(&selectable, &selectStyle); - if (NS_FAILED(result)) - return result; + frameselection->StopAutoScrollTimer(); + // Check if we are dragging in a table cell + nsCOMPtr parentContent; + PRInt32 contentOffset; + PRInt32 target; + nsMouseEvent *me = (nsMouseEvent *)aEvent; + result = GetDataForTableSelection(frameselection, presShell, me, + getter_AddRefs(parentContent), + &contentOffset, &target); - // check for select: none - if (selectable) - { - frameselection->StopAutoScrollTimer(); - // Check if we are dragging in a table cell - nsCOMPtr parentContent; - PRInt32 contentOffset; - PRInt32 target; - nsMouseEvent *me = (nsMouseEvent *)aEvent; - result = GetDataForTableSelection(frameselection, presShell, me, getter_AddRefs(parentContent), &contentOffset, &target); + if (NS_SUCCEEDED(result) && parentContent) + frameselection->HandleTableSelection(parentContent, contentOffset, target, me); + else + frameselection->HandleDrag(aPresContext, this, aEvent->point); - if (NS_SUCCEEDED(result) && parentContent) - frameselection->HandleTableSelection(parentContent, contentOffset, target, me); - else - frameselection->HandleDrag(aPresContext, this, aEvent->point); - - nsIView* captureView = GetNearestCapturingView(this); - if (captureView) { - // Get the view that aEvent->point is relative to. This is disgusting. - nsPoint dummyPoint; - nsIView* eventView; - GetOffsetFromView(aPresContext, dummyPoint, &eventView); - nsPoint pt = aEvent->point; - nsIView* view = eventView; - while (view && view != captureView) { - pt += view->GetPosition(); - view = view->GetParent(); - } - if (!view) { - // Hmm. Maybe captureView is a child of eventView? Recover by - // subtracting the global offset of eventView. - for (view = eventView; view; view = view->GetParent()) { - pt -= view->GetPosition(); - } - } - frameselection->StartAutoScrollTimer(aPresContext, captureView, pt, 30); + nsIView* captureView = GetNearestCapturingView(this); + if (captureView) { + // Get the view that aEvent->point is relative to. This is disgusting. + nsPoint dummyPoint; + nsIView* eventView; + GetOffsetFromView(aPresContext, dummyPoint, &eventView); + nsPoint pt = aEvent->point; + nsIView* view = eventView; + while (view && view != captureView) { + pt += view->GetPosition(); + view = view->GetParent(); + } + if (!view) { + // Hmm. Maybe captureView is a child of eventView? Recover by + // subtracting the global offset of eventView. + for (view = eventView; view; view = view->GetParent()) { + pt -= view->GetPosition(); } } + frameselection->StartAutoScrollTimer(aPresContext, captureView, pt, 30); } return NS_OK; @@ -1796,13 +1778,7 @@ NS_IMETHODIMP nsFrame::HandleRelease(nsPresContext* aPresContext, if (NS_SUCCEEDED(result) && selCon) frameselection = do_QueryInterface(selCon); //this MAY implement if (!frameselection) - result = presShell->GetFrameSelection(getter_AddRefs(frameselection)); - - if (NS_FAILED(result)) - return result; - - if (!frameselection) - return NS_ERROR_FAILURE; + frameselection = presShell->FrameSelection(); NS_ENSURE_ARG_POINTER(aEventStatus); if (nsEventStatus_eConsumeNoDefault != *aEventStatus) { diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index cd5b64ddf18..c243e21331b 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -1085,17 +1085,10 @@ public: NS_IMETHOD AllocateStackMemory(size_t aSize, void** aResult); NS_IMETHOD GetPresContext(nsPresContext** aResult); - NS_IMETHOD GetViewManager(nsIViewManager** aResult); - nsIViewManager* GetViewManager() { return mViewManager; } NS_IMETHOD GetActiveAlternateStyleSheet(nsString& aSheetTitle); NS_IMETHOD SelectAlternateStyleSheet(const nsString& aSheetTitle); NS_IMETHOD ListAlternateStyleSheets(nsStringArray& aTitleList); - NS_IMETHOD GetAuthorStyleDisabled(PRBool* aStyleDisabled); - NS_IMETHOD SetAuthorStyleDisabled(PRBool aStyleDisabled); - NS_IMETHOD ReconstructStyleData(); NS_IMETHOD SetPreferenceStyleRules(PRBool aForceReflow); - NS_IMETHOD EnablePrefStyleRules(PRBool aEnable, PRUint8 aPrefType=0xFF); - NS_IMETHOD ArePrefStyleRulesEnabled(PRBool& aEnabled); NS_IMETHOD GetSelection(SelectionType aType, nsISelection** aSelection); @@ -1103,7 +1096,6 @@ public: NS_IMETHOD GetDisplaySelection(PRInt16 *aToggle); NS_IMETHOD ScrollSelectionIntoView(SelectionType aType, SelectionRegion aRegion, PRBool aIsSynchronous); NS_IMETHOD RepaintSelection(SelectionType aType); - NS_IMETHOD GetFrameSelection(nsIFrameSelection** aSelection); NS_IMETHOD BeginObservingDocument(); NS_IMETHOD EndObservingDocument(); @@ -1395,14 +1387,12 @@ protected: nsVoidArray mReflowCommands; PLDHashTable mReflowCommandTable; - PRPackedBool mEnablePrefStyleSheet; PRPackedBool mDocumentLoading; PRPackedBool mIsReflowing; PRPackedBool mIsDestroying; PRPackedBool mDidInitialReflow; PRPackedBool mIgnoreFrameDestruction; - PRPackedBool mStylesHaveChanged; PRPackedBool mHaveShutDown; nsIFrame* mCurrentEventFrame; @@ -1416,7 +1406,6 @@ protected: nsIView* mCurrentTargetView; #endif - nsCOMPtr mSelection; nsCOMPtr mCaret; PRInt16 mSelectionFlags; PRPackedBool mBatchReflows; // When set to true, the pres shell batches reflow commands. @@ -1607,12 +1596,12 @@ NS_NewPresShell(nsIPresShell** aInstancePtrResult) (void **) aInstancePtrResult); } -PresShell::PresShell(): +PresShell::PresShell() #ifdef IBMBIDI - mBidiLevel(BIDI_LEVEL_UNDEFINED), + : mBidiLevel(BIDI_LEVEL_UNDEFINED) #endif - mEnablePrefStyleSheet(PR_TRUE) { + mSelection = nsnull; #ifdef MOZ_REFLOW_PERF mReflowCountMgr = new ReflowCountMgr(); mReflowCountMgr->SetPresContext(mPresContext); @@ -1662,6 +1651,7 @@ PresShell::~PresShell() NS_IF_RELEASE(mPresContext); NS_IF_RELEASE(mDocument); + NS_IF_RELEASE(mSelection); } /** @@ -1740,7 +1730,7 @@ PresShell::Init(nsIDocument* aDocument, // before creating any frames. SetPreferenceStyleRules(PR_FALSE); - mSelection = do_CreateInstance(kFrameSelectionCID, &result); + result = CallCreateInstance(kFrameSelectionCID, &mSelection); if (NS_FAILED(result)) { mStyleSet = nsnull; return result; @@ -2026,18 +2016,6 @@ PresShell::GetPresContext(nsPresContext** aResult) return NS_OK; } -NS_IMETHODIMP -PresShell::GetViewManager(nsIViewManager** aResult) -{ - NS_PRECONDITION(nsnull != aResult, "null ptr"); - if (nsnull == aResult) { - return NS_ERROR_NULL_POINTER; - } - *aResult = mViewManager; - NS_IF_ADDREF(mViewManager); - return NS_OK; -} - NS_IMETHODIMP PresShell::GetActiveAlternateStyleSheet(nsString& aSheetTitle) { // first non-html sheet in style set that has title @@ -2096,7 +2074,7 @@ PresShell::SelectAlternateStyleSheet(const nsString& aSheetTitle) } mStyleSet->EndUpdate(); - return ReconstructStyleData(); + ReconstructStyleData(); } return NS_OK; } @@ -2129,61 +2107,19 @@ PresShell::ListAlternateStyleSheets(nsStringArray& aTitleList) return NS_OK; } -NS_IMETHODIMP -PresShell::SetAuthorStyleDisabled(PRBool aStyleDisabled) +void +nsIPresShell::SetAuthorStyleDisabled(PRBool aStyleDisabled) { if (aStyleDisabled != mStyleSet->GetAuthorStyleDisabled()) { - nsresult rv = mStyleSet->SetAuthorStyleDisabled(aStyleDisabled); - if (NS_FAILED(rv)) return rv; - return ReconstructStyleData(); + mStyleSet->SetAuthorStyleDisabled(aStyleDisabled); + ReconstructStyleData(); } - return NS_OK; } -NS_IMETHODIMP -PresShell::GetAuthorStyleDisabled(PRBool* aStyleDisabled) +PRBool +nsIPresShell::GetAuthorStyleDisabled() { - *aStyleDisabled = mStyleSet->GetAuthorStyleDisabled(); - return NS_OK; -} - -NS_IMETHODIMP -PresShell::EnablePrefStyleRules(PRBool aEnable, PRUint8 aPrefType/*=0xFF*/) -{ - nsresult result = NS_OK; - - // capture change in state - PRBool bChanging = (mEnablePrefStyleSheet != aEnable) ? PR_TRUE : PR_FALSE; - // set to desired state - mEnablePrefStyleSheet = aEnable; - -#ifdef DEBUG_attinasi - printf("PrefStyleSheet %s %s\n", - mEnablePrefStyleSheet ? "ENABLED" : "DISABLED", - bChanging ? "(state toggled)" : "(state unchanged)"); -#endif - - // deal with changing state - if(bChanging){ - switch (mEnablePrefStyleSheet){ - case PR_TRUE: - // was off, now on, so create the rules - result = SetPreferenceStyleRules(PR_TRUE); - break; - default : - // was on, now off, so clear the rules - result = ClearPreferenceStyleRules(); - break; - } - } - return result; -} - -NS_IMETHODIMP -PresShell::ArePrefStyleRulesEnabled(PRBool& aEnabled) -{ - aEnabled = mEnablePrefStyleSheet; - return NS_OK; + return mStyleSet->GetAuthorStyleDisabled(); } NS_IMETHODIMP @@ -2208,16 +2144,6 @@ PresShell::SetPreferenceStyleRules(PRBool aForceReflow) if (mPresContext) { nsresult result = NS_OK; - // zeroth, make sure this feature is enabled - // XXX: may get more granularity later - // (i.e. each pref may be controlled independently) - if (!mEnablePrefStyleSheet) { -#ifdef DEBUG_attinasi - printf("PrefStyleSheet disabled\n"); -#endif - return PR_TRUE; - } - // first, make sure this is not a chrome shell nsCOMPtr container = mPresContext->GetContainer(); if (container) { @@ -2615,17 +2541,6 @@ PresShell::RepaintSelection(SelectionType aType) return mSelection->RepaintSelection(mPresContext, aType); } -NS_IMETHODIMP -PresShell::GetFrameSelection(nsIFrameSelection** aSelection) -{ - if (!aSelection || !mSelection) - return NS_ERROR_NULL_POINTER; - *aSelection = mSelection; - (*aSelection)->AddRef(); - return NS_OK; -} - - // Make shell be a document observer NS_IMETHODIMP PresShell::BeginObservingDocument() @@ -5269,14 +5184,14 @@ PresShell::ReconstructFrames(void) return rv; } -NS_IMETHODIMP -PresShell::ReconstructStyleData() +void +nsIPresShell::ReconstructStyleDataInternal() { mStylesHaveChanged = PR_FALSE; nsIFrame* rootFrame = FrameManager()->GetRootFrame(); if (!rootFrame) - return NS_OK; + return; nsStyleChangeList changeList; FrameManager()->ComputeStyleChangeFor(rootFrame, &changeList, @@ -5285,8 +5200,12 @@ PresShell::ReconstructStyleData() mFrameConstructor->ProcessRestyledFrames(changeList, mPresContext); VERIFY_STYLE_TREE; +} - return NS_OK; +void +nsIPresShell::ReconstructStyleDataExternal() +{ + ReconstructStyleDataInternal(); } void diff --git a/mozilla/layout/html/base/src/nsTextFrame.cpp b/mozilla/layout/html/base/src/nsTextFrame.cpp index b9768c5d068..4452ef9fb29 100644 --- a/mozilla/layout/html/base/src/nsTextFrame.cpp +++ b/mozilla/layout/html/base/src/nsTextFrame.cpp @@ -2128,18 +2128,19 @@ nsTextFrame::IsTextInSelection(nsPresContext* aPresContext, nsresult rv = NS_OK; //if that failed get it from the pres shell if (!frameSelection) - rv = shell->GetFrameSelection(getter_AddRefs(frameSelection)); + frameSelection = shell->FrameSelection(); nsCOMPtr content; - if (NS_SUCCEEDED(rv) && frameSelection){ - PRInt32 offset; - PRInt32 length; + PRInt32 offset; + PRInt32 length; - rv = GetContentAndOffsetsForSelection(aPresContext,getter_AddRefs(content),&offset,&length); - if (NS_SUCCEEDED(rv) && content){ - rv = frameSelection->LookUpSelection(content, mContentOffset, - mContentLength , &details, PR_FALSE); - } + rv = GetContentAndOffsetsForSelection(aPresContext, + getter_AddRefs(content), + &offset, &length); + if (NS_SUCCEEDED(rv) && content) { + rv = frameSelection->LookUpSelection(content, mContentOffset, + mContentLength, &details, + PR_FALSE); } //where are the selection points "really" @@ -2314,19 +2315,19 @@ nsTextFrame::PaintUnicodeText(nsPresContext* aPresContext, //if that failed get it from the pres shell nsresult rv = NS_OK; if (!frameSelection) - rv = shell->GetFrameSelection(getter_AddRefs(frameSelection)); + frameSelection = shell->FrameSelection(); nsCOMPtr content; - if (NS_SUCCEEDED(rv) && frameSelection){ - PRInt32 offset; - PRInt32 length; + PRInt32 offset; + PRInt32 length; - rv = GetContentAndOffsetsForSelection(aPresContext,getter_AddRefs(content),&offset,&length); - if (NS_SUCCEEDED(rv) && content){ - rv = frameSelection->LookUpSelection(content, mContentOffset, - mContentLength , &details, PR_FALSE); - } + rv = GetContentAndOffsetsForSelection(aPresContext, + getter_AddRefs(content), + &offset, &length); + if (NS_SUCCEEDED(rv) && content) { + rv = frameSelection->LookUpSelection(content, mContentOffset, + mContentLength, &details, + PR_FALSE); } - //where are the selection points "really" SelectionDetails *sdptr = details; @@ -2992,19 +2993,18 @@ nsTextFrame::PaintTextSlowly(nsPresContext* aPresContext, nsresult rv = NS_OK; frameSelection = do_QueryInterface(selCon); //this MAY implement if (!frameSelection)//if that failed get it from the presshell - rv = shell->GetFrameSelection(getter_AddRefs(frameSelection)); + frameSelection = shell->FrameSelection(); nsCOMPtr content; - if (NS_SUCCEEDED(rv) && frameSelection) - { - PRInt32 offset; - PRInt32 length; + PRInt32 offset; + PRInt32 length; - rv = GetContentAndOffsetsForSelection(aPresContext,getter_AddRefs(content),&offset,&length); - if (NS_SUCCEEDED(rv)) - { - rv = frameSelection->LookUpSelection(content, mContentOffset, - mContentLength , &details, PR_FALSE); - } + rv = GetContentAndOffsetsForSelection(aPresContext, + getter_AddRefs(content), + &offset, &length); + if (NS_SUCCEEDED(rv)) { + rv = frameSelection->LookUpSelection(content, mContentOffset, + mContentLength, &details, + PR_FALSE); } //where are the selection points "really" @@ -3218,17 +3218,18 @@ nsTextFrame::PaintAsciiText(nsPresContext* aPresContext, frameSelection = do_QueryInterface(selCon); //this MAY implement nsresult rv = NS_OK; if (!frameSelection)//if that failed get it from the presshell - rv = shell->GetFrameSelection(getter_AddRefs(frameSelection)); + frameSelection = shell->FrameSelection(); nsCOMPtr content; - if (NS_SUCCEEDED(rv) && frameSelection){ - PRInt32 offset; - PRInt32 length; + PRInt32 offset; + PRInt32 length; - rv = GetContentAndOffsetsForSelection(aPresContext, getter_AddRefs(content),&offset,&length); - if (NS_SUCCEEDED(rv)){ - rv = frameSelection->LookUpSelection(content, mContentOffset, - mContentLength , &details, PR_FALSE); - } + rv = GetContentAndOffsetsForSelection(aPresContext, + getter_AddRefs(content), + &offset, &length); + if (NS_SUCCEEDED(rv)) { + rv = frameSelection->LookUpSelection(content, mContentOffset, + mContentLength, &details, + PR_FALSE); } //where are the selection points "really" @@ -3650,19 +3651,19 @@ nsTextFrame::SetSelected(nsPresContext* aPresContext, frameSelection = do_QueryInterface(selCon); //this MAY implement } if (!frameSelection) - rv = shell->GetFrameSelection(getter_AddRefs(frameSelection)); - if (NS_SUCCEEDED(rv) && frameSelection){ - nsCOMPtr content; - PRInt32 offset; - PRInt32 length; + frameSelection = shell->FrameSelection(); - rv = GetContentAndOffsetsForSelection(aPresContext, getter_AddRefs(content),&offset,&length); - if (NS_SUCCEEDED(rv) && content){ - rv = frameSelection->LookUpSelection(content, offset, - length , &details, PR_TRUE); -// PR_TRUE last param used here! we need to see if we are still selected. so no shortcut + nsCOMPtr content; + PRInt32 offset; + PRInt32 length; - } + rv = GetContentAndOffsetsForSelection(aPresContext, + getter_AddRefs(content), + &offset, &length); + if (NS_SUCCEEDED(rv) && content) { + rv = frameSelection->LookUpSelection(content, offset, + length, &details, PR_TRUE); + // PR_TRUE last param used here! we need to see if we are still selected. so no shortcut } } if (!details) diff --git a/mozilla/layout/html/table/src/nsTableCellFrame.cpp b/mozilla/layout/html/table/src/nsTableCellFrame.cpp index e4c52e98709..ac7935562a4 100644 --- a/mozilla/layout/html/table/src/nsTableCellFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableCellFrame.cpp @@ -305,39 +305,38 @@ nsTableCellFrame::DecorateForSelection(nsPresContext* aPresContext, PRBool isSelected = (GetStateBits() & NS_FRAME_SELECTED_CONTENT) == NS_FRAME_SELECTED_CONTENT; if (isSelected) { - nsCOMPtr frameSelection; - nsresult result = aPresContext->PresShell()-> - GetFrameSelection(getter_AddRefs(frameSelection)); - if (NS_SUCCEEDED(result)) { - PRBool tableCellSelectionMode; - result = frameSelection->GetTableCellSelection(&tableCellSelectionMode); - if (NS_SUCCEEDED(result) && tableCellSelectionMode) { - nscolor bordercolor; - if (displaySelection == nsISelectionController::SELECTION_DISABLED) { - bordercolor = NS_RGB(176,176,176);// disabled color - } - else { - aPresContext->LookAndFeel()-> - GetColor(nsILookAndFeel::eColor_TextSelectBackground, - bordercolor); - } - PRInt16 t2p = (PRInt16) aPresContext->PixelsToTwips(); - if ((mRect.width >(3*t2p)) && (mRect.height > (3*t2p))) - { - //compare bordercolor to ((nsStyleColor *)myColor)->mBackgroundColor) - bordercolor = EnsureDifferentColors(bordercolor, aStyleColor->mBackgroundColor); - //outerrounded - aRenderingContext.SetColor(bordercolor); - aRenderingContext.DrawLine(t2p, 0, mRect.width, 0); - aRenderingContext.DrawLine(0, t2p, 0, mRect.height); - aRenderingContext.DrawLine(t2p, mRect.height, mRect.width, mRect.height); - aRenderingContext.DrawLine(mRect.width, t2p, mRect.width, mRect.height); - //middle - aRenderingContext.DrawRect(t2p, t2p, mRect.width-t2p, mRect.height-t2p); - //shading - aRenderingContext.DrawLine(2*t2p, mRect.height-2*t2p, mRect.width-t2p, mRect.height- (2*t2p)); - aRenderingContext.DrawLine(mRect.width - (2*t2p), 2*t2p, mRect.width - (2*t2p), mRect.height-t2p); - } + nsIFrameSelection *frameSelection = + aPresContext->PresShell()->FrameSelection(); + + PRBool tableCellSelectionMode; + nsresult result = + frameSelection->GetTableCellSelection(&tableCellSelectionMode); + if (NS_SUCCEEDED(result) && tableCellSelectionMode) { + nscolor bordercolor; + if (displaySelection == nsISelectionController::SELECTION_DISABLED) { + bordercolor = NS_RGB(176,176,176);// disabled color + } + else { + aPresContext->LookAndFeel()-> + GetColor(nsILookAndFeel::eColor_TextSelectBackground, + bordercolor); + } + PRInt16 t2p = (PRInt16) aPresContext->PixelsToTwips(); + if ((mRect.width >(3*t2p)) && (mRect.height > (3*t2p))) + { + //compare bordercolor to ((nsStyleColor *)myColor)->mBackgroundColor) + bordercolor = EnsureDifferentColors(bordercolor, aStyleColor->mBackgroundColor); + //outerrounded + aRenderingContext.SetColor(bordercolor); + aRenderingContext.DrawLine(t2p, 0, mRect.width, 0); + aRenderingContext.DrawLine(0, t2p, 0, mRect.height); + aRenderingContext.DrawLine(t2p, mRect.height, mRect.width, mRect.height); + aRenderingContext.DrawLine(mRect.width, t2p, mRect.width, mRect.height); + //middle + aRenderingContext.DrawRect(t2p, t2p, mRect.width-t2p, mRect.height-t2p); + //shading + aRenderingContext.DrawLine(2*t2p, mRect.height-2*t2p, mRect.width-t2p, mRect.height- (2*t2p)); + aRenderingContext.DrawLine(mRect.width - (2*t2p), 2*t2p, mRect.width - (2*t2p), mRect.height-t2p); } } } @@ -491,16 +490,11 @@ nsTableCellFrame::SetSelected(nsPresContext* aPresContext, // only this frame is considered nsFrame::SetSelected(aPresContext, aRange, aSelected, aSpread); - nsCOMPtr frameSelection; - nsresult result = aPresContext->PresShell()-> - GetFrameSelection(getter_AddRefs(frameSelection)); - if (NS_SUCCEEDED(result) && frameSelection) { - PRBool tableCellSelectionMode; - result = frameSelection->GetTableCellSelection(&tableCellSelectionMode); - if (NS_SUCCEEDED(result) && tableCellSelectionMode) { - // Selection can affect content, border and outline - Invalidate(GetOverflowRect(), PR_FALSE); - } + PRBool tableCellSelectionMode; + nsresult result = aPresContext->PresShell()->FrameSelection()->GetTableCellSelection(&tableCellSelectionMode); + if (NS_SUCCEEDED(result) && tableCellSelectionMode) { + // Selection can affect content, border and outline + Invalidate(GetOverflowRect(), PR_FALSE); } return NS_OK; } diff --git a/mozilla/layout/mathml/base/src/nsMathMLmoFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmoFrame.cpp index f05f32f89f8..b22cbc65685 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmoFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmoFrame.cpp @@ -134,11 +134,10 @@ nsMathMLmoFrame::IsFrameInSelection(nsPresContext* aPresContext, if (NS_SUCCEEDED(rv) && selCon) frameSelection = do_QueryInterface(selCon); if (!frameSelection) - rv = shell->GetFrameSelection(getter_AddRefs(frameSelection)); - if (NS_SUCCEEDED(rv) && frameSelection) { - frameSelection->LookUpSelection(aFrame->GetContent(), - 0, 1, &details, PR_TRUE); - } + frameSelection = shell->FrameSelection(); + + frameSelection->LookUpSelection(aFrame->GetContent(), + 0, 1, &details, PR_TRUE); } if (!details) return PR_FALSE; diff --git a/mozilla/layout/style/nsRuleNode.cpp b/mozilla/layout/style/nsRuleNode.cpp index 70b8ddb1114..a9f2a179470 100644 --- a/mozilla/layout/style/nsRuleNode.cpp +++ b/mozilla/layout/style/nsRuleNode.cpp @@ -2019,16 +2019,6 @@ nsRuleNode::ComputeFontData(nsStyleStruct* aStartStruct, // then we use the document fonts anyway useDocumentFonts = mPresContext->GetCachedBoolPref(kPresContext_UseDocumentFonts); - if (!useDocumentFonts) { - // check if the prefs have been disabled for this shell - // - if prefs are disabled then we use the document fonts anyway (yet another override) - PRBool prefsEnabled = PR_TRUE; - nsIPresShell *shell = mPresContext->GetPresShell(); - if (shell) - shell->ArePrefStyleRulesEnabled(prefsEnabled); - if (!prefsEnabled) - useDocumentFonts = PR_TRUE; - } } // See if we are in the chrome diff --git a/mozilla/layout/svg/base/src/nsSVGGlyphFrame.cpp b/mozilla/layout/svg/base/src/nsSVGGlyphFrame.cpp index d15fb9b0800..54cc6bad754 100644 --- a/mozilla/layout/svg/base/src/nsSVGGlyphFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGGlyphFrame.cpp @@ -766,7 +766,7 @@ nsSVGGlyphFrame::GetHighlight(PRUint32 *charnum, PRUint32 *nchars, nscolor *fore frameSelection = do_QueryInterface(controller); } if (!frameSelection) { - presContext->PresShell()->GetFrameSelection(getter_AddRefs(frameSelection)); + frameSelection = presContext->PresShell()->FrameSelection(); } if (!frameSelection) { NS_ERROR("no frameselection interface"); diff --git a/mozilla/layout/tables/nsTableCellFrame.cpp b/mozilla/layout/tables/nsTableCellFrame.cpp index e4c52e98709..ac7935562a4 100644 --- a/mozilla/layout/tables/nsTableCellFrame.cpp +++ b/mozilla/layout/tables/nsTableCellFrame.cpp @@ -305,39 +305,38 @@ nsTableCellFrame::DecorateForSelection(nsPresContext* aPresContext, PRBool isSelected = (GetStateBits() & NS_FRAME_SELECTED_CONTENT) == NS_FRAME_SELECTED_CONTENT; if (isSelected) { - nsCOMPtr frameSelection; - nsresult result = aPresContext->PresShell()-> - GetFrameSelection(getter_AddRefs(frameSelection)); - if (NS_SUCCEEDED(result)) { - PRBool tableCellSelectionMode; - result = frameSelection->GetTableCellSelection(&tableCellSelectionMode); - if (NS_SUCCEEDED(result) && tableCellSelectionMode) { - nscolor bordercolor; - if (displaySelection == nsISelectionController::SELECTION_DISABLED) { - bordercolor = NS_RGB(176,176,176);// disabled color - } - else { - aPresContext->LookAndFeel()-> - GetColor(nsILookAndFeel::eColor_TextSelectBackground, - bordercolor); - } - PRInt16 t2p = (PRInt16) aPresContext->PixelsToTwips(); - if ((mRect.width >(3*t2p)) && (mRect.height > (3*t2p))) - { - //compare bordercolor to ((nsStyleColor *)myColor)->mBackgroundColor) - bordercolor = EnsureDifferentColors(bordercolor, aStyleColor->mBackgroundColor); - //outerrounded - aRenderingContext.SetColor(bordercolor); - aRenderingContext.DrawLine(t2p, 0, mRect.width, 0); - aRenderingContext.DrawLine(0, t2p, 0, mRect.height); - aRenderingContext.DrawLine(t2p, mRect.height, mRect.width, mRect.height); - aRenderingContext.DrawLine(mRect.width, t2p, mRect.width, mRect.height); - //middle - aRenderingContext.DrawRect(t2p, t2p, mRect.width-t2p, mRect.height-t2p); - //shading - aRenderingContext.DrawLine(2*t2p, mRect.height-2*t2p, mRect.width-t2p, mRect.height- (2*t2p)); - aRenderingContext.DrawLine(mRect.width - (2*t2p), 2*t2p, mRect.width - (2*t2p), mRect.height-t2p); - } + nsIFrameSelection *frameSelection = + aPresContext->PresShell()->FrameSelection(); + + PRBool tableCellSelectionMode; + nsresult result = + frameSelection->GetTableCellSelection(&tableCellSelectionMode); + if (NS_SUCCEEDED(result) && tableCellSelectionMode) { + nscolor bordercolor; + if (displaySelection == nsISelectionController::SELECTION_DISABLED) { + bordercolor = NS_RGB(176,176,176);// disabled color + } + else { + aPresContext->LookAndFeel()-> + GetColor(nsILookAndFeel::eColor_TextSelectBackground, + bordercolor); + } + PRInt16 t2p = (PRInt16) aPresContext->PixelsToTwips(); + if ((mRect.width >(3*t2p)) && (mRect.height > (3*t2p))) + { + //compare bordercolor to ((nsStyleColor *)myColor)->mBackgroundColor) + bordercolor = EnsureDifferentColors(bordercolor, aStyleColor->mBackgroundColor); + //outerrounded + aRenderingContext.SetColor(bordercolor); + aRenderingContext.DrawLine(t2p, 0, mRect.width, 0); + aRenderingContext.DrawLine(0, t2p, 0, mRect.height); + aRenderingContext.DrawLine(t2p, mRect.height, mRect.width, mRect.height); + aRenderingContext.DrawLine(mRect.width, t2p, mRect.width, mRect.height); + //middle + aRenderingContext.DrawRect(t2p, t2p, mRect.width-t2p, mRect.height-t2p); + //shading + aRenderingContext.DrawLine(2*t2p, mRect.height-2*t2p, mRect.width-t2p, mRect.height- (2*t2p)); + aRenderingContext.DrawLine(mRect.width - (2*t2p), 2*t2p, mRect.width - (2*t2p), mRect.height-t2p); } } } @@ -491,16 +490,11 @@ nsTableCellFrame::SetSelected(nsPresContext* aPresContext, // only this frame is considered nsFrame::SetSelected(aPresContext, aRange, aSelected, aSpread); - nsCOMPtr frameSelection; - nsresult result = aPresContext->PresShell()-> - GetFrameSelection(getter_AddRefs(frameSelection)); - if (NS_SUCCEEDED(result) && frameSelection) { - PRBool tableCellSelectionMode; - result = frameSelection->GetTableCellSelection(&tableCellSelectionMode); - if (NS_SUCCEEDED(result) && tableCellSelectionMode) { - // Selection can affect content, border and outline - Invalidate(GetOverflowRect(), PR_FALSE); - } + PRBool tableCellSelectionMode; + nsresult result = aPresContext->PresShell()->FrameSelection()->GetTableCellSelection(&tableCellSelectionMode); + if (NS_SUCCEEDED(result) && tableCellSelectionMode) { + // Selection can affect content, border and outline + Invalidate(GetOverflowRect(), PR_FALSE); } return NS_OK; } diff --git a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp index 157abb3743e..37f4d1f019e 100644 --- a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp +++ b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp @@ -1154,8 +1154,7 @@ NS_IMETHODIMP nsBrowserWindow::ForceRefresh() { nsIPresShell* shell = GetPresShell(); if (nsnull != shell) { - nsCOMPtr vm; - shell->GetViewManager(getter_AddRefs(vm)); + nsIViewManager *vm = shell->GetViewManager(); if (vm) { nsIView* root; vm->GetRootView(root); @@ -2479,8 +2478,7 @@ DumpViewsRecurse(nsIDocShell* aDocShell, FILE* out) fprintf(out, "docshell=%p \n", aDocShell); nsIPresShell* shell = GetPresShellFor(aDocShell); if (nsnull != shell) { - nsCOMPtr vm; - shell->GetViewManager(getter_AddRefs(vm)); + nsIViewManager *vm = shell->GetViewManager(); if (vm) { nsIView* root; vm->GetRootView(root); diff --git a/mozilla/webshell/tests/viewer/nsXPBaseWindow.cpp b/mozilla/webshell/tests/viewer/nsXPBaseWindow.cpp index 55b39b0f850..a93419721c8 100644 --- a/mozilla/webshell/tests/viewer/nsXPBaseWindow.cpp +++ b/mozilla/webshell/tests/viewer/nsXPBaseWindow.cpp @@ -258,8 +258,7 @@ void nsXPBaseWindow::ForceRefresh() nsIPresShell* shell; GetPresShell(shell); if (nsnull != shell) { - nsCOMPtr vm; - shell->GetViewManager(getter_AddRefs(vm)); + nsIViewManager *vm = shell->GetViewManager(); if (vm) { nsIView* root; vm->GetRootView(root);