Chromium Code Reviews| 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" | 
| 40 #include "platform/weborigin/SchemeRegistry.h" | |
| 39 #include "platform/weborigin/SecurityPolicy.h" | 41 #include "platform/weborigin/SecurityPolicy.h" | 
| 42 #include "public/platform/WebNavigationHintType.h" | |
| 40 | 43 | 
| 41 namespace blink { | 44 namespace blink { | 
| 42 | 45 | 
| 43 using namespace HTMLNames; | 46 using namespace HTMLNames; | 
| 44 | 47 | 
| 48 class HTMLAnchorElement::NavigationHintSender : public GarbageCollected<HTMLAnch orElement::NavigationHintSender> { | |
| 
 
kinuko
2016/06/16 06:14:31
Now it looks this class seems to exist primarily f
 
horo
2016/06/16 07:02:14
Added "ForServiceWorkerSender".
 
 | |
| 49 public: | |
| 50 static NavigationHintSender* create(HTMLAnchorElement* anchorElement) | |
| 51 { | |
| 52 return new NavigationHintSender(anchorElement); | |
| 53 } | |
| 54 void handleEvent(Event*); | |
| 55 | |
| 56 DECLARE_VIRTUAL_TRACE(); | |
| 57 | |
| 58 private: | |
| 59 explicit NavigationHintSender(HTMLAnchorElement*); | |
| 60 bool shouldSendNavigationHintForServiceWorker() const; | |
| 61 void maybeSendNavigationHintForServiceWorker(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 maybeSendNavigationHintForServiceWorker(WebNavigationHintType::LinkMouse Down); | |
| 70 else if (event->type() == EventTypeNames::gesturetapunconfirmed) | |
| 71 maybeSendNavigationHintForServiceWorker(WebNavigationHintType::LinkTapUn confirmed); | |
| 72 else if (event->type() == EventTypeNames::gestureshowpress) | |
| 73 maybeSendNavigationHintForServiceWorker(WebNavigationHintType::LinkTapDo wn); | |
| 74 } | |
| 75 | |
| 76 DEFINE_TRACE(HTMLAnchorElement::NavigationHintSender) | |
| 77 { | |
| 78 visitor->trace(m_anchorElement); | |
| 79 } | |
| 80 | |
| 81 HTMLAnchorElement::NavigationHintSender::NavigationHintSender(HTMLAnchorElement* anchorElement) | |
| 82 : m_anchorElement(anchorElement) | |
| 83 { | |
| 84 } | |
| 85 | |
| 86 bool HTMLAnchorElement::NavigationHintSender::shouldSendNavigationHintForService Worker() const | |
| 87 { | |
| 88 const KURL& url = m_anchorElement->href(); | |
| 89 if (!SchemeRegistry::shouldTreatURLSchemeAsAllowingServiceWorkers(url.protoc ol())) | |
| 90 return false; | |
| 91 | |
| 92 Document& document = m_anchorElement->document(); | |
| 93 // If the element was detached from the frame, handleClick() doesn't cause | |
| 94 // the navigation. | |
| 95 if (!document.frame()) | |
| 96 return false; | |
| 97 | |
| 98 // When the user clicks a link which is to the current document with a hash, | |
| 99 // the network request is not fetched. So we don't need to start the Service | |
| 100 // Worker. | |
| 101 if (url.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier(document. url(), url)) | |
| 102 return false; | |
| 103 | |
| 104 return true; | |
| 105 } | |
| 106 | |
| 107 void HTMLAnchorElement::NavigationHintSender::maybeSendNavigationHintForServiceW orker(WebNavigationHintType type) | |
| 108 { | |
| 109 if (!shouldSendNavigationHintForServiceWorker()) | |
| 110 return; | |
| 111 | |
| 112 // TODO(horo): Send the navigation hint message to the browser process. | |
| 113 } | |
| 114 | |
| 45 HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tagName, Document& doc ument) | 115 HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tagName, Document& doc ument) | 
| 46 : HTMLElement(tagName, document) | 116 : HTMLElement(tagName, document) | 
| 47 , m_linkRelations(0) | 117 , m_linkRelations(0) | 
| 48 , m_cachedVisitedLinkHash(0) | 118 , m_cachedVisitedLinkHash(0) | 
| 49 , m_wasFocusedByMouse(false) | 119 , m_wasFocusedByMouse(false) | 
| 50 { | 120 { | 
| 51 } | 121 } | 
| 52 | 122 | 
| 53 HTMLAnchorElement* HTMLAnchorElement::create(Document& document) | 123 HTMLAnchorElement* HTMLAnchorElement::create(Document& document) | 
| 54 { | 124 { | 
| 55 return new HTMLAnchorElement(aTag, document); | 125 return new HTMLAnchorElement(aTag, document); | 
| 56 } | 126 } | 
| 57 | 127 | 
| 58 HTMLAnchorElement::~HTMLAnchorElement() | 128 HTMLAnchorElement::~HTMLAnchorElement() | 
| 59 { | 129 { | 
| 60 } | 130 } | 
| 61 | 131 | 
| 132 DEFINE_TRACE(HTMLAnchorElement) | |
| 133 { | |
| 134 visitor->trace(m_navigationHintsender); | |
| 135 HTMLElement::trace(visitor); | |
| 136 } | |
| 137 | |
| 62 bool HTMLAnchorElement::supportsFocus() const | 138 bool HTMLAnchorElement::supportsFocus() const | 
| 63 { | 139 { | 
| 64 if (hasEditableStyle()) | 140 if (hasEditableStyle()) | 
| 65 return HTMLElement::supportsFocus(); | 141 return HTMLElement::supportsFocus(); | 
| 66 // If not a link we should still be able to focus the element if it has tabI ndex. | 142 // If not a link we should still be able to focus the element if it has tabI ndex. | 
| 67 return isLink() || HTMLElement::supportsFocus(); | 143 return isLink() || HTMLElement::supportsFocus(); | 
| 68 } | 144 } | 
| 69 | 145 | 
| 70 bool HTMLAnchorElement::matchesEnabledPseudoClass() const | 146 bool HTMLAnchorElement::matchesEnabledPseudoClass() const | 
| 71 { | 147 { | 
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 | 231 | 
| 156 void HTMLAnchorElement::defaultEventHandler(Event* event) | 232 void HTMLAnchorElement::defaultEventHandler(Event* event) | 
| 157 { | 233 { | 
| 158 if (isLink()) { | 234 if (isLink()) { | 
| 159 if (focused() && isEnterKeyKeydownEvent(event) && isLiveLink()) { | 235 if (focused() && isEnterKeyKeydownEvent(event) && isLiveLink()) { | 
| 160 event->setDefaultHandled(); | 236 event->setDefaultHandled(); | 
| 161 dispatchSimulatedClick(event); | 237 dispatchSimulatedClick(event); | 
| 162 return; | 238 return; | 
| 163 } | 239 } | 
| 164 | 240 | 
| 241 // TODO(horo): Call NavigationHintSender::handleEvent() when | |
| 242 // SpeculativeLaunchServiceWorker feature is enabled. | |
| 243 // ensureNavigationHintSender()->handleEvent(event); | |
| 244 | |
| 165 if (isLinkClick(event) && isLiveLink()) { | 245 if (isLinkClick(event) && isLiveLink()) { | 
| 166 handleClick(event); | 246 handleClick(event); | 
| 167 return; | 247 return; | 
| 168 } | 248 } | 
| 169 } | 249 } | 
| 170 | 250 | 
| 171 HTMLElement::defaultEventHandler(event); | 251 HTMLElement::defaultEventHandler(event); | 
| 172 } | 252 } | 
| 173 | 253 | 
| 174 void HTMLAnchorElement::setActive(bool down) | 254 void HTMLAnchorElement::setActive(bool down) | 
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 389 return isLink(); | 469 return isLink(); | 
| 390 } | 470 } | 
| 391 | 471 | 
| 392 Node::InsertionNotificationRequest HTMLAnchorElement::insertedInto(ContainerNode * insertionPoint) | 472 Node::InsertionNotificationRequest HTMLAnchorElement::insertedInto(ContainerNode * insertionPoint) | 
| 393 { | 473 { | 
| 394 InsertionNotificationRequest request = HTMLElement::insertedInto(insertionPo int); | 474 InsertionNotificationRequest request = HTMLElement::insertedInto(insertionPo int); | 
| 395 logAddElementIfIsolatedWorldAndInDocument("a", hrefAttr); | 475 logAddElementIfIsolatedWorldAndInDocument("a", hrefAttr); | 
| 396 return request; | 476 return request; | 
| 397 } | 477 } | 
| 398 | 478 | 
| 479 HTMLAnchorElement::NavigationHintSender* HTMLAnchorElement::ensureNavigationHint Sender() | |
| 480 { | |
| 481 if (!m_navigationHintSender) | |
| 482 m_navigationHintSender = NavigationHintSender::create(this); | |
| 483 return m_navigationHintSender; | |
| 484 } | |
| 485 | |
| 399 } // namespace blink | 486 } // namespace blink | 
| OLD | NEW |