Bug 1562655: rename `Selection::HasSameRoot` to `HasSameRootOrSameComposedDoc`. r=masayuki
authorMirko Brodesser <mbrodesser@mozilla.com>
Mon, 01 Jul 2019 17:20:28 +0200
changeset 540602 109ccdeb96342a315b86ef0c7ebe76738308673b
parent 540601 f7088c17e4233adca92208d73394721c8c71308b
child 540603 db11508e43e7d2d424d58a68241a3b9a915f572a
child 540618 be87db5f1b62eaadff0597d78d930f25a3034a0c
push id11529
push userarchaeopteryx@coole-files.de
push dateThu, 04 Jul 2019 15:22:33 +0000
treeherdermozilla-beta@ebb510a784b8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1562655
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1562655: rename `Selection::HasSameRoot` to `HasSameRootOrSameComposedDoc`. r=masayuki Differential Revision: https://phabricator.services.mozilla.com/D36492
dom/base/Selection.cpp
dom/base/Selection.h
--- a/dom/base/Selection.cpp
+++ b/dom/base/Selection.cpp
@@ -2183,17 +2183,17 @@ void Selection::Collapse(const RawRangeB
   // a child of the container when IsSet() is true.  If its offset hasn't been
   // computed yet, this just checks it with its mRef.  So, we can avoid
   // computing offset here.
   if (!aPoint.IsSetAndValid()) {
     aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
     return;
   }
 
-  if (!HasSameRoot(*aPoint.Container())) {
+  if (!HasSameRootOrSameComposedDoc(*aPoint.Container())) {
     // Return with no error
     return;
   }
 
   RefPtr<nsFrameSelection> frameSelection = mFrameSelection;
   frameSelection->InvalidateDesiredPos();
   if (!IsValidSelectionPoint(frameSelection, aPoint.Container())) {
     aRv.Throw(NS_ERROR_FAILURE);
@@ -2484,17 +2484,17 @@ void Selection::Extend(nsINode& aContain
     return;
   }
 
   if (!mFrameSelection) {
     aRv.Throw(NS_ERROR_NOT_INITIALIZED);  // Can't do selection
     return;
   }
 
-  if (!HasSameRoot(aContainer)) {
+  if (!HasSameRootOrSameComposedDoc(aContainer)) {
     // Return with no error
     return;
   }
 
   nsresult res;
   if (!IsValidSelectionPoint(mFrameSelection, &aContainer)) {
     aRv.Throw(NS_ERROR_FAILURE);
     return;
@@ -2754,17 +2754,17 @@ void Selection::SelectAllChildrenJS(nsIN
 }
 
 void Selection::SelectAllChildren(nsINode& aNode, ErrorResult& aRv) {
   if (aNode.NodeType() == nsINode::DOCUMENT_TYPE_NODE) {
     aRv.Throw(NS_ERROR_DOM_INVALID_NODE_TYPE_ERR);
     return;
   }
 
-  if (!HasSameRoot(aNode)) {
+  if (!HasSameRootOrSameComposedDoc(aNode)) {
     // Return with no error
     return;
   }
 
   if (mFrameSelection) {
     mFrameSelection->PostReason(nsISelectionListener::SELECTALL_REASON);
   }
 
@@ -3400,18 +3400,18 @@ void Selection::SetBaseAndExtentInternal
     return;
   }
 
   if (NS_WARN_IF(!aAnchorRef.IsSet()) || NS_WARN_IF(!aFocusRef.IsSet())) {
     aRv.Throw(NS_ERROR_INVALID_ARG);
     return;
   }
 
-  if (!HasSameRoot(*aAnchorRef.Container()) ||
-      !HasSameRoot(*aFocusRef.Container())) {
+  if (!HasSameRootOrSameComposedDoc(*aAnchorRef.Container()) ||
+      !HasSameRootOrSameComposedDoc(*aFocusRef.Container())) {
     // Return with no error
     return;
   }
 
   // Prevent "selectionchange" event temporarily because it should be fired
   // after we set the direction.
   // XXX If they are disconnected, shouldn't we return error before allocating
   //     new nsRange instance?
@@ -3665,13 +3665,13 @@ JSObject* Selection::WrapObject(JSContex
 }
 
 // AutoHideSelectionChanges
 AutoHideSelectionChanges::AutoHideSelectionChanges(
     const nsFrameSelection* aFrame)
     : AutoHideSelectionChanges(
           aFrame ? aFrame->GetSelection(SelectionType::eNormal) : nullptr) {}
 
-bool Selection::HasSameRoot(nsINode& aNode) {
+bool Selection::HasSameRootOrSameComposedDoc(const nsINode& aNode) {
   nsINode* root = aNode.SubtreeRoot();
   Document* doc = GetParentObject();
   return doc == root || (root && doc == root->GetComposedDoc());
 }
--- a/dom/base/Selection.h
+++ b/dom/base/Selection.h
@@ -585,18 +585,17 @@ class Selection final : public nsSupport
    */
   nsresult SelectionLanguageChange(bool aLangRTL);
 
  private:
   friend class ::nsAutoScrollTimer;
 
   MOZ_CAN_RUN_SCRIPT nsresult DoAutoScroll(nsIFrame* aFrame, nsPoint aPoint);
 
-  // We are not allowed to be in nodes whose root is not our document
-  bool HasSameRoot(nsINode& aNode);
+  bool HasSameRootOrSameComposedDoc(const nsINode& aNode);
 
   // XXX Please don't add additional uses of this method, it's only for
   // XXX supporting broken code (bug 1245883) in the following classes:
   friend class ::nsCopySupport;
   friend class ::nsHTMLCopyEncoder;
   MOZ_CAN_RUN_SCRIPT
   void AddRangeInternal(nsRange& aRange, Document* aDocument, ErrorResult&);