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

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: Rebase Created 6 years, 1 month 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') | Source/core/svg/SVGAElement.cpp » ('j') | 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 ASSERT(event->target());
152 Node* target = event->target()->toNode();
153 ASSERT(target);
154 if ((focused() || target->focused()) && isEnterKeyKeypressEvent(event)) {
152 event->setDefaultHandled(); 155 event->setDefaultHandled();
153 dispatchSimulatedClick(event); 156 dispatchSimulatedClick(event);
154 return; 157 return;
155 } 158 }
156 159
157 if (isLinkClick(event) && isLiveLink()) { 160 if (isLinkClick(event)) {
158 handleClick(event); 161 handleClick(event);
159 return; 162 return;
160 } 163 }
161 } 164 }
162 165
163 HTMLElement::defaultEventHandler(event); 166 HTMLElement::defaultEventHandler(event);
164 } 167 }
165 168
166 void HTMLAnchorElement::setActive(bool down) 169 void HTMLAnchorElement::setActive(bool down)
167 { 170 {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 } else { 353 } else {
351 request.setRequestContext(blink::WebURLRequest::RequestContextHyperlink) ; 354 request.setRequestContext(blink::WebURLRequest::RequestContextHyperlink) ;
352 FrameLoadRequest frameRequest(&document(), request, getAttribute(targetA ttr)); 355 FrameLoadRequest frameRequest(&document(), request, getAttribute(targetA ttr));
353 frameRequest.setTriggeringEvent(event); 356 frameRequest.setTriggeringEvent(event);
354 if (hasRel(RelationNoReferrer)) 357 if (hasRel(RelationNoReferrer))
355 frameRequest.setShouldSendReferrer(NeverSendReferrer); 358 frameRequest.setShouldSendReferrer(NeverSendReferrer);
356 frame->loader().load(frameRequest); 359 frame->loader().load(frameRequest);
357 } 360 }
358 } 361 }
359 362
360 bool isEnterKeyKeydownEvent(Event* event) 363 bool isEnterKeyKeypressEvent(Event* event)
361 { 364 {
362 return event->type() == EventTypeNames::keydown && event->isKeyboardEvent() && toKeyboardEvent(event)->keyIdentifier() == "Enter"; 365 return event->type() == EventTypeNames::keypress && event->isKeyboardEvent() && toKeyboardEvent(event)->keyIdentifier() == "Enter";
363 } 366 }
364 367
365 bool isLinkClick(Event* event) 368 bool isLinkClick(Event* event)
366 { 369 {
367 return event->type() == EventTypeNames::click && (!event->isMouseEvent() || toMouseEvent(event)->button() != RightButton); 370 return event->type() == EventTypeNames::click && (!event->isMouseEvent() || toMouseEvent(event)->button() != RightButton);
368 } 371 }
369 372
370 bool HTMLAnchorElement::willRespondToMouseClickEvents() 373 bool HTMLAnchorElement::willRespondToMouseClickEvents()
371 { 374 {
372 return isLink() || HTMLElement::willRespondToMouseClickEvents(); 375 return isLink() || HTMLElement::willRespondToMouseClickEvents();
(...skipping 12 matching lines...) Expand all
385 Vector<String> argv; 388 Vector<String> argv;
386 argv.append("a"); 389 argv.append("a");
387 argv.append(fastGetAttribute(hrefAttr)); 390 argv.append(fastGetAttribute(hrefAttr));
388 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data() ); 391 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data() );
389 } 392 }
390 } 393 }
391 return HTMLElement::insertedInto(insertionPoint); 394 return HTMLElement::insertedInto(insertionPoint);
392 } 395 }
393 396
394 } 397 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLAnchorElement.h ('k') | Source/core/svg/SVGAElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698