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  &lt;mario.prada at samsung.com=
&gt;
+
+        &lt;https://webkit.org/b/119882&gt; 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&amp;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  &lt;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 &quot;PASS&quot; messages, followed=
 by &quot;TEST COMPLETE&quot;.
+
+
+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>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=3D&quot;../../fast/js/resources/js-test-pre.js&quot;&gt;&=
lt;/script&gt;
+&lt;title&gt;Test moving up and down through non-rendered elements.&lt;/=
title&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=3D&quot;before&quot; hidden&gt;&lt;/div&gt;
+&lt;h1 id=3D&quot;first_line&quot;&gt;First line of rendered text&lt;/h1=
&gt;
+&lt;div id=3D&quot;after&quot; hidden&gt;&lt;/div&gt;
+
+&lt;p id=3D&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=3D&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test moving up and down through non-rendered elements.=
 This test should execute quickly if it's working correctly; a timeout is=
 a failure.&quot;);
+
+var before =3D document.getElementById(&quot;before&quot;);
+var after =3D document.getElementById(&quot;after&quot;);
+for (var i =3D 0; i &lt; 1000; i++) {
+    before.appendChild(document.createElement(&quot;meta&quot;));
+    after.appendChild(document.createElement(&quot;meta&quot;));
+}
+
+function selectFirstLine() {
+    var selection =3D document.getSelection();
+    selection.removeAllRanges();
+    var range =3D document.createRange();
+    range.selectNode(document.getElementById(&quot;first_line&quot;));
+   selection.addRange(range);
+}
+
+for (var i =3D 0; i &lt; 100; i++) {
+    selectFirstLine();
+    if (window.testRunner)
+        testRunner.execCommand(&quot;MoveUpAndModifySelection&quot;);
+
+    selectFirstLine();
+   if (window.testRunner)
+        testRunner.execCommand(&quot;MoveDownAndModifySelection&quot;);
+}
+
+before.textContent =3D &quot;&quot;;
+after.textContent =3D &quot;&quot;;
+
+&lt;/script&gt;
+&lt;script src=3D&quot;../../fast/js/resources/js-test-post.js&quot;&gt;=
&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</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  &lt;mario.prada at samsung.com=
&gt;
+
+        &lt;https://webkit.org/b/119882&gt; 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&amp;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  &lt;akling at apple.com=
&gt;
</span><span class=3D"cx">=20
</span><span class=3D"cx">         &lt;https://webkit.org/b/120000&gt; 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 &amp;&amp; inSameLine(firstPositionI=
nOrBeforeNode(previousNode), visiblePosition))
</del><ins>+    while (previousNode &amp;&amp; (!previousNode-&gt;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 &amp;&amp; !previousNo=
de-&gt;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 &amp;&amp; inSameLine(firstPositionInOrB=
eforeNode(nextNode), visiblePosition))
</del><ins>+    while (nextNode &amp;&amp; (!nextNode-&gt;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 &amp;&amp; !nextNode-&gt;i=
sShadowRoot()) {
</span></span></pre>
</div>
</div>

</body>
</html>


More information about the webkit-changes mailing list