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

Unified Diff: Source/core/events/MouseEvent.cpp

Issue 1165693005: Change MouseEvent.button to be 'short' instead of 'unsigned short' (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/events/MouseEvent.h ('k') | Source/core/events/MouseEvent.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/events/MouseEvent.cpp
diff --git a/Source/core/events/MouseEvent.cpp b/Source/core/events/MouseEvent.cpp
index 2ecccb43c3dd31e669da96c199b179628a2bab6b..cba1190a3047dba42be57d947a694f65d5184043 100644
--- a/Source/core/events/MouseEvent.cpp
+++ b/Source/core/events/MouseEvent.cpp
@@ -60,7 +60,7 @@ PassRefPtrWillBeRawPtr<MouseEvent> MouseEvent::create(const AtomicString& type,
int detail, int screenX, int screenY, int windowX, int windowY,
int movementX, int movementY,
bool ctrlKey, bool altKey, bool shiftKey, bool metaKey,
- unsigned short button, unsigned short buttons,
+ short button, unsigned short buttons,
PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, DataTransfer* dataTransfer, bool isSimulated, PlatformMouseEvent::SyntheticEventType syntheticEventType,
double uiCreateTime)
{
@@ -73,7 +73,6 @@ PassRefPtrWillBeRawPtr<MouseEvent> MouseEvent::create(const AtomicString& type,
MouseEvent::MouseEvent()
: m_button(0)
, m_buttons(0)
- , m_buttonDown(false)
, m_relatedTarget(nullptr)
, m_dataTransfer(nullptr)
, m_syntheticEventType(PlatformMouseEvent::RealOrIndistinguishable)
@@ -84,16 +83,15 @@ MouseEvent::MouseEvent(const AtomicString& eventType, bool canBubble, bool cance
int detail, int screenX, int screenY, int windowX, int windowY,
int movementX, int movementY,
bool ctrlKey, bool altKey, bool shiftKey, bool metaKey,
- unsigned short button, unsigned short buttons, PassRefPtrWillBeRawPtr<EventTarget> relatedTarget,
+ short button, unsigned short buttons, PassRefPtrWillBeRawPtr<EventTarget> relatedTarget,
DataTransfer* dataTransfer, bool isSimulated, PlatformMouseEvent::SyntheticEventType syntheticEventType,
double uiCreateTime)
: MouseRelatedEvent(eventType, canBubble, cancelable, view, detail, IntPoint(screenX, screenY),
IntPoint(windowX, windowY),
IntPoint(movementX, movementY),
ctrlKey, altKey, shiftKey, metaKey, isSimulated)
- , m_button(button == (unsigned short)-1 ? 0 : button)
+ , m_button(button)
, m_buttons(buttons)
- , m_buttonDown(button != (unsigned short)-1)
, m_relatedTarget(relatedTarget)
, m_dataTransfer(dataTransfer)
, m_syntheticEventType(syntheticEventType)
@@ -106,9 +104,8 @@ MouseEvent::MouseEvent(const AtomicString& eventType, const MouseEventInit& init
IntPoint(0 /* pageX */, 0 /* pageY */),
IntPoint(initializer.movementX(), initializer.movementY()),
initializer.ctrlKey(), initializer.altKey(), initializer.shiftKey(), initializer.metaKey(), false /* isSimulated */)
- , m_button(initializer.button() == (unsigned short)-1 ? 0 : initializer.button())
+ , m_button(initializer.button())
, m_buttons(initializer.buttons())
- , m_buttonDown(initializer.button() != (unsigned short)-1)
, m_relatedTarget(initializer.relatedTarget())
, m_dataTransfer(nullptr)
, m_syntheticEventType(PlatformMouseEvent::RealOrIndistinguishable)
@@ -137,7 +134,7 @@ unsigned short MouseEvent::platformModifiersToButtons(unsigned modifiers)
void MouseEvent::initMouseEvent(ScriptState* scriptState, const AtomicString& type, bool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView> view,
int detail, int screenX, int screenY, int clientX, int clientY,
bool ctrlKey, bool altKey, bool shiftKey, bool metaKey,
- unsigned short button, PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, unsigned short buttons)
+ short button, PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, unsigned short buttons)
{
if (dispatched())
return;
@@ -152,9 +149,8 @@ void MouseEvent::initMouseEvent(ScriptState* scriptState, const AtomicString& ty
m_altKey = altKey;
m_shiftKey = shiftKey;
m_metaKey = metaKey;
- m_button = button == (unsigned short)-1 ? 0 : button;
+ m_button = button;
m_buttons = buttons;
- m_buttonDown = button != (unsigned short)-1;
m_relatedTarget = relatedTarget;
initCoordinates(IntPoint(clientX, clientY));
@@ -185,8 +181,6 @@ int MouseEvent::which() const
// For the DOM, the return values for left, middle and right mouse buttons are 0, 1, 2, respectively.
// For the Netscape "which" property, the return values for left, middle and right mouse buttons are 1, 2, 3, respectively.
// So we must add 1.
- if (!m_buttonDown)
- return 0;
return m_button + 1;
}
« no previous file with comments | « Source/core/events/MouseEvent.h ('k') | Source/core/events/MouseEvent.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698