Bug 762862 - Rename nsTypedSelection to mozilla::Selection; r=ehsan

--HG--
rename : layout/generic/nsTypedSelection.h => layout/generic/Selection.h
This commit is contained in:
Aryeh Gregor 2012-06-08 17:20:55 +03:00
parent d4f110a4ea
commit 6865bb0c16
24 changed files with 273 additions and 310 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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)

View File

@ -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);

View File

@ -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"

View File

@ -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;

View File

@ -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<nsISelection> sel;
nsresult res = GetSelection(getter_AddRefs(sel));

View File

@ -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

View File

@ -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<nsTypedSelection> selection = GetTypedSelection();
nsRefPtr<Selection> 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<nsTypedSelection> selection = GetTypedSelection();
nsRefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
nsTextRulesInfo ruleInfo(aChange < 0 ? kOpDecreaseZIndex :
kOpIncreaseZIndex);

View File

@ -153,7 +153,7 @@ NS_IMETHODIMP nsHTMLEditor::LoadHTML(const nsAString & aInputString)
nsAutoRules beginRulesSniffing(this, kOpLoadHTML, nsIEditor::eNext);
// Get selection
nsRefPtr<nsTypedSelection> selection = GetTypedSelection();
nsRefPtr<Selection> 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<nsTypedSelection> selection = GetTypedSelection();
nsRefPtr<Selection> 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<nsTypedSelection> selection = GetTypedSelection();
nsRefPtr<Selection> 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<nsIDOMNode> newNode;
// get selection
nsRefPtr<nsTypedSelection> selection = GetTypedSelection();
nsRefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
nsAutoEditBatch beginBatching(this);
@ -2019,7 +2019,7 @@ nsHTMLEditor::InsertAsCitedQuotation(const nsAString & aQuotedText,
nsCOMPtr<nsIDOMNode> newNode;
// get selection
nsRefPtr<nsTypedSelection> selection = GetTypedSelection();
nsRefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
nsAutoEditBatch beginBatching(this);

View File

@ -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<nsTypedSelection> selection = mHTMLEditor->GetTypedSelection();
nsRefPtr<Selection> selection = mHTMLEditor->GetSelection();
MOZ_ASSERT(selection);
if (!selection->GetRangeCount()) {
// Nothing to do

View File

@ -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);

View File

@ -1694,7 +1694,7 @@ nsHTMLEditor::InsertElementAtSelection(nsIDOMElement* aElement, bool aDeleteSele
nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, kOpInsertElement, nsIEditor::eNext);
nsRefPtr<nsTypedSelection> selection = GetTypedSelection();
nsRefPtr<Selection> 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<nsTypedSelection> selection = GetTypedSelection();
nsRefPtr<Selection> 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<nsTypedSelection> selection = GetTypedSelection();
nsRefPtr<Selection> 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<nsTypedSelection> selection = GetTypedSelection();
nsRefPtr<Selection> 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<nsTypedSelection> selection = GetTypedSelection();
nsRefPtr<Selection> 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<nsTypedSelection> selection = GetTypedSelection();
nsRefPtr<Selection> 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<nsTypedSelection> selection = GetTypedSelection();
nsRefPtr<Selection> 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<nsTypedSelection> typedSel = GetTypedSelection();
nsRefPtr<Selection> 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<nsIContent> content = do_QueryInterface(typedSel->GetAnchorNode());
nsCOMPtr<nsIContent> 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<nsIEditRules> kungFuDeathGrip(mRules);
nsRefPtr<nsTypedSelection> selection = GetTypedSelection();
nsRefPtr<Selection> selection = GetSelection();
bool isCollapsed = selection->Collapsed();

View File

@ -88,7 +88,7 @@ nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
}
ForceCompositionEnd();
nsRefPtr<nsTypedSelection> selection = GetTypedSelection();
nsRefPtr<Selection> 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<nsTypedSelection> selection = GetTypedSelection();
nsRefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
bool useCSS = IsCSSEnabled();

View File

@ -630,7 +630,7 @@ nsPlaintextEditor::DeleteSelection(EDirection aAction,
nsAutoRules beginRulesSniffing(this, kOpDeleteSelection, aAction);
// pre-process
nsRefPtr<nsTypedSelection> selection = GetTypedSelection();
nsRefPtr<Selection> 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<nsTypedSelection> selection = GetTypedSelection();
nsRefPtr<Selection> 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<nsTypedSelection> selection = GetTypedSelection();
nsRefPtr<Selection> 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<nsTypedSelection> selection = GetTypedSelection();
nsRefPtr<Selection> 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<nsTypedSelection> selection = GetTypedSelection();
nsRefPtr<Selection> 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<nsTypedSelection> selection = GetTypedSelection();
nsRefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
nsAutoEditBatch beginBatching(this);

View File

@ -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<nsTypedSelection> selection = mEditor->GetTypedSelection();
nsRefPtr<Selection> selection = mEditor->GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
PRInt32 start, end;
nsContentUtils::GetSelectionInTextControl(selection, mEditor->GetRoot(),

View File

@ -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,

View File

@ -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"

View File

@ -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<nsTypedSelection> typedSel =
nsRefPtr<Selection> typedSel =
frameSel->GetSelection(nsISelectionController::SELECTION_NORMAL);
NS_ENSURE_TRUE(typedSel, NS_ERROR_FAILURE);

View File

@ -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 \

View File

@ -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__

View File

@ -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<nsTypedSelection> mDomSelections[nsISelectionController::NUM_SELECTIONTYPES];
nsRefPtr<mozilla::Selection> mDomSelections[nsISelectionController::NUM_SELECTIONTYPES];
// Table selection support.
// Interfaces that let us get info based on cellmap locations

File diff suppressed because it is too large Load Diff

View File

@ -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