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

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

Issue 455223002: Make anchors mouse-focusable (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Move m_wasFocusedByMouse into subclasses. 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
« no previous file with comments | « Source/core/html/HTMLAnchorElement.h ('k') | Source/core/html/HTMLFormControlElement.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 reserv ed. 5 * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed.
6 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 6 * (C) 2006 Graham Dennis (graham.dennis@gmail.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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 #include "wtf/text/StringBuilder.h" 56 #include "wtf/text/StringBuilder.h"
57 57
58 namespace blink { 58 namespace blink {
59 59
60 using namespace HTMLNames; 60 using namespace HTMLNames;
61 61
62 HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tagName, Document& doc ument) 62 HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tagName, Document& doc ument)
63 : HTMLElement(tagName, document) 63 : HTMLElement(tagName, document)
64 , m_linkRelations(0) 64 , m_linkRelations(0)
65 , m_cachedVisitedLinkHash(0) 65 , m_cachedVisitedLinkHash(0)
66 , m_wasFocusedByMouse(false)
66 { 67 {
67 ScriptWrappable::init(this); 68 ScriptWrappable::init(this);
68 } 69 }
69 70
70 PassRefPtrWillBeRawPtr<HTMLAnchorElement> HTMLAnchorElement::create(Document& do cument) 71 PassRefPtrWillBeRawPtr<HTMLAnchorElement> HTMLAnchorElement::create(Document& do cument)
71 { 72 {
72 return adoptRefWillBeNoop(new HTMLAnchorElement(aTag, document)); 73 return adoptRefWillBeNoop(new HTMLAnchorElement(aTag, document));
73 } 74 }
74 75
75 HTMLAnchorElement::~HTMLAnchorElement() 76 HTMLAnchorElement::~HTMLAnchorElement()
76 { 77 {
77 } 78 }
78 79
79 bool HTMLAnchorElement::supportsFocus() const 80 bool HTMLAnchorElement::supportsFocus() const
80 { 81 {
81 if (hasEditableStyle()) 82 if (hasEditableStyle())
82 return HTMLElement::supportsFocus(); 83 return HTMLElement::supportsFocus();
83 // If not a link we should still be able to focus the element if it has tabI ndex. 84 // If not a link we should still be able to focus the element if it has tabI ndex.
84 return isLink() || HTMLElement::supportsFocus(); 85 return isLink() || HTMLElement::supportsFocus();
85 } 86 }
86 87
88 bool HTMLAnchorElement::shouldHaveFocusAppearance() const
89 {
90 return !m_wasFocusedByMouse || HTMLElement::supportsFocus();
91 }
92
93 bool HTMLAnchorElement::wasFocusedByMouse() const
94 {
95 return m_wasFocusedByMouse;
96 }
97
98 void HTMLAnchorElement::setWasFocusedByMouse(bool wasFocusedByMouse)
99 {
100 m_wasFocusedByMouse = wasFocusedByMouse;
101 }
102
87 bool HTMLAnchorElement::isMouseFocusable() const 103 bool HTMLAnchorElement::isMouseFocusable() const
88 { 104 {
89 // Links are focusable by default, but only allow links with tabindex or con tenteditable to be mouse focusable.
90 // https://bugs.webkit.org/show_bug.cgi?id=26856
91 if (isLink()) 105 if (isLink())
92 return HTMLElement::supportsFocus(); 106 return supportsFocus();
93 107
94 return HTMLElement::isMouseFocusable(); 108 return HTMLElement::isMouseFocusable();
95 } 109 }
96 110
97 bool HTMLAnchorElement::isKeyboardFocusable() const 111 bool HTMLAnchorElement::isKeyboardFocusable() const
98 { 112 {
99 ASSERT(document().isActive()); 113 ASSERT(document().isActive());
100 114
101 if (isFocusable() && Element::supportsFocus()) 115 if (isFocusable() && Element::supportsFocus())
102 return HTMLElement::isKeyboardFocusable(); 116 return HTMLElement::isKeyboardFocusable();
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 Vector<String> argv; 394 Vector<String> argv;
381 argv.append("a"); 395 argv.append("a");
382 argv.append(fastGetAttribute(hrefAttr)); 396 argv.append(fastGetAttribute(hrefAttr));
383 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data() ); 397 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data() );
384 } 398 }
385 } 399 }
386 return HTMLElement::insertedInto(insertionPoint); 400 return HTMLElement::insertedInto(insertionPoint);
387 } 401 }
388 402
389 } 403 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLAnchorElement.h ('k') | Source/core/html/HTMLFormControlElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698