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 22 matching lines...) Expand all Loading... | |
| 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 | 40 |
| 41 namespace blink { | 41 namespace blink { |
| 42 | 42 |
| 43 namespace { | |
| 44 | |
| 45 // TODO(horo): Move WebNavigationHintType to public/ directory. | |
| 46 enum class WebNavigationHintType { | |
|
kinuko
2016/06/21 04:51:25
nit: It's supposed to be tentative code but it mig
horo
2016/06/21 05:05:47
Done.
| |
| 47 Unknown, | |
| 48 LinkMouseDown, | |
| 49 LinkTapUnconfirmed, | |
| 50 LinkTapDown, | |
| 51 Last = LinkTapDown | |
| 52 }; | |
| 53 | |
| 54 } // namespace | |
| 55 | |
| 43 using namespace HTMLNames; | 56 using namespace HTMLNames; |
| 44 | 57 |
| 58 class HTMLAnchorElement::NavigationHintSender : public GarbageCollected<HTMLAnch orElement::NavigationHintSender> { | |
| 59 public: | |
| 60 static NavigationHintSender* create(HTMLAnchorElement* anchorElement) | |
| 61 { | |
| 62 return new NavigationHintSender(anchorElement); | |
| 63 } | |
| 64 void handleEvent(Event*); | |
| 65 | |
| 66 DECLARE_VIRTUAL_TRACE(); | |
| 67 | |
| 68 private: | |
| 69 explicit NavigationHintSender(HTMLAnchorElement*); | |
| 70 bool shouldSendNavigationHint() const; | |
| 71 void maybeSendNavigationHint(WebNavigationHintType); | |
| 72 | |
| 73 Member<HTMLAnchorElement> m_anchorElement; | |
| 74 }; | |
| 75 | |
| 76 void HTMLAnchorElement::NavigationHintSender::handleEvent(Event* event) | |
| 77 { | |
| 78 if (event->type() == EventTypeNames::mousedown && event->isMouseEvent() && t oMouseEvent(event)->button() == LeftButton) | |
| 79 maybeSendNavigationHint(WebNavigationHintType::LinkMouseDown); | |
| 80 else if (event->type() == EventTypeNames::gesturetapunconfirmed) | |
| 81 maybeSendNavigationHint(WebNavigationHintType::LinkTapUnconfirmed); | |
| 82 else if (event->type() == EventTypeNames::gestureshowpress) | |
| 83 maybeSendNavigationHint(WebNavigationHintType::LinkTapDown); | |
| 84 } | |
| 85 | |
| 86 DEFINE_TRACE(HTMLAnchorElement::NavigationHintSender) | |
| 87 { | |
| 88 visitor->trace(m_anchorElement); | |
| 89 } | |
| 90 | |
| 91 HTMLAnchorElement::NavigationHintSender::NavigationHintSender(HTMLAnchorElement* anchorElement) | |
| 92 : m_anchorElement(anchorElement) | |
| 93 { | |
| 94 } | |
| 95 | |
| 96 bool HTMLAnchorElement::NavigationHintSender::shouldSendNavigationHint() const | |
| 97 { | |
| 98 const KURL& url = m_anchorElement->href(); | |
| 99 // Currently the navigation hint only supports HTTP and HTTPS. | |
| 100 if (!url.protocolIsInHTTPFamily()) | |
| 101 return false; | |
| 102 | |
| 103 Document& document = m_anchorElement->document(); | |
| 104 // If the element was detached from the frame, handleClick() doesn't cause | |
| 105 // the navigation. | |
| 106 if (!document.frame()) | |
| 107 return false; | |
| 108 | |
| 109 // When the user clicks a link which is to the current document with a hash, | |
| 110 // the network request is not fetched. So we don't send the navigation hint | |
| 111 // to the browser process. | |
| 112 if (url.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier(document. url(), url)) | |
| 113 return false; | |
| 114 | |
| 115 return true; | |
| 116 } | |
| 117 | |
| 118 void HTMLAnchorElement::NavigationHintSender::maybeSendNavigationHint(WebNavigat ionHintType type) | |
| 119 { | |
| 120 if (!shouldSendNavigationHint()) | |
| 121 return; | |
| 122 | |
| 123 // TODO(horo): Send the navigation hint message to the browser process. | |
| 124 } | |
| 125 | |
| 45 HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tagName, Document& doc ument) | 126 HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tagName, Document& doc ument) |
| 46 : HTMLElement(tagName, document) | 127 : HTMLElement(tagName, document) |
| 47 , m_linkRelations(0) | 128 , m_linkRelations(0) |
| 48 , m_cachedVisitedLinkHash(0) | 129 , m_cachedVisitedLinkHash(0) |
| 49 , m_wasFocusedByMouse(false) | 130 , m_wasFocusedByMouse(false) |
| 50 { | 131 { |
| 51 } | 132 } |
| 52 | 133 |
| 53 HTMLAnchorElement* HTMLAnchorElement::create(Document& document) | 134 HTMLAnchorElement* HTMLAnchorElement::create(Document& document) |
| 54 { | 135 { |
| 55 return new HTMLAnchorElement(aTag, document); | 136 return new HTMLAnchorElement(aTag, document); |
| 56 } | 137 } |
| 57 | 138 |
| 58 HTMLAnchorElement::~HTMLAnchorElement() | 139 HTMLAnchorElement::~HTMLAnchorElement() |
| 59 { | 140 { |
| 60 } | 141 } |
| 61 | 142 |
| 143 DEFINE_TRACE(HTMLAnchorElement) | |
| 144 { | |
| 145 visitor->trace(m_navigationHintSender); | |
| 146 HTMLElement::trace(visitor); | |
| 147 } | |
| 148 | |
| 62 bool HTMLAnchorElement::supportsFocus() const | 149 bool HTMLAnchorElement::supportsFocus() const |
| 63 { | 150 { |
| 64 if (hasEditableStyle()) | 151 if (hasEditableStyle()) |
| 65 return HTMLElement::supportsFocus(); | 152 return HTMLElement::supportsFocus(); |
| 66 // If not a link we should still be able to focus the element if it has tabI ndex. | 153 // If not a link we should still be able to focus the element if it has tabI ndex. |
| 67 return isLink() || HTMLElement::supportsFocus(); | 154 return isLink() || HTMLElement::supportsFocus(); |
| 68 } | 155 } |
| 69 | 156 |
| 70 bool HTMLAnchorElement::matchesEnabledPseudoClass() const | 157 bool HTMLAnchorElement::matchesEnabledPseudoClass() const |
| 71 { | 158 { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 | 242 |
| 156 void HTMLAnchorElement::defaultEventHandler(Event* event) | 243 void HTMLAnchorElement::defaultEventHandler(Event* event) |
| 157 { | 244 { |
| 158 if (isLink()) { | 245 if (isLink()) { |
| 159 if (focused() && isEnterKeyKeydownEvent(event) && isLiveLink()) { | 246 if (focused() && isEnterKeyKeydownEvent(event) && isLiveLink()) { |
| 160 event->setDefaultHandled(); | 247 event->setDefaultHandled(); |
| 161 dispatchSimulatedClick(event); | 248 dispatchSimulatedClick(event); |
| 162 return; | 249 return; |
| 163 } | 250 } |
| 164 | 251 |
| 252 // TODO(horo): Call NavigationHintSender::handleEvent() when | |
| 253 // SpeculativeLaunchServiceWorker feature is enabled. | |
| 254 // ensureNavigationHintSender()->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::ensureNavigationHint Sender() | |
| 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 |