Changeset 38098 in webkit


Ignore:
Timestamp:
Nov 4, 2008 10:54:50 AM (15 years ago)
Author:
Simon Fraser
Message:

2008-11-04 Simon Fraser <Simon Fraser>

Reviewed by Dave Hyatt

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

Rename absolutePosition() to localToAbsolute(), and add the ability
to optionally take transforms into account (which will eventually be the
default behavior).

Location:
trunk
Files:
43 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r38097 r38098  
     12008-11-04  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Reviewed by Dave Hyatt
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=21941
     6
     7        Rename absolutePosition() to localToAbsolute(), and add the ability
     8        to optionally take transforms into account (which will eventually be the
     9        default behavior).
     10
     11        * WebCore.base.exp:
     12        * WebCore.xcodeproj/project.pbxproj:
     13        * dom/ContainerNode.cpp:
     14        (WebCore::ContainerNode::getUpperLeftCorner):
     15        (WebCore::ContainerNode::getLowerRightCorner):
     16        (WebCore::ContainerNode::getRect):
     17        * dom/ContainerNode.h:
     18        * dom/MouseRelatedEvent.cpp:
     19        (WebCore::MouseRelatedEvent::receivedTarget):
     20        * dom/Node.cpp:
     21        (WebCore::Node::getRect):
     22        * editing/SelectionController.cpp:
     23        (WebCore::SelectionController::layout):
     24        (WebCore::SelectionController::caretRect):
     25        * editing/visible_units.cpp:
     26        (WebCore::previousLinePosition):
     27        (WebCore::nextLinePosition):
     28        * html/HTMLAnchorElement.cpp:
     29        (WebCore::HTMLAnchorElement::isKeyboardFocusable):
     30        (WebCore::HTMLAnchorElement::defaultEventHandler):
     31        * html/HTMLAreaElement.cpp:
     32        (WebCore::HTMLAreaElement::getRect):
     33        * html/HTMLImageElement.cpp:
     34        (WebCore::HTMLImageElement::x):
     35        (WebCore::HTMLImageElement::y):
     36        * html/HTMLInputElement.cpp:
     37        (WebCore::HTMLInputElement::defaultEventHandler):
     38        * html/HTMLInputElement.h:
     39        * page/AccessibilityRenderObject.cpp:
     40        (WebCore::AccessibilityRenderObject::boundingBoxRect):
     41        * page/EventHandler.cpp:
     42        (WebCore::EventHandler::handleDrag):
     43        * platform/graphics/FloatPoint.h:
     44        (WebCore::roundedIntPoint):
     45        * platform/graphics/IntSize.h:
     46        (WebCore::IntSize::expand):
     47        * rendering/LayoutState.cpp:
     48        (WebCore::LayoutState::LayoutState):
     49        * rendering/RenderBlock.cpp:
     50        (WebCore::RenderBlock::layoutBlock):
     51        (WebCore::RenderBlock::paintObject):
     52        (WebCore::RenderBlock::selectionGapRects):
     53        (WebCore::RenderBlock::fillBlockSelectionGaps):
     54        (WebCore::RenderBlock::nodeAtPoint):
     55        (WebCore::RenderBlock::positionForCoordinates):
     56        * rendering/RenderBox.cpp:
     57        (WebCore::RenderBox::localToAbsolute):
     58        (WebCore::RenderBox::computeAbsoluteRepaintRect):
     59        (WebCore::RenderBox::caretRect):
     60        * rendering/RenderBox.h:
     61        (WebCore::RenderBox::relativePositionOffset):
     62        * rendering/RenderContainer.cpp:
     63        (WebCore::RenderContainer::addLineBoxRects):
     64        * rendering/RenderFlow.cpp:
     65        (WebCore::RenderFlow::absoluteClippedOverflowRect):
     66        (WebCore::RenderFlow::caretRect):
     67        (WebCore::RenderFlow::addFocusRingRects):
     68        * rendering/RenderLayer.cpp:
     69        (WebCore::RenderLayer::updateLayerPosition):
     70        (WebCore::RenderLayer::convertToLayerCoords):
     71        (WebCore::RenderLayer::addScrolledContentOffset):
     72        (WebCore::RenderLayer::subtractScrolledContentOffset):
     73        (WebCore::RenderLayer::scrollRectToVisible):
     74        * rendering/RenderLayer.h:
     75        (WebCore::RenderLayer::scrolledContentOffset):
     76        (WebCore::RenderLayer::relativePositionOffset):
     77        * rendering/RenderListBox.cpp:
     78        (WebCore::RenderListBox::panScroll):
     79        (WebCore::RenderListBox::scrollToward):
     80        * rendering/RenderListMarker.cpp:
     81        (WebCore::RenderListMarker::selectionRect):
     82        * rendering/RenderObject.cpp:
     83        (WebCore::RenderObject::absoluteBoundingBoxRect):
     84        (WebCore::RenderObject::computeAbsoluteRepaintRect):
     85        (WebCore::RenderObject::localToAbsolute):
     86        (WebCore::RenderObject::addDashboardRegions):
     87        (WebCore::RenderObject::absoluteContentBox):
     88        (WebCore::RenderObject::absoluteOutlineBox):
     89        * rendering/RenderObject.h:
     90        (WebCore::RenderObject::localToAbsoluteForContent):
     91        * rendering/RenderPart.cpp:
     92        (WebCore::RenderPart::updateWidgetPosition):
     93        * rendering/RenderReplaced.cpp:
     94        (WebCore::RenderReplaced::selectionRect):
     95        * rendering/RenderSVGInlineText.cpp:
     96        (WebCore::RenderSVGInlineText::computeAbsoluteRectForRange):
     97        * rendering/RenderSVGText.cpp:
     98        (WebCore::RenderSVGText::absoluteRects):
     99        * rendering/RenderTableCell.cpp:
     100        (WebCore::RenderTableCell::localToAbsolute):
     101        * rendering/RenderTableCell.h:
     102        * rendering/RenderText.cpp:
     103        (WebCore::RenderText::addLineBoxRects):
     104        (WebCore::RenderText::caretRect):
     105        (WebCore::RenderText::selectionRect):
     106        * rendering/RenderVideo.cpp:
     107        (WebCore::RenderVideo::updatePlayer):
     108        * rendering/RenderView.cpp:
     109        (WebCore::RenderView::localToAbsolute):
     110        * rendering/RenderView.h:
     111        * rendering/RenderWidget.cpp:
     112        (WebCore::RenderWidget::updateWidgetPosition):
     113        * svg/SVGSVGElement.cpp:
     114        (WebCore::SVGSVGElement::getScreenCTM):
     115
    11162008-11-03  Yael Aharon  <yael.aharon@nokia.com>
    2117
  • trunk/WebCore/WebCore.base.exp

    r38094 r38098  
    567567__ZN7WebCore8FormDataD1Ev
    568568__ZN7WebCore8IntPointC1ERK8_NSPoint
     569__ZNK7WebCore10FloatPointcv8_NSPointEv
    569570__ZN7WebCore8Settings14setJavaEnabledEb
    570571__ZN7WebCore8Settings16setUsesPageCacheEb
  • trunk/WebCore/dom/ContainerNode.cpp

    r38094 r38098  
    3030#include "EventNames.h"
    3131#include "ExceptionCode.h"
     32#include "FloatRect.h"
    3233#include "Frame.h"
    3334#include "FrameView.h"
     
    648649}
    649650
    650 bool ContainerNode::getUpperLeftCorner(int &xPos, int &yPos) const
     651// FIXME: This doesn't work correctly with transforms.
     652bool ContainerNode::getUpperLeftCorner(FloatPoint& point) const
    651653{
    652654    if (!renderer())
    653655        return false;
     656    // What is this code really trying to do?
    654657    RenderObject *o = renderer();
    655658    RenderObject *p = o;
    656659
    657     xPos = yPos = 0;
    658660    if (!o->isInline() || o->isReplaced()) {
    659         o->absolutePosition(xPos, yPos);
     661        point = o->localToAbsolute();
    660662        return true;
    661663    }
    662664
    663665    // find the next text/image child, to get a position
    664     while(o) {
     666    while (o) {
    665667        p = o;
    666668        if (o->firstChild())
    667669            o = o->firstChild();
    668         else if(o->nextSibling())
     670        else if (o->nextSibling())
    669671            o = o->nextSibling();
    670672        else {
     
    681683
    682684        if (!o->isInline() || o->isReplaced()) {
    683             o->absolutePosition(xPos, yPos);
     685            point = o->localToAbsolute();
    684686            return true;
    685687        }
     
    688690                // do nothing - skip unrendered whitespace that is a child or next sibling of the anchor
    689691        } else if ((o->isText() && !o->isBR()) || o->isReplaced()) {
    690             o->container()->absolutePosition(xPos, yPos);
     692            point = o->container()->localToAbsolute();
    691693            if (o->isText() && static_cast<RenderText *>(o)->firstTextBox()) {
    692                 xPos += static_cast<RenderText *>(o)->minXPos();
    693                 yPos += static_cast<RenderText *>(o)->firstTextBox()->root()->topOverflow();
    694             } else {
    695                 xPos += o->xPos();
    696                 yPos += o->yPos();
    697             }
     694                point.move(static_cast<RenderText *>(o)->minXPos(),
     695                           static_cast<RenderText *>(o)->firstTextBox()->root()->topOverflow());
     696            } else
     697                point.move(o->xPos(), o->yPos());
    698698            return true;
    699699        }
     
    701701   
    702702    // If the target doesn't have any children or siblings that could be used to calculate the scroll position, we must be
    703     // at the end of the document.  Scroll to the bottom.
     703    // at the end of the document.  Scroll to the bottom. FIXME: who said anything about scrolling?
    704704    if (!o && document()->view()) {
    705         yPos += document()->view()->contentsHeight();
     705        point = FloatPoint(0, document()->view()->contentsHeight());
    706706        return true;
    707707    }
     
    709709}
    710710
    711 bool ContainerNode::getLowerRightCorner(int &xPos, int &yPos) const
     711// FIXME: This doesn't work correctly with transforms.
     712bool ContainerNode::getLowerRightCorner(FloatPoint& point) const
    712713{
    713714    if (!renderer())
     
    715716
    716717    RenderObject *o = renderer();
    717     xPos = yPos = 0;
    718718    if (!o->isInline() || o->isReplaced())
    719719    {
    720         o->absolutePosition(xPos, yPos);
    721         xPos += o->width();
    722         yPos += o->height() + o->borderTopExtra() + o->borderBottomExtra();
     720        point = o->localToAbsolute();
     721        point.move(o->width(),
     722                   o->height() + o->borderTopExtra() + o->borderBottomExtra());
    723723        return true;
    724724    }
     725
    725726    // find the last text/image child, to get a position
    726     while(o) {
    727         if(o->lastChild())
     727    while (o) {
     728        if (o->lastChild())
    728729            o = o->lastChild();
    729         else if(o->previousSibling())
     730        else if (o->previousSibling())
    730731            o = o->previousSibling();
    731732        else {
     
    733734            while(!prev) {
    734735                o = o->parent();
    735                 if(!o) return false;
     736                if (!o)
     737                    return false;
    736738                prev = o->previousSibling();
    737739            }
     
    739741        }
    740742        if (o->isText() || o->isReplaced()) {
    741             o->container()->absolutePosition(xPos, yPos);
     743            point = o->container()->localToAbsolute();
     744            int xOffset;
    742745            if (o->isText())
    743                 xPos += static_cast<RenderText *>(o)->minXPos() + o->width();
     746                xOffset = static_cast<RenderText *>(o)->minXPos() + o->width();
    744747            else
    745                 xPos += o->xPos()+o->width();
    746             yPos += o->yPos()+o->height();
     748                xOffset = o->xPos() + o->width();
     749           
     750            point.move(xOffset, o->yPos() + o->height());
    747751            return true;
    748752        }
     
    753757IntRect ContainerNode::getRect() const
    754758{
    755     int xPos = 0, yPos = 0, xEnd = 0, yEnd = 0;
    756     bool foundUpperLeft = getUpperLeftCorner(xPos,yPos);
    757     bool foundLowerRight = getLowerRightCorner(xEnd,yEnd);
     759    FloatPoint  upperLeft, lowerRight;
     760    bool foundUpperLeft = getUpperLeftCorner(upperLeft);
     761    bool foundLowerRight = getLowerRightCorner(lowerRight);
    758762   
    759763    // If we've found one corner, but not the other,
     
    761765    if (foundUpperLeft != foundLowerRight)
    762766    {
    763         if (foundUpperLeft) {
    764             xEnd = xPos;
    765             yEnd = yPos;
    766         } else {
    767             xPos = xEnd;
    768             yPos = yEnd;
    769         }
     767        if (foundUpperLeft)
     768            lowerRight = upperLeft;
     769        else
     770            upperLeft = lowerRight;
    770771    }
    771772
    772     if (xEnd < xPos)
    773         xEnd = xPos;
    774     if (yEnd < yPos)
    775         yEnd = yPos;
    776        
    777     return IntRect(xPos, yPos, xEnd - xPos, yEnd - yPos);
     773    lowerRight.setX(max(upperLeft.x(), lowerRight.x()));
     774    lowerRight.setY(max(upperLeft.y(), lowerRight.y()));
     775   
     776    return enclosingIntRect(FloatRect(upperLeft, lowerRight - upperLeft));
    778777}
    779778
  • trunk/WebCore/dom/ContainerNode.h

    r36923 r38098  
    2626
    2727#include "EventTargetNode.h"
     28#include "FloatPoint.h"
    2829
    2930namespace WebCore {
     
    9091    static void dispatchPostAttachCallbacks();
    9192   
    92     bool getUpperLeftCorner(int& x, int& y) const;
    93     bool getLowerRightCorner(int& x, int& y) const;
     93    bool getUpperLeftCorner(FloatPoint&) const;
     94    bool getLowerRightCorner(FloatPoint&) const;
    9495
    9596    Node* m_firstChild;
  • trunk/WebCore/dom/MouseRelatedEvent.cpp

    r36925 r38098  
    134134    if (!isSimulated()) {
    135135        if (RenderObject* r = targ->renderer()) {
    136             int rx, ry;
    137             if (r->absolutePosition(rx, ry)) {
    138                 m_offsetX -= rx;
    139                 m_offsetY -= ry;
    140             }
     136            // FIXME: This doesn't work correctly with transforms. We need
     137            // an absoluteToLocal() method.
     138            FloatPoint absPos = r->localToAbsolute();
     139            m_offsetX -= absPos.x();
     140            m_offsetY -= absPos.y();
    141141        }
    142142    }
  • trunk/WebCore/dom/Node.cpp

    r38087 r38098  
    410410IntRect Node::getRect() const
    411411{
    412     int _x, _y;
    413     if (renderer() && renderer()->absolutePosition(_x, _y))
    414         return IntRect( _x, _y, renderer()->width(), renderer()->height() + renderer()->borderTopExtra() + renderer()->borderBottomExtra());
    415 
     412    // FIXME: broken with transforms
     413    if (renderer()) {
     414        FloatPoint absPos = renderer()->localToAbsolute();
     415        return IntRect(roundedIntPoint(absPos),
     416                       IntSize(renderer()->width(), renderer()->height() + renderer()->borderTopExtra() + renderer()->borderBottomExtra()));
     417    }
    416418    return IntRect();
    417419}
  • trunk/WebCore/editing/SelectionController.cpp

    r38094 r38098  
    741741            m_caretRect = pos.caretRect();
    742742
    743             int x, y;
    744             pos.deepEquivalent().node()->renderer()->absolutePositionForContent(x, y);
    745             m_caretPositionOnLayout = IntPoint(x, y);
     743            // FIXME: broken with transforms
     744            FloatPoint absPos = pos.deepEquivalent().node()->renderer()->localToAbsoluteForContent(FloatPoint());
     745            m_caretPositionOnLayout = roundedIntPoint(absPos);
    746746        }
    747747    }
     
    758758
    759759    if (m_sel.start().node() && m_sel.start().node()->renderer()) {
    760         int x, y;
    761         m_sel.start().node()->renderer()->absolutePositionForContent(x, y);
    762         caret.move(IntPoint(x, y) - m_caretPositionOnLayout);
     760        FloatPoint absPos = m_sel.start().node()->renderer()->localToAbsoluteForContent(FloatPoint());
     761        caret.move(roundedIntPoint(absPos) - m_caretPositionOnLayout);
    763762    }
    764763
  • trunk/WebCore/editing/visible_units.cpp

    r34344 r38098  
    494494   
    495495    if (root) {
    496         // FIXME: Can be wrong for multi-column layout.
    497         int absx, absy;
    498         containingBlock->absolutePositionForContent(absx, absy);
     496        // FIXME: Can be wrong for multi-column layout, and with transforms
     497        FloatPoint absPos = containingBlock->localToAbsoluteForContent(FloatPoint());
    499498        if (containingBlock->hasOverflowClip())
    500             containingBlock->layer()->subtractScrollOffset(absx, absy);
    501         RenderObject *renderer = root->closestLeafChildForXPos(x - absx, isEditablePosition(p))->object();
     499            absPos -= containingBlock->layer()->scrolledContentOffset();
     500        RenderObject *renderer = root->closestLeafChildForXPos(x - absPos.x(), isEditablePosition(p))->object();
    502501        Node* node = renderer->element();
    503502        if (editingIgnoresContent(node))
    504503            return Position(node->parent(), node->nodeIndex());
    505         return renderer->positionForCoordinates(x - absx, root->topOverflow());
     504        return renderer->positionForCoordinates(x - absPos.x(), root->topOverflow());
    506505    }
    507506   
     
    596595   
    597596    if (root) {
    598         // FIXME: Can be wrong for multi-column layout.
    599         int absx, absy;
    600         containingBlock->absolutePositionForContent(absx, absy);
     597        // FIXME: Can be wrong for multi-column layout and with transforms
     598        FloatPoint absPos = containingBlock->localToAbsoluteForContent(FloatPoint());
    601599        if (containingBlock->hasOverflowClip())
    602             containingBlock->layer()->subtractScrollOffset(absx, absy);
    603         RenderObject *renderer = root->closestLeafChildForXPos(x - absx, isEditablePosition(p))->object();
     600            absPos -= containingBlock->layer()->scrolledContentOffset();
     601        RenderObject *renderer = root->closestLeafChildForXPos(x - absPos.x(), isEditablePosition(p))->object();
    604602        Node* node = renderer->element();
    605603        if (editingIgnoresContent(node))
    606604            return Position(node->parent(), node->nodeIndex());
    607         return renderer->positionForCoordinates(x - absx, root->topOverflow());
     605        return renderer->positionForCoordinates(x - absPos.x(), root->topOverflow());
    608606    }   
    609607
  • trunk/WebCore/html/HTMLAnchorElement.cpp

    r38094 r38098  
    116116
    117117    Vector<IntRect> rects;
    118     int x, y;
    119     renderer()->absolutePosition(x, y);
    120     renderer()->absoluteRects(rects, x, y);
     118    FloatPoint absPos = renderer()->localToAbsolute();
     119    renderer()->absoluteRects(rects, absPos.x(), absPos.y());
    121120    size_t n = rects.size();
    122121    for (size_t i = 0; i < n; ++i)
     
    201200                RenderImage* r = static_cast<RenderImage*>(img->renderer());
    202201                if (r && e) {
    203                     int absx, absy;
    204                     r->absolutePosition(absx, absy);
    205                     int x = e->pageX() - absx;
    206                     int y = e->pageY() - absy;
     202                    // FIXME: broken with transforms
     203                    FloatPoint absPos = r->localToAbsolute();
     204                    int x = e->pageX() - absPos.x();
     205                    int y = e->pageY() - absPos.y();
    207206                    url += "?";
    208207                    url += String::number(x);
  • trunk/WebCore/html/HTMLAreaElement.cpp

    r37527 r38098  
    8787IntRect HTMLAreaElement::getRect(RenderObject* obj) const
    8888{
    89     int dx, dy;
    90     obj->absolutePosition(dx, dy);
     89    // FIXME: This doesn't work correctly with transforms.
     90    FloatPoint absPos = obj->localToAbsolute();
    9191    Path p = getRegion(m_lastSize);
    92     p.translate(IntSize(dx, dy));
     92    p.translate(absPos - FloatPoint());
    9393    return enclosingIntRect(p.boundingRect());
    9494}
  • trunk/WebCore/html/HTMLImageElement.cpp

    r38094 r38098  
    408408    if (!r)
    409409        return 0;
    410     int x, y;
    411     r->absolutePosition(x, y);
    412     return x;
     410
     411    // FIXME: This doesn't work correctly with transforms.
     412    FloatPoint absPos = r->localToAbsolute();
     413    return absPos.x();
    413414}
    414415
     
    418419    if (!r)
    419420        return 0;
    420     int x, y;
    421     r->absolutePosition(x, y);
    422     return y;
     421
     422    // FIXME: This doesn't work correctly with transforms.
     423    FloatPoint absPos = r->localToAbsolute();
     424    return absPos.y();
    423425}
    424426
  • trunk/WebCore/html/HTMLInputElement.cpp

    r38094 r38098  
    11841184            yPos = 0;
    11851185        } else {
    1186             int offsetX, offsetY;
    1187             renderer()->absolutePosition(offsetX, offsetY);
    1188             xPos = me->pageX() - offsetX;
    1189             // FIXME: Why is yPos a short?
    1190             yPos = me->pageY() - offsetY;
     1186            // FIXME: This doesn't work correctly with transforms.
     1187            IntPoint absOffset = roundedIntPoint(renderer()->localToAbsolute());
     1188            xPos = me->pageX() - absOffset.x();
     1189            yPos = me->pageY() - absOffset.y();
    11911190        }
    11921191    }
  • trunk/WebCore/html/HTMLInputElement.h

    r37863 r38098  
    229229    String m_originalValue;
    230230    int xPos;
     231    int yPos;
    231232    int m_maxLen;
    232     short m_size;
    233     short yPos;
     233    int m_size;
    234234
    235235    short m_maxResults;
  • trunk/WebCore/page/AccessibilityRenderObject.cpp

    r38094 r38098  
    921921    // FIXME: This doesn't work correctly with transforms.
    922922    Vector<IntRect> rects;
    923     int x, y;
    924     obj->absolutePosition(x, y);
    925     obj->absoluteRects(rects, x, y);
     923    FloatPoint absPos = obj->localToAbsolute();
     924    obj->absoluteRects(rects, absPos.x(), absPos.y());
    926925    const size_t n = rects.size();
    927926    for (size_t i = 0; i < n; ++i) {
  • trunk/WebCore/page/EventHandler.cpp

    r38094 r38098  
    20242024        // image and offset
    20252025        if (dragState().m_dragSrcIsDHTML) {
    2026             int srcX, srcY;
    20272026            if (RenderObject* renderer = dragState().m_dragSrc->renderer()) {
    2028                 renderer->absolutePosition(srcX, srcY);
    2029                 IntSize delta = m_mouseDownPos - IntPoint(srcX, srcY);
     2027                // FIXME: This doesn't work correctly with transforms.
     2028                FloatPoint absPos = renderer->localToAbsolute();
     2029                IntSize delta = m_mouseDownPos - roundedIntPoint(absPos);
    20302030                dragState().m_dragClipboard->setDragImageElement(dragState().m_dragSrc.get(), IntPoint() + delta);
    20312031            } else {
  • trunk/WebCore/platform/graphics/FloatPoint.h

    r35852 r38098  
    2929
    3030#include "FloatSize.h"
     31#include "IntPoint.h"
    3132#include <wtf/Platform.h>
    3233
     
    147148}
    148149
     150inline IntPoint roundedIntPoint(const FloatPoint& p)
     151{
     152    return IntPoint(static_cast<int>(roundf(p.x())), static_cast<int>(roundf(p.y())));
     153}
     154
    149155}
    150156
  • trunk/WebCore/platform/graphics/IntSize.h

    r31899 r38098  
    6868    bool isEmpty() const { return m_width <= 0 || m_height <= 0; }
    6969
     70    void expand(int width, int height)
     71    {
     72        m_width += width;
     73        m_height += height;
     74    }
     75   
    7076    IntSize expandedTo(const IntSize& other) const
    7177    {
  • trunk/WebCore/rendering/LayoutState.cpp

    r31735 r38098  
    4141    bool fixed = renderer->isPositioned() && renderer->style()->position() == FixedPosition;
    4242    if (fixed) {
    43         int fixedX = 0;
    44         int fixedY = 0;
    45         renderer->view()->absolutePosition(fixedX, fixedY, true);
    46         m_offset = IntSize(fixedX, fixedY) + offset;
     43        // FIXME: This doesn't work correctly with transforms.
     44        FloatPoint fixedOffset = renderer->view()->localToAbsolute(FloatPoint(), true);
     45        m_offset = IntSize(fixedOffset.x(), fixedOffset.y()) + offset;
    4746    } else
    4847        m_offset = prev->m_offset + offset;
    4948
    5049    if (renderer->isRelPositioned()) {
    51         if (renderer->hasLayer()) {
    52             int relX = 0;
    53             int relY = 0;
    54             renderer->layer()->relativePositionOffset(relX, relY);
    55             m_offset += IntSize(relX, relY);
    56         }
     50        if (renderer->hasLayer())
     51            m_offset += renderer->layer()->relativePositionOffset();
    5752    } else if (renderer->isPositioned() && !fixed) {
    5853        if (RenderObject* container = renderer->container())
     
    7570            m_clipped = true;
    7671        }
    77         layer->subtractScrollOffset(x, y);
     72        layer->subtractScrolledContentOffset(x, y);
    7873        m_offset = IntSize(x, y);
    7974    }
     
    8580{
    8681    RenderObject* container = root->container();
    87     int x = 0;
    88     int y = 0;
    89     container->absolutePositionForContent(x, y);
    90     m_offset = IntSize(x, y);
     82    // FIXME: this is broken with transforms?
     83    FloatPoint absContentPoint = container->localToAbsoluteForContent(FloatPoint());
     84    m_offset = IntSize(absContentPoint.x(), absContentPoint.y());
    9185    m_next = 0;
    9286}
  • trunk/WebCore/rendering/RenderBlock.cpp

    r37637 r38098  
    752752            int x = repaintRect.x();
    753753            int y = repaintRect.y();
    754             layer()->subtractScrollOffset(x, y);
     754            layer()->subtractScrolledContentOffset(x, y);
    755755            repaintRect.setX(x);
    756756            repaintRect.setY(y);
     
    16931693    int scrolledY = ty;
    16941694    if (hasOverflowClip())
    1695         m_layer->subtractScrollOffset(scrolledX, scrolledY);
     1695        m_layer->subtractScrolledContentOffset(scrolledX, scrolledY);
    16961696
    16971697    // 2. paint contents
     
    19021902        return GapRects();
    19031903
    1904     int tx, ty;
    1905     absolutePositionForContent(tx, ty);
     1904    // FIXME: this is broken with transforms
     1905    FloatPoint absContentPoint = localToAbsoluteForContent(FloatPoint());
    19061906    if (hasOverflowClip())
    1907         layer()->subtractScrollOffset(tx, ty);
     1907        absContentPoint -= layer()->scrolledContentOffset();
    19081908
    19091909    int lastTop = -borderTopExtra();
     
    19111911    int lastRight = rightSelectionOffset(this, lastTop);
    19121912   
    1913     return fillSelectionGaps(this, tx, ty, tx, ty, lastTop, lastLeft, lastRight);
     1913    return fillSelectionGaps(this, absContentPoint.x(), absContentPoint.y(), absContentPoint.x(), absContentPoint.y(), lastTop, lastLeft, lastRight);
    19141914}
    19151915
     
    20562056            // If the relposition offset is anything other than 0, then treat this just like an absolute positioned element.
    20572057            // Just disregard it completely.
    2058             int x = 0;
    2059             int y = 0;
    2060             curr->layer()->relativePositionOffset(x, y);
    2061             if (x || y)
     2058            IntSize relOffset = curr->layer()->relativePositionOffset();
     2059            if (relOffset.width() || relOffset.height())
    20622060                continue;
    20632061        }
     
    31413139        int scrolledY = ty;
    31423140        if (hasOverflowClip())
    3143             m_layer->subtractScrollOffset(scrolledX, scrolledY);
     3141            m_layer->subtractScrolledContentOffset(scrolledX, scrolledY);
    31443142
    31453143        // Hit test contents if we don't have columns.
     
    32963294    int contentsY = y - borderTopExtra();
    32973295    if (hasOverflowClip())
    3298         m_layer->scrollOffset(contentsX, contentsY);
     3296        m_layer->addScrolledContentOffset(contentsX, contentsY);
    32993297    if (m_hasColumns) {
    33003298        IntPoint contentsPoint(contentsX, contentsY);
  • trunk/WebCore/rendering/RenderBox.cpp

    r37731 r38098  
    992992}
    993993
    994 bool RenderBox::absolutePosition(int& xPos, int& yPos, bool fixed) const
     994FloatPoint RenderBox::localToAbsolute(FloatPoint localPoint, bool fixed, bool useTransforms) const
    995995{
    996996    if (RenderView* v = view()) {
    997997        if (LayoutState* layoutState = v->layoutState()) {
    998             xPos = layoutState->m_offset.width() + m_x;
    999             yPos = layoutState->m_offset.height() + m_y;
     998            IntSize offset = layoutState->m_offset;
     999            offset.expand(m_x, m_y);
     1000            localPoint += offset;
    10001001            if (style()->position() == RelativePosition && m_layer)
    1001                 m_layer->relativePositionOffset(xPos, yPos);
    1002             return true;
     1002                localPoint += m_layer->relativePositionOffset();
     1003            return localPoint;
    10031004        }
    10041005    }
     
    10081009
    10091010    RenderObject* o = container();
    1010     if (o && o->absolutePositionForContent(xPos, yPos, fixed)) {
    1011         if (style()->position() == AbsolutePosition) {
    1012             IntSize offset = offsetForPositionedInContainer(o);
    1013             xPos += offset.width();
    1014             yPos += offset.height();
    1015         }
    1016 
    1017         if (o->hasOverflowClip())
    1018             o->layer()->subtractScrollOffset(xPos, yPos);
     1011    if (o) {
     1012        if (useTransforms && m_layer && m_layer->transform()) {
     1013            fixed = false;  // Elements with transforms act as a containing block for fixed position descendants
     1014            localPoint = m_layer->transform()->mapPoint(localPoint);
     1015        }
     1016
     1017        if (isRelPositioned())
     1018            localPoint += relativePositionOffset();
    10191019
    10201020        if (!isInline() || isReplaced()) {
     
    10241024                IntRect rect(m_x, m_y, 1, 1);
    10251025                cb->adjustRectForColumns(rect);
    1026                 xPos += rect.x();
    1027                 yPos += rect.y();
    1028             } else {
    1029                 xPos += m_x;
    1030                 yPos += m_y;
    1031             }
    1032         }
    1033 
    1034         if (isRelPositioned()) {
    1035             xPos += relativePositionOffsetX();
    1036             yPos += relativePositionOffsetY();
    1037         }
    1038 
    1039         return true;
    1040     } else {
    1041         xPos = 0;
    1042         yPos = 0;
    1043         return false;
    1044     }
     1026                localPoint.move(rect.x(), rect.y());
     1027            } else
     1028                localPoint.move(m_x, m_y);
     1029        }
     1030
     1031        if (o->hasOverflowClip())
     1032            localPoint -= o->layer()->scrolledContentOffset();
     1033
     1034        if (style()->position() == AbsolutePosition)
     1035            localPoint += offsetForPositionedInContainer(o);
     1036
     1037        return o->localToAbsoluteForContent(localPoint, fixed, useTransforms);
     1038    }
     1039   
     1040    return FloatPoint();
    10451041}
    10461042
     
    11251121    if (RenderView* v = view()) {
    11261122        if (LayoutState* layoutState = v->layoutState()) {
    1127             if (style()->position() == RelativePosition && m_layer) {
    1128                 int relX = 0;
    1129                 int relY = 0;
    1130                 m_layer->relativePositionOffset(relX, relY);
    1131                 rect.move(relX, relY);
    1132             }
     1123            if (style()->position() == RelativePosition && m_layer)
     1124                rect.move(m_layer->relativePositionOffset());
     1125
    11331126            rect.move(m_x, m_y);
    11341127            rect.move(layoutState->m_offset);
     
    11481141    }
    11491142
    1150     int x = rect.x() + m_x;
    1151     int y = rect.y() + m_y;
     1143    IntPoint topLeft = rect.location();
     1144    topLeft.move(m_x, m_y);
    11521145
    11531146    // Apply the relative position offset when invalidating a rectangle.  The layer
     
    11561149    // flag on the RenderObject has been cleared, so use the one on the style().
    11571150    if (style()->position() == RelativePosition && m_layer)
    1158         m_layer->relativePositionOffset(x, y);
     1151        topLeft += m_layer->relativePositionOffset();
    11591152
    11601153    if (style()->position() == FixedPosition)
     
    11661159            RenderBlock* cb = static_cast<RenderBlock*>(o);
    11671160            if (cb->hasColumns()) {
    1168                 IntRect repaintRect(x, y, rect.width(), rect.height());
     1161                IntRect repaintRect(topLeft, rect.size());
    11691162                cb->adjustRectForColumns(repaintRect);
    1170                 x = repaintRect.x();
    1171                 y = repaintRect.y();
     1163                topLeft = repaintRect.location();
    11721164                rect = repaintRect;
    11731165            }
    11741166        }
    11751167
    1176         if (style()->position() == AbsolutePosition) {
    1177             IntSize offset = offsetForPositionedInContainer(o);
    1178             x += offset.width();
    1179             y += offset.height();
    1180         }
     1168        if (style()->position() == AbsolutePosition)
     1169            topLeft += offsetForPositionedInContainer(o);
    11811170       
    11821171        // We are now in our parent container's coordinate space.  Apply our transform to obtain a bounding box
     
    11851174            fixed = false;
    11861175            rect = m_layer->transform()->mapRect(rect);
    1187             x = rect.x() + m_x;
    1188             y = rect.y() + m_y;
     1176            topLeft = rect.location();
     1177            topLeft.move(m_x, m_y);
    11891178        }
    11901179
     
    11961185            // anyway if its size does change.
    11971186            IntRect boxRect(0, 0, o->layer()->width(), o->layer()->height());
    1198             o->layer()->subtractScrollOffset(x, y); // For overflow:auto/scroll/hidden.
    1199             IntRect repaintRect(x, y, rect.width(), rect.height());
     1187            int x = 0, y = 0;
     1188            o->layer()->subtractScrolledContentOffset(x, y); // For overflow:auto/scroll/hidden.
     1189            topLeft.move(x, y);
     1190            IntRect repaintRect(topLeft, rect.size());
    12001191            rect = intersection(repaintRect, boxRect);
    12011192            if (rect.isEmpty())
    12021193                return;
    1203         } else {
    1204             rect.setX(x);
    1205             rect.setY(y);
    1206         }
     1194        } else
     1195            rect.setLocation(topLeft);
    12071196       
    12081197        o->computeAbsoluteRepaintRect(rect, fixed);
     
    26762665
    26772666    RenderObject* cb = containingBlock();
    2678     int cbx, cby;
    2679     if (!cb || !cb->absolutePosition(cbx, cby))
     2667    if (!cb)
    26802668        // No point returning a relative position.
    26812669        return IntRect();
    26822670
     2671    FloatPoint absPos = cb->localToAbsolute();
     2672
    26832673    if (extraWidthToEndOfLine)
    26842674        *extraWidthToEndOfLine = xPos() + m_width - rect.right();
    26852675
    2686     rect.move(cbx, cby);
     2676    rect.move(absPos.x(), absPos.y());
    26872677    return rect;
    26882678}
  • trunk/WebCore/rendering/RenderBox.h

    r37464 r38098  
    5050    virtual void setOverrideSize(int);
    5151
    52     virtual bool absolutePosition(int& x, int& y, bool fixed = false) const;
     52    virtual FloatPoint localToAbsolute(FloatPoint localPoint = FloatPoint(), bool fixed = false, bool useTransforms = false) const;
    5353
    5454    virtual int xPos() const { return m_x; }
     
    136136    int relativePositionOffsetX() const;
    137137    int relativePositionOffsetY() const;
    138 
     138    IntSize relativePositionOffset() const { return IntSize(relativePositionOffsetX(), relativePositionOffsetY()); }
     139   
    139140    virtual RenderLayer* layer() const { return m_layer; }
    140141
  • trunk/WebCore/rendering/RenderContainer.cpp

    r37637 r38098  
    663663{
    664664    if (!m_firstChild && (isInline() || isAnonymousBlock())) {
    665         int x, y;
    666         absolutePositionForContent(x, y);
    667         absoluteRects(rects, x, y);
     665        FloatPoint absPos = localToAbsoluteForContent(FloatPoint());
     666        absoluteRects(rects, absPos.x(), absPos.y());
    668667        return;
    669668    }
     
    675674    for (RenderObject* child = childAt(start); child && offset < end; child = child->nextSibling(), ++offset) {
    676675        if (child->isText() || child->isInline() || child->isAnonymousBlock()) {
    677             int x, y;
    678             child->absolutePositionForContent(x, y);
    679             child->absoluteRects(rects, x, y);
     676            FloatPoint absPos = child->localToAbsoluteForContent(FloatPoint());
     677            child->absoluteRects(rects, absPos.x(), absPos.y());
    680678        }
    681679    }
  • trunk/WebCore/rendering/RenderFlow.cpp

    r37637 r38098  
    523523            int y = r.y();
    524524            IntRect boxRect(0, 0, cb->layer()->width(), cb->layer()->height());
    525             cb->layer()->subtractScrollOffset(x, y); // For overflow:auto/scroll/hidden.
     525            cb->layer()->subtractScrolledContentOffset(x, y); // For overflow:auto/scroll/hidden.
    526526            IntRect repaintRect(x, y, r.width(), r.height());
    527527            r = intersection(repaintRect, boxRect);
     
    685685
    686686            int myRight = x + caretWidth;
    687             int ignore;
    688             absolutePositionForContent(myRight, ignore);
     687            // FIXME: why call localToAbsoluteForContent() twice here, too?
     688            FloatPoint absRightPoint = localToAbsoluteForContent(FloatPoint(myRight, 0));
    689689
    690690            int containerRight = containingBlock()->xPos() + containingBlockWidth();
    691             absolutePositionForContent(containerRight, ignore);
    692 
    693             *extraWidthToEndOfLine = containerRight - myRight;
    694         }
    695     }
    696 
    697     int absx, absy;
    698     absolutePositionForContent(absx, absy);
    699     x += absx;
    700     int y = absy + paddingTop() + borderTop();
     691            FloatPoint absContainerPoint = localToAbsoluteForContent(FloatPoint(containerRight, 0));
     692
     693            *extraWidthToEndOfLine = absContainerPoint.x() - absRightPoint.x();
     694        }
     695    }
     696
     697    FloatPoint absPos = localToAbsoluteForContent(FloatPoint());
     698    x += absPos.x();
     699    int y = absPos.y() + paddingTop() + borderTop();
    701700
    702701    return IntRect(x, y, caretWidth, height);
     
    724723        for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling())
    725724            if (!curr->isText() && !curr->isListMarker()) {
    726                 int x = 0;
    727                 int y = 0;
     725                FloatPoint pos;
     726                // FIXME: This doesn't work correctly with transforms.
    728727                if (curr->layer())
    729                     curr->absolutePosition(x, y);
    730                 else {
    731                     x = tx + curr->xPos();
    732                     y = ty + curr->yPos();
    733                 }
    734                 curr->addFocusRingRects(graphicsContext, x, y);
     728                    pos = curr->localToAbsolute();
     729                else
     730                    pos = FloatPoint(tx + curr->xPos(), ty + curr->yPos());
     731                curr->addFocusRingRects(graphicsContext, pos.x(), pos.y());
    735732            }
    736733    }
  • trunk/WebCore/rendering/RenderLayer.cpp

    r38094 r38098  
    410410
    411411        // For positioned layers, we subtract out the enclosing positioned layer's scroll offset.
    412         positionedParent->subtractScrollOffset(x, y);
     412        positionedParent->subtractScrolledContentOffset(x, y);
    413413       
    414414        if (m_object->isPositioned()) {
     
    418418        }
    419419    } else if (parent())
    420         parent()->subtractScrollOffset(x, y);
     420        parent()->subtractScrolledContentOffset(x, y);
    421421   
    422422    setPos(x,y);
     
    688688    if (m_object->style()->position() == FixedPosition) {
    689689        // Add in the offset of the view.  We can obtain this by calling
    690         // absolutePosition() on the RenderView.
    691         int xOff, yOff;
    692         m_object->absolutePosition(xOff, yOff, true);
    693         x += xOff;
    694         y += yOff;
     690        // localToAbsolute() on the RenderView.
     691        FloatPoint absPos = m_object->localToAbsolute(FloatPoint(), true);
     692        x += absPos.x();
     693        y += absPos.y();
    695694        return;
    696695    }
     
    773772
    774773void
    775 RenderLayer::scrollOffset(int& x, int& y)
     774RenderLayer::addScrolledContentOffset(int& x, int& y) const
    776775{
    777776    x += scrollXOffset() + m_scrollLeftOverflow;
     
    780779
    781780void
    782 RenderLayer::subtractScrollOffset(int& x, int& y)
     781RenderLayer::subtractScrolledContentOffset(int& x, int& y) const
    783782{
    784783    x -= scrollXOffset() + m_scrollLeftOverflow;
     
    866865        // Don't scroll to reveal an overflow layer that is restricted by the -webkit-line-clamp property.
    867866        // This will prevent us from revealing text hidden by the slider in Safari RSS.
    868         int x, y;
    869         m_object->absolutePosition(x, y);
    870         x += m_object->borderLeft();
    871         y += m_object->borderTop();
    872 
    873         IntRect layerBounds = IntRect(x + scrollXOffset(), y + scrollYOffset(), m_object->clientWidth(), m_object->clientHeight());
     867        FloatPoint absPos = m_object->localToAbsolute();
     868        absPos.move(m_object->borderLeft(), m_object->borderTop());
     869
     870        IntRect layerBounds = IntRect(absPos.x() + scrollXOffset(), absPos.y() + scrollYOffset(), m_object->clientWidth(), m_object->clientHeight());
    874871        IntRect exposeRect = IntRect(rect.x() + scrollXOffset(), rect.y() + scrollYOffset(), rect.width(), rect.height());
    875872        IntRect r = getRectToExpose(layerBounds, exposeRect, alignX, alignY);
    876873       
    877         xOffset = r.x() - x;
    878         yOffset = r.y() - y;
     874        xOffset = r.x() - absPos.x();
     875        yOffset = r.y() - absPos.y();
    879876        // Adjust offsets if they're outside of the allowable range.
    880877        xOffset = max(0, min(scrollWidth() - layerBounds.width(), xOffset));
  • trunk/WebCore/rendering/RenderLayer.h

    r37562 r38098  
    209209    // Scrolling methods for layers that can scroll their overflow.
    210210    void scrollByRecursively(int xDelta, int yDelta);
    211     void scrollOffset(int& x, int& y);
    212     void subtractScrollOffset(int& x, int& y);
     211    void addScrolledContentOffset(int& x, int& y) const;
     212    void subtractScrolledContentOffset(int& x, int& y) const;
     213    IntSize scrolledContentOffset() const { return IntSize(scrollXOffset() + m_scrollLeftOverflow, scrollYOffset()); }
     214
    213215    int scrollXOffset() const { return m_scrollX + m_scrollOriginX; }
    214216    int scrollYOffset() const { return m_scrollY; }
     217
    215218    void scrollToOffset(int x, int y, bool updateScrollbars = true, bool repaint = true);
    216219    void scrollToXOffset(int x) { scrollToOffset(x, m_scrollY); }
     
    255258    void updateTransform();
    256259
    257     void relativePositionOffset(int& relX, int& relY) { relX += m_relX; relY += m_relY; }
     260    void relativePositionOffset(int& relX, int& relY) const { relX += m_relX; relY += m_relY; }
     261    IntSize relativePositionOffset() const { return IntSize(m_relX, m_relY); }
    258262
    259263    void clearClipRects();
     
    401405    int m_scrollX;
    402406    int m_scrollY;
    403     int m_scrollOriginX;
    404     int m_scrollLeftOverflow;
     407    int m_scrollOriginX;        // only non-zero for rtl content
     408    int m_scrollLeftOverflow;   // only non-zero for rtl content
    405409
    406410    // The width/height of our scrolled area.
  • trunk/WebCore/rendering/RenderListBox.cpp

    r38094 r38098  
    402402    const int speedReducer = 4;
    403403
    404     int offsetX;
    405     int offsetY;
    406     absolutePosition(offsetX, offsetY);
     404    // FIXME: This doesn't work correctly with transforms.
     405    FloatPoint absOffset = localToAbsolute();
    407406
    408407    IntPoint currentMousePosition = document()->frame()->eventHandler()->currentMousePosition();
     
    424423    if (yDelta > 0)
    425424        //offsetY = view()->viewHeight();
    426         offsetY += listHeight();
     425        absOffset.move(0, listHeight());
    427426   else if (yDelta < 0)
    428427       yDelta--;
     
    432431
    433432    IntPoint scrollPoint(0,0);
    434     scrollPoint.setY(offsetY + yDelta);
     433    scrollPoint.setY(absOffset.y() + yDelta);
    435434    int newOffset = scrollToward(scrollPoint);
    436435    if (newOffset < 0)
     
    445444int RenderListBox::scrollToward(const IntPoint& destination)
    446445{
    447     int rx = 0;
    448     int ry = 0;
    449     absolutePosition(rx, ry);
    450     int offsetX = destination.x() - rx;
    451     int offsetY = destination.y() - ry;
     446    // FIXME: This doesn't work correctly with transforms.
     447    FloatPoint absPos = localToAbsolute();
     448    int offsetX = destination.x() - absPos.x();
     449    int offsetY = destination.y() - absPos.y();
    452450
    453451    int rows = numVisibleItems();
  • trunk/WebCore/rendering/RenderListMarker.cpp

    r37464 r38098  
    896896        computeAbsoluteRepaintRect(rect);
    897897    else {
    898         int absx, absy;
    899         absolutePosition(absx, absy);
    900         rect.move(absx, absy);
     898        FloatPoint absPos = localToAbsolute();
     899        rect.move(absPos.x(), absPos.y());
    901900    }
    902901   
  • trunk/WebCore/rendering/RenderObject.cpp

    r38094 r38098  
    17071707IntRect RenderObject::absoluteBoundingBoxRect()
    17081708{
    1709     int x, y;
    1710     absolutePosition(x, y);
     1709    // FIXME: This doesn't work correctly with transforms.
     1710    FloatPoint absPos = localToAbsolute();
    17111711    Vector<IntRect> rects;
    1712     absoluteRects(rects, x, y);
     1712    absoluteRects(rects, absPos.x(), absPos.y());
    17131713
    17141714    size_t n = rects.size();
     
    20082008            int x = rect.x();
    20092009            int y = rect.y();
    2010             o->layer()->subtractScrollOffset(x, y); // For overflow:auto/scroll/hidden.
     2010            o->layer()->subtractScrolledContentOffset(x, y); // For overflow:auto/scroll/hidden.
    20112011            IntRect repaintRect(x, y, rect.width(), rect.height());
    20122012            rect = intersection(repaintRect, boxRect);
     
    23732373}
    23742374
    2375 bool RenderObject::absolutePosition(int& xPos, int& yPos, bool f) const
     2375FloatPoint RenderObject::localToAbsolute(FloatPoint localPoint, bool fixed, bool useTransforms) const
    23762376{
    23772377    RenderObject* o = parent();
    23782378    if (o) {
    2379         o->absolutePosition(xPos, yPos, f);
    2380         yPos += o->borderTopExtra();
     2379        localPoint.move(0.0f, static_cast<float>(o->borderTopExtra()));
    23812380        if (o->hasOverflowClip())
    2382             o->layer()->subtractScrollOffset(xPos, yPos);
    2383         return true;
    2384     } else {
    2385         xPos = yPos = 0;
    2386         return false;
    2387     }
     2381            localPoint -= o->layer()->scrolledContentOffset();
     2382        return o->localToAbsolute(localPoint, fixed, useTransforms);
     2383    }
     2384
     2385    return FloatPoint();
    23882386}
    23892387
     
    29342932        }
    29352933
    2936         int x, y;
    2937         absolutePosition(x, y);
    2938         region.bounds.setX(x + styleRegion.offset.left().value());
    2939         region.bounds.setY(y + styleRegion.offset.top().value());
     2934        FloatPoint absPos = localToAbsolute();
     2935        region.bounds.setX(absPos.x() + styleRegion.offset.left().value());
     2936        region.bounds.setY(absPos.y() + styleRegion.offset.top().value());
    29402937
    29412938        if (document()->frame()) {
     
    30563053{
    30573054    IntRect rect = contentBox();
    3058     int x, y;
    3059     absolutePositionForContent(x, y);
    3060     rect.move(x, y);
     3055    FloatPoint absPos = localToAbsoluteForContent(FloatPoint());
     3056    rect.move(absPos.x(), absPos.y());
    30613057    return rect;
    30623058}
     
    30903086{
    30913087    IntRect box = borderBox();
    3092     int x, y;
    3093     absolutePosition(x, y);
    3094     box.move(x, y);
     3088    FloatPoint absPos = localToAbsolute();
     3089    box.move(absPos.x(), absPos.y());
    30953090    box.move(view()->layoutDelta());
    30963091    adjustRectForOutlineAndShadow(box);
  • trunk/WebCore/rendering/RenderObject.h

    r37637 r38098  
    581581    virtual int yPos() const { return 0; }
    582582
    583     // calculate client position of box
    584     virtual bool absolutePosition(int& x, int& y, bool fixed = false) const;
     583    // Convert the given local point to absolute coordinates
     584    // FIXME: Temporary. If useTransforms is true, take transforms into account. Eventually localToAbsolute() will always be transform-aware.
     585    virtual FloatPoint localToAbsolute(FloatPoint localPoint = FloatPoint(), bool fixed = false, bool useTransforms = false) const;
    585586
    586587    // This function is used to deal with the extra top space that can occur in table cells (called borderTopExtra).
    587588    // The children of the cell do not factor this space in, so we have to add it in.  Any code that wants to
    588589    // accurately deal with the contents of a cell must call this function instad of absolutePosition.
    589     bool absolutePositionForContent(int& xPos, int& yPos, bool fixed = false) const
     590    FloatPoint localToAbsoluteForContent(FloatPoint localPoint = FloatPoint(), bool fixed = false, bool useTransforms = false) const
    590591    {
    591         bool result = absolutePosition(xPos, yPos, fixed);
    592         yPos += borderTopExtra();
    593         return result;
     592        localPoint.move(0.0f, static_cast<float>(borderTopExtra()));
     593        return localToAbsolute(localPoint, fixed, useTransforms);
    594594    }
    595595
  • trunk/WebCore/rendering/RenderPart.cpp

    r36995 r38098  
    8989        return;
    9090   
    91     int x, y, width, height;
    92     absolutePosition(x, y);
    93     x += borderLeft() + paddingLeft();
    94     y += borderTop() + paddingTop();
     91    int width, height;
     92    FloatPoint absPos = localToAbsolute();
     93    absPos.move(borderLeft() + paddingLeft(), borderTop() + paddingTop());
    9594    width = m_width - borderLeft() - borderRight() - paddingLeft() - paddingRight();
    9695    height = m_height - borderTop() - borderBottom() - paddingTop() - paddingBottom();
    97     IntRect newBounds(x,y,width,height);
     96    IntRect newBounds(absPos.x(), absPos.y(), width, height);
    9897    bool boundsChanged = newBounds != m_widget->frameRect();
    9998    if (boundsChanged) {
  • trunk/WebCore/rendering/RenderReplaced.cpp

    r37464 r38098  
    259259        computeAbsoluteRepaintRect(rect);
    260260    else {
    261         int absx, absy;
    262         absolutePositionForContent(absx, absy);
    263         rect.move(absx, absy);
     261        FloatPoint absPos = localToAbsoluteForContent(FloatPoint());
     262        rect.move(absPos.x(), absPos.y());
    264263    }
    265264   
  • trunk/WebCore/rendering/RenderSVGInlineText.cpp

    r34766 r38098  
    108108
    109109    // Mimic RenderBox::computeAbsoluteRepaintRect() functionality. But only the subset needed for SVG and respecting SVG transformations.
    110     int x, y;
    111     cb->container()->absolutePosition(x, y);
     110    FloatPoint absPos = cb->container()->localToAbsolute();
    112111
    113112    // Remove HTML parent translation offsets here! These need to be retrieved from the RenderSVGRoot object.
     
    115114    AffineTransform htmlParentCtm = root->RenderContainer::absoluteTransform();
    116115
    117     FloatRect fixedRect(narrowPrecisionToFloat(rect.x() + x - xPos() - htmlParentCtm.e()), narrowPrecisionToFloat(rect.y() + y - yPos() - htmlParentCtm.f()), rect.width(), rect.height());
     116    FloatRect fixedRect(narrowPrecisionToFloat(rect.x() + absPos.x() - xPos() - htmlParentCtm.e()),
     117                        narrowPrecisionToFloat(rect.y() + absPos.y() - yPos() - htmlParentCtm.f()), rect.width(), rect.height());
    118118    return enclosingIntRect(absoluteTransform().mapRect(fixedRect));
    119119}
  • trunk/WebCore/rendering/RenderSVGText.cpp

    r35204 r38098  
    152152        return;
    153153
    154     int x, y;
    155     absolutePosition(x, y);
     154    FloatPoint absPos = localToAbsolute();
    156155
    157156    AffineTransform htmlParentCtm = root->RenderContainer::absoluteTransform();
     
    165164        for (InlineBox* box = flowBox->firstChild(); box; box = box->nextOnLine()) {
    166165            FloatRect boxRect(box->xPos(), box->yPos(), box->width(), box->height());
    167             boxRect.move(narrowPrecisionToFloat(x - htmlParentCtm.e()), narrowPrecisionToFloat(y - htmlParentCtm.f()));
     166            boxRect.move(narrowPrecisionToFloat(absPos.x() - htmlParentCtm.e()), narrowPrecisionToFloat(absPos.y() - htmlParentCtm.f()));
    168167            rects.append(enclosingIntRect(absoluteTransform().mapRect(boxRect)));
    169168        }
  • trunk/WebCore/rendering/RenderTableCell.cpp

    r37464 r38098  
    197197}
    198198
    199 bool RenderTableCell::absolutePosition(int& xPos, int& yPos, bool fixed) const
    200 {
    201     bool result = RenderBlock::absolutePosition(xPos, yPos, fixed);
     199FloatPoint RenderTableCell::localToAbsolute(FloatPoint localPoint, bool fixed, bool useTransforms) const
     200{
     201    FloatPoint result = RenderBlock::localToAbsolute(localPoint, fixed, useTransforms);
    202202    RenderView* v = view();
    203203    if ((!v || !v->layoutState()) && parent()) {
    204         xPos -= parent()->xPos(); // Rows are in the same coordinate space, so don't add their offset in.
    205         yPos -= parent()->yPos();
     204        // Rows are in the same coordinate space, so don't add their offset in.
     205        result.move(-parent()->xPos(), -parent()->yPos());
    206206    }
    207207    return result;
  • trunk/WebCore/rendering/RenderTableCell.h

    r37464 r38098  
    102102    virtual IntRect absoluteClippedOverflowRect();
    103103    virtual void computeAbsoluteRepaintRect(IntRect&, bool fixed = false);
    104     virtual bool absolutePosition(int& x, int& y, bool fixed = false) const;
     104    virtual FloatPoint localToAbsolute(FloatPoint localPoint = FloatPoint(), bool fixed = false, bool useTransforms = false) const;
    105105
    106106    virtual int baselinePosition(bool firstLine = false, bool isRootLineBox = false) const;
  • trunk/WebCore/rendering/RenderText.cpp

    r37464 r38098  
    215215    end = min(end, static_cast<unsigned>(INT_MAX));
    216216   
    217     int x, y;
    218     absolutePositionForContent(x, y);
     217    FloatPoint absPos = localToAbsoluteForContent(FloatPoint());
    219218
    220219    for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) {
    221220        // Note: box->end() returns the index of the last character, not the index past it
    222221        if (start <= box->start() && box->end() < end) {
    223             IntRect r = IntRect(x + box->xPos(), y + box->yPos(), box->width(), box->height());
     222            IntRect r = IntRect(absPos.x() + box->xPos(), absPos.y() + box->yPos(), box->width(), box->height());
    224223            if (useSelectionHeight) {
    225                 IntRect selectionRect = box->selectionRect(x, y, start, end);
     224                IntRect selectionRect = box->selectionRect(absPos.x(), absPos.y(), start, end);
    226225                r.setHeight(selectionRect.height());
    227226                r.setY(selectionRect.y());
     
    230229        } else {
    231230            unsigned realEnd = min(box->end() + 1, end);
    232             IntRect r = box->selectionRect(x, y, start, realEnd);
     231            IntRect r = box->selectionRect(absPos.x(), absPos.y(), start, realEnd);
    233232            if (!r.isEmpty()) {
    234233                if (!useSelectionHeight) {
    235234                    // change the height and y position because selectionRect uses selection-specific values
    236235                    r.setHeight(box->height());
    237                     r.setY(y + box->yPos());
     236                    r.setY(absPos.y() + box->yPos());
    238237                }
    239238                rects.append(r);
     
    343342        *extraWidthToEndOfLine = (box->root()->width() + rootLeft) - (left + 1);
    344343
    345     int absx, absy;
    346     absolutePositionForContent(absx, absy);
    347     left += absx;
    348     top += absy;
     344    // FIXME: broken with transforms
     345    FloatPoint absPos = localToAbsoluteForContent(FloatPoint());
     346    left += absPos.x();
     347    top += absPos.y();
    349348
    350349    RenderBlock* cb = containingBlock();
     
    352351        int availableWidth = cb->lineWidth(top);
    353352        if (box->direction() == LTR)
    354             left = min(left, absx + rootLeft + availableWidth - 1);
     353            left = min(left, static_cast<int>(absPos.x()) + rootLeft + availableWidth - 1);
    355354        else
    356             left = max(left, absx + rootLeft);
     355            left = max(left, static_cast<int>(absPos.x()) + rootLeft);
    357356    }
    358357
     
    10801079        if (cb->hasColumns())
    10811080            cb->adjustRectForColumns(rect);
    1082         int absx, absy;
    1083         absolutePosition(absx, absy);
    1084         rect.move(absx, absy);
     1081        // FIXME: This doesn't work correctly with transforms.
     1082        FloatPoint absPos = localToAbsolute();
     1083        rect.move(absPos.x(), absPos.y());
    10851084    }
    10861085
  • trunk/WebCore/rendering/RenderVideo.cpp

    r36957 r38098  
    125125        return;
    126126    }
    127     int x;
    128     int y;
    129     absolutePosition(x, y);
     127   
     128    // FIXME: This doesn't work correctly with transforms.
     129    FloatPoint absPos = localToAbsolute();
    130130    IntRect videoBounds = videoBox();
    131     videoBounds.move(x, y);
     131    videoBounds.move(absPos.x(), absPos.y());
    132132    mediaPlayer->setFrameView(document()->view());
    133133    mediaPlayer->setRect(videoBounds);
  • trunk/WebCore/rendering/RenderView.cpp

    r37758 r38098  
    132132}
    133133
    134 bool RenderView::absolutePosition(int& xPos, int& yPos, bool fixed) const
    135 {
    136     if (fixed && m_frameView) {
    137         xPos = m_frameView->scrollX();
    138         yPos = m_frameView->scrollY();
    139     } else
    140         xPos = yPos = 0;
    141     return true;
     134FloatPoint RenderView::localToAbsolute(FloatPoint localPoint, bool fixed, bool useTransforms) const
     135{
     136    if (fixed && m_frameView)
     137        localPoint += m_frameView->scrollOffset();
     138
     139    return localPoint;
    142140}
    143141
  • trunk/WebCore/rendering/RenderView.h

    r37758 r38098  
    4545    virtual void calcHeight();
    4646    virtual void calcPrefWidths();
    47     virtual bool absolutePosition(int& xPos, int& yPos, bool fixed = false) const;
     47    virtual FloatPoint localToAbsolute(FloatPoint localPoint = FloatPoint(), bool fixed = false, bool useTransforms = false) const;
    4848   
    4949    int docHeight() const;
  • trunk/WebCore/rendering/RenderWidget.cpp

    r38094 r38098  
    219219        return;
    220220
    221     int x;
    222     int y;
    223     absolutePosition(x, y);
    224     x += borderLeft() + paddingLeft();
    225     y += borderTop() + paddingTop();
     221    // FIXME: This doesn't work correctly with transforms.
     222    FloatPoint absPos = localToAbsolute();
     223    absPos.move(borderLeft() + paddingLeft(), borderTop() + paddingTop());
    226224
    227225    int width = m_width - borderLeft() - borderRight() - paddingLeft() - paddingRight();
    228226    int height = m_height - borderTop() - borderBottom() - paddingTop() - paddingBottom();
    229227
    230     IntRect newBounds(x, y, width, height);
     228    IntRect newBounds(absPos.x(), absPos.y(), width, height);
    231229    IntRect oldBounds(m_widget->frameRect());
    232230    if (newBounds != oldBounds) {
  • trunk/WebCore/svg/SVGSVGElement.cpp

    r38094 r38098  
    398398{
    399399    document()->updateLayoutIgnorePendingStylesheets();
    400     float rootX = 0.0f;
    401     float rootY = 0.0f;
    402    
     400    FloatPoint rootLocation;   
     401
    403402    if (RenderObject* renderer = this->renderer()) {
    404403        if (isOutermostSVG()) {
    405             int tx = 0;
    406             int ty = 0;
     404            // FIXME: This doesn't work correctly with CSS transforms.
     405            FloatPoint point;
    407406            if (renderer->parent())
    408                 renderer->absolutePosition(tx, ty, true);
    409             rootX += tx;
    410             rootY += ty;
    411         } else {
    412             rootX += x().value(this);
    413             rootY += y().value(this);
    414         }
     407                point = renderer->localToAbsolute(point, true);
     408            rootLocation.move(point.x(), point.y());
     409        } else
     410            rootLocation.move(x().value(this), y().value(this));
    415411    }
    416412   
    417413    AffineTransform mat = SVGStyledLocatableElement::getScreenCTM();
    418     mat.translate(rootX, rootY);
     414    mat.translate(rootLocation.x(), rootLocation.y());
    419415
    420416    if (attributes()->getNamedItem(SVGNames::viewBoxAttr)) {
  • trunk/WebKit/mac/ChangeLog

    r38094 r38098  
     12008-11-04  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Reviewed by Dave Hyatt
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=21941
     6
     7        Rename absolutePosition() to localToAbsolute(), and add the ability
     8        to optionally take transforms into account (which will eventually be the
     9        default behavior).
     10
     11        * WebView/WebRenderNode.mm:
     12        (copyRenderNode):
     13
    1142008-11-01  Alexey Proskuryakov  <ap@webkit.org>
    215
  • trunk/WebKit/mac/WebView/WebRenderNode.mm

    r36553 r38098  
    8787    NSView *view = widget ? widget->platformWidget() : nil;
    8888
    89     int nx, ny;
    90     node->absolutePosition(nx, ny);
     89    // FIXME: broken with transforms
     90    FloatPoint absPos = node->localToAbsolute(FloatPoint());
    9191    WebRenderNode *result = [[WebRenderNode alloc] initWithName:name
    92         position:NSMakePoint(nx, ny) rect:NSMakeRect(node->xPos(), node->yPos(), node->width(), node->height())
     92        position:absPos rect:NSMakeRect(node->xPos(), node->yPos(), node->width(), node->height())
    9393        view:view children:children];
    9494
Note: See TracChangeset for help on using the changeset viewer.