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

Side by Side Diff: third_party/WebKit/Source/core/dom/Node.cpp

Issue 2650403006: Remove PlatformMouseEvent and use WebMouseEvent instead (Closed)
Patch Set: Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
6 * rights reserved. 6 * rights reserved.
7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * 10 *
(...skipping 2101 matching lines...) Expand 10 before | Expand all | Expand 10 after
2112 event->setUnderlyingEvent(&underlyingEvent); 2112 event->setUnderlyingEvent(&underlyingEvent);
2113 event->setComposed(underlyingEvent.composed()); 2113 event->setComposed(underlyingEvent.composed());
2114 dispatchScopedEvent(event); 2114 dispatchScopedEvent(event);
2115 2115
2116 // TODO(dtapuska): Dispatching scoped events shouldn't check the return 2116 // TODO(dtapuska): Dispatching scoped events shouldn't check the return
2117 // type because the scoped event could get put off in the delayed queue. 2117 // type because the scoped event could get put off in the delayed queue.
2118 return EventTarget::dispatchEventResult(*event); 2118 return EventTarget::dispatchEventResult(*event);
2119 } 2119 }
2120 2120
2121 void Node::createAndDispatchPointerEvent(const AtomicString& mouseEventName, 2121 void Node::createAndDispatchPointerEvent(const AtomicString& mouseEventName,
2122 const PlatformMouseEvent& mouseEvent, 2122 const WebMouseEvent& mouseEvent,
2123 LocalDOMWindow* view) { 2123 LocalDOMWindow* view) {
2124 AtomicString pointerEventName; 2124 AtomicString pointerEventName;
2125 if (mouseEventName == EventTypeNames::mousemove) 2125 if (mouseEventName == EventTypeNames::mousemove)
2126 pointerEventName = EventTypeNames::pointermove; 2126 pointerEventName = EventTypeNames::pointermove;
2127 else if (mouseEventName == EventTypeNames::mousedown) 2127 else if (mouseEventName == EventTypeNames::mousedown)
2128 pointerEventName = EventTypeNames::pointerdown; 2128 pointerEventName = EventTypeNames::pointerdown;
2129 else if (mouseEventName == EventTypeNames::mouseup) 2129 else if (mouseEventName == EventTypeNames::mouseup)
2130 pointerEventName = EventTypeNames::pointerup; 2130 pointerEventName = EventTypeNames::pointerup;
2131 else 2131 else
2132 return; 2132 return;
2133 2133
2134 PointerEventInit pointerEventInit; 2134 PointerEventInit pointerEventInit;
2135 2135
2136 pointerEventInit.setPointerId(PointerEventFactory::s_mouseId); 2136 pointerEventInit.setPointerId(PointerEventFactory::s_mouseId);
2137 pointerEventInit.setPointerType("mouse"); 2137 pointerEventInit.setPointerType("mouse");
2138 pointerEventInit.setIsPrimary(true); 2138 pointerEventInit.setIsPrimary(true);
2139 pointerEventInit.setButtons( 2139 pointerEventInit.setButtons(
2140 MouseEvent::platformModifiersToButtons(mouseEvent.getModifiers())); 2140 MouseEvent::platformModifiersToButtons(mouseEvent.modifiers()));
2141 2141
2142 pointerEventInit.setBubbles(true); 2142 pointerEventInit.setBubbles(true);
2143 pointerEventInit.setCancelable(true); 2143 pointerEventInit.setCancelable(true);
2144 pointerEventInit.setComposed(true); 2144 pointerEventInit.setComposed(true);
2145 pointerEventInit.setDetail(0); 2145 pointerEventInit.setDetail(0);
2146 2146
2147 pointerEventInit.setScreenX(mouseEvent.globalPosition().x()); 2147 pointerEventInit.setScreenX(mouseEvent.globalX);
2148 pointerEventInit.setScreenY(mouseEvent.globalPosition().y()); 2148 pointerEventInit.setScreenY(mouseEvent.globalY);
2149 2149
2150 IntPoint locationInFrameZoomed; 2150 IntPoint locationInFrameZoomed;
2151 if (view && view->frame() && view->frame()->view()) { 2151 if (view && view->frame() && view->frame()->view()) {
2152 LocalFrame* frame = view->frame(); 2152 LocalFrame* frame = view->frame();
2153 FrameView* frameView = frame->view(); 2153 FrameView* frameView = frame->view();
2154 IntPoint locationInContents = 2154 IntPoint locationInContents = flooredIntPoint(
mustaq 2017/01/27 16:53:44 Let's floor the coord first before transforming, t
dtapuska 2017/01/27 20:59:59 Done.
2155 frameView->rootFrameToContents(mouseEvent.position()); 2155 frameView->rootFrameToContents(mouseEvent.positionInRootFrame()));
2156 locationInFrameZoomed = frameView->contentsToFrame(locationInContents); 2156 locationInFrameZoomed = frameView->contentsToFrame(locationInContents);
2157 float scaleFactor = 1 / frame->pageZoomFactor(); 2157 float scaleFactor = 1 / frame->pageZoomFactor();
2158 locationInFrameZoomed.scale(scaleFactor, scaleFactor); 2158 locationInFrameZoomed.scale(scaleFactor, scaleFactor);
2159 } 2159 }
2160 2160
2161 // Set up initial values for coordinates. 2161 // Set up initial values for coordinates.
2162 pointerEventInit.setClientX(locationInFrameZoomed.x()); 2162 pointerEventInit.setClientX(locationInFrameZoomed.x());
2163 pointerEventInit.setClientY(locationInFrameZoomed.y()); 2163 pointerEventInit.setClientY(locationInFrameZoomed.y());
2164 2164
2165 if (pointerEventName == EventTypeNames::pointerdown || 2165 if (pointerEventName == EventTypeNames::pointerdown ||
2166 pointerEventName == EventTypeNames::pointerup) { 2166 pointerEventName == EventTypeNames::pointerup) {
2167 pointerEventInit.setButton( 2167 pointerEventInit.setButton(static_cast<int>(mouseEvent.button));
2168 static_cast<int>(mouseEvent.pointerProperties().button));
2169 } else { 2168 } else {
2170 pointerEventInit.setButton( 2169 pointerEventInit.setButton(
2171 static_cast<int>(WebPointerProperties::Button::NoButton)); 2170 static_cast<int>(WebPointerProperties::Button::NoButton));
2172 } 2171 }
2173 2172
2174 UIEventWithKeyState::setFromPlatformModifiers(pointerEventInit, 2173 UIEventWithKeyState::setFromWebInputEventModifiers(
2175 mouseEvent.getModifiers()); 2174 pointerEventInit,
2175 static_cast<WebInputEvent::Modifiers>(mouseEvent.modifiers()));
2176 pointerEventInit.setView(view); 2176 pointerEventInit.setView(view);
2177 2177
2178 dispatchEvent(PointerEvent::create(pointerEventName, pointerEventInit)); 2178 dispatchEvent(PointerEvent::create(pointerEventName, pointerEventInit));
2179 } 2179 }
2180 2180
2181 void Node::dispatchMouseEvent(const PlatformMouseEvent& nativeEvent, 2181 void Node::dispatchMouseEvent(const WebMouseEvent& nativeEvent,
2182 const AtomicString& mouseEventType, 2182 const AtomicString& mouseEventType,
2183 int detail, 2183 int detail,
2184 const String& canvasRegionId,
2184 Node* relatedTarget) { 2185 Node* relatedTarget) {
2185 createAndDispatchPointerEvent(mouseEventType, nativeEvent, 2186 createAndDispatchPointerEvent(mouseEventType, nativeEvent,
2186 document().domWindow()); 2187 document().domWindow());
2187 dispatchEvent(MouseEvent::create(mouseEventType, document().domWindow(), 2188 dispatchEvent(MouseEvent::create(mouseEventType, document().domWindow(),
2188 nativeEvent, detail, relatedTarget)); 2189 nativeEvent, detail, canvasRegionId,
2190 relatedTarget));
2189 } 2191 }
2190 2192
2191 void Node::dispatchSimulatedClick(Event* underlyingEvent, 2193 void Node::dispatchSimulatedClick(Event* underlyingEvent,
2192 SimulatedClickMouseEventOptions eventOptions, 2194 SimulatedClickMouseEventOptions eventOptions,
2193 SimulatedClickCreationScope scope) { 2195 SimulatedClickCreationScope scope) {
2194 EventDispatcher::dispatchSimulatedClick(*this, underlyingEvent, eventOptions, 2196 EventDispatcher::dispatchSimulatedClick(*this, underlyingEvent, eventOptions,
2195 scope); 2197 scope);
2196 } 2198 }
2197 2199
2198 void Node::dispatchInputEvent() { 2200 void Node::dispatchInputEvent() {
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
2564 if (node) { 2566 if (node) {
2565 std::stringstream stream; 2567 std::stringstream stream;
2566 node->printNodePathTo(stream); 2568 node->printNodePathTo(stream);
2567 LOG(INFO) << stream.str(); 2569 LOG(INFO) << stream.str();
2568 } else { 2570 } else {
2569 LOG(INFO) << "Cannot showNodePath for <null>"; 2571 LOG(INFO) << "Cannot showNodePath for <null>";
2570 } 2572 }
2571 } 2573 }
2572 2574
2573 #endif 2575 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698