Title: [105453] trunk/Source/WebCore
Revision
105453
Author
[email protected]
Date
2012-01-19 15:07:12 -0800 (Thu, 19 Jan 2012)

Log Message

Improve touch handling performance by reusing the hitTest result
https://bugs.webkit.org/show_bug.cgi?id=75506

Patch by Min Qin <[email protected]> on 2012-01-19
Reviewed by Adam Barth.

This is a performance optimization and should not cause behavior changes. Existing tests should cover it.

* page/EventHandler.cpp:
(WebCore::EventHandler::handleTouchEvent):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (105452 => 105453)


--- trunk/Source/WebCore/ChangeLog	2012-01-19 23:01:24 UTC (rev 105452)
+++ trunk/Source/WebCore/ChangeLog	2012-01-19 23:07:12 UTC (rev 105453)
@@ -1,3 +1,15 @@
+2012-01-19  Min Qin  <[email protected]>
+
+        Improve touch handling performance by reusing the hitTest result
+        https://bugs.webkit.org/show_bug.cgi?id=75506
+
+        Reviewed by Adam Barth.
+
+        This is a performance optimization and should not cause behavior changes. Existing tests should cover it.
+
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::handleTouchEvent):
+
 2012-01-19  Jon Lee  <[email protected]>
 
         Add text-overflow support that allows placeholder and value text to show an ellipsis when not focused

Modified: trunk/Source/WebCore/page/EventHandler.cpp (105452 => 105453)


--- trunk/Source/WebCore/page/EventHandler.cpp	2012-01-19 23:01:24 UTC (rev 105452)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2012-01-19 23:07:12 UTC (rev 105453)
@@ -3252,34 +3252,24 @@
             break;
         }
 
-        HitTestResult result = hitTestResultAtPoint(pagePoint, /*allowShadowContent*/ false, false, DontHitTestScrollbars, hitType);
-        Node* node = result.innerNode();
-        ASSERT(node);
-
-        // Touch events should not go to text nodes
-        if (node->isTextNode())
-            node = node->parentNode();
-
-        Document* doc = node->document();
-        if (!doc)
-            continue;
-        if (!doc->hasListenerType(Document::TOUCH_LISTENER))
-            continue;
-
-        if (m_frame != doc->frame()) {
-            // pagePoint should always be relative to the target elements containing frame.
-            pagePoint = documentPointForWindowPoint(doc->frame(), point.pos());
-        }
-
-        float scaleFactor = m_frame->pageZoomFactor() * m_frame->frameScaleFactor();
-
-        int adjustedPageX = lroundf(pagePoint.x() / scaleFactor);
-        int adjustedPageY = lroundf(pagePoint.y() / scaleFactor);
-
         // Increment the platform touch id by 1 to avoid storing a key of 0 in the hashmap.
         unsigned touchPointTargetKey = point.id() + 1;
         RefPtr<EventTarget> touchTarget;
         if (pointState == PlatformTouchPoint::TouchPressed) {
+            HitTestResult result = hitTestResultAtPoint(pagePoint, /*allowShadowContent*/ false, false, DontHitTestScrollbars, hitType);
+            Node* node = result.innerNode();
+            ASSERT(node);
+
+            // Touch events should not go to text nodes
+            if (node->isTextNode())
+                node = node->parentNode();
+
+            Document* doc = node->document();
+            if (!doc)
+                continue;
+            if (!doc->hasListenerType(Document::TOUCH_LISTENER))
+                continue;
+
             m_originatingTouchPointTargets.set(touchPointTargetKey, node);
             touchTarget = node;
         } else if (pointState == PlatformTouchPoint::TouchReleased || pointState == PlatformTouchPoint::TouchCancelled) {
@@ -3292,7 +3282,18 @@
         if (!touchTarget.get())
             continue;
 
-        RefPtr<Touch> touch = Touch::create(doc->frame(), touchTarget.get(), point.id(),
+        Frame* targetFrame = touchTarget->toNode()->document()->frame();
+        if (m_frame != targetFrame) {
+            // pagePoint should always be relative to the target elements containing frame.
+            pagePoint = documentPointForWindowPoint(targetFrame, point.pos());
+        }
+
+        float scaleFactor = targetFrame->pageZoomFactor() * targetFrame->frameScaleFactor();
+
+        int adjustedPageX = lroundf(pagePoint.x() / scaleFactor);
+        int adjustedPageY = lroundf(pagePoint.y() / scaleFactor);
+
+        RefPtr<Touch> touch = Touch::create(targetFrame, touchTarget.get(), point.id(),
                                             point.screenPos().x(), point.screenPos().y(),
                                             adjustedPageX, adjustedPageY,
                                             point.radiusX(), point.radiusY(), point.rotationAngle(), point.force());
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to