Chromium Code Reviews| 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..91fddfec1b329d7b8ba4011690317e850de83236 100644 |
| --- a/third_party/WebKit/Source/core/html/HTMLTextFormControlElement.cpp |
| +++ b/third_party/WebKit/Source/core/html/HTMLTextFormControlElement.cpp |
| @@ -632,15 +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()) |
| + return; |
| + |
| + // 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 |
|
esprehn
2015/09/25 18:34:37
I would remove the comment about less allocations
sof
2015/09/26 06:20:23
Done.
|
| + // 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())); |
| - if (value.endsWith('\n') || value.endsWith('\r')) |
| - innerEditorElement()->appendChild(HTMLBRElement::create(document())); |
| + if (textIsChanged && layoutObject()) { |
| + if (AXObjectCache* cache = document().existingAXObjectCache()) |
| + cache->handleTextFormControlChanged(this); |
| } |
| } |