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

Side by Side Diff: third_party/WebKit/Source/core/events/MouseEvent.cpp

Issue 2840023002: Fix button event on mouse events. (Closed)
Patch Set: Fix button event on mouse events. Created 3 years, 7 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 | « third_party/WebKit/Source/core/events/MouseEvent.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) 2001 Peter Kelly (pmk@post.com) 2 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) 3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5 * Copyright (C) 2003, 2005, 2006, 2008 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2005, 2006, 2008 Apple Inc. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 } 377 }
378 378
379 const AtomicString& MouseEvent::InterfaceName() const { 379 const AtomicString& MouseEvent::InterfaceName() const {
380 return EventNames::MouseEvent; 380 return EventNames::MouseEvent;
381 } 381 }
382 382
383 bool MouseEvent::IsMouseEvent() const { 383 bool MouseEvent::IsMouseEvent() const {
384 return true; 384 return true;
385 } 385 }
386 386
387 short MouseEvent::button() const {
388 const AtomicString& event_name = type();
389 if (button_ == -1 || event_name == EventTypeNames::mousemove ||
390 event_name == EventTypeNames::mouseleave ||
391 event_name == EventTypeNames::mouseenter ||
392 event_name == EventTypeNames::mouseover ||
393 event_name == EventTypeNames::mouseout) {
394 return 0;
395 }
396 return button_;
397 }
398
387 int MouseEvent::which() const { 399 int MouseEvent::which() const {
388 // For the DOM, the return values for left, middle and right mouse buttons are 400 // For the DOM, the return values for left, middle and right mouse buttons are
389 // 0, 1, 2, respectively. 401 // 0, 1, 2, respectively.
390 // For the Netscape "which" property, the return values for left, middle and 402 // For the Netscape "which" property, the return values for left, middle and
391 // right mouse buttons are 1, 2, 3, respectively. 403 // right mouse buttons are 1, 2, 3, respectively.
392 // So we must add 1. 404 // So we must add 1.
393 return button_ + 1; 405 return button_ + 1;
394 } 406 }
395 407
396 Node* MouseEvent::toElement() const { 408 Node* MouseEvent::toElement() const {
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 598
587 int MouseEvent::offsetY() { 599 int MouseEvent::offsetY() {
588 if (!HasPosition()) 600 if (!HasPosition())
589 return 0; 601 return 0;
590 if (!has_cached_relative_position_) 602 if (!has_cached_relative_position_)
591 ComputeRelativePosition(); 603 ComputeRelativePosition();
592 return std::round(offset_location_.Y()); 604 return std::round(offset_location_.Y());
593 } 605 }
594 606
595 } // namespace blink 607 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/events/MouseEvent.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698