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

Unified Diff: third_party/WebKit/Source/core/events/PointerEventFactory.cpp

Issue 2313653004: Make a pen in eraser mode visible thru PointerEvent.buttons (Closed)
Patch Set: Created 4 years, 3 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
Index: third_party/WebKit/Source/core/events/PointerEventFactory.cpp
diff --git a/third_party/WebKit/Source/core/events/PointerEventFactory.cpp b/third_party/WebKit/Source/core/events/PointerEventFactory.cpp
index ef93631cd36dd7b0459ea194c434603f576bb1d1..671129364bd1a03a814805c953427551c49a2d0a 100644
--- a/third_party/WebKit/Source/core/events/PointerEventFactory.cpp
+++ b/third_party/WebKit/Source/core/events/PointerEventFactory.cpp
@@ -21,6 +21,8 @@ const char* pointerTypeNameForWebPointPointerType(WebPointerProperties::PointerT
case WebPointerProperties::PointerType::Touch:
return "touch";
case WebPointerProperties::PointerType::Pen:
+ case WebPointerProperties::PointerType::Eraser:
+ // TODO(mustaq): Fix when the spec starts supporting hovering erasers.
return "pen";
case WebPointerProperties::PointerType::Mouse:
return "mouse";
@@ -54,16 +56,22 @@ const AtomicString& pointerEventNameForMouseEventName(
unsigned short buttonToButtonsBitfield(WebPointerProperties::Button button)
{
+#define CASE_BUTTON_TO_BUTTONS(enumLabel) \
+ case WebPointerProperties::Button::enumLabel:\
+ return static_cast<unsigned short>(WebPointerProperties::Buttons::enumLabel)
+
switch (button) {
- case WebPointerProperties::Button::NoButton:
- return static_cast<unsigned short>(MouseEvent::Buttons::None);
- case WebPointerProperties::Button::Left:
- return static_cast<unsigned short>(MouseEvent::Buttons::Left);
- case WebPointerProperties::Button::Right:
- return static_cast<unsigned short>(MouseEvent::Buttons::Right);
- case WebPointerProperties::Button::Middle:
- return static_cast<unsigned short>(MouseEvent::Buttons::Middle);
+ CASE_BUTTON_TO_BUTTONS(NoButton);
+ CASE_BUTTON_TO_BUTTONS(Left);
+ CASE_BUTTON_TO_BUTTONS(Right);
+ CASE_BUTTON_TO_BUTTONS(Middle);
+ CASE_BUTTON_TO_BUTTONS(X1);
+ CASE_BUTTON_TO_BUTTONS(X2);
+ CASE_BUTTON_TO_BUTTONS(Eraser);
}
+
+#undef CASE_BUTTON_TO_BUTTONS
+
NOTREACHED();
return 0;
}
@@ -89,7 +97,15 @@ void PointerEventFactory::setIdTypeButtons(PointerEventInit& pointerEventInit,
const IncomingId incomingId(pointerType, pointerProperties.id);
int pointerId = addIdAndActiveButtons(incomingId, buttons != 0);
+ // Tweak the |buttons| to reflect pen eraser mode only if the pen is in
+ // active buttons state w/o even considering the eraser button.
+ // TODO(mustaq): Fix when the spec starts supporting hovering erasers.
+ if (pointerType == WebPointerProperties::PointerType::Eraser && buttons != 0) {
+ buttons |= static_cast<unsigned>(WebPointerProperties::Buttons::Eraser);
+ buttons &= ~static_cast<unsigned>(WebPointerProperties::Buttons::Left);
+ }
pointerEventInit.setButtons(buttons);
+
pointerEventInit.setPointerId(pointerId);
pointerEventInit.setPointerType(pointerTypeNameForWebPointPointerType(pointerType));
pointerEventInit.setIsPrimary(isPrimary(pointerId));
@@ -142,7 +158,12 @@ PointerEvent* PointerEventFactory::create(
if (pointerEventName == EventTypeNames::pointerdown
|| pointerEventName == EventTypeNames::pointerup) {
- pointerEventInit.setButton(static_cast<int>(mouseEvent.pointerProperties().button));
+ WebPointerProperties::Button button = mouseEvent.pointerProperties().button;
+ // TODO(mustaq): Fix when the spec starts supporting hovering erasers.
+ if (mouseEvent.pointerProperties().pointerType == WebPointerProperties::PointerType::Eraser
+ && button == WebPointerProperties::Button::Left)
+ button = WebPointerProperties::Button::Eraser;
+ pointerEventInit.setButton(static_cast<int>(button));
} else {
DCHECK(pointerEventName == EventTypeNames::pointermove);
pointerEventInit.setButton(static_cast<int>(WebPointerProperties::Button::NoButton));
« no previous file with comments | « third_party/WebKit/Source/core/events/MouseEvent.cpp ('k') | third_party/WebKit/public/platform/WebPointerProperties.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698