Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(794)

Side by Side Diff: Source/core/html/HTMLAnchorElement.cpp

Issue 619613005: The link should be activated by enter key on focusing the child element inside the anchor(relanding) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/html/HTMLAnchorElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 int x = absolutePosition.x(); 140 int x = absolutePosition.x();
141 int y = absolutePosition.y(); 141 int y = absolutePosition.y();
142 url.append('?'); 142 url.append('?');
143 url.appendNumber(x); 143 url.appendNumber(x);
144 url.append(','); 144 url.append(',');
145 url.appendNumber(y); 145 url.appendNumber(y);
146 } 146 }
147 147
148 void HTMLAnchorElement::defaultEventHandler(Event* event) 148 void HTMLAnchorElement::defaultEventHandler(Event* event)
149 { 149 {
150 if (isLink()) { 150 if (isLiveLink()) {
151 if (focused() && isEnterKeyKeydownEvent(event) && isLiveLink()) { 151 if (isLinkEnterKey(event)) {
152 event->setDefaultHandled(); 152 event->setDefaultHandled();
153 dispatchSimulatedClick(event); 153 dispatchSimulatedClick(event);
154 return; 154 return;
155 } 155 }
156 156
157 if (isLinkClick(event) && isLiveLink()) { 157 if (isLinkClick(event)) {
158 handleClick(event); 158 handleClick(event);
159 return; 159 return;
160 } 160 }
161 } 161 }
162 162
163 HTMLElement::defaultEventHandler(event); 163 HTMLElement::defaultEventHandler(event);
164 } 164 }
165 165
166 void HTMLAnchorElement::setActive(bool down) 166 void HTMLAnchorElement::setActive(bool down)
167 { 167 {
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 } else { 356 } else {
357 request.setRequestContext(blink::WebURLRequest::RequestContextHyperlink) ; 357 request.setRequestContext(blink::WebURLRequest::RequestContextHyperlink) ;
358 FrameLoadRequest frameRequest(&document(), request, getAttribute(targetA ttr)); 358 FrameLoadRequest frameRequest(&document(), request, getAttribute(targetA ttr));
359 frameRequest.setTriggeringEvent(event); 359 frameRequest.setTriggeringEvent(event);
360 if (hasRel(RelationNoReferrer)) 360 if (hasRel(RelationNoReferrer))
361 frameRequest.setShouldSendReferrer(NeverSendReferrer); 361 frameRequest.setShouldSendReferrer(NeverSendReferrer);
362 frame->loader().load(frameRequest); 362 frame->loader().load(frameRequest);
363 } 363 }
364 } 364 }
365 365
366 bool HTMLAnchorElement::isLinkEnterKey(Event* event)
367 {
368 if (isEnterKeyKeydownEvent(event)) {
369 if (focused())
370 return true;
371
372 ASSERT(event->target());
373 Node* target = event->target()->toNode();
374 ASSERT(target);
375
376 // if the target element is one of form controls or has contentEditable attribute on,
377 // we shouldn't simulate click action
378 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
379 return true;
380 }
381 return false;
382 }
383
366 bool isEnterKeyKeydownEvent(Event* event) 384 bool isEnterKeyKeydownEvent(Event* event)
367 { 385 {
368 return event->type() == EventTypeNames::keydown && event->isKeyboardEvent() && toKeyboardEvent(event)->keyIdentifier() == "Enter"; 386 return event->type() == EventTypeNames::keydown && event->isKeyboardEvent() && toKeyboardEvent(event)->keyIdentifier() == "Enter";
369 } 387 }
370 388
371 bool isLinkClick(Event* event) 389 bool isLinkClick(Event* event)
372 { 390 {
373 return event->type() == EventTypeNames::click && (!event->isMouseEvent() || toMouseEvent(event)->button() != RightButton); 391 return event->type() == EventTypeNames::click && (!event->isMouseEvent() || toMouseEvent(event)->button() != RightButton);
374 } 392 }
375 393
(...skipping 15 matching lines...) Expand all
391 Vector<String> argv; 409 Vector<String> argv;
392 argv.append("a"); 410 argv.append("a");
393 argv.append(fastGetAttribute(hrefAttr)); 411 argv.append(fastGetAttribute(hrefAttr));
394 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data() ); 412 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data() );
395 } 413 }
396 } 414 }
397 return HTMLElement::insertedInto(insertionPoint); 415 return HTMLElement::insertedInto(insertionPoint);
398 } 416 }
399 417
400 } 418 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLAnchorElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698