Title: [154212] trunk/Source/WebCore
Revision
154212
Author
[email protected]
Date
2013-08-16 18:31:34 -0700 (Fri, 16 Aug 2013)

Log Message

<https://webkit.org/b/119536> Refactor highestEditableRoot to avoid a redundant call to rendererIsEditable

Reviewed by Benjamin Poulain.

Refactor highestEditableRoot to avoid an extra tree walk. We now walk up the ancestor chain up to
the first root editable element exactly once.

* dom/Node.cpp:
(WebCore::Node::rendererIsEditable): Change the order of conditions to make the evaluation faster
when we don't have to check RenderStyle's value.
* editing/htmlediting.cpp:
(WebCore::highestEditableRoot):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (154211 => 154212)


--- trunk/Source/WebCore/ChangeLog	2013-08-17 01:31:15 UTC (rev 154211)
+++ trunk/Source/WebCore/ChangeLog	2013-08-17 01:31:34 UTC (rev 154212)
@@ -1,3 +1,18 @@
+2013-08-16  Ryosuke Niwa  <[email protected]>
+
+        <https://webkit.org/b/119536> Refactor highestEditableRoot to avoid a redundant call to rendererIsEditable
+
+        Reviewed by Benjamin Poulain.
+
+        Refactor highestEditableRoot to avoid an extra tree walk. We now walk up the ancestor chain up to
+        the first root editable element exactly once.
+
+        * dom/Node.cpp:
+        (WebCore::Node::rendererIsEditable): Change the order of conditions to make the evaluation faster
+        when we don't have to check RenderStyle's value.
+        * editing/htmlediting.cpp:
+        (WebCore::highestEditableRoot):
+
 2013-08-16  Benjamin Poulain  <[email protected]>
 
         Remove a useless #include of SelectorChecker.h

Modified: trunk/Source/WebCore/dom/Node.cpp (154211 => 154212)


--- trunk/Source/WebCore/dom/Node.cpp	2013-08-17 01:31:15 UTC (rev 154211)
+++ trunk/Source/WebCore/dom/Node.cpp	2013-08-17 01:31:34 UTC (rev 154212)
@@ -629,7 +629,7 @@
 #if ENABLE(USERSELECT_ALL)
             // Elements with user-select: all style are considered atomic
             // therefore non editable.
-            if (node->renderer()->style()->userSelect() == SELECT_ALL && treatment == UserSelectAllIsAlwaysNonEditable)
+            if (treatment == UserSelectAllIsAlwaysNonEditable && node->renderer()->style()->userSelect() == SELECT_ALL)
                 return false;
 #else
             UNUSED_PARAM(treatment);

Modified: trunk/Source/WebCore/editing/htmlediting.cpp (154211 => 154212)


--- trunk/Source/WebCore/editing/htmlediting.cpp	2013-08-17 01:31:15 UTC (rev 154211)
+++ trunk/Source/WebCore/editing/htmlediting.cpp	2013-08-17 01:31:34 UTC (rev 154212)
@@ -112,21 +112,21 @@
     Node* node = position.deprecatedNode();
     if (!node)
         return 0;
-        
-    Node* highestRoot = editableRootForPosition(position, editableType);
-    if (!highestRoot)
+
+    Node* highestEditableRoot = editableRootForPosition(position, editableType);
+    if (!highestEditableRoot)
         return 0;
-    
-    node = highestRoot;
-    while (node) {
+
+    node = highestEditableRoot;
+    while (!node->hasTagName(bodyTag)) {
+        node = node->parentNode();
+        if (!node)
+            break;
         if (node->rendererIsEditable(editableType))
-            highestRoot = node;
-        if (node->hasTagName(bodyTag))
-            break;
-        node = node->parentNode();
+            highestEditableRoot = node;
     }
-    
-    return highestRoot;
+
+    return highestEditableRoot;
 }
 
 Node* lowestEditableAncestor(Node* node)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to