Bug 1072137 part.1 Stop searching root editable node if a node has independent selection r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 26 Sep 2014 09:10:49 +0900
changeset 207384 049f2e6b043d59e77f7982330f348cb3a18bc607
parent 207383 2bfce4ae91e66064f4e893e2c341a59c57e33657
child 207385 b8b5d2575b75a9eea1a041de96d1c50c2fbd0676
push id27552
push usercbook@mozilla.com
push dateFri, 26 Sep 2014 11:21:05 +0000
treeherdermozilla-central@31db6c04c40e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1072137
milestone35.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 1072137 part.1 Stop searching root editable node if a node has independent selection r=smaug
dom/events/IMEStateManager.cpp
--- a/dom/events/IMEStateManager.cpp
+++ b/dom/events/IMEStateManager.cpp
@@ -1079,16 +1079,26 @@ IMEStateManager::IsEditable(nsINode* nod
 nsINode*
 IMEStateManager::GetRootEditableNode(nsPresContext* aPresContext,
                                      nsIContent* aContent)
 {
   if (aContent) {
     nsINode* root = nullptr;
     nsINode* node = aContent;
     while (node && IsEditable(node)) {
+      // If the node has independent selection like <input type="text"> or
+      // <textarea>, the node should be the root editable node for aContent.
+      // FYI: <select> element also has independent selection but IsEditable()
+      //      returns false.
+      // XXX: If somebody adds new editable element which has independent
+      //      selection but doesn't own editor, we'll need more checks here.
+      if (node->IsContent() &&
+          node->AsContent()->HasIndependentSelection()) {
+        return node;
+      }
       root = node;
       node = node->GetParentNode();
     }
     return root;
   }
   if (aPresContext) {
     nsIDocument* document = aPresContext->Document();
     if (document && document->IsEditable()) {