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

Side by Side Diff: third_party/WebKit/Source/core/input/PointerEventManager.cpp

Issue 2229743003: add HitTestCanvasResult Class instend of std::pair<Element*, String> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "core/input/PointerEventManager.h" 5 #include "core/input/PointerEventManager.h"
6 6
7 #include "core/dom/ElementTraversal.h" 7 #include "core/dom/ElementTraversal.h"
8 #include "core/dom/shadow/FlatTreeTraversal.h" 8 #include "core/dom/shadow/FlatTreeTraversal.h"
9 #include "core/events/MouseEvent.h" 9 #include "core/events/MouseEvent.h"
10 #include "core/frame/FrameView.h" 10 #include "core/frame/FrameView.h"
11 #include "core/frame/UseCounter.h" 11 #include "core/frame/UseCounter.h"
12 #include "core/html/HTMLCanvasElement.h" 12 #include "core/html/HTMLCanvasElement.h"
13 #include "core/input/EventHandler.h" 13 #include "core/input/EventHandler.h"
14 #include "core/input/TouchActionUtil.h" 14 #include "core/input/TouchActionUtil.h"
15 #include "core/layout/HitTestCanvasResult.h"
15 #include "core/page/ChromeClient.h" 16 #include "core/page/ChromeClient.h"
16 #include "core/page/Page.h" 17 #include "core/page/Page.h"
17 #include "platform/PlatformTouchEvent.h" 18 #include "platform/PlatformTouchEvent.h"
18 19
19 namespace blink { 20 namespace blink {
20 21
21 namespace { 22 namespace {
22 23
23 size_t toPointerTypeIndex(WebPointerProperties::PointerType t) { return static_c ast<size_t>(t); } 24 size_t toPointerTypeIndex(WebPointerProperties::PointerType t) { return static_c ast<size_t>(t); }
24 25
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 // before firing the event. 430 // before firing the event.
430 if (touchInfo.point.state() == PlatformTouchPoint::TouchPressed 431 if (touchInfo.point.state() == PlatformTouchPoint::TouchPressed
431 || !m_pendingPointerCaptureTarget.contains(pointerId)) { 432 || !m_pendingPointerCaptureTarget.contains(pointerId)) {
432 HitTestRequest::HitTestRequestType hitType = HitTestRequest::TouchEv ent | HitTestRequest::ReadOnly | HitTestRequest::Active; 433 HitTestRequest::HitTestRequestType hitType = HitTestRequest::TouchEv ent | HitTestRequest::ReadOnly | HitTestRequest::Active;
433 LayoutPoint pagePoint = roundedLayoutPoint(m_frame->view()->rootFram eToContents(touchInfo.point.pos())); 434 LayoutPoint pagePoint = roundedLayoutPoint(m_frame->view()->rootFram eToContents(touchInfo.point.pos()));
434 HitTestResult hitTestTesult = m_frame->eventHandler().hitTestResultA tPoint(pagePoint, hitType); 435 HitTestResult hitTestTesult = m_frame->eventHandler().hitTestResultA tPoint(pagePoint, hitType);
435 Node* node = hitTestTesult.innerNode(); 436 Node* node = hitTestTesult.innerNode();
436 if (node) { 437 if (node) {
437 touchInfo.targetFrame = node->document().frame(); 438 touchInfo.targetFrame = node->document().frame();
438 if (isHTMLCanvasElement(node)) { 439 if (isHTMLCanvasElement(node)) {
439 std::pair<Element*, String> regionInfo = toHTMLCanvasElement (node)->getControlAndIdIfHitRegionExists(hitTestTesult.pointInInnerNodeFrame()); 440 HitTestCanvasResult* hitTestCanvasResult = toHTMLCanvasEleme nt(node)->getControlAndIdIfHitRegionExists(hitTestTesult.pointInInnerNodeFrame() );
440 if (regionInfo.first) 441 if (hitTestCanvasResult->getControl())
441 node = regionInfo.first; 442 node = hitTestCanvasResult->getControl();
442 touchInfo.region = regionInfo.second; 443 touchInfo.region = hitTestCanvasResult->getId();
443 } 444 }
444 // TODO(crbug.com/612456): We need to investigate whether pointe r 445 // TODO(crbug.com/612456): We need to investigate whether pointe r
445 // events should go to text nodes or not. If so we need to 446 // events should go to text nodes or not. If so we need to
446 // update the mouse code as well. Also this logic looks similar 447 // update the mouse code as well. Also this logic looks similar
447 // to the one in TouchEventManager. We should be able to 448 // to the one in TouchEventManager. We should be able to
448 // refactor it better after this investigation. 449 // refactor it better after this investigation.
449 if (node->isTextNode()) 450 if (node->isTextNode())
450 node = FlatTreeTraversal::parent(*node); 451 node = FlatTreeTraversal::parent(*node);
451 touchInfo.touchNode = node; 452 touchInfo.touchNode = node;
452 453
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 { 807 {
807 visitor->trace(m_frame); 808 visitor->trace(m_frame);
808 visitor->trace(m_nodeUnderPointer); 809 visitor->trace(m_nodeUnderPointer);
809 visitor->trace(m_pointerCaptureTarget); 810 visitor->trace(m_pointerCaptureTarget);
810 visitor->trace(m_pendingPointerCaptureTarget); 811 visitor->trace(m_pendingPointerCaptureTarget);
811 visitor->trace(m_touchEventManager); 812 visitor->trace(m_touchEventManager);
812 } 813 }
813 814
814 815
815 } // namespace blink 816 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698