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

Unified Diff: third_party/WebKit/Source/core/html/HTMLFormControlElement.cpp

Issue 2586143004: Blur immediately if an attribute change made an element unfocasable. (Closed)
Patch Set: Update comments and a function name Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/html/HTMLFormControlElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLFormControlElement.cpp b/third_party/WebKit/Source/core/html/HTMLFormControlElement.cpp
index a3a0d1d4fbf02b1d39013c61337acdf008c2e314..22fcd497f1de602ecafae80020cb184cc417db78 100644
--- a/third_party/WebKit/Source/core/html/HTMLFormControlElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLFormControlElement.cpp
@@ -39,6 +39,7 @@
#include "core/layout/LayoutTheme.h"
#include "core/page/Page.h"
#include "core/page/ValidationMessageClient.h"
+#include "platform/EventDispatchForbiddenScope.h"
#include "platform/text/BidiTextRun.h"
#include "wtf/Vector.h"
@@ -135,15 +136,26 @@ void HTMLFormControlElement::reset() {
resetImpl();
}
+void HTMLFormControlElement::attributeChanged(
+ const QualifiedName& name,
+ const AtomicString& oldValue,
+ const AtomicString& newValue,
+ AttributeModificationReason reason) {
+ HTMLElement::attributeChanged(name, oldValue, newValue, reason);
+ if (name == disabledAttr && oldValue.isNull() != newValue.isNull()) {
+ disabledAttributeChanged();
+ if (reason == AttributeModificationReason::kDirectly &&
+ isDisabledFormControl() && adjustedFocusedElementInTreeScope() == this)
+ blur();
+ }
+}
+
void HTMLFormControlElement::parseAttribute(const QualifiedName& name,
const AtomicString& oldValue,
const AtomicString& value) {
if (name == formAttr) {
formAttributeChanged();
UseCounter::count(document(), UseCounter::FormAttribute);
- } else if (name == disabledAttr) {
- if (oldValue.isNull() != value.isNull())
- disabledAttributeChanged();
} else if (name == readonlyAttr) {
if (oldValue.isNull() != value.isNull()) {
setNeedsWillValidateCheck();
@@ -166,17 +178,16 @@ void HTMLFormControlElement::parseAttribute(const QualifiedName& name,
}
void HTMLFormControlElement::disabledAttributeChanged() {
+ // Don't blur in this function because this is called for descendants of
+ // <fieldset> while tree traversal.
+ EventDispatchForbiddenScope eventForbidden;
+
setNeedsWillValidateCheck();
pseudoStateChanged(CSSSelector::PseudoDisabled);
pseudoStateChanged(CSSSelector::PseudoEnabled);
if (layoutObject())
LayoutTheme::theme().controlStateChanged(*layoutObject(),
EnabledControlState);
- if (isDisabledFormControl() && adjustedFocusedElementInTreeScope() == this) {
- // We might want to call blur(), but it's dangerous to dispatch events
- // here.
- document().setNeedsFocusedElementCheck();
- }
}
void HTMLFormControlElement::requiredAttributeChanged() {
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLFormControlElement.h ('k') | third_party/WebKit/Source/core/html/HTMLInputElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698