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 20 matching lines...) Expand all Loading... | |
31 #include "core/dom/Document.h" | 31 #include "core/dom/Document.h" |
32 #include "core/dom/ElementTraversal.h" | 32 #include "core/dom/ElementTraversal.h" |
33 #include "core/dom/NodeList.h" | 33 #include "core/dom/NodeList.h" |
34 #include "core/dom/Text.h" | 34 #include "core/dom/Text.h" |
35 #include "core/dom/shadow/ShadowRoot.h" | 35 #include "core/dom/shadow/ShadowRoot.h" |
36 #include "core/editing/EditingUtilities.h" | 36 #include "core/editing/EditingUtilities.h" |
37 #include "core/editing/Editor.h" | 37 #include "core/editing/Editor.h" |
38 #include "core/editing/FrameSelection.h" | 38 #include "core/editing/FrameSelection.h" |
39 #include "core/editing/iterators/CharacterIterator.h" | 39 #include "core/editing/iterators/CharacterIterator.h" |
40 #include "core/editing/iterators/TextIterator.h" | 40 #include "core/editing/iterators/TextIterator.h" |
41 #include "core/editing/serializers/Serialization.h" | |
41 #include "core/events/Event.h" | 42 #include "core/events/Event.h" |
42 #include "core/frame/LocalFrame.h" | 43 #include "core/frame/LocalFrame.h" |
43 #include "core/frame/UseCounter.h" | 44 #include "core/frame/UseCounter.h" |
44 #include "core/html/HTMLBRElement.h" | 45 #include "core/html/HTMLBRElement.h" |
45 #include "core/html/shadow/ShadowElementNames.h" | 46 #include "core/html/shadow/ShadowElementNames.h" |
46 #include "core/layout/LayoutBlock.h" | 47 #include "core/layout/LayoutBlock.h" |
47 #include "core/layout/LayoutBlockFlow.h" | 48 #include "core/layout/LayoutBlockFlow.h" |
48 #include "core/layout/LayoutTheme.h" | 49 #include "core/layout/LayoutTheme.h" |
49 #include "core/page/FocusController.h" | 50 #include "core/page/FocusController.h" |
50 #include "core/page/Page.h" | 51 #include "core/page/Page.h" |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
628 bool textIsChanged = value != innerEditorValue(); | 629 bool textIsChanged = value != innerEditorValue(); |
629 HTMLElement* innerEditor = innerEditorElement(); | 630 HTMLElement* innerEditor = innerEditorElement(); |
630 if (!textIsChanged && innerEditor->hasChildren()) | 631 if (!textIsChanged && innerEditor->hasChildren()) |
631 return; | 632 return; |
632 | 633 |
633 // If the last child is a trailing <br> that's appended below, remove it | 634 // If the last child is a trailing <br> that's appended below, remove it |
634 // first so as to enable setInnerText() fast path of updating a text node. | 635 // first so as to enable setInnerText() fast path of updating a text node. |
635 if (isHTMLBRElement(innerEditor->lastChild())) | 636 if (isHTMLBRElement(innerEditor->lastChild())) |
636 innerEditor->removeChild(innerEditor->lastChild(), ASSERT_NO_EXCEPTION); | 637 innerEditor->removeChild(innerEditor->lastChild(), ASSERT_NO_EXCEPTION); |
637 | 638 |
638 innerEditor->setInnerText(value, ASSERT_NO_EXCEPTION); | 639 // We don't use setTextContent. It triggers unnecessary paint. |
640 if (value.isEmpty()) | |
tkent
2016/03/10 00:57:02
I added this code after yosin's lgtm. Both of set
| |
641 innerEditor->removeChildren(); | |
642 else | |
643 replaceChildrenWithText(innerEditor, value, ASSERT_NO_EXCEPTION); | |
639 | 644 |
640 if (value.endsWith('\n') || value.endsWith('\r')) | 645 if (value.endsWith('\n') || value.endsWith('\r')) |
641 innerEditor->appendChild(HTMLBRElement::create(document())); | 646 innerEditor->appendChild(HTMLBRElement::create(document())); |
642 | 647 |
643 if (textIsChanged && layoutObject()) { | 648 if (textIsChanged && layoutObject()) { |
644 if (AXObjectCache* cache = document().existingAXObjectCache()) | 649 if (AXObjectCache* cache = document().existingAXObjectCache()) |
645 cache->handleTextFormControlChanged(this); | 650 cache->handleTextFormControlChanged(this); |
646 } | 651 } |
647 } | 652 } |
648 | 653 |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1009 } | 1014 } |
1010 | 1015 |
1011 void HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(const Ele ment& source) | 1016 void HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(const Ele ment& source) |
1012 { | 1017 { |
1013 const HTMLTextFormControlElement& sourceElement = static_cast<const HTMLText FormControlElement&>(source); | 1018 const HTMLTextFormControlElement& sourceElement = static_cast<const HTMLText FormControlElement&>(source); |
1014 m_lastChangeWasUserEdit = sourceElement.m_lastChangeWasUserEdit; | 1019 m_lastChangeWasUserEdit = sourceElement.m_lastChangeWasUserEdit; |
1015 HTMLFormControlElement::copyNonAttributePropertiesFromElement(source); | 1020 HTMLFormControlElement::copyNonAttributePropertiesFromElement(source); |
1016 } | 1021 } |
1017 | 1022 |
1018 } // namespace blink | 1023 } // namespace blink |
OLD | NEW |