No subject
Mon Jan 28 08:41:14 PST 2013
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.t=
xt: Added.
* editing/execCommand/move-up-down-should-skip-hidden-elements.html: Adde=
d.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href=3D"#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a=
></li>
<li><a href=3D"#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeL=
og</a></li>
<li><a href=3D"#trunkSourceWebCoreeditingVisibleUnitscpp">trunk/Source/We=
bCore/editing/VisibleUnits.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href=3D"#trunkLayoutTestseditingexecCommandmoveupdownshouldskiphid=
denelementsexpectedtxt">trunk/LayoutTests/editing/execCommand/move-up-dow=
n-should-skip-hidden-elements-expected.txt</a></li>
<li><a href=3D"#trunkLayoutTestseditingexecCommandmoveupdownshouldskiphid=
denelementshtml">trunk/LayoutTests/editing/execCommand/move-up-down-shoul=
d-skip-hidden-elements.html</a></li>
</ul>
</div>
<div id=3D"patch">
<h3>Diff</h3>
<a id=3D"trunkLayoutTestsChangeLog"></a>
<div class=3D"modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (154273 =
=3D> 154274)</h4>
<pre class=3D"diff"><span>
<span class=3D"info">--- trunk/LayoutTests/ChangeLog 2013-08-19 11:00:06 =
UTC (rev 154273)
+++ trunk/LayoutTests/ChangeLog 2013-08-19 11:12:41 UTC (rev 154274)
</span><span class=3D"lines">@@ -1,3 +1,15 @@
</span><ins>+2013-08-19 Mario Sanchez Prada <mario.prada at samsung.com=
>
+
+ <https://webkit.org/b/119882> Speed up moving cursor/selec=
tion 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=3D154977&view=
=3Drevision
+
+ * editing/execCommand/move-up-down-should-skip-hidden-elements-e=
xpected.txt: Added.
+ * editing/execCommand/move-up-down-should-skip-hidden-elements.h=
tml: Added.
+
</ins><span class=3D"cx"> 2013-08-18 Seokju Kwon <seokju at webkit.org&=
gt;
</span><span class=3D"cx">=20
</span><span class=3D"cx"> Unreviewed gardening after r154135
</span></span></pre></div>
<a id=3D"trunkLayoutTestseditingexecCommandmoveupdownshouldskiphiddenelem=
entsexpectedtxt"></a>
<div class=3D"addfile"><h4>Added: trunk/LayoutTests/editing/execCommand/m=
ove-up-down-should-skip-hidden-elements-expected.txt (0 =3D> 154274)</h4>
<pre class=3D"diff"><span>
<span class=3D"info">--- trunk/LayoutTests/editing/execCommand/move-up-do=
wn-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)
</span><span class=3D"lines">@@ -0,0 +1,11 @@
</span><ins>+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
+
</ins></span></pre></div>
<a id=3D"trunkLayoutTestseditingexecCommandmoveupdownshouldskiphiddenelem=
entshtml"></a>
<div class=3D"addfile"><h4>Added: trunk/LayoutTests/editing/execCommand/m=
ove-up-down-should-skip-hidden-elements.html (0 =3D> 154274)</h4>
<pre class=3D"diff"><span>
<span class=3D"info">--- trunk/LayoutTests/editing/execCommand/move-up-do=
wn-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)
</span><span class=3D"lines">@@ -0,0 +1,49 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<script src=3D"../../fast/js/resources/js-test-pre.js">&=
lt;/script>
+<title>Test moving up and down through non-rendered elements.</=
title>
+</head>
+<body>
+<div id=3D"before" hidden></div>
+<h1 id=3D"first_line">First line of rendered text</h1=
>
+<div id=3D"after" hidden></div>
+
+<p id=3D"description"></p>
+<div id=3D"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 =3D document.getElementById("before");
+var after =3D document.getElementById("after");
+for (var i =3D 0; i < 1000; i++) {
+ before.appendChild(document.createElement("meta"));
+ after.appendChild(document.createElement("meta"));
+}
+
+function selectFirstLine() {
+ var selection =3D document.getSelection();
+ selection.removeAllRanges();
+ var range =3D document.createRange();
+ range.selectNode(document.getElementById("first_line"));
+ selection.addRange(range);
+}
+
+for (var i =3D 0; i < 100; i++) {
+ selectFirstLine();
+ if (window.testRunner)
+ testRunner.execCommand("MoveUpAndModifySelection");
+
+ selectFirstLine();
+ if (window.testRunner)
+ testRunner.execCommand("MoveDownAndModifySelection");
+}
+
+before.textContent =3D "";
+after.textContent =3D "";
+
+</script>
+<script src=3D"../../fast/js/resources/js-test-post.js">=
</script>
+</body>
+</html>
</ins><span class=3D"cx">\ No newline at end of file
</span></span></pre></div>
<a id=3D"trunkSourceWebCoreChangeLog"></a>
<div class=3D"modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (1542=
73 =3D> 154274)</h4>
<pre class=3D"diff"><span>
<span class=3D"info">--- 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)
</span><span class=3D"lines">@@ -1,3 +1,25 @@
</span><ins>+2013-08-19 Mario Sanchez Prada <mario.prada at samsung.com=
>
+
+ <https://webkit.org/b/119882> Speed up moving cursor/selec=
tion 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=3D154977&view=
=3Drevision
+
+ From the original commit:
+
+ Skips calling firstPositionInOrBeforeNode when a node doesn't ha=
ve a
+ renderer, since there couldn't possibly be a visible position th=
ere.
+ 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-elemen=
ts.html
+
+ * editing/VisibleUnits.cpp:
+ (WebCore::previousRootInlineBoxCandidatePosition): Updated.
+ (WebCore::nextRootInlineBoxCandidatePosition): Updates.
+
</ins><span class=3D"cx"> 2013-08-19 Andreas Kling <akling at apple.com=
>
</span><span class=3D"cx">=20
</span><span class=3D"cx"> <https://webkit.org/b/120000> Ch=
rome::client() should return a reference.
</span></span></pre></div>
<a id=3D"trunkSourceWebCoreeditingVisibleUnitscpp"></a>
<div class=3D"modfile"><h4>Modified: trunk/Source/WebCore/editing/Visible=
Units.cpp (154273 =3D> 154274)</h4>
<pre class=3D"diff"><span>
<span class=3D"info">--- trunk/Source/WebCore/editing/VisibleUnits.cpp 20=
13-08-19 11:00:06 UTC (rev 154273)
+++ trunk/Source/WebCore/editing/VisibleUnits.cpp 2013-08-19 11:12:41 UTC=
(rev 154274)
</span><span class=3D"lines">@@ -80,7 +80,7 @@
</span><span class=3D"cx"> Node* highestRoot =3D highestEditableRoot(=
visiblePosition.deepEquivalent(), editableType);
</span><span class=3D"cx"> Node* previousNode =3D previousLeafWithSam=
eEditability(node, editableType);
</span><span class=3D"cx">=20
</span><del>- while (previousNode && inSameLine(firstPositionI=
nOrBeforeNode(previousNode), visiblePosition))
</del><ins>+ while (previousNode && (!previousNode->rendere=
r() || inSameLine(firstPositionInOrBeforeNode(previousNode), visiblePosit=
ion)))
</ins><span class=3D"cx"> previousNode =3D previousLeafWithSameEd=
itability(previousNode, editableType);
</span><span class=3D"cx">=20
</span><span class=3D"cx"> while (previousNode && !previousNo=
de->isShadowRoot()) {
</span><span class=3D"lines">@@ -102,7 +102,7 @@
</span><span class=3D"cx"> {
</span><span class=3D"cx"> Node* highestRoot =3D highestEditableRoot(=
visiblePosition.deepEquivalent(), editableType);
</span><span class=3D"cx"> Node* nextNode =3D nextLeafWithSameEditabi=
lity(node, editableType);
</span><del>- while (nextNode && inSameLine(firstPositionInOrB=
eforeNode(nextNode), visiblePosition))
</del><ins>+ while (nextNode && (!nextNode->renderer() || i=
nSameLine(firstPositionInOrBeforeNode(nextNode), visiblePosition)))
</ins><span class=3D"cx"> nextNode =3D nextLeafWithSameEditabilit=
y(nextNode, ContentIsEditable);
</span><span class=3D"cx">=20
</span><span class=3D"cx"> while (nextNode && !nextNode->i=
sShadowRoot()) {
</span></span></pre>
</div>
</div>
</body>
</html>
More information about the webkit-changes
mailing list