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

Unified Diff: Source/platform/PlatformMouseEvent.h

Issue 727593003: Implement MouseEvent buttons attribute. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: addressed comments 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 side-by-side diff with in-line comments
Download patch
Index: Source/platform/PlatformMouseEvent.h
diff --git a/Source/platform/PlatformMouseEvent.h b/Source/platform/PlatformMouseEvent.h
index 488bd0c211c910e5137fe452603608f3484de634..070ab9839f6bc3030ef4bda0677b863cfb8ec647 100644
--- a/Source/platform/PlatformMouseEvent.h
+++ b/Source/platform/PlatformMouseEvent.h
@@ -61,6 +61,7 @@ public:
, m_synthesized(RealOrIndistinguishable)
, m_modifierFlags(0)
{
+ addModifierFromButton(button);
}
PlatformMouseEvent(const IntPoint& position, const IntPoint& globalPosition, MouseButton button, PlatformEvent::Type type, int clickCount, Modifiers modifiers, SyntheticEventType synthesized, double timestamp)
@@ -72,6 +73,7 @@ public:
, m_synthesized(synthesized)
, m_modifierFlags(0)
{
+ addModifierFromButton(button);
}
PlatformMouseEvent(const IntPoint& position, const IntPoint& globalPosition, MouseButton button, PlatformEvent::Type type, int clickCount, bool shiftKey, bool ctrlKey, bool altKey, bool metaKey, SyntheticEventType synthesized, double timestamp)
@@ -83,6 +85,7 @@ public:
, m_synthesized(synthesized)
, m_modifierFlags(0)
{
+ addModifierFromButton(button);
}
const IntPoint& position() const { return m_position; }
@@ -95,6 +98,18 @@ public:
bool fromTouch() const { return m_synthesized == FromTouch; }
SyntheticEventType syntheticEventType() const { return m_synthesized; }
+private:
+ void addModifierFromButton(MouseButton button)
+ {
+ if (!fromTouch() || button == NoButton)
+ return;
+
+ const unsigned map[] = {
+ LeftButtonDown, MiddleButtonDown, RightButtonDown
+ };
+ m_modifiers |= map[button];
+ }
+
protected:
IntPoint m_position;
IntPoint m_globalPosition;

Powered by Google App Engine
This is Rietveld 408576698