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 17 matching lines...) Expand all Loading... | |
28 #include "core/frame/FrameHost.h" | 28 #include "core/frame/FrameHost.h" |
29 #include "core/frame/Settings.h" | 29 #include "core/frame/Settings.h" |
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/RuntimeEnabledFeatures.h" | |
38 #include "platform/network/NetworkHints.h" | 39 #include "platform/network/NetworkHints.h" |
39 #include "platform/weborigin/SecurityPolicy.h" | 40 #include "platform/weborigin/SecurityPolicy.h" |
41 #include "public/platform/WebNavigationHintType.h" | |
40 | 42 |
41 namespace blink { | 43 namespace blink { |
42 | 44 |
43 using namespace HTMLNames; | 45 using namespace HTMLNames; |
44 | 46 |
47 class HTMLAnchorElement::NavigationHintSender : public GarbageCollected<HTMLAnch orElement::NavigationHintSender> { | |
48 public: | |
49 static NavigationHintSender* create(HTMLAnchorElement* anchorElement) | |
50 { | |
51 return new NavigationHintSender(anchorElement); | |
52 } | |
53 void handleEvent(Event*); | |
54 | |
55 DECLARE_VIRTUAL_TRACE(); | |
56 DECLARE_VIRTUAL_TRACE_WRAPPERS(); | |
kouhei (in TOK)
2016/06/09 02:31:13
I'm not sure if we need traceWrappers here. harake
haraken
2016/06/09 04:07:29
You don't need to add TRACE_WRAPPERS. It is needed
horo
2016/06/09 05:27:58
Removed.
Thank you.
| |
57 | |
58 private: | |
59 explicit NavigationHintSender(HTMLAnchorElement*); | |
60 bool shouldSendNavigationHint() const; | |
61 void maybeSendNavigationHint(WebNavigationHintType); | |
62 | |
63 Member<HTMLAnchorElement> m_anchorElement; | |
64 }; | |
65 | |
66 void HTMLAnchorElement::NavigationHintSender::handleEvent(Event* event) | |
67 { | |
68 if (event->type() == EventTypeNames::mousedown && event->isMouseEvent() && t oMouseEvent(event)->button() == LeftButton) | |
69 maybeSendNavigationHint(WebNavigationHintType::LinkMouseDown); | |
70 else if (event->type() == EventTypeNames::gesturetapunconfirmed) | |
71 maybeSendNavigationHint(WebNavigationHintType::LinkTapUnconfirmed); | |
72 else if (event->type() == EventTypeNames::gestureshowpress) | |
73 maybeSendNavigationHint(WebNavigationHintType::LinkTapDown); | |
74 } | |
75 | |
76 DEFINE_TRACE(HTMLAnchorElement::NavigationHintSender) | |
77 { | |
78 visitor->trace(m_anchorElement); | |
79 } | |
80 | |
81 DEFINE_TRACE_WRAPPERS(HTMLAnchorElement::NavigationHintSender) | |
82 { | |
83 visitor->traceWrappers(m_anchorElement); | |
84 } | |
85 | |
86 HTMLAnchorElement::NavigationHintSender::NavigationHintSender(HTMLAnchorElement* anchorElement) | |
87 : m_anchorElement(anchorElement) | |
88 { | |
89 } | |
90 | |
91 bool HTMLAnchorElement::NavigationHintSender::shouldSendNavigationHint() const | |
92 { | |
93 const KURL& url = m_anchorElement->href(); | |
94 if (!url.protocolIsInHTTPFamily()) | |
95 return false; | |
96 Document& document = m_anchorElement->document(); | |
97 if (!document.frame()) | |
98 return false; | |
99 if (!document.getSecurityOrigin()->canDisplay(url)) | |
100 return false; | |
101 if (url.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier(document. url(), url)) | |
102 return false; | |
103 | |
104 // If the opener is to be suppressed and the target frame name is set, | |
105 // WebContentsImpl::CreateNewWindow() will create a new process when the | |
106 // user click the anchor element. In such case we shouldn't start the | |
107 // Service Worker not to keep the current process running. | |
108 const bool openerSuppressed = m_anchorElement->hasRel(RelationNoReferrer) || m_anchorElement->hasRel(RelationNoOpener); | |
109 if (openerSuppressed && !m_anchorElement->getAttribute(targetAttr).isEmpty() ) | |
110 return false; | |
111 return true; | |
112 } | |
113 | |
114 void HTMLAnchorElement::NavigationHintSender::maybeSendNavigationHint(WebNavigat ionHintType type) | |
115 { | |
116 if (!shouldSendNavigationHint()) | |
117 return; | |
118 blink::sendNavigationHint(m_anchorElement->href(), type); | |
119 } | |
120 | |
45 HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tagName, Document& doc ument) | 121 HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tagName, Document& doc ument) |
46 : HTMLElement(tagName, document) | 122 : HTMLElement(tagName, document) |
47 , m_linkRelations(0) | 123 , m_linkRelations(0) |
48 , m_cachedVisitedLinkHash(0) | 124 , m_cachedVisitedLinkHash(0) |
49 , m_wasFocusedByMouse(false) | 125 , m_wasFocusedByMouse(false) |
50 { | 126 { |
51 } | 127 } |
52 | 128 |
53 HTMLAnchorElement* HTMLAnchorElement::create(Document& document) | 129 HTMLAnchorElement* HTMLAnchorElement::create(Document& document) |
54 { | 130 { |
55 return new HTMLAnchorElement(aTag, document); | 131 return new HTMLAnchorElement(aTag, document); |
56 } | 132 } |
57 | 133 |
58 HTMLAnchorElement::~HTMLAnchorElement() | 134 HTMLAnchorElement::~HTMLAnchorElement() |
59 { | 135 { |
60 } | 136 } |
61 | 137 |
138 DEFINE_TRACE(HTMLAnchorElement) | |
139 { | |
140 visitor->trace(m_navigationHintsender); | |
141 HTMLElement::trace(visitor); | |
142 } | |
143 | |
144 DEFINE_TRACE_WRAPPERS(HTMLAnchorElement) | |
145 { | |
146 visitor->traceWrappers(m_navigationHintsender); | |
147 HTMLElement::traceWrappers(visitor); | |
148 } | |
149 | |
62 bool HTMLAnchorElement::supportsFocus() const | 150 bool HTMLAnchorElement::supportsFocus() const |
63 { | 151 { |
64 if (hasEditableStyle()) | 152 if (hasEditableStyle()) |
65 return HTMLElement::supportsFocus(); | 153 return HTMLElement::supportsFocus(); |
66 // If not a link we should still be able to focus the element if it has tabI ndex. | 154 // If not a link we should still be able to focus the element if it has tabI ndex. |
67 return isLink() || HTMLElement::supportsFocus(); | 155 return isLink() || HTMLElement::supportsFocus(); |
68 } | 156 } |
69 | 157 |
70 bool HTMLAnchorElement::matchesEnabledPseudoClass() const | 158 bool HTMLAnchorElement::matchesEnabledPseudoClass() const |
71 { | 159 { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 | 243 |
156 void HTMLAnchorElement::defaultEventHandler(Event* event) | 244 void HTMLAnchorElement::defaultEventHandler(Event* event) |
157 { | 245 { |
158 if (isLink()) { | 246 if (isLink()) { |
159 if (focused() && isEnterKeyKeydownEvent(event) && isLiveLink()) { | 247 if (focused() && isEnterKeyKeydownEvent(event) && isLiveLink()) { |
160 event->setDefaultHandled(); | 248 event->setDefaultHandled(); |
161 dispatchSimulatedClick(event); | 249 dispatchSimulatedClick(event); |
162 return; | 250 return; |
163 } | 251 } |
164 | 252 |
253 if (RuntimeEnabledFeatures::speculativeLaunchServiceWorkerEnabled()) | |
254 navigationHintSender()->handleEvent(event); | |
255 | |
165 if (isLinkClick(event) && isLiveLink()) { | 256 if (isLinkClick(event) && isLiveLink()) { |
166 handleClick(event); | 257 handleClick(event); |
167 return; | 258 return; |
168 } | 259 } |
169 } | 260 } |
170 | 261 |
171 HTMLElement::defaultEventHandler(event); | 262 HTMLElement::defaultEventHandler(event); |
172 } | 263 } |
173 | 264 |
174 void HTMLAnchorElement::setActive(bool down) | 265 void HTMLAnchorElement::setActive(bool down) |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
389 return isLink(); | 480 return isLink(); |
390 } | 481 } |
391 | 482 |
392 Node::InsertionNotificationRequest HTMLAnchorElement::insertedInto(ContainerNode * insertionPoint) | 483 Node::InsertionNotificationRequest HTMLAnchorElement::insertedInto(ContainerNode * insertionPoint) |
393 { | 484 { |
394 InsertionNotificationRequest request = HTMLElement::insertedInto(insertionPo int); | 485 InsertionNotificationRequest request = HTMLElement::insertedInto(insertionPo int); |
395 logAddElementIfIsolatedWorldAndInDocument("a", hrefAttr); | 486 logAddElementIfIsolatedWorldAndInDocument("a", hrefAttr); |
396 return request; | 487 return request; |
397 } | 488 } |
398 | 489 |
490 HTMLAnchorElement::NavigationHintSender* HTMLAnchorElement::navigationHintSender () | |
kouhei (in TOK)
2016/06/09 02:31:13
ensureNavigationHintSender()
horo
2016/06/09 05:27:58
Done.
| |
491 { | |
492 if (!m_navigationHintsender) | |
493 m_navigationHintsender = NavigationHintSender::create(this); | |
494 return m_navigationHintsender; | |
495 } | |
496 | |
399 } // namespace blink | 497 } // namespace blink |
OLD | NEW |