OLD | NEW |
---|---|
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 Loading... | |
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 | |
pdr.
2014/08/10 20:21:52
This will be the third time we've copied the exact
robwu
2014/08/10 23:37:19
Yes, certainly. A template class seems like a grea
| |
89 { | |
90 ASSERT(focused()); | |
91 return !m_wasFocusedByMouse || HTMLElement::supportsFocus(); | |
92 } | |
93 | |
94 void HTMLAnchorElement::dispatchFocusEvent(Element* oldFocusedElement, FocusType type) | |
95 { | |
96 if (type != FocusTypePage) | |
97 m_wasFocusedByMouse = type == FocusTypeMouse; | |
98 HTMLElement::dispatchFocusEvent(oldFocusedElement, type); | |
99 } | |
100 | |
101 void HTMLAnchorElement::willCallDefaultEventHandler(const Event& event) | |
102 { | |
103 if (!event.isKeyboardEvent() || event.type() != EventTypeNames::keydown) | |
104 return; | |
105 if (!m_wasFocusedByMouse) | |
106 return; | |
107 m_wasFocusedByMouse = false; | |
108 } | |
109 | |
87 bool HTMLAnchorElement::isMouseFocusable() const | 110 bool HTMLAnchorElement::isMouseFocusable() const |
88 { | 111 { |
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()) | 112 if (isLink()) |
92 return HTMLElement::supportsFocus(); | 113 return supportsFocus(); |
93 | 114 |
94 return HTMLElement::isMouseFocusable(); | 115 return HTMLElement::isMouseFocusable(); |
95 } | 116 } |
96 | 117 |
97 bool HTMLAnchorElement::isKeyboardFocusable() const | 118 bool HTMLAnchorElement::isKeyboardFocusable() const |
98 { | 119 { |
99 ASSERT(document().isActive()); | 120 ASSERT(document().isActive()); |
100 | 121 |
101 if (isFocusable() && Element::supportsFocus()) | 122 if (isFocusable() && Element::supportsFocus()) |
102 return HTMLElement::isKeyboardFocusable(); | 123 return HTMLElement::isKeyboardFocusable(); |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
380 Vector<String> argv; | 401 Vector<String> argv; |
381 argv.append("a"); | 402 argv.append("a"); |
382 argv.append(fastGetAttribute(hrefAttr)); | 403 argv.append(fastGetAttribute(hrefAttr)); |
383 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data() ); | 404 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data() ); |
384 } | 405 } |
385 } | 406 } |
386 return HTMLElement::insertedInto(insertionPoint); | 407 return HTMLElement::insertedInto(insertionPoint); |
387 } | 408 } |
388 | 409 |
389 } | 410 } |
OLD | NEW |