Title: [154274] trunk
Revision
154274
Author
[email protected]
Date
2013-08-19 04:12:41 -0700 (Mon, 19 Aug 2013)

Log Message

<https://webkit.org/b/119882> Speed up moving cursor/selection up or down past non-rendered elements.

Patch by Mario Sanchez Prada <[email protected]> on 2013-08-19
Reviewed by Darin Adler.

This is a port from Blink originally written by Dominic Mazzoni:
https://src.chromium.org/viewvc/blink?revision=154977&view=revision

Source/WebCore:

>From the original commit:

Skips calling firstPositionInOrBeforeNode when a node doesn't have a
renderer, since there couldn't possibly be a visible position there.
This was particularly wasteful when trying to move the cursor up when at
the beginning of a document, as it did a O(n^2) scan through the document head.

Test: editing/execCommand/move-up-down-should-skip-hidden-elements.html

* editing/VisibleUnits.cpp:
(WebCore::previousRootInlineBoxCandidatePosition): Updated.
(WebCore::nextRootInlineBoxCandidatePosition): Updates.

LayoutTests:

* editing/execCommand/move-up-down-should-skip-hidden-elements-expected.txt: Added.
* editing/execCommand/move-up-down-should-skip-hidden-elements.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (154273 => 154274)


--- trunk/LayoutTests/ChangeLog	2013-08-19 11:00:06 UTC (rev 154273)
+++ trunk/LayoutTests/ChangeLog	2013-08-19 11:12:41 UTC (rev 154274)
@@ -1,3 +1,15 @@
+2013-08-19  Mario Sanchez Prada  <[email protected]>
+
+        <https://webkit.org/b/119882> Speed up moving cursor/selection up or down past non-rendered elements.
+
+        Reviewed by Darin Adler.
+
+        This is a port from Blink originally written by Dominic Mazzoni:
+        https://src.chromium.org/viewvc/blink?revision=154977&view=revision
+
+        * editing/execCommand/move-up-down-should-skip-hidden-elements-expected.txt: Added.
+        * editing/execCommand/move-up-down-should-skip-hidden-elements.html: Added.
+
 2013-08-18  Seokju Kwon  <[email protected]>
 
         Unreviewed gardening after r154135

Added: trunk/LayoutTests/editing/execCommand/move-up-down-should-skip-hidden-elements-expected.txt (0 => 154274)


--- trunk/LayoutTests/editing/execCommand/move-up-down-should-skip-hidden-elements-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/execCommand/move-up-down-should-skip-hidden-elements-expected.txt	2013-08-19 11:12:41 UTC (rev 154274)
@@ -0,0 +1,11 @@
+First line of rendered text
+
+Test moving up and down through non-rendered elements. This test should execute quickly if it's working correctly; a timeout is a failure.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/editing/execCommand/move-up-down-should-skip-hidden-elements.html (0 => 154274)


--- trunk/LayoutTests/editing/execCommand/move-up-down-should-skip-hidden-elements.html	                        (rev 0)
+++ trunk/LayoutTests/editing/execCommand/move-up-down-should-skip-hidden-elements.html	2013-08-19 11:12:41 UTC (rev 154274)
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<title>Test moving up and down through non-rendered elements.</title>
+</head>
+<body>
+<div id="before" hidden></div>
+<h1 id="first_line">First line of rendered text</h1>
+<div id="after" hidden></div>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test moving up and down through non-rendered elements. This test should execute quickly if it's working correctly; a timeout is a failure.");
+
+var before = document.getElementById("before");
+var after = document.getElementById("after");
+for (var i = 0; i < 1000; i++) {
+    before.appendChild(document.createElement("meta"));
+    after.appendChild(document.createElement("meta"));
+}
+
+function selectFirstLine() {
+    var selection = document.getSelection();
+    selection.removeAllRanges();
+    var range = document.createRange();
+    range.selectNode(document.getElementById("first_line"));
+   selection.addRange(range);
+}
+
+for (var i = 0; i < 100; i++) {
+    selectFirstLine();
+    if (window.testRunner)
+        testRunner.execCommand("MoveUpAndModifySelection");
+
+    selectFirstLine();
+   if (window.testRunner)
+        testRunner.execCommand("MoveDownAndModifySelection");
+}
+
+before.textContent = "";
+after.textContent = "";
+
+</script>
+<script src=""
+</body>
+</html>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (154273 => 154274)


--- trunk/Source/WebCore/ChangeLog	2013-08-19 11:00:06 UTC (rev 154273)
+++ trunk/Source/WebCore/ChangeLog	2013-08-19 11:12:41 UTC (rev 154274)
@@ -1,3 +1,25 @@
+2013-08-19  Mario Sanchez Prada  <[email protected]>
+
+        <https://webkit.org/b/119882> Speed up moving cursor/selection up or down past non-rendered elements.
+
+        Reviewed by Darin Adler.
+
+        This is a port from Blink originally written by Dominic Mazzoni:
+        https://src.chromium.org/viewvc/blink?revision=154977&view=revision
+
+        From the original commit:
+
+        Skips calling firstPositionInOrBeforeNode when a node doesn't have a
+        renderer, since there couldn't possibly be a visible position there.
+        This was particularly wasteful when trying to move the cursor up when at
+        the beginning of a document, as it did a O(n^2) scan through the document head.
+
+        Test: editing/execCommand/move-up-down-should-skip-hidden-elements.html
+
+        * editing/VisibleUnits.cpp:
+        (WebCore::previousRootInlineBoxCandidatePosition): Updated.
+        (WebCore::nextRootInlineBoxCandidatePosition): Updates.
+
 2013-08-19  Andreas Kling  <[email protected]>
 
         <https://webkit.org/b/120000> Chrome::client() should return a reference.

Modified: trunk/Source/WebCore/editing/VisibleUnits.cpp (154273 => 154274)


--- trunk/Source/WebCore/editing/VisibleUnits.cpp	2013-08-19 11:00:06 UTC (rev 154273)
+++ trunk/Source/WebCore/editing/VisibleUnits.cpp	2013-08-19 11:12:41 UTC (rev 154274)
@@ -80,7 +80,7 @@
     Node* highestRoot = highestEditableRoot(visiblePosition.deepEquivalent(), editableType);
     Node* previousNode = previousLeafWithSameEditability(node, editableType);
 
-    while (previousNode && inSameLine(firstPositionInOrBeforeNode(previousNode), visiblePosition))
+    while (previousNode && (!previousNode->renderer() || inSameLine(firstPositionInOrBeforeNode(previousNode), visiblePosition)))
         previousNode = previousLeafWithSameEditability(previousNode, editableType);
 
     while (previousNode && !previousNode->isShadowRoot()) {
@@ -102,7 +102,7 @@
 {
     Node* highestRoot = highestEditableRoot(visiblePosition.deepEquivalent(), editableType);
     Node* nextNode = nextLeafWithSameEditability(node, editableType);
-    while (nextNode && inSameLine(firstPositionInOrBeforeNode(nextNode), visiblePosition))
+    while (nextNode && (!nextNode->renderer() || inSameLine(firstPositionInOrBeforeNode(nextNode), visiblePosition)))
         nextNode = nextLeafWithSameEditability(nextNode, ContentIsEditable);
 
     while (nextNode && !nextNode->isShadowRoot()) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to