Chromium Code Reviews| Index: Source/core/html/HTMLAnchorElement.cpp |
| diff --git a/Source/core/html/HTMLAnchorElement.cpp b/Source/core/html/HTMLAnchorElement.cpp |
| index 533dc7f200053467398ad4fcd85b52a2a18c06ed..d7f1711762b111a395563edfb18aa5183ecdc8c8 100644 |
| --- a/Source/core/html/HTMLAnchorElement.cpp |
| +++ b/Source/core/html/HTMLAnchorElement.cpp |
| @@ -147,14 +147,14 @@ static void appendServerMapMousePosition(StringBuilder& url, Event* event) |
| void HTMLAnchorElement::defaultEventHandler(Event* event) |
| { |
| - if (isLink()) { |
| - if (focused() && isEnterKeyKeydownEvent(event) && isLiveLink()) { |
| + if (isLiveLink()) { |
| + if (isLinkEnterKey(event)) { |
| event->setDefaultHandled(); |
| dispatchSimulatedClick(event); |
| return; |
| } |
| - if (isLinkClick(event) && isLiveLink()) { |
| + if (isLinkClick(event)) { |
| handleClick(event); |
| return; |
| } |
| @@ -363,6 +363,24 @@ void HTMLAnchorElement::handleClick(Event* event) |
| } |
| } |
| +bool HTMLAnchorElement::isLinkEnterKey(Event* event) |
| +{ |
| + if (isEnterKeyKeydownEvent(event)) { |
| + if (focused()) |
| + return true; |
| + |
| + ASSERT(event->target()); |
| + Node* target = event->target()->toNode(); |
| + ASSERT(target); |
| + |
| + // if the target element is one of form controls or has contentEditable attribute on, |
| + // we shouldn't simulate click action |
| + if (target->focused() && !((target->isElementNode() && toElement(target)->isFormControlElement()) || target->isContentEditable())) |
|
robwu
2014/10/03 13:28:40
This logic is insufficient, because some form cont
|
| + return true; |
| + } |
| + return false; |
| +} |
| + |
| bool isEnterKeyKeydownEvent(Event* event) |
| { |
| return event->type() == EventTypeNames::keydown && event->isKeyboardEvent() && toKeyboardEvent(event)->keyIdentifier() == "Enter"; |