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

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: rebase 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..d48fe0f5d50283720ec93018fdbabbc626cded88 100644
--- a/third_party/WebKit/Source/core/html/HTMLElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLElement.cpp
@@ -426,6 +426,26 @@ 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) {
+ // supportsFocus() behavior depends on element classes. It's hard to avoid
+ // to call it, and it needs up-to-date style.
+ document().updateStyleAndLayoutTreeForNode(this);
+ if (!supportsFocus())
+ blur();
+ }
+}
+
void HTMLElement::parseAttribute(const QualifiedName& name,
const AtomicString& oldValue,
const AtomicString& value) {

Powered by Google App Engine
This is Rietveld 408576698