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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLTextFormControlElement.cpp

Issue 1776903003: Do not use setInnerText in INPUT / TEXTAREA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix some test failures Created 4 years, 9 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 | « third_party/WebKit/LayoutTests/platform/mac/fast/forms/textarea/textarea-width-expected.txt ('k') | 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 20 matching lines...) Expand all
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
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
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
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/platform/mac/fast/forms/textarea/textarea-width-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698