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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLAnchorElement.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 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) 2000 Simon Hausmann <hausmann@kde.org> 4 * (C) 2000 Simon Hausmann <hausmann@kde.org>
5 * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights 5 * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
6 * reserved. 6 * reserved.
7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com)
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 HTMLElement::defaultEventHandler(event); 244 HTMLElement::defaultEventHandler(event);
245 } 245 }
246 246
247 void HTMLAnchorElement::setActive(bool down) { 247 void HTMLAnchorElement::setActive(bool down) {
248 if (hasEditableStyle(*this)) 248 if (hasEditableStyle(*this))
249 return; 249 return;
250 250
251 ContainerNode::setActive(down); 251 ContainerNode::setActive(down);
252 } 252 }
253 253
254 void HTMLAnchorElement::attributeChanged(const QualifiedName& name,
255 const AtomicString& oldValue,
256 const AtomicString& newValue,
257 AttributeModificationReason reason) {
258 HTMLElement::attributeChanged(name, oldValue, newValue, reason);
259 if (reason != AttributeModificationReason::kDirectly)
260 return;
261 if (name != hrefAttr && isLink())
262 return;
263 if (adjustedFocusedElementInTreeScope() != this)
264 return;
265 blur();
266 }
267
254 void HTMLAnchorElement::parseAttribute(const QualifiedName& name, 268 void HTMLAnchorElement::parseAttribute(const QualifiedName& name,
255 const AtomicString& oldValue, 269 const AtomicString& oldValue,
256 const AtomicString& value) { 270 const AtomicString& value) {
257 if (name == hrefAttr) { 271 if (name == hrefAttr) {
258 bool wasLink = isLink(); 272 bool wasLink = isLink();
259 setIsLink(!value.isNull()); 273 setIsLink(!value.isNull());
260 if (wasLink || isLink()) { 274 if (wasLink || isLink()) {
261 pseudoStateChanged(CSSSelector::PseudoLink); 275 pseudoStateChanged(CSSSelector::PseudoLink);
262 pseudoStateChanged(CSSSelector::PseudoVisited); 276 pseudoStateChanged(CSSSelector::PseudoVisited);
263 pseudoStateChanged(CSSSelector::PseudoAnyLink); 277 pseudoStateChanged(CSSSelector::PseudoAnyLink);
264 } 278 }
265 if (wasLink && !isLink() && adjustedFocusedElementInTreeScope() == this) {
266 // We might want to call blur(), but it's dangerous to dispatch
267 // events here.
268 document().setNeedsFocusedElementCheck();
269 }
270 if (isLink()) { 279 if (isLink()) {
271 String parsedURL = stripLeadingAndTrailingHTMLSpaces(value); 280 String parsedURL = stripLeadingAndTrailingHTMLSpaces(value);
272 if (document().isDNSPrefetchEnabled()) { 281 if (document().isDNSPrefetchEnabled()) {
273 if (protocolIs(parsedURL, "http") || protocolIs(parsedURL, "https") || 282 if (protocolIs(parsedURL, "http") || protocolIs(parsedURL, "https") ||
274 parsedURL.startsWith("//")) 283 parsedURL.startsWith("//"))
275 prefetchDNS(document().completeURL(parsedURL).host()); 284 prefetchDNS(document().completeURL(parsedURL).host());
276 } 285 }
277 } 286 }
278 invalidateCachedVisitedLinkHash(); 287 invalidateCachedVisitedLinkHash();
279 logUpdateAttributeIfIsolatedWorldAndInDocument("a", hrefAttr, oldValue, 288 logUpdateAttributeIfIsolatedWorldAndInDocument("a", hrefAttr, oldValue,
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 } 485 }
477 486
478 HTMLAnchorElement::NavigationHintSender* 487 HTMLAnchorElement::NavigationHintSender*
479 HTMLAnchorElement::ensureNavigationHintSender() { 488 HTMLAnchorElement::ensureNavigationHintSender() {
480 if (!m_navigationHintSender) 489 if (!m_navigationHintSender)
481 m_navigationHintSender = NavigationHintSender::create(this); 490 m_navigationHintSender = NavigationHintSender::create(this);
482 return m_navigationHintSender; 491 return m_navigationHintSender;
483 } 492 }
484 493
485 } // namespace blink 494 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLAnchorElement.h ('k') | third_party/WebKit/Source/core/html/HTMLElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698