Changeset 87101 in webkit


Ignore:
Timestamp:
May 23, 2011 3:15:19 PM (13 years ago)
Author:
eae@chromium.org
Message:

2011-05-23 Emil A Eklund <eae@chromium.org>

Reviewed by Eric Seidel.

Change RenderBlock hit testing to use IntPoint instead x,y pair
https://bugs.webkit.org/show_bug.cgi?id=61146

Covered by existing tests.

  • platform/graphics/IntPoint.h: (WebCore::toSize): Add toSize function for converting from point to size.
  • rendering/RenderBlock.cpp: (WebCore::RenderBlock::isPointInOverflowControl): (WebCore::RenderBlock::nodeAtPoint): (WebCore::RenderBlock::hitTestFloats): (WebCore::RenderBlock::hitTestColumns): (WebCore::RenderBlock::hitTestContents):
  • rendering/RenderBlock.h: Change hit testing code in RenderBlock to use IntPoint.
  • rendering/RenderListBox.cpp: (WebCore::RenderListBox::isPointInOverflowControl):
  • rendering/RenderListBox.h: Change overridden method to use IntPoint.
Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r87099 r87101  
     12011-05-23  Emil A Eklund  <eae@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Change RenderBlock hit testing to use IntPoint instead x,y pair
     6        https://bugs.webkit.org/show_bug.cgi?id=61146
     7
     8        Covered by existing tests.
     9
     10        * platform/graphics/IntPoint.h:
     11        (WebCore::toSize):
     12        Add toSize function for converting from point to size.
     13
     14        * rendering/RenderBlock.cpp:
     15        (WebCore::RenderBlock::isPointInOverflowControl):
     16        (WebCore::RenderBlock::nodeAtPoint):
     17        (WebCore::RenderBlock::hitTestFloats):
     18        (WebCore::RenderBlock::hitTestColumns):
     19        (WebCore::RenderBlock::hitTestContents):
     20        * rendering/RenderBlock.h:
     21        Change hit testing code in RenderBlock to use IntPoint.
     22
     23        * rendering/RenderListBox.cpp:
     24        (WebCore::RenderListBox::isPointInOverflowControl):
     25        * rendering/RenderListBox.h:
     26        Change overridden method to use IntPoint.
     27
    1282011-05-23  Mike Reed  <reed@google.com>
    229
  • trunk/Source/WebCore/platform/graphics/IntPoint.h

    r84101 r87101  
    206206}
    207207
     208inline IntSize toSize(const IntPoint& a)
     209{
     210    return IntSize(a.x(), a.y());
     211}
     212
    208213#if PLATFORM(QT)
    209214inline QDataStream& operator<<(QDataStream& stream, const IntPoint& point)
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r87019 r87101  
    38903890}
    38913891
    3892 bool RenderBlock::isPointInOverflowControl(HitTestResult& result, int _x, int _y, int _tx, int _ty)
     3892bool RenderBlock::isPointInOverflowControl(HitTestResult& result, const IntPoint& pointInContainer, int tx, int ty)
    38933893{
    38943894    if (!scrollsOverflow())
    38953895        return false;
    38963896
    3897     return layer()->hitTestOverflowControls(result, IntPoint(_x - _tx, _y - _ty));
     3897    return layer()->hitTestOverflowControls(result, pointInContainer - IntSize(tx, ty));
    38983898}
    38993899
     
    39103910    }
    39113911
    3912     if ((hitTestAction == HitTestBlockBackground || hitTestAction == HitTestChildBlockBackground) && isPointInOverflowControl(result, pointInContainer.x(), pointInContainer.y(), localOffset.width(), localOffset.height())) {
     3912    if ((hitTestAction == HitTestBlockBackground || hitTestAction == HitTestChildBlockBackground) && isPointInOverflowControl(result, pointInContainer, localOffset.width(), localOffset.height())) {
    39133913        updateHitTestResult(result, pointInContainer - localOffset);
    39143914        // FIXME: isPointInOverflowControl() doesn't handle rect-based tests yet.
     
    39313931        // Hit test contents if we don't have columns.
    39323932        if (!hasColumns()) {
    3933             if (hitTestContents(request, result, pointInContainer.x(), pointInContainer.y(), scrolledOffset.width(), scrolledOffset.height(), hitTestAction)) {
     3933            if (hitTestContents(request, result, pointInContainer, scrolledOffset.width(), scrolledOffset.height(), hitTestAction)) {
    39343934                updateHitTestResult(result, pointInContainer - localOffset);
    39353935                return true;
    39363936            }
    3937             if (hitTestAction == HitTestFloat && hitTestFloats(request, result, pointInContainer.x(), pointInContainer.y(), scrolledOffset.width(), scrolledOffset.height()))
     3937            if (hitTestAction == HitTestFloat && hitTestFloats(request, result, pointInContainer, scrolledOffset.width(), scrolledOffset.height()))
    39383938                return true;
    3939         } else if (hitTestColumns(request, result, pointInContainer.x(), pointInContainer.y(), scrolledOffset.width(), scrolledOffset.height(), hitTestAction)) {
     3939        } else if (hitTestColumns(request, result, pointInContainer, scrolledOffset.width(), scrolledOffset.height(), hitTestAction)) {
    39403940            updateHitTestResult(result, pointInContainer - localOffset);
    39413941            return true;
     
    39563956}
    39573957
    3958 bool RenderBlock::hitTestFloats(const HitTestRequest& request, HitTestResult& result, int x, int y, int tx, int ty)
     3958bool RenderBlock::hitTestFloats(const HitTestRequest& request, HitTestResult& result, const IntPoint& pointInContainer, int tx, int ty)
    39593959{
    39603960    if (!m_floatingObjects)
     
    39753975            int yOffset = yPositionForFloatIncludingMargin(floatingObject) - floatingObject->m_renderer->y();
    39763976            IntPoint childPoint = flipFloatForWritingMode(floatingObject, IntPoint(tx + xOffset, ty + yOffset));
    3977             if (floatingObject->m_renderer->hitTest(request, result, IntPoint(x, y), childPoint.x(), childPoint.y())) {
    3978                 updateHitTestResult(result, IntPoint(x - childPoint.x(), y - childPoint.y()));
     3977            if (floatingObject->m_renderer->hitTest(request, result, pointInContainer, childPoint.x(), childPoint.y())) {
     3978                updateHitTestResult(result, pointInContainer - toSize(childPoint));
    39793979                return true;
    39803980            }
     
    39853985}
    39863986
    3987 bool RenderBlock::hitTestColumns(const HitTestRequest& request, HitTestResult& result, int x, int y, int tx, int ty, HitTestAction hitTestAction)
     3987bool RenderBlock::hitTestColumns(const HitTestRequest& request, HitTestResult& result, const IntPoint& pointInContainer, int tx, int ty, HitTestAction hitTestAction)
    39883988{
    39893989    // We need to do multiple passes, breaking up our hit testing into strips.
     
    40154015        colRect.move(tx, ty);
    40164016       
    4017         if (colRect.intersects(result.rectForPoint(IntPoint(x, y)))) {
     4017        if (colRect.intersects(result.rectForPoint(pointInContainer))) {
    40184018            // The point is inside this column.
    40194019            // Adjust tx and ty to change where we hit test.
     
    40224022            int finalX = tx + offset.width();
    40234023            int finalY = ty + offset.height();
    4024             if (result.isRectBasedTest() && !colRect.contains(result.rectForPoint(IntPoint(x, y))))
    4025                 hitTestContents(request, result, x, y, finalX, finalY, hitTestAction);
     4024            if (result.isRectBasedTest() && !colRect.contains(result.rectForPoint(pointInContainer)))
     4025                hitTestContents(request, result, pointInContainer, finalX, finalY, hitTestAction);
    40264026            else
    4027                 return hitTestContents(request, result, x, y, finalX, finalY, hitTestAction) || (hitTestAction == HitTestFloat && hitTestFloats(request, result, x, y, finalX, finalY));
     4027                return hitTestContents(request, result, pointInContainer, finalX, finalY, hitTestAction) || (hitTestAction == HitTestFloat && hitTestFloats(request, result, pointInContainer, finalX, finalY));
    40284028        }
    40294029    }
     
    40324032}
    40334033
    4034 bool RenderBlock::hitTestContents(const HitTestRequest& request, HitTestResult& result, int x, int y, int tx, int ty, HitTestAction hitTestAction)
     4034bool RenderBlock::hitTestContents(const HitTestRequest& request, HitTestResult& result, const IntPoint& pointInContainer, int tx, int ty, HitTestAction hitTestAction)
    40354035{
    40364036    if (childrenInline() && !isTable()) {
    40374037        // We have to hit-test our line boxes.
    4038         if (m_lineBoxes.hitTest(this, request, result, IntPoint(x, y), tx, ty, hitTestAction))
     4038        if (m_lineBoxes.hitTest(this, request, result, pointInContainer, tx, ty, hitTestAction))
    40394039            return true;
    40404040    } else {
     
    40454045        for (RenderBox* child = lastChildBox(); child; child = child->previousSiblingBox()) {
    40464046            IntPoint childPoint = flipForWritingMode(child, IntPoint(tx, ty), ParentToChildFlippingAdjustment);
    4047             if (!child->hasSelfPaintingLayer() && !child->isFloating() && child->nodeAtPoint(request, result, IntPoint(x, y), childPoint.x(), childPoint.y(), childHitTest))
     4047            if (!child->hasSelfPaintingLayer() && !child->isFloating() && child->nodeAtPoint(request, result, pointInContainer, childPoint.x(), childPoint.y(), childHitTest))
    40484048                return true;
    40494049        }
  • trunk/Source/WebCore/rendering/RenderBlock.h

    r86739 r87101  
    585585    int nextFloatLogicalBottomBelow(int) const;
    586586   
    587     virtual bool hitTestColumns(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
    588     virtual bool hitTestContents(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
    589     bool hitTestFloats(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty);
    590 
    591     virtual bool isPointInOverflowControl(HitTestResult&, int x, int y, int tx, int ty);
     587    virtual bool hitTestColumns(const HitTestRequest&, HitTestResult&, const IntPoint& pointInContainer, int tx, int ty, HitTestAction);
     588    virtual bool hitTestContents(const HitTestRequest&, HitTestResult&, const IntPoint& pointInContainer, int tx, int ty, HitTestAction);
     589    bool hitTestFloats(const HitTestRequest&, HitTestResult&, const IntPoint& pointInContainer, int tx, int ty);
     590
     591    virtual bool isPointInOverflowControl(HitTestResult&, const IntPoint& pointInContainer, int tx, int ty);
    592592
    593593    void computeInlinePreferredLogicalWidths();
  • trunk/Source/WebCore/rendering/RenderListBox.cpp

    r86739 r87101  
    435435}
    436436
    437 bool RenderListBox::isPointInOverflowControl(HitTestResult& result, int _x, int _y, int _tx, int _ty)
     437bool RenderListBox::isPointInOverflowControl(HitTestResult& result, const IntPoint& pointInContainer, int tx, int ty)
    438438{
    439439    if (!m_vBar)
    440440        return false;
    441441
    442     IntRect vertRect(_tx + width() - borderRight() - m_vBar->width(),
    443                      _ty + borderTop(),
     442    IntRect vertRect(tx + width() - borderRight() - m_vBar->width(),
     443                     ty + borderTop(),
    444444                     m_vBar->width(),
    445445                     height() - borderTop() - borderBottom());
    446446
    447     if (vertRect.contains(_x, _y)) {
     447    if (vertRect.contains(pointInContainer)) {
    448448        result.setScrollbar(m_vBar.get());
    449449        return true;
  • trunk/Source/WebCore/rendering/RenderListBox.h

    r86705 r87101  
    6969    virtual IntRect controlClipRect(int tx, int ty) const;
    7070
    71     virtual bool isPointInOverflowControl(HitTestResult&, int x, int y, int tx, int ty);
     71    virtual bool isPointInOverflowControl(HitTestResult&, const IntPoint& pointInContainer, int tx, int ty);
    7272
    7373    virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Node** stopNode = 0);
Note: See TracChangeset for help on using the changeset viewer.