From 6865bb0c162d698a373303c5df0699bff8bda14c Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Fri, 8 Jun 2012 17:20:55 +0300 Subject: [PATCH] Bug 762862 - Rename nsTypedSelection to mozilla::Selection; r=ehsan --HG-- rename : layout/generic/nsTypedSelection.h => layout/generic/Selection.h --- .../src/generic/HyperTextAccessible.cpp | 2 +- content/base/public/nsContentUtils.h | 5 +- content/base/src/nsContentUtils.cpp | 4 +- .../html/content/src/nsTextEditorState.cpp | 3 +- dom/base/nsFocusManager.cpp | 2 +- editor/libeditor/base/nsEditRules.h | 2 +- editor/libeditor/base/nsEditor.cpp | 4 +- editor/libeditor/base/nsEditor.h | 5 +- editor/libeditor/html/nsHTMLAbsPosition.cpp | 4 +- editor/libeditor/html/nsHTMLDataTransfer.cpp | 10 +- editor/libeditor/html/nsHTMLEditRules.cpp | 10 +- editor/libeditor/html/nsHTMLEditRules.h | 8 +- editor/libeditor/html/nsHTMLEditor.cpp | 26 +- editor/libeditor/html/nsHTMLEditorStyle.cpp | 4 +- editor/libeditor/text/nsPlaintextEditor.cpp | 12 +- editor/libeditor/text/nsTextEditRules.cpp | 12 +- editor/libeditor/text/nsTextEditRules.h | 10 +- layout/base/nsPresShell.cpp | 2 +- layout/forms/nsTextControlFrame.cpp | 4 +- layout/generic/Makefile.in | 8 +- .../{nsTypedSelection.h => Selection.h} | 48 ++- layout/generic/nsFrameSelection.h | 10 +- layout/generic/nsSelection.cpp | 386 ++++++++---------- layout/generic/nsTextFrame.h | 2 +- 24 files changed, 273 insertions(+), 310 deletions(-) rename layout/generic/{nsTypedSelection.h => Selection.h} (88%) diff --git a/accessible/src/generic/HyperTextAccessible.cpp b/accessible/src/generic/HyperTextAccessible.cpp index 0821f47e6ca..462888d493e 100644 --- a/accessible/src/generic/HyperTextAccessible.cpp +++ b/accessible/src/generic/HyperTextAccessible.cpp @@ -31,7 +31,7 @@ #include "nsISelectionPrivate.h" #include "nsIServiceManager.h" #include "nsTextFragment.h" -#include "nsTypedSelection.h" +#include "mozilla/Selection.h" #include "gfxSkipChars.h" using namespace mozilla::a11y; diff --git a/content/base/public/nsContentUtils.h b/content/base/public/nsContentUtils.h index a317ed084c6..a67ea8ba16c 100644 --- a/content/base/public/nsContentUtils.h +++ b/content/base/public/nsContentUtils.h @@ -117,10 +117,11 @@ struct nsIntMargin; class nsPIDOMWindow; class nsIDocumentLoaderFactory; class nsIDOMHTMLInputElement; -class nsTypedSelection; namespace mozilla { +class Selection; + namespace layers { class LayerManager; } // namespace layers @@ -2040,7 +2041,7 @@ public: * @param aOutStartOffset Output start offset * @param aOutEndOffset Output end offset */ - static void GetSelectionInTextControl(nsTypedSelection* aSelection, + static void GetSelectionInTextControl(mozilla::Selection* aSelection, Element* aRoot, PRInt32& aOutStartOffset, PRInt32& aOutEndOffset); diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index 0209238fcdf..17be0d6ae04 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -143,7 +143,7 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID); #include "nsIDOMHTMLInputElement.h" #include "nsParserConstants.h" #include "nsIWebNavigation.h" -#include "nsTypedSelection.h" +#include "mozilla/Selection.h" #ifdef IBMBIDI #include "nsIBidiKeyboard.h" @@ -6867,7 +6867,7 @@ nsContentUtils::IsOnPrefWhitelist(nsPIDOMWindow* aWindow, // static void -nsContentUtils::GetSelectionInTextControl(nsTypedSelection* aSelection, +nsContentUtils::GetSelectionInTextControl(Selection* aSelection, Element* aRoot, PRInt32& aOutStartOffset, PRInt32& aOutEndOffset) diff --git a/content/html/content/src/nsTextEditorState.cpp b/content/html/content/src/nsTextEditorState.cpp index 0ff88d66d83..5111e845d80 100644 --- a/content/html/content/src/nsTextEditorState.cpp +++ b/content/html/content/src/nsTextEditorState.cpp @@ -33,10 +33,11 @@ #include "nsServiceManagerUtils.h" #include "nsIEditor.h" #include "nsTextEditRules.h" -#include "nsTypedSelection.h" +#include "mozilla/Selection.h" #include "nsEventListenerManager.h" #include "nsContentUtils.h" +using namespace mozilla; using namespace mozilla::dom; static NS_DEFINE_CID(kTextEditorCID, NS_TEXTEDITOR_CID); diff --git a/dom/base/nsFocusManager.cpp b/dom/base/nsFocusManager.cpp index 701b3a1b234..48fc90ae12d 100644 --- a/dom/base/nsFocusManager.cpp +++ b/dom/base/nsFocusManager.cpp @@ -44,7 +44,7 @@ #include "nsIBaseWindow.h" #include "nsIViewManager.h" #include "nsFrameSelection.h" -#include "nsTypedSelection.h" +#include "mozilla/Selection.h" #include "nsXULPopupManager.h" #include "nsIDOMNodeFilter.h" #include "nsIScriptObjectPrincipal.h" diff --git a/editor/libeditor/base/nsEditRules.h b/editor/libeditor/base/nsEditRules.h index db361fb403b..28e888c6045 100644 --- a/editor/libeditor/base/nsEditRules.h +++ b/editor/libeditor/base/nsEditRules.h @@ -46,7 +46,7 @@ public: nsIEditor::EDirection aDirection) = 0; NS_IMETHOD AfterEdit(nsEditor::OperationID action, nsIEditor::EDirection aDirection) = 0; - NS_IMETHOD WillDoAction(nsTypedSelection* aSelection, nsRulesInfo* aInfo, + NS_IMETHOD WillDoAction(mozilla::Selection* aSelection, nsRulesInfo* aInfo, bool* aCancel, bool* aHandled) = 0; NS_IMETHOD DidDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, nsresult aResult)=0; NS_IMETHOD DocumentIsEmpty(bool *aDocumentIsEmpty)=0; diff --git a/editor/libeditor/base/nsEditor.cpp b/editor/libeditor/base/nsEditor.cpp index 949e892b29e..651bcdb3d4d 100644 --- a/editor/libeditor/base/nsEditor.cpp +++ b/editor/libeditor/base/nsEditor.cpp @@ -598,8 +598,8 @@ nsEditor::GetSelection(nsISelection **aSelection) return selcon->GetSelection(nsISelectionController::SELECTION_NORMAL, aSelection); // does an addref } -nsTypedSelection* -nsEditor::GetTypedSelection() +Selection* +nsEditor::GetSelection() { nsCOMPtr sel; nsresult res = GetSelection(getter_AddRefs(sel)); diff --git a/editor/libeditor/base/nsEditor.h b/editor/libeditor/base/nsEditor.h index 9601c21bb47..a0979dd0a95 100644 --- a/editor/libeditor/base/nsEditor.h +++ b/editor/libeditor/base/nsEditor.h @@ -16,8 +16,7 @@ #include "nsIAtom.h" #include "nsIDOMDocument.h" -#include "nsISelection.h" -#include "nsTypedSelection.h" +#include "mozilla/Selection.h" #include "nsIDOMCharacterData.h" #include "nsIPrivateTextRange.h" #include "nsITransactionManager.h" @@ -595,7 +594,7 @@ public: #if DEBUG_JOE static void DumpNode(nsIDOMNode *aNode, PRInt32 indent=0); #endif - nsTypedSelection* GetTypedSelection(); + mozilla::Selection* GetSelection(); // Helpers to add a node to the selection. // Used by table cell selection methods diff --git a/editor/libeditor/html/nsHTMLAbsPosition.cpp b/editor/libeditor/html/nsHTMLAbsPosition.cpp index afab6e51d5e..3425a0727f9 100644 --- a/editor/libeditor/html/nsHTMLAbsPosition.cpp +++ b/editor/libeditor/html/nsHTMLAbsPosition.cpp @@ -46,7 +46,7 @@ nsHTMLEditor::AbsolutePositionSelection(bool aEnabled) // the line below does not match the code; should it be removed? // Find out if the selection is collapsed: - nsRefPtr selection = GetTypedSelection(); + nsRefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); nsTextRulesInfo ruleInfo(aEnabled ? kOpSetAbsolutePosition : @@ -159,7 +159,7 @@ nsHTMLEditor::RelativeChangeZIndex(PRInt32 aChange) // brade: can we get rid of this comment? // Find out if the selection is collapsed: - nsRefPtr selection = GetTypedSelection(); + nsRefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); nsTextRulesInfo ruleInfo(aChange < 0 ? kOpDecreaseZIndex : kOpIncreaseZIndex); diff --git a/editor/libeditor/html/nsHTMLDataTransfer.cpp b/editor/libeditor/html/nsHTMLDataTransfer.cpp index 7ed4ace00b3..b9e7ecbe4e2 100644 --- a/editor/libeditor/html/nsHTMLDataTransfer.cpp +++ b/editor/libeditor/html/nsHTMLDataTransfer.cpp @@ -153,7 +153,7 @@ NS_IMETHODIMP nsHTMLEditor::LoadHTML(const nsAString & aInputString) nsAutoRules beginRulesSniffing(this, kOpLoadHTML, nsIEditor::eNext); // Get selection - nsRefPtr selection = GetTypedSelection(); + nsRefPtr selection = GetSelection(); NS_ENSURE_STATE(selection); nsTextRulesInfo ruleInfo(kOpLoadHTML); @@ -250,7 +250,7 @@ nsHTMLEditor::DoInsertHTMLWithContext(const nsAString & aInputString, nsAutoRules beginRulesSniffing(this, kOpHTMLPaste, nsIEditor::eNext); // Get selection - nsRefPtr selection = GetTypedSelection(); + nsRefPtr selection = GetSelection(); NS_ENSURE_STATE(selection); // create a dom document fragment that represents the structure to paste @@ -1730,7 +1730,7 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsCitedQuotation(const nsAString & aCitation, nsAutoRules beginRulesSniffing(this, kOpInsertQuotation, nsIEditor::eNext); // get selection - nsRefPtr selection = GetTypedSelection(); + nsRefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); // give rules a chance to handle or cancel @@ -1927,7 +1927,7 @@ nsHTMLEditor::InsertAsPlaintextQuotation(const nsAString & aQuotedText, nsCOMPtr newNode; // get selection - nsRefPtr selection = GetTypedSelection(); + nsRefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); nsAutoEditBatch beginBatching(this); @@ -2019,7 +2019,7 @@ nsHTMLEditor::InsertAsCitedQuotation(const nsAString & aQuotedText, nsCOMPtr newNode; // get selection - nsRefPtr selection = GetTypedSelection(); + nsRefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); nsAutoEditBatch beginBatching(this); diff --git a/editor/libeditor/html/nsHTMLEditRules.cpp b/editor/libeditor/html/nsHTMLEditRules.cpp index 65a7a40e43a..4fd3af1edd5 100644 --- a/editor/libeditor/html/nsHTMLEditRules.cpp +++ b/editor/libeditor/html/nsHTMLEditRules.cpp @@ -515,7 +515,7 @@ nsHTMLEditRules::AfterEditInner(nsEditor::OperationID action, NS_IMETHODIMP -nsHTMLEditRules::WillDoAction(nsTypedSelection* aSelection, +nsHTMLEditRules::WillDoAction(Selection* aSelection, nsRulesInfo* aInfo, bool* aCancel, bool* aHandled) @@ -1237,7 +1237,7 @@ nsHTMLEditRules::WillInsert(nsISelection *aSelection, bool *aCancel) nsresult nsHTMLEditRules::WillInsertText(nsEditor::OperationID aAction, - nsTypedSelection* aSelection, + Selection* aSelection, bool *aCancel, bool *aHandled, const nsAString *inString, @@ -1463,7 +1463,7 @@ nsHTMLEditRules::WillLoadHTML(nsISelection *aSelection, bool *aCancel) } nsresult -nsHTMLEditRules::WillInsertBreak(nsTypedSelection* aSelection, +nsHTMLEditRules::WillInsertBreak(Selection* aSelection, bool* aCancel, bool* aHandled) { if (!aSelection || !aCancel || !aHandled) { @@ -1779,7 +1779,7 @@ nsHTMLEditRules::SplitMailCites(nsISelection *aSelection, bool aPlaintext, bool nsresult -nsHTMLEditRules::WillDeleteSelection(nsTypedSelection* aSelection, +nsHTMLEditRules::WillDeleteSelection(Selection* aSelection, nsIEditor::EDirection aAction, nsIEditor::EStripWrappers aStripWrappers, bool* aCancel, @@ -7244,7 +7244,7 @@ nsHTMLEditRules::ReapplyCachedStyles() bool useCSS = mHTMLEditor->IsCSSEnabled(); // get selection point; if it doesn't exist, we have nothing to do - nsRefPtr selection = mHTMLEditor->GetTypedSelection(); + nsRefPtr selection = mHTMLEditor->GetSelection(); MOZ_ASSERT(selection); if (!selection->GetRangeCount()) { // Nothing to do diff --git a/editor/libeditor/html/nsHTMLEditRules.h b/editor/libeditor/html/nsHTMLEditRules.h index 13f3f90d760..e340f493128 100644 --- a/editor/libeditor/html/nsHTMLEditRules.h +++ b/editor/libeditor/html/nsHTMLEditRules.h @@ -60,7 +60,7 @@ public: nsIEditor::EDirection aDirection); NS_IMETHOD AfterEdit(nsEditor::OperationID action, nsIEditor::EDirection aDirection); - NS_IMETHOD WillDoAction(nsTypedSelection* aSelection, nsRulesInfo* aInfo, + NS_IMETHOD WillDoAction(mozilla::Selection* aSelection, nsRulesInfo* aInfo, bool* aCancel, bool* aHandled); NS_IMETHOD DidDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, nsresult aResult); NS_IMETHOD DocumentModified(); @@ -108,19 +108,19 @@ protected: // nsHTMLEditRules implementation methods nsresult WillInsert(nsISelection *aSelection, bool *aCancel); nsresult WillInsertText( nsEditor::OperationID aAction, - nsTypedSelection* aSelection, + mozilla::Selection* aSelection, bool *aCancel, bool *aHandled, const nsAString *inString, nsAString *outString, PRInt32 aMaxLength); nsresult WillLoadHTML(nsISelection *aSelection, bool *aCancel); - nsresult WillInsertBreak(nsTypedSelection* aSelection, + nsresult WillInsertBreak(mozilla::Selection* aSelection, bool* aCancel, bool* aHandled); nsresult StandardBreakImpl(nsIDOMNode *aNode, PRInt32 aOffset, nsISelection *aSelection); nsresult DidInsertBreak(nsISelection *aSelection, nsresult aResult); nsresult SplitMailCites(nsISelection *aSelection, bool aPlaintext, bool *aHandled); - nsresult WillDeleteSelection(nsTypedSelection* aSelection, + nsresult WillDeleteSelection(mozilla::Selection* aSelection, nsIEditor::EDirection aAction, nsIEditor::EStripWrappers aStripWrappers, bool* aCancel, bool* aHandled); diff --git a/editor/libeditor/html/nsHTMLEditor.cpp b/editor/libeditor/html/nsHTMLEditor.cpp index 70f43a39832..df10fc3f7c6 100644 --- a/editor/libeditor/html/nsHTMLEditor.cpp +++ b/editor/libeditor/html/nsHTMLEditor.cpp @@ -1694,7 +1694,7 @@ nsHTMLEditor::InsertElementAtSelection(nsIDOMElement* aElement, bool aDeleteSele nsAutoEditBatch beginBatching(this); nsAutoRules beginRulesSniffing(this, kOpInsertElement, nsIEditor::eNext); - nsRefPtr selection = GetTypedSelection(); + nsRefPtr selection = GetSelection(); if (!selection) { return NS_ERROR_FAILURE; } @@ -2179,7 +2179,7 @@ nsHTMLEditor::MakeOrChangeList(const nsAString& aListType, bool entireList, cons nsAutoRules beginRulesSniffing(this, kOpMakeList, nsIEditor::eNext); // pre-process - nsRefPtr selection = GetTypedSelection(); + nsRefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); nsTextRulesInfo ruleInfo(kOpMakeList); @@ -2255,7 +2255,7 @@ nsHTMLEditor::RemoveList(const nsAString& aListType) nsAutoRules beginRulesSniffing(this, kOpRemoveList, nsIEditor::eNext); // pre-process - nsRefPtr selection = GetTypedSelection(); + nsRefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); nsTextRulesInfo ruleInfo(kOpRemoveList); @@ -2286,7 +2286,7 @@ nsHTMLEditor::MakeDefinitionItem(const nsAString& aItemType) nsAutoRules beginRulesSniffing(this, kOpMakeDefListItem, nsIEditor::eNext); // pre-process - nsRefPtr selection = GetTypedSelection(); + nsRefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); nsTextRulesInfo ruleInfo(kOpMakeDefListItem); ruleInfo.blockType = &aItemType; @@ -2317,7 +2317,7 @@ nsHTMLEditor::InsertBasicBlock(const nsAString& aBlockType) nsAutoRules beginRulesSniffing(this, kOpMakeBasicBlock, nsIEditor::eNext); // pre-process - nsRefPtr selection = GetTypedSelection(); + nsRefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); nsTextRulesInfo ruleInfo(kOpMakeBasicBlock); ruleInfo.blockType = &aBlockType; @@ -2391,7 +2391,7 @@ nsHTMLEditor::Indent(const nsAString& aIndent) nsAutoRules beginRulesSniffing(this, opID, nsIEditor::eNext); // pre-process - nsRefPtr selection = GetTypedSelection(); + nsRefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); nsTextRulesInfo ruleInfo(opID); @@ -2468,7 +2468,7 @@ nsHTMLEditor::Align(const nsAString& aAlignType) bool cancel, handled; // Find out if the selection is collapsed: - nsRefPtr selection = GetTypedSelection(); + nsRefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); nsTextRulesInfo ruleInfo(kOpAlign); ruleInfo.alignType = &aAlignType; @@ -3389,14 +3389,14 @@ nsHTMLEditor::DeleteSelectionImpl(EDirection aAction, return NS_OK; } - nsRefPtr typedSel = GetTypedSelection(); + nsRefPtr selection = GetSelection(); // Just checking that the selection itself is collapsed doesn't seem to work // right in the multi-range case - NS_ENSURE_STATE(typedSel); - NS_ENSURE_STATE(typedSel->GetAnchorFocusRange()); - NS_ENSURE_STATE(typedSel->GetAnchorFocusRange()->Collapsed()); + NS_ENSURE_STATE(selection); + NS_ENSURE_STATE(selection->GetAnchorFocusRange()); + NS_ENSURE_STATE(selection->GetAnchorFocusRange()->Collapsed()); - nsCOMPtr content = do_QueryInterface(typedSel->GetAnchorNode()); + nsCOMPtr content = do_QueryInterface(selection->GetAnchorNode()); NS_ENSURE_STATE(content); // Don't strip wrappers if this is the only wrapper in the block. Then we'll @@ -4887,7 +4887,7 @@ nsHTMLEditor::SetCSSBackgroundColor(const nsAString& aColor) // Protect the edit rules object from dying nsCOMPtr kungFuDeathGrip(mRules); - nsRefPtr selection = GetTypedSelection(); + nsRefPtr selection = GetSelection(); bool isCollapsed = selection->Collapsed(); diff --git a/editor/libeditor/html/nsHTMLEditorStyle.cpp b/editor/libeditor/html/nsHTMLEditorStyle.cpp index b337e14b3de..30629013f05 100644 --- a/editor/libeditor/html/nsHTMLEditorStyle.cpp +++ b/editor/libeditor/html/nsHTMLEditorStyle.cpp @@ -88,7 +88,7 @@ nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty, } ForceCompositionEnd(); - nsRefPtr selection = GetTypedSelection(); + nsRefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); if (selection->Collapsed()) { @@ -1333,7 +1333,7 @@ nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsAStr ForceCompositionEnd(); nsresult res; - nsRefPtr selection = GetTypedSelection(); + nsRefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); bool useCSS = IsCSSEnabled(); diff --git a/editor/libeditor/text/nsPlaintextEditor.cpp b/editor/libeditor/text/nsPlaintextEditor.cpp index 1853524922b..903dfe136b3 100644 --- a/editor/libeditor/text/nsPlaintextEditor.cpp +++ b/editor/libeditor/text/nsPlaintextEditor.cpp @@ -630,7 +630,7 @@ nsPlaintextEditor::DeleteSelection(EDirection aAction, nsAutoRules beginRulesSniffing(this, kOpDeleteSelection, aAction); // pre-process - nsRefPtr selection = GetTypedSelection(); + nsRefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); // If there is an existing selection when an extended delete is requested, @@ -688,7 +688,7 @@ NS_IMETHODIMP nsPlaintextEditor::InsertText(const nsAString &aStringToInsert) nsAutoRules beginRulesSniffing(this, opID, nsIEditor::eNext); // pre-process - nsRefPtr selection = GetTypedSelection(); + nsRefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); nsAutoString resultString; // XXX can we trust instring to outlive ruleInfo, @@ -725,7 +725,7 @@ NS_IMETHODIMP nsPlaintextEditor::InsertLineBreak() nsAutoRules beginRulesSniffing(this, kOpInsertBreak, nsIEditor::eNext); // pre-process - nsRefPtr selection = GetTypedSelection(); + nsRefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); // Batching the selection and moving nodes out from under the caret causes @@ -1073,7 +1073,7 @@ nsPlaintextEditor::Undo(PRUint32 aCount) nsAutoRules beginRulesSniffing(this, kOpUndo, nsIEditor::eNone); nsTextRulesInfo ruleInfo(kOpUndo); - nsRefPtr selection = GetTypedSelection(); + nsRefPtr selection = GetSelection(); bool cancel, handled; nsresult result = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled); @@ -1102,7 +1102,7 @@ nsPlaintextEditor::Redo(PRUint32 aCount) nsAutoRules beginRulesSniffing(this, kOpRedo, nsIEditor::eNone); nsTextRulesInfo ruleInfo(kOpRedo); - nsRefPtr selection = GetTypedSelection(); + nsRefPtr selection = GetSelection(); bool cancel, handled; nsresult result = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled); @@ -1376,7 +1376,7 @@ nsPlaintextEditor::InsertAsQuotation(const nsAString& aQuotedText, quotedStuff.Append(PRUnichar('\n')); // get selection - nsRefPtr selection = GetTypedSelection(); + nsRefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); nsAutoEditBatch beginBatching(this); diff --git a/editor/libeditor/text/nsTextEditRules.cpp b/editor/libeditor/text/nsTextEditRules.cpp index b4f98861450..ad5986a2818 100644 --- a/editor/libeditor/text/nsTextEditRules.cpp +++ b/editor/libeditor/text/nsTextEditRules.cpp @@ -210,7 +210,7 @@ nsTextEditRules::AfterEdit(nsEditor::OperationID action, NS_IMETHODIMP -nsTextEditRules::WillDoAction(nsTypedSelection* aSelection, +nsTextEditRules::WillDoAction(Selection* aSelection, nsRulesInfo* aInfo, bool* aCancel, bool* aHandled) @@ -334,7 +334,7 @@ nsTextEditRules::DidInsert(nsISelection *aSelection, nsresult aResult) } nsresult -nsTextEditRules::WillInsertBreak(nsTypedSelection* aSelection, +nsTextEditRules::WillInsertBreak(Selection* aSelection, bool *aCancel, bool *aHandled, PRInt32 aMaxLength) @@ -541,7 +541,7 @@ nsTextEditRules::HandleNewLines(nsString &aString, nsresult nsTextEditRules::WillInsertText(nsEditor::OperationID aAction, - nsTypedSelection* aSelection, + Selection* aSelection, bool *aCancel, bool *aHandled, const nsAString *inString, @@ -753,7 +753,7 @@ nsTextEditRules::DidRemoveTextProperty(nsISelection *aSelection, nsresult aResul } nsresult -nsTextEditRules::WillDeleteSelection(nsTypedSelection* aSelection, +nsTextEditRules::WillDeleteSelection(Selection* aSelection, nsIEditor::EDirection aCollapsedAction, bool *aCancel, bool *aHandled) @@ -1138,7 +1138,7 @@ nsTextEditRules::CreateBogusNodeIfNeeded(nsISelection *aSelection) nsresult -nsTextEditRules::TruncateInsertionIfNeeded(nsTypedSelection* aSelection, +nsTextEditRules::TruncateInsertionIfNeeded(Selection* aSelection, const nsAString *aInString, nsAString *aOutString, PRInt32 aMaxLength, @@ -1240,7 +1240,7 @@ nsresult nsTextEditRules::HideLastPWInput() { nsAutoString hiddenText; FillBufWithPWChars(&hiddenText, mLastLength); - nsRefPtr selection = mEditor->GetTypedSelection(); + nsRefPtr selection = mEditor->GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); PRInt32 start, end; nsContentUtils::GetSelectionInTextControl(selection, mEditor->GetRoot(), diff --git a/editor/libeditor/text/nsTextEditRules.h b/editor/libeditor/text/nsTextEditRules.h index f57b5970092..4fc6724b51d 100644 --- a/editor/libeditor/text/nsTextEditRules.h +++ b/editor/libeditor/text/nsTextEditRules.h @@ -42,7 +42,7 @@ public: nsIEditor::EDirection aDirection); NS_IMETHOD AfterEdit(nsEditor::OperationID action, nsIEditor::EDirection aDirection); - NS_IMETHOD WillDoAction(nsTypedSelection* aSelection, nsRulesInfo* aInfo, + NS_IMETHOD WillDoAction(mozilla::Selection* aSelection, nsRulesInfo* aInfo, bool* aCancel, bool* aHandled); NS_IMETHOD DidDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, nsresult aResult); NS_IMETHOD DocumentIsEmpty(bool *aDocumentIsEmpty); @@ -91,7 +91,7 @@ protected: // nsTextEditRules implementation methods nsresult WillInsertText( nsEditor::OperationID aAction, - nsTypedSelection* aSelection, + mozilla::Selection* aSelection, bool *aCancel, bool *aHandled, const nsAString *inString, @@ -100,14 +100,14 @@ protected: nsresult DidInsertText(nsISelection *aSelection, nsresult aResult); nsresult GetTopEnclosingPre(nsIDOMNode *aNode, nsIDOMNode** aOutPreNode); - nsresult WillInsertBreak(nsTypedSelection* aSelection, bool* aCancel, + nsresult WillInsertBreak(mozilla::Selection* aSelection, bool* aCancel, bool *aHandled, PRInt32 aMaxLength); nsresult DidInsertBreak(nsISelection *aSelection, nsresult aResult); nsresult WillInsert(nsISelection *aSelection, bool *aCancel); nsresult DidInsert(nsISelection *aSelection, nsresult aResult); - nsresult WillDeleteSelection(nsTypedSelection* aSelection, + nsresult WillDeleteSelection(mozilla::Selection* aSelection, nsIEditor::EDirection aCollapsedAction, bool *aCancel, bool *aHandled); @@ -156,7 +156,7 @@ protected: /** returns a truncated insertion string if insertion would place us over aMaxLength */ - nsresult TruncateInsertionIfNeeded(nsTypedSelection* aSelection, + nsresult TruncateInsertionIfNeeded(mozilla::Selection* aSelection, const nsAString *aInString, nsAString *aOutString, PRInt32 aMaxLength, diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 9b4c0afb0b3..f108f359962 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -53,7 +53,7 @@ #include "nsHTMLParts.h" #include "nsISelection.h" #include "nsISelectionPrivate.h" -#include "nsTypedSelection.h" +#include "mozilla/Selection.h" #include "nsLayoutCID.h" #include "nsGkAtoms.h" #include "nsIDOMRange.h" diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index b1910c2ddd7..073cb1e5597 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -78,6 +78,8 @@ #define DEFAULT_COLUMN_WIDTH 20 +using namespace mozilla; + nsIFrame* NS_NewTextControlFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) { @@ -1065,7 +1067,7 @@ nsTextControlFrame::GetSelectionRange(PRInt32* aSelectionStart, rv = selPriv->GetFrameSelection(getter_AddRefs(frameSel)); NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_TRUE(frameSel, NS_ERROR_FAILURE); - nsRefPtr typedSel = + nsRefPtr typedSel = frameSel->GetSelection(nsISelectionController::SELECTION_NORMAL); NS_ENSURE_TRUE(typedSel, NS_ERROR_FAILURE); diff --git a/layout/generic/Makefile.in b/layout/generic/Makefile.in index dfa55e9c25d..8c9bfa2ac6a 100644 --- a/layout/generic/Makefile.in +++ b/layout/generic/Makefile.in @@ -34,16 +34,20 @@ EXPORTS = \ nsIStatefulFrame.h \ nsFrameSelection.h \ nsSubDocumentFrame.h \ - nsTypedSelection.h \ + Selection.h \ nsObjectFrame.h \ $(NULL) -EXPORTS_NAMESPACES = mozilla/layout +EXPORTS_NAMESPACES = mozilla/layout mozilla EXPORTS_mozilla/layout = \ FrameChildList.h \ $(NULL) +EXPORTS_mozilla = \ + Selection.h \ + $(NULL) + CPPSRCS = \ FrameChildList.cpp \ nsAbsoluteContainingBlock.cpp \ diff --git a/layout/generic/nsTypedSelection.h b/layout/generic/Selection.h similarity index 88% rename from layout/generic/nsTypedSelection.h rename to layout/generic/Selection.h index 14e7ed942ad..f03b975b1f0 100644 --- a/layout/generic/nsTypedSelection.h +++ b/layout/generic/Selection.h @@ -4,8 +4,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef nsTypedSelection_h -#define nsTypedSelection_h +#ifndef mozilla_Selection_h__ +#define mozilla_Selection_h__ #include "nsIWeakReference.h" @@ -19,6 +19,7 @@ class nsAutoScrollTimer; class nsIContentIterator; class nsIFrame; struct SelectionDetails; +class nsSelectionIterator; struct RangeData { @@ -30,22 +31,23 @@ struct RangeData nsTextRangeStyle mTextRangeStyle; }; -// Note, the ownership of nsTypedSelection depends on which way the object is -// created. When nsFrameSelection has created nsTypedSelection, -// addreffing/releasing nsTypedSelection object is aggregated to -// nsFrameSelection. Otherwise normal addref/release is used. -// This ensures that nsFrameSelection is never deleted before its -// nsTypedSelections. -class nsTypedSelection : public nsISelectionPrivate, - public nsSupportsWeakReference +// Note, the ownership of mozilla::Selection depends on which way the object is +// created. When nsFrameSelection has created Selection, addreffing/releasing +// the Selection object is aggregated to nsFrameSelection. Otherwise normal +// addref/release is used. This ensures that nsFrameSelection is never deleted +// before its Selections. +namespace mozilla { + +class Selection : public nsISelectionPrivate, + public nsSupportsWeakReference { public: - nsTypedSelection(); - nsTypedSelection(nsFrameSelection *aList); - virtual ~nsTypedSelection(); + Selection(); + Selection(nsFrameSelection *aList); + virtual ~Selection(); NS_DECL_CYCLE_COLLECTING_ISUPPORTS - NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsTypedSelection, nsISelectionPrivate) + NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(Selection, nsISelectionPrivate) NS_DECL_NSISELECTION NS_DECL_NSISELECTIONPRIVATE @@ -127,7 +129,7 @@ public: nsresult StopAutoScrollTimer(); private: - friend class nsAutoScrollTimer; + friend class ::nsAutoScrollTimer; // Note: DoAutoScroll might destroy arbitrary frames etc. nsresult DoAutoScroll(nsIFrame *aFrame, nsPoint& aPoint); @@ -139,7 +141,7 @@ public: nsresult NotifySelectionListeners(); private: - friend class nsSelectionIterator; + friend class ::nsSelectionIterator; class ScrollSelectionIntoViewEvent; friend class ScrollSelectionIntoViewEvent; @@ -147,21 +149,21 @@ private: class ScrollSelectionIntoViewEvent : public nsRunnable { public: NS_DECL_NSIRUNNABLE - ScrollSelectionIntoViewEvent(nsTypedSelection *aTypedSelection, + ScrollSelectionIntoViewEvent(Selection* aSelection, SelectionRegion aRegion, nsIPresShell::ScrollAxis aVertical, nsIPresShell::ScrollAxis aHorizontal, bool aFirstAncestorOnly) - : mTypedSelection(aTypedSelection), + : mSelection(aSelection), mRegion(aRegion), mVerticalScroll(aVertical), mHorizontalScroll(aHorizontal), mFirstAncestorOnly(aFirstAncestorOnly) { - NS_ASSERTION(aTypedSelection, "null parameter"); + NS_ASSERTION(aSelection, "null parameter"); } - void Revoke() { mTypedSelection = nsnull; } + void Revoke() { mSelection = nsnull; } private: - nsTypedSelection *mTypedSelection; + Selection *mSelection; SelectionRegion mRegion; nsIPresShell::ScrollAxis mVerticalScroll; nsIPresShell::ScrollAxis mHorizontalScroll; @@ -218,4 +220,6 @@ private: SelectionType mType; }; -#endif // nsTypedSelection_h +} // namespace mozilla + +#endif // mozilla_Selection_h__ diff --git a/layout/generic/nsFrameSelection.h b/layout/generic/nsFrameSelection.h index bfd9f848b36..0f51bf9de5a 100644 --- a/layout/generic/nsFrameSelection.h +++ b/layout/generic/nsFrameSelection.h @@ -173,7 +173,9 @@ struct nsPrevNextBidiLevels PRUint8 mLevelAfter; }; -class nsTypedSelection; +namespace mozilla { +class Selection; +} class nsIScrollableFrame; /** @@ -351,7 +353,7 @@ public: * no query interface for selection. must use this method now. * @param aSelectionType enum value defined in nsISelection for the seleciton you want. */ - nsTypedSelection* GetSelection(SelectionType aType) const; + mozilla::Selection* GetSelection(SelectionType aType) const; /** * ScrollSelectionIntoView scrolls a region of the selection, @@ -618,7 +620,7 @@ private: return retval; } - friend class nsTypedSelection; + friend class mozilla::Selection; #ifdef DEBUG void printSelection(); // for debugging #endif /* DEBUG */ @@ -645,7 +647,7 @@ private: // so remember to use nsCOMPtr when needed. nsresult NotifySelectionListeners(SelectionType aType); // add parameters to say collapsed etc? - nsRefPtr mDomSelections[nsISelectionController::NUM_SELECTIONTYPES]; + nsRefPtr mDomSelections[nsISelectionController::NUM_SELECTIONTYPES]; // Table selection support. // Interfaces that let us get info based on cellmap locations diff --git a/layout/generic/nsSelection.cpp b/layout/generic/nsSelection.cpp index 43b0971a3f0..107f2372fa4 100644 --- a/layout/generic/nsSelection.cpp +++ b/layout/generic/nsSelection.cpp @@ -8,7 +8,7 @@ * Implementation of selection: nsISelection,nsISelectionPrivate and nsFrameSelection */ -#include "nsTypedSelection.h" +#include "mozilla/Selection.h" #include "mozilla/Attributes.h" @@ -163,15 +163,15 @@ see the nsIEnumerator for more details*/ nsRange* CurrentItem(); /*END Helper Methods*/ private: - friend class nsTypedSelection; + friend class mozilla::Selection; //lame lame lame if delete from document goes away then get rid of this unless its debug friend class nsFrameSelection; - nsSelectionIterator(nsTypedSelection *); + nsSelectionIterator(Selection*); virtual ~nsSelectionIterator(); PRInt32 mIndex; - nsTypedSelection *mDomSelection; + Selection* mDomSelection; SelectionType mType; }; @@ -227,7 +227,7 @@ public: return NS_OK; } - nsresult Init(nsFrameSelection *aFrameSelection, nsTypedSelection *aSelection) + nsresult Init(nsFrameSelection* aFrameSelection, Selection* aSelection) { mFrameSelection = aFrameSelection; mSelection = aSelection; @@ -263,7 +263,7 @@ public: } private: nsFrameSelection *mFrameSelection; - nsTypedSelection *mSelection; + Selection* mSelection; nsPresContext *mPresContext; // relative to mPresContext's root frame nsPoint mPoint; @@ -276,7 +276,7 @@ NS_IMPL_ISUPPORTS1(nsAutoScrollTimer, nsITimerCallback) nsresult NS_NewDomSelection(nsISelection **aDomSelection) { - nsTypedSelection *rlist = new nsTypedSelection; + Selection* rlist = new Selection; *aDomSelection = (nsISelection *)rlist; NS_ADDREF(rlist); return NS_OK; @@ -365,7 +365,7 @@ NS_INTERFACE_MAP_END_AGGREGATED(mDomSelection) ///////////BEGIN nsSelectionIterator methods -nsSelectionIterator::nsSelectionIterator(nsTypedSelection *aList) +nsSelectionIterator::nsSelectionIterator(Selection* aList) :mIndex(0) { if (!aList) @@ -475,7 +475,7 @@ nsFrameSelection::nsFrameSelection() { PRInt32 i; for (i = 0;iSetType(GetSelectionTypeFromIndex(i)); } mBatching = 0; @@ -902,7 +902,7 @@ nsFrameSelection::MoveCaret(PRUint32 aKeycode, nscoord desiredX = 0; //we must keep this around and revalidate it when its just UP/DOWN PRInt8 index = GetIndexFromSelectionType(nsISelectionController::SELECTION_NORMAL); - nsRefPtr sel = mDomSelections[index]; + nsRefPtr sel = mDomSelections[index]; if (!sel) return NS_ERROR_NULL_POINTER; @@ -1087,7 +1087,7 @@ nsFrameSelection::MoveCaret(PRUint32 aKeycode, //BEGIN nsFrameSelection methods NS_IMETHODIMP -nsTypedSelection::ToString(nsAString& aReturn) +Selection::ToString(nsAString& aReturn) { // We need Flush_Style here to make sure frames have been created for // the selected content. Use mFrameSelection->GetShell() which returns @@ -1106,8 +1106,8 @@ nsTypedSelection::ToString(nsAString& aReturn) } NS_IMETHODIMP -nsTypedSelection::ToStringWithFormat(const char * aFormatType, PRUint32 aFlags, - PRInt32 aWrapCol, nsAString& aReturn) +Selection::ToStringWithFormat(const char* aFormatType, PRUint32 aFlags, + PRInt32 aWrapCol, nsAString& aReturn) { nsresult rv = NS_OK; nsCAutoString formatType( NS_DOC_ENCODER_CONTRACTID_BASE ); @@ -1143,7 +1143,7 @@ nsTypedSelection::ToStringWithFormat(const char * aFormatType, PRUint32 aFlags, } NS_IMETHODIMP -nsTypedSelection::SetInterlinePosition(bool aHintRight) +Selection::SetInterlinePosition(bool aHintRight) { if (!mFrameSelection) return NS_ERROR_NOT_INITIALIZED; // Can't do selection @@ -1158,7 +1158,7 @@ nsTypedSelection::SetInterlinePosition(bool aHintRight) } NS_IMETHODIMP -nsTypedSelection::GetInterlinePosition(bool *aHintRight) +Selection::GetInterlinePosition(bool* aHintRight) { if (!mFrameSelection) return NS_ERROR_NOT_INITIALIZED; // Can't do selection @@ -1722,7 +1722,7 @@ nsFrameSelection::SetMouseDownState(bool aState) } } -nsTypedSelection* +Selection* nsFrameSelection::GetSelection(SelectionType aType) const { PRInt8 index = GetIndexFromSelectionType(aType); @@ -1745,11 +1745,11 @@ nsFrameSelection::ScrollSelectionIntoView(SelectionType aType, return NS_ERROR_NULL_POINTER; nsIPresShell::ScrollAxis verticalScroll = nsIPresShell::ScrollAxis(); - PRInt32 flags = nsTypedSelection::SCROLL_DO_FLUSH; + PRInt32 flags = Selection::SCROLL_DO_FLUSH; if (aFlags & nsISelectionController::SCROLL_SYNCHRONOUS) { - flags |= nsTypedSelection::SCROLL_SYNCHRONOUS; + flags |= Selection::SCROLL_SYNCHRONOUS; } else if (aFlags & nsISelectionController::SCROLL_FIRST_ANCESTOR_ONLY) { - flags |= nsTypedSelection::SCROLL_FIRST_ANCESTOR_ONLY; + flags |= Selection::SCROLL_FIRST_ANCESTOR_ONLY; } if (aFlags & nsISelectionController::SCROLL_CENTER_VERTICALLY) { verticalScroll = nsIPresShell::ScrollAxis( @@ -2874,7 +2874,9 @@ nsFrameSelection::SelectCellElement(nsIContent *aCellElement) } nsresult -nsTypedSelection::getTableCellLocationFromRange(nsRange *aRange, PRInt32 *aSelectionType, PRInt32 *aRow, PRInt32 *aCol) +Selection::getTableCellLocationFromRange(nsRange* aRange, + PRInt32* aSelectionType, + PRInt32* aRow, PRInt32* aCol) { if (!aRange || !aSelectionType || !aRow || !aCol) return NS_ERROR_NULL_POINTER; @@ -2916,8 +2918,8 @@ nsTypedSelection::getTableCellLocationFromRange(nsRange *aRange, PRInt32 *aSelec } nsresult -nsTypedSelection::addTableCellRange(nsRange *aRange, bool *aDidAddRange, - PRInt32 *aOutIndex) +Selection::addTableCellRange(nsRange* aRange, bool* aDidAddRange, + PRInt32* aOutIndex) { if (!aDidAddRange || !aOutIndex) return NS_ERROR_NULL_POINTER; @@ -2957,8 +2959,8 @@ nsTypedSelection::addTableCellRange(nsRange *aRange, bool *aDidAddRange, //TODO: Figure out TABLESELECTION_COLUMN and TABLESELECTION_ALLCELLS nsresult -nsTypedSelection::GetTableSelectionType(nsIDOMRange* aDOMRange, - PRInt32* aTableSelectionType) +Selection::GetTableSelectionType(nsIDOMRange* aDOMRange, + PRInt32* aTableSelectionType) { if (!aDOMRange || !aTableSelectionType) return NS_ERROR_NULL_POINTER; @@ -3139,18 +3141,18 @@ nsFrameSelection::DisconnectFromPresShell() #pragma mark - #endif -// nsTypedSelection implementation +// mozilla::Selection implementation // note: this can return a nil anchor node -nsTypedSelection::nsTypedSelection() +Selection::Selection() : mCachedOffsetForFrame(nsnull) , mDirection(eDirNext) , mType(nsISelectionController::SELECTION_NORMAL) { } -nsTypedSelection::nsTypedSelection(nsFrameSelection *aList) +Selection::Selection(nsFrameSelection* aList) : mFrameSelection(aList) , mCachedOffsetForFrame(nsnull) , mDirection(eDirNext) @@ -3158,7 +3160,7 @@ nsTypedSelection::nsTypedSelection(nsFrameSelection *aList) { } -nsTypedSelection::~nsTypedSelection() +Selection::~Selection() { setAnchorFocusRange(-1); @@ -3181,8 +3183,8 @@ nsTypedSelection::~nsTypedSelection() } -NS_IMPL_CYCLE_COLLECTION_CLASS(nsTypedSelection) -NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsTypedSelection) +NS_IMPL_CYCLE_COLLECTION_CLASS(Selection) +NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(Selection) // Unlink the selection listeners *before* we do RemoveAllRanges since // we don't want to notify the listeners during JS GC (they could be // in JS!). @@ -3190,7 +3192,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsTypedSelection) tmp->RemoveAllRanges(); NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mFrameSelection) NS_IMPL_CYCLE_COLLECTION_UNLINK_END -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsTypedSelection) +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Selection) { PRUint32 i, count = tmp->mRanges.Length(); for (i = 0; i < count; ++i) { @@ -3202,10 +3204,10 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsTypedSelection) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMARRAY(mSelectionListeners) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END -DOMCI_DATA(Selection, nsTypedSelection) +DOMCI_DATA(Selection, Selection) -// QueryInterface implementation for nsTypedSelection -NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsTypedSelection) +// QueryInterface implementation for Selection +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Selection) NS_INTERFACE_MAP_ENTRY(nsISelection) NS_INTERFACE_MAP_ENTRY(nsISelectionPrivate) NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) @@ -3213,11 +3215,11 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsTypedSelection) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Selection) NS_INTERFACE_MAP_END -NS_IMPL_CYCLE_COLLECTING_ADDREF(nsTypedSelection) -NS_IMPL_CYCLE_COLLECTING_RELEASE(nsTypedSelection) +NS_IMPL_CYCLE_COLLECTING_ADDREF(Selection) +NS_IMPL_CYCLE_COLLECTING_RELEASE(Selection) NS_IMETHODIMP -nsTypedSelection::SetPresShell(nsIPresShell *aPresShell) +Selection::SetPresShell(nsIPresShell* aPresShell) { mPresShellWeak = do_GetWeakReference(aPresShell); return NS_OK; @@ -3226,7 +3228,7 @@ nsTypedSelection::SetPresShell(nsIPresShell *aPresShell) NS_IMETHODIMP -nsTypedSelection::GetAnchorNode(nsIDOMNode** aAnchorNode) +Selection::GetAnchorNode(nsIDOMNode** aAnchorNode) { nsINode* anchorNode = GetAnchorNode(); if (anchorNode) { @@ -3238,7 +3240,7 @@ nsTypedSelection::GetAnchorNode(nsIDOMNode** aAnchorNode) } nsINode* -nsTypedSelection::GetAnchorNode() +Selection::GetAnchorNode() { if (!mAnchorFocusRange) return nsnull; @@ -3251,7 +3253,7 @@ nsTypedSelection::GetAnchorNode() } NS_IMETHODIMP -nsTypedSelection::GetAnchorOffset(PRInt32* aAnchorOffset) +Selection::GetAnchorOffset(PRInt32* aAnchorOffset) { *aAnchorOffset = GetAnchorOffset(); return NS_OK; @@ -3259,7 +3261,7 @@ nsTypedSelection::GetAnchorOffset(PRInt32* aAnchorOffset) // note: this can return a nil focus node NS_IMETHODIMP -nsTypedSelection::GetFocusNode(nsIDOMNode** aFocusNode) +Selection::GetFocusNode(nsIDOMNode** aFocusNode) { nsINode* focusNode = GetFocusNode(); if (focusNode) { @@ -3271,7 +3273,7 @@ nsTypedSelection::GetFocusNode(nsIDOMNode** aFocusNode) } nsINode* -nsTypedSelection::GetFocusNode() +Selection::GetFocusNode() { if (!mAnchorFocusRange) return nsnull; @@ -3283,13 +3285,15 @@ nsTypedSelection::GetFocusNode() return mAnchorFocusRange->GetStartParent(); } -NS_IMETHODIMP nsTypedSelection::GetFocusOffset(PRInt32* aFocusOffset) +NS_IMETHODIMP +Selection::GetFocusOffset(PRInt32* aFocusOffset) { *aFocusOffset = GetFocusOffset(); return NS_OK; } -void nsTypedSelection::setAnchorFocusRange(PRInt32 indx) +void +Selection::setAnchorFocusRange(PRInt32 indx) { if (indx >= (PRInt32)mRanges.Length()) return; @@ -3303,7 +3307,7 @@ void nsTypedSelection::setAnchorFocusRange(PRInt32 indx) } PRInt32 -nsTypedSelection::GetAnchorOffset() +Selection::GetAnchorOffset() { if (!mAnchorFocusRange) return 0; @@ -3316,7 +3320,7 @@ nsTypedSelection::GetAnchorOffset() } PRInt32 -nsTypedSelection::GetFocusOffset() +Selection::GetFocusOffset() { if (!mAnchorFocusRange) return 0; @@ -3364,7 +3368,7 @@ CompareToRangeEnd(nsINode* aCompareNode, PRInt32 aCompareOffset, return NS_OK; } -// nsTypedSelection::FindInsertionPoint +// Selection::FindInsertionPoint // // Binary searches the given sorted array of ranges for the insertion point // for the given node/offset. The given comparator is used, and the index @@ -3374,7 +3378,7 @@ CompareToRangeEnd(nsINode* aCompareNode, PRInt32 aCompareOffset, // the index of this item. nsresult -nsTypedSelection::FindInsertionPoint( +Selection::FindInsertionPoint( nsTArray* aElementArray, nsINode* aPointNode, PRInt32 aPointOffset, nsresult (*aComparator)(nsINode*,PRInt32,nsRange*,PRInt32*), @@ -3405,7 +3409,7 @@ nsTypedSelection::FindInsertionPoint( return NS_OK; } -// nsTypedSelection::SubtractRange +// Selection::SubtractRange // // A helper function that subtracts aSubtract from aRange, and adds // 1 or 2 RangeData objects representing the remaining non-overlapping @@ -3413,8 +3417,8 @@ nsTypedSelection::FindInsertionPoint( // aRange and aSubtract do indeed overlap nsresult -nsTypedSelection::SubtractRange(RangeData* aRange, nsRange* aSubtract, - nsTArray* aOutput) +Selection::SubtractRange(RangeData* aRange, nsRange* aSubtract, + nsTArray* aOutput) { nsRange* range = aRange->mRange; @@ -3478,7 +3482,7 @@ nsTypedSelection::SubtractRange(RangeData* aRange, nsRange* aSubtract, } nsresult -nsTypedSelection::AddItem(nsRange *aItem, PRInt32 *aOutIndex) +Selection::AddItem(nsRange* aItem, PRInt32* aOutIndex) { if (!aItem) return NS_ERROR_NULL_POINTER; @@ -3587,7 +3591,7 @@ nsTypedSelection::AddItem(nsRange *aItem, PRInt32 *aOutIndex) } nsresult -nsTypedSelection::RemoveItem(nsRange *aItem) +Selection::RemoveItem(nsRange* aItem) { if (!aItem) return NS_ERROR_NULL_POINTER; @@ -3613,7 +3617,7 @@ nsTypedSelection::RemoveItem(nsRange *aItem) } nsresult -nsTypedSelection::RemoveCollapsedRanges() +Selection::RemoveCollapsedRanges() { PRUint32 i = 0; while (i < mRanges.Length()) { @@ -3628,7 +3632,7 @@ nsTypedSelection::RemoveCollapsedRanges() } nsresult -nsTypedSelection::Clear(nsPresContext* aPresContext) +Selection::Clear(nsPresContext* aPresContext) { setAnchorFocusRange(-1); @@ -3652,7 +3656,7 @@ nsTypedSelection::Clear(nsPresContext* aPresContext) } NS_IMETHODIMP -nsTypedSelection::GetType(PRInt16 *aType) +Selection::GetType(PRInt16* aType) { NS_ENSURE_ARG_POINTER(aType); *aType = mType; @@ -3677,12 +3681,12 @@ RangeMatchesEndPoint(nsRange* aRange, nsINode* aNode, PRInt32 aOffset) return aRange->GetEndParent() == aNode && aRange->EndOffset() == aOffset; } -// nsTypedSelection::EqualsRangeAtPoint +// Selection::EqualsRangeAtPoint // // Utility method for checking equivalence of two ranges. bool -nsTypedSelection::EqualsRangeAtPoint( +Selection::EqualsRangeAtPoint( nsINode* aBeginNode, PRInt32 aBeginOffset, nsINode* aEndNode, PRInt32 aEndOffset, PRInt32 aRangeIndex) @@ -3696,16 +3700,16 @@ nsTypedSelection::EqualsRangeAtPoint( return false; } -// nsTypedSelection::GetRangesForInterval +// Selection::GetRangesForInterval // // XPCOM wrapper for the nsTArray version NS_IMETHODIMP -nsTypedSelection::GetRangesForInterval(nsIDOMNode* aBeginNode, PRInt32 aBeginOffset, - nsIDOMNode* aEndNode, PRInt32 aEndOffset, - bool aAllowAdjacent, - PRUint32 *aResultCount, - nsIDOMRange ***aResults) +Selection::GetRangesForInterval(nsIDOMNode* aBeginNode, PRInt32 aBeginOffset, + nsIDOMNode* aEndNode, PRInt32 aEndOffset, + bool aAllowAdjacent, + PRUint32* aResultCount, + nsIDOMRange*** aResults) { if (!aBeginNode || ! aEndNode || ! aResultCount || ! aResults) return NS_ERROR_NULL_POINTER; @@ -3735,7 +3739,7 @@ nsTypedSelection::GetRangesForInterval(nsIDOMNode* aBeginNode, PRInt32 aBeginOff return NS_OK; } -// nsTypedSelection::GetRangesForIntervalArray +// Selection::GetRangesForIntervalArray // // Fills a nsTArray with the ranges overlapping the range specified by // the given endpoints. Ranges in the selection exactly adjacent to the @@ -3756,10 +3760,10 @@ nsTypedSelection::GetRangesForInterval(nsIDOMNode* aBeginNode, PRInt32 aBeginOff // 2 adjacent ranges nsresult -nsTypedSelection::GetRangesForIntervalArray(nsINode* aBeginNode, PRInt32 aBeginOffset, - nsINode* aEndNode, PRInt32 aEndOffset, - bool aAllowAdjacent, - nsTArray* aRanges) +Selection::GetRangesForIntervalArray(nsINode* aBeginNode, PRInt32 aBeginOffset, + nsINode* aEndNode, PRInt32 aEndOffset, + bool aAllowAdjacent, + nsTArray* aRanges) { aRanges->Clear(); PRInt32 startIndex, endIndex; @@ -3776,19 +3780,17 @@ nsTypedSelection::GetRangesForIntervalArray(nsINode* aBeginNode, PRInt32 aBeginO return NS_OK; } -// nsTypedSelection::GetIndicesForInterval +// Selection::GetIndicesForInterval // // Works on the same principle as GetRangesForIntervalArray above, however // instead this returns the indices into mRanges between which the // overlapping ranges lie. void -nsTypedSelection::GetIndicesForInterval(nsINode* aBeginNode, - PRInt32 aBeginOffset, - nsINode* aEndNode, PRInt32 aEndOffset, - bool aAllowAdjacent, - PRInt32 *aStartIndex, - PRInt32 *aEndIndex) +Selection::GetIndicesForInterval(nsINode* aBeginNode, PRInt32 aBeginOffset, + nsINode* aEndNode, PRInt32 aEndOffset, + bool aAllowAdjacent, + PRInt32* aStartIndex, PRInt32* aEndIndex) { PRInt32 startIndex; PRInt32 endIndex; @@ -3906,57 +3908,8 @@ nsTypedSelection::GetIndicesForInterval(nsINode* aBeginNode, return; } -//utility method to get the primary frame of node or use the offset to get frame of child node - -#if 0 NS_IMETHODIMP -nsTypedSelection::GetPrimaryFrameForRangeEndpoint(nsIDOMNode *aNode, PRInt32 aOffset, bool aIsEndNode, nsIFrame **aReturnFrame) -{ - if (!aNode || !aReturnFrame || !mFrameSelection) - return NS_ERROR_NULL_POINTER; - - if (aOffset < 0) - return NS_ERROR_FAILURE; - - *aReturnFrame = 0; - - nsresult result = NS_OK; - - nsCOMPtr node = aNode; - - if (!node) - return NS_ERROR_NULL_POINTER; - - nsCOMPtr content = do_QueryInterface(node, &result); - - if (NS_FAILED(result)) - return result; - - if (!content) - return NS_ERROR_NULL_POINTER; - - if (content->IsElement()) - { - if (aIsEndNode) - aOffset--; - - if (aOffset >= 0) - { - nsIContent *child = content->GetChildAt(aOffset); - if (!child) //out of bounds? - return NS_ERROR_FAILURE; - - content = child; // releases the focusnode - } - } - *aReturnFrame = content->GetPrimaryFrame(); - return NS_OK; -} -#endif - - -NS_IMETHODIMP -nsTypedSelection::GetPrimaryFrameForAnchorNode(nsIFrame **aReturnFrame) +Selection::GetPrimaryFrameForAnchorNode(nsIFrame** aReturnFrame) { if (!aReturnFrame) return NS_ERROR_NULL_POINTER; @@ -3976,8 +3929,9 @@ nsTypedSelection::GetPrimaryFrameForAnchorNode(nsIFrame **aReturnFrame) } NS_IMETHODIMP -nsTypedSelection::GetPrimaryFrameForFocusNode(nsIFrame **aReturnFrame, PRInt32 *aOffsetUsed, - bool aVisual) +Selection::GetPrimaryFrameForFocusNode(nsIFrame** aReturnFrame, + PRInt32* aOffsetUsed, + bool aVisual) { if (!aReturnFrame) return NS_ERROR_NULL_POINTER; @@ -4017,9 +3971,9 @@ nsTypedSelection::GetPrimaryFrameForFocusNode(nsIFrame **aReturnFrame, PRInt32 * //select all content children of aContent nsresult -nsTypedSelection::SelectAllFramesForContent(nsIContentIterator *aInnerIter, - nsIContent *aContent, - bool aSelected) +Selection::SelectAllFramesForContent(nsIContentIterator* aInnerIter, + nsIContent* aContent, + bool aSelected) { nsresult result = aInnerIter->Init(aContent); nsIFrame *frame; @@ -4057,7 +4011,8 @@ nsTypedSelection::SelectAllFramesForContent(nsIContentIterator *aInnerIter, //the idea of this helper method is to select, deselect "top to bottom" traversing through the frames nsresult -nsTypedSelection::selectFrames(nsPresContext* aPresContext, nsRange* aRange, bool aFlags) +Selection::selectFrames(nsPresContext* aPresContext, nsRange* aRange, + bool aFlags) { if (!mFrameSelection || !aPresContext || !aPresContext->GetPresShell()) { return NS_OK; // nothing to do @@ -4148,7 +4103,7 @@ nsTypedSelection::selectFrames(nsPresContext* aPresContext, nsRange* aRange, boo } -// nsTypedSelection::LookUpSelection +// Selection::LookUpSelection // // This function is called when a node wants to know where the selection is // over itself. @@ -4173,10 +4128,10 @@ nsTypedSelection::selectFrames(nsPresContext* aPresContext, nsRange* aRange, boo // the aSlowCheck flag would have meaning again. NS_IMETHODIMP -nsTypedSelection::LookUpSelection(nsIContent *aContent, PRInt32 aContentOffset, - PRInt32 aContentLength, - SelectionDetails **aReturnDetails, - SelectionType aType, bool aSlowCheck) +Selection::LookUpSelection(nsIContent* aContent, PRInt32 aContentOffset, + PRInt32 aContentLength, + SelectionDetails** aReturnDetails, + SelectionType aType, bool aSlowCheck) { nsresult rv; if (!aContent || ! aReturnDetails) @@ -4253,7 +4208,7 @@ nsTypedSelection::LookUpSelection(nsIContent *aContent, PRInt32 aContentOffset, } NS_IMETHODIMP -nsTypedSelection::Repaint(nsPresContext* aPresContext) +Selection::Repaint(nsPresContext* aPresContext) { PRInt32 arrCount = (PRInt32)mRanges.Length(); @@ -4275,7 +4230,7 @@ nsTypedSelection::Repaint(nsPresContext* aPresContext) } NS_IMETHODIMP -nsTypedSelection::GetCanCacheFrameOffset(bool *aCanCacheFrameOffset) +Selection::GetCanCacheFrameOffset(bool* aCanCacheFrameOffset) { NS_ENSURE_ARG_POINTER(aCanCacheFrameOffset); @@ -4288,7 +4243,7 @@ nsTypedSelection::GetCanCacheFrameOffset(bool *aCanCacheFrameOffset) } NS_IMETHODIMP -nsTypedSelection::SetCanCacheFrameOffset(bool aCanCacheFrameOffset) +Selection::SetCanCacheFrameOffset(bool aCanCacheFrameOffset) { if (!mCachedOffsetForFrame) { mCachedOffsetForFrame = new CachedOffsetForFrame; @@ -4306,7 +4261,8 @@ nsTypedSelection::SetCanCacheFrameOffset(bool aCanCacheFrameOffset) } NS_IMETHODIMP -nsTypedSelection::GetCachedFrameOffset(nsIFrame *aFrame, PRInt32 inOffset, nsPoint& aPoint) +Selection::GetCachedFrameOffset(nsIFrame* aFrame, PRInt32 inOffset, + nsPoint& aPoint) { if (!mCachedOffsetForFrame) { mCachedOffsetForFrame = new CachedOffsetForFrame; @@ -4337,7 +4293,7 @@ nsTypedSelection::GetCachedFrameOffset(nsIFrame *aFrame, PRInt32 inOffset, nsPoi } NS_IMETHODIMP -nsTypedSelection::GetFrameSelection(nsFrameSelection **aFrameSelection) { +Selection::GetFrameSelection(nsFrameSelection** aFrameSelection) { NS_ENSURE_ARG_POINTER(aFrameSelection); *aFrameSelection = mFrameSelection; NS_IF_ADDREF(*aFrameSelection); @@ -4345,7 +4301,7 @@ nsTypedSelection::GetFrameSelection(nsFrameSelection **aFrameSelection) { } NS_IMETHODIMP -nsTypedSelection::SetAncestorLimiter(nsIContent *aContent) +Selection::SetAncestorLimiter(nsIContent* aContent) { if (mFrameSelection) mFrameSelection->SetAncestorLimiter(aContent); @@ -4353,7 +4309,7 @@ nsTypedSelection::SetAncestorLimiter(nsIContent *aContent) } RangeData* -nsTypedSelection::FindRangeData(nsIDOMRange* aRange) +Selection::FindRangeData(nsIDOMRange* aRange) { NS_ENSURE_TRUE(aRange, nsnull); for (PRUint32 i = 0; i < mRanges.Length(); i++) { @@ -4364,8 +4320,8 @@ nsTypedSelection::FindRangeData(nsIDOMRange* aRange) } NS_IMETHODIMP -nsTypedSelection::SetTextRangeStyle(nsIDOMRange *aRange, - const nsTextRangeStyle &aTextRangeStyle) +Selection::SetTextRangeStyle(nsIDOMRange* aRange, + const nsTextRangeStyle& aTextRangeStyle) { NS_ENSURE_ARG_POINTER(aRange); RangeData *rd = FindRangeData(aRange); @@ -4376,9 +4332,8 @@ nsTypedSelection::SetTextRangeStyle(nsIDOMRange *aRange, } nsresult -nsTypedSelection::StartAutoScrollTimer(nsIFrame *aFrame, - nsPoint& aPoint, - PRUint32 aDelay) +Selection::StartAutoScrollTimer(nsIFrame* aFrame, nsPoint& aPoint, + PRUint32 aDelay) { NS_PRECONDITION(aFrame, "Need a frame"); @@ -4405,7 +4360,7 @@ nsTypedSelection::StartAutoScrollTimer(nsIFrame *aFrame, } nsresult -nsTypedSelection::StopAutoScrollTimer() +Selection::StopAutoScrollTimer() { if (mAutoScrollTimer) return mAutoScrollTimer->Stop(); @@ -4414,7 +4369,7 @@ nsTypedSelection::StopAutoScrollTimer() } nsresult -nsTypedSelection::DoAutoScroll(nsIFrame *aFrame, nsPoint& aPoint) +Selection::DoAutoScroll(nsIFrame* aFrame, nsPoint& aPoint) { NS_PRECONDITION(aFrame, "Need a frame"); @@ -4452,7 +4407,7 @@ nsTypedSelection::DoAutoScroll(nsIFrame *aFrame, nsPoint& aPoint) } NS_IMETHODIMP -nsTypedSelection::GetEnumerator(nsIEnumerator **aIterator) +Selection::GetEnumerator(nsIEnumerator** aIterator) { NS_ADDREF(*aIterator = new nsSelectionIterator(this)); return NS_OK; @@ -4463,7 +4418,7 @@ nsTypedSelection::GetEnumerator(nsIEnumerator **aIterator) /** RemoveAllRanges zeroes the selection */ NS_IMETHODIMP -nsTypedSelection::RemoveAllRanges() +Selection::RemoveAllRanges() { if (!mFrameSelection) return NS_OK;//nothing to do @@ -4487,7 +4442,7 @@ nsTypedSelection::RemoveAllRanges() * @param aRange is the range to be added */ NS_IMETHODIMP -nsTypedSelection::AddRange(nsIDOMRange* aDOMRange) +Selection::AddRange(nsIDOMRange* aDOMRange) { if (!aDOMRange) { return NS_ERROR_NULL_POINTER; @@ -4524,7 +4479,7 @@ nsTypedSelection::AddRange(nsIDOMRange* aDOMRange) return mFrameSelection->NotifySelectionListeners(GetType()); } -// nsTypedSelection::RemoveRange +// Selection::RemoveRange // // Removes the given range from the selection. The tricky part is updating // the flags on the frames that indicate whether they have a selection or @@ -4537,7 +4492,7 @@ nsTypedSelection::AddRange(nsIDOMRange* aDOMRange) // selected frames after we've cleared the bit from ours. nsresult -nsTypedSelection::RemoveRange(nsIDOMRange* aDOMRange) +Selection::RemoveRange(nsIDOMRange* aDOMRange) { if (!aDOMRange) { return NS_ERROR_INVALID_ARG; @@ -4609,20 +4564,20 @@ nsTypedSelection::RemoveRange(nsIDOMRange* aDOMRange) * Collapse sets the whole selection to be one point. */ NS_IMETHODIMP -nsTypedSelection::Collapse(nsIDOMNode* aParentNode, PRInt32 aOffset) +Selection::Collapse(nsIDOMNode* aParentNode, PRInt32 aOffset) { nsCOMPtr parentNode = do_QueryInterface(aParentNode); return Collapse(parentNode, aOffset); } NS_IMETHODIMP -nsTypedSelection::CollapseNative(nsINode* aParentNode, PRInt32 aOffset) +Selection::CollapseNative(nsINode* aParentNode, PRInt32 aOffset) { return Collapse(aParentNode, aOffset); } nsresult -nsTypedSelection::Collapse(nsINode* aParentNode, PRInt32 aOffset) +Selection::Collapse(nsINode* aParentNode, PRInt32 aOffset) { if (!aParentNode) return NS_ERROR_INVALID_ARG; @@ -4675,7 +4630,7 @@ nsTypedSelection::Collapse(nsINode* aParentNode, PRInt32 aOffset) * at the start of the current selection */ NS_IMETHODIMP -nsTypedSelection::CollapseToStart() +Selection::CollapseToStart() { PRInt32 cnt; nsresult rv = GetRangeCount(&cnt); @@ -4695,7 +4650,7 @@ nsTypedSelection::CollapseToStart() * at the end of the current selection */ NS_IMETHODIMP -nsTypedSelection::CollapseToEnd() +Selection::CollapseToEnd() { PRInt32 cnt; nsresult rv = GetRangeCount(&cnt); @@ -4714,7 +4669,7 @@ nsTypedSelection::CollapseToEnd() * IsCollapsed -- is the whole selection just one point, or unset? */ bool -nsTypedSelection::IsCollapsed() +Selection::IsCollapsed() { PRUint32 cnt = mRanges.Length(); if (cnt == 0) { @@ -4730,13 +4685,13 @@ nsTypedSelection::IsCollapsed() /* virtual */ bool -nsTypedSelection::Collapsed() +Selection::Collapsed() { return IsCollapsed(); } NS_IMETHODIMP -nsTypedSelection::GetIsCollapsed(bool* aIsCollapsed) +Selection::GetIsCollapsed(bool* aIsCollapsed) { NS_ENSURE_TRUE(aIsCollapsed, NS_ERROR_NULL_POINTER); @@ -4745,7 +4700,7 @@ nsTypedSelection::GetIsCollapsed(bool* aIsCollapsed) } NS_IMETHODIMP -nsTypedSelection::GetRangeCount(PRInt32* aRangeCount) +Selection::GetRangeCount(PRInt32* aRangeCount) { *aRangeCount = (PRInt32)mRanges.Length(); @@ -4753,7 +4708,7 @@ nsTypedSelection::GetRangeCount(PRInt32* aRangeCount) } NS_IMETHODIMP -nsTypedSelection::GetRangeAt(PRInt32 aIndex, nsIDOMRange** aReturn) +Selection::GetRangeAt(PRInt32 aIndex, nsIDOMRange** aReturn) { *aReturn = mRanges.SafeElementAt(aIndex, sEmptyData).mRange; if (!*aReturn) { @@ -4766,7 +4721,7 @@ nsTypedSelection::GetRangeAt(PRInt32 aIndex, nsIDOMRange** aReturn) } nsRange* -nsTypedSelection::GetRangeAt(PRInt32 aIndex) +Selection::GetRangeAt(PRInt32 aIndex) { return mRanges.SafeElementAt(aIndex, sEmptyData).mRange; } @@ -4775,7 +4730,7 @@ nsTypedSelection::GetRangeAt(PRInt32 aIndex) utility function */ nsresult -nsTypedSelection::SetAnchorFocusToRange(nsRange *aRange) +Selection::SetAnchorFocusToRange(nsRange* aRange) { NS_ENSURE_STATE(mAnchorFocusRange); @@ -4793,7 +4748,7 @@ nsTypedSelection::SetAnchorFocusToRange(nsRange *aRange) } void -nsTypedSelection::ReplaceAnchorFocusRange(nsRange *aRange) +Selection::ReplaceAnchorFocusRange(nsRange* aRange) { nsRefPtr presContext; GetPresContext(getter_AddRefs(presContext)); @@ -4834,20 +4789,20 @@ a 2 1 deselect from 2 to 1 * We don't need to know the direction, because we always change the focus. */ NS_IMETHODIMP -nsTypedSelection::Extend(nsIDOMNode* aParentNode, PRInt32 aOffset) +Selection::Extend(nsIDOMNode* aParentNode, PRInt32 aOffset) { nsCOMPtr parentNode = do_QueryInterface(aParentNode); return Extend(parentNode, aOffset); } NS_IMETHODIMP -nsTypedSelection::ExtendNative(nsINode* aParentNode, PRInt32 aOffset) +Selection::ExtendNative(nsINode* aParentNode, PRInt32 aOffset) { return Extend(aParentNode, aOffset); } nsresult -nsTypedSelection::Extend(nsINode* aParentNode, PRInt32 aOffset) +Selection::Extend(nsINode* aParentNode, PRInt32 aOffset) { if (!aParentNode) return NS_ERROR_INVALID_ARG; @@ -5063,7 +5018,7 @@ nsTypedSelection::Extend(nsINode* aParentNode, PRInt32 aOffset) } NS_IMETHODIMP -nsTypedSelection::SelectAllChildren(nsIDOMNode* aParentNode) +Selection::SelectAllChildren(nsIDOMNode* aParentNode) { NS_ENSURE_ARG_POINTER(aParentNode); nsCOMPtr node = do_QueryInterface(aParentNode); @@ -5084,8 +5039,7 @@ nsTypedSelection::SelectAllChildren(nsIDOMNode* aParentNode) } NS_IMETHODIMP -nsTypedSelection::ContainsNode(nsIDOMNode* aNode, bool aAllowPartial, - bool* aYes) +Selection::ContainsNode(nsIDOMNode* aNode, bool aAllowPartial, bool* aYes) { nsresult rv; if (!aYes) @@ -5142,7 +5096,7 @@ nsTypedSelection::ContainsNode(nsIDOMNode* aNode, bool aAllowPartial, nsresult -nsTypedSelection::GetPresContext(nsPresContext **aPresContext) +Selection::GetPresContext(nsPresContext** aPresContext) { if (!mFrameSelection) return NS_ERROR_FAILURE;//nothing to do @@ -5156,7 +5110,7 @@ nsTypedSelection::GetPresContext(nsPresContext **aPresContext) } nsresult -nsTypedSelection::GetPresShell(nsIPresShell **aPresShell) +Selection::GetPresShell(nsIPresShell** aPresShell) { if (mPresShellWeak) { @@ -5178,8 +5132,7 @@ nsTypedSelection::GetPresShell(nsIPresShell **aPresShell) } nsIFrame * -nsTypedSelection::GetSelectionAnchorGeometry(SelectionRegion aRegion, - nsRect *aRect) +Selection::GetSelectionAnchorGeometry(SelectionRegion aRegion, nsRect* aRect) { if (!mFrameSelection) return nsnull; // nothing to do @@ -5224,8 +5177,7 @@ nsTypedSelection::GetSelectionAnchorGeometry(SelectionRegion aRegion, } nsIFrame * -nsTypedSelection::GetSelectionEndPointGeometry(SelectionRegion aRegion, - nsRect *aRect) +Selection::GetSelectionEndPointGeometry(SelectionRegion aRegion, nsRect* aRect) { if (!mFrameSelection) return nsnull; // nothing to do @@ -5301,25 +5253,25 @@ nsTypedSelection::GetSelectionEndPointGeometry(SelectionRegion aRegion, } NS_IMETHODIMP -nsTypedSelection::ScrollSelectionIntoViewEvent::Run() +Selection::ScrollSelectionIntoViewEvent::Run() { - if (!mTypedSelection) + if (!mSelection) return NS_OK; // event revoked - PRInt32 flags = nsTypedSelection::SCROLL_DO_FLUSH | - nsTypedSelection::SCROLL_SYNCHRONOUS; + PRInt32 flags = Selection::SCROLL_DO_FLUSH | + Selection::SCROLL_SYNCHRONOUS; if (mFirstAncestorOnly) { - flags |= nsTypedSelection::SCROLL_FIRST_ANCESTOR_ONLY; + flags |= Selection::SCROLL_FIRST_ANCESTOR_ONLY; } - mTypedSelection->mScrollEvent.Forget(); - mTypedSelection->ScrollIntoView(mRegion, mVerticalScroll, - mHorizontalScroll, flags); + mSelection->mScrollEvent.Forget(); + mSelection->ScrollIntoView(mRegion, mVerticalScroll, + mHorizontalScroll, flags); return NS_OK; } nsresult -nsTypedSelection::PostScrollSelectionIntoViewEvent( +Selection::PostScrollSelectionIntoViewEvent( SelectionRegion aRegion, bool aFirstAncestorOnly, nsIPresShell::ScrollAxis aVertical, @@ -5342,10 +5294,8 @@ nsTypedSelection::PostScrollSelectionIntoViewEvent( } NS_IMETHODIMP -nsTypedSelection::ScrollIntoView(SelectionRegion aRegion, - bool aIsSynchronous, - PRInt16 aVPercent, - PRInt16 aHPercent) +Selection::ScrollIntoView(SelectionRegion aRegion, bool aIsSynchronous, + PRInt16 aVPercent, PRInt16 aHPercent) { return ScrollIntoViewInternal(aRegion, aIsSynchronous, @@ -5354,20 +5304,19 @@ nsTypedSelection::ScrollIntoView(SelectionRegion aRegion, } NS_IMETHODIMP -nsTypedSelection::ScrollIntoViewInternal(SelectionRegion aRegion, - bool aIsSynchronous, - nsIPresShell::ScrollAxis aVertical, - nsIPresShell::ScrollAxis aHorizontal) +Selection::ScrollIntoViewInternal(SelectionRegion aRegion, bool aIsSynchronous, + nsIPresShell::ScrollAxis aVertical, + nsIPresShell::ScrollAxis aHorizontal) { return ScrollIntoView(aRegion, aVertical, aHorizontal, - aIsSynchronous ? nsTypedSelection::SCROLL_SYNCHRONOUS : 0); + aIsSynchronous ? Selection::SCROLL_SYNCHRONOUS : 0); } nsresult -nsTypedSelection::ScrollIntoView(SelectionRegion aRegion, - nsIPresShell::ScrollAxis aVertical, - nsIPresShell::ScrollAxis aHorizontal, - PRInt32 aFlags) +Selection::ScrollIntoView(SelectionRegion aRegion, + nsIPresShell::ScrollAxis aVertical, + nsIPresShell::ScrollAxis aHorizontal, + PRInt32 aFlags) { nsresult result; if (!mFrameSelection) @@ -5376,9 +5325,9 @@ nsTypedSelection::ScrollIntoView(SelectionRegion aRegion, if (mFrameSelection->GetBatching()) return NS_OK; - if (!(aFlags & nsTypedSelection::SCROLL_SYNCHRONOUS)) + if (!(aFlags & Selection::SCROLL_SYNCHRONOUS)) return PostScrollSelectionIntoViewEvent(aRegion, - !!(aFlags & nsTypedSelection::SCROLL_FIRST_ANCESTOR_ONLY), + !!(aFlags & Selection::SCROLL_FIRST_ANCESTOR_ONLY), aVertical, aHorizontal); // @@ -5397,7 +5346,7 @@ nsTypedSelection::ScrollIntoView(SelectionRegion aRegion, // is that some callers might scroll to the wrong place. Those should // either manually flush if they're in a safe position for it or use the // async version of this method. - if (aFlags & nsTypedSelection::SCROLL_DO_FLUSH) { + if (aFlags & Selection::SCROLL_DO_FLUSH) { presShell->FlushPendingNotifications(Flush_Layout); // Reget the presshell, since it might have gone away. @@ -5418,7 +5367,8 @@ nsTypedSelection::ScrollIntoView(SelectionRegion aRegion, return NS_ERROR_FAILURE; presShell->ScrollFrameRectIntoView(frame, rect, aVertical, aHorizontal, - (aFlags & nsTypedSelection::SCROLL_FIRST_ANCESTOR_ONLY) ? nsIPresShell::SCROLL_FIRST_ANCESTOR_ONLY: 0); + (aFlags & Selection::SCROLL_FIRST_ANCESTOR_ONLY) ? + nsIPresShell::SCROLL_FIRST_ANCESTOR_ONLY : 0); return NS_OK; } return result; @@ -5427,7 +5377,7 @@ nsTypedSelection::ScrollIntoView(SelectionRegion aRegion, NS_IMETHODIMP -nsTypedSelection::AddSelectionListener(nsISelectionListener* aNewListener) +Selection::AddSelectionListener(nsISelectionListener* aNewListener) { if (!aNewListener) return NS_ERROR_NULL_POINTER; @@ -5437,7 +5387,7 @@ nsTypedSelection::AddSelectionListener(nsISelectionListener* aNewListener) NS_IMETHODIMP -nsTypedSelection::RemoveSelectionListener(nsISelectionListener* aListenerToRemove) +Selection::RemoveSelectionListener(nsISelectionListener* aListenerToRemove) { if (!aListenerToRemove ) return NS_ERROR_NULL_POINTER; @@ -5446,7 +5396,7 @@ nsTypedSelection::RemoveSelectionListener(nsISelectionListener* aListenerToRemov nsresult -nsTypedSelection::NotifySelectionListeners() +Selection::NotifySelectionListeners() { if (!mFrameSelection) return NS_OK;//nothing to do @@ -5473,7 +5423,7 @@ nsTypedSelection::NotifySelectionListeners() } NS_IMETHODIMP -nsTypedSelection::StartBatchChanges() +Selection::StartBatchChanges() { if (mFrameSelection) mFrameSelection->StartBatchChanges(); @@ -5484,7 +5434,7 @@ nsTypedSelection::StartBatchChanges() NS_IMETHODIMP -nsTypedSelection::EndBatchChanges() +Selection::EndBatchChanges() { if (mFrameSelection) mFrameSelection->EndBatchChanges(); @@ -5495,7 +5445,7 @@ nsTypedSelection::EndBatchChanges() NS_IMETHODIMP -nsTypedSelection::DeleteFromDocument() +Selection::DeleteFromDocument() { if (!mFrameSelection) return NS_OK;//nothing to do @@ -5503,8 +5453,8 @@ nsTypedSelection::DeleteFromDocument() } NS_IMETHODIMP -nsTypedSelection::Modify(const nsAString& aAlter, const nsAString& aDirection, - const nsAString& aGranularity) +Selection::Modify(const nsAString& aAlter, const nsAString& aDirection, + const nsAString& aGranularity) { // Silently exit if there's no selection or no focus node. if (!mFrameSelection || !GetAnchorFocusRange() || !GetFocusNode()) { @@ -5623,7 +5573,7 @@ nsTypedSelection::Modify(const nsAString& aAlter, const nsAString& aDirection, * @param aLangRTL is true if the new language is right-to-left or false if the new language is left-to-right */ NS_IMETHODIMP -nsTypedSelection::SelectionLanguageChange(bool aLangRTL) +Selection::SelectionLanguageChange(bool aLangRTL) { if (!mFrameSelection) return NS_ERROR_NOT_INITIALIZED; // Can't do selection @@ -5704,12 +5654,12 @@ nsTypedSelection::SelectionLanguageChange(bool aLangRTL) } NS_IMETHODIMP_(nsDirection) -nsTypedSelection::GetSelectionDirection() { +Selection::GetSelectionDirection() { return mDirection; } NS_IMETHODIMP_(void) -nsTypedSelection::SetSelectionDirection(nsDirection aDirection) { +Selection::SetSelectionDirection(nsDirection aDirection) { mDirection = aDirection; } diff --git a/layout/generic/nsTextFrame.h b/layout/generic/nsTextFrame.h index df2f8da1bbc..1354261736d 100644 --- a/layout/generic/nsTextFrame.h +++ b/layout/generic/nsTextFrame.h @@ -116,7 +116,7 @@ public: * This is called only on the primary text frame. It indicates that * the selection state of the given character range has changed. * Text in the range is unconditionally invalidated - * (nsTypedSelection::Repaint depends on this). + * (Selection::Repaint depends on this). * @param aSelected true if the selection has been added to the range, * false otherwise * @param aType the type of selection added or removed