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

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

Issue 896383002: Revert 184783 "The link should be activated by enter key on focus.." (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 10 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') | 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 (isLiveLink()) { 150 if (isLink()) {
151 Node* target = event->target() ? event->target()->toNode() : 0; 151 if (focused() && isEnterKeyKeydownEvent(event) && isLiveLink()) {
152 bool hasFocus = focused() || (target && target->focused());
153 if (hasFocus && isEnterKeyKeypressEvent(event)) {
154 event->setDefaultHandled(); 152 event->setDefaultHandled();
155 dispatchSimulatedClick(event); 153 dispatchSimulatedClick(event);
156 return; 154 return;
157 } 155 }
158 156
159 if (isLinkClick(event)) { 157 if (isLinkClick(event) && isLiveLink()) {
160 handleClick(event); 158 handleClick(event);
161 return; 159 return;
162 } 160 }
163 } 161 }
164 162
165 HTMLElement::defaultEventHandler(event); 163 HTMLElement::defaultEventHandler(event);
166 } 164 }
167 165
168 void HTMLAnchorElement::setActive(bool down) 166 void HTMLAnchorElement::setActive(bool down)
169 { 167 {
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 } else { 353 } else {
356 request.setRequestContext(blink::WebURLRequest::RequestContextHyperlink) ; 354 request.setRequestContext(blink::WebURLRequest::RequestContextHyperlink) ;
357 FrameLoadRequest frameRequest(&document(), request, getAttribute(targetA ttr)); 355 FrameLoadRequest frameRequest(&document(), request, getAttribute(targetA ttr));
358 frameRequest.setTriggeringEvent(event); 356 frameRequest.setTriggeringEvent(event);
359 if (hasRel(RelationNoReferrer)) 357 if (hasRel(RelationNoReferrer))
360 frameRequest.setShouldSendReferrer(NeverSendReferrer); 358 frameRequest.setShouldSendReferrer(NeverSendReferrer);
361 frame->loader().load(frameRequest); 359 frame->loader().load(frameRequest);
362 } 360 }
363 } 361 }
364 362
365 bool isEnterKeyKeypressEvent(Event* event) 363 bool isEnterKeyKeydownEvent(Event* event)
366 { 364 {
367 return event->type() == EventTypeNames::keypress && event->isKeyboardEvent() && toKeyboardEvent(event)->keyIdentifier() == "Enter"; 365 return event->type() == EventTypeNames::keydown && event->isKeyboardEvent() && toKeyboardEvent(event)->keyIdentifier() == "Enter";
368 } 366 }
369 367
370 bool isLinkClick(Event* event) 368 bool isLinkClick(Event* event)
371 { 369 {
372 return event->type() == EventTypeNames::click && (!event->isMouseEvent() || toMouseEvent(event)->button() != RightButton); 370 return event->type() == EventTypeNames::click && (!event->isMouseEvent() || toMouseEvent(event)->button() != RightButton);
373 } 371 }
374 372
375 bool HTMLAnchorElement::willRespondToMouseClickEvents() 373 bool HTMLAnchorElement::willRespondToMouseClickEvents()
376 { 374 {
377 return isLink() || HTMLElement::willRespondToMouseClickEvents(); 375 return isLink() || HTMLElement::willRespondToMouseClickEvents();
(...skipping 12 matching lines...) Expand all
390 Vector<String> argv; 388 Vector<String> argv;
391 argv.append("a"); 389 argv.append("a");
392 argv.append(fastGetAttribute(hrefAttr)); 390 argv.append(fastGetAttribute(hrefAttr));
393 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data() ); 391 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data() );
394 } 392 }
395 } 393 }
396 return HTMLElement::insertedInto(insertionPoint); 394 return HTMLElement::insertedInto(insertionPoint);
397 } 395 }
398 396
399 } 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