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

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

Issue 2510763002: Fired PointerEvent from Node::dispatchMouseEvent() to fix a bug. (Closed)
Patch Set: Added a layout test. Created 4 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/dom/Node.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 #include "core/events/Event.h" 71 #include "core/events/Event.h"
72 #include "core/events/EventDispatchMediator.h" 72 #include "core/events/EventDispatchMediator.h"
73 #include "core/events/EventDispatcher.h" 73 #include "core/events/EventDispatcher.h"
74 #include "core/events/EventListener.h" 74 #include "core/events/EventListener.h"
75 #include "core/events/GestureEvent.h" 75 #include "core/events/GestureEvent.h"
76 #include "core/events/InputEvent.h" 76 #include "core/events/InputEvent.h"
77 #include "core/events/KeyboardEvent.h" 77 #include "core/events/KeyboardEvent.h"
78 #include "core/events/MouseEvent.h" 78 #include "core/events/MouseEvent.h"
79 #include "core/events/MutationEvent.h" 79 #include "core/events/MutationEvent.h"
80 #include "core/events/PointerEvent.h" 80 #include "core/events/PointerEvent.h"
81 #include "core/events/PointerEventFactory.h"
81 #include "core/events/TextEvent.h" 82 #include "core/events/TextEvent.h"
82 #include "core/events/TouchEvent.h" 83 #include "core/events/TouchEvent.h"
83 #include "core/events/UIEvent.h" 84 #include "core/events/UIEvent.h"
84 #include "core/events/WheelEvent.h" 85 #include "core/events/WheelEvent.h"
85 #include "core/frame/EventHandlerRegistry.h" 86 #include "core/frame/EventHandlerRegistry.h"
87 #include "core/frame/FrameView.h"
86 #include "core/frame/LocalDOMWindow.h" 88 #include "core/frame/LocalDOMWindow.h"
87 #include "core/frame/LocalFrame.h" 89 #include "core/frame/LocalFrame.h"
88 #include "core/html/HTMLDialogElement.h" 90 #include "core/html/HTMLDialogElement.h"
89 #include "core/html/HTMLFrameOwnerElement.h" 91 #include "core/html/HTMLFrameOwnerElement.h"
90 #include "core/html/HTMLSlotElement.h" 92 #include "core/html/HTMLSlotElement.h"
91 #include "core/input/EventHandler.h" 93 #include "core/input/EventHandler.h"
92 #include "core/layout/LayoutBox.h" 94 #include "core/layout/LayoutBox.h"
93 #include "core/page/ContextMenuController.h" 95 #include "core/page/ContextMenuController.h"
94 #include "core/page/Page.h" 96 #include "core/page/Page.h"
95 #include "core/svg/SVGElement.h" 97 #include "core/svg/SVGElement.h"
(...skipping 2006 matching lines...) Expand 10 before | Expand all | Expand 10 after
2102 document().domWindow(), detail); 2104 document().domWindow(), detail);
2103 event->setUnderlyingEvent(&underlyingEvent); 2105 event->setUnderlyingEvent(&underlyingEvent);
2104 event->setComposed(underlyingEvent.composed()); 2106 event->setComposed(underlyingEvent.composed());
2105 dispatchScopedEvent(event); 2107 dispatchScopedEvent(event);
2106 2108
2107 // TODO(dtapuska): Dispatching scoped events shouldn't check the return 2109 // TODO(dtapuska): Dispatching scoped events shouldn't check the return
2108 // type because the scoped event could get put off in the delayed queue. 2110 // type because the scoped event could get put off in the delayed queue.
2109 return EventTarget::dispatchEventResult(*event); 2111 return EventTarget::dispatchEventResult(*event);
2110 } 2112 }
2111 2113
2112 DispatchEventResult Node::dispatchMouseEvent( 2114 void Node::createAndDispatchPointerEvent(const AtomicString& mouseEventName,
2113 const PlatformMouseEvent& nativeEvent, 2115 const PlatformMouseEvent& mouseEvent,
2114 const AtomicString& eventType, 2116 LocalDOMWindow* view) {
2115 int detail, 2117 AtomicString pointerEventName;
2116 Node* relatedTarget) { 2118 if (mouseEventName == EventTypeNames::mousemove)
2117 MouseEvent* event = MouseEvent::create(eventType, document().domWindow(), 2119 pointerEventName = EventTypeNames::pointermove;
2118 nativeEvent, detail, relatedTarget); 2120 else if (mouseEventName == EventTypeNames::mousedown)
2119 return dispatchEvent(event); 2121 pointerEventName = EventTypeNames::pointerdown;
2122 else if (mouseEventName == EventTypeNames::mouseup)
2123 pointerEventName = EventTypeNames::pointerup;
2124 else
2125 return;
2126
2127 PointerEventInit pointerEventInit;
2128
2129 pointerEventInit.setPointerId(PointerEventFactory::s_mouseId);
2130 pointerEventInit.setPointerType("mouse");
2131 pointerEventInit.setIsPrimary(true);
2132 pointerEventInit.setButtons(
2133 MouseEvent::platformModifiersToButtons(mouseEvent.getModifiers()));
2134
2135 pointerEventInit.setBubbles(true);
2136 pointerEventInit.setCancelable(true);
2137 pointerEventInit.setComposed(true);
2138 pointerEventInit.setDetail(0);
2139
2140 pointerEventInit.setScreenX(mouseEvent.globalPosition().x());
2141 pointerEventInit.setScreenY(mouseEvent.globalPosition().y());
2142
2143 IntPoint locationInFrameZoomed;
2144 if (view && view->frame() && view->frame()->view()) {
2145 LocalFrame* frame = view->frame();
2146 FrameView* frameView = frame->view();
2147 IntPoint locationInContents =
2148 frameView->rootFrameToContents(mouseEvent.position());
2149 locationInFrameZoomed = frameView->contentsToFrame(locationInContents);
2150 float scaleFactor = 1 / frame->pageZoomFactor();
2151 locationInFrameZoomed.scale(scaleFactor, scaleFactor);
2152 }
2153
2154 // Set up initial values for coordinates.
2155 pointerEventInit.setClientX(locationInFrameZoomed.x());
2156 pointerEventInit.setClientY(locationInFrameZoomed.y());
2157
2158 if (pointerEventName == EventTypeNames::pointerdown ||
2159 pointerEventName == EventTypeNames::pointerup) {
2160 pointerEventInit.setButton(
2161 static_cast<int>(mouseEvent.pointerProperties().button));
2162 } else {
2163 pointerEventInit.setButton(
2164 static_cast<int>(WebPointerProperties::Button::NoButton));
2165 }
2166
2167 UIEventWithKeyState::setFromPlatformModifiers(pointerEventInit,
2168 mouseEvent.getModifiers());
2169 pointerEventInit.setView(view);
2170
2171 dispatchEvent(PointerEvent::create(pointerEventName, pointerEventInit));
2172 }
2173
2174 void Node::dispatchMouseEvent(const PlatformMouseEvent& nativeEvent,
2175 const AtomicString& mouseEventType,
2176 int detail,
2177 Node* relatedTarget) {
2178 createAndDispatchPointerEvent(mouseEventType, nativeEvent,
2179 document().domWindow());
2180 dispatchEvent(MouseEvent::create(mouseEventType, document().domWindow(),
2181 nativeEvent, detail, relatedTarget));
2120 } 2182 }
2121 2183
2122 void Node::dispatchSimulatedClick(Event* underlyingEvent, 2184 void Node::dispatchSimulatedClick(Event* underlyingEvent,
2123 SimulatedClickMouseEventOptions eventOptions, 2185 SimulatedClickMouseEventOptions eventOptions,
2124 SimulatedClickCreationScope scope) { 2186 SimulatedClickCreationScope scope) {
2125 EventDispatcher::dispatchSimulatedClick(*this, underlyingEvent, eventOptions, 2187 EventDispatcher::dispatchSimulatedClick(*this, underlyingEvent, eventOptions,
2126 scope); 2188 scope);
2127 } 2189 }
2128 2190
2129 void Node::dispatchInputEvent() { 2191 void Node::dispatchInputEvent() {
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
2489 if (node) { 2551 if (node) {
2490 std::stringstream stream; 2552 std::stringstream stream;
2491 node->printNodePathTo(stream); 2553 node->printNodePathTo(stream);
2492 LOG(INFO) << stream.str(); 2554 LOG(INFO) << stream.str();
2493 } else { 2555 } else {
2494 LOG(INFO) << "Cannot showNodePath for <null>"; 2556 LOG(INFO) << "Cannot showNodePath for <null>";
2495 } 2557 }
2496 } 2558 }
2497 2559
2498 #endif 2560 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Node.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698