зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1465702 - part 5: Remove unnecessary Selection argument from editor module r=m_kato
EditorBase::SelectionRefPtr() is now safe to use in editor and really fast to retrieve Selection than EditorBase::GetSelection(). Therefore, we can get rid of all Selection pointer/reference argument of each method which always take normal Selection. Note that this changes nsIHTMLEditor.checkSelectionStateForAnonymousButtons() because its argument is only Selection. So, BlueGriffon should work even though it calls the method with nsIEditor.selection. Differential Revision: https://phabricator.services.mozilla.com/D10009 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
41166eca5f
Коммит
f91716e775
|
@ -453,7 +453,7 @@ CSSEditUtils::SetCSSProperty(Element& aElement,
|
|||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
RefPtr<HTMLEditor> htmlEditor(mHTMLEditor);
|
||||
return htmlEditor->DoTransaction(transaction);
|
||||
return htmlEditor->DoTransactionInternal(transaction);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -485,7 +485,7 @@ CSSEditUtils::RemoveCSSProperty(Element& aElement,
|
|||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
RefPtr<HTMLEditor> htmlEditor(mHTMLEditor);
|
||||
return htmlEditor->DoTransaction(transaction);
|
||||
return htmlEditor->DoTransactionInternal(transaction);
|
||||
}
|
||||
|
||||
// static
|
||||
|
|
|
@ -752,11 +752,11 @@ EditorBase::DoTransaction(nsITransaction* aTxn)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return DoTransaction(nullptr, aTxn);
|
||||
return DoTransactionInternal(aTxn);
|
||||
}
|
||||
|
||||
nsresult
|
||||
EditorBase::DoTransaction(Selection* aSelection, nsITransaction* aTxn)
|
||||
EditorBase::DoTransactionInternal(nsITransaction* aTxn)
|
||||
{
|
||||
if (mPlaceholderBatch && !mPlaceholderTransaction) {
|
||||
mPlaceholderTransaction =
|
||||
|
@ -764,7 +764,7 @@ EditorBase::DoTransaction(Selection* aSelection, nsITransaction* aTxn)
|
|||
MOZ_ASSERT(mSelState.isNothing());
|
||||
|
||||
// We will recurse, but will not hit this case in the nested call
|
||||
DoTransaction(mPlaceholderTransaction);
|
||||
DoTransactionInternal(mPlaceholderTransaction);
|
||||
|
||||
if (mTransactionManager) {
|
||||
nsCOMPtr<nsITransaction> topTransaction =
|
||||
|
@ -806,10 +806,7 @@ EditorBase::DoTransaction(Selection* aSelection, nsITransaction* aTxn)
|
|||
// XXX: re-entry during initial reflow. - kin
|
||||
|
||||
// get the selection and start a batch change
|
||||
RefPtr<Selection> selection = aSelection ? aSelection : GetSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
|
||||
SelectionBatcher selectionBatcher(selection);
|
||||
SelectionBatcher selectionBatcher(SelectionRefPtr());
|
||||
|
||||
nsresult rv;
|
||||
if (mTransactionManager) {
|
||||
|
@ -1065,11 +1062,7 @@ EditorBase::SelectAllInternal()
|
|||
// focus to different element? Although TextEditor has independent
|
||||
// selection, so, we may not see any odd behavior even in such case.
|
||||
|
||||
RefPtr<Selection> selection = GetSelection();
|
||||
if (NS_WARN_IF(!selection)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsresult rv = SelectEntireDocument(selection);
|
||||
nsresult rv = SelectEntireDocument();
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -1118,21 +1111,19 @@ EditorBase::EndOfDocument()
|
|||
if (NS_WARN_IF(!editActionData.CanHandle())) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
return CollapseSelectionToEnd(SelectionRefPtr());
|
||||
return CollapseSelectionToEnd();
|
||||
}
|
||||
|
||||
nsresult
|
||||
EditorBase::CollapseSelectionToEnd(Selection* aSelection)
|
||||
EditorBase::CollapseSelectionToEnd()
|
||||
{
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
// XXX Why doesn't this check if the document is alive?
|
||||
if (NS_WARN_IF(!IsInitialized())) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(!aSelection)) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
// get the root element
|
||||
nsINode* node = GetRoot();
|
||||
if (NS_WARN_IF(!node)) {
|
||||
|
@ -1146,7 +1137,7 @@ EditorBase::CollapseSelectionToEnd(Selection* aSelection)
|
|||
}
|
||||
|
||||
uint32_t length = node->Length();
|
||||
return aSelection->Collapse(node, static_cast<int32_t>(length));
|
||||
return SelectionRefPtr()->Collapse(node, static_cast<int32_t>(length));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -1275,7 +1266,7 @@ EditorBase::SetAttributeWithTransaction(Element& aElement,
|
|||
{
|
||||
RefPtr<ChangeAttributeTransaction> transaction =
|
||||
ChangeAttributeTransaction::Create(aElement, aAttribute, aValue);
|
||||
return DoTransaction(transaction);
|
||||
return DoTransactionInternal(transaction);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -1327,7 +1318,7 @@ EditorBase::RemoveAttributeWithTransaction(Element& aElement,
|
|||
// which does nothing at doing undo/redo.
|
||||
RefPtr<ChangeAttributeTransaction> transaction =
|
||||
ChangeAttributeTransaction::CreateToRemove(aElement, aAttribute);
|
||||
return DoTransaction(transaction);
|
||||
return DoTransactionInternal(transaction);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -1439,7 +1430,7 @@ EditorBase::CreateNodeWithTransaction(
|
|||
|
||||
RefPtr<CreateElementTransaction> transaction =
|
||||
CreateElementTransaction::Create(*this, aTagName, aPointToInsert);
|
||||
nsresult rv = DoTransaction(transaction);
|
||||
nsresult rv = DoTransactionInternal(transaction);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
// XXX Why do we do this even when DoTransaction() returned error?
|
||||
mRangeUpdater.SelAdjCreateNode(aPointToInsert);
|
||||
|
@ -1521,7 +1512,7 @@ EditorBase::InsertNodeWithTransaction(
|
|||
|
||||
RefPtr<InsertNodeTransaction> transaction =
|
||||
InsertNodeTransaction::Create(*this, aContentToInsert, aPointToInsert);
|
||||
nsresult rv = DoTransaction(transaction);
|
||||
nsresult rv = DoTransactionInternal(transaction);
|
||||
|
||||
mRangeUpdater.SelAdjInsertNode(aPointToInsert);
|
||||
|
||||
|
@ -1595,7 +1586,7 @@ EditorBase::SplitNodeWithTransaction(
|
|||
|
||||
RefPtr<SplitNodeTransaction> transaction =
|
||||
SplitNodeTransaction::Create(*this, aStartOfRightNode);
|
||||
aError = DoTransaction(transaction);
|
||||
aError = DoTransactionInternal(transaction);
|
||||
|
||||
nsCOMPtr<nsIContent> newNode = transaction->GetNewNode();
|
||||
NS_WARNING_ASSERTION(newNode, "Failed to create a new left node");
|
||||
|
@ -1680,7 +1671,7 @@ EditorBase::JoinNodesWithTransaction(nsINode& aLeftNode,
|
|||
RefPtr<JoinNodeTransaction> transaction =
|
||||
JoinNodeTransaction::MaybeCreate(*this, aLeftNode, aRightNode);
|
||||
if (transaction) {
|
||||
rv = DoTransaction(transaction);
|
||||
rv = DoTransactionInternal(transaction);
|
||||
}
|
||||
|
||||
// XXX Some other transactions manage range updater by themselves.
|
||||
|
@ -1754,8 +1745,9 @@ EditorBase::DeleteNodeWithTransaction(nsINode& aNode)
|
|||
// to refer aNode even after calling DoTransaction().
|
||||
RefPtr<DeleteNodeTransaction> deleteNodeTransaction =
|
||||
DeleteNodeTransaction::MaybeCreate(*this, aNode);
|
||||
nsresult rv = deleteNodeTransaction ? DoTransaction(deleteNodeTransaction) :
|
||||
NS_ERROR_FAILURE;
|
||||
nsresult rv =
|
||||
deleteNodeTransaction ? DoTransactionInternal(deleteNodeTransaction) :
|
||||
NS_ERROR_FAILURE;
|
||||
|
||||
if (mTextServicesDocument && NS_SUCCEEDED(rv)) {
|
||||
RefPtr<TextServicesDocument> textServicesDocument = mTextServicesDocument;
|
||||
|
@ -2385,19 +2377,23 @@ EditorBase::ArePreservingSelection()
|
|||
}
|
||||
|
||||
void
|
||||
EditorBase::PreserveSelectionAcrossActions(Selection* aSel)
|
||||
EditorBase::PreserveSelectionAcrossActions()
|
||||
{
|
||||
mSavedSel.SaveSelection(aSel);
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
mSavedSel.SaveSelection(SelectionRefPtr());
|
||||
mRangeUpdater.RegisterSelectionState(mSavedSel);
|
||||
}
|
||||
|
||||
nsresult
|
||||
EditorBase::RestorePreservedSelection(Selection* aSel)
|
||||
EditorBase::RestorePreservedSelection()
|
||||
{
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
if (mSavedSel.IsEmpty()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mSavedSel.RestoreSelection(aSel);
|
||||
mSavedSel.RestoreSelection(SelectionRefPtr());
|
||||
StopPreservingSelection();
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2851,7 +2847,7 @@ EditorBase::InsertTextIntoTextNodeWithTransaction(
|
|||
// XXX We may not need these view batches anymore. This is handled at a
|
||||
// higher level now I believe.
|
||||
BeginUpdateViewBatch();
|
||||
nsresult rv = DoTransaction(transaction);
|
||||
nsresult rv = DoTransactionInternal(transaction);
|
||||
EndUpdateViewBatch();
|
||||
|
||||
if (mRules && mRules->AsHTMLEditRules() && insertedTextNode) {
|
||||
|
@ -2897,11 +2893,9 @@ EditorBase::InsertTextIntoTextNodeWithTransaction(
|
|||
}
|
||||
|
||||
nsresult
|
||||
EditorBase::SelectEntireDocument(Selection* aSelection)
|
||||
EditorBase::SelectEntireDocument()
|
||||
{
|
||||
if (!aSelection) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
Element* rootElement = GetRoot();
|
||||
if (!rootElement) {
|
||||
|
@ -2909,7 +2903,7 @@ EditorBase::SelectEntireDocument(Selection* aSelection)
|
|||
}
|
||||
|
||||
ErrorResult errorResult;
|
||||
aSelection->SelectAllChildren(*rootElement, errorResult);
|
||||
SelectionRefPtr()->SelectAllChildren(*rootElement, errorResult);
|
||||
return errorResult.StealNSResult();
|
||||
}
|
||||
|
||||
|
@ -2984,9 +2978,11 @@ EditorBase::NotifyDocumentListeners(
|
|||
}
|
||||
|
||||
nsresult
|
||||
EditorBase::SetTextImpl(Selection& aSelection, const nsAString& aString,
|
||||
EditorBase::SetTextImpl(const nsAString& aString,
|
||||
Text& aCharData)
|
||||
{
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
const uint32_t length = aCharData.Length();
|
||||
|
||||
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
|
||||
|
@ -3011,14 +3007,10 @@ EditorBase::SetTextImpl(Selection& aSelection, const nsAString& aString,
|
|||
return rv;
|
||||
}
|
||||
|
||||
RefPtr<Selection> selection = GetSelection();
|
||||
if (NS_WARN_IF(!selection)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
{
|
||||
// Create a nested scope to not overwrite rv from the outer scope.
|
||||
DebugOnly<nsresult> rv = selection->Collapse(&aCharData, aString.Length());
|
||||
DebugOnly<nsresult> rv =
|
||||
SelectionRefPtr()->Collapse(&aCharData, aString.Length());
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv),
|
||||
"Selection could not be collapsed after insert");
|
||||
}
|
||||
|
@ -3029,10 +3021,10 @@ EditorBase::SetTextImpl(Selection& aSelection, const nsAString& aString,
|
|||
if (mRules && mRules->AsHTMLEditRules()) {
|
||||
RefPtr<HTMLEditRules> htmlEditRules = mRules->AsHTMLEditRules();
|
||||
if (length) {
|
||||
htmlEditRules->DidDeleteText(*selection, aCharData, 0, length);
|
||||
htmlEditRules->DidDeleteText(*SelectionRefPtr(), aCharData, 0, length);
|
||||
}
|
||||
if (!aString.IsEmpty()) {
|
||||
htmlEditRules->DidInsertText(*selection, aCharData, 0, aString);
|
||||
htmlEditRules->DidInsertText(*SelectionRefPtr(), aCharData, 0, aString);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3075,7 +3067,7 @@ EditorBase::DeleteTextWithTransaction(CharacterData& aCharData,
|
|||
}
|
||||
}
|
||||
|
||||
nsresult rv = DoTransaction(transaction);
|
||||
nsresult rv = DoTransactionInternal(transaction);
|
||||
|
||||
if (mRules && mRules->AsHTMLEditRules()) {
|
||||
RefPtr<Selection> selection = GetSelection();
|
||||
|
@ -3950,15 +3942,13 @@ EditorBase::GetNodeAtRangeOffsetPoint(const RawRangeBoundary& aPoint)
|
|||
|
||||
// static
|
||||
EditorRawDOMPoint
|
||||
EditorBase::GetStartPoint(Selection* aSelection)
|
||||
EditorBase::GetStartPoint(const Selection& aSelection)
|
||||
{
|
||||
MOZ_ASSERT(aSelection);
|
||||
|
||||
if (NS_WARN_IF(!aSelection->RangeCount())) {
|
||||
if (NS_WARN_IF(!aSelection.RangeCount())) {
|
||||
return EditorRawDOMPoint();
|
||||
}
|
||||
|
||||
const nsRange* range = aSelection->GetRangeAt(0);
|
||||
const nsRange* range = aSelection.GetRangeAt(0);
|
||||
if (NS_WARN_IF(!range) ||
|
||||
NS_WARN_IF(!range->IsPositioned())) {
|
||||
return EditorRawDOMPoint();
|
||||
|
@ -3969,15 +3959,13 @@ EditorBase::GetStartPoint(Selection* aSelection)
|
|||
|
||||
// static
|
||||
EditorRawDOMPoint
|
||||
EditorBase::GetEndPoint(Selection* aSelection)
|
||||
EditorBase::GetEndPoint(const Selection& aSelection)
|
||||
{
|
||||
MOZ_ASSERT(aSelection);
|
||||
|
||||
if (NS_WARN_IF(!aSelection->RangeCount())) {
|
||||
if (NS_WARN_IF(!aSelection.RangeCount())) {
|
||||
return EditorRawDOMPoint();
|
||||
}
|
||||
|
||||
const nsRange* range = aSelection->GetRangeAt(0);
|
||||
const nsRange* range = aSelection.GetRangeAt(0);
|
||||
if (NS_WARN_IF(!range) ||
|
||||
NS_WARN_IF(!range->IsPositioned())) {
|
||||
return EditorRawDOMPoint();
|
||||
|
@ -3986,20 +3974,20 @@ EditorBase::GetEndPoint(Selection* aSelection)
|
|||
return EditorRawDOMPoint(range->EndRef());
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult
|
||||
EditorBase::GetEndChildNode(Selection* aSelection,
|
||||
EditorBase::GetEndChildNode(const Selection& aSelection,
|
||||
nsIContent** aEndNode)
|
||||
{
|
||||
MOZ_ASSERT(aSelection);
|
||||
MOZ_ASSERT(aEndNode);
|
||||
|
||||
*aEndNode = nullptr;
|
||||
|
||||
if (NS_WARN_IF(!aSelection->RangeCount())) {
|
||||
if (NS_WARN_IF(!aSelection.RangeCount())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
const nsRange* range = aSelection->GetRangeAt(0);
|
||||
const nsRange* range = aSelection.GetRangeAt(0);
|
||||
if (NS_WARN_IF(!range)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -4245,7 +4233,7 @@ EditorBase::EndUpdateViewBatch()
|
|||
return;
|
||||
}
|
||||
|
||||
DebugOnly<nsresult> rv = htmlEditor->RefereshEditingUI(*selection);
|
||||
DebugOnly<nsresult> rv = htmlEditor->RefereshEditingUI();
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "RefereshEditingUI() failed");
|
||||
}
|
||||
|
||||
|
@ -4706,7 +4694,6 @@ EditorBase::HandleKeyPressEvent(WidgetKeyboardEvent* aKeyboardEvent)
|
|||
|
||||
nsresult
|
||||
EditorBase::HandleInlineSpellCheck(EditSubAction aEditSubAction,
|
||||
Selection& aSelection,
|
||||
nsINode* previousSelectedNode,
|
||||
uint32_t previousSelectedOffset,
|
||||
nsINode* aStartContainer,
|
||||
|
@ -4714,11 +4701,13 @@ EditorBase::HandleInlineSpellCheck(EditSubAction aEditSubAction,
|
|||
nsINode* aEndContainer,
|
||||
uint32_t aEndOffset)
|
||||
{
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
if (!mInlineSpellChecker) {
|
||||
return NS_OK;
|
||||
}
|
||||
return mInlineSpellChecker->SpellCheckAfterEditorChange(
|
||||
aEditSubAction, aSelection,
|
||||
aEditSubAction, *SelectionRefPtr(),
|
||||
previousSelectedNode, previousSelectedOffset,
|
||||
aStartContainer, aStartOffset, aEndContainer,
|
||||
aEndOffset);
|
||||
|
@ -4731,10 +4720,11 @@ EditorBase::FindSelectionRoot(nsINode* aNode) const
|
|||
}
|
||||
|
||||
void
|
||||
EditorBase::InitializeSelectionAncestorLimit(Selection& aSelection,
|
||||
nsIContent& aAncestorLimit)
|
||||
EditorBase::InitializeSelectionAncestorLimit(nsIContent& aAncestorLimit)
|
||||
{
|
||||
aSelection.SetAncestorLimiter(&aAncestorLimit);
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
SelectionRefPtr()->SetAncestorLimiter(&aAncestorLimit);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -4781,7 +4771,7 @@ EditorBase::InitializeSelection(EventTarget* aFocusEventTarget)
|
|||
// NOTE: If we set a root element to the ancestor limit, some selection
|
||||
// methods don't work fine.
|
||||
if (selectionRootContent->GetParent()) {
|
||||
InitializeSelectionAncestorLimit(*selection, *selectionRootContent);
|
||||
InitializeSelectionAncestorLimit(*selectionRootContent);
|
||||
} else {
|
||||
selection->SetAncestorLimiter(nullptr);
|
||||
}
|
||||
|
@ -5266,7 +5256,6 @@ EditorBase::HideCaret(bool aHide)
|
|||
*****************************************************************************/
|
||||
|
||||
EditorBase::AutoSelectionRestorer::AutoSelectionRestorer(
|
||||
Selection& aSelection,
|
||||
EditorBase& aEditorBase
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
|
||||
: mEditorBase(nullptr)
|
||||
|
@ -5276,27 +5265,22 @@ EditorBase::AutoSelectionRestorer::AutoSelectionRestorer(
|
|||
// We already have initialized mSavedSel, so this must be nested call.
|
||||
return;
|
||||
}
|
||||
mSelection = &aSelection;
|
||||
MOZ_ASSERT(aEditorBase.IsEditActionDataAvailable());
|
||||
mEditorBase = &aEditorBase;
|
||||
mEditorBase->PreserveSelectionAcrossActions(mSelection);
|
||||
mEditorBase->PreserveSelectionAcrossActions();
|
||||
}
|
||||
|
||||
EditorBase::AutoSelectionRestorer::~AutoSelectionRestorer()
|
||||
{
|
||||
NS_ASSERTION(!mSelection || mEditorBase,
|
||||
"mEditorBase should be non-null when mSelection is");
|
||||
// mSelection will be null if this was nested call.
|
||||
if (mSelection && mEditorBase->ArePreservingSelection()) {
|
||||
mEditorBase->RestorePreservedSelection(mSelection);
|
||||
if (mEditorBase && mEditorBase->ArePreservingSelection()) {
|
||||
mEditorBase->RestorePreservedSelection();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
EditorBase::AutoSelectionRestorer::Abort()
|
||||
{
|
||||
NS_ASSERTION(!mSelection || mEditorBase,
|
||||
"mEditorBase should be non-null when mSelection is");
|
||||
if (mSelection) {
|
||||
if (mEditorBase) {
|
||||
mEditorBase->StopPreservingSelection();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -803,8 +803,7 @@ protected: // May be called by friends.
|
|||
Text& aTextNode, int32_t aOffset,
|
||||
bool aSuppressIME = false);
|
||||
|
||||
nsresult SetTextImpl(Selection& aSelection,
|
||||
const nsAString& aString,
|
||||
nsresult SetTextImpl(const nsAString& aString,
|
||||
Text& aTextNode);
|
||||
|
||||
/**
|
||||
|
@ -1316,11 +1315,7 @@ protected: // May be called by friends.
|
|||
EditorDOMPoint JoinNodesDeepWithTransaction(nsIContent& aLeftNode,
|
||||
nsIContent& aRightNode);
|
||||
|
||||
/**
|
||||
* Note that aSelection is optional and can be nullptr.
|
||||
*/
|
||||
nsresult DoTransaction(Selection* aSelection,
|
||||
nsITransaction* aTxn);
|
||||
nsresult DoTransactionInternal(nsITransaction* aTxn);
|
||||
|
||||
virtual bool IsBlockNode(nsINode* aNode);
|
||||
|
||||
|
@ -1602,16 +1597,16 @@ protected: // May be called by friends.
|
|||
}
|
||||
static nsIContent* GetNodeAtRangeOffsetPoint(const RawRangeBoundary& aPoint);
|
||||
|
||||
static EditorRawDOMPoint GetStartPoint(Selection* aSelection);
|
||||
static EditorRawDOMPoint GetEndPoint(Selection* aSelection);
|
||||
static EditorRawDOMPoint GetStartPoint(const Selection& aSelection);
|
||||
static EditorRawDOMPoint GetEndPoint(const Selection& aSelection);
|
||||
|
||||
static nsresult GetEndChildNode(Selection* aSelection,
|
||||
static nsresult GetEndChildNode(const Selection& aSelection,
|
||||
nsIContent** aEndNode);
|
||||
|
||||
/**
|
||||
* CollapseSelectionToEnd() collapses the selection to the end of the editor.
|
||||
*/
|
||||
nsresult CollapseSelectionToEnd(Selection* aSelection);
|
||||
nsresult CollapseSelectionToEnd();
|
||||
|
||||
/**
|
||||
* Helpers to add a node to the selection.
|
||||
|
@ -1644,7 +1639,6 @@ protected: // May be called by friends.
|
|||
}
|
||||
|
||||
nsresult HandleInlineSpellCheck(EditSubAction aEditSubAction,
|
||||
Selection& aSelection,
|
||||
nsINode* previousSelectedNode,
|
||||
uint32_t previousSelectedOffset,
|
||||
nsINode* aStartContainer,
|
||||
|
@ -1720,8 +1714,8 @@ protected: // Called by helper classes.
|
|||
* various editor actions.
|
||||
*/
|
||||
bool ArePreservingSelection();
|
||||
void PreserveSelectionAcrossActions(Selection* aSel);
|
||||
nsresult RestorePreservedSelection(Selection* aSel);
|
||||
void PreserveSelectionAcrossActions();
|
||||
nsresult RestorePreservedSelection();
|
||||
void StopPreservingSelection();
|
||||
|
||||
/**
|
||||
|
@ -1802,7 +1796,7 @@ protected: // Shouldn't be used by friend classes
|
|||
/**
|
||||
* Make the given selection span the entire document.
|
||||
*/
|
||||
virtual nsresult SelectEntireDocument(Selection* aSelection);
|
||||
virtual nsresult SelectEntireDocument();
|
||||
|
||||
/**
|
||||
* Helper method for scrolling the selection into view after
|
||||
|
@ -1908,15 +1902,13 @@ protected: // Shouldn't be used by friend classes
|
|||
/**
|
||||
* InitializeSelectionAncestorLimit() is called by InitializeSelection().
|
||||
* When this is called, each implementation has to call
|
||||
* aSelection.SetAncestorLimiter() with aAnotherLimit.
|
||||
* Selection::SetAncestorLimiter() with aAnotherLimit.
|
||||
*
|
||||
* @param aSelection The selection.
|
||||
* @param aAncestorLimit New ancestor limit of aSelection. This always
|
||||
* @param aAncestorLimit New ancestor limit of Selection. This always
|
||||
* has parent node. So, it's always safe to
|
||||
* call SetAncestorLimit() with this node.
|
||||
*/
|
||||
virtual void InitializeSelectionAncestorLimit(Selection& aSelection,
|
||||
nsIContent& aAncestorLimit);
|
||||
virtual void InitializeSelectionAncestorLimit(nsIContent& aAncestorLimit);
|
||||
|
||||
/**
|
||||
* Return the offset of aChild in aParent. Asserts fatally if parent or
|
||||
|
@ -2051,9 +2043,8 @@ protected: // helper classes which may be used by friends
|
|||
* Constructor responsible for remembering all state needed to restore
|
||||
* aSelection.
|
||||
*/
|
||||
AutoSelectionRestorer(Selection& aSelection,
|
||||
EditorBase& aEditorBase
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
|
||||
explicit AutoSelectionRestorer(EditorBase& aEditorBase
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
|
||||
|
||||
/**
|
||||
* Destructor restores mSelection to its former state
|
||||
|
@ -2066,7 +2057,6 @@ protected: // helper classes which may be used by friends
|
|||
void Abort();
|
||||
|
||||
protected:
|
||||
RefPtr<Selection> mSelection;
|
||||
EditorBase* mEditorBase;
|
||||
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
|
|
@ -90,7 +90,7 @@ HTMLEditor::GetAbsolutelyPositionedSelectionContainer()
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<Element> element = GetSelectionContainerElement(*SelectionRefPtr());
|
||||
RefPtr<Element> element = GetSelectionContainerElement();
|
||||
if (NS_WARN_IF(!element)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -473,11 +473,7 @@ HTMLEditor::EndMoving()
|
|||
|
||||
mGrabberClicked = false;
|
||||
mIsMoving = false;
|
||||
RefPtr<Selection> selection = GetSelection();
|
||||
if (!selection) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
nsresult rv = RefereshEditingUI(*selection);
|
||||
nsresult rv = RefereshEditingUI();
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -582,8 +578,7 @@ HTMLEditor::SetPositionToAbsolute(Element& aElement)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
RefPtr<Element> newBrElement =
|
||||
InsertBrElementWithTransaction(*selection,
|
||||
EditorRawDOMPoint(parentNode, 0));
|
||||
InsertBrElementWithTransaction(EditorRawDOMPoint(parentNode, 0));
|
||||
if (NS_WARN_IF(!newBrElement)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
|
|
@ -328,18 +328,14 @@ HTMLEditor::HideAnonymousEditingUIsIfUnnecessary()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLEditor::CheckSelectionStateForAnonymousButtons(Selection* aSelection)
|
||||
HTMLEditor::CheckSelectionStateForAnonymousButtons()
|
||||
{
|
||||
if (NS_WARN_IF(!aSelection)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
AutoEditActionDataSetter editActionData(*this, EditAction::eNotEditing);
|
||||
if (NS_WARN_IF(!editActionData.CanHandle())) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
nsresult rv = RefereshEditingUI(*aSelection);
|
||||
nsresult rv = RefereshEditingUI();
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -347,8 +343,10 @@ HTMLEditor::CheckSelectionStateForAnonymousButtons(Selection* aSelection)
|
|||
}
|
||||
|
||||
nsresult
|
||||
HTMLEditor::RefereshEditingUI(Selection& aSelection)
|
||||
HTMLEditor::RefereshEditingUI()
|
||||
{
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
// First, we need to remove unnecessary editing UI now since some of them
|
||||
// may be disabled while them are visible.
|
||||
HideAnonymousEditingUIsIfUnnecessary();
|
||||
|
@ -366,7 +364,7 @@ HTMLEditor::RefereshEditingUI(Selection& aSelection)
|
|||
}
|
||||
|
||||
// let's get the containing element of the selection
|
||||
RefPtr<Element> focusElement = GetSelectionContainerElement(aSelection);
|
||||
RefPtr<Element> focusElement = GetSelectionContainerElement();
|
||||
if (NS_WARN_IF(!focusElement)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -390,8 +388,7 @@ HTMLEditor::RefereshEditingUI(Selection& aSelection)
|
|||
if (IsObjectResizerEnabled() || IsInlineTableEditorEnabled()) {
|
||||
// Resizing or Inline Table Editing is enabled, we need to check if the
|
||||
// selection is contained in a table cell
|
||||
cellElement =
|
||||
GetElementOrParentByTagNameAtSelection(aSelection, *nsGkAtoms::td);
|
||||
cellElement = GetElementOrParentByTagNameAtSelection(*nsGkAtoms::td);
|
||||
}
|
||||
|
||||
if (IsObjectResizerEnabled() && cellElement) {
|
||||
|
|
|
@ -181,7 +181,7 @@ public:
|
|||
|
||||
Element* root = aHTMLEditor.FindSelectionRoot(&aStartPointNode);
|
||||
if (root) {
|
||||
aHTMLEditor.InitializeSelectionAncestorLimit(aSelection, *root);
|
||||
aHTMLEditor.InitializeSelectionAncestorLimit(*root);
|
||||
mSelection = &aSelection;
|
||||
}
|
||||
}
|
||||
|
@ -634,7 +634,7 @@ HTMLEditRules::AfterEditInner(EditSubAction aEditSubAction,
|
|||
}
|
||||
}
|
||||
|
||||
rv = HTMLEditorRef().HandleInlineSpellCheck(aEditSubAction, SelectionRef(),
|
||||
rv = HTMLEditorRef().HandleInlineSpellCheck(aEditSubAction,
|
||||
mRangeItem->mStartContainer,
|
||||
mRangeItem->mStartOffset,
|
||||
rangeStartContainer,
|
||||
|
@ -1199,7 +1199,7 @@ HTMLEditRules::GetParagraphState(bool* aMixed,
|
|||
// and put that on the list
|
||||
if (arrayOfNodes.IsEmpty()) {
|
||||
EditorRawDOMPoint selectionStartPoint(
|
||||
EditorBase::GetStartPoint(&SelectionRef()));
|
||||
EditorBase::GetStartPoint(SelectionRef()));
|
||||
if (NS_WARN_IF(!selectionStartPoint.IsSet())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -1528,8 +1528,7 @@ HTMLEditRules::WillInsertText(EditSubAction aEditSubAction,
|
|||
// is it a return?
|
||||
if (subStr.Equals(newlineStr)) {
|
||||
RefPtr<Element> brElement =
|
||||
HTMLEditorRef().InsertBrElementWithTransaction(SelectionRef(),
|
||||
currentPoint,
|
||||
HTMLEditorRef().InsertBrElementWithTransaction(currentPoint,
|
||||
nsIEditor::eNone);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
|
@ -1916,8 +1915,7 @@ HTMLEditRules::WillInsertBreak(bool* aCancel,
|
|||
EditorRawDOMPoint endOfBlockParent;
|
||||
endOfBlockParent.SetToEndOf(blockParent);
|
||||
RefPtr<Element> brElement =
|
||||
HTMLEditorRef().InsertBrElementWithTransaction(SelectionRef(),
|
||||
endOfBlockParent);
|
||||
HTMLEditorRef().InsertBrElementWithTransaction(endOfBlockParent);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -2012,8 +2010,7 @@ HTMLEditRules::InsertBRElement(const EditorDOMPoint& aPointToBreak)
|
|||
RefPtr<Element> brElement;
|
||||
if (IsPlaintextEditor()) {
|
||||
brElement =
|
||||
HTMLEditorRef().InsertBrElementWithTransaction(SelectionRef(),
|
||||
aPointToBreak);
|
||||
HTMLEditorRef().InsertBrElementWithTransaction(aPointToBreak);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -2153,7 +2150,7 @@ HTMLEditRules::SplitMailCites(bool* aHandled)
|
|||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
EditorRawDOMPoint pointToSplit(EditorBase::GetStartPoint(&SelectionRef()));
|
||||
EditorRawDOMPoint pointToSplit(EditorBase::GetStartPoint(SelectionRef()));
|
||||
if (NS_WARN_IF(!pointToSplit.IsSet())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -2227,7 +2224,6 @@ HTMLEditRules::SplitMailCites(bool* aHandled)
|
|||
endOfPreviousNodeOfSplitPoint.SetToEndOf(previousNodeOfSplitPoint);
|
||||
RefPtr<Element> invisibleBrElement =
|
||||
HTMLEditorRef().InsertBrElementWithTransaction(
|
||||
SelectionRef(),
|
||||
endOfPreviousNodeOfSplitPoint);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
|
@ -2242,8 +2238,7 @@ HTMLEditRules::SplitMailCites(bool* aHandled)
|
|||
// cite node, <br> should be inserted before the current cite.
|
||||
EditorRawDOMPoint pointToInsertBrNode(splitCiteNodeResult.SplitPoint());
|
||||
RefPtr<Element> brElement =
|
||||
HTMLEditorRef().InsertBrElementWithTransaction(SelectionRef(),
|
||||
pointToInsertBrNode);
|
||||
HTMLEditorRef().InsertBrElementWithTransaction(pointToInsertBrNode);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -2297,7 +2292,7 @@ HTMLEditRules::SplitMailCites(bool* aHandled)
|
|||
wsType == WSType::thisBlock) {
|
||||
brElement =
|
||||
HTMLEditorRef().InsertBrElementWithTransaction(
|
||||
SelectionRef(), pointToCreateNewBrNode);
|
||||
pointToCreateNewBrNode);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -2383,8 +2378,7 @@ HTMLEditRules::WillDeleteSelection(nsIEditor::EDirection aAction,
|
|||
// First check for table selection mode. If so, hand off to table editor.
|
||||
ErrorResult error;
|
||||
RefPtr<Element> cellElement =
|
||||
HTMLEditorRef().GetFirstSelectedTableCellElement(SelectionRef(),
|
||||
error);
|
||||
HTMLEditorRef().GetFirstSelectedTableCellElement(error);
|
||||
if (cellElement) {
|
||||
error.SuppressException();
|
||||
nsresult rv = HTMLEditorRef().DeleteTableCellContentsWithTransaction();
|
||||
|
@ -2407,7 +2401,7 @@ HTMLEditRules::WillDeleteSelection(nsIEditor::EDirection aAction,
|
|||
bool origCollapsed = SelectionRef().IsCollapsed();
|
||||
|
||||
if (origCollapsed) {
|
||||
EditorDOMPoint startPoint(EditorBase::GetStartPoint(&SelectionRef()));
|
||||
EditorDOMPoint startPoint(EditorBase::GetStartPoint(SelectionRef()));
|
||||
if (NS_WARN_IF(!startPoint.IsSet())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -2447,7 +2441,7 @@ HTMLEditRules::WillDeleteSelection(nsIEditor::EDirection aAction,
|
|||
AutoSetTemporaryAncestorLimiter autoSetter(HTMLEditorRef(), SelectionRef(),
|
||||
*startPoint.GetContainer());
|
||||
|
||||
rv = HTMLEditorRef().ExtendSelectionForDelete(&SelectionRef(), &aAction);
|
||||
rv = HTMLEditorRef().ExtendSelectionForDelete(&aAction);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -2461,7 +2455,7 @@ HTMLEditRules::WillDeleteSelection(nsIEditor::EDirection aAction,
|
|||
if (SelectionRef().IsCollapsed()) {
|
||||
// ExtendSelectionForDelete() won't change the selection.
|
||||
|
||||
EditorDOMPoint startPoint(EditorBase::GetStartPoint(&SelectionRef()));
|
||||
EditorDOMPoint startPoint(EditorBase::GetStartPoint(SelectionRef()));
|
||||
if (NS_WARN_IF(!startPoint.IsSet())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -3276,7 +3270,7 @@ HTMLEditRules::InsertBRIfNeeded()
|
|||
MOZ_ASSERT(IsEditorDataAvailable());
|
||||
|
||||
EditorRawDOMPoint atStartOfSelection(
|
||||
EditorBase::GetStartPoint(&SelectionRef()));
|
||||
EditorBase::GetStartPoint(SelectionRef()));
|
||||
if (NS_WARN_IF(!atStartOfSelection.IsSet())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -3296,8 +3290,7 @@ HTMLEditRules::InsertBRIfNeeded()
|
|||
if (HTMLEditorRef().CanContainTag(*atStartOfSelection.GetContainer(),
|
||||
*nsGkAtoms::br)) {
|
||||
RefPtr<Element> brElement =
|
||||
HTMLEditorRef().InsertBrElementWithTransaction(SelectionRef(),
|
||||
atStartOfSelection,
|
||||
HTMLEditorRef().InsertBrElementWithTransaction(atStartOfSelection,
|
||||
nsIEditor::ePrevious);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
|
@ -3900,7 +3893,7 @@ HTMLEditRules::DidDeleteSelection()
|
|||
MOZ_ASSERT(IsEditorDataAvailable());
|
||||
|
||||
// find where we are
|
||||
EditorDOMPoint atStartOfSelection(EditorBase::GetStartPoint(&SelectionRef()));
|
||||
EditorDOMPoint atStartOfSelection(EditorBase::GetStartPoint(SelectionRef()));
|
||||
if (NS_WARN_IF(!atStartOfSelection.IsSet())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -3926,8 +3919,7 @@ HTMLEditRules::DidDeleteSelection()
|
|||
}
|
||||
if (atCiteNode.IsSet() && seenBR) {
|
||||
RefPtr<Element> brElement =
|
||||
HTMLEditorRef().InsertBrElementWithTransaction(SelectionRef(),
|
||||
atCiteNode);
|
||||
HTMLEditorRef().InsertBrElementWithTransaction(atCiteNode);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -4022,7 +4014,7 @@ HTMLEditRules::MakeList(nsAtom& aListType,
|
|||
bool* aCancel,
|
||||
nsAtom& aItemType)
|
||||
{
|
||||
AutoSelectionRestorer restoreSelectionLater(SelectionRef(), HTMLEditorRef());
|
||||
AutoSelectionRestorer restoreSelectionLater(HTMLEditorRef());
|
||||
|
||||
nsTArray<OwningNonNull<nsINode>> arrayOfNodes;
|
||||
nsresult rv =
|
||||
|
@ -4437,7 +4429,7 @@ HTMLEditRules::WillRemoveList(bool* aCancel,
|
|||
return rv;
|
||||
}
|
||||
|
||||
AutoSelectionRestorer restoreSelectionLater(SelectionRef(), HTMLEditorRef());
|
||||
AutoSelectionRestorer restoreSelectionLater(HTMLEditorRef());
|
||||
|
||||
nsTArray<RefPtr<nsRange>> arrayOfRanges;
|
||||
GetPromotedRanges(arrayOfRanges, EditSubAction::eCreateOrChangeList);
|
||||
|
@ -4541,7 +4533,7 @@ HTMLEditRules::MakeBasicBlock(nsAtom& blockType)
|
|||
return rv;
|
||||
}
|
||||
|
||||
AutoSelectionRestorer restoreSelectionLater(SelectionRef(), HTMLEditorRef());
|
||||
AutoSelectionRestorer restoreSelectionLater(HTMLEditorRef());
|
||||
AutoTransactionsConserveSelection dontChangeMySelection(HTMLEditorRef());
|
||||
|
||||
// Contruct a list of nodes to act on.
|
||||
|
@ -4601,8 +4593,7 @@ HTMLEditRules::MakeBasicBlock(nsAtom& blockType)
|
|||
EditorRawDOMPoint pointToInsertBrNode(splitNodeResult.SplitPoint());
|
||||
// Put a <br> element at the split point
|
||||
brContent =
|
||||
HTMLEditorRef().InsertBrElementWithTransaction(SelectionRef(),
|
||||
pointToInsertBrNode);
|
||||
HTMLEditorRef().InsertBrElementWithTransaction(pointToInsertBrNode);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -4793,7 +4784,7 @@ HTMLEditRules::IndentAroundSelectionWithCSS()
|
|||
{
|
||||
MOZ_ASSERT(IsEditorDataAvailable());
|
||||
|
||||
AutoSelectionRestorer restoreSelectionLater(SelectionRef(), HTMLEditorRef());
|
||||
AutoSelectionRestorer restoreSelectionLater(HTMLEditorRef());
|
||||
nsTArray<OwningNonNull<nsRange>> arrayOfRanges;
|
||||
nsTArray<OwningNonNull<nsINode>> arrayOfNodes;
|
||||
|
||||
|
@ -4803,7 +4794,7 @@ HTMLEditRules::IndentAroundSelectionWithCSS()
|
|||
nsCOMPtr<Element> liNode;
|
||||
if (SelectionRef().IsCollapsed()) {
|
||||
EditorRawDOMPoint selectionStartPoint(
|
||||
EditorBase::GetStartPoint(&SelectionRef()));
|
||||
EditorBase::GetStartPoint(SelectionRef()));
|
||||
if (NS_WARN_IF(!selectionStartPoint.IsSet())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -5097,7 +5088,7 @@ HTMLEditRules::IndentAroundSelectionWithHTML()
|
|||
{
|
||||
MOZ_ASSERT(IsEditorDataAvailable());
|
||||
|
||||
AutoSelectionRestorer restoreSelectionLater(SelectionRef(), HTMLEditorRef());
|
||||
AutoSelectionRestorer restoreSelectionLater(HTMLEditorRef());
|
||||
|
||||
// convert the selection ranges into "promoted" selection ranges:
|
||||
// this basically just expands the range to include the immediate
|
||||
|
@ -5477,7 +5468,7 @@ HTMLEditRules::OutdentAroundSelection()
|
|||
{
|
||||
MOZ_ASSERT(IsEditorDataAvailable());
|
||||
|
||||
AutoSelectionRestorer restoreSelectionLater(SelectionRef(), HTMLEditorRef());
|
||||
AutoSelectionRestorer restoreSelectionLater(HTMLEditorRef());
|
||||
|
||||
bool useCSS = HTMLEditorRef().IsCSSEnabled();
|
||||
|
||||
|
@ -6117,7 +6108,7 @@ HTMLEditRules::WillAlign(const nsAString& aAlignType,
|
|||
nsresult
|
||||
HTMLEditRules::AlignContentsAtSelection(const nsAString& aAlignType)
|
||||
{
|
||||
AutoSelectionRestorer restoreSelectionLater(SelectionRef(), HTMLEditorRef());
|
||||
AutoSelectionRestorer restoreSelectionLater(HTMLEditorRef());
|
||||
|
||||
// Convert the selection ranges into "promoted" selection ranges: This
|
||||
// basically just expands the range to include the immediate block parent,
|
||||
|
@ -6547,8 +6538,7 @@ HTMLEditRules::MaybeDeleteTopMostEmptyAncestor(nsINode& aStartNode,
|
|||
// AfterEdit().
|
||||
if (!HTMLEditUtils::IsList(atBlockParent.GetContainer())) {
|
||||
RefPtr<Element> brElement =
|
||||
HTMLEditorRef().InsertBrElementWithTransaction(SelectionRef(),
|
||||
atBlockParent);
|
||||
HTMLEditorRef().InsertBrElementWithTransaction(atBlockParent);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -8092,7 +8082,7 @@ HTMLEditRules::ReturnInHeader(Element& aHeader,
|
|||
// Append a <br> to it
|
||||
RefPtr<Element> brElement =
|
||||
HTMLEditorRef().InsertBrElementWithTransaction(
|
||||
SelectionRef(), EditorRawDOMPoint(pNode, 0));
|
||||
EditorRawDOMPoint(pNode, 0));
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -8310,8 +8300,7 @@ HTMLEditRules::ReturnInParagraph(Element& aParentDivOrP)
|
|||
}
|
||||
|
||||
brContent =
|
||||
HTMLEditorRef().InsertBrElementWithTransaction(SelectionRef(),
|
||||
pointToInsertBR);
|
||||
HTMLEditorRef().InsertBrElementWithTransaction(pointToInsertBR);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return EditActionResult(NS_ERROR_EDITOR_DESTROYED);
|
||||
}
|
||||
|
@ -8523,7 +8512,7 @@ HTMLEditRules::ReturnInListItem(Element& aListItem,
|
|||
// Append a <br> to it
|
||||
RefPtr<Element> brElement =
|
||||
HTMLEditorRef().InsertBrElementWithTransaction(
|
||||
SelectionRef(), EditorRawDOMPoint(pNode, 0));
|
||||
EditorRawDOMPoint(pNode, 0));
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -9464,7 +9453,7 @@ HTMLEditRules::AdjustWhitespace()
|
|||
MOZ_ASSERT(IsEditorDataAvailable());
|
||||
|
||||
EditorRawDOMPoint selectionStartPoint(
|
||||
EditorBase::GetStartPoint(&SelectionRef()));
|
||||
EditorBase::GetStartPoint(SelectionRef()));
|
||||
if (NS_WARN_IF(!selectionStartPoint.IsSet())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -9495,7 +9484,7 @@ HTMLEditRules::PinSelectionToNewBlock()
|
|||
}
|
||||
|
||||
EditorRawDOMPoint selectionStartPoint(
|
||||
EditorBase::GetStartPoint(&SelectionRef()));
|
||||
EditorBase::GetStartPoint(SelectionRef()));
|
||||
if (NS_WARN_IF(!selectionStartPoint.IsSet())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -9648,7 +9637,7 @@ HTMLEditRules::AdjustSelection(nsIEditor::EDirection aAction)
|
|||
}
|
||||
|
||||
// get the (collapsed) selection location
|
||||
EditorDOMPoint point(EditorBase::GetStartPoint(&SelectionRef()));
|
||||
EditorDOMPoint point(EditorBase::GetStartPoint(SelectionRef()));
|
||||
if (NS_WARN_IF(!point.IsSet())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -10007,7 +9996,7 @@ HTMLEditRules::RemoveEmptyNodesInChangedRange()
|
|||
// but preserve br.
|
||||
RefPtr<Element> brElement =
|
||||
HTMLEditorRef().InsertBrElementWithTransaction(
|
||||
SelectionRef(), EditorRawDOMPoint(delNode));
|
||||
EditorRawDOMPoint(delNode));
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -10283,7 +10272,7 @@ HTMLEditRules::ConfirmSelectionInBody()
|
|||
}
|
||||
|
||||
EditorRawDOMPoint selectionStartPoint(
|
||||
EditorBase::GetStartPoint(&SelectionRef()));
|
||||
EditorBase::GetStartPoint(SelectionRef()));
|
||||
if (NS_WARN_IF(!selectionStartPoint.IsSet())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -10307,7 +10296,7 @@ HTMLEditRules::ConfirmSelectionInBody()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
EditorRawDOMPoint selectionEndPoint(EditorBase::GetEndPoint(&SelectionRef()));
|
||||
EditorRawDOMPoint selectionEndPoint(EditorBase::GetEndPoint(SelectionRef()));
|
||||
if (NS_WARN_IF(!selectionEndPoint.IsSet())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -10621,11 +10610,11 @@ HTMLEditRules::WillDeleteSelection(Selection& aSelection)
|
|||
|
||||
AutoSafeEditorData setData(*this, *mHTMLEditor, aSelection);
|
||||
|
||||
EditorRawDOMPoint startPoint = EditorBase::GetStartPoint(&SelectionRef());
|
||||
EditorRawDOMPoint startPoint = EditorBase::GetStartPoint(SelectionRef());
|
||||
if (NS_WARN_IF(!startPoint.IsSet())) {
|
||||
return;
|
||||
}
|
||||
EditorRawDOMPoint endPoint = EditorBase::GetEndPoint(&SelectionRef());
|
||||
EditorRawDOMPoint endPoint = EditorBase::GetEndPoint(SelectionRef());
|
||||
if (NS_WARN_IF(!endPoint.IsSet())) {
|
||||
return;
|
||||
}
|
||||
|
@ -10780,8 +10769,7 @@ HTMLEditRules::MakeSureElemStartsOrEndsOnCR(nsINode& aNode,
|
|||
pointToInsert.Set(&aNode, 0);
|
||||
}
|
||||
RefPtr<Element> brElement =
|
||||
HTMLEditorRef().InsertBrElementWithTransaction(SelectionRef(),
|
||||
pointToInsert);
|
||||
HTMLEditorRef().InsertBrElementWithTransaction(pointToInsert);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -10963,8 +10951,7 @@ HTMLEditRules::WillAbsolutePosition(bool* aCancel,
|
|||
*aCancel = false;
|
||||
*aHandled = true;
|
||||
|
||||
RefPtr<Element> focusElement =
|
||||
HTMLEditorRef().GetSelectionContainerElement(SelectionRef());
|
||||
RefPtr<Element> focusElement = HTMLEditorRef().GetSelectionContainerElement();
|
||||
if (focusElement && HTMLEditUtils::IsImage(focusElement)) {
|
||||
mNewBlock = focusElement;
|
||||
return NS_OK;
|
||||
|
@ -10998,7 +10985,7 @@ HTMLEditRules::PrepareToMakeElementAbsolutePosition(
|
|||
MOZ_ASSERT(aHandled);
|
||||
MOZ_ASSERT(aTargetElement);
|
||||
|
||||
AutoSelectionRestorer restoreSelectionLater(SelectionRef(), HTMLEditorRef());
|
||||
AutoSelectionRestorer restoreSelectionLater(HTMLEditorRef());
|
||||
|
||||
// Convert the selection ranges into "promoted" selection ranges: this
|
||||
// basically just expands the range to include the immediate block parent,
|
||||
|
@ -11303,7 +11290,7 @@ HTMLEditRules::WillRemoveAbsolutePosition(bool* aCancel,
|
|||
}
|
||||
|
||||
{
|
||||
AutoSelectionRestorer restoreSelectionLater(SelectionRef(), HTMLEditorRef());
|
||||
AutoSelectionRestorer restoreSelectionLater(HTMLEditorRef());
|
||||
|
||||
nsresult rv = HTMLEditorRef().SetPositionToAbsoluteOrStatic(*element, false);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
|
@ -11349,7 +11336,7 @@ HTMLEditRules::WillRelativeChangeZIndex(int32_t aChange,
|
|||
}
|
||||
|
||||
{
|
||||
AutoSelectionRestorer restoreSelectionLater(SelectionRef(), HTMLEditorRef());
|
||||
AutoSelectionRestorer restoreSelectionLater(HTMLEditorRef());
|
||||
|
||||
int32_t zIndex;
|
||||
nsresult rv = HTMLEditorRef().RelativeChangeElementZIndex(*element, aChange,
|
||||
|
|
|
@ -438,7 +438,7 @@ HTMLEditor::NotifySelectionChanged(nsIDocument* aDocument,
|
|||
// FYI: This is an XPCOM method. So, the caller, Selection, guarantees
|
||||
// the lifetime of this instance. So, don't need to grab this with
|
||||
// local variable.
|
||||
DebugOnly<nsresult> rv = RefereshEditingUI(*aSelection);
|
||||
DebugOnly<nsresult> rv = RefereshEditingUI();
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "RefereshEditingUI() failed");
|
||||
}
|
||||
}
|
||||
|
@ -611,9 +611,10 @@ HTMLEditor::BeginningOfDocument()
|
|||
}
|
||||
|
||||
void
|
||||
HTMLEditor::InitializeSelectionAncestorLimit(Selection& aSelection,
|
||||
nsIContent& aAncestorLimit)
|
||||
HTMLEditor::InitializeSelectionAncestorLimit(nsIContent& aAncestorLimit)
|
||||
{
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
// Hack for initializing selection.
|
||||
// HTMLEditor::MaybeCollapseSelectionAtFirstEditableNode() will try to
|
||||
// collapse selection at first editable text node or inline element which
|
||||
|
@ -631,9 +632,10 @@ HTMLEditor::InitializeSelectionAncestorLimit(Selection& aSelection,
|
|||
// Basically, we should try to collapse selection at first editable node
|
||||
// in HTMLEditor.
|
||||
bool tryToCollapseSelectionAtFirstEditableNode = true;
|
||||
if (aSelection.RangeCount() == 1 && aSelection.IsCollapsed()) {
|
||||
if (SelectionRefPtr()->RangeCount() == 1 &&
|
||||
SelectionRefPtr()->IsCollapsed()) {
|
||||
Element* editingHost = GetActiveEditingHost();
|
||||
nsRange* range = aSelection.GetRangeAt(0);
|
||||
nsRange* range = SelectionRefPtr()->GetRangeAt(0);
|
||||
if (range->GetStartContainer() == editingHost &&
|
||||
!range->StartOffset()) {
|
||||
// JS or user operation has already collapsed selection at start of
|
||||
|
@ -643,7 +645,7 @@ HTMLEditor::InitializeSelectionAncestorLimit(Selection& aSelection,
|
|||
}
|
||||
}
|
||||
|
||||
EditorBase::InitializeSelectionAncestorLimit(aSelection, aAncestorLimit);
|
||||
EditorBase::InitializeSelectionAncestorLimit(aAncestorLimit);
|
||||
|
||||
// XXX Do we need to check if we still need to change selection? E.g.,
|
||||
// we could have already lost focus while we're changing the ancestor
|
||||
|
@ -1149,8 +1151,7 @@ HTMLEditor::TabInTable(bool inIsShift,
|
|||
}
|
||||
|
||||
// Find enclosing table cell from selection (cell may be selected element)
|
||||
Element* cellElement =
|
||||
GetElementOrParentByTagNameAtSelection(*SelectionRefPtr(), *nsGkAtoms::td);
|
||||
Element* cellElement = GetElementOrParentByTagNameAtSelection(*nsGkAtoms::td);
|
||||
if (NS_WARN_IF(!cellElement)) {
|
||||
// Do nothing if we didn't find a table cell.
|
||||
return NS_OK;
|
||||
|
@ -1187,7 +1188,7 @@ HTMLEditor::TabInTable(bool inIsShift,
|
|||
|
||||
if (node && HTMLEditUtils::IsTableCell(node) &&
|
||||
GetEnclosingTable(node) == table) {
|
||||
CollapseSelectionToDeepestNonTableFirstChild(nullptr, node);
|
||||
CollapseSelectionToDeepestNonTableFirstChild(node);
|
||||
*outHandled = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1212,8 +1213,7 @@ HTMLEditor::TabInTable(bool inIsShift,
|
|||
// to new row...
|
||||
RefPtr<Element> tblElement, cell;
|
||||
int32_t row;
|
||||
rv = GetCellContext(nullptr,
|
||||
getter_AddRefs(tblElement),
|
||||
rv = GetCellContext(getter_AddRefs(tblElement),
|
||||
getter_AddRefs(cell),
|
||||
nullptr, nullptr,
|
||||
&row, nullptr);
|
||||
|
@ -1257,7 +1257,7 @@ HTMLEditor::InsertBrElementAtSelectionWithTransaction()
|
|||
}
|
||||
}
|
||||
|
||||
EditorRawDOMPoint atStartOfSelection(GetStartPoint(selection));
|
||||
EditorRawDOMPoint atStartOfSelection(EditorBase::GetStartPoint(*selection));
|
||||
if (NS_WARN_IF(!atStartOfSelection.IsSet())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -1265,7 +1265,7 @@ HTMLEditor::InsertBrElementAtSelectionWithTransaction()
|
|||
// InsertBrElementWithTransaction() will set selection after the new <br>
|
||||
// element.
|
||||
RefPtr<Element> newBrElement =
|
||||
InsertBrElementWithTransaction(*selection, atStartOfSelection, eNext);
|
||||
InsertBrElementWithTransaction(atStartOfSelection, eNext);
|
||||
if (NS_WARN_IF(!newBrElement)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -1273,19 +1273,11 @@ HTMLEditor::InsertBrElementAtSelectionWithTransaction()
|
|||
}
|
||||
|
||||
void
|
||||
HTMLEditor::CollapseSelectionToDeepestNonTableFirstChild(Selection* aSelection,
|
||||
nsINode* aNode)
|
||||
HTMLEditor::CollapseSelectionToDeepestNonTableFirstChild(nsINode* aNode)
|
||||
{
|
||||
MOZ_ASSERT(aNode);
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
RefPtr<Selection> selection = aSelection;
|
||||
if (!selection) {
|
||||
selection = GetSelection();
|
||||
}
|
||||
if (!selection) {
|
||||
// Nothing to do
|
||||
return;
|
||||
}
|
||||
MOZ_ASSERT(aNode);
|
||||
|
||||
nsCOMPtr<nsINode> node = aNode;
|
||||
|
||||
|
@ -1299,7 +1291,7 @@ HTMLEditor::CollapseSelectionToDeepestNonTableFirstChild(Selection* aSelection,
|
|||
node = child;
|
||||
}
|
||||
|
||||
selection->Collapse(node, 0);
|
||||
SelectionRefPtr()->Collapse(node, 0);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -1729,7 +1721,7 @@ HTMLEditor::InsertElementAtSelection(Element* aElement,
|
|||
// Set caret after element, but check for special case
|
||||
// of inserting table-related elements: set in first cell instead
|
||||
if (!SetCaretInTableCell(aElement)) {
|
||||
rv = CollapseSelectionAfter(*SelectionRefPtr(), *aElement);
|
||||
rv = CollapseSelectionAfter(*aElement);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -1743,8 +1735,7 @@ HTMLEditor::InsertElementAtSelection(Element* aElement,
|
|||
"Failed to advance offset from inserted point");
|
||||
// Collapse selection to the new <br> element node after creating it.
|
||||
RefPtr<Element> newBrElement =
|
||||
InsertBrElementWithTransaction(*SelectionRefPtr(), insertedPoint,
|
||||
ePrevious);
|
||||
InsertBrElementWithTransaction(insertedPoint, ePrevious);
|
||||
if (NS_WARN_IF(!newBrElement)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -1835,7 +1826,7 @@ HTMLEditor::SelectElement(Element* aElement)
|
|||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
nsresult rv = SelectContentInternal(*SelectionRefPtr(), *aElement);
|
||||
nsresult rv = SelectContentInternal(*aElement);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -1843,9 +1834,10 @@ HTMLEditor::SelectElement(Element* aElement)
|
|||
}
|
||||
|
||||
nsresult
|
||||
HTMLEditor::SelectContentInternal(Selection& aSelection,
|
||||
nsIContent& aContentToSelect)
|
||||
HTMLEditor::SelectContentInternal(nsIContent& aContentToSelect)
|
||||
{
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
// Must be sure that element is contained in the document body
|
||||
if (!IsDescendantOfEditorRoot(&aContentToSelect)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -1863,12 +1855,12 @@ HTMLEditor::SelectContentInternal(Selection& aSelection,
|
|||
int32_t offsetInParent = parent->ComputeIndexOf(&aContentToSelect);
|
||||
|
||||
// Collapse selection to just before desired element,
|
||||
nsresult rv = aSelection.Collapse(parent, offsetInParent);
|
||||
nsresult rv = SelectionRefPtr()->Collapse(parent, offsetInParent);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
// then extend it to just after
|
||||
rv = aSelection.Extend(parent, offsetInParent + 1);
|
||||
rv = SelectionRefPtr()->Extend(parent, offsetInParent + 1);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -1887,7 +1879,7 @@ HTMLEditor::SetCaretAfterElement(Element* aElement)
|
|||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
nsresult rv = CollapseSelectionAfter(*SelectionRefPtr(), *aElement);
|
||||
nsresult rv = CollapseSelectionAfter(*aElement);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -1895,9 +1887,10 @@ HTMLEditor::SetCaretAfterElement(Element* aElement)
|
|||
}
|
||||
|
||||
nsresult
|
||||
HTMLEditor::CollapseSelectionAfter(Selection& aSelection,
|
||||
Element& aElement)
|
||||
HTMLEditor::CollapseSelectionAfter(Element& aElement)
|
||||
{
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
// Be sure the element is contained in the document body
|
||||
if (NS_WARN_IF(!IsDescendantOfEditorRoot(&aElement))) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
@ -1912,7 +1905,7 @@ HTMLEditor::CollapseSelectionAfter(Selection& aSelection,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
ErrorResult error;
|
||||
aSelection.Collapse(afterElement, error);
|
||||
SelectionRefPtr()->Collapse(afterElement, error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
|
@ -2108,7 +2101,7 @@ HTMLEditor::GetHTMLBackgroundColorState(bool* aMixed,
|
|||
|
||||
ErrorResult error;
|
||||
RefPtr<Element> cellOrRowOrTableElement =
|
||||
GetSelectedOrParentTableElement(*selection, error);
|
||||
GetSelectedOrParentTableElement(error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
|
@ -2311,7 +2304,11 @@ HTMLEditor::MakeOrChangeList(const nsAString& aListType,
|
|||
}
|
||||
}
|
||||
|
||||
return rules->DidDoAction(SelectionRefPtr(), subActionInfo, rv);
|
||||
rv = rules->DidDoAction(SelectionRefPtr(), subActionInfo, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -2345,7 +2342,11 @@ HTMLEditor::RemoveList(const nsAString&)
|
|||
|
||||
// no default behavior for this yet. what would it mean?
|
||||
|
||||
return rules->DidDoAction(SelectionRefPtr(), subActionInfo, rv);
|
||||
rv = rules->DidDoAction(SelectionRefPtr(), subActionInfo, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -2679,7 +2680,11 @@ HTMLEditor::Align(const nsAString& aAlignType)
|
|||
return rv;
|
||||
}
|
||||
|
||||
return rules->DidDoAction(SelectionRefPtr(), subActionInfo, rv);
|
||||
rv = rules->DidDoAction(SelectionRefPtr(), subActionInfo, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
Element*
|
||||
|
@ -2696,21 +2701,18 @@ HTMLEditor::GetElementOrParentByTagName(const nsAtom& aTagName,
|
|||
if (aNode) {
|
||||
return GetElementOrParentByTagNameInternal(aTagName, *aNode);
|
||||
}
|
||||
RefPtr<Selection> selection = GetSelection();
|
||||
if (NS_WARN_IF(!selection)) {
|
||||
return nullptr;
|
||||
}
|
||||
return GetElementOrParentByTagNameAtSelection(*selection, aTagName);
|
||||
return GetElementOrParentByTagNameAtSelection(aTagName);
|
||||
}
|
||||
|
||||
Element*
|
||||
HTMLEditor::GetElementOrParentByTagNameAtSelection(Selection& aSelection,
|
||||
const nsAtom& aTagName) const
|
||||
HTMLEditor::GetElementOrParentByTagNameAtSelection(const nsAtom& aTagName) const
|
||||
{
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
MOZ_ASSERT(&aTagName != nsGkAtoms::_empty);
|
||||
|
||||
// If no node supplied, get it from anchor node of current selection
|
||||
const EditorRawDOMPoint atAnchor(aSelection.AnchorRef());
|
||||
const EditorRawDOMPoint atAnchor(SelectionRefPtr()->AnchorRef());
|
||||
if (NS_WARN_IF(!atAnchor.IsSet())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -2820,8 +2822,7 @@ HTMLEditor::GetSelectedElement(const nsAString& aTagName,
|
|||
|
||||
ErrorResult error;
|
||||
RefPtr<nsAtom> tagName = GetLowerCaseNameAtom(aTagName);
|
||||
RefPtr<nsINode> selectedNode =
|
||||
GetSelectedElement(*SelectionRefPtr(), tagName, error);
|
||||
RefPtr<nsINode> selectedNode = GetSelectedElement(tagName, error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
|
@ -2830,16 +2831,17 @@ HTMLEditor::GetSelectedElement(const nsAString& aTagName,
|
|||
}
|
||||
|
||||
already_AddRefed<Element>
|
||||
HTMLEditor::GetSelectedElement(Selection& aSelection,
|
||||
const nsAtom* aTagName,
|
||||
HTMLEditor::GetSelectedElement(const nsAtom* aTagName,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
MOZ_ASSERT(!aRv.Failed());
|
||||
|
||||
bool isLinkTag = aTagName && IsLinkTag(*aTagName);
|
||||
bool isNamedAnchorTag = aTagName && IsNamedAnchorTag(*aTagName);
|
||||
|
||||
RefPtr<nsRange> firstRange = aSelection.GetRangeAt(0);
|
||||
RefPtr<nsRange> firstRange = SelectionRefPtr()->GetRangeAt(0);
|
||||
if (NS_WARN_IF(!firstRange)) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
|
@ -2878,8 +2880,8 @@ HTMLEditor::GetSelectedElement(Selection& aSelection,
|
|||
// Link tag is a special case - we return the anchor node
|
||||
// found for any selection that is totally within a link,
|
||||
// included a collapsed selection (just a caret in a link)
|
||||
const RangeBoundary& anchor = aSelection.AnchorRef();
|
||||
const RangeBoundary& focus = aSelection.FocusRef();
|
||||
const RangeBoundary& anchor = SelectionRefPtr()->AnchorRef();
|
||||
const RangeBoundary& focus = SelectionRefPtr()->FocusRef();
|
||||
// Link node must be the same for both ends of selection
|
||||
if (anchor.IsSet()) {
|
||||
Element* parentLinkOfAnchor =
|
||||
|
@ -2887,7 +2889,7 @@ HTMLEditor::GetSelectedElement(Selection& aSelection,
|
|||
*anchor.Container());
|
||||
// XXX: ERROR_HANDLING can parentLinkOfAnchor be null?
|
||||
if (parentLinkOfAnchor) {
|
||||
if (aSelection.IsCollapsed()) {
|
||||
if (SelectionRefPtr()->IsCollapsed()) {
|
||||
// We have just a caret in the link.
|
||||
return do_AddRef(parentLinkOfAnchor);
|
||||
}
|
||||
|
@ -2912,7 +2914,7 @@ HTMLEditor::GetSelectedElement(Selection& aSelection,
|
|||
}
|
||||
}
|
||||
|
||||
if (aSelection.IsCollapsed()) {
|
||||
if (SelectionRefPtr()->IsCollapsed()) {
|
||||
return selectedElement.forget();
|
||||
}
|
||||
|
||||
|
@ -3135,7 +3137,7 @@ HTMLEditor::SetHTMLBackgroundColorWithTransaction(const nsAString& aColor)
|
|||
ErrorResult error;
|
||||
bool isCellSelected = false;
|
||||
RefPtr<Element> cellOrRowOrTableElement =
|
||||
GetSelectedOrParentTableElement(*selection, error, &isCellSelected);
|
||||
GetSelectedOrParentTableElement(error, &isCellSelected);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
|
@ -3154,7 +3156,7 @@ HTMLEditor::SetHTMLBackgroundColorWithTransaction(const nsAString& aColor)
|
|||
nsGkAtoms::tr)) {
|
||||
IgnoredErrorResult ignoredError;
|
||||
RefPtr<Element> cellElement =
|
||||
GetFirstSelectedTableCellElement(*selection, ignoredError);
|
||||
GetFirstSelectedTableCellElement(ignoredError);
|
||||
if (cellElement) {
|
||||
if (setColor) {
|
||||
while (cellElement) {
|
||||
|
@ -3164,8 +3166,7 @@ HTMLEditor::SetHTMLBackgroundColorWithTransaction(const nsAString& aColor)
|
|||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
cellElement =
|
||||
GetNextSelectedTableCellElement(*selection, ignoredError);
|
||||
cellElement = GetNextSelectedTableCellElement(ignoredError);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -3175,8 +3176,7 @@ HTMLEditor::SetHTMLBackgroundColorWithTransaction(const nsAString& aColor)
|
|||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
cellElement =
|
||||
GetNextSelectedTableCellElement(*selection, ignoredError);
|
||||
cellElement = GetNextSelectedTableCellElement(ignoredError);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -3816,9 +3816,11 @@ HTMLEditor::IsContainer(nsINode* aNode)
|
|||
}
|
||||
|
||||
nsresult
|
||||
HTMLEditor::SelectEntireDocument(Selection* aSelection)
|
||||
HTMLEditor::SelectEntireDocument()
|
||||
{
|
||||
if (!aSelection || !mRules) {
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
if (!mRules) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
|
@ -3831,10 +3833,14 @@ HTMLEditor::SelectEntireDocument(Selection* aSelection)
|
|||
Element* rootElement = GetRoot();
|
||||
|
||||
// if its empty dont select entire doc - that would select the bogus node
|
||||
return aSelection->Collapse(rootElement, 0);
|
||||
nsresult rv = SelectionRefPtr()->Collapse(rootElement, 0);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return EditorBase::SelectEntireDocument(aSelection);
|
||||
return EditorBase::SelectEntireDocument();
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -4022,12 +4028,18 @@ HTMLEditor::CollapseAdjacentTextNodes(nsRange* aInRange)
|
|||
}
|
||||
|
||||
nsresult
|
||||
HTMLEditor::SetSelectionAtDocumentStart(Selection* aSelection)
|
||||
HTMLEditor::SetSelectionAtDocumentStart()
|
||||
{
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
dom::Element* rootElement = GetRoot();
|
||||
NS_ENSURE_TRUE(rootElement, NS_ERROR_NULL_POINTER);
|
||||
|
||||
return aSelection->Collapse(rootElement, 0);
|
||||
nsresult rv = SelectionRefPtr()->Collapse(rootElement, 0);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4064,8 +4076,7 @@ HTMLEditor::RemoveBlockContainerWithTransaction(Element& aElement)
|
|||
!sibling->IsHTMLElement(nsGkAtoms::br) && !IsBlockNode(child)) {
|
||||
// Insert br node
|
||||
RefPtr<Element> brElement =
|
||||
InsertBrElementWithTransaction(*selection,
|
||||
EditorRawDOMPoint(&aElement, 0));
|
||||
InsertBrElementWithTransaction(EditorRawDOMPoint(&aElement, 0));
|
||||
if (NS_WARN_IF(!brElement)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -4085,8 +4096,7 @@ HTMLEditor::RemoveBlockContainerWithTransaction(Element& aElement)
|
|||
// Insert br node
|
||||
EditorRawDOMPoint endOfNode;
|
||||
endOfNode.SetToEndOf(&aElement);
|
||||
RefPtr<Element> brElement =
|
||||
InsertBrElementWithTransaction(*selection, endOfNode);
|
||||
RefPtr<Element> brElement = InsertBrElementWithTransaction(endOfNode);
|
||||
if (NS_WARN_IF(!brElement)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -4107,8 +4117,7 @@ HTMLEditor::RemoveBlockContainerWithTransaction(Element& aElement)
|
|||
!sibling->IsHTMLElement(nsGkAtoms::br)) {
|
||||
// Insert br node
|
||||
RefPtr<Element> brElement =
|
||||
InsertBrElementWithTransaction(*selection,
|
||||
EditorRawDOMPoint(&aElement, 0));
|
||||
InsertBrElementWithTransaction(EditorRawDOMPoint(&aElement, 0));
|
||||
if (NS_WARN_IF(!brElement)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -4641,7 +4650,7 @@ HTMLEditor::SetCSSBackgroundColorWithTransaction(const nsAString& aColor)
|
|||
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
|
||||
*this, EditSubAction::eInsertElement,
|
||||
nsIEditor::eNext);
|
||||
AutoSelectionRestorer restoreSelectionLater(*selection, *this);
|
||||
AutoSelectionRestorer restoreSelectionLater(*this);
|
||||
AutoTransactionsConserveSelection dontChangeMySelection(*this);
|
||||
|
||||
// XXX Although, this method may set background color of ancestor block
|
||||
|
@ -4897,8 +4906,7 @@ HTMLEditor::CopyLastEditableChildStylesWithTransaction(
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
RefPtr<Element> brElement =
|
||||
InsertBrElementWithTransaction(*selection,
|
||||
EditorRawDOMPoint(firstClonsedElement, 0));
|
||||
InsertBrElementWithTransaction(EditorRawDOMPoint(firstClonsedElement, 0));
|
||||
if (NS_WARN_IF(!brElement)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -4933,20 +4941,22 @@ HTMLEditor::GetElementOrigin(Element& aElement,
|
|||
}
|
||||
|
||||
Element*
|
||||
HTMLEditor::GetSelectionContainerElement(Selection& aSelection) const
|
||||
HTMLEditor::GetSelectionContainerElement() const
|
||||
{
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
nsINode* focusNode = nullptr;
|
||||
if (aSelection.IsCollapsed()) {
|
||||
focusNode = aSelection.GetFocusNode();
|
||||
if (SelectionRefPtr()->IsCollapsed()) {
|
||||
focusNode = SelectionRefPtr()->GetFocusNode();
|
||||
if (NS_WARN_IF(!focusNode)) {
|
||||
return nullptr;
|
||||
}
|
||||
} else {
|
||||
uint32_t rangeCount = aSelection.RangeCount();
|
||||
uint32_t rangeCount = SelectionRefPtr()->RangeCount();
|
||||
MOZ_ASSERT(rangeCount, "If 0, Selection::IsCollapsed() should return true");
|
||||
|
||||
if (rangeCount == 1) {
|
||||
nsRange* range = aSelection.GetRangeAt(0);
|
||||
nsRange* range = SelectionRefPtr()->GetRangeAt(0);
|
||||
|
||||
const RangeBoundary& startRef = range->StartRef();
|
||||
const RangeBoundary& endRef = range->EndRef();
|
||||
|
@ -4970,7 +4980,7 @@ HTMLEditor::GetSelectionContainerElement(Selection& aSelection) const
|
|||
}
|
||||
} else {
|
||||
for (uint32_t i = 0; i < rangeCount; i++) {
|
||||
nsRange* range = aSelection.GetRangeAt(i);
|
||||
nsRange* range = SelectionRefPtr()->GetRangeAt(i);
|
||||
nsINode* startContainer = range->GetStartContainer();
|
||||
if (!focusNode) {
|
||||
focusNode = startContainer;
|
||||
|
|
|
@ -252,11 +252,7 @@ public:
|
|||
}
|
||||
|
||||
mIsObjectResizingEnabled = aEnable;
|
||||
RefPtr<Selection> selection = GetSelection();
|
||||
if (NS_WARN_IF(!selection)) {
|
||||
return;
|
||||
}
|
||||
RefereshEditingUI(*selection);
|
||||
RefereshEditingUI();
|
||||
}
|
||||
bool IsObjectResizerEnabled() const
|
||||
{
|
||||
|
@ -280,11 +276,7 @@ public:
|
|||
}
|
||||
|
||||
mIsInlineTableEditingEnabled = aEnable;
|
||||
RefPtr<Selection> selection = GetSelection();
|
||||
if (NS_WARN_IF(!selection)) {
|
||||
return;
|
||||
}
|
||||
RefereshEditingUI(*selection);
|
||||
RefereshEditingUI();
|
||||
}
|
||||
bool IsInlineTableEditorEnabled() const
|
||||
{
|
||||
|
@ -309,11 +301,7 @@ public:
|
|||
}
|
||||
|
||||
mIsAbsolutelyPositioningEnabled = aEnable;
|
||||
RefPtr<Selection> selection = GetSelection();
|
||||
if (NS_WARN_IF(!selection)) {
|
||||
return;
|
||||
}
|
||||
RefereshEditingUI(*selection);
|
||||
RefereshEditingUI();
|
||||
}
|
||||
bool IsAbsolutePositionEditorEnabled() const
|
||||
{
|
||||
|
@ -609,7 +597,7 @@ protected: // May be called by friends.
|
|||
* of start container of a range which starts with different node from
|
||||
* start container of the first range.
|
||||
*/
|
||||
Element* GetSelectionContainerElement(Selection& aSelection) const;
|
||||
Element* GetSelectionContainerElement() const;
|
||||
|
||||
/**
|
||||
* GetFirstSelectedTableCellElement() returns a <td> or <th> element if
|
||||
|
@ -622,7 +610,6 @@ protected: // May be called by friends.
|
|||
* GetNextSelectedTableCellElement() after a call of this, it'll return 2nd
|
||||
* selected cell if there is.
|
||||
*
|
||||
* @param aSelection Selection for this editor.
|
||||
* @param aRv Returns error if there is no selection or
|
||||
* first range of Selection is unexpected.
|
||||
* @return A <td> or <th> element is selected by first
|
||||
|
@ -631,8 +618,7 @@ protected: // May be called by friends.
|
|||
* <tr> element, startOffset + 1 equals endOffset.
|
||||
*/
|
||||
already_AddRefed<Element>
|
||||
GetFirstSelectedTableCellElement(Selection& aSelection,
|
||||
ErrorResult& aRv) const;
|
||||
GetFirstSelectedTableCellElement(ErrorResult& aRv) const;
|
||||
|
||||
/**
|
||||
* GetNextSelectedTableCellElement() is a stateful method to retrieve
|
||||
|
@ -649,7 +635,6 @@ protected: // May be called by friends.
|
|||
* scans all ranges of Selection. Therefore, returning cells which
|
||||
* belong to different <table> elements.
|
||||
*
|
||||
* @param Selection Selection for this editor.
|
||||
* @param aRv Returns error if Selection doesn't have
|
||||
* range properly.
|
||||
* @return A <td> or <th> element if one of remaining
|
||||
|
@ -657,8 +642,7 @@ protected: // May be called by friends.
|
|||
* this does not meet a range in a text node.
|
||||
*/
|
||||
already_AddRefed<Element>
|
||||
GetNextSelectedTableCellElement(Selection& aSelection,
|
||||
ErrorResult& aRv) const;
|
||||
GetNextSelectedTableCellElement(ErrorResult& aRv) const;
|
||||
|
||||
/**
|
||||
* DeleteTableCellContentsWithTransaction() removes any contents in cell
|
||||
|
@ -1020,25 +1004,20 @@ protected: // Shouldn't be used by friend classes
|
|||
* SelectContentInternal() sets Selection to aContentToSelect to
|
||||
* aContentToSelect + 1 in parent of aContentToSelect.
|
||||
*
|
||||
* @param aSelection The Selection, callers have to guarantee the
|
||||
* lifetime.
|
||||
* @param aContentToSelect The content which should be selected.
|
||||
*/
|
||||
nsresult SelectContentInternal(Selection& aSelection,
|
||||
nsIContent& aContentToSelect);
|
||||
nsresult SelectContentInternal(nsIContent& aContentToSelect);
|
||||
|
||||
/**
|
||||
* CollapseSelectionAfter() collapses Selection after aElement.
|
||||
* If aElement is an orphan node or not in editing host, returns error.
|
||||
*/
|
||||
nsresult CollapseSelectionAfter(Selection& aSelection,
|
||||
Element& aElement);
|
||||
nsresult CollapseSelectionAfter(Element& aElement);
|
||||
|
||||
/**
|
||||
* GetElementOrParentByTagNameAtSelection() looks for an element node whose
|
||||
* name matches aTagName from anchor node of Selection to <body> element.
|
||||
*
|
||||
* @param aSelection The Selection for this editor.
|
||||
* @param aTagName The tag name which you want to look for.
|
||||
* Must not be nsGkAtoms::_empty.
|
||||
* If nsGkAtoms::list, the result may be <ul>, <ol> or
|
||||
|
@ -1052,8 +1031,7 @@ protected: // Shouldn't be used by friend classes
|
|||
* an Element. Otherwise, nullptr.
|
||||
*/
|
||||
Element*
|
||||
GetElementOrParentByTagNameAtSelection(Selection& aSelection,
|
||||
const nsAtom& aTagName) const;
|
||||
GetElementOrParentByTagNameAtSelection(const nsAtom& aTagName) const;
|
||||
|
||||
/**
|
||||
* GetElementOrParentByTagNameInternal() looks for an element node whose
|
||||
|
@ -1078,7 +1056,7 @@ protected: // Shouldn't be used by friend classes
|
|||
|
||||
/**
|
||||
* GetSelectedElement() returns an element node which is in first range of
|
||||
* aSelection. The rule is a little bit complicated and the rules do not
|
||||
* Selection. The rule is a little bit complicated and the rules do not
|
||||
* make sense except in a few cases. If you want to use this newly,
|
||||
* you should create new method instead. This needs to be here for
|
||||
* comm-central.
|
||||
|
@ -1097,7 +1075,6 @@ protected: // Shouldn't be used by friend classes
|
|||
* 4-2. When first element node matches with the argument, returns
|
||||
* *next* element node.
|
||||
*
|
||||
* @param aSelection The Selection.
|
||||
* @param aTagName The atom of tag name in lower case.
|
||||
* If nullptr, look for any element node.
|
||||
* If nsGkAtoms::href, look for an <a> element
|
||||
|
@ -1106,11 +1083,10 @@ protected: // Shouldn't be used by friend classes
|
|||
* look for an <a> element which has non-empty
|
||||
* name attribute.
|
||||
* @param aRv Returns error code.
|
||||
* @return An element in first range of aSelection.
|
||||
* @return An element in first range of Selection.
|
||||
*/
|
||||
already_AddRefed<Element>
|
||||
GetSelectedElement(Selection& aSelection,
|
||||
const nsAtom* aTagName,
|
||||
GetSelectedElement(const nsAtom* aTagName,
|
||||
ErrorResult& aRv);
|
||||
|
||||
/**
|
||||
|
@ -1525,8 +1501,7 @@ protected: // Shouldn't be used by friend classes
|
|||
* a selection range selects a cell element).
|
||||
*/
|
||||
already_AddRefed<Element>
|
||||
GetSelectedOrParentTableElement(Selection& aSelection,
|
||||
ErrorResult& aRv,
|
||||
GetSelectedOrParentTableElement(ErrorResult& aRv,
|
||||
bool* aIsCellSelected = nullptr) const;
|
||||
|
||||
/**
|
||||
|
@ -1649,13 +1624,12 @@ protected: // Shouldn't be used by friend classes
|
|||
nsresult SetHTMLBackgroundColorWithTransaction(const nsAString& aColor);
|
||||
|
||||
virtual void
|
||||
InitializeSelectionAncestorLimit(Selection& aSelection,
|
||||
nsIContent& aAncestorLimit) override;
|
||||
InitializeSelectionAncestorLimit(nsIContent& aAncestorLimit) override;
|
||||
|
||||
/**
|
||||
* Make the given selection span the entire document.
|
||||
*/
|
||||
virtual nsresult SelectEntireDocument(Selection* aSelection) override;
|
||||
virtual nsresult SelectEntireDocument() override;
|
||||
|
||||
/**
|
||||
* Use this to assure that selection is set after attribute nodes when
|
||||
|
@ -1663,10 +1637,8 @@ protected: // Shouldn't be used by friend classes
|
|||
* e.g., when setting at beginning of a table cell
|
||||
* This will stop at a table, however, since we don't want to
|
||||
* "drill down" into nested tables.
|
||||
* @param aSelection Optional. If null, we get current selection.
|
||||
*/
|
||||
void CollapseSelectionToDeepestNonTableFirstChild(Selection* aSelection,
|
||||
nsINode* aNode);
|
||||
void CollapseSelectionToDeepestNonTableFirstChild(nsINode* aNode);
|
||||
|
||||
/**
|
||||
* Returns TRUE if sheet was loaded, false if it wasn't.
|
||||
|
@ -1980,12 +1952,10 @@ protected: // Shouldn't be used by friend classes
|
|||
* DeleteTableElementAndChildren() removes aTableElement (and its children)
|
||||
* from the DOM tree with transaction.
|
||||
*
|
||||
* @param aSelection The normal Selection for the editor.
|
||||
* @param aTableElement The <table> element which you want to remove.
|
||||
*/
|
||||
nsresult
|
||||
DeleteTableElementAndChildrenWithTransaction(Selection& aSelection,
|
||||
Element& aTableElement);
|
||||
DeleteTableElementAndChildrenWithTransaction(Element& aTableElement);
|
||||
|
||||
nsresult SetColSpan(Element* aCell, int32_t aColSpan);
|
||||
nsresult SetRowSpan(Element* aCell, int32_t aRowSpan);
|
||||
|
@ -2026,7 +1996,7 @@ protected: // Shouldn't be used by friend classes
|
|||
* Returns NS_EDITOR_ELEMENT_NOT_FOUND if cell is not found even if aCell is
|
||||
* null.
|
||||
*/
|
||||
nsresult GetCellContext(Selection** aSelection, Element** aTable,
|
||||
nsresult GetCellContext(Element** aTable,
|
||||
Element** aCell, nsINode** aCellParent,
|
||||
int32_t* aCellOffset, int32_t* aRowIndex,
|
||||
int32_t* aColIndex);
|
||||
|
@ -2056,24 +2026,22 @@ protected: // Shouldn't be used by friend classes
|
|||
int32_t& aNewColCount);
|
||||
|
||||
/**
|
||||
* XXX NormalizeTable() is broken. If it meets a cell which has bigger or
|
||||
* smaller rowspan or colspan than actual number of cells, this always
|
||||
* failed to scan the table. Therefore, this does nothing when the
|
||||
* table should be normalized.
|
||||
* XXX NormalizeTableInternal() is broken. If it meets a cell which has
|
||||
* bigger or smaller rowspan or colspan than actual number of cells,
|
||||
* this always failed to scan the table. Therefore, this does nothing
|
||||
* when the table should be normalized.
|
||||
*
|
||||
* @param aSelection The Selection for the editor.
|
||||
* @param aTableOrElementInTable An element which is in a <table> element
|
||||
* or <table> element itself. Otherwise,
|
||||
* this returns NS_OK but does nothing.
|
||||
*/
|
||||
nsresult NormalizeTable(Selection& aSelection,
|
||||
Element& aTableOrElementInTable);
|
||||
nsresult NormalizeTableInternal(Element& aTableOrElementInTable);
|
||||
|
||||
/**
|
||||
* Fallback method: Call this after using ClearSelection() and you
|
||||
* failed to set selection to some other content in the document.
|
||||
*/
|
||||
nsresult SetSelectionAtDocumentStart(Selection* aSelection);
|
||||
nsresult SetSelectionAtDocumentStart();
|
||||
|
||||
static Element* GetEnclosingTable(nsINode* aNode);
|
||||
|
||||
|
@ -2299,7 +2267,7 @@ protected: // Shouldn't be used by friend classes
|
|||
* etc. If this shows or hides some UIs, it causes reflow. So, this is
|
||||
* not safe method.
|
||||
*/
|
||||
nsresult RefereshEditingUI(Selection& aSelection);
|
||||
nsresult RefereshEditingUI();
|
||||
|
||||
/**
|
||||
* Returns the offset of an element's frame to its absolute containing block.
|
||||
|
|
|
@ -232,7 +232,7 @@ HTMLEditor::DoInsertHTMLWithContext(const nsAString& aInputString,
|
|||
if (!aDestNode) {
|
||||
// if caller didn't provide the destination/target node,
|
||||
// fetch the paste insertion point from our selection
|
||||
targetPoint = EditorBase::GetStartPoint(selection);
|
||||
targetPoint = EditorBase::GetStartPoint(*selection);
|
||||
if (NS_WARN_IF(!targetPoint.IsSet()) ||
|
||||
!IsEditable(targetPoint.GetContainer())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -293,8 +293,7 @@ HTMLEditor::DoInsertHTMLWithContext(const nsAString& aInputString,
|
|||
// check for table cell selection mode
|
||||
bool cellSelectionMode = false;
|
||||
IgnoredErrorResult ignoredError;
|
||||
RefPtr<Element> cellElement =
|
||||
GetFirstSelectedTableCellElement(*selection, ignoredError);
|
||||
RefPtr<Element> cellElement = GetFirstSelectedTableCellElement(ignoredError);
|
||||
if (cellElement) {
|
||||
cellSelectionMode = true;
|
||||
}
|
||||
|
@ -328,7 +327,7 @@ HTMLEditor::DoInsertHTMLWithContext(const nsAString& aInputString,
|
|||
// Save current selection since DeleteTableCellWithTransaction() perturbs
|
||||
// it.
|
||||
{
|
||||
AutoSelectionRestorer restoreSelectionLater(*selection, *this);
|
||||
AutoSelectionRestorer restoreSelectionLater(*this);
|
||||
rv = DeleteTableCellWithTransaction(1);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
|
@ -351,7 +350,8 @@ HTMLEditor::DoInsertHTMLWithContext(const nsAString& aInputString,
|
|||
// Adjust position based on the first node we are going to insert.
|
||||
// FYI: WillDoAction() above might have changed the selection.
|
||||
EditorDOMPoint pointToInsert =
|
||||
GetBetterInsertionPointFor(nodeList[0], GetStartPoint(selection));
|
||||
GetBetterInsertionPointFor(nodeList[0],
|
||||
EditorBase::GetStartPoint(*selection));
|
||||
if (NS_WARN_IF(!pointToInsert.IsSet())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ HTMLEditorEventListener::MouseDown(MouseEvent* aMouseEvent)
|
|||
}
|
||||
// HACK !!! Context click places the caret but the context menu consumes
|
||||
// the event; so we need to check resizing state ourselves
|
||||
htmlEditor->CheckSelectionStateForAnonymousButtons(selection);
|
||||
htmlEditor->CheckSelectionStateForAnonymousButtons();
|
||||
|
||||
// Prevent bubbling if we changed selection or
|
||||
// for all context clicks
|
||||
|
|
|
@ -135,7 +135,7 @@ HTMLEditor::SetInlinePropertyInternal(nsAtom& aProperty,
|
|||
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
|
||||
*this, EditSubAction::eInsertElement,
|
||||
nsIEditor::eNext);
|
||||
AutoSelectionRestorer restoreSelectionLater(*selection, *this);
|
||||
AutoSelectionRestorer restoreSelectionLater(*this);
|
||||
AutoTransactionsConserveSelection dontChangeMySelection(*this);
|
||||
|
||||
bool cancel, handled;
|
||||
|
@ -1366,7 +1366,7 @@ HTMLEditor::RemoveInlinePropertyInternal(nsAtom* aProperty,
|
|||
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
|
||||
*this, EditSubAction::eRemoveTextProperty,
|
||||
nsIEditor::eNext);
|
||||
AutoSelectionRestorer restoreSelectionLater(*selection, *this);
|
||||
AutoSelectionRestorer restoreSelectionLater(*this);
|
||||
AutoTransactionsConserveSelection dontChangeMySelection(*this);
|
||||
|
||||
bool cancel, handled;
|
||||
|
@ -1548,7 +1548,7 @@ HTMLEditor::RelativeFontChange(FontSize aDir)
|
|||
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
|
||||
*this, EditSubAction::eSetTextProperty,
|
||||
nsIEditor::eNext);
|
||||
AutoSelectionRestorer restoreSelectionLater(*selection, *this);
|
||||
AutoSelectionRestorer restoreSelectionLater(*this);
|
||||
AutoTransactionsConserveSelection dontChangeMySelection(*this);
|
||||
|
||||
// Loop through the ranges in the selection
|
||||
|
|
|
@ -194,8 +194,7 @@ HTMLEditor::InsertTableCellsWithTransaction(int32_t aNumberOfCellsToInsert,
|
|||
RefPtr<Element> curCell;
|
||||
nsCOMPtr<nsINode> cellParent;
|
||||
int32_t cellOffset, startRowIndex, startColIndex;
|
||||
nsresult rv = GetCellContext(nullptr,
|
||||
getter_AddRefs(table),
|
||||
nsresult rv = GetCellContext(getter_AddRefs(table),
|
||||
getter_AddRefs(curCell),
|
||||
getter_AddRefs(cellParent), &cellOffset,
|
||||
&startRowIndex, &startColIndex);
|
||||
|
@ -435,12 +434,12 @@ nsresult
|
|||
HTMLEditor::InsertTableColumnsWithTransaction(int32_t aNumberOfColumnsToInsert,
|
||||
InsertPosition aInsertPosition)
|
||||
{
|
||||
RefPtr<Selection> selection;
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
RefPtr<Element> table;
|
||||
RefPtr<Element> curCell;
|
||||
int32_t startRowIndex, startColIndex;
|
||||
nsresult rv = GetCellContext(getter_AddRefs(selection),
|
||||
getter_AddRefs(table),
|
||||
nsresult rv = GetCellContext(getter_AddRefs(table),
|
||||
getter_AddRefs(curCell),
|
||||
nullptr, nullptr,
|
||||
&startRowIndex, &startColIndex);
|
||||
|
@ -504,14 +503,11 @@ HTMLEditor::InsertTableColumnsWithTransaction(int32_t aNumberOfColumnsToInsert,
|
|||
|
||||
// If we are inserting after all existing columns, make sure table is
|
||||
// "well formed" before appending new column.
|
||||
// XXX As far as I've tested, NormalizeTable() always fails to normalize
|
||||
// non-rectangular table. So, the following CellData will fail if
|
||||
// the table is not rectangle.
|
||||
// XXX As far as I've tested, NormalizeTableInternal() always fails to
|
||||
// normalize non-rectangular table. So, the following CellData will
|
||||
// fail if the table is not rectangle.
|
||||
if (startColIndex >= tableSize.mColumnCount) {
|
||||
if (NS_WARN_IF(!selection)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
DebugOnly<nsresult> rv = NormalizeTable(*selection, *table);
|
||||
DebugOnly<nsresult> rv = NormalizeTableInternal(*table);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to normalize the table");
|
||||
}
|
||||
|
||||
|
@ -547,7 +543,8 @@ HTMLEditor::InsertTableColumnsWithTransaction(int32_t aNumberOfColumnsToInsert,
|
|||
// Simply set selection to the current cell. So, we can let
|
||||
// InsertTableCellsWithTransaction() do the work. Insert a new cell
|
||||
// before current one.
|
||||
selection->Collapse(RawRangeBoundary(cellData.mElement, 0), ignoredError);
|
||||
SelectionRefPtr()->Collapse(RawRangeBoundary(cellData.mElement, 0),
|
||||
ignoredError);
|
||||
NS_WARNING_ASSERTION(!ignoredError.Failed(),
|
||||
"Failed to collapse Selection into the cell");
|
||||
rv = InsertTableCellsWithTransaction(aNumberOfColumnsToInsert,
|
||||
|
@ -591,9 +588,10 @@ HTMLEditor::InsertTableColumnsWithTransaction(int32_t aNumberOfColumnsToInsert,
|
|||
|
||||
// Simply add same number of cells to each row. Although tempted to check
|
||||
// cell indexes for current cell, the effects of colspan > 1 in some cells
|
||||
// makes this futile. We must use NormalizeTable first to assure that
|
||||
// there are cells in each cellmap location.
|
||||
selection->Collapse(RawRangeBoundary(lastCellNode, 0), ignoredError);
|
||||
// makes this futile. We must use NormalizeTableInternal() first to assure
|
||||
// that there are cells in each cellmap location.
|
||||
SelectionRefPtr()->Collapse(RawRangeBoundary(lastCellNode, 0),
|
||||
ignoredError);
|
||||
NS_WARNING_ASSERTION(!ignoredError.Failed(),
|
||||
"Failed to collapse Selection into the cell");
|
||||
rv = InsertTableCellsWithTransaction(aNumberOfColumnsToInsert,
|
||||
|
@ -633,8 +631,7 @@ HTMLEditor::InsertTableRowsWithTransaction(int32_t aNumberOfRowsToInsert,
|
|||
RefPtr<Element> curCell;
|
||||
|
||||
int32_t startRowIndex, startColIndex;
|
||||
nsresult rv = GetCellContext(nullptr,
|
||||
getter_AddRefs(table),
|
||||
nsresult rv = GetCellContext(getter_AddRefs(table),
|
||||
getter_AddRefs(curCell),
|
||||
nullptr, nullptr,
|
||||
&startRowIndex, &startColIndex);
|
||||
|
@ -828,17 +825,18 @@ HTMLEditor::InsertTableRowsWithTransaction(int32_t aNumberOfRowsToInsert,
|
|||
}
|
||||
|
||||
nsresult
|
||||
HTMLEditor::DeleteTableElementAndChildrenWithTransaction(Selection& aSelection,
|
||||
Element& aTableElement)
|
||||
HTMLEditor::DeleteTableElementAndChildrenWithTransaction(Element& aTableElement)
|
||||
{
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
// Block selectionchange event. It's enough to dispatch selectionchange
|
||||
// event immediately after removing the table element.
|
||||
{
|
||||
AutoHideSelectionChanges hideSelection(&aSelection);
|
||||
AutoHideSelectionChanges hideSelection(SelectionRefPtr());
|
||||
|
||||
// Select the <table> element after clear current selection.
|
||||
if (aSelection.RangeCount()) {
|
||||
nsresult rv = aSelection.RemoveAllRangesTemporarily();
|
||||
if (SelectionRefPtr()->RangeCount()) {
|
||||
nsresult rv = SelectionRefPtr()->RemoveAllRangesTemporarily();
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -850,13 +848,13 @@ HTMLEditor::DeleteTableElementAndChildrenWithTransaction(Selection& aSelection,
|
|||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
aSelection.AddRange(*range, error);
|
||||
SelectionRefPtr()->AddRange(*range, error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
range = aSelection.GetRangeAt(0);
|
||||
range = SelectionRefPtr()->GetRangeAt(0);
|
||||
MOZ_ASSERT(range);
|
||||
MOZ_ASSERT(range->GetStartContainer() == aTableElement.GetParent());
|
||||
MOZ_ASSERT(range->GetEndContainer() == aTableElement.GetParent());
|
||||
|
@ -882,8 +880,7 @@ HTMLEditor::DeleteTable()
|
|||
}
|
||||
|
||||
RefPtr<Element> table;
|
||||
nsresult rv = GetCellContext(nullptr,
|
||||
getter_AddRefs(table),
|
||||
nsresult rv = GetCellContext(getter_AddRefs(table),
|
||||
nullptr, nullptr, nullptr, nullptr, nullptr);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
|
@ -893,7 +890,7 @@ HTMLEditor::DeleteTable()
|
|||
}
|
||||
|
||||
AutoPlaceholderBatch treateAsOneTransaction(*this);
|
||||
rv = DeleteTableElementAndChildrenWithTransaction(*SelectionRefPtr(), *table);
|
||||
rv = DeleteTableElementAndChildrenWithTransaction(*table);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -919,14 +916,14 @@ HTMLEditor::DeleteTableCell(int32_t aNumberOfCellsToDelete)
|
|||
nsresult
|
||||
HTMLEditor::DeleteTableCellWithTransaction(int32_t aNumberOfCellsToDelete)
|
||||
{
|
||||
RefPtr<Selection> selection;
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
RefPtr<Element> table;
|
||||
RefPtr<Element> cell;
|
||||
int32_t startRowIndex, startColIndex;
|
||||
|
||||
|
||||
nsresult rv = GetCellContext(getter_AddRefs(selection),
|
||||
getter_AddRefs(table),
|
||||
nsresult rv = GetCellContext(getter_AddRefs(table),
|
||||
getter_AddRefs(cell),
|
||||
nullptr, nullptr,
|
||||
&startRowIndex, &startColIndex);
|
||||
|
@ -947,12 +944,12 @@ HTMLEditor::DeleteTableCellWithTransaction(int32_t aNumberOfCellsToDelete)
|
|||
|
||||
ErrorResult error;
|
||||
RefPtr<Element> firstSelectedCellElement =
|
||||
GetFirstSelectedTableCellElement(*selection, error);
|
||||
GetFirstSelectedTableCellElement(error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
|
||||
MOZ_ASSERT(selection->RangeCount());
|
||||
MOZ_ASSERT(SelectionRefPtr()->RangeCount());
|
||||
|
||||
TableSize tableSize(*this, *table, error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
|
@ -964,10 +961,9 @@ HTMLEditor::DeleteTableCellWithTransaction(int32_t aNumberOfCellsToDelete)
|
|||
// If only one cell is selected or no cell is selected, remove cells
|
||||
// starting from the first selected cell or a cell containing first
|
||||
// selection range.
|
||||
if (!firstSelectedCellElement || selection->RangeCount() == 1) {
|
||||
if (!firstSelectedCellElement || SelectionRefPtr()->RangeCount() == 1) {
|
||||
for (int32_t i = 0; i < aNumberOfCellsToDelete; i++) {
|
||||
rv = GetCellContext(getter_AddRefs(selection),
|
||||
getter_AddRefs(table),
|
||||
rv = GetCellContext(getter_AddRefs(table),
|
||||
getter_AddRefs(cell),
|
||||
nullptr, nullptr,
|
||||
&startRowIndex, &startColIndex);
|
||||
|
@ -987,7 +983,7 @@ HTMLEditor::DeleteTableCellWithTransaction(int32_t aNumberOfCellsToDelete)
|
|||
// Remove <tr> or <table> if we're removing all cells in the row or
|
||||
// the table.
|
||||
if (tableSize.mRowCount == 1) {
|
||||
rv = DeleteTableElementAndChildrenWithTransaction(*selection, *table);
|
||||
rv = DeleteTableElementAndChildrenWithTransaction(*table);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -1060,7 +1056,7 @@ HTMLEditor::DeleteTableCellWithTransaction(int32_t aNumberOfCellsToDelete)
|
|||
// delete this row.
|
||||
int32_t nextRow = startRowIndex;
|
||||
while (nextRow == startRowIndex) {
|
||||
cell = GetNextSelectedTableCellElement(*selection, error);
|
||||
cell = GetNextSelectedTableCellElement(error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
|
@ -1075,7 +1071,7 @@ HTMLEditor::DeleteTableCellWithTransaction(int32_t aNumberOfCellsToDelete)
|
|||
startColIndex = nextSelectedCellIndexes.mColumn;
|
||||
}
|
||||
if (tableSize.mRowCount == 1) {
|
||||
rv = DeleteTableElementAndChildrenWithTransaction(*selection, *table);
|
||||
rv = DeleteTableElementAndChildrenWithTransaction(*table);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -1113,7 +1109,7 @@ HTMLEditor::DeleteTableCellWithTransaction(int32_t aNumberOfCellsToDelete)
|
|||
// we delete this column.
|
||||
int32_t nextCol = startColIndex;
|
||||
while (nextCol == startColIndex) {
|
||||
cell = GetNextSelectedTableCellElement(*selection, error);
|
||||
cell = GetNextSelectedTableCellElement(error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
|
@ -1151,8 +1147,7 @@ HTMLEditor::DeleteTableCellWithTransaction(int32_t aNumberOfCellsToDelete)
|
|||
}
|
||||
|
||||
// First get the next cell to delete
|
||||
RefPtr<Element> nextCell =
|
||||
GetNextSelectedTableCellElement(*selection, error);
|
||||
RefPtr<Element> nextCell = GetNextSelectedTableCellElement(error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
|
@ -1202,19 +1197,19 @@ HTMLEditor::DeleteTableCellContents()
|
|||
nsresult
|
||||
HTMLEditor::DeleteTableCellContentsWithTransaction()
|
||||
{
|
||||
RefPtr<Selection> selection;
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
RefPtr<Element> table;
|
||||
RefPtr<Element> cell;
|
||||
int32_t startRowIndex, startColIndex;
|
||||
nsresult rv = GetCellContext(getter_AddRefs(selection),
|
||||
getter_AddRefs(table),
|
||||
nsresult rv = GetCellContext(getter_AddRefs(table),
|
||||
getter_AddRefs(cell),
|
||||
nullptr, nullptr,
|
||||
&startRowIndex, &startColIndex);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
if (NS_WARN_IF(!selection) || NS_WARN_IF(!cell)) {
|
||||
if (NS_WARN_IF(!cell)) {
|
||||
// Don't fail if no cell found.
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1230,7 +1225,7 @@ HTMLEditor::DeleteTableCellContentsWithTransaction()
|
|||
|
||||
ErrorResult error;
|
||||
RefPtr<Element> firstSelectedCellElement =
|
||||
GetFirstSelectedTableCellElement(*selection, error);
|
||||
GetFirstSelectedTableCellElement(error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
|
@ -1260,7 +1255,7 @@ HTMLEditor::DeleteTableCellContentsWithTransaction()
|
|||
}
|
||||
// If there are 2 or more selected cells, keep handling the other selected
|
||||
// cells.
|
||||
cell = GetNextSelectedTableCellElement(*selection, error);
|
||||
cell = GetNextSelectedTableCellElement(error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
|
@ -1289,19 +1284,17 @@ nsresult
|
|||
HTMLEditor::DeleteSelectedTableColumnsWithTransaction(
|
||||
int32_t aNumberOfColumnsToDelete)
|
||||
{
|
||||
RefPtr<Selection> selection;
|
||||
RefPtr<Element> table;
|
||||
RefPtr<Element> cell;
|
||||
int32_t startRowIndex, startColIndex;
|
||||
nsresult rv = GetCellContext(getter_AddRefs(selection),
|
||||
getter_AddRefs(table),
|
||||
nsresult rv = GetCellContext(getter_AddRefs(table),
|
||||
getter_AddRefs(cell),
|
||||
nullptr, nullptr,
|
||||
&startRowIndex, &startColIndex);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
if (NS_WARN_IF(!selection) || NS_WARN_IF(!table) || NS_WARN_IF(!cell)) {
|
||||
if (NS_WARN_IF(!table) || NS_WARN_IF(!cell)) {
|
||||
// Don't fail if no cell found.
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1321,7 +1314,7 @@ HTMLEditor::DeleteSelectedTableColumnsWithTransaction(
|
|||
|
||||
// Shortcut the case of deleting all columns in table
|
||||
if (!startColIndex && aNumberOfColumnsToDelete >= tableSize.mColumnCount) {
|
||||
rv = DeleteTableElementAndChildrenWithTransaction(*selection, *table);
|
||||
rv = DeleteTableElementAndChildrenWithTransaction(*table);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -1331,14 +1324,14 @@ HTMLEditor::DeleteSelectedTableColumnsWithTransaction(
|
|||
|
||||
// Test if deletion is controlled by selected cells
|
||||
RefPtr<Element> firstSelectedCellElement =
|
||||
GetFirstSelectedTableCellElement(*selection, error);
|
||||
GetFirstSelectedTableCellElement(error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
|
||||
MOZ_ASSERT(selection->RangeCount());
|
||||
MOZ_ASSERT(SelectionRefPtr()->RangeCount());
|
||||
|
||||
if (firstSelectedCellElement && selection->RangeCount() > 1) {
|
||||
if (firstSelectedCellElement && SelectionRefPtr()->RangeCount() > 1) {
|
||||
CellIndexes firstCellIndexes(*firstSelectedCellElement, error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
|
@ -1354,7 +1347,7 @@ HTMLEditor::DeleteSelectedTableColumnsWithTransaction(
|
|||
|
||||
// If 2 or more cells are not selected, removing columns starting from
|
||||
// a column which contains first selection range.
|
||||
if (!firstSelectedCellElement || selection->RangeCount() == 1) {
|
||||
if (!firstSelectedCellElement || SelectionRefPtr()->RangeCount() == 1) {
|
||||
int32_t columnCountToRemove =
|
||||
std::min(aNumberOfColumnsToDelete,
|
||||
tableSize.mColumnCount - startColIndex);
|
||||
|
@ -1382,7 +1375,7 @@ HTMLEditor::DeleteSelectedTableColumnsWithTransaction(
|
|||
// to continue after we delete this column
|
||||
int32_t nextCol = startColIndex;
|
||||
while (nextCol == startColIndex) {
|
||||
cell = GetNextSelectedTableCellElement(*selection, error);
|
||||
cell = GetNextSelectedTableCellElement(error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
|
@ -1484,8 +1477,7 @@ HTMLEditor::DeleteTableColumnWithTransaction(Element& aTableElement,
|
|||
if (NS_WARN_IF(!selection)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsresult rv =
|
||||
DeleteTableElementAndChildrenWithTransaction(*selection, aTableElement);
|
||||
nsresult rv = DeleteTableElementAndChildrenWithTransaction(aTableElement);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -1525,19 +1517,19 @@ nsresult
|
|||
HTMLEditor::DeleteSelectedTableRowsWithTransaction(
|
||||
int32_t aNumberOfRowsToDelete)
|
||||
{
|
||||
RefPtr<Selection> selection;
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
RefPtr<Element> table;
|
||||
RefPtr<Element> cell;
|
||||
int32_t startRowIndex, startColIndex;
|
||||
nsresult rv = GetCellContext(getter_AddRefs(selection),
|
||||
getter_AddRefs(table),
|
||||
nsresult rv = GetCellContext(getter_AddRefs(table),
|
||||
getter_AddRefs(cell),
|
||||
nullptr, nullptr,
|
||||
&startRowIndex, &startColIndex);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
if (NS_WARN_IF(!selection) || NS_WARN_IF(!table) || NS_WARN_IF(!cell)) {
|
||||
if (NS_WARN_IF(!table) || NS_WARN_IF(!cell)) {
|
||||
// Don't fail if no cell found.
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1557,7 +1549,7 @@ HTMLEditor::DeleteSelectedTableRowsWithTransaction(
|
|||
|
||||
// Shortcut the case of deleting all rows in table
|
||||
if (!startRowIndex && aNumberOfRowsToDelete >= tableSize.mRowCount) {
|
||||
rv = DeleteTableElementAndChildrenWithTransaction(*selection, *table);
|
||||
rv = DeleteTableElementAndChildrenWithTransaction(*table);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -1565,14 +1557,14 @@ HTMLEditor::DeleteSelectedTableRowsWithTransaction(
|
|||
}
|
||||
|
||||
RefPtr<Element> firstSelectedCellElement =
|
||||
GetFirstSelectedTableCellElement(*selection, error);
|
||||
GetFirstSelectedTableCellElement(error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
|
||||
MOZ_ASSERT(selection->RangeCount());
|
||||
MOZ_ASSERT(SelectionRefPtr()->RangeCount());
|
||||
|
||||
if (firstSelectedCellElement && selection->RangeCount() > 1) {
|
||||
if (firstSelectedCellElement && SelectionRefPtr()->RangeCount() > 1) {
|
||||
// Fetch indexes again - may be different for selected cells
|
||||
CellIndexes firstCellIndexes(*firstSelectedCellElement, error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
|
@ -1595,7 +1587,7 @@ HTMLEditor::DeleteSelectedTableRowsWithTransaction(
|
|||
|
||||
// If 2 or more cells are not selected, removing rows starting from
|
||||
// a row which contains first selection range.
|
||||
if (!firstSelectedCellElement || selection->RangeCount() == 1) {
|
||||
if (!firstSelectedCellElement || SelectionRefPtr()->RangeCount() == 1) {
|
||||
int32_t rowCountToRemove =
|
||||
std::min(aNumberOfRowsToDelete, tableSize.mRowCount - startRowIndex);
|
||||
for (int32_t i = 0; i < rowCountToRemove; i++) {
|
||||
|
@ -1628,7 +1620,7 @@ HTMLEditor::DeleteSelectedTableRowsWithTransaction(
|
|||
// to continue after we delete this row
|
||||
int32_t nextRow = startRowIndex;
|
||||
while (nextRow == startRowIndex) {
|
||||
cell = GetNextSelectedTableCellElement(*selection, error);
|
||||
cell = GetNextSelectedTableCellElement(error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
|
@ -1781,8 +1773,7 @@ HTMLEditor::SelectTable()
|
|||
}
|
||||
|
||||
RefPtr<Element> table =
|
||||
GetElementOrParentByTagNameAtSelection(*SelectionRefPtr(),
|
||||
*nsGkAtoms::table);
|
||||
GetElementOrParentByTagNameAtSelection(*nsGkAtoms::table);
|
||||
if (NS_WARN_IF(!table)) {
|
||||
return NS_OK; // Don't fail if we didn't find a table.
|
||||
}
|
||||
|
@ -1802,8 +1793,7 @@ HTMLEditor::SelectTableCell()
|
|||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
RefPtr<Element> cell =
|
||||
GetElementOrParentByTagNameAtSelection(*SelectionRefPtr(), *nsGkAtoms::td);
|
||||
RefPtr<Element> cell = GetElementOrParentByTagNameAtSelection(*nsGkAtoms::td);
|
||||
if (NS_WARN_IF(!cell)) {
|
||||
return NS_SUCCESS_EDITOR_ELEMENT_NOT_FOUND;
|
||||
}
|
||||
|
@ -1871,8 +1861,7 @@ HTMLEditor::SelectBlockOfCells(Element* aStartCell,
|
|||
int32_t maxRow =
|
||||
std::max(startCellIndexes.mRow, endCellIndexes.mRow);
|
||||
|
||||
RefPtr<Element> cell;
|
||||
cell = GetFirstSelectedTableCellElement(*SelectionRefPtr(), error);
|
||||
RefPtr<Element> cell = GetFirstSelectedTableCellElement(error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
|
@ -1895,7 +1884,7 @@ HTMLEditor::SelectBlockOfCells(Element* aStartCell,
|
|||
MOZ_ASSERT(mSelectedCellIndex > 0);
|
||||
mSelectedCellIndex--;
|
||||
}
|
||||
cell = GetNextSelectedTableCellElement(*SelectionRefPtr(), error);
|
||||
cell = GetNextSelectedTableCellElement(error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
|
@ -1943,7 +1932,7 @@ HTMLEditor::SelectAllTableCells()
|
|||
}
|
||||
|
||||
RefPtr<Element> cell =
|
||||
GetElementOrParentByTagNameAtSelection(*SelectionRefPtr(), *nsGkAtoms::td);
|
||||
GetElementOrParentByTagNameAtSelection(*nsGkAtoms::td);
|
||||
if (NS_WARN_IF(!cell)) {
|
||||
// Don't fail if we didn't find a cell.
|
||||
return NS_SUCCESS_EDITOR_ELEMENT_NOT_FOUND;
|
||||
|
@ -2018,7 +2007,7 @@ HTMLEditor::SelectTableRow()
|
|||
}
|
||||
|
||||
RefPtr<Element> cell =
|
||||
GetElementOrParentByTagNameAtSelection(*SelectionRefPtr(), *nsGkAtoms::td);
|
||||
GetElementOrParentByTagNameAtSelection(*nsGkAtoms::td);
|
||||
if (NS_WARN_IF(!cell)) {
|
||||
// Don't fail if we didn't find a cell.
|
||||
return NS_SUCCESS_EDITOR_ELEMENT_NOT_FOUND;
|
||||
|
@ -2030,8 +2019,7 @@ HTMLEditor::SelectTableRow()
|
|||
RefPtr<Element> table;
|
||||
int32_t startRowIndex, startColIndex;
|
||||
|
||||
nsresult rv = GetCellContext(nullptr,
|
||||
getter_AddRefs(table),
|
||||
nsresult rv = GetCellContext(getter_AddRefs(table),
|
||||
getter_AddRefs(cell),
|
||||
nullptr, nullptr,
|
||||
&startRowIndex, &startColIndex);
|
||||
|
@ -2103,8 +2091,7 @@ HTMLEditor::SelectTableColumn()
|
|||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
RefPtr<Element> cell =
|
||||
GetElementOrParentByTagNameAtSelection(*SelectionRefPtr(), *nsGkAtoms::td);
|
||||
RefPtr<Element> cell = GetElementOrParentByTagNameAtSelection(*nsGkAtoms::td);
|
||||
if (NS_WARN_IF(!cell)) {
|
||||
// Don't fail if we didn't find a cell.
|
||||
return NS_SUCCESS_EDITOR_ELEMENT_NOT_FOUND;
|
||||
|
@ -2116,8 +2103,7 @@ HTMLEditor::SelectTableColumn()
|
|||
RefPtr<Element> table;
|
||||
int32_t startRowIndex, startColIndex;
|
||||
|
||||
nsresult rv = GetCellContext(nullptr,
|
||||
getter_AddRefs(table),
|
||||
nsresult rv = GetCellContext(getter_AddRefs(table),
|
||||
getter_AddRefs(cell),
|
||||
nullptr, nullptr,
|
||||
&startRowIndex, &startColIndex);
|
||||
|
@ -2190,8 +2176,7 @@ HTMLEditor::SplitTableCell()
|
|||
RefPtr<Element> cell;
|
||||
int32_t startRowIndex, startColIndex, actualRowSpan, actualColSpan;
|
||||
// Get cell, table, etc. at selection anchor node
|
||||
nsresult rv = GetCellContext(nullptr,
|
||||
getter_AddRefs(table),
|
||||
nsresult rv = GetCellContext(getter_AddRefs(table),
|
||||
getter_AddRefs(cell),
|
||||
nullptr, nullptr,
|
||||
&startRowIndex, &startColIndex);
|
||||
|
@ -2480,7 +2465,7 @@ HTMLEditor::SwitchTableCellHeaderType(Element* aSourceCell,
|
|||
// Save current selection to restore when done.
|
||||
// This is needed so ReplaceContainerAndCloneAttributesWithTransaction()
|
||||
// can monitor selection when replacing nodes.
|
||||
AutoSelectionRestorer restoreSelectionLater(*SelectionRefPtr(), *this);
|
||||
AutoSelectionRestorer restoreSelectionLater(*this);
|
||||
|
||||
// Set to the opposite of current type
|
||||
nsAtom* newCellName =
|
||||
|
@ -2517,8 +2502,7 @@ HTMLEditor::JoinTableCells(bool aMergeNonContiguousContents)
|
|||
int32_t startRowIndex, startColIndex;
|
||||
|
||||
// Get cell, table, etc. at selection anchor node
|
||||
nsresult rv = GetCellContext(nullptr,
|
||||
getter_AddRefs(table),
|
||||
nsresult rv = GetCellContext(getter_AddRefs(table),
|
||||
getter_AddRefs(targetCell),
|
||||
nullptr, nullptr,
|
||||
&startRowIndex, &startColIndex);
|
||||
|
@ -2545,8 +2529,7 @@ HTMLEditor::JoinTableCells(bool aMergeNonContiguousContents)
|
|||
|
||||
bool joinSelectedCells = false;
|
||||
if (firstSelectedCell.mElement) {
|
||||
RefPtr<Element> secondCell =
|
||||
GetNextSelectedTableCellElement(*SelectionRefPtr(), error);
|
||||
RefPtr<Element> secondCell = GetNextSelectedTableCellElement(error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
|
@ -2791,7 +2774,7 @@ HTMLEditor::JoinTableCells(bool aMergeNonContiguousContents)
|
|||
}
|
||||
|
||||
// Fixup disturbances in table layout
|
||||
DebugOnly<nsresult> rv = NormalizeTable(*SelectionRefPtr(), *table);
|
||||
DebugOnly<nsresult> rv = NormalizeTableInternal(*table);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to normalize the table");
|
||||
} else {
|
||||
// Joining with cell to the right -- get rowspan and colspan data of target
|
||||
|
@ -3118,13 +3101,12 @@ HTMLEditor::NormalizeTable(Element* aTableOrElementInTable)
|
|||
|
||||
if (!aTableOrElementInTable) {
|
||||
aTableOrElementInTable =
|
||||
GetElementOrParentByTagNameAtSelection(*SelectionRefPtr(),
|
||||
*nsGkAtoms::table);
|
||||
GetElementOrParentByTagNameAtSelection(*nsGkAtoms::table);
|
||||
if (!aTableOrElementInTable) {
|
||||
return NS_OK; // Don't throw error even if the element is not in <table>.
|
||||
}
|
||||
}
|
||||
nsresult rv = NormalizeTable(*SelectionRefPtr(), *aTableOrElementInTable);
|
||||
nsresult rv = NormalizeTableInternal(*aTableOrElementInTable);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -3132,9 +3114,9 @@ HTMLEditor::NormalizeTable(Element* aTableOrElementInTable)
|
|||
}
|
||||
|
||||
nsresult
|
||||
HTMLEditor::NormalizeTable(Selection& aSelection,
|
||||
Element& aTableOrElementInTable)
|
||||
HTMLEditor::NormalizeTableInternal(Element& aTableOrElementInTable)
|
||||
{
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
RefPtr<Element> tableElement;
|
||||
if (aTableOrElementInTable.NodeInfo()->NameAtom() == nsGkAtoms::table) {
|
||||
|
@ -3155,7 +3137,7 @@ HTMLEditor::NormalizeTable(Selection& aSelection,
|
|||
}
|
||||
|
||||
// Save current selection
|
||||
AutoSelectionRestorer restoreSelectionLater(aSelection, *this);
|
||||
AutoSelectionRestorer restoreSelectionLater(*this);
|
||||
|
||||
AutoPlaceholderBatch treateAsOneTransaction(*this);
|
||||
// Prevent auto insertion of BR in new cell until we're done
|
||||
|
@ -3277,8 +3259,7 @@ HTMLEditor::CellIndexes::Update(HTMLEditor& aHTMLEditor,
|
|||
// Guarantee the life time of the cell element since Init() will access
|
||||
// layout methods.
|
||||
RefPtr<Element> cellElement =
|
||||
aHTMLEditor.GetElementOrParentByTagNameAtSelection(aSelection,
|
||||
*nsGkAtoms::td);
|
||||
aHTMLEditor.GetElementOrParentByTagNameAtSelection(*nsGkAtoms::td);
|
||||
if (!cellElement) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
|
@ -3375,8 +3356,7 @@ HTMLEditor::GetTableSize(Element* aTableOrElementInTable,
|
|||
Element* tableOrElementInTable = aTableOrElementInTable;
|
||||
if (!tableOrElementInTable) {
|
||||
tableOrElementInTable =
|
||||
GetElementOrParentByTagNameAtSelection(*SelectionRefPtr(),
|
||||
*nsGkAtoms::table);
|
||||
GetElementOrParentByTagNameAtSelection(*nsGkAtoms::table);
|
||||
if (NS_WARN_IF(!tableOrElementInTable)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -3461,9 +3441,7 @@ HTMLEditor::GetCellDataAt(Element* aTableElement,
|
|||
RefPtr<Element> table = aTableElement;
|
||||
if (!table) {
|
||||
// Get the selected table or the table enclosing the selection anchor.
|
||||
table =
|
||||
GetElementOrParentByTagNameAtSelection(*SelectionRefPtr(),
|
||||
*nsGkAtoms::table);
|
||||
table = GetElementOrParentByTagNameAtSelection(*nsGkAtoms::table);
|
||||
if (NS_WARN_IF(!table)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -3552,9 +3530,7 @@ HTMLEditor::GetCellAt(Element* aTableElement,
|
|||
Element* tableElement = aTableElement;
|
||||
if (!tableElement) {
|
||||
// Get the selected table or the table enclosing the selection anchor.
|
||||
tableElement =
|
||||
GetElementOrParentByTagNameAtSelection(*SelectionRefPtr(),
|
||||
*nsGkAtoms::table);
|
||||
tableElement = GetElementOrParentByTagNameAtSelection(*nsGkAtoms::table);
|
||||
if (NS_WARN_IF(!tableElement)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -3602,18 +3578,16 @@ HTMLEditor::GetCellSpansAt(Element* aTable,
|
|||
}
|
||||
|
||||
nsresult
|
||||
HTMLEditor::GetCellContext(Selection** aSelection,
|
||||
Element** aTable,
|
||||
HTMLEditor::GetCellContext(Element** aTable,
|
||||
Element** aCell,
|
||||
nsINode** aCellParent,
|
||||
int32_t* aCellOffset,
|
||||
int32_t* aRowIndex,
|
||||
int32_t* aColumnIndex)
|
||||
{
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
// Initialize return pointers
|
||||
if (aSelection) {
|
||||
*aSelection = nullptr;
|
||||
}
|
||||
if (aTable) {
|
||||
*aTable = nullptr;
|
||||
}
|
||||
|
@ -3633,15 +3607,6 @@ HTMLEditor::GetCellContext(Selection** aSelection,
|
|||
*aColumnIndex = 0;
|
||||
}
|
||||
|
||||
RefPtr<Selection> selection = GetSelection();
|
||||
if (NS_WARN_IF(!selection)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (aSelection) {
|
||||
*aSelection = selection.get();
|
||||
NS_ADDREF(*aSelection);
|
||||
}
|
||||
RefPtr<Element> table;
|
||||
RefPtr<Element> cell;
|
||||
|
||||
|
@ -3657,7 +3622,7 @@ HTMLEditor::GetCellContext(Selection** aSelection,
|
|||
// Find a selected or enclosing table element
|
||||
ErrorResult error;
|
||||
RefPtr<Element> cellOrRowOrTableElement =
|
||||
GetSelectedOrParentTableElement(*selection, error);
|
||||
GetSelectedOrParentTableElement(error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
|
@ -3790,7 +3755,7 @@ HTMLEditor::GetFirstSelectedCell(nsRange** aFirstSelectedRange,
|
|||
|
||||
ErrorResult error;
|
||||
RefPtr<Element> firstSelectedCellElement =
|
||||
GetFirstSelectedTableCellElement(*SelectionRefPtr(), error);
|
||||
GetFirstSelectedTableCellElement(error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
|
@ -3812,12 +3777,13 @@ HTMLEditor::GetFirstSelectedCell(nsRange** aFirstSelectedRange,
|
|||
}
|
||||
|
||||
already_AddRefed<Element>
|
||||
HTMLEditor::GetFirstSelectedTableCellElement(Selection& aSelection,
|
||||
ErrorResult& aRv) const
|
||||
HTMLEditor::GetFirstSelectedTableCellElement(ErrorResult& aRv) const
|
||||
{
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
MOZ_ASSERT(!aRv.Failed());
|
||||
|
||||
nsRange* firstRange = aSelection.GetRangeAt(0);
|
||||
nsRange* firstRange = SelectionRefPtr()->GetRangeAt(0);
|
||||
if (NS_WARN_IF(!firstRange)) {
|
||||
// XXX Why don't we treat "not found" in this case?
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
|
@ -3869,7 +3835,7 @@ HTMLEditor::GetNextSelectedCell(nsRange** aNextSelectedCellRange,
|
|||
|
||||
ErrorResult error;
|
||||
RefPtr<Element> nextSelectedCellElement =
|
||||
GetNextSelectedTableCellElement(*SelectionRefPtr(), error);
|
||||
GetNextSelectedTableCellElement(error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
|
@ -3889,19 +3855,22 @@ HTMLEditor::GetNextSelectedCell(nsRange** aNextSelectedCellRange,
|
|||
}
|
||||
|
||||
already_AddRefed<Element>
|
||||
HTMLEditor::GetNextSelectedTableCellElement(Selection& aSelection,
|
||||
ErrorResult& aRv) const
|
||||
HTMLEditor::GetNextSelectedTableCellElement(ErrorResult& aRv) const
|
||||
{
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
MOZ_ASSERT(!aRv.Failed());
|
||||
|
||||
if (mSelectedCellIndex >= aSelection.RangeCount()) {
|
||||
if (mSelectedCellIndex >= SelectionRefPtr()->RangeCount()) {
|
||||
// We've already returned all selected cells.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(mSelectedCellIndex > 0);
|
||||
for (; mSelectedCellIndex < aSelection.RangeCount(); mSelectedCellIndex++) {
|
||||
nsRange* range = aSelection.GetRangeAt(mSelectedCellIndex);
|
||||
for (;
|
||||
mSelectedCellIndex < SelectionRefPtr()->RangeCount();
|
||||
mSelectedCellIndex++) {
|
||||
nsRange* range = SelectionRefPtr()->GetRangeAt(mSelectedCellIndex);
|
||||
if (NS_WARN_IF(!range)) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
|
@ -3969,7 +3938,7 @@ HTMLEditor::CellAndIndexes::Update(HTMLEditor& aHTMLEditor,
|
|||
mIndexes.mRow = -1;
|
||||
mIndexes.mColumn = -1;
|
||||
|
||||
mElement = aHTMLEditor.GetFirstSelectedTableCellElement(aSelection, aRv);
|
||||
mElement = aHTMLEditor.GetFirstSelectedTableCellElement(aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return;
|
||||
}
|
||||
|
@ -4005,7 +3974,7 @@ HTMLEditor::SetSelectionAfterTableEdit(Element* aTable,
|
|||
if (cell) {
|
||||
if (aSelected) {
|
||||
// Reselect the cell
|
||||
DebugOnly<nsresult> rv = SelectContentInternal(*selection, *cell);
|
||||
DebugOnly<nsresult> rv = SelectContentInternal(*cell);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
|
||||
"Failed to select the cell");
|
||||
return;
|
||||
|
@ -4015,7 +3984,7 @@ HTMLEditor::SetSelectionAfterTableEdit(Element* aTable,
|
|||
// but don't go into nested tables
|
||||
// TODO: Should we really be placing the caret at the END
|
||||
// of the cell content?
|
||||
CollapseSelectionToDeepestNonTableFirstChild(selection, cell);
|
||||
CollapseSelectionToDeepestNonTableFirstChild(cell);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4062,7 +4031,7 @@ HTMLEditor::SetSelectionAfterTableEdit(Element* aTable,
|
|||
}
|
||||
// Last resort: Set selection to start of doc
|
||||
// (it's very bad to not have a valid selection!)
|
||||
SetSelectionAtDocumentStart(selection);
|
||||
SetSelectionAtDocumentStart();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -4086,7 +4055,7 @@ HTMLEditor::GetSelectedOrParentTableElement(nsAString& aTagName,
|
|||
bool isCellSelected = false;
|
||||
ErrorResult aRv;
|
||||
RefPtr<Element> cellOrRowOrTableElement =
|
||||
GetSelectedOrParentTableElement(*SelectionRefPtr(), aRv, &isCellSelected);
|
||||
GetSelectedOrParentTableElement(aRv, &isCellSelected);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return aRv.StealNSResult();
|
||||
}
|
||||
|
@ -4129,10 +4098,11 @@ HTMLEditor::GetSelectedOrParentTableElement(nsAString& aTagName,
|
|||
|
||||
already_AddRefed<Element>
|
||||
HTMLEditor::GetSelectedOrParentTableElement(
|
||||
Selection& aSelection,
|
||||
ErrorResult& aRv,
|
||||
bool* aIsCellSelected /* = nullptr */) const
|
||||
{
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
MOZ_ASSERT(!aRv.Failed());
|
||||
|
||||
if (aIsCellSelected) {
|
||||
|
@ -4140,8 +4110,7 @@ HTMLEditor::GetSelectedOrParentTableElement(
|
|||
}
|
||||
|
||||
// Try to get the first selected cell, first.
|
||||
RefPtr<Element> cellElement =
|
||||
GetFirstSelectedTableCellElement(aSelection, aRv);
|
||||
RefPtr<Element> cellElement = GetFirstSelectedTableCellElement(aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -4153,7 +4122,7 @@ HTMLEditor::GetSelectedOrParentTableElement(
|
|||
return cellElement.forget();
|
||||
}
|
||||
|
||||
const RangeBoundary& anchorRef = aSelection.AnchorRef();
|
||||
const RangeBoundary& anchorRef = SelectionRefPtr()->AnchorRef();
|
||||
if (NS_WARN_IF(!anchorRef.IsSet())) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
|
@ -4214,9 +4183,7 @@ HTMLEditor::GetSelectedCellsType(Element* aElement,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
} else {
|
||||
table =
|
||||
GetElementOrParentByTagNameAtSelection(*SelectionRefPtr(),
|
||||
*nsGkAtoms::table);
|
||||
table = GetElementOrParentByTagNameAtSelection(*nsGkAtoms::table);
|
||||
if (NS_WARN_IF(!table)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -4229,8 +4196,7 @@ HTMLEditor::GetSelectedCellsType(Element* aElement,
|
|||
}
|
||||
|
||||
// Traverse all selected cells
|
||||
RefPtr<Element> selectedCell =
|
||||
GetFirstSelectedTableCellElement(*SelectionRefPtr(), error);
|
||||
RefPtr<Element> selectedCell = GetFirstSelectedTableCellElement(error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
|
@ -4263,7 +4229,7 @@ HTMLEditor::GetSelectedCellsType(Element* aElement,
|
|||
}
|
||||
}
|
||||
selectedCell =
|
||||
GetNextSelectedTableCellElement(*SelectionRefPtr(), ignoredError);
|
||||
GetNextSelectedTableCellElement(ignoredError);
|
||||
NS_WARNING_ASSERTION(!ignoredError.Failed(),
|
||||
"Failed to get next selected table cell element");
|
||||
}
|
||||
|
@ -4278,8 +4244,7 @@ HTMLEditor::GetSelectedCellsType(Element* aElement,
|
|||
indexArray.Clear();
|
||||
|
||||
// Start at first cell again
|
||||
selectedCell = GetFirstSelectedTableCellElement(*SelectionRefPtr(),
|
||||
ignoredError);
|
||||
selectedCell = GetFirstSelectedTableCellElement(ignoredError);
|
||||
while (selectedCell) {
|
||||
CellIndexes selectedCellIndexes(*selectedCell, error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
|
@ -4296,8 +4261,7 @@ HTMLEditor::GetSelectedCellsType(Element* aElement,
|
|||
break;
|
||||
}
|
||||
}
|
||||
selectedCell =
|
||||
GetNextSelectedTableCellElement(*SelectionRefPtr(), ignoredError);
|
||||
selectedCell = GetNextSelectedTableCellElement(ignoredError);
|
||||
NS_WARNING_ASSERTION(!ignoredError.Failed(),
|
||||
"Failed to get next selected table cell element");
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ TextEditRules::Init(TextEditor* aTextEditor)
|
|||
// If the selection hasn't been set up yet, set it up collapsed to the end of
|
||||
// our editable content.
|
||||
if (!SelectionRef().RangeCount()) {
|
||||
rv = TextEditorRef().CollapseSelectionToEnd(&SelectionRef());
|
||||
rv = TextEditorRef().CollapseSelectionToEnd();
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -263,7 +263,7 @@ TextEditRules::AfterEdit(EditSubAction aEditSubAction,
|
|||
AutoSafeEditorData setData(*this, *mTextEditor, *selection);
|
||||
|
||||
nsresult rv =
|
||||
TextEditorRef().HandleInlineSpellCheck(aEditSubAction, *selection,
|
||||
TextEditorRef().HandleInlineSpellCheck(aEditSubAction,
|
||||
mCachedSelectionNode,
|
||||
mCachedSelectionOffset,
|
||||
nullptr, 0, nullptr, 0);
|
||||
|
@ -505,7 +505,7 @@ TextEditRules::CollapseSelectionToTrailingBRIfNeeded()
|
|||
// This is usually performed in TextEditRules::Init(), however, if the
|
||||
// editor is reframed, this may be called by AfterEdit().
|
||||
if (!SelectionRef().RangeCount()) {
|
||||
TextEditorRef().CollapseSelectionToEnd(&SelectionRef());
|
||||
TextEditorRef().CollapseSelectionToEnd();
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -514,7 +514,7 @@ TextEditRules::CollapseSelectionToTrailingBRIfNeeded()
|
|||
// If we are at the end of the <textarea> element, we need to set the
|
||||
// selection to stick to the moz-<br> at the end of the <textarea>.
|
||||
EditorRawDOMPoint selectionStartPoint(
|
||||
EditorBase::GetStartPoint(&SelectionRef()));
|
||||
EditorBase::GetStartPoint(SelectionRef()));
|
||||
if (NS_WARN_IF(!selectionStartPoint.IsSet())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -561,7 +561,7 @@ TextEditRules::GetTextNodeAroundSelectionStartContainer()
|
|||
MOZ_ASSERT(IsEditorDataAvailable());
|
||||
|
||||
EditorRawDOMPoint selectionStartPoint(
|
||||
EditorBase::GetStartPoint(&SelectionRef()));
|
||||
EditorBase::GetStartPoint(SelectionRef()));
|
||||
if (NS_WARN_IF(!selectionStartPoint.IsSet())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -979,8 +979,7 @@ TextEditRules::WillSetText(bool* aCancel,
|
|||
|
||||
// Even if empty text, we don't remove text node and set empty text
|
||||
// for performance
|
||||
rv = TextEditorRef().SetTextImpl(SelectionRef(), tString,
|
||||
*curNode->GetAsText());
|
||||
rv = TextEditorRef().SetTextImpl(tString, *curNode->GetAsText());
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -1080,9 +1079,7 @@ TextEditRules::DeleteSelectionWithTransaction(
|
|||
nsAutoScriptBlocker scriptBlocker;
|
||||
|
||||
if (IsPasswordEditor()) {
|
||||
nsresult rv =
|
||||
TextEditorRef().ExtendSelectionForDelete(&SelectionRef(),
|
||||
&aCollapsedAction);
|
||||
nsresult rv = TextEditorRef().ExtendSelectionForDelete(&aCollapsedAction);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -1123,7 +1120,7 @@ TextEditRules::DeleteSelectionWithTransaction(
|
|||
}
|
||||
} else {
|
||||
EditorRawDOMPoint selectionStartPoint(
|
||||
EditorBase::GetStartPoint(&SelectionRef()));
|
||||
EditorBase::GetStartPoint(SelectionRef()));
|
||||
if (NS_WARN_IF(!selectionStartPoint.IsSet())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -1142,8 +1139,7 @@ TextEditRules::DeleteSelectionWithTransaction(
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
rv = TextEditorRef().ExtendSelectionForDelete(&SelectionRef(),
|
||||
&aCollapsedAction);
|
||||
rv = TextEditorRef().ExtendSelectionForDelete(&aCollapsedAction);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -1170,7 +1166,7 @@ TextEditRules::DidDeleteSelection()
|
|||
MOZ_ASSERT(IsEditorDataAvailable());
|
||||
|
||||
EditorRawDOMPoint selectionStartPoint(
|
||||
EditorBase::GetStartPoint(&SelectionRef()));
|
||||
EditorBase::GetStartPoint(SelectionRef()));
|
||||
if (NS_WARN_IF(!selectionStartPoint.IsSet())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -1817,8 +1813,7 @@ TextEditRules::CreateBRInternal(
|
|||
}
|
||||
|
||||
RefPtr<Element> brElement =
|
||||
TextEditorRef().InsertBrElementWithTransaction(SelectionRef(),
|
||||
aPointToInsert);
|
||||
TextEditorRef().InsertBrElementWithTransaction(aPointToInsert);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return CreateElementResult(NS_ERROR_EDITOR_DESTROYED);
|
||||
}
|
||||
|
|
|
@ -66,12 +66,10 @@ using namespace dom;
|
|||
|
||||
template already_AddRefed<Element>
|
||||
TextEditor::InsertBrElementWithTransaction(
|
||||
Selection& aSelection,
|
||||
const EditorDOMPoint& aPointToInsert,
|
||||
EDirection aSelect);
|
||||
template already_AddRefed<Element>
|
||||
TextEditor::InsertBrElementWithTransaction(
|
||||
Selection& aSelection,
|
||||
const EditorRawDOMPoint& aPointToInsert,
|
||||
EDirection aSelect);
|
||||
|
||||
|
@ -463,10 +461,11 @@ TextEditor::OnInputParagraphSeparator()
|
|||
template<typename PT, typename CT>
|
||||
already_AddRefed<Element>
|
||||
TextEditor::InsertBrElementWithTransaction(
|
||||
Selection& aSelection,
|
||||
const EditorDOMPointBase<PT, CT>& aPointToInsert,
|
||||
EDirection aSelect /* = eNone */)
|
||||
{
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
if (NS_WARN_IF(!aPointToInsert.IsSet())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -520,7 +519,7 @@ TextEditor::InsertBrElementWithTransaction(
|
|||
case eNone:
|
||||
break;
|
||||
case eNext: {
|
||||
aSelection.SetInterlinePosition(true, IgnoreErrors());
|
||||
SelectionRefPtr()->SetInterlinePosition(true, IgnoreErrors());
|
||||
// Collapse selection after the <br> node.
|
||||
EditorRawDOMPoint afterBRElement(newBRElement);
|
||||
if (afterBRElement.IsSet()) {
|
||||
|
@ -528,7 +527,7 @@ TextEditor::InsertBrElementWithTransaction(
|
|||
NS_WARNING_ASSERTION(advanced,
|
||||
"Failed to advance offset after the <br> element");
|
||||
ErrorResult error;
|
||||
aSelection.Collapse(afterBRElement, error);
|
||||
SelectionRefPtr()->Collapse(afterBRElement, error);
|
||||
NS_WARNING_ASSERTION(!error.Failed(),
|
||||
"Failed to collapse selection after the <br> element");
|
||||
} else {
|
||||
|
@ -537,12 +536,12 @@ TextEditor::InsertBrElementWithTransaction(
|
|||
break;
|
||||
}
|
||||
case ePrevious: {
|
||||
aSelection.SetInterlinePosition(true, IgnoreErrors());
|
||||
SelectionRefPtr()->SetInterlinePosition(true, IgnoreErrors());
|
||||
// Collapse selection at the <br> node.
|
||||
EditorRawDOMPoint atBRElement(newBRElement);
|
||||
if (atBRElement.IsSet()) {
|
||||
ErrorResult error;
|
||||
aSelection.Collapse(atBRElement, error);
|
||||
SelectionRefPtr()->Collapse(atBRElement, error);
|
||||
NS_WARNING_ASSERTION(!error.Failed(),
|
||||
"Failed to collapse selection at the <br> element");
|
||||
} else {
|
||||
|
@ -560,10 +559,11 @@ TextEditor::InsertBrElementWithTransaction(
|
|||
}
|
||||
|
||||
nsresult
|
||||
TextEditor::ExtendSelectionForDelete(Selection* aSelection,
|
||||
nsIEditor::EDirection* aAction)
|
||||
TextEditor::ExtendSelectionForDelete(nsIEditor::EDirection* aAction)
|
||||
{
|
||||
bool bCollapsed = aSelection->IsCollapsed();
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
bool bCollapsed = SelectionRefPtr()->IsCollapsed();
|
||||
|
||||
if (*aAction == eNextWord ||
|
||||
*aAction == ePreviousWord ||
|
||||
|
@ -609,7 +609,7 @@ TextEditor::ExtendSelectionForDelete(Selection* aSelection,
|
|||
// to make sure that pressing backspace will only delete the last
|
||||
// typed character.
|
||||
EditorRawDOMPoint atStartOfSelection =
|
||||
EditorBase::GetStartPoint(aSelection);
|
||||
EditorBase::GetStartPoint(*SelectionRefPtr());
|
||||
if (NS_WARN_IF(!atStartOfSelection.IsSet())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -847,7 +847,7 @@ TextEditor::DeleteSelectionWithTransaction(EDirection aDirection,
|
|||
}
|
||||
|
||||
// Delete the specified amount
|
||||
nsresult rv = DoTransaction(deleteSelectionTransaction);
|
||||
nsresult rv = DoTransactionInternal(deleteSelectionTransaction);
|
||||
|
||||
if (mRules && mRules->AsHTMLEditRules() && deleteCharData) {
|
||||
MOZ_ASSERT(deleteNode);
|
||||
|
@ -1172,7 +1172,7 @@ TextEditor::InsertParagraphSeparatorAsAction()
|
|||
rv = selection->Collapse(pointAfterInsertedLineBreak);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// see if we're at the end of the editor range
|
||||
EditorRawDOMPoint endPoint = GetEndPoint(selection);
|
||||
EditorRawDOMPoint endPoint = EditorBase::GetEndPoint(*selection);
|
||||
if (endPoint == pointAfterInsertedLineBreak) {
|
||||
// SetInterlinePosition(true) means we want the caret to stick to the
|
||||
// content on the "right". We want the caret to stick to whatever is
|
||||
|
@ -1313,7 +1313,7 @@ TextEditor::SetTextAsSubAction(const nsAString& aString)
|
|||
}
|
||||
rv = selection->Collapse(rootElement, 0);
|
||||
} else {
|
||||
rv = EditorBase::SelectEntireDocument(selection);
|
||||
rv = EditorBase::SelectEntireDocument();
|
||||
}
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = ReplaceSelectionAsSubAction(aString);
|
||||
|
@ -2239,9 +2239,11 @@ TextEditor::OnEndHandlingTopLevelEditSubAction()
|
|||
}
|
||||
|
||||
nsresult
|
||||
TextEditor::SelectEntireDocument(Selection* aSelection)
|
||||
TextEditor::SelectEntireDocument()
|
||||
{
|
||||
if (!aSelection || !mRules) {
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
if (!mRules) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
|
@ -2257,16 +2259,19 @@ TextEditor::SelectEntireDocument(Selection* aSelection)
|
|||
}
|
||||
|
||||
// if it's empty don't select entire doc - that would select the bogus node
|
||||
return aSelection->Collapse(rootElement, 0);
|
||||
return SelectionRefPtr()->Collapse(rootElement, 0);
|
||||
}
|
||||
|
||||
SelectionBatcher selectionBatcher(aSelection);
|
||||
nsresult rv = EditorBase::SelectEntireDocument(aSelection);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
SelectionBatcher selectionBatcher(SelectionRefPtr());
|
||||
nsresult rv = EditorBase::SelectEntireDocument();
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Don't select the trailing BR node if we have one
|
||||
nsCOMPtr<nsIContent> childNode;
|
||||
rv = GetEndChildNode(aSelection, getter_AddRefs(childNode));
|
||||
rv = EditorBase::GetEndChildNode(*SelectionRefPtr(),
|
||||
getter_AddRefs(childNode));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -2278,7 +2283,7 @@ TextEditor::SelectEntireDocument(Selection* aSelection)
|
|||
int32_t parentOffset;
|
||||
nsINode* parentNode = GetNodeLocation(childNode, &parentOffset);
|
||||
|
||||
return aSelection->Extend(parentNode, parentOffset);
|
||||
return SelectionRefPtr()->Extend(parentNode, parentOffset);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -314,7 +314,6 @@ protected: // May be called by friends.
|
|||
* before aPointToInsert. Then, tries to collapse selection at or after the
|
||||
* new <br> node if aSelect is not eNone.
|
||||
*
|
||||
* @param aSelection The selection of this editor.
|
||||
* @param aPointToInsert The DOM point where should be <br> node inserted
|
||||
* before.
|
||||
* @param aSelect If eNone, this won't change selection.
|
||||
|
@ -328,7 +327,6 @@ protected: // May be called by friends.
|
|||
template<typename PT, typename CT>
|
||||
already_AddRefed<Element>
|
||||
InsertBrElementWithTransaction(
|
||||
Selection& aSelection,
|
||||
const EditorDOMPointBase<PT, CT>& aPointToInsert,
|
||||
EDirection aSelect = eNone);
|
||||
|
||||
|
@ -337,8 +335,7 @@ protected: // May be called by friends.
|
|||
* If done, also update aAction to what's actually left to do after the
|
||||
* extension.
|
||||
*/
|
||||
nsresult ExtendSelectionForDelete(Selection* aSelection,
|
||||
nsIEditor::EDirection* aAction);
|
||||
nsresult ExtendSelectionForDelete(nsIEditor::EDirection* aAction);
|
||||
|
||||
/**
|
||||
* HideLastPasswordInput() is called by timer callback of TextEditRules.
|
||||
|
@ -369,7 +366,7 @@ protected: // Shouldn't be used by friend classes
|
|||
/**
|
||||
* Make the given selection span the entire document.
|
||||
*/
|
||||
virtual nsresult SelectEntireDocument(Selection* aSelection) override;
|
||||
virtual nsresult SelectEntireDocument() override;
|
||||
|
||||
/**
|
||||
* OnInputText() is called when user inputs text with keyboard or something.
|
||||
|
|
|
@ -73,7 +73,7 @@ TypeInState::UpdateSelState(Selection* aSelection)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
mLastSelectionPoint = EditorBase::GetStartPoint(aSelection);
|
||||
mLastSelectionPoint = EditorBase::GetStartPoint(*aSelection);
|
||||
if (!mLastSelectionPoint.IsSet()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ TypeInState::OnSelectionChange(Selection& aSelection)
|
|||
|
||||
if (aSelection.IsCollapsed() && aSelection.RangeCount()) {
|
||||
EditorRawDOMPoint selectionStartPoint(
|
||||
EditorBase::GetStartPoint(&aSelection));
|
||||
EditorBase::GetStartPoint(aSelection));
|
||||
if (NS_WARN_IF(!selectionStartPoint.IsSet())) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -265,8 +265,7 @@ WSRunObject::InsertBreak(Selection& aSelection,
|
|||
}
|
||||
|
||||
RefPtr<Element> newBrElement =
|
||||
mHTMLEditor->InsertBrElementWithTransaction(aSelection, pointToInsert,
|
||||
aSelect);
|
||||
mHTMLEditor->InsertBrElementWithTransaction(pointToInsert, aSelect);
|
||||
if (NS_WARN_IF(!newBrElement)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -1898,8 +1897,7 @@ WSRunObject::CheckTrailingNBSPOfRun(WSFragment *aRun)
|
|||
// they type 2 spaces.
|
||||
|
||||
RefPtr<Element> brElement =
|
||||
htmlEditor->InsertBrElementWithTransaction(*selection,
|
||||
aRun->EndPoint());
|
||||
htmlEditor->InsertBrElementWithTransaction(aRun->EndPoint());
|
||||
if (NS_WARN_IF(!brElement)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
|
|
@ -397,11 +397,8 @@ interface nsIHTMLEditor : nsISupports
|
|||
* Selection and focus state. When this method shows or hides UI, the
|
||||
* editor (and/or its document/window) could be broken by mutation observers.
|
||||
* FYI: Current user in script is only BlueGriffon.
|
||||
*
|
||||
* @param aSelection Selection instance for the normal selection of the
|
||||
* document.
|
||||
*/
|
||||
void checkSelectionStateForAnonymousButtons(in Selection aSelection);
|
||||
void checkSelectionStateForAnonymousButtons();
|
||||
|
||||
boolean isAnonymousElement(in Element aElement);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче