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

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

Issue 2517603002: Fired PointerEvent from Node::dispatchMouseEvent() to fix a bug. (Closed)
Patch Set: 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 #include "core/events/Event.h" 70 #include "core/events/Event.h"
71 #include "core/events/EventDispatchMediator.h" 71 #include "core/events/EventDispatchMediator.h"
72 #include "core/events/EventDispatcher.h" 72 #include "core/events/EventDispatcher.h"
73 #include "core/events/EventListener.h" 73 #include "core/events/EventListener.h"
74 #include "core/events/GestureEvent.h" 74 #include "core/events/GestureEvent.h"
75 #include "core/events/InputEvent.h" 75 #include "core/events/InputEvent.h"
76 #include "core/events/KeyboardEvent.h" 76 #include "core/events/KeyboardEvent.h"
77 #include "core/events/MouseEvent.h" 77 #include "core/events/MouseEvent.h"
78 #include "core/events/MutationEvent.h" 78 #include "core/events/MutationEvent.h"
79 #include "core/events/PointerEvent.h" 79 #include "core/events/PointerEvent.h"
80 #include "core/events/PointerEventFactory.h"
80 #include "core/events/TextEvent.h" 81 #include "core/events/TextEvent.h"
81 #include "core/events/TouchEvent.h" 82 #include "core/events/TouchEvent.h"
82 #include "core/events/UIEvent.h" 83 #include "core/events/UIEvent.h"
83 #include "core/events/WheelEvent.h" 84 #include "core/events/WheelEvent.h"
84 #include "core/frame/EventHandlerRegistry.h" 85 #include "core/frame/EventHandlerRegistry.h"
86 #include "core/frame/FrameView.h"
85 #include "core/frame/LocalDOMWindow.h" 87 #include "core/frame/LocalDOMWindow.h"
86 #include "core/frame/LocalFrame.h" 88 #include "core/frame/LocalFrame.h"
87 #include "core/html/HTMLDialogElement.h" 89 #include "core/html/HTMLDialogElement.h"
88 #include "core/html/HTMLFrameOwnerElement.h" 90 #include "core/html/HTMLFrameOwnerElement.h"
89 #include "core/html/HTMLSlotElement.h" 91 #include "core/html/HTMLSlotElement.h"
90 #include "core/input/EventHandler.h" 92 #include "core/input/EventHandler.h"
91 #include "core/inspector/InstanceCounters.h" 93 #include "core/inspector/InstanceCounters.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"
(...skipping 1981 matching lines...) Expand 10 before | Expand all | Expand 10 after
2076 UIEvent* event = UIEvent::create(EventTypeNames::DOMActivate, true, true, 2078 UIEvent* event = UIEvent::create(EventTypeNames::DOMActivate, true, true,
2077 document().domWindow(), detail); 2079 document().domWindow(), detail);
2078 event->setUnderlyingEvent(underlyingEvent); 2080 event->setUnderlyingEvent(underlyingEvent);
2079 dispatchScopedEvent(event); 2081 dispatchScopedEvent(event);
2080 2082
2081 // TODO(dtapuska): Dispatching scoped events shouldn't check the return 2083 // TODO(dtapuska): Dispatching scoped events shouldn't check the return
2082 // type because the scoped event could get put off in the delayed queue. 2084 // type because the scoped event could get put off in the delayed queue.
2083 return EventTarget::dispatchEventResult(*event); 2085 return EventTarget::dispatchEventResult(*event);
2084 } 2086 }
2085 2087
2086 DispatchEventResult Node::dispatchMouseEvent( 2088 void Node::createAndDispatchPointerEvent(const AtomicString& mouseEventName,
2087 const PlatformMouseEvent& nativeEvent, 2089 const PlatformMouseEvent& mouseEvent,
2088 const AtomicString& eventType, 2090 LocalDOMWindow* view) {
2089 int detail, 2091 AtomicString pointerEventName;
2090 Node* relatedTarget) { 2092 if (mouseEventName == EventTypeNames::mousemove)
2091 MouseEvent* event = MouseEvent::create(eventType, document().domWindow(), 2093 pointerEventName = EventTypeNames::pointermove;
2092 nativeEvent, detail, relatedTarget); 2094 else if (mouseEventName == EventTypeNames::mousedown)
2093 return dispatchEvent(event); 2095 pointerEventName = EventTypeNames::pointerdown;
2096 else if (mouseEventName == EventTypeNames::mouseup)
2097 pointerEventName = EventTypeNames::pointerup;
2098 else
2099 return;
2100
2101 PointerEventInit pointerEventInit;
2102
2103 pointerEventInit.setPointerId(PointerEventFactory::s_mouseId);
2104 pointerEventInit.setPointerType("mouse");
2105 pointerEventInit.setIsPrimary(true);
2106 pointerEventInit.setButtons(
2107 MouseEvent::platformModifiersToButtons(mouseEvent.getModifiers()));
2108
2109 pointerEventInit.setBubbles(true);
2110 pointerEventInit.setCancelable(true);
2111 pointerEventInit.setComposed(true);
2112 pointerEventInit.setDetail(0);
2113
2114 pointerEventInit.setScreenX(mouseEvent.globalPosition().x());
2115 pointerEventInit.setScreenY(mouseEvent.globalPosition().y());
2116
2117 IntPoint locationInFrameZoomed;
2118 if (view && view->frame() && view->frame()->view()) {
2119 LocalFrame* frame = view->frame();
2120 FrameView* frameView = frame->view();
2121 IntPoint locationInContents =
2122 frameView->rootFrameToContents(mouseEvent.position());
2123 locationInFrameZoomed = frameView->contentsToFrame(locationInContents);
2124 float scaleFactor = 1 / frame->pageZoomFactor();
2125 locationInFrameZoomed.scale(scaleFactor, scaleFactor);
2126 }
2127
2128 // Set up initial values for coordinates.
2129 pointerEventInit.setClientX(locationInFrameZoomed.x());
2130 pointerEventInit.setClientY(locationInFrameZoomed.y());
2131
2132 if (pointerEventName == EventTypeNames::pointerdown ||
2133 pointerEventName == EventTypeNames::pointerup) {
2134 pointerEventInit.setButton(
2135 static_cast<int>(mouseEvent.pointerProperties().button));
2136 } else {
2137 pointerEventInit.setButton(
2138 static_cast<int>(WebPointerProperties::Button::NoButton));
2139 }
2140
2141 UIEventWithKeyState::setFromPlatformModifiers(pointerEventInit,
2142 mouseEvent.getModifiers());
2143 pointerEventInit.setView(view);
2144
2145 dispatchEvent(PointerEvent::create(pointerEventName, pointerEventInit));
2146 }
2147
2148 void Node::dispatchMouseEvent(const PlatformMouseEvent& nativeEvent,
2149 const AtomicString& mouseEventType,
2150 int detail,
2151 Node* relatedTarget) {
2152 createAndDispatchPointerEvent(mouseEventType, nativeEvent,
2153 document().domWindow());
2154 dispatchEvent(MouseEvent::create(mouseEventType, document().domWindow(),
2155 nativeEvent, detail, relatedTarget));
2094 } 2156 }
2095 2157
2096 void Node::dispatchSimulatedClick(Event* underlyingEvent, 2158 void Node::dispatchSimulatedClick(Event* underlyingEvent,
2097 SimulatedClickMouseEventOptions eventOptions, 2159 SimulatedClickMouseEventOptions eventOptions,
2098 SimulatedClickCreationScope scope) { 2160 SimulatedClickCreationScope scope) {
2099 EventDispatcher::dispatchSimulatedClick(*this, underlyingEvent, eventOptions, 2161 EventDispatcher::dispatchSimulatedClick(*this, underlyingEvent, eventOptions,
2100 scope); 2162 scope);
2101 } 2163 }
2102 2164
2103 void Node::dispatchInputEvent() { 2165 void Node::dispatchInputEvent() {
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
2462 if (node) { 2524 if (node) {
2463 std::stringstream stream; 2525 std::stringstream stream;
2464 node->printNodePathTo(stream); 2526 node->printNodePathTo(stream);
2465 LOG(INFO) << stream.str(); 2527 LOG(INFO) << stream.str();
2466 } else { 2528 } else {
2467 LOG(INFO) << "Cannot showNodePath for <null>"; 2529 LOG(INFO) << "Cannot showNodePath for <null>";
2468 } 2530 }
2469 } 2531 }
2470 2532
2471 #endif 2533 #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