Changeset 92993 in webkit


Ignore:
Timestamp:
Aug 12, 2011 2:02:19 PM (13 years ago)
Author:
hyatt@apple.com
Message:

https://bugs.webkit.org/show_bug.cgi?id=66133

Make hit testing work on RenderRegions. Pass off the hit testing to the RenderFlowThread
layer tree (just as we did with painting).

Reviewed by Sam Weinig.

Added hit-test-float.html to demonstrate basic hit testing of content flowed into regions.

Source/WebCore:

  • rendering/HitTestRequest.h:

(WebCore::HitTestRequest::type):

  • rendering/RenderFlowThread.cpp:

(WebCore::RenderFlowThread::hitTestRegion):

  • rendering/RenderFlowThread.h:
  • rendering/RenderRegion.cpp:

(WebCore::RenderRegion::paintReplaced):
(WebCore::RenderRegion::nodeAtPoint):

  • rendering/RenderRegion.h:

LayoutTests:

  • fast/regions/hit-test-float-expected.txt: Added.
  • fast/regions/hit-test-float.html: Added.
Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r92990 r92993  
     12011-08-12  David Hyatt  <hyatt@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=66133
     4       
     5        Make hit testing work on RenderRegions. Pass off the hit testing to the RenderFlowThread
     6        layer tree (just as we did with painting).
     7
     8        Reviewed by Sam Weinig.
     9
     10        Added hit-test-float.html to demonstrate basic hit testing of content flowed into regions.
     11
     12        * fast/regions/hit-test-float-expected.txt: Added.
     13        * fast/regions/hit-test-float.html: Added.
     14
    1152011-08-12  Ryosuke Niwa  <rniwa@webkit.org>
    216
  • trunk/Source/WebCore/ChangeLog

    r92992 r92993  
     12011-08-12  David Hyatt  <hyatt@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=66133
     4       
     5        Make hit testing work on RenderRegions. Pass off the hit testing to the RenderFlowThread
     6        layer tree (just as we did with painting).
     7
     8        Reviewed by Sam Weinig.
     9
     10        Added hit-test-float.html to demonstrate basic hit testing of content flowed into regions.
     11
     12        * rendering/HitTestRequest.h:
     13        (WebCore::HitTestRequest::type):
     14        * rendering/RenderFlowThread.cpp:
     15        (WebCore::RenderFlowThread::hitTestRegion):
     16        * rendering/RenderFlowThread.h:
     17        * rendering/RenderRegion.cpp:
     18        (WebCore::RenderRegion::paintReplaced):
     19        (WebCore::RenderRegion::nodeAtPoint):
     20        * rendering/RenderRegion.h:
     21
    1222011-08-12  Levi Weintraub  <leviw@chromium.org>
    223
  • trunk/Source/WebCore/rendering/HitTestRequest.h

    r63888 r92993  
    5050    bool svgClipContent() const { return m_requestType & SVGClipContent; }
    5151
     52    HitTestRequestType type() const { return m_requestType; }
     53
    5254private:
    5355    HitTestRequestType m_requestType;
  • trunk/Source/WebCore/rendering/RenderFlowThread.cpp

    r92981 r92993  
    3131
    3232#include "RenderFlowThread.h"
     33#include "HitTestRequest.h"
     34#include "HitTestResult.h"
    3335#include "Node.h"
    3436#include "PaintInfo.h"
     
    264266}
    265267
     268bool RenderFlowThread::hitTestRegion(const LayoutRect& regionRect, const HitTestRequest& request, HitTestResult& result, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset)
     269{
     270    LayoutRect regionClippingRect(accumulatedOffset, regionRect.size());
     271    if (!regionClippingRect.contains(pointInContainer))
     272        return false;
     273   
     274    LayoutPoint renderFlowThreadOffset;
     275    if (style()->isFlippedBlocksWritingMode()) {
     276        LayoutRect flippedRegionRect(regionRect);
     277        flipForWritingMode(flippedRegionRect);
     278        renderFlowThreadOffset = LayoutPoint(regionClippingRect.location() - flippedRegionRect.location());
     279    } else
     280        renderFlowThreadOffset = LayoutPoint(regionClippingRect.location() - regionRect.location());
     281
     282    LayoutPoint transformedPoint(pointInContainer.x() - renderFlowThreadOffset.x(), pointInContainer.y() - renderFlowThreadOffset.y());
     283   
     284    // Always ignore clipping, since the RenderFlowThread has nothing to do with the bounds of the FrameView.
     285    HitTestRequest newRequest(request.type() & HitTestRequest::IgnoreClipping);
     286
     287    LayoutPoint oldPoint = result.point();
     288    result.setPoint(transformedPoint);
     289    bool isPointInsideFlowThread = layer()->hitTest(newRequest, result);
     290    result.setPoint(oldPoint);
     291   
     292    // FIXME: Should we set result.m_localPoint back to the RenderRegion's coordinate space or leave it in the RenderFlowThread's coordinate
     293    // space? Right now it's staying in the RenderFlowThread's coordinate space, which may end up being ok. We will know more when we get around to
     294    // patching positionForPoint.
     295    return isPointInsideFlowThread;
     296}
     297
    266298} // namespace WebCore
  • trunk/Source/WebCore/rendering/RenderFlowThread.h

    r92969 r92993  
    7878    void computeLogicalHeight();
    7979
    80     void paintIntoRegion(PaintInfo&, const LayoutRect&, const LayoutPoint&);
     80    void paintIntoRegion(PaintInfo&, const LayoutRect& regionRect, const LayoutPoint& paintOffset);
     81    bool hitTestRegion(const LayoutRect& regionRect, const HitTestRequest&, HitTestResult&, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset);
    8182
    8283    bool hasRegions() const { return m_regionList.size(); }
  • trunk/Source/WebCore/rendering/RenderRegion.cpp

    r92981 r92993  
    3232
    3333#include "GraphicsContext.h"
     34#include "HitTestResult.h"
    3435#include "IntRect.h"
    3536#include "PaintInfo.h"
     
    5556{
    5657    // Delegate painting of content in region to RenderFlowThread.
     58    if (!m_flowThread)
     59        return;
    5760    m_flowThread->paintIntoRegion(paintInfo, regionRect(), LayoutPoint(paintOffset.x() + borderLeft() + paddingLeft(), paintOffset.y() + borderTop() + paddingTop()));
     61}
     62
     63// Hit Testing
     64bool RenderRegion::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction action)
     65{
     66    LayoutPoint adjustedLocation = accumulatedOffset + location();
     67
     68    // Check our bounds next. For this purpose always assume that we can only be hit in the
     69    // foreground phase (which is true for replaced elements like images).
     70    LayoutRect boundsRect(adjustedLocation, size());
     71    if (visibleToHitTesting() && action == HitTestForeground && boundsRect.intersects(result.rectForPoint(pointInContainer))) {
     72        // Check the contents of the RenderFlowThread.
     73        if (m_flowThread && m_flowThread->hitTestRegion(regionRect(), request, result, pointInContainer, LayoutPoint(adjustedLocation.x() + borderLeft() + paddingLeft(), adjustedLocation.y() + borderTop() + paddingTop())))
     74            return true;
     75        updateHitTestResult(result, pointInContainer - toLayoutSize(adjustedLocation));
     76        if (!result.addNodeToRectBasedTestResult(node(), pointInContainer, boundsRect))
     77            return true;
     78    }
     79
     80    return false;
    5881}
    5982
  • trunk/Source/WebCore/rendering/RenderRegion.h

    r92981 r92993  
    4545
    4646    virtual void paintReplaced(PaintInfo&, const LayoutPoint&);
     47    virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
    4748
    4849    void setRegionRect(const IntRect& rect) { m_regionRect = rect; }
Note: See TracChangeset for help on using the changeset viewer.