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

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

Issue 547823002: Track reasons for |Node::SetNeedsStyleRecalc| (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 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
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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 } else if (name == disabledAttr) { 145 } else if (name == disabledAttr) {
146 bool oldDisabled = m_disabled; 146 bool oldDisabled = m_disabled;
147 m_disabled = !value.isNull(); 147 m_disabled = !value.isNull();
148 if (oldDisabled != m_disabled) 148 if (oldDisabled != m_disabled)
149 disabledAttributeChanged(); 149 disabledAttributeChanged();
150 } else if (name == readonlyAttr) { 150 } else if (name == readonlyAttr) {
151 bool wasReadOnly = m_isReadOnly; 151 bool wasReadOnly = m_isReadOnly;
152 m_isReadOnly = !value.isNull(); 152 m_isReadOnly = !value.isNull();
153 if (wasReadOnly != m_isReadOnly) { 153 if (wasReadOnly != m_isReadOnly) {
154 setNeedsWillValidateCheck(); 154 setNeedsWillValidateCheck();
155 setNeedsStyleRecalc(SubtreeStyleChange); 155 setNeedsStyleRecalc(StyleRecalcDueToControl, SubtreeStyleChange);
156 if (renderer() && renderer()->style()->hasAppearance()) 156 if (renderer() && renderer()->style()->hasAppearance())
157 RenderTheme::theme().stateChanged(renderer(), ReadOnlyControlSta te); 157 RenderTheme::theme().stateChanged(renderer(), ReadOnlyControlSta te);
158 } 158 }
159 } else if (name == requiredAttr) { 159 } else if (name == requiredAttr) {
160 bool wasRequired = m_isRequired; 160 bool wasRequired = m_isRequired;
161 m_isRequired = !value.isNull(); 161 m_isRequired = !value.isNull();
162 if (wasRequired != m_isRequired) 162 if (wasRequired != m_isRequired)
163 requiredAttributeChanged(); 163 requiredAttributeChanged();
164 UseCounter::count(document(), UseCounter::RequiredAttribute); 164 UseCounter::count(document(), UseCounter::RequiredAttribute);
165 } else if (name == autofocusAttr) { 165 } else if (name == autofocusAttr) {
(...skipping 14 matching lines...) Expand all
180 // here. 180 // here.
181 document().setNeedsFocusedElementCheck(); 181 document().setNeedsFocusedElementCheck();
182 } 182 }
183 } 183 }
184 184
185 void HTMLFormControlElement::requiredAttributeChanged() 185 void HTMLFormControlElement::requiredAttributeChanged()
186 { 186 {
187 setNeedsValidityCheck(); 187 setNeedsValidityCheck();
188 // Style recalculation is needed because style selectors may include 188 // Style recalculation is needed because style selectors may include
189 // :required and :optional pseudo-classes. 189 // :required and :optional pseudo-classes.
190 setNeedsStyleRecalc(SubtreeStyleChange); 190 setNeedsStyleRecalc(StyleRecalcDueToRequiredOptionalPseudoClass, SubtreeStyl eChange);
rune 2014/09/08 08:27:57 This is an example of a case that should happen du
191 } 191 }
192 192
193 bool HTMLFormControlElement::supportsAutofocus() const 193 bool HTMLFormControlElement::supportsAutofocus() const
194 { 194 {
195 return false; 195 return false;
196 } 196 }
197 197
198 bool HTMLFormControlElement::isAutofocusable() const 198 bool HTMLFormControlElement::isAutofocusable() const
199 { 199 {
200 return fastHasAttribute(autofocusAttr) && supportsAutofocus(); 200 return fastHasAttribute(autofocusAttr) && supportsAutofocus();
201 } 201 }
202 202
203 void HTMLFormControlElement::setAutofilled(bool autofilled) 203 void HTMLFormControlElement::setAutofilled(bool autofilled)
204 { 204 {
205 if (autofilled == m_isAutofilled) 205 if (autofilled == m_isAutofilled)
206 return; 206 return;
207 207
208 m_isAutofilled = autofilled; 208 m_isAutofilled = autofilled;
209 setNeedsStyleRecalc(SubtreeStyleChange); 209 setNeedsStyleRecalc(StyleRecalcDueToControlValue, SubtreeStyleChange);
210 } 210 }
211 211
212 static bool shouldAutofocusOnAttach(const HTMLFormControlElement* element) 212 static bool shouldAutofocusOnAttach(const HTMLFormControlElement* element)
213 { 213 {
214 if (!element->isAutofocusable()) 214 if (!element->isAutofocusable())
215 return false; 215 return false;
216 if (element->document().isSandboxed(SandboxAutomaticFeatures)) { 216 if (element->document().isSandboxed(SandboxAutomaticFeatures)) {
217 // FIXME: This message should be moved off the console once a solution t o https://bugs.webkit.org/show_bug.cgi?id=103274 exists. 217 // FIXME: This message should be moved off the console once a solution t o https://bugs.webkit.org/show_bug.cgi?id=103274 exists.
218 element->document().addConsoleMessage(ConsoleMessage::create(SecurityMes sageSource, ErrorMessageLevel, "Blocked autofocusing on a form control because t he form's frame is sandboxed and the 'allow-scripts' permission is not set.")); 218 element->document().addConsoleMessage(ConsoleMessage::create(SecurityMes sageSource, ErrorMessageLevel, "Blocked autofocusing on a form control because t he form's frame is sandboxed and the 'allow-scripts' permission is not set."));
219 return false; 219 return false;
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 387
388 void HTMLFormControlElement::setNeedsWillValidateCheck() 388 void HTMLFormControlElement::setNeedsWillValidateCheck()
389 { 389 {
390 // We need to recalculate willValidate immediately because willValidate chan ge can causes style change. 390 // We need to recalculate willValidate immediately because willValidate chan ge can causes style change.
391 bool newWillValidate = recalcWillValidate(); 391 bool newWillValidate = recalcWillValidate();
392 if (m_willValidateInitialized && m_willValidate == newWillValidate) 392 if (m_willValidateInitialized && m_willValidate == newWillValidate)
393 return; 393 return;
394 m_willValidateInitialized = true; 394 m_willValidateInitialized = true;
395 m_willValidate = newWillValidate; 395 m_willValidate = newWillValidate;
396 setNeedsValidityCheck(); 396 setNeedsValidityCheck();
397 setNeedsStyleRecalc(SubtreeStyleChange); 397 setNeedsStyleRecalc(StyleRecalcDueToControl, SubtreeStyleChange);
398 if (!m_willValidate) 398 if (!m_willValidate)
399 hideVisibleValidationMessage(); 399 hideVisibleValidationMessage();
400 } 400 }
401 401
402 void HTMLFormControlElement::findCustomValidationMessageTextDirection(const Stri ng& message, TextDirection &messageDir, String& subMessage, TextDirection &subMe ssageDir) 402 void HTMLFormControlElement::findCustomValidationMessageTextDirection(const Stri ng& message, TextDirection &messageDir, String& subMessage, TextDirection &subMe ssageDir)
403 { 403 {
404 bool hasStrongDirection; 404 bool hasStrongDirection;
405 subMessage = fastGetAttribute(titleAttr); 405 subMessage = fastGetAttribute(titleAttr);
406 messageDir = determineDirectionality(message, hasStrongDirection); 406 messageDir = determineDirectionality(message, hasStrongDirection);
407 if (!subMessage.isEmpty()) 407 if (!subMessage.isEmpty())
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 // correctly when something which changes validity is updated. 482 // correctly when something which changes validity is updated.
483 ASSERT(m_isValid == valid()); 483 ASSERT(m_isValid == valid());
484 } 484 }
485 return m_isValid; 485 return m_isValid;
486 } 486 }
487 487
488 void HTMLFormControlElement::setNeedsValidityCheck() 488 void HTMLFormControlElement::setNeedsValidityCheck()
489 { 489 {
490 if (!m_validityIsDirty && willValidate()) { 490 if (!m_validityIsDirty && willValidate()) {
491 // Update style for pseudo classes such as :valid :invalid. 491 // Update style for pseudo classes such as :valid :invalid.
492 setNeedsStyleRecalc(SubtreeStyleChange); 492 setNeedsStyleRecalc(StyleRecalcDueToControl, SubtreeStyleChange);
493 m_validityIsDirty = true; 493 m_validityIsDirty = true;
494 } 494 }
495 495
496 // Updates only if this control already has a validation message. 496 // Updates only if this control already has a validation message.
497 if (isValidationMessageVisible()) { 497 if (isValidationMessageVisible()) {
498 // Calls updateVisibleValidationMessage() even if m_isValid is not 498 // Calls updateVisibleValidationMessage() even if m_isValid is not
499 // changed because a validation message can be changed. 499 // changed because a validation message can be changed.
500 updateVisibleValidationMessage(); 500 updateVisibleValidationMessage();
501 } 501 }
502 } 502 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 543
544 void HTMLFormControlElement::setFocus(bool flag) 544 void HTMLFormControlElement::setFocus(bool flag)
545 { 545 {
546 LabelableElement::setFocus(flag); 546 LabelableElement::setFocus(flag);
547 547
548 if (!flag && wasChangedSinceLastFormControlChangeEvent()) 548 if (!flag && wasChangedSinceLastFormControlChangeEvent())
549 dispatchFormControlChangeEvent(); 549 dispatchFormControlChangeEvent();
550 } 550 }
551 551
552 } // namespace Webcore 552 } // namespace Webcore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698