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

Side by Side Diff: sky/engine/core/frame/NewEventHandler.cpp

Issue 961483004: Fix multi-touch to work in SkyShell. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « sky/engine/core/dom/ParentNode.idl ('k') | sky/examples/touch-demo.sky » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "sky/engine/config.h" 5 #include "sky/engine/config.h"
6 #include "sky/engine/core/frame/NewEventHandler.h" 6 #include "sky/engine/core/frame/NewEventHandler.h"
7 7
8 #include "sky/engine/core/dom/Document.h" 8 #include "sky/engine/core/dom/Document.h"
9 #include "sky/engine/core/dom/NodeRenderingTraversal.h" 9 #include "sky/engine/core/dom/NodeRenderingTraversal.h"
10 #include "sky/engine/core/editing/Editor.h" 10 #include "sky/engine/core/editing/Editor.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 Node* clickTarget = NodeRenderingTraversal::commonAncestor(*releaseTarget, c apturingTarget); 114 Node* clickTarget = NodeRenderingTraversal::commonAncestor(*releaseTarget, c apturingTarget);
115 if (!clickTarget) 115 if (!clickTarget)
116 return true; 116 return true;
117 // TODO(abarth): Make a proper gesture event that includes information from the event. 117 // TODO(abarth): Make a proper gesture event that includes information from the event.
118 return clickTarget->dispatchEvent(Event::createCancelableBubble(EventTypeNam es::click)); 118 return clickTarget->dispatchEvent(Event::createCancelableBubble(EventTypeNam es::click));
119 } 119 }
120 120
121 void NewEventHandler::updateSelectionForPointerDown(const HitTestResult& hitTest Result, const WebPointerEvent& event) 121 void NewEventHandler::updateSelectionForPointerDown(const HitTestResult& hitTest Result, const WebPointerEvent& event)
122 { 122 {
123 Node* innerNode = hitTestResult.innerNode(); 123 Node* innerNode = hitTestResult.innerNode();
124 if (!innerNode->renderer()) 124 if (!innerNode || !innerNode->renderer())
125 return; 125 return;
126 if (Position::nodeIsUserSelectNone(innerNode)) 126 if (Position::nodeIsUserSelectNone(innerNode))
127 return; 127 return;
128 if (!innerNode->dispatchEvent(Event::createCancelableBubble(EventTypeNames:: selectstart))) 128 if (!innerNode->dispatchEvent(Event::createCancelableBubble(EventTypeNames:: selectstart)))
129 return; 129 return;
130 VisiblePosition position = visiblePositionForHitTestResult(hitTestResult); 130 VisiblePosition position = visiblePositionForHitTestResult(hitTestResult);
131 // TODO(abarth): Can we change this to setSelectionIfNeeded? 131 // TODO(abarth): Can we change this to setSelectionIfNeeded?
132 m_frame.selection().setNonDirectionalSelectionIfNeeded(VisibleSelection(posi tion), CharacterGranularity); 132 m_frame.selection().setNonDirectionalSelectionIfNeeded(VisibleSelection(posi tion), CharacterGranularity);
133 } 133 }
134 134
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 RefPtr<Node> target = targetForHitTestResult(hitTestResult); 184 RefPtr<Node> target = targetForHitTestResult(hitTestResult);
185 return target && !dispatchWheelEvent(*target, event); 185 return target && !dispatchWheelEvent(*target, event);
186 } 186 }
187 187
188 bool NewEventHandler::handlePointerDownEvent(const WebPointerEvent& event) 188 bool NewEventHandler::handlePointerDownEvent(const WebPointerEvent& event)
189 { 189 {
190 // In principle, we shouldn't get another pointer down for the same 190 // In principle, we shouldn't get another pointer down for the same
191 // pointer ID, but for mice, we don't get a pointer cancel when you 191 // pointer ID, but for mice, we don't get a pointer cancel when you
192 // drag outside the window frame on Linux. For now, send the pointer 192 // drag outside the window frame on Linux. For now, send the pointer
193 // cancel at this point. 193 // cancel at this point.
194 if (event.kind == WebPointerEvent::Mouse 194 bool alreadyDown = m_stateForPointer.find(event.pointer) != m_stateForPointe r.end();
195 && m_stateForPointer.find(event.pointer) != m_stateForPointer.end()) { 195 if (event.kind == WebPointerEvent::Mouse && alreadyDown) {
196 WebPointerEvent fakeCancel = event; 196 WebPointerEvent fakeCancel = event;
197 fakeCancel.type = WebInputEvent::PointerCancel; 197 fakeCancel.type = WebInputEvent::PointerCancel;
198 handlePointerCancelEvent(fakeCancel); 198 handlePointerCancelEvent(fakeCancel);
199 } 199 }
200 200
201 ASSERT(m_stateForPointer.find(event.pointer) == m_stateForPointer.end()); 201 DCHECK(!alreadyDown) << "Pointer id " << event.pointer << "already down!";
202 HitTestResult hitTestResult = performHitTest(positionForEvent(event)); 202 HitTestResult hitTestResult = performHitTest(positionForEvent(event));
203 RefPtr<Node> target = targetForHitTestResult(hitTestResult); 203 RefPtr<Node> target = targetForHitTestResult(hitTestResult);
204 if (!target) 204 if (!target)
205 return false; 205 return false;
206 PointerState& state = m_stateForPointer[event.pointer]; 206 PointerState& state = m_stateForPointer[event.pointer];
207 state.target = target; 207 state.target = target;
208 bool eventSwallowed = !dispatchPointerEvent(state, event); 208 bool eventSwallowed = !dispatchPointerEvent(state, event);
209 // TODO(abarth): Set the target for the pointer to something determined when 209 // TODO(abarth): Set the target for the pointer to something determined when
210 // dispatching the event. 210 // dispatching the event.
211 updateSelectionForPointerDown(hitTestResult, event); 211 updateSelectionForPointerDown(hitTestResult, event);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 auto it = m_stateForPointer.find(event.pointer); 244 auto it = m_stateForPointer.find(event.pointer);
245 if (it == m_stateForPointer.end()) 245 if (it == m_stateForPointer.end())
246 return false; 246 return false;
247 PointerState stateCopy = it->second; 247 PointerState stateCopy = it->second;
248 m_stateForPointer.erase(it); 248 m_stateForPointer.erase(it);
249 ASSERT(stateCopy.target); 249 ASSERT(stateCopy.target);
250 return dispatchPointerEvent(stateCopy, event); 250 return dispatchPointerEvent(stateCopy, event);
251 } 251 }
252 252
253 } 253 }
OLDNEW
« no previous file with comments | « sky/engine/core/dom/ParentNode.idl ('k') | sky/examples/touch-demo.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698