Chromium Code Reviews| 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 1859b52c095392365e3b4397d0d3c5c0838dae46..1b5b130654af5c6076fcd4a0dc665b2a4e677452 100644 |
| --- a/third_party/WebKit/Source/core/events/PointerEventFactory.cpp |
| +++ b/third_party/WebKit/Source/core/events/PointerEventFactory.cpp |
| @@ -51,6 +51,23 @@ const AtomicString& pointerEventNameForMouseEventName( |
| return emptyAtom; |
| } |
| + |
| +unsigned short buttonToButtons(WebPointerProperties::Button button) |
|
bokan
2016/08/12 16:25:16
There's got to be a better name for this...:P
Per
Navid Zolghadr
2016/08/12 17:14:37
Sure :)
|
| +{ |
| + 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); |
| + } |
| + NOTREACHED(); |
| + return 0; |
| +} |
| + |
| } // namespace |
| const int PointerEventFactory::s_invalidId = 0; |
| @@ -91,8 +108,8 @@ void PointerEventFactory::setBubblesAndCancelable( |
| } |
| PointerEvent* PointerEventFactory::create( |
| - const AtomicString& mouseEventName, const PlatformMouseEvent& mouseEvent, |
| - EventTarget* relatedTarget, |
| + const AtomicString& mouseEventName, |
| + const PlatformMouseEvent& mouseEvent, |
| LocalDOMWindow* view) |
| { |
| DCHECK(mouseEventName == EventTypeNames::mousemove |
| @@ -125,9 +142,9 @@ PointerEvent* PointerEventFactory::create( |
| if (pointerEventName == EventTypeNames::pointerdown |
| || pointerEventName == EventTypeNames::pointerup) { |
| - pointerEventInit.setButton(mouseEvent.button()); |
| + pointerEventInit.setButton(static_cast<int>(mouseEvent.pointerProperties().button)); |
| } else { // Only when pointerEventName == EventTypeNames::pointermove |
|
bokan
2016/08/12 16:25:16
Perhaps turn this comment into a DCHECK?
Navid Zolghadr
2016/08/12 17:14:37
Done.
|
| - pointerEventInit.setButton(NoButton); |
| + pointerEventInit.setButton(static_cast<int>(WebPointerProperties::Button::NoButton)); |
| } |
| pointerEventInit.setPressure(getPointerEventPressure( |
| mouseEvent.pointerProperties().force, pointerEventInit.buttons())); |
| @@ -138,14 +155,12 @@ PointerEvent* PointerEventFactory::create( |
| // Make sure chorded buttons fire pointermove instead of pointerup/down. |
| if ((pointerEventName == EventTypeNames::pointerdown |
| - && (buttons & ~MouseEvent::buttonToButtons(mouseEvent.button())) != 0) |
| + && (buttons & ~buttonToButtons(mouseEvent.pointerProperties().button)) != 0) |
| || (pointerEventName == EventTypeNames::pointerup && buttons != 0)) |
| pointerEventName = EventTypeNames::pointermove; |
| pointerEventInit.setView(view); |
| - if (relatedTarget) |
| - pointerEventInit.setRelatedTarget(relatedTarget); |
|
bokan
2016/08/12 16:25:16
Why is this no longer needed? Please elaborate in
Navid Zolghadr
2016/08/12 17:14:37
The related target for all pointerevents (similar
|
| return PointerEvent::create(pointerEventName, pointerEventInit); |
| } |
| @@ -178,7 +193,7 @@ PointerEvent* PointerEventFactory::create(const AtomicString& type, |
| pointerEventInit.setScreenY(touchPoint.screenPos().y()); |
| pointerEventInit.setClientX(clientPoint.x()); |
| pointerEventInit.setClientY(clientPoint.y()); |
| - pointerEventInit.setButton(pointerPressedOrReleased ? LeftButton: NoButton); |
| + pointerEventInit.setButton(static_cast<int>(pointerPressedOrReleased ? WebPointerProperties::Button::Left : WebPointerProperties::Button::NoButton)); |
| pointerEventInit.setPressure(getPointerEventPressure( |
| touchPoint.force(), pointerEventInit.buttons())); |
| pointerEventInit.setTiltX(touchPoint.pointerProperties().tiltX); |