OLD | NEW |
---|---|
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 Loading... | |
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 || 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.
| |
636 if (textIsChanged && layoutObject()) { | 637 if (textIsChanged && layoutObject()) { |
637 if (AXObjectCache* cache = document().existingAXObjectCache()) | 638 if (AXObjectCache* cache = document().existingAXObjectCache()) |
638 cache->handleTextFormControlChanged(this); | 639 cache->handleTextFormControlChanged(this); |
639 } | 640 } |
640 innerEditorElement()->setInnerText(value, ASSERT_NO_EXCEPTION); | 641 #if ENABLE(OILPAN) |
642 // Oilpan: if last child is a trailing <br> that's appended below, | |
643 // remove it first so as to enable setInnerText() fast path of | |
644 // updating a text node, requiring less allocations. | |
645 // There is a slight slowdown without Oilpan on small benchmarks, | |
646 // hence not checked for & done there. | |
647 if (isHTMLBRElement(innerEditor->lastChild())) | |
648 innerEditor->removeChild(innerEditor->lastChild(), ASSERT_NO_EXCEPTI ON); | |
649 #endif | |
650 | |
651 innerEditor->setInnerText(value, ASSERT_NO_EXCEPTION); | |
641 | 652 |
642 if (value.endsWith('\n') || value.endsWith('\r')) | 653 if (value.endsWith('\n') || value.endsWith('\r')) |
643 innerEditorElement()->appendChild(HTMLBRElement::create(document())) ; | 654 innerEditor->appendChild(HTMLBRElement::create(document())); |
644 } | 655 } |
645 } | 656 } |
646 | 657 |
647 static String finishText(StringBuilder& result) | 658 static String finishText(StringBuilder& result) |
648 { | 659 { |
649 // Remove one trailing newline; there's always one that's collapsed out by l ayoutObject. | 660 // Remove one trailing newline; there's always one that's collapsed out by l ayoutObject. |
650 size_t size = result.length(); | 661 size_t size = result.length(); |
651 if (size && result[size - 1] == '\n') | 662 if (size && result[size - 1] == '\n') |
652 result.resize(--size); | 663 result.resize(--size); |
653 return result.toString(); | 664 return result.toString(); |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1007 } | 1018 } |
1008 | 1019 |
1009 void HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(const Ele ment& source) | 1020 void HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(const Ele ment& source) |
1010 { | 1021 { |
1011 const HTMLTextFormControlElement& sourceElement = static_cast<const HTMLText FormControlElement&>(source); | 1022 const HTMLTextFormControlElement& sourceElement = static_cast<const HTMLText FormControlElement&>(source); |
1012 m_lastChangeWasUserEdit = sourceElement.m_lastChangeWasUserEdit; | 1023 m_lastChangeWasUserEdit = sourceElement.m_lastChangeWasUserEdit; |
1013 HTMLFormControlElement::copyNonAttributePropertiesFromElement(source); | 1024 HTMLFormControlElement::copyNonAttributePropertiesFromElement(source); |
1014 } | 1025 } |
1015 | 1026 |
1016 } // namespace blink | 1027 } // namespace blink |
OLD | NEW |