| 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 10 matching lines...) Expand all Loading... |
| 21 * Boston, MA 02110-1301, USA. | 21 * Boston, MA 02110-1301, USA. |
| 22 */ | 22 */ |
| 23 | 23 |
| 24 #include "sky/engine/config.h" | 24 #include "sky/engine/config.h" |
| 25 #include "sky/engine/core/html/HTMLAnchorElement.h" | 25 #include "sky/engine/core/html/HTMLAnchorElement.h" |
| 26 | 26 |
| 27 #include "mojo/services/navigation/public/interfaces/navigation.mojom.h" | 27 #include "mojo/services/navigation/public/interfaces/navigation.mojom.h" |
| 28 #include "sky/engine/core/dom/Attribute.h" | 28 #include "sky/engine/core/dom/Attribute.h" |
| 29 #include "sky/engine/core/editing/FrameSelection.h" | 29 #include "sky/engine/core/editing/FrameSelection.h" |
| 30 #include "sky/engine/core/events/KeyboardEvent.h" | 30 #include "sky/engine/core/events/KeyboardEvent.h" |
| 31 #include "sky/engine/core/events/MouseEvent.h" | |
| 32 #include "sky/engine/core/frame/FrameHost.h" | 31 #include "sky/engine/core/frame/FrameHost.h" |
| 33 #include "sky/engine/core/frame/LocalFrame.h" | 32 #include "sky/engine/core/frame/LocalFrame.h" |
| 34 #include "sky/engine/core/frame/Settings.h" | 33 #include "sky/engine/core/frame/Settings.h" |
| 35 #include "sky/engine/core/html/HTMLImageElement.h" | 34 #include "sky/engine/core/html/HTMLImageElement.h" |
| 36 #include "sky/engine/core/html/parser/HTMLParserIdioms.h" | 35 #include "sky/engine/core/html/parser/HTMLParserIdioms.h" |
| 37 #include "sky/engine/core/loader/FrameLoaderClient.h" | 36 #include "sky/engine/core/loader/FrameLoaderClient.h" |
| 38 #include "sky/engine/core/loader/FrameLoaderTypes.h" | 37 #include "sky/engine/core/loader/FrameLoaderTypes.h" |
| 39 #include "sky/engine/core/page/Chrome.h" | 38 #include "sky/engine/core/page/Chrome.h" |
| 40 #include "sky/engine/core/page/ChromeClient.h" | 39 #include "sky/engine/core/page/ChromeClient.h" |
| 41 #include "sky/engine/core/rendering/RenderImage.h" | 40 #include "sky/engine/core/rendering/RenderImage.h" |
| 42 #include "sky/engine/platform/PlatformMouseEvent.h" | |
| 43 #include "sky/engine/platform/network/ResourceRequest.h" | 41 #include "sky/engine/platform/network/ResourceRequest.h" |
| 44 #include "sky/engine/platform/weborigin/KnownPorts.h" | 42 #include "sky/engine/platform/weborigin/KnownPorts.h" |
| 45 #include "sky/engine/platform/weborigin/SecurityPolicy.h" | 43 #include "sky/engine/platform/weborigin/SecurityPolicy.h" |
| 46 #include "sky/engine/public/platform/Platform.h" | 44 #include "sky/engine/public/platform/Platform.h" |
| 47 #include "sky/engine/public/platform/ServiceProvider.h" | 45 #include "sky/engine/public/platform/ServiceProvider.h" |
| 48 #include "sky/engine/public/platform/WebURL.h" | 46 #include "sky/engine/public/platform/WebURL.h" |
| 49 #include "sky/engine/public/platform/WebURLRequest.h" | 47 #include "sky/engine/public/platform/WebURLRequest.h" |
| 50 #include "sky/engine/wtf/text/StringBuilder.h" | 48 #include "sky/engine/wtf/text/StringBuilder.h" |
| 51 | 49 |
| 52 namespace blink { | 50 namespace blink { |
| 53 | 51 |
| 54 static bool isEnterKeyKeydownEvent(Event* event) | |
| 55 { | |
| 56 return event->type() == EventTypeNames::keydown && event->isKeyboardEvent()
&& toKeyboardEvent(event)->keyIdentifier() == "Enter"; | |
| 57 } | |
| 58 | |
| 59 static bool isLinkClick(Event* event) | 52 static bool isLinkClick(Event* event) |
| 60 { | 53 { |
| 61 return event->type() == EventTypeNames::click && (!event->isMouseEvent() ||
toMouseEvent(event)->button() != RightButton); | 54 return event->type() == EventTypeNames::click; |
| 62 } | 55 } |
| 63 | 56 |
| 64 PassRefPtr<HTMLAnchorElement> HTMLAnchorElement::create(Document& document) | 57 PassRefPtr<HTMLAnchorElement> HTMLAnchorElement::create(Document& document) |
| 65 { | 58 { |
| 66 return adoptRef(new HTMLAnchorElement(document)); | 59 return adoptRef(new HTMLAnchorElement(document)); |
| 67 } | 60 } |
| 68 | 61 |
| 69 HTMLAnchorElement::HTMLAnchorElement(Document& document) | 62 HTMLAnchorElement::HTMLAnchorElement(Document& document) |
| 70 : HTMLElement(HTMLNames::aTag, document) | 63 : HTMLElement(HTMLNames::aTag, document) |
| 71 { | 64 { |
| 72 } | 65 } |
| 73 | 66 |
| 74 HTMLAnchorElement::~HTMLAnchorElement() | 67 HTMLAnchorElement::~HTMLAnchorElement() |
| 75 { | 68 { |
| 76 } | 69 } |
| 77 | 70 |
| 78 bool HTMLAnchorElement::supportsFocus() const | 71 bool HTMLAnchorElement::supportsFocus() const |
| 79 { | 72 { |
| 80 if (hasEditableStyle()) | 73 if (hasEditableStyle()) |
| 81 return HTMLElement::supportsFocus(); | 74 return HTMLElement::supportsFocus(); |
| 82 return true; | 75 return true; |
| 83 } | 76 } |
| 84 | 77 |
| 85 void HTMLAnchorElement::defaultEventHandler(Event* event) | 78 void HTMLAnchorElement::defaultEventHandler(Event* event) |
| 86 { | 79 { |
| 87 if (focused() && isEnterKeyKeydownEvent(event) && isLiveLink()) { | |
| 88 event->setDefaultHandled(); | |
| 89 dispatchSimulatedClick(event); | |
| 90 return; | |
| 91 } | |
| 92 | |
| 93 if (isLinkClick(event) && isLiveLink()) { | 80 if (isLinkClick(event) && isLiveLink()) { |
| 94 handleClick(event); | 81 handleClick(event); |
| 95 return; | 82 return; |
| 96 } | 83 } |
| 97 } | 84 } |
| 98 | 85 |
| 99 bool HTMLAnchorElement::isURLAttribute(const Attribute& attribute) const | 86 bool HTMLAnchorElement::isURLAttribute(const Attribute& attribute) const |
| 100 { | 87 { |
| 101 return attribute.name() == HTMLNames::hrefAttr || HTMLElement::isURLAttribut
e(attribute); | 88 return attribute.name() == HTMLNames::hrefAttr || HTMLElement::isURLAttribut
e(attribute); |
| 102 } | 89 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 mojo::TARGET_SOURCE_NODE, request.Pass()); | 122 mojo::TARGET_SOURCE_NODE, request.Pass()); |
| 136 event->setDefaultHandled(); | 123 event->setDefaultHandled(); |
| 137 } | 124 } |
| 138 | 125 |
| 139 bool HTMLAnchorElement::willRespondToMouseClickEvents() | 126 bool HTMLAnchorElement::willRespondToMouseClickEvents() |
| 140 { | 127 { |
| 141 return isLiveLink(); | 128 return isLiveLink(); |
| 142 } | 129 } |
| 143 | 130 |
| 144 } | 131 } |
| OLD | NEW |