Commit 5aad18fd authored by rniwa@webkit.org's avatar rniwa@webkit.org
Browse files

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.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@159619 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 46a188fe
2013-11-21 Ryosuke Niwa <rniwa@webkit.org>
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 <rniwa@webkit.org>
 
HTML parser should not associate elements inside templates with forms
......
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.
<!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="../editing.js"></script>
<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>
2013-11-21 Ryosuke Niwa <rniwa@webkit.org>
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 <rniwa@webkit.org>
 
HTML parser should not associate elements inside templates with forms
......@@ -207,7 +207,8 @@ public:
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; }
......
......@@ -487,9 +487,9 @@ static VisiblePosition previousBoundary(const VisiblePosition& c, BoundarySearch
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 @@ static VisiblePosition nextBoundary(const VisiblePosition& c, BoundarySearchFunc
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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment