Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(433)

Unified Diff: third_party/WebKit/Source/core/html/HTMLTextFormControlElement.cpp

Issue 1355013002: Speed up updating inner value of HTMLTextFormControlElements. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebased Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/HTMLTextFormControlElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLTextFormControlElement.cpp b/third_party/WebKit/Source/core/html/HTMLTextFormControlElement.cpp
index 1c8fbe9798b18ed838a2e587644dbb5964e85eab..5172ba701165d719ebe03adb567755b604a9613a 100644
--- a/third_party/WebKit/Source/core/html/HTMLTextFormControlElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLTextFormControlElement.cpp
@@ -632,16 +632,25 @@ void HTMLTextFormControlElement::setInnerEditorValue(const String& value)
return;
bool textIsChanged = value != innerEditorValue();
- if (textIsChanged || !innerEditorElement()->hasChildren()) {
- if (textIsChanged && layoutObject()) {
- if (AXObjectCache* cache = document().existingAXObjectCache())
- cache->handleTextFormControlChanged(this);
- }
- innerEditorElement()->setInnerText(value, ASSERT_NO_EXCEPTION);
+ HTMLElement* innerEditor = innerEditorElement();
+ if (!textIsChanged && !innerEditor->hasChildren())
sof 2015/09/25 09:34:05 The RHS negation of (&&) was incorrect; fixed.
+ return;
- if (value.endsWith('\n') || value.endsWith('\r'))
- innerEditorElement()->appendChild(HTMLBRElement::create(document()));
+ if (textIsChanged && layoutObject()) {
+ if (AXObjectCache* cache = document().existingAXObjectCache())
+ cache->handleTextFormControlChanged(this);
tkent 2015/09/25 09:03:36 It's safe to change the order of AX notification a
sof 2015/09/25 09:34:05 It makes sense to have this notification post upda
}
+ // If the last child is a trailing <br> that's appended below, remove it
+ // first so as to enable setInnerText() fast path of updating a text node,
+ // requiring less allocations. Generally helpful, but avoids dead object
+ // buildup with Oilpan on benchmarks pounding this update operation.
+ if (isHTMLBRElement(innerEditor->lastChild()))
+ innerEditor->removeChild(innerEditor->lastChild(), ASSERT_NO_EXCEPTION);
+
+ innerEditor->setInnerText(value, ASSERT_NO_EXCEPTION);
+
+ if (value.endsWith('\n') || value.endsWith('\r'))
+ innerEditor->appendChild(HTMLBRElement::create(document()));
}
static String finishText(StringBuilder& result)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698