| 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 | 5 * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights |
| 6 * reserved. | 6 * reserved. |
| 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) | 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #include "core/frame/UseCounter.h" | 32 #include "core/frame/UseCounter.h" |
| 33 #include "core/html/HTMLImageElement.h" | 33 #include "core/html/HTMLImageElement.h" |
| 34 #include "core/html/parser/HTMLParserIdioms.h" | 34 #include "core/html/parser/HTMLParserIdioms.h" |
| 35 #include "core/layout/LayoutBox.h" | 35 #include "core/layout/LayoutBox.h" |
| 36 #include "core/loader/FrameLoadRequest.h" | 36 #include "core/loader/FrameLoadRequest.h" |
| 37 #include "core/loader/PingLoader.h" | 37 #include "core/loader/PingLoader.h" |
| 38 #include "core/page/ChromeClient.h" | 38 #include "core/page/ChromeClient.h" |
| 39 #include "core/page/Page.h" | 39 #include "core/page/Page.h" |
| 40 #include "platform/network/NetworkHints.h" | 40 #include "platform/network/NetworkHints.h" |
| 41 #include "platform/weborigin/SecurityPolicy.h" | 41 #include "platform/weborigin/SecurityPolicy.h" |
| 42 #include "public/platform/WebNavigationHintType.h" | |
| 43 | 42 |
| 44 namespace blink { | 43 namespace blink { |
| 45 | 44 |
| 46 using namespace HTMLNames; | 45 using namespace HTMLNames; |
| 47 | 46 |
| 48 class HTMLAnchorElement::NavigationHintSender | |
| 49 : public GarbageCollected<HTMLAnchorElement::NavigationHintSender> { | |
| 50 public: | |
| 51 static NavigationHintSender* create(HTMLAnchorElement* anchorElement) { | |
| 52 return new NavigationHintSender(anchorElement); | |
| 53 } | |
| 54 void handleEvent(Event*); | |
| 55 | |
| 56 DECLARE_TRACE(); | |
| 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 if (event->type() == EventTypeNames::mousedown && event->isMouseEvent() && | |
| 68 toMouseEvent(event)->button() == | |
| 69 static_cast<short>(WebPointerProperties::Button::Left)) | |
| 70 maybeSendNavigationHint(WebNavigationHintType::LinkMouseDown); | |
| 71 else if (event->type() == EventTypeNames::gesturetapunconfirmed) | |
| 72 maybeSendNavigationHint(WebNavigationHintType::LinkTapUnconfirmed); | |
| 73 else if (event->type() == EventTypeNames::gestureshowpress) | |
| 74 maybeSendNavigationHint(WebNavigationHintType::LinkTapDown); | |
| 75 } | |
| 76 | |
| 77 DEFINE_TRACE(HTMLAnchorElement::NavigationHintSender) { | |
| 78 visitor->trace(m_anchorElement); | |
| 79 } | |
| 80 | |
| 81 HTMLAnchorElement::NavigationHintSender::NavigationHintSender( | |
| 82 HTMLAnchorElement* anchorElement) | |
| 83 : m_anchorElement(anchorElement) {} | |
| 84 | |
| 85 bool HTMLAnchorElement::NavigationHintSender::shouldSendNavigationHint() const { | |
| 86 const KURL& url = m_anchorElement->href(); | |
| 87 // Currently the navigation hint only supports HTTP and HTTPS. | |
| 88 if (!url.protocolIsInHTTPFamily()) | |
| 89 return false; | |
| 90 | |
| 91 Document& document = m_anchorElement->document(); | |
| 92 // If the element was detached from the frame, handleClick() doesn't cause | |
| 93 // the navigation. | |
| 94 if (!document.frame()) | |
| 95 return false; | |
| 96 | |
| 97 // When the user clicks a link which is to the current document with a hash, | |
| 98 // the network request is not fetched. So we don't send the navigation hint | |
| 99 // to the browser process. | |
| 100 if (url.hasFragmentIdentifier() && | |
| 101 equalIgnoringFragmentIdentifier(document.url(), url)) | |
| 102 return false; | |
| 103 | |
| 104 return true; | |
| 105 } | |
| 106 | |
| 107 void HTMLAnchorElement::NavigationHintSender::maybeSendNavigationHint( | |
| 108 WebNavigationHintType type) { | |
| 109 if (!shouldSendNavigationHint()) | |
| 110 return; | |
| 111 | |
| 112 sendNavigationHint(m_anchorElement->href(), type); | |
| 113 } | |
| 114 | |
| 115 HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tagName, | 47 HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tagName, |
| 116 Document& document) | 48 Document& document) |
| 117 : HTMLElement(tagName, document), | 49 : HTMLElement(tagName, document), |
| 118 m_linkRelations(0), | 50 m_linkRelations(0), |
| 119 m_cachedVisitedLinkHash(0), | 51 m_cachedVisitedLinkHash(0), |
| 120 m_wasFocusedByMouse(false) {} | 52 m_wasFocusedByMouse(false) {} |
| 121 | 53 |
| 122 HTMLAnchorElement* HTMLAnchorElement::create(Document& document) { | 54 HTMLAnchorElement* HTMLAnchorElement::create(Document& document) { |
| 123 return new HTMLAnchorElement(aTag, document); | 55 return new HTMLAnchorElement(aTag, document); |
| 124 } | 56 } |
| 125 | 57 |
| 126 HTMLAnchorElement::~HTMLAnchorElement() {} | 58 HTMLAnchorElement::~HTMLAnchorElement() {} |
| 127 | 59 |
| 128 DEFINE_TRACE(HTMLAnchorElement) { | |
| 129 visitor->trace(m_navigationHintSender); | |
| 130 HTMLElement::trace(visitor); | |
| 131 } | |
| 132 | |
| 133 bool HTMLAnchorElement::supportsFocus() const { | 60 bool HTMLAnchorElement::supportsFocus() const { |
| 134 if (hasEditableStyle(*this)) | 61 if (hasEditableStyle(*this)) |
| 135 return HTMLElement::supportsFocus(); | 62 return HTMLElement::supportsFocus(); |
| 136 // If not a link we should still be able to focus the element if it has | 63 // If not a link we should still be able to focus the element if it has |
| 137 // tabIndex. | 64 // tabIndex. |
| 138 return isLink() || HTMLElement::supportsFocus(); | 65 return isLink() || HTMLElement::supportsFocus(); |
| 139 } | 66 } |
| 140 | 67 |
| 141 bool HTMLAnchorElement::matchesEnabledPseudoClass() const { | 68 bool HTMLAnchorElement::matchesEnabledPseudoClass() const { |
| 142 return isLink(); | 69 return isLink(); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 } | 152 } |
| 226 | 153 |
| 227 void HTMLAnchorElement::defaultEventHandler(Event* event) { | 154 void HTMLAnchorElement::defaultEventHandler(Event* event) { |
| 228 if (isLink()) { | 155 if (isLink()) { |
| 229 if (isFocused() && isEnterKeyKeydownEvent(event) && isLiveLink()) { | 156 if (isFocused() && isEnterKeyKeydownEvent(event) && isLiveLink()) { |
| 230 event->setDefaultHandled(); | 157 event->setDefaultHandled(); |
| 231 dispatchSimulatedClick(event); | 158 dispatchSimulatedClick(event); |
| 232 return; | 159 return; |
| 233 } | 160 } |
| 234 | 161 |
| 235 if (RuntimeEnabledFeatures::speculativeLaunchServiceWorkerEnabled()) | |
| 236 ensureNavigationHintSender()->handleEvent(event); | |
| 237 | |
| 238 if (isLinkClick(event) && isLiveLink()) { | 162 if (isLinkClick(event) && isLiveLink()) { |
| 239 handleClick(event); | 163 handleClick(event); |
| 240 return; | 164 return; |
| 241 } | 165 } |
| 242 } | 166 } |
| 243 | 167 |
| 244 HTMLElement::defaultEventHandler(event); | 168 HTMLElement::defaultEventHandler(event); |
| 245 } | 169 } |
| 246 | 170 |
| 247 void HTMLAnchorElement::setActive(bool down) { | 171 void HTMLAnchorElement::setActive(bool down) { |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 } | 398 } |
| 475 | 399 |
| 476 Node::InsertionNotificationRequest HTMLAnchorElement::insertedInto( | 400 Node::InsertionNotificationRequest HTMLAnchorElement::insertedInto( |
| 477 ContainerNode* insertionPoint) { | 401 ContainerNode* insertionPoint) { |
| 478 InsertionNotificationRequest request = | 402 InsertionNotificationRequest request = |
| 479 HTMLElement::insertedInto(insertionPoint); | 403 HTMLElement::insertedInto(insertionPoint); |
| 480 logAddElementIfIsolatedWorldAndInDocument("a", hrefAttr); | 404 logAddElementIfIsolatedWorldAndInDocument("a", hrefAttr); |
| 481 return request; | 405 return request; |
| 482 } | 406 } |
| 483 | 407 |
| 484 HTMLAnchorElement::NavigationHintSender* | |
| 485 HTMLAnchorElement::ensureNavigationHintSender() { | |
| 486 if (!m_navigationHintSender) | |
| 487 m_navigationHintSender = NavigationHintSender::create(this); | |
| 488 return m_navigationHintSender; | |
| 489 } | |
| 490 | |
| 491 } // namespace blink | 408 } // namespace blink |
| OLD | NEW |