Bug 1347367 - Remove unimplemented FindUserSelectAllNode. r?masayuki draft
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Wed, 15 Mar 2017 13:40:23 +0900
changeset 498727 0162e47997335547bc36b78347c7a6adb3398162
parent 497206 f9362554866b327700c7f9b18050d7b7eb3d2b23
child 549231 7c81d4c650787271cdf47fea27ac86a31fcde4aa
push id49285
push userm_kato@ga2.so-net.ne.jp
push dateWed, 15 Mar 2017 07:08:12 +0000
reviewersmasayuki
bugs1347367, 769967
milestone55.0a1
Bug 1347367 - Remove unimplemented FindUserSelectAllNode. r?masayuki After bug 769967, FindUserSelectAllNode always returns nullptr. So we get rid of this method. Also, AreaRestriction is used by this, so it is unnecessary now. MozReview-Commit-ID: HTc8PUCQmy5
editor/libeditor/EditorBase.h
editor/libeditor/HTMLEditorEventListener.cpp
editor/libeditor/TextEditorDataTransfer.cpp
editor/libeditor/WSRunObject.cpp
editor/libeditor/WSRunObject.h
--- a/editor/libeditor/EditorBase.h
+++ b/editor/libeditor/EditorBase.h
@@ -926,21 +926,16 @@ public:
                                           int32_t aIndex,
                                           nsIDOMDocument* aSourceDoc,
                                           nsIDOMNode* aDestinationNode,
                                           int32_t aDestOffset,
                                           bool aDoDeleteSelection) = 0;
 
   virtual nsresult InsertFromDrop(nsIDOMEvent* aDropEvent) = 0;
 
-  virtual already_AddRefed<nsIDOMNode> FindUserSelectAllNode(nsIDOMNode* aNode)
-  {
-    return nullptr;
-  }
-
   /**
    * GetIMESelectionStartOffsetIn() returns the start offset of IME selection in
    * the aTextNode.  If there is no IME selection, returns -1.
    */
   int32_t GetIMESelectionStartOffsetIn(nsINode* aTextNode);
 
   /**
    * FindBetterInsertionPoint() tries to look for better insertion point which
--- a/editor/libeditor/HTMLEditorEventListener.cpp
+++ b/editor/libeditor/HTMLEditorEventListener.cpp
@@ -172,27 +172,16 @@ HTMLEditorEventListener::MouseDown(nsIDO
           if (linkElement) {
             element = linkElement;
           }
         }
       }
       // Select entire element clicked on if NOT within an existing selection
       //   and not the entire body, or table-related elements
       if (element) {
-        nsCOMPtr<nsIDOMNode> selectAllNode =
-          htmlEditor->FindUserSelectAllNode(element);
-
-        if (selectAllNode) {
-          nsCOMPtr<nsIDOMElement> newElement = do_QueryInterface(selectAllNode);
-          if (newElement) {
-            node = selectAllNode;
-            element = newElement;
-          }
-        }
-
         if (isContextClick && !HTMLEditUtils::IsImage(node)) {
           selection->Collapse(parent, offset);
         } else {
           htmlEditor->SelectElement(element);
         }
         if (DetachedFromEditor()) {
           return NS_OK;
         }
--- a/editor/libeditor/TextEditorDataTransfer.cpp
+++ b/editor/libeditor/TextEditorDataTransfer.cpp
@@ -224,33 +224,16 @@ TextEditor::InsertFromDrop(nsIDOMEvent* 
   rv = uiEvent->GetRangeOffset(&newSelectionOffset);
   NS_ENSURE_SUCCESS(rv, rv);
 
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE);
 
   bool isCollapsed = selection->Collapsed();
 
-  // Only the HTMLEditor::FindUserSelectAllNode returns a node.
-  nsCOMPtr<nsIDOMNode> userSelectNode = FindUserSelectAllNode(newSelectionParent);
-  if (userSelectNode) {
-    // The drop is happening over a "-moz-user-select: all"
-    // subtree so make sure the content we insert goes before
-    // the root of the subtree.
-    //
-    // XXX: Note that inserting before the subtree matches the
-    //      current behavior when dropping on top of an image.
-    //      The decision for dropping before or after the
-    //      subtree should really be done based on coordinates.
-
-    newSelectionParent = GetNodeLocation(userSelectNode, &newSelectionOffset);
-
-    NS_ENSURE_TRUE(newSelectionParent, NS_ERROR_FAILURE);
-  }
-
   // Check if mouse is in the selection
   // if so, jump through some hoops to determine if mouse is over selection (bail)
   // and whether user wants to copy selection or delete it
   if (!isCollapsed) {
     // We never have to delete if selection is already collapsed
     bool cursorIsInSelection = false;
 
     int32_t rangeCount;
--- a/editor/libeditor/WSRunObject.cpp
+++ b/editor/libeditor/WSRunObject.cpp
@@ -189,18 +189,17 @@ WSRunObject::InsertBreak(nsCOMPtr<nsINod
     // Handle any changes needed to ws run after inserted br
     if (!afterRun || (afterRun->mType & WSType::trailingWS)) {
       // Don't need to do anything.  Just insert break.  ws won't change.
     } else if (afterRun->mType & WSType::leadingWS) {
       // Delete the leading ws that is after insertion point.  We don't
       // have to (it would still not be significant after br), but it's
       // just more aesthetically pleasing to.
       nsresult rv = DeleteChars(*aInOutParent, *aInOutOffset,
-                                afterRun->mEndNode, afterRun->mEndOffset,
-                                eOutsideUserSelectAll);
+                                afterRun->mEndNode, afterRun->mEndOffset);
       NS_ENSURE_SUCCESS(rv, nullptr);
     } else if (afterRun->mType == WSType::normalWS) {
       // Need to determine if break at front of non-nbsp run.  If so, convert
       // run to nbsp.
       WSPoint thePoint = GetCharAfter(*aInOutParent, *aInOutOffset);
       if (thePoint.mTextNode && nsCRT::IsAsciiSpace(thePoint.mChar)) {
         WSPoint prevPoint = GetCharBefore(thePoint);
         if (prevPoint.mTextNode && !nsCRT::IsAsciiSpace(prevPoint.mChar)) {
@@ -213,18 +212,17 @@ WSRunObject::InsertBreak(nsCOMPtr<nsINod
 
     // Handle any changes needed to ws run before inserted br
     if (!beforeRun || (beforeRun->mType & WSType::leadingWS)) {
       // Don't need to do anything.  Just insert break.  ws won't change.
     } else if (beforeRun->mType & WSType::trailingWS) {
       // Need to delete the trailing ws that is before insertion point, because it
       // would become significant after break inserted.
       nsresult rv = DeleteChars(beforeRun->mStartNode, beforeRun->mStartOffset,
-                                *aInOutParent, *aInOutOffset,
-                                eOutsideUserSelectAll);
+                                *aInOutParent, *aInOutOffset);
       NS_ENSURE_SUCCESS(rv, nullptr);
     } else if (beforeRun->mType == WSType::normalWS) {
       // Try to change an nbsp to a space, just to prevent nbsp proliferation
       nsresult rv = CheckTrailingNBSP(beforeRun, *aInOutParent, *aInOutOffset);
       NS_ENSURE_SUCCESS(rv, nullptr);
     }
   }
 
@@ -267,34 +265,34 @@ WSRunObject::InsertText(const nsAString&
     // Handle any changes needed to ws run after inserted text
     if (!afterRun || afterRun->mType & WSType::trailingWS) {
       // Don't need to do anything.  Just insert text.  ws won't change.
     } else if (afterRun->mType & WSType::leadingWS) {
       // Delete the leading ws that is after insertion point, because it
       // would become significant after text inserted.
       nsresult rv =
         DeleteChars(*aInOutParent, *aInOutOffset, afterRun->mEndNode,
-                    afterRun->mEndOffset, eOutsideUserSelectAll);
+                    afterRun->mEndOffset);
       NS_ENSURE_SUCCESS(rv, rv);
     } else if (afterRun->mType == WSType::normalWS) {
       // Try to change an nbsp to a space, if possible, just to prevent nbsp
       // proliferation
       nsresult rv = CheckLeadingNBSP(afterRun, *aInOutParent, *aInOutOffset);
       NS_ENSURE_SUCCESS(rv, rv);
     }
 
     // Handle any changes needed to ws run before inserted text
     if (!beforeRun || beforeRun->mType & WSType::leadingWS) {
       // Don't need to do anything.  Just insert text.  ws won't change.
     } else if (beforeRun->mType & WSType::trailingWS) {
       // Need to delete the trailing ws that is before insertion point, because
       // it would become significant after text inserted.
       nsresult rv =
         DeleteChars(beforeRun->mStartNode, beforeRun->mStartOffset,
-                    *aInOutParent, *aInOutOffset, eOutsideUserSelectAll);
+                    *aInOutParent, *aInOutOffset);
       NS_ENSURE_SUCCESS(rv, rv);
     } else if (beforeRun->mType == WSType::normalWS) {
       // Try to change an nbsp to a space, if possible, just to prevent nbsp
       // proliferation
       nsresult rv = CheckTrailingNBSP(beforeRun, *aInOutParent, *aInOutOffset);
       NS_ENSURE_SUCCESS(rv, rv);
     }
   }
@@ -1153,54 +1151,53 @@ WSRunObject::PrepareToDeleteRangePriv(WS
   WSFragment *beforeRun, *afterRun;
   FindRun(mNode, mOffset, &beforeRun, false);
   aEndObject->FindRun(aEndObject->mNode, aEndObject->mOffset, &afterRun, true);
 
   // trim after run of any leading ws
   if (afterRun && (afterRun->mType & WSType::leadingWS)) {
     nsresult rv =
       aEndObject->DeleteChars(aEndObject->mNode, aEndObject->mOffset,
-                              afterRun->mEndNode, afterRun->mEndOffset,
-                              eOutsideUserSelectAll);
+                              afterRun->mEndNode, afterRun->mEndOffset);
     NS_ENSURE_SUCCESS(rv, rv);
   }
   // adjust normal ws in afterRun if needed
   if (afterRun && afterRun->mType == WSType::normalWS && !aEndObject->mPRE) {
     if ((beforeRun && (beforeRun->mType & WSType::leadingWS)) ||
         (!beforeRun && ((mStartReason & WSType::block) ||
                         mStartReason == WSType::br))) {
       // make sure leading char of following ws is an nbsp, so that it will show up
       WSPoint point = aEndObject->GetCharAfter(aEndObject->mNode,
                                                aEndObject->mOffset);
       if (point.mTextNode && nsCRT::IsAsciiSpace(point.mChar)) {
-        nsresult rv = aEndObject->ConvertToNBSP(point, eOutsideUserSelectAll);
+        nsresult rv = aEndObject->ConvertToNBSP(point);
         NS_ENSURE_SUCCESS(rv, rv);
       }
     }
   }
   // trim before run of any trailing ws
   if (beforeRun && (beforeRun->mType & WSType::trailingWS)) {
     nsresult rv = DeleteChars(beforeRun->mStartNode, beforeRun->mStartOffset,
-                              mNode, mOffset, eOutsideUserSelectAll);
+                              mNode, mOffset);
     NS_ENSURE_SUCCESS(rv, rv);
   } else if (beforeRun && beforeRun->mType == WSType::normalWS && !mPRE) {
     if ((afterRun && (afterRun->mType & WSType::trailingWS)) ||
         (afterRun && afterRun->mType == WSType::normalWS) ||
         (!afterRun && (aEndObject->mEndReason & WSType::block))) {
       // make sure trailing char of starting ws is an nbsp, so that it will show up
       WSPoint point = GetCharBefore(mNode, mOffset);
       if (point.mTextNode && nsCRT::IsAsciiSpace(point.mChar)) {
         RefPtr<Text> wsStartNode, wsEndNode;
         int32_t wsStartOffset, wsEndOffset;
         GetAsciiWSBounds(eBoth, mNode, mOffset,
                          getter_AddRefs(wsStartNode), &wsStartOffset,
                          getter_AddRefs(wsEndNode), &wsEndOffset);
         point.mTextNode = wsStartNode;
         point.mOffset = wsStartOffset;
-        nsresult rv = ConvertToNBSP(point, eOutsideUserSelectAll);
+        nsresult rv = ConvertToNBSP(point);
         NS_ENSURE_SUCCESS(rv, rv);
       }
     }
   }
   return NS_OK;
 }
 
 nsresult
@@ -1243,38 +1240,22 @@ WSRunObject::PrepareToSplitAcrossBlocksP
   }
   return NS_OK;
 }
 
 nsresult
 WSRunObject::DeleteChars(nsINode* aStartNode,
                          int32_t aStartOffset,
                          nsINode* aEndNode,
-                         int32_t aEndOffset,
-                         AreaRestriction aAR)
+                         int32_t aEndOffset)
 {
   // MOOSE: this routine needs to be modified to preserve the integrity of the
   // wsFragment info.
   NS_ENSURE_TRUE(aStartNode && aEndNode, NS_ERROR_NULL_POINTER);
 
-  if (aAR == eOutsideUserSelectAll) {
-    nsCOMPtr<nsIDOMNode> san =
-      mHTMLEditor->FindUserSelectAllNode(GetAsDOMNode(aStartNode));
-    if (san) {
-      return NS_OK;
-    }
-
-    if (aStartNode != aEndNode) {
-      san = mHTMLEditor->FindUserSelectAllNode(GetAsDOMNode(aEndNode));
-      if (san) {
-        return NS_OK;
-      }
-    }
-  }
-
   if (aStartNode == aEndNode && aStartOffset == aEndOffset) {
     // Nothing to delete
     return NS_OK;
   }
 
   int32_t idx = mNodeArray.IndexOf(aStartNode);
   if (idx == -1) {
     // If our strarting point wasn't one of our ws text nodes, then just go
@@ -1431,30 +1412,22 @@ WSRunObject::GetCharBefore(const WSPoint
       outPoint.mOffset = len - 1;
       outPoint.mChar = GetCharAt(outPoint.mTextNode, len - 1);
     }
   }
   return outPoint;
 }
 
 nsresult
-WSRunObject::ConvertToNBSP(WSPoint aPoint, AreaRestriction aAR)
+WSRunObject::ConvertToNBSP(WSPoint aPoint)
 {
   // MOOSE: this routine needs to be modified to preserve the integrity of the
   // wsFragment info.
   NS_ENSURE_TRUE(aPoint.mTextNode, NS_ERROR_NULL_POINTER);
 
-  if (aAR == eOutsideUserSelectAll) {
-    nsCOMPtr<nsIDOMNode> san =
-      mHTMLEditor->FindUserSelectAllNode(GetAsDOMNode(aPoint.mTextNode));
-    if (san) {
-      return NS_OK;
-    }
-  }
-
   // First, insert an nbsp
   AutoTransactionsConserveSelection dontSpazMySelection(mHTMLEditor);
   nsAutoString nbspStr(nbsp);
   nsresult rv =
     mHTMLEditor->InsertTextIntoTextNodeImpl(nbspStr, *aPoint.mTextNode,
                                             aPoint.mOffset, true);
   NS_ENSURE_SUCCESS(rv, rv);
 
--- a/editor/libeditor/WSRunObject.h
+++ b/editor/libeditor/WSRunObject.h
@@ -303,21 +303,16 @@ protected:
 
     WSPoint(dom::Text* aTextNode, int32_t aOffset, char16_t aChar)
       : mTextNode(aTextNode)
       , mOffset(aOffset)
       , mChar(aChar)
     {}
   };
 
-  enum AreaRestriction
-  {
-    eAnywhere, eOutsideUserSelectAll
-  };
-
   /**
    * Return the node which we will handle white-space under. This is the
    * closest block within the DOM subtree we're editing, or if none is
    * found, the (inline) root of the editable subtree.
    */
   nsINode* GetWSBoundingParent();
 
   nsresult GetWSNodes();
@@ -327,24 +322,22 @@ protected:
   nsIContent* GetPreviousWSNodeInner(nsINode* aStartNode,
                                      nsINode* aBlockParent);
   nsIContent* GetPreviousWSNode(EditorDOMPoint aPoint, nsINode* aBlockParent);
   nsIContent* GetNextWSNodeInner(nsINode* aStartNode, nsINode* aBlockParent);
   nsIContent* GetNextWSNode(EditorDOMPoint aPoint, nsINode* aBlockParent);
   nsresult PrepareToDeleteRangePriv(WSRunObject* aEndObject);
   nsresult PrepareToSplitAcrossBlocksPriv();
   nsresult DeleteChars(nsINode* aStartNode, int32_t aStartOffset,
-                       nsINode* aEndNode, int32_t aEndOffset,
-                       AreaRestriction aAR = eAnywhere);
+                       nsINode* aEndNode, int32_t aEndOffset);
   WSPoint GetCharAfter(nsINode* aNode, int32_t aOffset);
   WSPoint GetCharBefore(nsINode* aNode, int32_t aOffset);
   WSPoint GetCharAfter(const WSPoint& aPoint);
   WSPoint GetCharBefore(const WSPoint& aPoint);
-  nsresult ConvertToNBSP(WSPoint aPoint,
-                         AreaRestriction aAR = eAnywhere);
+  nsresult ConvertToNBSP(WSPoint aPoint);
   void GetAsciiWSBounds(int16_t aDir, nsINode* aNode, int32_t aOffset,
                         dom::Text** outStartNode, int32_t* outStartOffset,
                         dom::Text** outEndNode, int32_t* outEndOffset);
   void FindRun(nsINode* aNode, int32_t aOffset, WSFragment** outRun,
                bool after);
   char16_t GetCharAt(dom::Text* aTextNode, int32_t aOffset);
   WSPoint GetWSPointAfter(nsINode* aNode, int32_t aOffset);
   WSPoint GetWSPointBefore(nsINode* aNode, int32_t aOffset);