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

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

Issue 2296303002: Make a pen in eraser mode visible thru PointerEvent.buttons (Closed)
Patch Set: Moved Buttons to WebPointerProperties, fixed button val, rebased. 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 21105e1b920a13158bbdb30fd933672e55f14899..0a1705b14b8ab864aeca4c3104b5acc05a0af0f9 100644
--- a/third_party/WebKit/Source/core/events/PointerEventFactory.cpp
+++ b/third_party/WebKit/Source/core/events/PointerEventFactory.cpp
@@ -22,8 +22,7 @@ const char* pointerTypeNameForWebPointPointerType(WebPointerProperties::PointerT
return "touch";
case WebPointerProperties::PointerType::Pen:
case WebPointerProperties::PointerType::Eraser:
- // TODO(mustaq): Continue eraser plumbing to web API.
- // See crbug.com/642455
+ // TODO(mustaq): Fix when the spec starts supporting hovering erasers.
return "pen";
case WebPointerProperties::PointerType::Mouse:
return "mouse";
@@ -57,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;
}
@@ -80,8 +85,9 @@ const int PointerEventFactory::s_mouseId = 1;
float getPointerEventPressure(float force, int buttons)
{
- if (std::isnan(force))
+ if (std::isnan(force)) {
return buttons ? 0.5 : 0;
+ }
Navid Zolghadr 2016/09/02 16:04:31 nit: This bracket is not needed here.
mustaq 2016/09/02 16:12:27 Done.
return force;
}
@@ -92,7 +98,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);
Navid Zolghadr 2016/09/02 16:04:31 If I understood from your previous comment, you sa
mustaq 2016/09/02 16:12:27 Yes, well, mostly: - Windows: definitely. - Linux:
+ }
pointerEventInit.setButtons(buttons);
+
pointerEventInit.setPointerId(pointerId);
pointerEventInit.setPointerType(pointerTypeNameForWebPointPointerType(pointerType));
pointerEventInit.setIsPrimary(isPrimary(pointerId));
@@ -145,7 +159,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