Chromium Code Reviews| Index: Source/core/html/HTMLTextFormControlElement.cpp |
| diff --git a/Source/core/html/HTMLTextFormControlElement.cpp b/Source/core/html/HTMLTextFormControlElement.cpp |
| index 1c8fbe9798b18ed838a2e587644dbb5964e85eab..63b2398d2e66b99966a7e48eb55b0d44c985f68d 100644 |
| --- a/Source/core/html/HTMLTextFormControlElement.cpp |
| +++ b/Source/core/html/HTMLTextFormControlElement.cpp |
| @@ -632,15 +632,26 @@ void HTMLTextFormControlElement::setInnerEditorValue(const String& value) |
| return; |
| bool textIsChanged = value != innerEditorValue(); |
| - if (textIsChanged || !innerEditorElement()->hasChildren()) { |
| + HTMLElement* innerEditor = innerEditorElement(); |
| + if (textIsChanged || innerEditor->hasChildren()) { |
|
yosin_UTC9
2015/09/20 12:42:40
nit: Could you change this to early return style?
sof
2015/09/20 13:05:05
Done.
|
| if (textIsChanged && layoutObject()) { |
| if (AXObjectCache* cache = document().existingAXObjectCache()) |
| cache->handleTextFormControlChanged(this); |
| } |
| - innerEditorElement()->setInnerText(value, ASSERT_NO_EXCEPTION); |
| +#if ENABLE(OILPAN) |
| + // Oilpan: if 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. |
| + // There is a slight slowdown without Oilpan on small benchmarks, |
| + // hence not checked for & done there. |
| + if (isHTMLBRElement(innerEditor->lastChild())) |
| + innerEditor->removeChild(innerEditor->lastChild(), ASSERT_NO_EXCEPTION); |
| +#endif |
| + |
| + innerEditor->setInnerText(value, ASSERT_NO_EXCEPTION); |
| if (value.endsWith('\n') || value.endsWith('\r')) |
| - innerEditorElement()->appendChild(HTMLBRElement::create(document())); |
| + innerEditor->appendChild(HTMLBRElement::create(document())); |
| } |
| } |