Title: [159619] trunk
Revision
159619
Author
[email protected]
Date
2013-11-21 05:46:39 -0800 (Thu, 21 Nov 2013)

Log Message

nextBoundary and previousBoundary are very slow when there is a password field
https://bugs.webkit.org/show_bug.cgi?id=123973

Reviewed by Antti Koivisto.

Source/WebCore:

Merge https://chromium.googlesource.com/chromium/blink/+/57366eec5e3edea54062d4e74c0e047f8681dbad

When iterating through DOM nodes nextBoundary and previousBoundary convert the contents of nodes using
text security to a sequence of 'x' characters. The SimplifiedBackwardsTextIterator and TextIterator
may iterate past node boundaries. Before this patch, the transformation was done looking at the starting
node rather than the current node. In some situations, this replaced all boundaries with 'x' and caused
the text iterator to continue iterating and transforming until the extent of the document.

Test: editing/deleting/password-delete-performance.html

* editing/TextIterator.h:
(WebCore::SimplifiedBackwardsTextIterator::node):
* editing/VisibleUnits.cpp:
(WebCore::previousBoundary):
(WebCore::nextBoundary):

LayoutTests:

* editing/deleting/password-delete-performance-expected.txt: Added.
* editing/deleting/password-delete-performance.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (159618 => 159619)


--- trunk/LayoutTests/ChangeLog	2013-11-21 13:43:34 UTC (rev 159618)
+++ trunk/LayoutTests/ChangeLog	2013-11-21 13:46:39 UTC (rev 159619)
@@ -1,5 +1,15 @@
 2013-11-21  Ryosuke Niwa  <[email protected]>
 
+        nextBoundary and previousBoundary are very slow when there is a password field
+        https://bugs.webkit.org/show_bug.cgi?id=123973
+
+        Reviewed by Antti Koivisto.
+
+        * editing/deleting/password-delete-performance-expected.txt: Added.
+        * editing/deleting/password-delete-performance.html: Added.
+
+2013-11-21  Ryosuke Niwa  <[email protected]>
+
         HTML parser should not associate elements inside templates with forms
         https://bugs.webkit.org/show_bug.cgi?id=117779
 

Added: trunk/LayoutTests/editing/deleting/password-delete-performance-expected.txt (0 => 159619)


--- trunk/LayoutTests/editing/deleting/password-delete-performance-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/deleting/password-delete-performance-expected.txt	2013-11-21 13:46:39 UTC (rev 159619)
@@ -0,0 +1,3 @@
+This test ensures that deleting characters from a password field that follows large content blocks is not slow. To run the test manually, delete the character from the password field. The user agent should not freeze.
+
+

Added: trunk/LayoutTests/editing/deleting/password-delete-performance.html (0 => 159619)


--- trunk/LayoutTests/editing/deleting/password-delete-performance.html	                        (rev 0)
+++ trunk/LayoutTests/editing/deleting/password-delete-performance.html	2013-11-21 13:46:39 UTC (rev 159619)
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+    <body>
+        <p id="description">This test ensures that deleting characters from a password field that follows large content blocks is not slow.
+        To run the test manually, delete the character from the password field. The user agent should not freeze.</p>
+
+        <div id="content" style="height:0px; overflow:hidden;"> </div>
+        <input id="field" type="password" value="A">
+
+        <script src=""
+        <script>
+            if (window.testRunner)
+                testRunner.dumpAsText();
+
+            var newContent = '<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</p>';
+            for (var i = 0; i < 15; i++) {
+                newContent += newContent;
+            }
+
+            var contentDiv = document.getElementById('content');
+            contentDiv.innerHTML = newContent;
+
+            document.getElementById("field").focus();
+            document.execCommand("Delete");
+
+            // We clear the content div to avoid having its content appear in the test harness output.
+            if (window.testRunner)
+                contentDiv.innerHTML = "";
+        </script>
+    </body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (159618 => 159619)


--- trunk/Source/WebCore/ChangeLog	2013-11-21 13:43:34 UTC (rev 159618)
+++ trunk/Source/WebCore/ChangeLog	2013-11-21 13:46:39 UTC (rev 159619)
@@ -1,5 +1,28 @@
 2013-11-21  Ryosuke Niwa  <[email protected]>
 
+        nextBoundary and previousBoundary are very slow when there is a password field
+        https://bugs.webkit.org/show_bug.cgi?id=123973
+
+        Reviewed by Antti Koivisto.
+
+        Merge https://chromium.googlesource.com/chromium/blink/+/57366eec5e3edea54062d4e74c0e047f8681dbad
+
+        When iterating through DOM nodes nextBoundary and previousBoundary convert the contents of nodes using
+        text security to a sequence of 'x' characters. The SimplifiedBackwardsTextIterator and TextIterator
+        may iterate past node boundaries. Before this patch, the transformation was done looking at the starting
+        node rather than the current node. In some situations, this replaced all boundaries with 'x' and caused
+        the text iterator to continue iterating and transforming until the extent of the document.
+
+        Test: editing/deleting/password-delete-performance.html
+
+        * editing/TextIterator.h:
+        (WebCore::SimplifiedBackwardsTextIterator::node):
+        * editing/VisibleUnits.cpp:
+        (WebCore::previousBoundary):
+        (WebCore::nextBoundary):
+
+2013-11-21  Ryosuke Niwa  <[email protected]>
+
         HTML parser should not associate elements inside templates with forms
         https://bugs.webkit.org/show_bug.cgi?id=117779
 

Modified: trunk/Source/WebCore/editing/TextIterator.h (159618 => 159619)


--- trunk/Source/WebCore/editing/TextIterator.h	2013-11-21 13:43:34 UTC (rev 159618)
+++ trunk/Source/WebCore/editing/TextIterator.h	2013-11-21 13:46:39 UTC (rev 159619)
@@ -207,7 +207,8 @@
     
     bool atEnd() const { return !m_positionNode || m_shouldStop; }
     void advance();
-    
+
+    Node* node() const { return m_node; }
     int length() const { return m_textLength; }
     const UChar* characters() const { return m_textCharacters; }
     

Modified: trunk/Source/WebCore/editing/VisibleUnits.cpp (159618 => 159619)


--- trunk/Source/WebCore/editing/VisibleUnits.cpp	2013-11-21 13:43:34 UTC (rev 159618)
+++ trunk/Source/WebCore/editing/VisibleUnits.cpp	2013-11-21 13:46:39 UTC (rev 159619)
@@ -487,9 +487,9 @@
 
     SimplifiedBackwardsTextIterator it(searchRange.get());
     unsigned next = 0;
-    bool inTextSecurityMode = start.deprecatedNode() && start.deprecatedNode()->renderer() && start.deprecatedNode()->renderer()->style().textSecurity() != TSNONE;
     bool needMoreContext = false;
     while (!it.atEnd()) {
+        bool inTextSecurityMode = it.node() && it.node()->renderer() && it.node()->renderer()->style().textSecurity() != TSNONE;
         // iterate to get chunks until the searchFunction returns a non-zero value.
         if (!inTextSecurityMode) 
             string.insert(0, it.characters(), it.length());
@@ -560,9 +560,9 @@
     searchRange->setStart(start.deprecatedNode(), start.deprecatedEditingOffset(), IGNORE_EXCEPTION);
     TextIterator it(searchRange.get(), TextIteratorEmitsCharactersBetweenAllVisiblePositions);
     unsigned next = 0;
-    bool inTextSecurityMode = start.deprecatedNode() && start.deprecatedNode()->renderer() && start.deprecatedNode()->renderer()->style().textSecurity() != TSNONE;
     bool needMoreContext = false;
     while (!it.atEnd()) {
+        bool inTextSecurityMode = it.node() && it.node()->renderer() && it.node()->renderer()->style().textSecurity() != TSNONE;
         // Keep asking the iterator for chunks until the search function
         // returns an end value not equal to the length of the string passed to it.
         if (!inTextSecurityMode)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to