diff --git a/mozilla/content/base/public/nsIContentIterator.h b/mozilla/content/base/public/nsIContentIterator.h index 6573f1b7ae9..f2cb33cecf0 100644 --- a/mozilla/content/base/public/nsIContentIterator.h +++ b/mozilla/content/base/public/nsIContentIterator.h @@ -40,8 +40,6 @@ #include "nsISupports.h" - -class nsIFocusTracker; class nsIContent; class nsIDOMRange; diff --git a/mozilla/content/base/src/nsContentIterator.cpp b/mozilla/content/base/src/nsContentIterator.cpp index 0eecda7f732..c94625585bd 100644 --- a/mozilla/content/base/src/nsContentIterator.cpp +++ b/mozilla/content/base/src/nsContentIterator.cpp @@ -48,7 +48,6 @@ #include "nsIContent.h" #include "nsIDOMText.h" #include "nsISupportsArray.h" -#include "nsIFocusTracker.h" #include "nsCOMPtr.h" #include "nsPresContext.h" #include "nsIComponentManager.h" diff --git a/mozilla/content/base/src/nsGeneratedIterator.cpp b/mozilla/content/base/src/nsGeneratedIterator.cpp index 988bec81427..f8ffea91cdf 100644 --- a/mozilla/content/base/src/nsGeneratedIterator.cpp +++ b/mozilla/content/base/src/nsGeneratedIterator.cpp @@ -47,7 +47,6 @@ #include "nsIContent.h" #include "nsIDOMText.h" #include "nsISupportsArray.h" -#include "nsIFocusTracker.h" #include "nsCOMPtr.h" #include "nsPresContext.h" #include "nsIComponentManager.h" diff --git a/mozilla/content/base/src/nsSelection.cpp b/mozilla/content/base/src/nsSelection.cpp index 8e4000f684c..dc19a724165 100644 --- a/mozilla/content/base/src/nsSelection.cpp +++ b/mozilla/content/base/src/nsSelection.cpp @@ -50,7 +50,6 @@ #include "nsISelection.h" #include "nsISelectionPrivate.h" #include "nsISelectionListener.h" -#include "nsIFocusTracker.h" #include "nsIComponentManager.h" #include "nsContentCID.h" #include "nsIContent.h" @@ -105,7 +104,7 @@ static NS_DEFINE_CID(kFrameTraversalCID, NS_FRAMETRAVERSAL_CID); #include "nsISelectionController.h"//for the enums #include "nsHTMLAtoms.h" -#define STATUS_CHECK_RETURN_MACRO() {if (!mTracker) return NS_ERROR_FAILURE;} +#define STATUS_CHECK_RETURN_MACRO() {if (!mShell) return NS_ERROR_FAILURE;} @@ -310,7 +309,7 @@ public: NS_DECL_ISUPPORTS /*BEGIN nsIFrameSelection interfaces*/ - NS_IMETHOD Init(nsIFocusTracker *aTracker, nsIContent *aLimiter); + NS_IMETHOD Init(nsIPresShell *aShell, nsIContent *aLimiter); NS_IMETHOD SetScrollableView(nsIScrollableView *aScrollView); NS_IMETHOD GetScrollableView(nsIScrollableView **aScrollView) {*aScrollView = mScrollView; return NS_OK;} @@ -381,7 +380,7 @@ public: NS_IMETHOD EndBatchChanges(); NS_IMETHOD DeleteFromDocument(); - nsIFocusTracker *GetTracker(){return mTracker;} + nsIPresShell *GetShell() {return mShell;} private: NS_IMETHOD TakeFocus(nsIContent *aNewFocus, PRUint32 aContentOffset, PRUint32 aContentEndOffset, @@ -491,7 +490,7 @@ private: PRInt32 mBatching; nsIContent *mLimiter; //limit selection navigation to a child of this node. - nsIFocusTracker *mTracker; + nsIPresShell *mShell; PRInt16 mSelectionChangeReason; // reason for notifications of selection changing PRInt16 mDisplaySelection; //for visual display purposes. @@ -953,7 +952,7 @@ NS_IMPL_ISUPPORTS1(nsSelection, nsIFrameSelection) nsresult nsSelection::FetchDesiredX(nscoord &aDesiredX) //the x position requested by the Key Handling for up down { - if (!mTracker) + if (!mShell) { NS_ASSERTION(0,"fetch desired X failed\n"); return NS_ERROR_FAILURE; @@ -964,19 +963,8 @@ nsSelection::FetchDesiredX(nscoord &aDesiredX) //the x position requested by the return NS_OK; } - nsCOMPtr context; - nsresult result = mTracker->GetPresContext(getter_AddRefs(context)); - if (NS_FAILED(result)) - return result; - if (!context) - return NS_ERROR_NULL_POINTER; - - nsIPresShell *shell = context->GetPresShell(); - if (!shell) - return NS_ERROR_NULL_POINTER; - nsCOMPtr caret; - result = shell->GetCaret(getter_AddRefs(caret)); + nsresult result = mShell->GetCaret(getter_AddRefs(caret)); if (NS_FAILED(result)) return result; if (!caret) @@ -1196,7 +1184,7 @@ nsSelection::ConstrainFrameAndPointToAnchorSubtree(nsPresContext *aPresContext, // find the closest frame aPoint. // - result = mTracker->GetPrimaryFrameFor(anchorRoot, aRetFrame); + result = mShell->GetPrimaryFrameFor(anchorRoot, aRetFrame); if (NS_FAILED(result)) return result; @@ -1313,9 +1301,9 @@ GetCellParent(nsIDOMNode *aDomNode) NS_IMETHODIMP -nsSelection::Init(nsIFocusTracker *aTracker, nsIContent *aLimiter) +nsSelection::Init(nsIPresShell *aShell, nsIContent *aLimiter) { - mTracker = aTracker; + mShell = aShell; mMouseDownState = PR_FALSE; mDesiredXSet = PR_FALSE; mLimiter = aLimiter; @@ -1360,10 +1348,9 @@ nsSelection::HandleTextEvent(nsGUIEvent *aGUIEvent) nsresult nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aAmount) { - nsCOMPtr context; - nsresult result = mTracker->GetPresContext(getter_AddRefs(context)); - if (NS_FAILED(result) || !context) - return result?result:NS_ERROR_FAILURE; + nsPresContext *context = mShell->GetPresContext(); + if (!context) + return NS_OK; nsCOMPtr weakNodeUsed; PRInt32 offsetused = 0; @@ -1372,7 +1359,7 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA nscoord desiredX = 0; //we must keep this around and revalidate it when its just UP/DOWN PRInt8 index = GetIndexFromSelectionType(nsISelectionController::SELECTION_NORMAL); - result = mDomSelections[index]->GetIsCollapsed(&isCollapsed); + nsresult result = mDomSelections[index]->GetIsCollapsed(&isCollapsed); if (NS_FAILED(result)) return result; if (aKeycode == nsIDOMKeyEvent::DOM_VK_UP || aKeycode == nsIDOMKeyEvent::DOM_VK_DOWN) @@ -1422,10 +1409,7 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA } nsCOMPtr caret; - nsIPresShell *shell = context->GetPresShell(); - if (!shell) - return 0; - result = shell->GetCaret(getter_AddRefs(caret)); + result = mShell->GetCaret(getter_AddRefs(caret)); if (NS_FAILED(result) || !caret) return 0; @@ -1444,7 +1428,7 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA //set data using mLimiter to stop on scroll views. If we have a limiter then we stop peeking //when we hit scrollable views. If no limiter then just let it go ahead - pos.SetData(mTracker, desiredX, aAmount, eDirPrevious, offsetused, PR_FALSE, + pos.SetData(mShell, desiredX, aAmount, eDirPrevious, offsetused, PR_FALSE, PR_TRUE, PR_TRUE, mLimiter != nsnull, PR_TRUE); HINT tHint(mHint); //temporary variable so we dont set mHint until it is necessary @@ -1519,7 +1503,7 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA pos.mContentOffset = frameEnd; // set the cursor Bidi level to the paragraph embedding level - shell->SetCaretBidiLevel(NS_GET_BASE_LEVEL(theFrame)); + mShell->SetCaretBidiLevel(NS_GET_BASE_LEVEL(theFrame)); break; default: @@ -1528,10 +1512,10 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA || (eSelectDir == aAmount) || (eSelectLine == aAmount)) { - shell->SetCaretBidiLevel(NS_GET_EMBEDDING_LEVEL(theFrame)); + mShell->SetCaretBidiLevel(NS_GET_EMBEDDING_LEVEL(theFrame)); } else - BidiLevelFromMove(context, shell, pos.mResultContent, pos.mContentOffset, aKeycode); + BidiLevelFromMove(context, mShell, pos.mResultContent, pos.mContentOffset, aKeycode); } } #ifdef VISUALSELECTION @@ -2392,23 +2376,14 @@ void nsSelection::BidiLevelFromMove(nsPresContext* aContext, */ void nsSelection::BidiLevelFromClick(nsIContent *aNode, PRUint32 aContentOffset) { - nsCOMPtr context; - nsresult result = mTracker->GetPresContext(getter_AddRefs(context)); - if (NS_FAILED(result) || !context) - return; - - nsIPresShell *shell = context->GetPresShell(); - if (!shell) - return; - nsIFrame* clickInFrame=nsnull; PRInt32 OffsetNotUsed; - result = GetFrameForNodeOffset(aNode, aContentOffset, mHint, &clickInFrame, &OffsetNotUsed); + nsresult result = GetFrameForNodeOffset(aNode, aContentOffset, mHint, &clickInFrame, &OffsetNotUsed); if (NS_FAILED(result)) return; - shell->SetCaretBidiLevel(NS_GET_EMBEDDING_LEVEL(clickInFrame)); + mShell->SetCaretBidiLevel(NS_GET_EMBEDDING_LEVEL(clickInFrame)); } @@ -2548,7 +2523,7 @@ nsSelection::HandleDrag(nsPresContext *aPresContext, nsIFrame *aFrame, nsPoint& nsPeekOffsetStruct pos; //set data using mLimiter to stop on scroll views. If we have a limiter then we stop peeking //when we hit scrollable views. If no limiter then just let it go ahead - pos.SetData(mTracker, 0, eSelectDir, eDirNext, startPos, PR_FALSE, + pos.SetData(mShell, 0, eSelectDir, eDirNext, startPos, PR_FALSE, PR_TRUE, PR_TRUE, mLimiter != nsnull, PR_FALSE); mHint = HINT(beginOfContent); HINT saveHint = mHint; @@ -2647,17 +2622,8 @@ nsSelection::TakeFocus(nsIContent *aNewFocus, PRUint32 aContentOffset, //if we are no longer inside same table ,cell then switch to table selection mode. // BUT only do this in an editor - nsCOMPtr presContext; - nsresult result = mTracker->GetPresContext(getter_AddRefs(presContext)); - if (NS_FAILED(result) || !presContext) - return result?result:NS_ERROR_FAILURE; - - nsIPresShell *presShell = presContext->GetPresShell(); - if (!presShell) - return NS_ERROR_FAILURE; - PRInt16 displaySelection; - result = presShell->GetSelectionFlags(&displaySelection); + nsresult result = mShell->GetSelectionFlags(&displaySelection); if (NS_FAILED(result)) return result; @@ -2913,7 +2879,7 @@ nsSelection::GetFrameForNodeOffset(nsIContent *aNode, PRInt32 aOffset, HINT aHin } } - result = mTracker->GetPrimaryFrameFor(theNode, aReturnFrame); + result = mShell->GetPrimaryFrameFor(theNode, aReturnFrame); if (NS_FAILED(result)) return result; @@ -2960,20 +2926,6 @@ nsSelection::CommonPageMove(PRBool aForward, return result; nsRect viewRect = clipView->GetBounds(); - nsCOMPtr context; - result = mTracker->GetPresContext(getter_AddRefs(context)); - - if (NS_FAILED(result)) - return result; - - if (!context) - return NS_ERROR_NULL_POINTER; - - nsIPresShell *shell = context->GetPresShell(); - - if (!shell) - return NS_ERROR_NULL_POINTER; - // find out where the caret is. // we should know mDesiredX value of nsSelection, but I havent seen that behavior in other windows applications yet. nsCOMPtr domSel; @@ -2985,7 +2937,7 @@ nsSelection::CommonPageMove(PRBool aForward, nsCOMPtr caret; nsRect caretPos; PRBool isCollapsed; - result = shell->GetCaret(getter_AddRefs(caret)); + result = mShell->GetCaret(getter_AddRefs(caret)); if (NS_FAILED(result)) return result; @@ -3023,6 +2975,7 @@ nsSelection::CommonPageMove(PRBool aForward, nsPoint desiredPoint; desiredPoint.x = caretPos.x; desiredPoint.y = caretPos.y + caretPos.height/2; + nsPresContext *context = mShell->GetPresContext(); result = mainframe->GetContentAndOffsetsFromPoint(context, desiredPoint, getter_AddRefs(content), startOffset, endOffset, beginFrameContent); if (NS_FAILED(result)) @@ -3086,13 +3039,7 @@ NS_IMETHODIMP nsSelection::SelectAll() } else { - nsresult rv; - nsCOMPtr shell(do_QueryInterface(mTracker,&rv)); - if (NS_FAILED(rv) || !shell) { - return NS_ERROR_FAILURE; - } - - nsIDocument *doc = shell->GetDocument(); + nsIDocument *doc = mShell->GetDocument(); if (!doc) return NS_ERROR_FAILURE; rootContent = doc->GetRootContent(); @@ -3174,7 +3121,7 @@ nsSelection::GetCellLayout(nsIContent *aCellContent) { // Get frame for cell nsIFrame *cellFrame = nsnull; - GetTracker()->GetPrimaryFrameFor(aCellContent, &cellFrame); + mShell->GetPrimaryFrameFor(aCellContent, &cellFrame); if (!cellFrame) return nsnull; @@ -3189,7 +3136,7 @@ nsSelection::GetTableLayout(nsIContent *aTableContent) { // Get frame for table nsIFrame *tableFrame = nsnull; - GetTracker()->GetPrimaryFrameFor(aTableContent, &tableFrame); + mShell->GetPrimaryFrameFor(aTableContent, &tableFrame); if (!tableFrame) return nsnull; @@ -3348,7 +3295,7 @@ printf("HandleTableSelection: Mouse down event\n"); // Check if new cell is already selected nsIFrame *cellFrame = nsnull; - result = GetTracker()->GetPrimaryFrameFor(childContent, &cellFrame); + result = mShell->GetPrimaryFrameFor(childContent, &cellFrame); if (NS_FAILED(result)) return result; if (!cellFrame) return NS_ERROR_NULL_POINTER; result = cellFrame->GetSelected(&isSelected); @@ -4778,7 +4725,7 @@ nsTypedSelection::GetPrimaryFrameForRangeEndpoint(nsIDOMNode *aNode, PRInt32 aOf content = child; // releases the focusnode } } - result = mFrameSelection->GetTracker()->GetPrimaryFrameFor(content,aReturnFrame); + result = mFrameSelection->GetShell()->GetPrimaryFrameFor(content,aReturnFrame); return result; } #endif @@ -4853,7 +4800,7 @@ nsTypedSelection::selectFrames(nsPresContext* aPresContext, if (NS_SUCCEEDED(result)) { // First select frame of content passed in - result = mFrameSelection->GetTracker()->GetPrimaryFrameFor(aContent, &frame); + result = mFrameSelection->GetShell()->GetPrimaryFrameFor(aContent, &frame); if (NS_SUCCEEDED(result) && frame) { //NOTE: eSpreadDown is now IGNORED. Selected state is set only for given frame @@ -4877,7 +4824,7 @@ nsTypedSelection::selectFrames(nsPresContext* aPresContext, { nsIContent *innercontent = aInnerIter->GetCurrentNode(); - result = mFrameSelection->GetTracker()->GetPrimaryFrameFor(innercontent, &frame); + result = mFrameSelection->GetShell()->GetPrimaryFrameFor(innercontent, &frame); if (NS_SUCCEEDED(result) && frame) { //NOTE: eSpreadDown is now IGNORED. Selected state is set only @@ -4908,7 +4855,7 @@ nsTypedSelection::selectFrames(nsPresContext* aPresContext, } #if 0 - result = mFrameSelection->GetTracker()->GetPrimaryFrameFor(content, &frame); + result = mFrameSelection->GetShell()->GetPrimaryFrameFor(content, &frame); if (NS_SUCCEEDED(result) && frame) frame->SetSelected(aRange,aFlags,eSpreadDown);//spread from here to hit all frames in flow #endif @@ -4973,7 +4920,7 @@ nsTypedSelection::selectFrames(nsPresContext* aPresContext, nsIDOMRange *aRange, if (!content->IsContentOfType(nsIContent::eELEMENT)) { - result = mFrameSelection->GetTracker()->GetPrimaryFrameFor(content, &frame); + result = mFrameSelection->GetShell()->GetPrimaryFrameFor(content, &frame); if (NS_SUCCEEDED(result) && frame) frame->SetSelected(aPresContext, aRange,aFlags,eSpreadDown);//spread from here to hit all frames in flow } @@ -4997,7 +4944,7 @@ nsTypedSelection::selectFrames(nsPresContext* aPresContext, nsIDOMRange *aRange, if (!content->IsContentOfType(nsIContent::eELEMENT)) { - result = mFrameSelection->GetTracker()->GetPrimaryFrameFor(content, &frame); + result = mFrameSelection->GetShell()->GetPrimaryFrameFor(content, &frame); if (NS_SUCCEEDED(result) && frame) frame->SetSelected(aPresContext, aRange,aFlags,eSpreadDown);//spread from here to hit all frames in flow } @@ -6678,12 +6625,13 @@ nsTypedSelection::GetPresContext(nsPresContext **aPresContext) { if (!mFrameSelection) return NS_ERROR_FAILURE;//nothing to do - nsIFocusTracker *tracker = mFrameSelection->GetTracker(); + nsIPresShell *shell = mFrameSelection->GetShell(); - if (!tracker) + if (!shell) return NS_ERROR_NULL_POINTER; - return tracker->GetPresContext(aPresContext); + NS_IF_ADDREF(*aPresContext = shell->GetPresContext()); + return NS_OK; } nsresult @@ -6700,22 +6648,8 @@ nsTypedSelection::GetPresShell(nsIPresShell **aPresShell) if (!mFrameSelection) return NS_ERROR_FAILURE;//nothing to do - nsIFocusTracker *tracker = mFrameSelection->GetTracker(); + nsIPresShell *shell = mFrameSelection->GetShell(); - if (!tracker) - return NS_ERROR_NULL_POINTER; - - nsCOMPtr presContext; - - rv = tracker->GetPresContext(getter_AddRefs(presContext)); - - if (NS_FAILED(rv)) - return rv; - - if (!presContext) - return NS_ERROR_NULL_POINTER; - - nsIPresShell *shell = presContext->GetPresShell(); mPresShellWeak = do_GetWeakReference(shell); // the presshell owns us, so no addref if (mPresShellWeak) NS_ADDREF(*aPresShell = shell); @@ -6792,13 +6726,12 @@ nsTypedSelection::GetFrameToScrolledViewOffsets(nsIScrollableView *aScrollableVi // Determine the offset from aFrame to the scrolled view. We do that by // getting the offset from its closest view and then walking up aScrollableView->GetScrolledView(scrolledView); - nsIFocusTracker *tracker = mFrameSelection->GetTracker(); + nsIPresShell *shell = mFrameSelection->GetShell(); - if (!tracker) + if (!shell) return NS_ERROR_NULL_POINTER; - nsCOMPtr presContext; - tracker->GetPresContext(getter_AddRefs(presContext)); + nsPresContext *presContext = shell->GetPresContext(); aFrame->GetOffsetFromView(presContext, offset, &closestView); // XXX Deal with the case where there is a scrolled element, e.g., a @@ -6834,18 +6767,11 @@ nsTypedSelection::GetPointFromOffset(nsIFrame *aFrame, PRInt32 aContentOffset, n // a rendering context. // - nsIFocusTracker *tracker = mFrameSelection->GetTracker(); - - if (!tracker) + nsIPresShell *shell = mFrameSelection->GetShell(); + if (!shell) return NS_ERROR_NULL_POINTER; - nsCOMPtr presContext; - - rv = tracker->GetPresContext(getter_AddRefs(presContext)); - - if (NS_FAILED(rv)) - return rv; - + nsPresContext *presContext = shell->GetPresContext(); if (!presContext) return NS_ERROR_NULL_POINTER; diff --git a/mozilla/layout/base/nsIFrameSelection.h b/mozilla/layout/base/nsIFrameSelection.h index ae92d4e7978..0dd97588007 100644 --- a/mozilla/layout/base/nsIFrameSelection.h +++ b/mozilla/layout/base/nsIFrameSelection.h @@ -47,17 +47,17 @@ #include "nsISupports.h" #include "nsIFrame.h" -#include "nsIFocusTracker.h" #include "nsISelection.h" #include "nsIContent.h" #include "nsCOMPtr.h" #include "nsISelectionController.h" +class nsIPresShell; // IID for the nsIFrameSelection interface #define NS_IFRAMESELECTION_IID \ -{ 0xf46e4171, 0xdeaa, 0x11d1, \ - { 0x97, 0xfc, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } } +{ 0x18477ed4, 0x01ff, 0x4319, \ + { 0x95, 0xc0, 0x63, 0x9e, 0xe4, 0x33, 0xbe, 0x92 } } //---------------------------------------------------------------------- @@ -73,7 +73,7 @@ struct SelectionDetails }; /*PeekOffsetStruct - * @param mTracker is used to get the PresContext usefull for measuring text ect. + * @param mShell is used to get the PresContext usefull for measuring text ect. * @param mDesiredX is the "desired" location of the new caret * @param mAmount eWord, eCharacter, eLine * @param mDirection enum defined in this file to be eForward or eBackward @@ -88,7 +88,7 @@ struct SelectionDetails */ struct nsPeekOffsetStruct { - void SetData(nsIFocusTracker *aTracker, + void SetData(nsIPresShell *aShell, nscoord aDesiredX, nsSelectionAmount aAmount, nsDirection aDirection, @@ -99,7 +99,7 @@ struct nsPeekOffsetStruct PRBool aScrollViewStop, PRBool aIsKeyboardSelect) { - mTracker=aTracker; + mShell=aShell; mDesiredX=aDesiredX; mAmount=aAmount; mDirection=aDirection; @@ -110,7 +110,7 @@ struct nsPeekOffsetStruct mScrollViewStop = aScrollViewStop; mIsKeyboardSelect = aIsKeyboardSelect; } - nsIFocusTracker *mTracker; + nsIPresShell *mShell; nscoord mDesiredX; nsSelectionAmount mAmount; nsDirection mDirection; @@ -134,12 +134,12 @@ public: NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFRAMESELECTION_IID) enum HINT { HINTLEFT = 0, HINTRIGHT = 1}; //end of this line or beginning of next - /** Init will initialize the frame selector with the necessary focus tracker to + /** Init will initialize the frame selector with the necessary pres shell to * be used by most of the methods - * @param aTracker is the parameter to be used for most of the other calls for callbacks ect + * @param aShell is the parameter to be used for most of the other calls for callbacks ect * @param aLimiter limits the selection to nodes with aLimiter parents */ - NS_IMETHOD Init(nsIFocusTracker *aTracker, nsIContent *aLimiter) = 0; //default since this isnt used for embedding + NS_IMETHOD Init(nsIPresShell *aShell, nsIContent *aLimiter) = 0; //default since this isnt used for embedding /* SetScrollableView sets the scroll view * @param aScrollView is the scroll view for this selection. diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index c243e21331b..333000fdc45 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -1056,7 +1056,7 @@ ReflowCommandHashMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *entry, // ---------------------------------------------------------------------------- class PresShell : public nsIPresShell, public nsIViewObserver, - public nsStubDocumentObserver, public nsIFocusTracker, + public nsStubDocumentObserver, public nsISelectionController, public nsIObserver, public nsSupportsWeakReference { @@ -1084,7 +1084,6 @@ public: NS_IMETHOD PopStackMemory(); NS_IMETHOD AllocateStackMemory(size_t aSize, void** aResult); - NS_IMETHOD GetPresContext(nsPresContext** aResult); NS_IMETHOD GetActiveAlternateStyleSheet(nsString& aSheetTitle); NS_IMETHOD SelectAlternateStyleSheet(const nsString& aSheetTitle); NS_IMETHOD ListAlternateStyleSheets(nsStringArray& aTitleList); @@ -1620,8 +1619,8 @@ PresShell::PresShell() new (this) nsFrameManager(); } -NS_IMPL_ISUPPORTS8(PresShell, nsIPresShell, nsIDocumentObserver, - nsIViewObserver, nsIFocusTracker, nsISelectionController, +NS_IMPL_ISUPPORTS7(PresShell, nsIPresShell, nsIDocumentObserver, + nsIViewObserver, nsISelectionController, nsISelectionDisplay, nsIObserver, nsISupportsWeakReference) PresShell::~PresShell() @@ -1744,7 +1743,7 @@ PresShell::Init(nsIDocument* aDocument, return result; } - result = mSelection->Init((nsIFocusTracker *) this, nsnull); + result = mSelection->Init(this, nsnull); if (NS_FAILED(result)) { mStyleSet = nsnull; return result; @@ -2004,18 +2003,6 @@ PresShell::AllocateFrame(size_t aSize) return mFrameArena.AllocateFrame(aSize); } -NS_IMETHODIMP -PresShell::GetPresContext(nsPresContext** aResult) -{ - NS_PRECONDITION(nsnull != aResult, "null ptr"); - if (nsnull == aResult) { - return NS_ERROR_NULL_POINTER; - } - *aResult = mPresContext; - NS_IF_ADDREF(*aResult); - return NS_OK; -} - NS_IMETHODIMP PresShell::GetActiveAlternateStyleSheet(nsString& aSheetTitle) { // first non-html sheet in style set that has title @@ -3252,7 +3239,7 @@ PresShell::CompleteMove(PRBool aForward, PRBool aExtend) PRInt8 outsideLimit = -1;//search from beginning nsPeekOffsetStruct pos; pos.mAmount = eSelectLine; - pos.mTracker = this; + pos.mShell = this; pos.mContentOffset = 0; pos.mContentOffsetEnd = 0; pos.mScrollViewStop = PR_FALSE;//dont stop on scrolled views. diff --git a/mozilla/layout/base/public/Makefile.in b/mozilla/layout/base/public/Makefile.in index 32435dbf647..67e73bdc761 100644 --- a/mozilla/layout/base/public/Makefile.in +++ b/mozilla/layout/base/public/Makefile.in @@ -57,7 +57,6 @@ nsHTMLReflowState.h \ nsIAutoCopy.h \ nsICanvasFrame.h \ nsICaret.h \ -nsIFocusTracker.h \ nsIFrame.h \ nsIFrameDebug.h \ nsIFrameSelection.h \ diff --git a/mozilla/layout/base/public/nsIFocusTracker.h b/mozilla/layout/base/public/nsIFocusTracker.h deleted file mode 100644 index cdb6e540497..00000000000 --- a/mozilla/layout/base/public/nsIFocusTracker.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsIFocusTracker_h___ -#define nsIFocusTracker_h___ - -#include "nsISupports.h" -#include "nsIFrame.h" - - -class nsPresContext; - - -// IID for the nsIFocusTracker interface -#define NS_IFOCUSTRACKER_IID \ -{ 0x81ac51d1, 0x923b, 0x11d2, \ - { 0x91, 0x8f, 0x0, 0x80, 0xc8, 0xe4, 0x4d, 0xb5 } } - -class nsIFocusTracker : public nsISupports -{ -public: - NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFOCUSTRACKER_IID) - - /** - * Returns the primary frame associated with the content object. - * - * The primary frame is the frame that is most closely associated with the - * content. A frame is more closely associated with the content that another - * frame if the one frame contains directly or indirectly the other frame (e.g., - * when a frame is scrolled there is a scroll frame that contains the frame - * being scrolled). The primary frame is always the first-in-flow. - * - * In the case of absolutely positioned elements and floated elements, - * the primary frame is the frame that is out of the flow and not the - * placeholder frame. - */ - NS_IMETHOD GetPrimaryFrameFor(nsIContent* aContent, - nsIFrame** aPrimaryFrame) const = 0; - - /** - * GetPresContent will return the nsPresContext Interface from this - * FocusTracker - * usefull for getting screen coordinates of current selection - */ - NS_IMETHOD GetPresContext(nsPresContext **aContext) = 0; -}; - - -#endif //nsIFocusTracker_h___ diff --git a/mozilla/layout/base/public/nsIFrameSelection.h b/mozilla/layout/base/public/nsIFrameSelection.h index ae92d4e7978..0dd97588007 100644 --- a/mozilla/layout/base/public/nsIFrameSelection.h +++ b/mozilla/layout/base/public/nsIFrameSelection.h @@ -47,17 +47,17 @@ #include "nsISupports.h" #include "nsIFrame.h" -#include "nsIFocusTracker.h" #include "nsISelection.h" #include "nsIContent.h" #include "nsCOMPtr.h" #include "nsISelectionController.h" +class nsIPresShell; // IID for the nsIFrameSelection interface #define NS_IFRAMESELECTION_IID \ -{ 0xf46e4171, 0xdeaa, 0x11d1, \ - { 0x97, 0xfc, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } } +{ 0x18477ed4, 0x01ff, 0x4319, \ + { 0x95, 0xc0, 0x63, 0x9e, 0xe4, 0x33, 0xbe, 0x92 } } //---------------------------------------------------------------------- @@ -73,7 +73,7 @@ struct SelectionDetails }; /*PeekOffsetStruct - * @param mTracker is used to get the PresContext usefull for measuring text ect. + * @param mShell is used to get the PresContext usefull for measuring text ect. * @param mDesiredX is the "desired" location of the new caret * @param mAmount eWord, eCharacter, eLine * @param mDirection enum defined in this file to be eForward or eBackward @@ -88,7 +88,7 @@ struct SelectionDetails */ struct nsPeekOffsetStruct { - void SetData(nsIFocusTracker *aTracker, + void SetData(nsIPresShell *aShell, nscoord aDesiredX, nsSelectionAmount aAmount, nsDirection aDirection, @@ -99,7 +99,7 @@ struct nsPeekOffsetStruct PRBool aScrollViewStop, PRBool aIsKeyboardSelect) { - mTracker=aTracker; + mShell=aShell; mDesiredX=aDesiredX; mAmount=aAmount; mDirection=aDirection; @@ -110,7 +110,7 @@ struct nsPeekOffsetStruct mScrollViewStop = aScrollViewStop; mIsKeyboardSelect = aIsKeyboardSelect; } - nsIFocusTracker *mTracker; + nsIPresShell *mShell; nscoord mDesiredX; nsSelectionAmount mAmount; nsDirection mDirection; @@ -134,12 +134,12 @@ public: NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFRAMESELECTION_IID) enum HINT { HINTLEFT = 0, HINTRIGHT = 1}; //end of this line or beginning of next - /** Init will initialize the frame selector with the necessary focus tracker to + /** Init will initialize the frame selector with the necessary pres shell to * be used by most of the methods - * @param aTracker is the parameter to be used for most of the other calls for callbacks ect + * @param aShell is the parameter to be used for most of the other calls for callbacks ect * @param aLimiter limits the selection to nodes with aLimiter parents */ - NS_IMETHOD Init(nsIFocusTracker *aTracker, nsIContent *aLimiter) = 0; //default since this isnt used for embedding + NS_IMETHOD Init(nsIPresShell *aShell, nsIContent *aLimiter) = 0; //default since this isnt used for embedding /* SetScrollableView sets the scroll view * @param aScrollView is the scroll view for this selection. diff --git a/mozilla/layout/forms/nsTextControlFrame.cpp b/mozilla/layout/forms/nsTextControlFrame.cpp index 89c062f027a..602a168a2be 100644 --- a/mozilla/layout/forms/nsTextControlFrame.cpp +++ b/mozilla/layout/forms/nsTextControlFrame.cpp @@ -415,7 +415,7 @@ public: NS_IMETHOD CheckVisibility(nsIDOMNode *node, PRInt16 startOffset, PRInt16 EndOffset, PRBool *_retval); // NSIFRAMESELECTION INTERFACES - NS_IMETHOD Init(nsIFocusTracker *aTracker, nsIContent *aLimiter) ; + NS_IMETHOD Init(nsIPresShell *aShell, nsIContent *aLimiter) ; NS_IMETHOD ShutDown() ; NS_IMETHOD HandleTextEvent(nsGUIEvent *aGuiEvent) ; NS_IMETHOD HandleKeyEvent(nsPresContext* aPresContext, nsGUIEvent *aGuiEvent); @@ -485,9 +485,8 @@ nsTextInputSelectionImpl::nsTextInputSelectionImpl(nsIFrameSelection *aSel, nsIP if (aSel && aShell) { mFrameSelection = aSel;//we are the owner now! - nsCOMPtr tracker = do_QueryInterface(aShell); mLimiter = aLimiter; - mFrameSelection->Init(tracker, mLimiter); + mFrameSelection->Init(aShell, mLimiter); mPresShellWeak = do_GetWeakReference(aShell); #ifdef IBMBIDI mBidiKeyboard = do_GetService("@mozilla.org/widget/bidikeyboard;1"); @@ -850,9 +849,9 @@ nsTextInputSelectionImpl::CheckVisibility(nsIDOMNode *node, PRInt16 startOffset, //nsTextInputSelectionImpl::FRAMESELECTIONAPIS NS_IMETHODIMP -nsTextInputSelectionImpl::Init(nsIFocusTracker *aTracker, nsIContent *aLimiter) +nsTextInputSelectionImpl::Init(nsIPresShell *aShell, nsIContent *aLimiter) { - return mFrameSelection->Init(aTracker, aLimiter); + return mFrameSelection->Init(aShell, aLimiter); } diff --git a/mozilla/layout/generic/nsBlockFrame.cpp b/mozilla/layout/generic/nsBlockFrame.cpp index 218a5ed4748..126be9814b4 100644 --- a/mozilla/layout/generic/nsBlockFrame.cpp +++ b/mozilla/layout/generic/nsBlockFrame.cpp @@ -66,7 +66,6 @@ #include "nsLayoutAtoms.h" #include "nsITextContent.h" #include "nsStyleChangeList.h" -#include "nsIFocusTracker.h" #include "nsIFrameSelection.h" #include "nsSpaceManager.h" #include "nsIntervalSet.h" @@ -5673,8 +5672,6 @@ nsBlockFrame::HandleEvent(nsPresContext* aPresContext, shell = aPresContext->GetPresShell(); if (!shell) return NS_OK; - nsCOMPtr tracker( do_QueryInterface(shell, &result) ); - nsCOMPtr it( do_QueryInterface(mainframe, &result) ); nsIView* parentWithView; nsPoint origin; @@ -5694,7 +5691,7 @@ nsBlockFrame::HandleEvent(nsPresContext* aPresContext, //we will now ask where to go. if we cant find what we want"aka another block frame" //we drill down again - pos.mTracker = tracker; + pos.mShell = shell; pos.mDirection = eDirNext; pos.mDesiredX = aEvent->point.x; pos.mScrollViewStop = PR_FALSE; diff --git a/mozilla/layout/generic/nsFrame.cpp b/mozilla/layout/generic/nsFrame.cpp index 7562603ebe4..534e847cb78 100644 --- a/mozilla/layout/generic/nsFrame.cpp +++ b/mozilla/layout/generic/nsFrame.cpp @@ -1604,18 +1604,13 @@ nsFrame::PeekBackwardAndForward(nsSelectionAmount aAmountBack, if (!shell || !selcon) return NS_ERROR_NOT_INITIALIZED; - nsCOMPtr tracker; - tracker = do_QueryInterface(shell, &rv); - if (NS_FAILED(rv) || !tracker) - return rv; - // Use peek offset one way then the other: nsCOMPtr startContent; nsCOMPtr startNode; nsCOMPtr endContent; nsCOMPtr endNode; nsPeekOffsetStruct startpos; - startpos.SetData(tracker, + startpos.SetData(shell, 0, aAmountBack, eDirPrevious, @@ -1629,7 +1624,7 @@ nsFrame::PeekBackwardAndForward(nsSelectionAmount aAmountBack, if (NS_FAILED(rv)) return rv; nsPeekOffsetStruct endpos; - endpos.SetData(tracker, + endpos.SetData(shell, 0, aAmountForward, eDirNext, @@ -3178,10 +3173,7 @@ nsFrame::GetNextPrevLineFromeBlockFrame(nsPresContext* aPresContext, nsISupports *isupports = nsnull; nsIFrame *storeOldResultFrame = resultFrame; while ( !found ){ - nsCOMPtr context; - result = aPos->mTracker->GetPresContext(getter_AddRefs(context)); - if (NS_FAILED(result)) - return result; + nsPresContext *context = aPos->mShell->GetPresContext(); nsPoint point; point.x = aPos->mDesiredX; @@ -3270,8 +3262,7 @@ nsFrame::GetNextPrevLineFromeBlockFrame(nsPresContext* aPresContext, aPresContext, resultFrame, aPos->mScrollViewStop); } while ( !found ){ - nsCOMPtr context; - result = aPos->mTracker->GetPresContext(getter_AddRefs(context)); + nsPresContext *context = aPos->mShell->GetPresContext(); nsPoint point; point.x = aPos->mDesiredX; @@ -3527,9 +3518,7 @@ DrillDownToEndOfLine(nsIFrame* aFrame, PRInt32 aLineNo, PRInt32 aLineFrameCount, // This doesn't seem very efficient since GetPosition // has to do a binary search. - nsCOMPtr context; - rv = aPos->mTracker->GetPresContext(getter_AddRefs(context)); - if (NS_FAILED(rv)) return rv; + nsPresContext *context = aPos->mShell->GetPresContext(); PRInt32 endoffset; rv = nextFrame->GetContentAndOffsetsFromPoint(context, offsetPoint, @@ -3554,7 +3543,7 @@ DrillDownToEndOfLine(nsIFrame* aFrame, PRInt32 aLineNo, PRInt32 aLineFrameCount, NS_IMETHODIMP nsFrame::PeekOffset(nsPresContext* aPresContext, nsPeekOffsetStruct *aPos) { - if (!aPos || !aPos->mTracker ) + if (!aPos || !aPos->mShell) return NS_ERROR_NULL_POINTER; nsresult result = NS_ERROR_FAILURE; PRInt32 endoffset; @@ -3604,10 +3593,9 @@ nsFrame::PeekOffset(nsPresContext* aPresContext, nsPeekOffsetStruct *aPos) }//drop into no amount case eSelectNoAmount: { - nsCOMPtr context; - result = aPos->mTracker->GetPresContext(getter_AddRefs(context)); - if (NS_FAILED(result) || !context) - return result; + nsPresContext *context = aPos->mShell->GetPresContext(); + if (!context) + return NS_OK; result = GetContentAndOffsetsFromPoint(context,point, getter_AddRefs(aPos->mResultContent), aPos->mContentOffset, @@ -3783,10 +3771,9 @@ nsFrame::PeekOffset(nsPresContext* aPresContext, nsPeekOffsetStruct *aPos) if (eSelectBeginLine == aPos->mAmount) { - nsCOMPtr context; - result = aPos->mTracker->GetPresContext(getter_AddRefs(context)); - if (NS_FAILED(result) || !context) - return result; + nsPresContext *context = aPos->mShell->GetPresContext(); + if (!context) + return NS_OK; while (firstFrame) { diff --git a/mozilla/layout/generic/nsSelection.cpp b/mozilla/layout/generic/nsSelection.cpp index 8e4000f684c..dc19a724165 100644 --- a/mozilla/layout/generic/nsSelection.cpp +++ b/mozilla/layout/generic/nsSelection.cpp @@ -50,7 +50,6 @@ #include "nsISelection.h" #include "nsISelectionPrivate.h" #include "nsISelectionListener.h" -#include "nsIFocusTracker.h" #include "nsIComponentManager.h" #include "nsContentCID.h" #include "nsIContent.h" @@ -105,7 +104,7 @@ static NS_DEFINE_CID(kFrameTraversalCID, NS_FRAMETRAVERSAL_CID); #include "nsISelectionController.h"//for the enums #include "nsHTMLAtoms.h" -#define STATUS_CHECK_RETURN_MACRO() {if (!mTracker) return NS_ERROR_FAILURE;} +#define STATUS_CHECK_RETURN_MACRO() {if (!mShell) return NS_ERROR_FAILURE;} @@ -310,7 +309,7 @@ public: NS_DECL_ISUPPORTS /*BEGIN nsIFrameSelection interfaces*/ - NS_IMETHOD Init(nsIFocusTracker *aTracker, nsIContent *aLimiter); + NS_IMETHOD Init(nsIPresShell *aShell, nsIContent *aLimiter); NS_IMETHOD SetScrollableView(nsIScrollableView *aScrollView); NS_IMETHOD GetScrollableView(nsIScrollableView **aScrollView) {*aScrollView = mScrollView; return NS_OK;} @@ -381,7 +380,7 @@ public: NS_IMETHOD EndBatchChanges(); NS_IMETHOD DeleteFromDocument(); - nsIFocusTracker *GetTracker(){return mTracker;} + nsIPresShell *GetShell() {return mShell;} private: NS_IMETHOD TakeFocus(nsIContent *aNewFocus, PRUint32 aContentOffset, PRUint32 aContentEndOffset, @@ -491,7 +490,7 @@ private: PRInt32 mBatching; nsIContent *mLimiter; //limit selection navigation to a child of this node. - nsIFocusTracker *mTracker; + nsIPresShell *mShell; PRInt16 mSelectionChangeReason; // reason for notifications of selection changing PRInt16 mDisplaySelection; //for visual display purposes. @@ -953,7 +952,7 @@ NS_IMPL_ISUPPORTS1(nsSelection, nsIFrameSelection) nsresult nsSelection::FetchDesiredX(nscoord &aDesiredX) //the x position requested by the Key Handling for up down { - if (!mTracker) + if (!mShell) { NS_ASSERTION(0,"fetch desired X failed\n"); return NS_ERROR_FAILURE; @@ -964,19 +963,8 @@ nsSelection::FetchDesiredX(nscoord &aDesiredX) //the x position requested by the return NS_OK; } - nsCOMPtr context; - nsresult result = mTracker->GetPresContext(getter_AddRefs(context)); - if (NS_FAILED(result)) - return result; - if (!context) - return NS_ERROR_NULL_POINTER; - - nsIPresShell *shell = context->GetPresShell(); - if (!shell) - return NS_ERROR_NULL_POINTER; - nsCOMPtr caret; - result = shell->GetCaret(getter_AddRefs(caret)); + nsresult result = mShell->GetCaret(getter_AddRefs(caret)); if (NS_FAILED(result)) return result; if (!caret) @@ -1196,7 +1184,7 @@ nsSelection::ConstrainFrameAndPointToAnchorSubtree(nsPresContext *aPresContext, // find the closest frame aPoint. // - result = mTracker->GetPrimaryFrameFor(anchorRoot, aRetFrame); + result = mShell->GetPrimaryFrameFor(anchorRoot, aRetFrame); if (NS_FAILED(result)) return result; @@ -1313,9 +1301,9 @@ GetCellParent(nsIDOMNode *aDomNode) NS_IMETHODIMP -nsSelection::Init(nsIFocusTracker *aTracker, nsIContent *aLimiter) +nsSelection::Init(nsIPresShell *aShell, nsIContent *aLimiter) { - mTracker = aTracker; + mShell = aShell; mMouseDownState = PR_FALSE; mDesiredXSet = PR_FALSE; mLimiter = aLimiter; @@ -1360,10 +1348,9 @@ nsSelection::HandleTextEvent(nsGUIEvent *aGUIEvent) nsresult nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aAmount) { - nsCOMPtr context; - nsresult result = mTracker->GetPresContext(getter_AddRefs(context)); - if (NS_FAILED(result) || !context) - return result?result:NS_ERROR_FAILURE; + nsPresContext *context = mShell->GetPresContext(); + if (!context) + return NS_OK; nsCOMPtr weakNodeUsed; PRInt32 offsetused = 0; @@ -1372,7 +1359,7 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA nscoord desiredX = 0; //we must keep this around and revalidate it when its just UP/DOWN PRInt8 index = GetIndexFromSelectionType(nsISelectionController::SELECTION_NORMAL); - result = mDomSelections[index]->GetIsCollapsed(&isCollapsed); + nsresult result = mDomSelections[index]->GetIsCollapsed(&isCollapsed); if (NS_FAILED(result)) return result; if (aKeycode == nsIDOMKeyEvent::DOM_VK_UP || aKeycode == nsIDOMKeyEvent::DOM_VK_DOWN) @@ -1422,10 +1409,7 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA } nsCOMPtr caret; - nsIPresShell *shell = context->GetPresShell(); - if (!shell) - return 0; - result = shell->GetCaret(getter_AddRefs(caret)); + result = mShell->GetCaret(getter_AddRefs(caret)); if (NS_FAILED(result) || !caret) return 0; @@ -1444,7 +1428,7 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA //set data using mLimiter to stop on scroll views. If we have a limiter then we stop peeking //when we hit scrollable views. If no limiter then just let it go ahead - pos.SetData(mTracker, desiredX, aAmount, eDirPrevious, offsetused, PR_FALSE, + pos.SetData(mShell, desiredX, aAmount, eDirPrevious, offsetused, PR_FALSE, PR_TRUE, PR_TRUE, mLimiter != nsnull, PR_TRUE); HINT tHint(mHint); //temporary variable so we dont set mHint until it is necessary @@ -1519,7 +1503,7 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA pos.mContentOffset = frameEnd; // set the cursor Bidi level to the paragraph embedding level - shell->SetCaretBidiLevel(NS_GET_BASE_LEVEL(theFrame)); + mShell->SetCaretBidiLevel(NS_GET_BASE_LEVEL(theFrame)); break; default: @@ -1528,10 +1512,10 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA || (eSelectDir == aAmount) || (eSelectLine == aAmount)) { - shell->SetCaretBidiLevel(NS_GET_EMBEDDING_LEVEL(theFrame)); + mShell->SetCaretBidiLevel(NS_GET_EMBEDDING_LEVEL(theFrame)); } else - BidiLevelFromMove(context, shell, pos.mResultContent, pos.mContentOffset, aKeycode); + BidiLevelFromMove(context, mShell, pos.mResultContent, pos.mContentOffset, aKeycode); } } #ifdef VISUALSELECTION @@ -2392,23 +2376,14 @@ void nsSelection::BidiLevelFromMove(nsPresContext* aContext, */ void nsSelection::BidiLevelFromClick(nsIContent *aNode, PRUint32 aContentOffset) { - nsCOMPtr context; - nsresult result = mTracker->GetPresContext(getter_AddRefs(context)); - if (NS_FAILED(result) || !context) - return; - - nsIPresShell *shell = context->GetPresShell(); - if (!shell) - return; - nsIFrame* clickInFrame=nsnull; PRInt32 OffsetNotUsed; - result = GetFrameForNodeOffset(aNode, aContentOffset, mHint, &clickInFrame, &OffsetNotUsed); + nsresult result = GetFrameForNodeOffset(aNode, aContentOffset, mHint, &clickInFrame, &OffsetNotUsed); if (NS_FAILED(result)) return; - shell->SetCaretBidiLevel(NS_GET_EMBEDDING_LEVEL(clickInFrame)); + mShell->SetCaretBidiLevel(NS_GET_EMBEDDING_LEVEL(clickInFrame)); } @@ -2548,7 +2523,7 @@ nsSelection::HandleDrag(nsPresContext *aPresContext, nsIFrame *aFrame, nsPoint& nsPeekOffsetStruct pos; //set data using mLimiter to stop on scroll views. If we have a limiter then we stop peeking //when we hit scrollable views. If no limiter then just let it go ahead - pos.SetData(mTracker, 0, eSelectDir, eDirNext, startPos, PR_FALSE, + pos.SetData(mShell, 0, eSelectDir, eDirNext, startPos, PR_FALSE, PR_TRUE, PR_TRUE, mLimiter != nsnull, PR_FALSE); mHint = HINT(beginOfContent); HINT saveHint = mHint; @@ -2647,17 +2622,8 @@ nsSelection::TakeFocus(nsIContent *aNewFocus, PRUint32 aContentOffset, //if we are no longer inside same table ,cell then switch to table selection mode. // BUT only do this in an editor - nsCOMPtr presContext; - nsresult result = mTracker->GetPresContext(getter_AddRefs(presContext)); - if (NS_FAILED(result) || !presContext) - return result?result:NS_ERROR_FAILURE; - - nsIPresShell *presShell = presContext->GetPresShell(); - if (!presShell) - return NS_ERROR_FAILURE; - PRInt16 displaySelection; - result = presShell->GetSelectionFlags(&displaySelection); + nsresult result = mShell->GetSelectionFlags(&displaySelection); if (NS_FAILED(result)) return result; @@ -2913,7 +2879,7 @@ nsSelection::GetFrameForNodeOffset(nsIContent *aNode, PRInt32 aOffset, HINT aHin } } - result = mTracker->GetPrimaryFrameFor(theNode, aReturnFrame); + result = mShell->GetPrimaryFrameFor(theNode, aReturnFrame); if (NS_FAILED(result)) return result; @@ -2960,20 +2926,6 @@ nsSelection::CommonPageMove(PRBool aForward, return result; nsRect viewRect = clipView->GetBounds(); - nsCOMPtr context; - result = mTracker->GetPresContext(getter_AddRefs(context)); - - if (NS_FAILED(result)) - return result; - - if (!context) - return NS_ERROR_NULL_POINTER; - - nsIPresShell *shell = context->GetPresShell(); - - if (!shell) - return NS_ERROR_NULL_POINTER; - // find out where the caret is. // we should know mDesiredX value of nsSelection, but I havent seen that behavior in other windows applications yet. nsCOMPtr domSel; @@ -2985,7 +2937,7 @@ nsSelection::CommonPageMove(PRBool aForward, nsCOMPtr caret; nsRect caretPos; PRBool isCollapsed; - result = shell->GetCaret(getter_AddRefs(caret)); + result = mShell->GetCaret(getter_AddRefs(caret)); if (NS_FAILED(result)) return result; @@ -3023,6 +2975,7 @@ nsSelection::CommonPageMove(PRBool aForward, nsPoint desiredPoint; desiredPoint.x = caretPos.x; desiredPoint.y = caretPos.y + caretPos.height/2; + nsPresContext *context = mShell->GetPresContext(); result = mainframe->GetContentAndOffsetsFromPoint(context, desiredPoint, getter_AddRefs(content), startOffset, endOffset, beginFrameContent); if (NS_FAILED(result)) @@ -3086,13 +3039,7 @@ NS_IMETHODIMP nsSelection::SelectAll() } else { - nsresult rv; - nsCOMPtr shell(do_QueryInterface(mTracker,&rv)); - if (NS_FAILED(rv) || !shell) { - return NS_ERROR_FAILURE; - } - - nsIDocument *doc = shell->GetDocument(); + nsIDocument *doc = mShell->GetDocument(); if (!doc) return NS_ERROR_FAILURE; rootContent = doc->GetRootContent(); @@ -3174,7 +3121,7 @@ nsSelection::GetCellLayout(nsIContent *aCellContent) { // Get frame for cell nsIFrame *cellFrame = nsnull; - GetTracker()->GetPrimaryFrameFor(aCellContent, &cellFrame); + mShell->GetPrimaryFrameFor(aCellContent, &cellFrame); if (!cellFrame) return nsnull; @@ -3189,7 +3136,7 @@ nsSelection::GetTableLayout(nsIContent *aTableContent) { // Get frame for table nsIFrame *tableFrame = nsnull; - GetTracker()->GetPrimaryFrameFor(aTableContent, &tableFrame); + mShell->GetPrimaryFrameFor(aTableContent, &tableFrame); if (!tableFrame) return nsnull; @@ -3348,7 +3295,7 @@ printf("HandleTableSelection: Mouse down event\n"); // Check if new cell is already selected nsIFrame *cellFrame = nsnull; - result = GetTracker()->GetPrimaryFrameFor(childContent, &cellFrame); + result = mShell->GetPrimaryFrameFor(childContent, &cellFrame); if (NS_FAILED(result)) return result; if (!cellFrame) return NS_ERROR_NULL_POINTER; result = cellFrame->GetSelected(&isSelected); @@ -4778,7 +4725,7 @@ nsTypedSelection::GetPrimaryFrameForRangeEndpoint(nsIDOMNode *aNode, PRInt32 aOf content = child; // releases the focusnode } } - result = mFrameSelection->GetTracker()->GetPrimaryFrameFor(content,aReturnFrame); + result = mFrameSelection->GetShell()->GetPrimaryFrameFor(content,aReturnFrame); return result; } #endif @@ -4853,7 +4800,7 @@ nsTypedSelection::selectFrames(nsPresContext* aPresContext, if (NS_SUCCEEDED(result)) { // First select frame of content passed in - result = mFrameSelection->GetTracker()->GetPrimaryFrameFor(aContent, &frame); + result = mFrameSelection->GetShell()->GetPrimaryFrameFor(aContent, &frame); if (NS_SUCCEEDED(result) && frame) { //NOTE: eSpreadDown is now IGNORED. Selected state is set only for given frame @@ -4877,7 +4824,7 @@ nsTypedSelection::selectFrames(nsPresContext* aPresContext, { nsIContent *innercontent = aInnerIter->GetCurrentNode(); - result = mFrameSelection->GetTracker()->GetPrimaryFrameFor(innercontent, &frame); + result = mFrameSelection->GetShell()->GetPrimaryFrameFor(innercontent, &frame); if (NS_SUCCEEDED(result) && frame) { //NOTE: eSpreadDown is now IGNORED. Selected state is set only @@ -4908,7 +4855,7 @@ nsTypedSelection::selectFrames(nsPresContext* aPresContext, } #if 0 - result = mFrameSelection->GetTracker()->GetPrimaryFrameFor(content, &frame); + result = mFrameSelection->GetShell()->GetPrimaryFrameFor(content, &frame); if (NS_SUCCEEDED(result) && frame) frame->SetSelected(aRange,aFlags,eSpreadDown);//spread from here to hit all frames in flow #endif @@ -4973,7 +4920,7 @@ nsTypedSelection::selectFrames(nsPresContext* aPresContext, nsIDOMRange *aRange, if (!content->IsContentOfType(nsIContent::eELEMENT)) { - result = mFrameSelection->GetTracker()->GetPrimaryFrameFor(content, &frame); + result = mFrameSelection->GetShell()->GetPrimaryFrameFor(content, &frame); if (NS_SUCCEEDED(result) && frame) frame->SetSelected(aPresContext, aRange,aFlags,eSpreadDown);//spread from here to hit all frames in flow } @@ -4997,7 +4944,7 @@ nsTypedSelection::selectFrames(nsPresContext* aPresContext, nsIDOMRange *aRange, if (!content->IsContentOfType(nsIContent::eELEMENT)) { - result = mFrameSelection->GetTracker()->GetPrimaryFrameFor(content, &frame); + result = mFrameSelection->GetShell()->GetPrimaryFrameFor(content, &frame); if (NS_SUCCEEDED(result) && frame) frame->SetSelected(aPresContext, aRange,aFlags,eSpreadDown);//spread from here to hit all frames in flow } @@ -6678,12 +6625,13 @@ nsTypedSelection::GetPresContext(nsPresContext **aPresContext) { if (!mFrameSelection) return NS_ERROR_FAILURE;//nothing to do - nsIFocusTracker *tracker = mFrameSelection->GetTracker(); + nsIPresShell *shell = mFrameSelection->GetShell(); - if (!tracker) + if (!shell) return NS_ERROR_NULL_POINTER; - return tracker->GetPresContext(aPresContext); + NS_IF_ADDREF(*aPresContext = shell->GetPresContext()); + return NS_OK; } nsresult @@ -6700,22 +6648,8 @@ nsTypedSelection::GetPresShell(nsIPresShell **aPresShell) if (!mFrameSelection) return NS_ERROR_FAILURE;//nothing to do - nsIFocusTracker *tracker = mFrameSelection->GetTracker(); + nsIPresShell *shell = mFrameSelection->GetShell(); - if (!tracker) - return NS_ERROR_NULL_POINTER; - - nsCOMPtr presContext; - - rv = tracker->GetPresContext(getter_AddRefs(presContext)); - - if (NS_FAILED(rv)) - return rv; - - if (!presContext) - return NS_ERROR_NULL_POINTER; - - nsIPresShell *shell = presContext->GetPresShell(); mPresShellWeak = do_GetWeakReference(shell); // the presshell owns us, so no addref if (mPresShellWeak) NS_ADDREF(*aPresShell = shell); @@ -6792,13 +6726,12 @@ nsTypedSelection::GetFrameToScrolledViewOffsets(nsIScrollableView *aScrollableVi // Determine the offset from aFrame to the scrolled view. We do that by // getting the offset from its closest view and then walking up aScrollableView->GetScrolledView(scrolledView); - nsIFocusTracker *tracker = mFrameSelection->GetTracker(); + nsIPresShell *shell = mFrameSelection->GetShell(); - if (!tracker) + if (!shell) return NS_ERROR_NULL_POINTER; - nsCOMPtr presContext; - tracker->GetPresContext(getter_AddRefs(presContext)); + nsPresContext *presContext = shell->GetPresContext(); aFrame->GetOffsetFromView(presContext, offset, &closestView); // XXX Deal with the case where there is a scrolled element, e.g., a @@ -6834,18 +6767,11 @@ nsTypedSelection::GetPointFromOffset(nsIFrame *aFrame, PRInt32 aContentOffset, n // a rendering context. // - nsIFocusTracker *tracker = mFrameSelection->GetTracker(); - - if (!tracker) + nsIPresShell *shell = mFrameSelection->GetShell(); + if (!shell) return NS_ERROR_NULL_POINTER; - nsCOMPtr presContext; - - rv = tracker->GetPresContext(getter_AddRefs(presContext)); - - if (NS_FAILED(rv)) - return rv; - + nsPresContext *presContext = shell->GetPresContext(); if (!presContext) return NS_ERROR_NULL_POINTER; diff --git a/mozilla/layout/generic/nsTextFrame.cpp b/mozilla/layout/generic/nsTextFrame.cpp index 4452ef9fb29..e44c76e6829 100644 --- a/mozilla/layout/generic/nsTextFrame.cpp +++ b/mozilla/layout/generic/nsTextFrame.cpp @@ -65,7 +65,6 @@ #include "nsIDOMText.h" #include "nsIDocument.h" #include "nsIDeviceContext.h" -#include "nsIFocusTracker.h" #include "nsICaret.h" #include "nsCSSPseudoElements.h" #include "nsILineBreaker.h" diff --git a/mozilla/layout/html/base/src/nsBlockFrame.cpp b/mozilla/layout/html/base/src/nsBlockFrame.cpp index 218a5ed4748..126be9814b4 100644 --- a/mozilla/layout/html/base/src/nsBlockFrame.cpp +++ b/mozilla/layout/html/base/src/nsBlockFrame.cpp @@ -66,7 +66,6 @@ #include "nsLayoutAtoms.h" #include "nsITextContent.h" #include "nsStyleChangeList.h" -#include "nsIFocusTracker.h" #include "nsIFrameSelection.h" #include "nsSpaceManager.h" #include "nsIntervalSet.h" @@ -5673,8 +5672,6 @@ nsBlockFrame::HandleEvent(nsPresContext* aPresContext, shell = aPresContext->GetPresShell(); if (!shell) return NS_OK; - nsCOMPtr tracker( do_QueryInterface(shell, &result) ); - nsCOMPtr it( do_QueryInterface(mainframe, &result) ); nsIView* parentWithView; nsPoint origin; @@ -5694,7 +5691,7 @@ nsBlockFrame::HandleEvent(nsPresContext* aPresContext, //we will now ask where to go. if we cant find what we want"aka another block frame" //we drill down again - pos.mTracker = tracker; + pos.mShell = shell; pos.mDirection = eDirNext; pos.mDesiredX = aEvent->point.x; pos.mScrollViewStop = PR_FALSE; diff --git a/mozilla/layout/html/base/src/nsFrame.cpp b/mozilla/layout/html/base/src/nsFrame.cpp index 7562603ebe4..534e847cb78 100644 --- a/mozilla/layout/html/base/src/nsFrame.cpp +++ b/mozilla/layout/html/base/src/nsFrame.cpp @@ -1604,18 +1604,13 @@ nsFrame::PeekBackwardAndForward(nsSelectionAmount aAmountBack, if (!shell || !selcon) return NS_ERROR_NOT_INITIALIZED; - nsCOMPtr tracker; - tracker = do_QueryInterface(shell, &rv); - if (NS_FAILED(rv) || !tracker) - return rv; - // Use peek offset one way then the other: nsCOMPtr startContent; nsCOMPtr startNode; nsCOMPtr endContent; nsCOMPtr endNode; nsPeekOffsetStruct startpos; - startpos.SetData(tracker, + startpos.SetData(shell, 0, aAmountBack, eDirPrevious, @@ -1629,7 +1624,7 @@ nsFrame::PeekBackwardAndForward(nsSelectionAmount aAmountBack, if (NS_FAILED(rv)) return rv; nsPeekOffsetStruct endpos; - endpos.SetData(tracker, + endpos.SetData(shell, 0, aAmountForward, eDirNext, @@ -3178,10 +3173,7 @@ nsFrame::GetNextPrevLineFromeBlockFrame(nsPresContext* aPresContext, nsISupports *isupports = nsnull; nsIFrame *storeOldResultFrame = resultFrame; while ( !found ){ - nsCOMPtr context; - result = aPos->mTracker->GetPresContext(getter_AddRefs(context)); - if (NS_FAILED(result)) - return result; + nsPresContext *context = aPos->mShell->GetPresContext(); nsPoint point; point.x = aPos->mDesiredX; @@ -3270,8 +3262,7 @@ nsFrame::GetNextPrevLineFromeBlockFrame(nsPresContext* aPresContext, aPresContext, resultFrame, aPos->mScrollViewStop); } while ( !found ){ - nsCOMPtr context; - result = aPos->mTracker->GetPresContext(getter_AddRefs(context)); + nsPresContext *context = aPos->mShell->GetPresContext(); nsPoint point; point.x = aPos->mDesiredX; @@ -3527,9 +3518,7 @@ DrillDownToEndOfLine(nsIFrame* aFrame, PRInt32 aLineNo, PRInt32 aLineFrameCount, // This doesn't seem very efficient since GetPosition // has to do a binary search. - nsCOMPtr context; - rv = aPos->mTracker->GetPresContext(getter_AddRefs(context)); - if (NS_FAILED(rv)) return rv; + nsPresContext *context = aPos->mShell->GetPresContext(); PRInt32 endoffset; rv = nextFrame->GetContentAndOffsetsFromPoint(context, offsetPoint, @@ -3554,7 +3543,7 @@ DrillDownToEndOfLine(nsIFrame* aFrame, PRInt32 aLineNo, PRInt32 aLineFrameCount, NS_IMETHODIMP nsFrame::PeekOffset(nsPresContext* aPresContext, nsPeekOffsetStruct *aPos) { - if (!aPos || !aPos->mTracker ) + if (!aPos || !aPos->mShell) return NS_ERROR_NULL_POINTER; nsresult result = NS_ERROR_FAILURE; PRInt32 endoffset; @@ -3604,10 +3593,9 @@ nsFrame::PeekOffset(nsPresContext* aPresContext, nsPeekOffsetStruct *aPos) }//drop into no amount case eSelectNoAmount: { - nsCOMPtr context; - result = aPos->mTracker->GetPresContext(getter_AddRefs(context)); - if (NS_FAILED(result) || !context) - return result; + nsPresContext *context = aPos->mShell->GetPresContext(); + if (!context) + return NS_OK; result = GetContentAndOffsetsFromPoint(context,point, getter_AddRefs(aPos->mResultContent), aPos->mContentOffset, @@ -3783,10 +3771,9 @@ nsFrame::PeekOffset(nsPresContext* aPresContext, nsPeekOffsetStruct *aPos) if (eSelectBeginLine == aPos->mAmount) { - nsCOMPtr context; - result = aPos->mTracker->GetPresContext(getter_AddRefs(context)); - if (NS_FAILED(result) || !context) - return result; + nsPresContext *context = aPos->mShell->GetPresContext(); + if (!context) + return NS_OK; while (firstFrame) { diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index c243e21331b..333000fdc45 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -1056,7 +1056,7 @@ ReflowCommandHashMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *entry, // ---------------------------------------------------------------------------- class PresShell : public nsIPresShell, public nsIViewObserver, - public nsStubDocumentObserver, public nsIFocusTracker, + public nsStubDocumentObserver, public nsISelectionController, public nsIObserver, public nsSupportsWeakReference { @@ -1084,7 +1084,6 @@ public: NS_IMETHOD PopStackMemory(); NS_IMETHOD AllocateStackMemory(size_t aSize, void** aResult); - NS_IMETHOD GetPresContext(nsPresContext** aResult); NS_IMETHOD GetActiveAlternateStyleSheet(nsString& aSheetTitle); NS_IMETHOD SelectAlternateStyleSheet(const nsString& aSheetTitle); NS_IMETHOD ListAlternateStyleSheets(nsStringArray& aTitleList); @@ -1620,8 +1619,8 @@ PresShell::PresShell() new (this) nsFrameManager(); } -NS_IMPL_ISUPPORTS8(PresShell, nsIPresShell, nsIDocumentObserver, - nsIViewObserver, nsIFocusTracker, nsISelectionController, +NS_IMPL_ISUPPORTS7(PresShell, nsIPresShell, nsIDocumentObserver, + nsIViewObserver, nsISelectionController, nsISelectionDisplay, nsIObserver, nsISupportsWeakReference) PresShell::~PresShell() @@ -1744,7 +1743,7 @@ PresShell::Init(nsIDocument* aDocument, return result; } - result = mSelection->Init((nsIFocusTracker *) this, nsnull); + result = mSelection->Init(this, nsnull); if (NS_FAILED(result)) { mStyleSet = nsnull; return result; @@ -2004,18 +2003,6 @@ PresShell::AllocateFrame(size_t aSize) return mFrameArena.AllocateFrame(aSize); } -NS_IMETHODIMP -PresShell::GetPresContext(nsPresContext** aResult) -{ - NS_PRECONDITION(nsnull != aResult, "null ptr"); - if (nsnull == aResult) { - return NS_ERROR_NULL_POINTER; - } - *aResult = mPresContext; - NS_IF_ADDREF(*aResult); - return NS_OK; -} - NS_IMETHODIMP PresShell::GetActiveAlternateStyleSheet(nsString& aSheetTitle) { // first non-html sheet in style set that has title @@ -3252,7 +3239,7 @@ PresShell::CompleteMove(PRBool aForward, PRBool aExtend) PRInt8 outsideLimit = -1;//search from beginning nsPeekOffsetStruct pos; pos.mAmount = eSelectLine; - pos.mTracker = this; + pos.mShell = this; pos.mContentOffset = 0; pos.mContentOffsetEnd = 0; pos.mScrollViewStop = PR_FALSE;//dont stop on scrolled views. diff --git a/mozilla/layout/html/base/src/nsTextFrame.cpp b/mozilla/layout/html/base/src/nsTextFrame.cpp index 4452ef9fb29..e44c76e6829 100644 --- a/mozilla/layout/html/base/src/nsTextFrame.cpp +++ b/mozilla/layout/html/base/src/nsTextFrame.cpp @@ -65,7 +65,6 @@ #include "nsIDOMText.h" #include "nsIDocument.h" #include "nsIDeviceContext.h" -#include "nsIFocusTracker.h" #include "nsICaret.h" #include "nsCSSPseudoElements.h" #include "nsILineBreaker.h" diff --git a/mozilla/layout/html/forms/src/nsTextControlFrame.cpp b/mozilla/layout/html/forms/src/nsTextControlFrame.cpp index 89c062f027a..602a168a2be 100644 --- a/mozilla/layout/html/forms/src/nsTextControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsTextControlFrame.cpp @@ -415,7 +415,7 @@ public: NS_IMETHOD CheckVisibility(nsIDOMNode *node, PRInt16 startOffset, PRInt16 EndOffset, PRBool *_retval); // NSIFRAMESELECTION INTERFACES - NS_IMETHOD Init(nsIFocusTracker *aTracker, nsIContent *aLimiter) ; + NS_IMETHOD Init(nsIPresShell *aShell, nsIContent *aLimiter) ; NS_IMETHOD ShutDown() ; NS_IMETHOD HandleTextEvent(nsGUIEvent *aGuiEvent) ; NS_IMETHOD HandleKeyEvent(nsPresContext* aPresContext, nsGUIEvent *aGuiEvent); @@ -485,9 +485,8 @@ nsTextInputSelectionImpl::nsTextInputSelectionImpl(nsIFrameSelection *aSel, nsIP if (aSel && aShell) { mFrameSelection = aSel;//we are the owner now! - nsCOMPtr tracker = do_QueryInterface(aShell); mLimiter = aLimiter; - mFrameSelection->Init(tracker, mLimiter); + mFrameSelection->Init(aShell, mLimiter); mPresShellWeak = do_GetWeakReference(aShell); #ifdef IBMBIDI mBidiKeyboard = do_GetService("@mozilla.org/widget/bidikeyboard;1"); @@ -850,9 +849,9 @@ nsTextInputSelectionImpl::CheckVisibility(nsIDOMNode *node, PRInt16 startOffset, //nsTextInputSelectionImpl::FRAMESELECTIONAPIS NS_IMETHODIMP -nsTextInputSelectionImpl::Init(nsIFocusTracker *aTracker, nsIContent *aLimiter) +nsTextInputSelectionImpl::Init(nsIPresShell *aShell, nsIContent *aLimiter) { - return mFrameSelection->Init(aTracker, aLimiter); + return mFrameSelection->Init(aShell, aLimiter); }