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

Unified Diff: third_party/WebKit/Source/core/html/HTMLElement.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/HTMLElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLElement.cpp b/third_party/WebKit/Source/core/html/HTMLElement.cpp
index 30bc4d81d68450103a6e24390c9557188f344936..042c0c8ef86f729c788caeeda28af2c7a3f0abde 100644
--- a/third_party/WebKit/Source/core/html/HTMLElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLElement.cpp
@@ -426,6 +426,29 @@ const AtomicString& HTMLElement::eventNameForAttributeName(
return attributeNameToEventNameMap.get(attrName.localName());
}
+void HTMLElement::attributeChanged(const QualifiedName& name,
+ const AtomicString& oldValue,
+ const AtomicString& newValue,
+ AttributeModificationReason reason) {
+ Element::attributeChanged(name, oldValue, newValue, reason);
+ if (reason != AttributeModificationReason::kDirectly)
+ return;
+ if (adjustedFocusedElementInTreeScope() != this)
+ return;
+ if (name == hiddenAttr && !newValue.isNull()) {
+ blur();
+ } else if (name == contenteditableAttr) {
+ // The attribute change may cause supportsFocus() to return false
+ // for the element which had focus.
+ //
+ // TODO(tkent): We should avoid updating style. We'd like to check only
+ // DOM-level focusability here.
+ document().updateStyleAndLayoutTreeForNode(this);
+ if (!supportsFocus())
+ blur();
+ }
+}
+
void HTMLElement::parseAttribute(const QualifiedName& name,
const AtomicString& oldValue,
const AtomicString& value) {
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLElement.h ('k') | third_party/WebKit/Source/core/html/HTMLFieldSetElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698