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 19 matching lines...) Expand all Loading... | |
30 #include "core/frame/UseCounter.h" | 30 #include "core/frame/UseCounter.h" |
31 #include "core/html/HTMLImageElement.h" | 31 #include "core/html/HTMLImageElement.h" |
32 #include "core/html/parser/HTMLParserIdioms.h" | 32 #include "core/html/parser/HTMLParserIdioms.h" |
33 #include "core/layout/LayoutBox.h" | 33 #include "core/layout/LayoutBox.h" |
34 #include "core/loader/FrameLoadRequest.h" | 34 #include "core/loader/FrameLoadRequest.h" |
35 #include "core/loader/FrameLoaderClient.h" | 35 #include "core/loader/FrameLoaderClient.h" |
36 #include "core/loader/PingLoader.h" | 36 #include "core/loader/PingLoader.h" |
37 #include "core/page/ChromeClient.h" | 37 #include "core/page/ChromeClient.h" |
38 #include "platform/network/NetworkHints.h" | 38 #include "platform/network/NetworkHints.h" |
39 #include "platform/weborigin/SecurityPolicy.h" | 39 #include "platform/weborigin/SecurityPolicy.h" |
40 #include "public/platform/WebNavigationHintType.h" | |
40 | 41 |
41 namespace blink { | 42 namespace blink { |
42 | 43 |
43 using namespace HTMLNames; | 44 using namespace HTMLNames; |
44 | 45 |
46 class HTMLAnchorElement::NavigationHintSender : public GarbageCollected<HTMLAnch orElement::NavigationHintSender> { | |
47 public: | |
48 static NavigationHintSender* create(HTMLAnchorElement* anchorElement) | |
49 { | |
50 return new NavigationHintSender(anchorElement); | |
51 } | |
52 void handleEvent(Event*); | |
53 | |
54 DECLARE_VIRTUAL_TRACE(); | |
55 | |
56 private: | |
57 explicit NavigationHintSender(HTMLAnchorElement*); | |
58 bool shouldSendNavigationHint() const; | |
59 void maybeSendNavigationHint(WebNavigationHintType); | |
60 | |
61 Member<HTMLAnchorElement> m_anchorElement; | |
62 }; | |
63 | |
64 void HTMLAnchorElement::NavigationHintSender::handleEvent(Event* event) | |
65 { | |
66 if (event->type() == EventTypeNames::mousedown && event->isMouseEvent() && t oMouseEvent(event)->button() == LeftButton) | |
67 maybeSendNavigationHint(WebNavigationHintType::LinkMouseDown); | |
68 else if (event->type() == EventTypeNames::gesturetapunconfirmed) | |
69 maybeSendNavigationHint(WebNavigationHintType::LinkTapUnconfirmed); | |
70 else if (event->type() == EventTypeNames::gestureshowpress) | |
71 maybeSendNavigationHint(WebNavigationHintType::LinkTapDown); | |
72 } | |
73 | |
74 DEFINE_TRACE(HTMLAnchorElement::NavigationHintSender) | |
75 { | |
76 visitor->trace(m_anchorElement); | |
77 } | |
78 | |
79 HTMLAnchorElement::NavigationHintSender::NavigationHintSender(HTMLAnchorElement* anchorElement) | |
80 : m_anchorElement(anchorElement) | |
81 { | |
82 } | |
83 | |
84 bool HTMLAnchorElement::NavigationHintSender::shouldSendNavigationHint() const | |
85 { | |
86 const KURL& url = m_anchorElement->href(); | |
87 if (!url.protocolIsInHTTPFamily()) | |
kinuko
2016/06/20 04:53:59
nit: please add a brief comment about this conditi
horo
2016/06/21 04:04:31
Done.
| |
88 return false; | |
89 | |
90 Document& document = m_anchorElement->document(); | |
91 // If the element was detached from the frame, handleClick() doesn't cause | |
92 // the navigation. | |
93 if (!document.frame()) | |
94 return false; | |
95 | |
96 // When the user clicks a link which is to the current document with a hash, | |
97 // the network request is not fetched. So we don't send the navigation hint | |
98 // to the browser process. | |
99 if (url.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier(document. url(), url)) | |
100 return false; | |
101 | |
102 return true; | |
103 } | |
104 | |
105 void HTMLAnchorElement::NavigationHintSender::maybeSendNavigationHint(WebNavigat ionHintType type) | |
106 { | |
107 if (!shouldSendNavigationHint()) | |
108 return; | |
109 | |
110 // TODO(horo): Send the navigation hint message to the browser process. | |
111 } | |
112 | |
45 HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tagName, Document& doc ument) | 113 HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tagName, Document& doc ument) |
46 : HTMLElement(tagName, document) | 114 : HTMLElement(tagName, document) |
47 , m_linkRelations(0) | 115 , m_linkRelations(0) |
48 , m_cachedVisitedLinkHash(0) | 116 , m_cachedVisitedLinkHash(0) |
49 , m_wasFocusedByMouse(false) | 117 , m_wasFocusedByMouse(false) |
50 { | 118 { |
51 } | 119 } |
52 | 120 |
53 HTMLAnchorElement* HTMLAnchorElement::create(Document& document) | 121 HTMLAnchorElement* HTMLAnchorElement::create(Document& document) |
54 { | 122 { |
55 return new HTMLAnchorElement(aTag, document); | 123 return new HTMLAnchorElement(aTag, document); |
56 } | 124 } |
57 | 125 |
58 HTMLAnchorElement::~HTMLAnchorElement() | 126 HTMLAnchorElement::~HTMLAnchorElement() |
59 { | 127 { |
60 } | 128 } |
61 | 129 |
130 DEFINE_TRACE(HTMLAnchorElement) | |
131 { | |
132 visitor->trace(m_navigationHintSender); | |
133 HTMLElement::trace(visitor); | |
134 } | |
135 | |
62 bool HTMLAnchorElement::supportsFocus() const | 136 bool HTMLAnchorElement::supportsFocus() const |
63 { | 137 { |
64 if (hasEditableStyle()) | 138 if (hasEditableStyle()) |
65 return HTMLElement::supportsFocus(); | 139 return HTMLElement::supportsFocus(); |
66 // If not a link we should still be able to focus the element if it has tabI ndex. | 140 // If not a link we should still be able to focus the element if it has tabI ndex. |
67 return isLink() || HTMLElement::supportsFocus(); | 141 return isLink() || HTMLElement::supportsFocus(); |
68 } | 142 } |
69 | 143 |
70 bool HTMLAnchorElement::matchesEnabledPseudoClass() const | 144 bool HTMLAnchorElement::matchesEnabledPseudoClass() const |
71 { | 145 { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 | 229 |
156 void HTMLAnchorElement::defaultEventHandler(Event* event) | 230 void HTMLAnchorElement::defaultEventHandler(Event* event) |
157 { | 231 { |
158 if (isLink()) { | 232 if (isLink()) { |
159 if (focused() && isEnterKeyKeydownEvent(event) && isLiveLink()) { | 233 if (focused() && isEnterKeyKeydownEvent(event) && isLiveLink()) { |
160 event->setDefaultHandled(); | 234 event->setDefaultHandled(); |
161 dispatchSimulatedClick(event); | 235 dispatchSimulatedClick(event); |
162 return; | 236 return; |
163 } | 237 } |
164 | 238 |
239 // TODO(horo): Call NavigationHintSender::handleEvent() when | |
240 // SpeculativeLaunchServiceWorker feature is enabled. | |
241 // ensureNavigationHintSender()->handleEvent(event); | |
242 | |
165 if (isLinkClick(event) && isLiveLink()) { | 243 if (isLinkClick(event) && isLiveLink()) { |
166 handleClick(event); | 244 handleClick(event); |
167 return; | 245 return; |
168 } | 246 } |
169 } | 247 } |
170 | 248 |
171 HTMLElement::defaultEventHandler(event); | 249 HTMLElement::defaultEventHandler(event); |
172 } | 250 } |
173 | 251 |
174 void HTMLAnchorElement::setActive(bool down) | 252 void HTMLAnchorElement::setActive(bool down) |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
389 return isLink(); | 467 return isLink(); |
390 } | 468 } |
391 | 469 |
392 Node::InsertionNotificationRequest HTMLAnchorElement::insertedInto(ContainerNode * insertionPoint) | 470 Node::InsertionNotificationRequest HTMLAnchorElement::insertedInto(ContainerNode * insertionPoint) |
393 { | 471 { |
394 InsertionNotificationRequest request = HTMLElement::insertedInto(insertionPo int); | 472 InsertionNotificationRequest request = HTMLElement::insertedInto(insertionPo int); |
395 logAddElementIfIsolatedWorldAndInDocument("a", hrefAttr); | 473 logAddElementIfIsolatedWorldAndInDocument("a", hrefAttr); |
396 return request; | 474 return request; |
397 } | 475 } |
398 | 476 |
477 HTMLAnchorElement::NavigationHintSender* HTMLAnchorElement::ensureNavigationHint Sender() | |
478 { | |
479 if (!m_navigationHintSender) | |
480 m_navigationHintSender = NavigationHintSender::create(this); | |
481 return m_navigationHintSender; | |
482 } | |
483 | |
399 } // namespace blink | 484 } // namespace blink |
OLD | NEW |