Remove unused TOUCH_ADJUSTMENT code.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 18 Jan 2014 00:34:08 +0000 (00:34 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 18 Jan 2014 00:34:08 +0000 (00:34 +0000)
<https://webkit.org/b/127181>

Source/WebCore:

There are no ports using the ENABLE(TOUCH_ADJUSTMENT) feature
anymore, so nuke it from orbit.

Reviewed by Anders Carlsson.

* page/EventHandler.cpp:
* page/EventHandler.h:
* page/Settings.in:
* page/TouchAdjustment.cpp: Removed.
* page/TouchAdjustment.h: Removed.
* testing/Internals.cpp:
* testing/Internals.h:
* testing/Internals.idl:

Source/WebKit2:

Reviewed by Anders Carlsson.

* WebProcess/WebPage/CoordinatedGraphics/WebPageCoordinatedGraphics.cpp:
(WebKit::WebPage::findZoomableAreaForPoint):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@162231 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/EventHandler.h
Source/WebCore/page/Settings.in
Source/WebCore/page/TouchAdjustment.cpp [deleted file]
Source/WebCore/page/TouchAdjustment.h [deleted file]
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/WebPageCoordinatedGraphics.cpp

index 73579c069ce968024bf58028258bff873f86ef49..cc2d115f741c77a05dcd393295a182310b5587eb 100644 (file)
@@ -1,3 +1,22 @@
+2014-01-17  Andreas Kling  <akling@apple.com>
+
+        Remove unused TOUCH_ADJUSTMENT code.
+        <https://webkit.org/b/127181>
+
+        There are no ports using the ENABLE(TOUCH_ADJUSTMENT) feature
+        anymore, so nuke it from orbit.
+
+        Reviewed by Anders Carlsson.
+
+        * page/EventHandler.cpp:
+        * page/EventHandler.h:
+        * page/Settings.in:
+        * page/TouchAdjustment.cpp: Removed.
+        * page/TouchAdjustment.h: Removed.
+        * testing/Internals.cpp:
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2014-01-17  Beth Dakin  <bdakin@apple.com>
 
         Need a way to test the tile cache with margins enabled
index 6d22a49ee38f3aa5feabdf5c6512a37d311ee880..d88d2bc783980bca26e9547d378975916057b21b 100644 (file)
 #include <wtf/StdLibExtras.h>
 #include <wtf/TemporaryChange.h>
 
-#if ENABLE(TOUCH_ADJUSTMENT)
-#include "TouchAdjustment.h"
-#endif
-
 #if ENABLE(SVG)
 #include "SVGDocument.h"
 #include "SVGElementInstance.h"
@@ -2625,43 +2621,6 @@ void EventHandler::defaultWheelEventHandler(Node* startNode, WheelEvent* wheelEv
         m_previousWheelScrolledElement = stopElement;
 }
 
-#if ENABLE(TOUCH_ADJUSTMENT)
-bool EventHandler::bestClickableNodeForTouchPoint(const IntPoint& touchCenter, const IntSize& touchRadius, IntPoint& targetPoint, Node*& targetNode)
-{
-    IntPoint hitTestPoint = m_frame.view()->windowToContents(touchCenter);
-    HitTestResult result = hitTestResultAtPoint(hitTestPoint, HitTestRequest::ReadOnly | HitTestRequest::Active, touchRadius);
-
-    IntRect touchRect(touchCenter - touchRadius, touchRadius + touchRadius);
-
-    // FIXME: Should be able to handle targetNode being a shadow DOM node to avoid performing uncessary hit tests
-    // in the case where further processing on the node is required. Returning the shadow ancestor prevents a
-    // regression in touchadjustment/html-label.html. Some refinement is required to testing/internals to
-    // handle targetNode being a shadow DOM node. 
-    bool success = findBestClickableCandidate(targetNode, targetPoint, touchCenter, touchRect, result.rectBasedTestResult());
-    if (success && targetNode)
-        targetNode = targetNode->deprecatedShadowAncestorNode();
-    return success;
-}
-
-bool EventHandler::bestContextMenuNodeForTouchPoint(const IntPoint& touchCenter, const IntSize& touchRadius, IntPoint& targetPoint, Node*& targetNode)
-{
-    IntPoint hitTestPoint = m_frame.view()->windowToContents(touchCenter);
-    HitTestResult result = hitTestResultAtPoint(hitTestPoint, HitTestRequest::ReadOnly | HitTestRequest::Active, touchRadius);
-
-    IntRect touchRect(touchCenter - touchRadius, touchRadius + touchRadius);
-    return findBestContextMenuCandidate(targetNode, targetPoint, touchCenter, touchRect, result.rectBasedTestResult());
-}
-
-bool EventHandler::bestZoomableAreaForTouchPoint(const IntPoint& touchCenter, const IntSize& touchRadius, IntRect& targetArea, Node*& targetNode)
-{
-    IntPoint hitTestPoint = m_frame.view()->windowToContents(touchCenter);
-    HitTestResult result = hitTestResultAtPoint(hitTestPoint, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowShadowContent, touchRadius);
-
-    IntRect touchRect(touchCenter - touchRadius, touchRadius + touchRadius);
-    return findBestZoomableArea(targetNode, targetArea, touchCenter, touchRect, result.rectBasedTestResult());
-}
-#endif
-
 #if ENABLE(CONTEXT_MENUS)
 bool EventHandler::sendContextMenuEvent(const PlatformMouseEvent& event)
 {
index 1e91446e6089fd330d5e7d9300ebbf6a69e92705..f5a4fca03eeb95dd5f92ea7973fd0337c47f00c0 100644 (file)
@@ -215,12 +215,6 @@ public:
     void defaultTouchEventHandler(Node*, TouchEvent*);
 #endif
 
-#if ENABLE(TOUCH_ADJUSTMENT)
-    bool bestClickableNodeForTouchPoint(const IntPoint& touchCenter, const IntSize& touchRadius, IntPoint& targetPoint, Node*& targetNode);
-    bool bestContextMenuNodeForTouchPoint(const IntPoint& touchCenter, const IntSize& touchRadius, IntPoint& targetPoint, Node*& targetNode);
-    bool bestZoomableAreaForTouchPoint(const IntPoint& touchCenter, const IntSize& touchRadius, IntRect& targetArea, Node*& targetNode);
-#endif
-
 #if ENABLE(CONTEXT_MENUS)
     bool sendContextMenuEvent(const PlatformMouseEvent&);
     bool sendContextMenuEventForKey();
index 6766d76dc100077a8b3f09fedaf74e5ad6b9a44f..bde0b3a0ebc3d4948b74ab9d155031c72f0df55b 100644 (file)
@@ -151,11 +151,6 @@ requestAnimationFrameEnabled initial=true
 deviceSupportsTouch initial=false
 deviceSupportsMouse initial=true
 
-# For touch adjustment to apply, the compile option TOUCH_ADJUSTMENT must also be enabled.
-# This setting adds a means to dynamically disable the feature at runtime on systems with
-# support for touch adjustment.
-touchAdjustmentEnabled initial=true
-
 fixedPositionCreatesStackingContext initial=defaultFixedPositionCreatesStackingContext
 syncXHRInDocumentsEnabled initial=true
 cookieEnabled initial=true
diff --git a/Source/WebCore/page/TouchAdjustment.cpp b/Source/WebCore/page/TouchAdjustment.cpp
deleted file mode 100644 (file)
index b588cbd..0000000
+++ /dev/null
@@ -1,503 +0,0 @@
-/*
- * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-
-#include "TouchAdjustment.h"
-
-#include "ContainerNode.h"
-#include "Editor.h"
-#include "FloatPoint.h"
-#include "FloatQuad.h"
-#include "Frame.h"
-#include "FrameView.h"
-#include "HTMLFrameOwnerElement.h"
-#include "HTMLInputElement.h"
-#include "HTMLLabelElement.h"
-#include "HTMLNames.h"
-#include "IntPoint.h"
-#include "IntSize.h"
-#include "Node.h"
-#include "NodeRenderStyle.h"
-#include "RenderBox.h"
-#include "RenderObject.h"
-#include "RenderStyle.h"
-#include "RenderText.h"
-#include "RenderView.h"
-#include "ShadowRoot.h"
-#include "Text.h"
-#include "TextBreakIterator.h"
-
-namespace WebCore {
-
-namespace TouchAdjustment {
-
-const float zeroTolerance = 1e-6f;
-
-// Class for remembering absolute quads of a target node and what node they represent.
-class SubtargetGeometry {
-public:
-    SubtargetGeometry(Node* node, const FloatQuad& quad)
-        : m_node(node)
-        , m_quad(quad)
-    { }
-
-    Node* node() const { return m_node; }
-    FloatQuad quad() const { return m_quad; }
-    IntRect boundingBox() const { return m_quad.enclosingBoundingBox(); }
-
-private:
-    Node* m_node;
-    FloatQuad m_quad;
-};
-
-typedef Vector<SubtargetGeometry> SubtargetGeometryList;
-typedef bool (*NodeFilter)(Node*);
-typedef void (*AppendSubtargetsForNode)(Node*, SubtargetGeometryList&);
-typedef float (*DistanceFunction)(const IntPoint&, const IntRect&, const SubtargetGeometry&);
-
-// Takes non-const Node* because isContentEditable is a non-const function.
-bool nodeRespondsToTapGesture(Node* node)
-{
-    if (node->willRespondToMouseClickEvents() || node->willRespondToMouseMoveEvents())
-        return true;
-    // Accept nodes that has a CSS effect when touched.
-    if (node->isElementNode()) {
-        Element* element = toElement(node);
-        if (element->isMouseFocusable())
-            return true;
-        if (element->childrenAffectedByActive() || element->childrenAffectedByHover())
-            return true;
-    }
-    if (RenderStyle* renderStyle = node->renderStyle()) {
-        if (renderStyle->affectedByActive() || renderStyle->affectedByHover())
-            return true;
-    }
-    return false;
-}
-
-bool nodeIsZoomTarget(Node* node)
-{
-    if (node->isTextNode() || node->isShadowRoot())
-        return false;
-
-    ASSERT(node->renderer());
-    return node->renderer()->isBox();
-}
-
-bool providesContextMenuItems(Node* node)
-{
-    // This function tries to match the nodes that receive special context-menu items in
-    // ContextMenuController::populate(), and should be kept uptodate with those.
-    ASSERT(node->renderer() || node->isShadowRoot());
-    if (!node->renderer())
-        return false;
-    if (node->isContentEditable())
-        return true;
-    if (node->isLink())
-        return true;
-    if (node->renderer()->isImage())
-        return true;
-    if (node->renderer()->isMedia())
-        return true;
-    if (node->renderer()->canBeSelectionLeaf()) {
-        // If the context menu gesture will trigger a selection all selectable nodes are valid targets.
-        if (node->renderer()->frame().editor().behavior().shouldSelectOnContextualMenuClick())
-            return true;
-        // Only the selected part of the renderer is a valid target, but this will be corrected in
-        // appendContextSubtargetsForNode.
-        if (node->renderer()->selectionState() != RenderObject::SelectionNone)
-            return true;
-    }
-    return false;
-}
-
-static inline void appendQuadsToSubtargetList(Vector<FloatQuad>& quads, Node* node, SubtargetGeometryList& subtargets)
-{
-    Vector<FloatQuad>::const_iterator it = quads.begin();
-    const Vector<FloatQuad>::const_iterator end = quads.end();
-    for (; it != end; ++it)
-        subtargets.append(SubtargetGeometry(node, *it));
-}
-
-static inline void appendBasicSubtargetsForNode(Node* node, SubtargetGeometryList& subtargets)
-{
-    // Node guaranteed to have renderer due to check in node filter.
-    ASSERT(node->renderer());
-
-    Vector<FloatQuad> quads;
-    node->renderer()->absoluteQuads(quads);
-
-    appendQuadsToSubtargetList(quads, node, subtargets);
-}
-
-static inline void appendContextSubtargetsForNode(Node* node, SubtargetGeometryList& subtargets)
-{
-    // This is a variant of appendBasicSubtargetsForNode that adds special subtargets for
-    // selected or auto-selectable parts of text nodes.
-    ASSERT(node->renderer());
-
-    if (!node->isTextNode())
-        return appendBasicSubtargetsForNode(node, subtargets);
-
-    Text* textNode = static_cast<WebCore::Text*>(node);
-    RenderText* textRenderer = textNode->renderer();
-
-    if (textRenderer->frame().editor().behavior().shouldSelectOnContextualMenuClick()) {
-        // Make subtargets out of every word.
-        String textValue = textNode->data();
-        TextBreakIterator* wordIterator = wordBreakIterator(textValue.characters(), textValue.length());
-        int lastOffset = textBreakFirst(wordIterator);
-        if (lastOffset == -1)
-            return;
-        int offset;
-        while ((offset = textBreakNext(wordIterator)) != -1) {
-            if (isWordTextBreak(wordIterator)) {
-                Vector<FloatQuad> quads = textRenderer->absoluteQuadsForRange(lastOffset, offset);
-                appendQuadsToSubtargetList(quads, textNode, subtargets);
-            }
-            lastOffset = offset;
-        }
-    } else {
-        if (textRenderer->selectionState() == RenderObject::SelectionNone)
-            return appendBasicSubtargetsForNode(node, subtargets);
-        // If selected, make subtargets out of only the selected part of the text.
-        int startPos, endPos;
-        switch (textRenderer->selectionState()) {
-        case RenderObject::SelectionInside:
-            startPos = 0;
-            endPos = textRenderer->textLength();
-            break;
-        case RenderObject::SelectionStart:
-            textRenderer->selectionStartEnd(startPos, endPos);
-            endPos = textRenderer->textLength();
-            break;
-        case RenderObject::SelectionEnd:
-            textRenderer->selectionStartEnd(startPos, endPos);
-            startPos = 0;
-            break;
-        case RenderObject::SelectionBoth:
-            textRenderer->selectionStartEnd(startPos, endPos);
-            break;
-        default:
-            ASSERT_NOT_REACHED();
-            return;
-        }
-        Vector<FloatQuad> quads = textRenderer->absoluteQuadsForRange(startPos, endPos);
-        appendQuadsToSubtargetList(quads, textNode, subtargets);
-    }
-}
-
-static inline void appendZoomableSubtargets(Node* node, SubtargetGeometryList& subtargets)
-{
-    RenderBox* renderer = toRenderBox(node->renderer());
-    ASSERT(renderer);
-
-    Vector<FloatQuad> quads;
-    FloatRect borderBoxRect = renderer->borderBoxRect();
-    FloatRect contentBoxRect = renderer->contentBoxRect();
-    quads.append(renderer->localToAbsoluteQuad(borderBoxRect));
-    if (borderBoxRect != contentBoxRect)
-        quads.append(renderer->localToAbsoluteQuad(contentBoxRect));
-    // FIXME: For RenderBlocks, add column boxes and content boxes cleared for floats.
-
-    Vector<FloatQuad>::const_iterator it = quads.begin();
-    const Vector<FloatQuad>::const_iterator end = quads.end();
-    for (; it != end; ++it)
-        subtargets.append(SubtargetGeometry(node, *it));
-}
-
-static inline Node* parentShadowHostOrOwner(const Node* node)
-{
-    if (Node* ancestor = node->parentOrShadowHostNode())
-        return ancestor;
-    if (node->isDocumentNode())
-        return toDocument(node)->ownerElement();
-    return 0;
-}
-
-// Compiles a list of subtargets of all the relevant target nodes.
-void compileSubtargetList(const NodeListHashSet& intersectedNodes, SubtargetGeometryList& subtargets, NodeFilter nodeFilter, AppendSubtargetsForNode appendSubtargetsForNode)
-{
-    // Find candidates responding to tap gesture events in O(n) time.
-    HashMap<Node*, Node*> responderMap;
-    HashSet<Node*> ancestorsToRespondersSet;
-    Vector<Node*> candidates;
-    HashSet<Node*> editableAncestors;
-
-    // A node matching the NodeFilter is called a responder. Candidate nodes must either be a
-    // responder or have an ancestor that is a responder.
-    // This iteration tests all ancestors at most once by caching earlier results.
-    NodeListHashSet::const_iterator end = intersectedNodes.end();
-    for (NodeListHashSet::const_iterator it = intersectedNodes.begin(); it != end; ++it) {
-        Node* const node = it->get();
-        Vector<Node*> visitedNodes;
-        Node* respondingNode = 0;
-        for (Node* visitedNode = node; visitedNode; visitedNode = visitedNode->parentOrShadowHostNode()) {
-            // Check if we already have a result for a common ancestor from another candidate.
-            respondingNode = responderMap.get(visitedNode);
-            if (respondingNode)
-                break;
-            visitedNodes.append(visitedNode);
-            // Check if the node filter applies, which would mean we have found a responding node.
-            if (nodeFilter(visitedNode)) {
-                respondingNode = visitedNode;
-                // Continue the iteration to collect the ancestors of the responder, which we will need later.
-                for (visitedNode = parentShadowHostOrOwner(visitedNode); visitedNode; visitedNode = parentShadowHostOrOwner(visitedNode)) {
-                    HashSet<Node*>::AddResult addResult = ancestorsToRespondersSet.add(visitedNode);
-                    if (!addResult.isNewEntry)
-                        break;
-                }
-                break;
-            }
-        }
-        // Insert the detected responder for all the visited nodes.
-        for (unsigned j = 0; j < visitedNodes.size(); j++)
-            responderMap.add(visitedNodes[j], respondingNode);
-
-        if (respondingNode)
-            candidates.append(node);
-    }
-
-    // We compile the list of component absolute quads instead of using the bounding rect
-    // to be able to perform better hit-testing on inline links on line-breaks.
-    unsigned length = candidates.size();
-    for (unsigned i = 0; i < length; i++) {
-        Node* candidate = candidates[i];
-        // Skip nodes who's responders are ancestors of other responders. This gives preference to
-        // the inner-most event-handlers. So that a link is always preferred even when contained
-        // in an element that monitors all click-events.
-        Node* respondingNode = responderMap.get(candidate);
-        ASSERT(respondingNode);
-        if (ancestorsToRespondersSet.contains(respondingNode))
-            continue;
-        // Consolidate bounds for editable content.
-        if (editableAncestors.contains(candidate))
-            continue;
-        if (candidate->isContentEditable()) {
-            Node* replacement = candidate;
-            Node* parent = candidate->parentOrShadowHostNode();
-            while (parent && parent->isContentEditable()) {
-                replacement = parent;
-                if (editableAncestors.contains(replacement)) {
-                    replacement = 0;
-                    break;
-                }
-                editableAncestors.add(replacement);
-                parent = parent->parentOrShadowHostNode();
-            }
-            candidate = replacement;
-        }
-        if (candidate)
-            appendSubtargetsForNode(candidate, subtargets);
-    }
-}
-
-// Compiles a list of zoomable subtargets.
-void compileZoomableSubtargets(const NodeListHashSet& intersectedNodes, SubtargetGeometryList& subtargets)
-{
-    NodeListHashSet::const_iterator end = intersectedNodes.end();
-    for (NodeListHashSet::const_iterator it = intersectedNodes.begin(); it != end; ++it) {
-        Node* const candidate = it->get();
-        if (nodeIsZoomTarget(candidate))
-            appendZoomableSubtargets(candidate, subtargets);
-    }
-}
-
-// This returns quotient of the target area and its intersection with the touch area.
-// This will prioritize largest intersection and smallest area, while balancing the two against each other.
-float zoomableIntersectionQuotient(const IntPoint& touchHotspot, const IntRect& touchArea, const SubtargetGeometry& subtarget)
-{
-    IntRect rect = subtarget.boundingBox();
-
-    // Convert from frame coordinates to window coordinates.
-    rect = subtarget.node()->document().view()->contentsToWindow(rect);
-
-    // Check the rectangle is meaningful zoom target. It should at least contain the hotspot.
-    if (!rect.contains(touchHotspot))
-        return std::numeric_limits<float>::infinity();
-    IntRect intersection = rect;
-    intersection.intersect(touchArea);
-
-    // Return the quotient of the intersection.
-    return rect.size().area() / (float)intersection.size().area();
-}
-
-// Uses a hybrid of distance to adjust and intersect ratio, normalizing each score between 0 and 1
-// and combining them. The distance to adjust works best for disambiguating clicks on targets such
-// as links, where the width may be significantly larger than the touch width. Using area of overlap
-// in such cases can lead to a bias towards shorter links. Conversely, percentage of overlap can
-// provide strong confidence in tapping on a small target, where the overlap is often quite high,
-// and works well for tightly packed controls.
-float hybridDistanceFunction(const IntPoint& touchHotspot, const IntRect& touchRect, const SubtargetGeometry& subtarget)
-{
-    IntRect rect = subtarget.boundingBox();
-
-    // Convert from frame coordinates to window coordinates.
-    rect = subtarget.node()->document().view()->contentsToWindow(rect);
-   
-    float radiusSquared = 0.25f * (touchRect.size().diagonalLengthSquared());
-    float distanceToAdjustScore = rect.distanceSquaredToPoint(touchHotspot) / radiusSquared;
-
-    int maxOverlapWidth = std::min(touchRect.width(), rect.width());
-    int maxOverlapHeight = std::min(touchRect.height(), rect.height());
-    float maxOverlapArea = std::max(maxOverlapWidth * maxOverlapHeight, 1);
-    rect.intersect(touchRect);
-    float intersectArea = rect.size().area();
-    float intersectionScore = 1 - intersectArea / maxOverlapArea;
-
-    float hybridScore = intersectionScore + distanceToAdjustScore;
-
-    return hybridScore;
-}
-
-FloatPoint contentsToWindow(FrameView *view, FloatPoint pt)
-{
-    int x = static_cast<int>(pt.x() + 0.5f);
-    int y = static_cast<int>(pt.y() + 0.5f);
-    IntPoint adjusted = view->contentsToWindow(IntPoint(x, y));
-    return FloatPoint(adjusted.x(), adjusted.y());
-}
-
-// Adjusts 'point' to the nearest point inside rect, and leaves it unchanged if already inside.
-void adjustPointToRect(FloatPoint& point, const FloatRect& rect)
-{
-    if (point.x() < rect.x())
-        point.setX(rect.x());
-    else if (point.x() > rect.maxX())
-        point.setX(rect.maxX());
-
-    if (point.y() < rect.y())
-        point.setY(rect.y());
-    else if (point.y() > rect.maxY())
-        point.setY(rect.maxY());
-}
-
-bool snapTo(const SubtargetGeometry& geom, const IntPoint& touchPoint, const IntRect& touchArea, IntPoint& adjustedPoint)
-{
-    FrameView* view = geom.node()->document().view();
-    FloatQuad quad = geom.quad();
-
-    if (quad.isRectilinear()) {
-        IntRect contentBounds = geom.boundingBox();
-        // Convert from frame coordinates to window coordinates.
-        IntRect bounds = view->contentsToWindow(contentBounds);
-        if (bounds.contains(touchPoint)) {
-            adjustedPoint = touchPoint;
-            return true;
-        }
-        if (bounds.intersects(touchArea)) {
-            bounds.intersect(touchArea);
-            adjustedPoint = bounds.center();
-            return true;
-        }
-        return false;
-    }
-
-    // The following code tries to adjust the point to place inside a both the touchArea and the non-rectilinear quad.
-    // FIXME: This will return the point inside the touch area that is the closest to the quad center, but does not
-    // guarantee that the point will be inside the quad. Corner-cases exist where the quad will intersect but this
-    // will fail to adjust the point to somewhere in the intersection.
-
-    // Convert quad from content to window coordinates.
-    FloatPoint p1 = contentsToWindow(view, quad.p1());
-    FloatPoint p2 = contentsToWindow(view, quad.p2());
-    FloatPoint p3 = contentsToWindow(view, quad.p3());
-    FloatPoint p4 = contentsToWindow(view, quad.p4());
-    quad = FloatQuad(p1, p2, p3, p4);
-
-    if (quad.containsPoint(touchPoint)) {
-        adjustedPoint = touchPoint;
-        return true;
-    }
-
-    // Pull point towards the center of the element.
-    FloatPoint center = quad.center();
-
-    adjustPointToRect(center, touchArea);
-    adjustedPoint = roundedIntPoint(center);
-
-    return quad.containsPoint(adjustedPoint);
-}
-
-// A generic function for finding the target node with the lowest distance metric. A distance metric here is the result
-// of a distance-like function, that computes how well the touch hits the node.
-// Distance functions could for instance be distance squared or area of intersection.
-bool findNodeWithLowestDistanceMetric(Node*& targetNode, IntPoint& targetPoint, IntRect& targetArea, const IntPoint& touchHotspot, const IntRect& touchArea, SubtargetGeometryList& subtargets, DistanceFunction distanceFunction)
-{
-    targetNode = 0;
-    float bestDistanceMetric = std::numeric_limits<float>::infinity();
-    SubtargetGeometryList::const_iterator it = subtargets.begin();
-    const SubtargetGeometryList::const_iterator end = subtargets.end();
-    IntPoint adjustedPoint;
-
-    for (; it != end; ++it) {
-        Node* node = it->node();
-        float distanceMetric = distanceFunction(touchHotspot, touchArea, *it);
-        if (distanceMetric < bestDistanceMetric) {
-            if (snapTo(*it, touchHotspot, touchArea, adjustedPoint)) {
-                targetPoint = adjustedPoint;
-                targetArea = it->boundingBox();
-                targetNode = node;
-                bestDistanceMetric = distanceMetric;
-            }
-        } else if (distanceMetric - bestDistanceMetric < zeroTolerance) {
-            if (snapTo(*it, touchHotspot, touchArea, adjustedPoint)) {
-                if (node->isDescendantOf(targetNode)) {
-                    // Try to always return the inner-most element.
-                    targetPoint = adjustedPoint;
-                    targetNode = node;
-                    targetArea = it->boundingBox();
-                }
-            }
-        }
-    }
-    if (targetNode) {
-        targetArea = targetNode->document().view()->contentsToWindow(targetArea);
-    }
-    return (targetNode);
-}
-
-} // namespace TouchAdjustment
-
-bool findBestClickableCandidate(Node*& targetNode, IntPoint &targetPoint, const IntPoint &touchHotspot, const IntRect &touchArea, const NodeListHashSet& nodeList)
-{
-    IntRect targetArea;
-    TouchAdjustment::SubtargetGeometryList subtargets;
-    TouchAdjustment::compileSubtargetList(nodeList, subtargets, TouchAdjustment::nodeRespondsToTapGesture, TouchAdjustment::appendBasicSubtargetsForNode);
-    return TouchAdjustment::findNodeWithLowestDistanceMetric(targetNode, targetPoint, targetArea, touchHotspot, touchArea, subtargets, TouchAdjustment::hybridDistanceFunction);
-}
-
-bool findBestContextMenuCandidate(Node*& targetNode, IntPoint &targetPoint, const IntPoint &touchHotspot, const IntRect &touchArea, const NodeListHashSet& nodeList)
-{
-    IntRect targetArea;
-    TouchAdjustment::SubtargetGeometryList subtargets;
-    TouchAdjustment::compileSubtargetList(nodeList, subtargets, TouchAdjustment::providesContextMenuItems, TouchAdjustment::appendContextSubtargetsForNode);
-    return TouchAdjustment::findNodeWithLowestDistanceMetric(targetNode, targetPoint, targetArea, touchHotspot, touchArea, subtargets, TouchAdjustment::hybridDistanceFunction);
-}
-
-bool findBestZoomableArea(Node*& targetNode, IntRect& targetArea, const IntPoint& touchHotspot, const IntRect& touchArea, const NodeListHashSet& nodeList)
-{
-    IntPoint targetPoint;
-    TouchAdjustment::SubtargetGeometryList subtargets;
-    TouchAdjustment::compileZoomableSubtargets(nodeList, subtargets);
-    return TouchAdjustment::findNodeWithLowestDistanceMetric(targetNode, targetPoint, targetArea, touchHotspot, touchArea, subtargets, TouchAdjustment::zoomableIntersectionQuotient);
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/page/TouchAdjustment.h b/Source/WebCore/page/TouchAdjustment.h
deleted file mode 100644 (file)
index 06ac008..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef TouchAdjustment_h
-#define TouchAdjustment_h
-
-#include "IntPoint.h"
-#include "IntRect.h"
-#include "Node.h"
-#include "NodeList.h"
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-typedef ListHashSet<RefPtr<Node> > NodeListHashSet;
-
-bool findBestClickableCandidate(Node*& targetNode, IntPoint& targetPoint, const IntPoint& touchHotspot, const IntRect& touchArea, const NodeListHashSet&);
-bool findBestContextMenuCandidate(Node*& targetNode, IntPoint& targetPoint, const IntPoint& touchHotspot, const IntRect& touchArea, const NodeListHashSet&);
-bool findBestZoomableArea(Node*& targetNode, IntRect& targetArea, const IntPoint& touchHotspot, const IntRect& touchArea, const NodeListHashSet&);
-// FIXME: Implement the similar functions for other gestures here as well.
-
-} // namespace WebCore
-
-#endif
index 93c9bf23cf9588c3d3da83853eaddcb402272665..f63884191efbba85150e5b6c639454af44fd5959 100644 (file)
 #include "DeviceProximityController.h"
 #endif
 
-#if ENABLE(TOUCH_ADJUSTMENT)
-#include "WebKitPoint.h"
-#endif
-
 #if ENABLE(MOUSE_CURSOR_SCALE)
 #include <wtf/dtoa.h>
 #endif
@@ -1034,105 +1030,6 @@ void Internals::setDelegatesScrolling(bool enabled, ExceptionCode& ec)
     document->view()->setDelegatesScrolling(enabled);
 }
 
-#if ENABLE(TOUCH_ADJUSTMENT)
-PassRefPtr<WebKitPoint> Internals::touchPositionAdjustedToBestClickableNode(long x, long y, long width, long height, ExceptionCode& ec)
-{
-    Document* document = contextDocument();
-    if (!document || !document->frame()) {
-        ec = INVALID_ACCESS_ERR;
-        return 0;
-    }
-
-    IntSize radius(width / 2, height / 2);
-    IntPoint point(x + radius.width(), y + radius.height());
-
-    Node* targetNode;
-    IntPoint adjustedPoint;
-
-    bool foundNode = document->frame()->eventHandler().bestClickableNodeForTouchPoint(point, radius, adjustedPoint, targetNode);
-    if (foundNode)
-        return WebKitPoint::create(adjustedPoint.x(), adjustedPoint.y());
-
-    return 0;
-}
-
-Node* Internals::touchNodeAdjustedToBestClickableNode(long x, long y, long width, long height, ExceptionCode& ec)
-{
-    Document* document = contextDocument();
-    if (!document || !document->frame()) {
-        ec = INVALID_ACCESS_ERR;
-        return 0;
-    }
-
-    IntSize radius(width / 2, height / 2);
-    IntPoint point(x + radius.width(), y + radius.height());
-
-    Node* targetNode;
-    IntPoint adjustedPoint;
-    document->frame()->eventHandler().bestClickableNodeForTouchPoint(point, radius, adjustedPoint, targetNode);
-    return targetNode;
-}
-
-PassRefPtr<WebKitPoint> Internals::touchPositionAdjustedToBestContextMenuNode(long x, long y, long width, long height, ExceptionCode& ec)
-{
-    Document* document = contextDocument();
-    if (!document || !document->frame()) {
-        ec = INVALID_ACCESS_ERR;
-        return 0;
-    }
-
-    IntSize radius(width / 2, height / 2);
-    IntPoint point(x + radius.width(), y + radius.height());
-
-    Node* targetNode = 0;
-    IntPoint adjustedPoint;
-
-    bool foundNode = document->frame()->eventHandler().bestContextMenuNodeForTouchPoint(point, radius, adjustedPoint, targetNode);
-    if (foundNode)
-        return WebKitPoint::create(adjustedPoint.x(), adjustedPoint.y());
-
-    return WebKitPoint::create(x, y);
-}
-
-Node* Internals::touchNodeAdjustedToBestContextMenuNode(long x, long y, long width, long height, ExceptionCode& ec)
-{
-    Document* document = contextDocument();
-    if (!document || !document->frame()) {
-        ec = INVALID_ACCESS_ERR;
-        return 0;
-    }
-
-    IntSize radius(width / 2, height / 2);
-    IntPoint point(x + radius.width(), y + radius.height());
-
-    Node* targetNode = 0;
-    IntPoint adjustedPoint;
-    document->frame()->eventHandler().bestContextMenuNodeForTouchPoint(point, radius, adjustedPoint, targetNode);
-    return targetNode;
-}
-
-PassRefPtr<ClientRect> Internals::bestZoomableAreaForTouchPoint(long x, long y, long width, long height, ExceptionCode& ec)
-{
-    Document* document = contextDocument();
-    if (!document || !document->frame()) {
-        ec = INVALID_ACCESS_ERR;
-        return 0;
-    }
-
-    IntSize radius(width / 2, height / 2);
-    IntPoint point(x + radius.width(), y + radius.height());
-
-    Node* targetNode;
-    IntRect zoomableArea;
-    bool foundNode = document->frame()->eventHandler().bestZoomableAreaForTouchPoint(point, radius, zoomableArea, targetNode);
-    if (foundNode)
-        return ClientRect::create(zoomableArea);
-
-    return 0;
-}
-#endif
-
-
 int Internals::lastSpellCheckRequestSequence(ExceptionCode& ec)
 {
     Document* document = contextDocument();
index 02fdeeda4e7e667cd4187e0e995f2e51b08b9c50..3ac89f4c273f5eb210a7e8d3cbad0e4ab69e8737 100644 (file)
@@ -56,7 +56,6 @@ class Page;
 class Range;
 class ScriptExecutionContext;
 class ShadowRoot;
-class WebKitPoint;
 class MallocStatistics;
 class SerializedScriptValue;
 class TimeRanges;
@@ -158,13 +157,6 @@ public:
     String rangeAsText(const Range*, ExceptionCode&);
 
     void setDelegatesScrolling(bool enabled, ExceptionCode&);
-#if ENABLE(TOUCH_ADJUSTMENT)
-    PassRefPtr<WebKitPoint> touchPositionAdjustedToBestClickableNode(long x, long y, long width, long height, ExceptionCode&);
-    Node* touchNodeAdjustedToBestClickableNode(long x, long y, long width, long height, ExceptionCode&);
-    PassRefPtr<WebKitPoint> touchPositionAdjustedToBestContextMenuNode(long x, long y, long width, long height, ExceptionCode&);
-    Node* touchNodeAdjustedToBestContextMenuNode(long x, long y, long width, long height, ExceptionCode&);
-    PassRefPtr<ClientRect> bestZoomableAreaForTouchPoint(long x, long y, long width, long height, ExceptionCode&);
-#endif
 
     int lastSpellCheckRequestSequence(ExceptionCode&);
     int lastSpellCheckProcessedSequence(ExceptionCode&);
index e0c3987c4bc02ebdda97bfa6da787286fb92a526..5fadd38f9486285f2d986ac3eb2f5203a85df20c 100644 (file)
     [RaisesException] DOMString rangeAsText(Range range);
 
     [RaisesException] void setDelegatesScrolling(boolean enabled);
-#if defined(ENABLE_TOUCH_ADJUSTMENT) && ENABLE_TOUCH_ADJUSTMENT
-    [RaisesException] WebKitPoint touchPositionAdjustedToBestClickableNode(long x, long y, long width, long height);
-    [RaisesException] Node touchNodeAdjustedToBestClickableNode(long x, long y, long width, long height);
-    [RaisesException] WebKitPoint touchPositionAdjustedToBestContextMenuNode(long x, long y, long width, long height);
-    [RaisesException] Node touchNodeAdjustedToBestContextMenuNode(long x, long y, long width, long height);
-    [RaisesException] ClientRect bestZoomableAreaForTouchPoint(long x, long y, long width, long height);
-#endif
 
     [RaisesException] long lastSpellCheckRequestSequence();
     [RaisesException] long lastSpellCheckProcessedSequence();
index d8cb75a4c72ea8f59eb3ad9072e7a9e86772f7a4..887c4a03f3897beb51d9893ef384aa31b85cfeac 100644 (file)
@@ -1,3 +1,13 @@
+2014-01-17  Andreas Kling  <akling@apple.com>
+
+        Remove unused TOUCH_ADJUSTMENT code.
+        <https://webkit.org/b/127181>
+
+        Reviewed by Anders Carlsson.
+
+        * WebProcess/WebPage/CoordinatedGraphics/WebPageCoordinatedGraphics.cpp:
+        (WebKit::WebPage::findZoomableAreaForPoint):
+
 2014-01-17  Anders Carlsson  <andersca@apple.com>
 
         Fix build.
index 3312bef694c181ce8eb49d54e95dbd82504dd19d..4cef986b35bf214f6fc509136f251813939b6e2a 100644 (file)
@@ -42,25 +42,6 @@ using namespace WebCore;
 
 namespace WebKit {
 
-#if ENABLE(TOUCH_ADJUSTMENT)
-void WebPage::findZoomableAreaForPoint(const IntPoint& point, const IntSize& area)
-{
-    Node* node = 0;
-    IntRect zoomableArea;
-    bool foundAreaForTouchPoint = m_mainFrame->coreFrame()->eventHandler().bestZoomableAreaForTouchPoint(point, IntSize(area.width() / 2, area.height() / 2), zoomableArea, node);
-
-    if (!foundAreaForTouchPoint)
-        return;
-
-    ASSERT(node);
-
-    if (node->document().view())
-        zoomableArea = node->document().view()->contentsToWindow(zoomableArea);
-
-    send(Messages::WebPageProxy::DidFindZoomableArea(point, zoomableArea));
-}
-
-#else
 void WebPage::findZoomableAreaForPoint(const IntPoint& point, const IntSize& area)
 {
     UNUSED_PARAM(area);
@@ -98,7 +79,6 @@ void WebPage::findZoomableAreaForPoint(const IntPoint& point, const IntSize& are
 
     send(Messages::WebPageProxy::DidFindZoomableArea(point, zoomableArea));
 }
-#endif
 
 } // namespace WebKit