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> { | |
| 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 Document& document = m_anchorElement->document(); | |
| 92 if (!document.frame()) | |
| 93 return false; | |
| 94 if (!document.getSecurityOrigin()->canDisplay(url)) | |
| 95 return false; | |
|
falken
2016/06/15 13:48:19
I'm probably just clueless about DOM stuff but why
horo
2016/06/16 06:02:44
Added comment about checking frame().
Ah we don't
| |
| 96 if (url.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier(document. url(), url)) | |
| 97 return false; | |
|
falken
2016/06/15 13:48:19
Thanks for the explanation of this one, that makes
| |
| 98 | |
| 99 // If the opener is to be suppressed and the target frame name is set, | |
| 100 // WebContentsImpl::CreateNewWindow() will create a new process when the | |
| 101 // user click the anchor element. In such case we shouldn't start the | |
|
falken
2016/06/15 13:48:19
s/click/clicks
| |
| 102 // Service Worker not to keep the current process running. | |
|
falken
2016/06/15 13:48:19
The first sentence makes sense to me, but the seco
horo
2016/06/16 06:02:44
I thought that we should not run the SW in the cur
| |
| 103 const bool openerSuppressed = m_anchorElement->hasRel(RelationNoReferrer) || m_anchorElement->hasRel(RelationNoOpener); | |
| 104 if (openerSuppressed && !m_anchorElement->getAttribute(targetAttr).isEmpty() ) | |
| 105 return false; | |
| 106 return true; | |
| 107 } | |
| 108 | |
| 109 void HTMLAnchorElement::NavigationHintSender::maybeSendNavigationHintForServiceW orker(WebNavigationHintType type) | |
| 110 { | |
| 111 if (!shouldSendNavigationHintForServiceWorker()) | |
| 112 return; | |
| 113 | |
| 114 // TODO(horo): Send the navigation hint message to the browser process. | |
| 115 } | |
| 116 | |
| 45 HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tagName, Document& doc ument) | 117 HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tagName, Document& doc ument) |
| 46 : HTMLElement(tagName, document) | 118 : HTMLElement(tagName, document) |
| 47 , m_linkRelations(0) | 119 , m_linkRelations(0) |
| 48 , m_cachedVisitedLinkHash(0) | 120 , m_cachedVisitedLinkHash(0) |
| 49 , m_wasFocusedByMouse(false) | 121 , m_wasFocusedByMouse(false) |
| 50 { | 122 { |
| 51 } | 123 } |
| 52 | 124 |
| 53 HTMLAnchorElement* HTMLAnchorElement::create(Document& document) | 125 HTMLAnchorElement* HTMLAnchorElement::create(Document& document) |
| 54 { | 126 { |
| 55 return new HTMLAnchorElement(aTag, document); | 127 return new HTMLAnchorElement(aTag, document); |
| 56 } | 128 } |
| 57 | 129 |
| 58 HTMLAnchorElement::~HTMLAnchorElement() | 130 HTMLAnchorElement::~HTMLAnchorElement() |
| 59 { | 131 { |
| 60 } | 132 } |
| 61 | 133 |
| 134 DEFINE_TRACE(HTMLAnchorElement) | |
| 135 { | |
| 136 visitor->trace(m_navigationHintsender); | |
| 137 HTMLElement::trace(visitor); | |
| 138 } | |
| 139 | |
| 62 bool HTMLAnchorElement::supportsFocus() const | 140 bool HTMLAnchorElement::supportsFocus() const |
| 63 { | 141 { |
| 64 if (hasEditableStyle()) | 142 if (hasEditableStyle()) |
| 65 return HTMLElement::supportsFocus(); | 143 return HTMLElement::supportsFocus(); |
| 66 // If not a link we should still be able to focus the element if it has tabI ndex. | 144 // If not a link we should still be able to focus the element if it has tabI ndex. |
| 67 return isLink() || HTMLElement::supportsFocus(); | 145 return isLink() || HTMLElement::supportsFocus(); |
| 68 } | 146 } |
| 69 | 147 |
| 70 bool HTMLAnchorElement::matchesEnabledPseudoClass() const | 148 bool HTMLAnchorElement::matchesEnabledPseudoClass() const |
| 71 { | 149 { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 | 233 |
| 156 void HTMLAnchorElement::defaultEventHandler(Event* event) | 234 void HTMLAnchorElement::defaultEventHandler(Event* event) |
| 157 { | 235 { |
| 158 if (isLink()) { | 236 if (isLink()) { |
| 159 if (focused() && isEnterKeyKeydownEvent(event) && isLiveLink()) { | 237 if (focused() && isEnterKeyKeydownEvent(event) && isLiveLink()) { |
| 160 event->setDefaultHandled(); | 238 event->setDefaultHandled(); |
| 161 dispatchSimulatedClick(event); | 239 dispatchSimulatedClick(event); |
| 162 return; | 240 return; |
| 163 } | 241 } |
| 164 | 242 |
| 243 // TODO(horo): Call NavigationHintSender::handleEvent() when | |
| 244 // SpeculativeLaunchServiceWorker feature is enabled. | |
| 245 // ensureNavigationHintSender()->handleEvent(event); | |
| 246 | |
| 165 if (isLinkClick(event) && isLiveLink()) { | 247 if (isLinkClick(event) && isLiveLink()) { |
| 166 handleClick(event); | 248 handleClick(event); |
| 167 return; | 249 return; |
| 168 } | 250 } |
| 169 } | 251 } |
| 170 | 252 |
| 171 HTMLElement::defaultEventHandler(event); | 253 HTMLElement::defaultEventHandler(event); |
| 172 } | 254 } |
| 173 | 255 |
| 174 void HTMLAnchorElement::setActive(bool down) | 256 void HTMLAnchorElement::setActive(bool down) |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 389 return isLink(); | 471 return isLink(); |
| 390 } | 472 } |
| 391 | 473 |
| 392 Node::InsertionNotificationRequest HTMLAnchorElement::insertedInto(ContainerNode * insertionPoint) | 474 Node::InsertionNotificationRequest HTMLAnchorElement::insertedInto(ContainerNode * insertionPoint) |
| 393 { | 475 { |
| 394 InsertionNotificationRequest request = HTMLElement::insertedInto(insertionPo int); | 476 InsertionNotificationRequest request = HTMLElement::insertedInto(insertionPo int); |
| 395 logAddElementIfIsolatedWorldAndInDocument("a", hrefAttr); | 477 logAddElementIfIsolatedWorldAndInDocument("a", hrefAttr); |
| 396 return request; | 478 return request; |
| 397 } | 479 } |
| 398 | 480 |
| 481 HTMLAnchorElement::NavigationHintSender* HTMLAnchorElement::ensureNavigationHint Sender() | |
| 482 { | |
| 483 if (!m_navigationHintsender) | |
| 484 m_navigationHintsender = NavigationHintSender::create(this); | |
| 485 return m_navigationHintsender; | |
| 486 } | |
| 487 | |
| 399 } // namespace blink | 488 } // namespace blink |
| OLD | NEW |