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

Side by Side Diff: Source/core/html/HTMLOutputElement.cpp

Issue 178253006: Output Element defaultValue should be based on textContent (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Flag holding textContent value setting removed Created 6 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 | « Source/core/html/HTMLOutputElement.h ('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) 2010 Google Inc. All rights reserved. 2 * Copyright (c) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 21 matching lines...) Expand all
32 #include "core/html/HTMLOutputElement.h" 32 #include "core/html/HTMLOutputElement.h"
33 33
34 #include "HTMLNames.h" 34 #include "HTMLNames.h"
35 #include "bindings/v8/ExceptionStatePlaceholder.h" 35 #include "bindings/v8/ExceptionStatePlaceholder.h"
36 36
37 namespace WebCore { 37 namespace WebCore {
38 38
39 inline HTMLOutputElement::HTMLOutputElement(Document& document, HTMLFormElement* form) 39 inline HTMLOutputElement::HTMLOutputElement(Document& document, HTMLFormElement* form)
40 : HTMLFormControlElement(HTMLNames::outputTag, document, form) 40 : HTMLFormControlElement(HTMLNames::outputTag, document, form)
41 , m_isDefaultValueMode(true) 41 , m_isDefaultValueMode(true)
42 , m_isSetTextContentInProgress(false)
43 , m_defaultValue("") 42 , m_defaultValue("")
44 , m_tokens(DOMSettableTokenList::create()) 43 , m_tokens(DOMSettableTokenList::create())
45 { 44 {
46 ScriptWrappable::init(this); 45 ScriptWrappable::init(this);
47 } 46 }
48 47
49 PassRefPtr<HTMLOutputElement> HTMLOutputElement::create(Document& document, HTML FormElement* form) 48 PassRefPtr<HTMLOutputElement> HTMLOutputElement::create(Document& document, HTML FormElement* form)
50 { 49 {
51 return adoptRef(new HTMLOutputElement(document, form)); 50 return adoptRef(new HTMLOutputElement(document, form));
52 } 51 }
(...skipping 24 matching lines...) Expand all
77 76
78 void HTMLOutputElement::setFor(const AtomicString& value) 77 void HTMLOutputElement::setFor(const AtomicString& value)
79 { 78 {
80 m_tokens->setValue(value); 79 m_tokens->setValue(value);
81 } 80 }
82 81
83 void HTMLOutputElement::childrenChanged(bool createdByParser, Node* beforeChange , Node* afterChange, int childCountDelta) 82 void HTMLOutputElement::childrenChanged(bool createdByParser, Node* beforeChange , Node* afterChange, int childCountDelta)
84 { 83 {
85 HTMLFormControlElement::childrenChanged(createdByParser, beforeChange, after Change, childCountDelta); 84 HTMLFormControlElement::childrenChanged(createdByParser, beforeChange, after Change, childCountDelta);
86 85
87 if (createdByParser || m_isSetTextContentInProgress) {
88 m_isSetTextContentInProgress = false;
89 return;
90 }
91
92 if (m_isDefaultValueMode) 86 if (m_isDefaultValueMode)
93 m_defaultValue = textContent(); 87 m_defaultValue = textContent();
94 } 88 }
95 89
96 void HTMLOutputElement::resetImpl() 90 void HTMLOutputElement::resetImpl()
97 { 91 {
98 // The reset algorithm for output elements is to set the element's 92 // The reset algorithm for output elements is to set the element's
99 // value mode flag to "default" and then to set the element's textContent 93 // value mode flag to "default" and then to set the element's textContent
100 // attribute to the default value. 94 // attribute to the default value.
101 m_isDefaultValueMode = true;
102 if (m_defaultValue == value()) 95 if (m_defaultValue == value())
103 return; 96 return;
104 setTextContentInternal(m_defaultValue); 97 setTextContent(m_defaultValue);
98 m_isDefaultValueMode = true;
105 } 99 }
106 100
107 String HTMLOutputElement::value() const 101 String HTMLOutputElement::value() const
108 { 102 {
109 return textContent(); 103 return textContent();
110 } 104 }
111 105
112 void HTMLOutputElement::setValue(const String& value) 106 void HTMLOutputElement::setValue(const String& value)
113 { 107 {
114 // The value mode flag set to "value" when the value attribute is set. 108 // The value mode flag set to "value" when the value attribute is set.
115 m_isDefaultValueMode = false; 109 m_isDefaultValueMode = false;
116 if (value == this->value()) 110 if (value == this->value())
117 return; 111 return;
118 setTextContentInternal(value); 112 setTextContent(value);
119 } 113 }
120 114
121 String HTMLOutputElement::defaultValue() const 115 String HTMLOutputElement::defaultValue() const
122 { 116 {
123 return m_defaultValue; 117 return m_defaultValue;
124 } 118 }
125 119
126 void HTMLOutputElement::setDefaultValue(const String& value) 120 void HTMLOutputElement::setDefaultValue(const String& value)
127 { 121 {
128 if (m_defaultValue == value) 122 if (m_defaultValue == value)
129 return; 123 return;
130 m_defaultValue = value; 124 m_defaultValue = value;
131 // The spec requires the value attribute set to the default value 125 // The spec requires the value attribute set to the default value
132 // when the element's value mode flag to "default". 126 // when the element's value mode flag to "default".
133 if (m_isDefaultValueMode) 127 if (m_isDefaultValueMode)
134 setTextContentInternal(value); 128 setTextContent(value);
135 }
136
137 void HTMLOutputElement::setTextContentInternal(const String& value)
138 {
139 ASSERT(!m_isSetTextContentInProgress);
140 m_isSetTextContentInProgress = true;
141 setTextContent(value);
142 } 129 }
143 130
144 } // namespace 131 } // namespace
OLDNEW
« no previous file with comments | « Source/core/html/HTMLOutputElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698