Bug 1101364 - Part 1: Apply AutoApplyUserSelectStyle to nsHTMLEditor::SelectAll(). r=mats
authorMorris Tseng <mtseng@mozilla.com>
Fri, 12 Dec 2014 01:15:00 -0500
changeset 219749 c3df17b883e5b029931ae8a245a5c79896b08abd
parent 219748 19313a129f6d23239277251823a1d4ee131aae72
child 219750 ee9acb07ca9db030d928534b88f3c6407c81418c
push id27968
push usernigelbabu@gmail.com
push dateTue, 16 Dec 2014 06:59:11 +0000
treeherdermozilla-central@b836016d82b5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs1101364
milestone37.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 1101364 - Part 1: Apply AutoApplyUserSelectStyle to nsHTMLEditor::SelectAll(). r=mats
editor/libeditor/nsHTMLEditor.cpp
--- a/editor/libeditor/nsHTMLEditor.cpp
+++ b/editor/libeditor/nsHTMLEditor.cpp
@@ -3535,34 +3535,36 @@ nsHTMLEditor::SelectAll()
   NS_ENSURE_STATE(selection);
 
   nsCOMPtr<nsIDOMNode> anchorNode;
   nsresult rv = selection->GetAnchorNode(getter_AddRefs(anchorNode));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIContent> anchorContent = do_QueryInterface(anchorNode, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
-  
-  // If the anchor content has independent selection, we never need to explicitly
-  // select its children.
+
+  nsIContent *rootContent;
   if (anchorContent->HasIndependentSelection()) {
     rv = selection->SetAncestorLimiter(nullptr);
     NS_ENSURE_SUCCESS(rv, rv);
-    nsCOMPtr<nsIDOMNode> rootElement = do_QueryInterface(mRootElement, &rv);
-    NS_ENSURE_SUCCESS(rv, rv);
-    return selection->SelectAllChildren(rootElement);
+    rootContent = mRootElement;
+  } else {
+    nsCOMPtr<nsIPresShell> ps = GetPresShell();
+    rootContent = anchorContent->GetSelectionRootContent(ps);
   }
 
-  nsCOMPtr<nsIPresShell> ps = GetPresShell();
-  nsIContent *rootContent = anchorContent->GetSelectionRootContent(ps);
   NS_ENSURE_TRUE(rootContent, NS_ERROR_UNEXPECTED);
 
   nsCOMPtr<nsIDOMNode> rootElement = do_QueryInterface(rootContent, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
+  Maybe<mozilla::dom::Selection::AutoApplyUserSelectStyle> userSelection;
+  if (!rootContent->IsEditable()) {
+    userSelection.emplace(selection);
+  }
   return selection->SelectAllChildren(rootElement);
 }
 
 
 // this will NOT find aAttribute unless aAttribute has a non-null value
 // so singleton attributes like <Table border> will not be matched!
 bool nsHTMLEditor::IsTextPropertySetByContent(nsIContent*      aContent,
                                               nsIAtom*         aProperty,