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

Side by Side 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, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 return m_lastChangeWasUserEdit; 625 return m_lastChangeWasUserEdit;
626 } 626 }
627 627
628 void HTMLTextFormControlElement::setInnerEditorValue(const String& value) 628 void HTMLTextFormControlElement::setInnerEditorValue(const String& value)
629 { 629 {
630 ASSERT(!openShadowRoot()); 630 ASSERT(!openShadowRoot());
631 if (!isTextFormControl() || openShadowRoot()) 631 if (!isTextFormControl() || openShadowRoot())
632 return; 632 return;
633 633
634 bool textIsChanged = value != innerEditorValue(); 634 bool textIsChanged = value != innerEditorValue();
635 if (textIsChanged || !innerEditorElement()->hasChildren()) { 635 HTMLElement* innerEditor = innerEditorElement();
636 if (textIsChanged && layoutObject()) { 636 if (!textIsChanged && !innerEditor->hasChildren())
sof 2015/09/25 09:34:05 The RHS negation of (&&) was incorrect; fixed.
637 if (AXObjectCache* cache = document().existingAXObjectCache()) 637 return;
638 cache->handleTextFormControlChanged(this);
639 }
640 innerEditorElement()->setInnerText(value, ASSERT_NO_EXCEPTION);
641 638
642 if (value.endsWith('\n') || value.endsWith('\r')) 639 if (textIsChanged && layoutObject()) {
643 innerEditorElement()->appendChild(HTMLBRElement::create(document())) ; 640 if (AXObjectCache* cache = document().existingAXObjectCache())
641 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
644 } 642 }
643 // If the last child is a trailing <br> that's appended below, remove it
644 // first so as to enable setInnerText() fast path of updating a text node,
645 // requiring less allocations. Generally helpful, but avoids dead object
646 // buildup with Oilpan on benchmarks pounding this update operation.
647 if (isHTMLBRElement(innerEditor->lastChild()))
648 innerEditor->removeChild(innerEditor->lastChild(), ASSERT_NO_EXCEPTION);
649
650 innerEditor->setInnerText(value, ASSERT_NO_EXCEPTION);
651
652 if (value.endsWith('\n') || value.endsWith('\r'))
653 innerEditor->appendChild(HTMLBRElement::create(document()));
645 } 654 }
646 655
647 static String finishText(StringBuilder& result) 656 static String finishText(StringBuilder& result)
648 { 657 {
649 // Remove one trailing newline; there's always one that's collapsed out by l ayoutObject. 658 // Remove one trailing newline; there's always one that's collapsed out by l ayoutObject.
650 size_t size = result.length(); 659 size_t size = result.length();
651 if (size && result[size - 1] == '\n') 660 if (size && result[size - 1] == '\n')
652 result.resize(--size); 661 result.resize(--size);
653 return result.toString(); 662 return result.toString();
654 } 663 }
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 } 1016 }
1008 1017
1009 void HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(const Ele ment& source) 1018 void HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(const Ele ment& source)
1010 { 1019 {
1011 const HTMLTextFormControlElement& sourceElement = static_cast<const HTMLText FormControlElement&>(source); 1020 const HTMLTextFormControlElement& sourceElement = static_cast<const HTMLText FormControlElement&>(source);
1012 m_lastChangeWasUserEdit = sourceElement.m_lastChangeWasUserEdit; 1021 m_lastChangeWasUserEdit = sourceElement.m_lastChangeWasUserEdit;
1013 HTMLFormControlElement::copyNonAttributePropertiesFromElement(source); 1022 HTMLFormControlElement::copyNonAttributePropertiesFromElement(source);
1014 } 1023 }
1015 1024
1016 } // namespace blink 1025 } // namespace blink
OLDNEW
« 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