Changeset 100059 in webkit


Ignore:
Timestamp:
Nov 11, 2011 6:53:52 PM (12 years ago)
Author:
leviw@chromium.org
Message:

Revert Page to operate on integers
https://bugs.webkit.org/show_bug.cgi?id=72185

Reviewed by Eric Seidel.

Reverting the page classes to integers from LayoutUnits. It's not necessary to expose
LayoutUnits in these classes, so we'll avoid doing so.

No new tests, no change in behavior.

  • page/EventHandler.cpp:

(WebCore::EventHandler::handleMousePressEvent):
(WebCore::EventHandler::sendContextMenuEventForKey):
(WebCore::EventHandler::dragHysteresisExceeded):
(WebCore::EventHandler::handleDrag):

  • page/EventHandler.h:
  • page/Frame.cpp:

(WebCore::Frame::documentAtPoint):

  • page/Frame.h:
  • page/FrameView.cpp:

(WebCore::FrameView::create):
(WebCore::FrameView::invalidateRect):
(WebCore::FrameView::setFrameRect):
(WebCore::FrameView::setContentsSize):
(WebCore::FrameView::adjustViewSize):
(WebCore::FrameView::repaintContentRectangle):
(WebCore::FrameView::invalidateScrollbarRect):
(WebCore::FrameView::getTickmarks):
(WebCore::FrameView::windowResizerRect):
(WebCore::FrameView::setVisibleScrollerThumbRect):
(WebCore::FrameView::updateScrollCorner):
(WebCore::FrameView::paintScrollCorner):
(WebCore::FrameView::paintContents):
(WebCore::FrameView::paintOverhangAreas):
(WebCore::FrameView::convertFromRenderer):
(WebCore::FrameView::convertToRenderer):
(WebCore::FrameView::convertToContainingView):
(WebCore::FrameView::convertFromContainingView):

  • page/FrameView.h:
  • page/Page.cpp:

(WebCore::Page::setPageScaleFactor):

  • page/Page.h:
  • page/SpatialNavigation.cpp:

(WebCore::scrollInDirection):

Location:
trunk/Source/WebCore
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r100057 r100059  
     12011-11-11  Levi Weintraub  <leviw@chromium.org>
     2
     3        Revert Page to operate on integers
     4        https://bugs.webkit.org/show_bug.cgi?id=72185
     5
     6        Reviewed by Eric Seidel.
     7
     8        Reverting the page classes to integers from LayoutUnits. It's not necessary to expose
     9        LayoutUnits in these classes, so we'll avoid doing so.
     10
     11        No new tests, no change in behavior.
     12
     13        * page/EventHandler.cpp:
     14        (WebCore::EventHandler::handleMousePressEvent):
     15        (WebCore::EventHandler::sendContextMenuEventForKey):
     16        (WebCore::EventHandler::dragHysteresisExceeded):
     17        (WebCore::EventHandler::handleDrag):
     18        * page/EventHandler.h:
     19        * page/Frame.cpp:
     20        (WebCore::Frame::documentAtPoint):
     21        * page/Frame.h:
     22        * page/FrameView.cpp:
     23        (WebCore::FrameView::create):
     24        (WebCore::FrameView::invalidateRect):
     25        (WebCore::FrameView::setFrameRect):
     26        (WebCore::FrameView::setContentsSize):
     27        (WebCore::FrameView::adjustViewSize):
     28        (WebCore::FrameView::repaintContentRectangle):
     29        (WebCore::FrameView::invalidateScrollbarRect):
     30        (WebCore::FrameView::getTickmarks):
     31        (WebCore::FrameView::windowResizerRect):
     32        (WebCore::FrameView::setVisibleScrollerThumbRect):
     33        (WebCore::FrameView::updateScrollCorner):
     34        (WebCore::FrameView::paintScrollCorner):
     35        (WebCore::FrameView::paintContents):
     36        (WebCore::FrameView::paintOverhangAreas):
     37        (WebCore::FrameView::convertFromRenderer):
     38        (WebCore::FrameView::convertToRenderer):
     39        (WebCore::FrameView::convertToContainingView):
     40        (WebCore::FrameView::convertFromContainingView):
     41        * page/FrameView.h:
     42        * page/Page.cpp:
     43        (WebCore::Page::setPageScaleFactor):
     44        * page/Page.h:
     45        * page/SpatialNavigation.cpp:
     46        (WebCore::scrollInDirection):
     47
    1482011-11-11  Dominic Mazzoni  <dmazzoni@google.com>
    249
  • trunk/Source/WebCore/page/EventHandler.cpp

    r99755 r100059  
    13991399    // Save the document point we generate in case the window coordinate is invalidated by what happens
    14001400    // when we dispatch the event.
    1401     LayoutPoint documentPoint = documentPointForWindowPoint(m_frame, mouseEvent.pos());
     1401    IntPoint documentPoint = documentPointForWindowPoint(m_frame, mouseEvent.pos());
    14021402    MouseEventWithHitTestResults mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mouseEvent);
    14031403
     
    14461446    if (FrameView* view = m_frame->view()) {
    14471447        RenderLayer* layer = m_clickNode->renderer() ? m_clickNode->renderer()->enclosingLayer() : 0;
    1448         LayoutPoint p = view->windowToContents(mouseEvent.pos());
     1448        IntPoint p = view->windowToContents(mouseEvent.pos());
    14491449        if (layer && layer->isPointInResizeControl(p)) {
    14501450            layer->setInResizeMode(true);
     
    23092309    int rightAligned = 0;
    23102310#endif
    2311     LayoutPoint location;
     2311    IntPoint location;
    23122312
    23132313    Node* focusedNode = doc->focusedNode();
     
    23172317    if (start.deprecatedNode() && (selection->rootEditableElement() || selection->isRange())) {
    23182318        RefPtr<Range> selectionRange = selection->toNormalizedRange();
    2319         LayoutRect firstRect = m_frame->editor()->firstRectForRange(selectionRange.get());
    2320 
    2321         LayoutUnit x = rightAligned ? firstRect.maxX() : firstRect.x();
    2322         location = LayoutPoint(x, firstRect.maxY());
     2319        IntRect firstRect = m_frame->editor()->firstRectForRange(selectionRange.get());
     2320
     2321        int x = rightAligned ? firstRect.maxX() : firstRect.x();
     2322        location = IntPoint(x, firstRect.maxY());
    23232323    } else if (focusedNode) {
    23242324        RenderBoxModelObject* box = focusedNode->renderBoxModelObject();
    23252325        if (!box)
    23262326            return false;
    2327         LayoutRect clippedRect = box->absoluteClippedOverflowRect();
    2328         location = LayoutPoint(clippedRect.x(), clippedRect.maxY() - 1);
     2327        IntRect clippedRect = box->absoluteClippedOverflowRect();
     2328        location = IntPoint(clippedRect.x(), clippedRect.maxY() - 1);
    23292329    } else {
    2330         location = LayoutPoint(
     2330        location = IntPoint(
    23312331            rightAligned ? view->contentsWidth() - kContextMenuMargin : kContextMenuMargin,
    23322332            kContextMenuMargin);
     
    23352335    m_frame->view()->setCursor(pointerCursor());
    23362336
    2337     LayoutPoint position = view->contentsToWindow(location);
    2338     LayoutPoint globalPosition = view->contentsToScreen(LayoutRect(location, LayoutSize())).location();
     2337    IntPoint position = view->contentsToWindow(location);
     2338    IntPoint globalPosition = view->contentsToScreen(IntRect(location, IntSize())).location();
    23392339
    23402340    Node* targetNode = doc->focusedNode();
     
    27212721    if (!view)
    27222722        return false;
    2723     LayoutPoint dragLocation = view->windowToContents(flooredLayoutPoint(dragViewportLocation));
    2724     LayoutSize delta = dragLocation - m_mouseDownPos;
     2723    IntPoint dragLocation = view->windowToContents(flooredIntPoint(dragViewportLocation));
     2724    IntSize delta = dragLocation - m_mouseDownPos;
    27252725   
    27262726    int threshold = GeneralDragHysteresis;
     
    28742874                // FIXME: This doesn't work correctly with transforms.
    28752875                FloatPoint absPos = renderer->localToAbsolute();
    2876                 LayoutSize delta = m_mouseDownPos - roundedLayoutPoint(absPos);
     2876                IntSize delta = m_mouseDownPos - roundedIntPoint(absPos);
    28772877                dragState().m_dragClipboard->setDragImageElement(dragState().m_dragSrc.get(), toPoint(delta));
    28782878            } else {
  • trunk/Source/WebCore/page/EventHandler.h

    r99014 r100059  
    402402   
    403403    IntPoint m_currentMousePosition;
    404     LayoutPoint m_mouseDownPos; // In our view's coords.
     404    IntPoint m_mouseDownPos; // In our view's coords.
    405405    double m_mouseDownTimestamp;
    406406    PlatformMouseEvent m_mouseDown;
  • trunk/Source/WebCore/page/Frame.cpp

    r99937 r100059  
    816816}
    817817
    818 Document* Frame::documentAtPoint(const LayoutPoint& point)
     818Document* Frame::documentAtPoint(const IntPoint& point)
    819819{
    820820    if (!view())
  • trunk/Source/WebCore/page/Frame.h

    r99099 r100059  
    188188
    189189        VisiblePosition visiblePositionForPoint(const LayoutPoint& framePoint);
    190         Document* documentAtPoint(const LayoutPoint& windowPoint);
     190        Document* documentAtPoint(const IntPoint& windowPoint);
    191191        PassRefPtr<Range> rangeForPoint(const LayoutPoint& framePoint);
    192192
  • trunk/Source/WebCore/page/FrameView.cpp

    r100014 r100059  
    171171{
    172172    RefPtr<FrameView> view = adoptRef(new FrameView(frame));
    173     view->Widget::setFrameRect(LayoutRect(view->location(), initialSize));
     173    view->Widget::setFrameRect(IntRect(view->location(), initialSize));
    174174    view->show();
    175175    return view.release();
     
    374374}
    375375
    376 void FrameView::invalidateRect(const LayoutRect& rect)
     376void FrameView::invalidateRect(const IntRect& rect)
    377377{
    378378    if (!parent()) {
     
    389389        return;
    390390
    391     LayoutRect repaintRect = rect;
     391    IntRect repaintRect = rect;
    392392    repaintRect.move(renderer->borderLeft() + renderer->paddingLeft(),
    393393                     renderer->borderTop() + renderer->paddingTop());
     
    395395}
    396396
    397 void FrameView::setFrameRect(const LayoutRect& newRect)
    398 {
    399     LayoutRect oldRect = frameRect();
     397void FrameView::setFrameRect(const IntRect& newRect)
     398{
     399    IntRect oldRect = frameRect();
    400400    if (newRect == oldRect)
    401401        return;
     
    489489}
    490490
    491 void FrameView::setContentsSize(const LayoutSize& size)
     491void FrameView::setContentsSize(const IntSize& size)
    492492{
    493493    if (size == contentsSize())
     
    519519    ASSERT(m_frame->view() == this);
    520520
    521     const LayoutRect& rect = root->documentRect();
    522     const LayoutSize& size = rect.size();
    523     ScrollView::setScrollOrigin(LayoutPoint(-rect.x(), -rect.y()), !m_frame->document()->printing(), size == contentsSize());
     521    const IntRect rect = root->documentRect();
     522    const IntSize& size = rect.size();
     523    ScrollView::setScrollOrigin(IntPoint(-rect.x(), -rect.y()), !m_frame->document()->printing(), size == contentsSize());
    524524   
    525525    setContentsSize(size);
     
    17321732const unsigned cRepaintRectUnionThreshold = 25;
    17331733
    1734 void FrameView::repaintContentRectangle(const LayoutRect& r, bool immediate)
     1734void FrameView::repaintContentRectangle(const IntRect& r, bool immediate)
    17351735{
    17361736    ASSERT(!m_frame->ownerElement());
    17371737   
    17381738    if (m_isTrackingRepaints) {
    1739         LayoutRect repaintRect = r;
     1739        IntRect repaintRect = r;
    17401740        repaintRect.move(-scrollOffset());
    17411741        m_trackedRepaintRects.append(repaintRect);
     
    17441744    double delay = m_deferringRepaints ? 0 : adjustedDeferredRepaintDelay();
    17451745    if ((m_deferringRepaints || m_deferredRepaintTimer.isActive() || delay) && !immediate) {
    1746         LayoutRect paintRect = r;
     1746        IntRect paintRect = r;
    17471747        if (clipsRepaints() && !paintsEntireContents())
    17481748            paintRect.intersect(visibleContentRect());
     
    17501750            return;
    17511751        if (m_repaintCount == cRepaintRectUnionThreshold) {
    1752             LayoutRect unionedRect;
     1752            IntRect unionedRect;
    17531753            for (unsigned i = 0; i < cRepaintRectUnionThreshold; ++i)
    17541754                unionedRect.unite(m_repaintRects[i]);
     
    23602360}
    23612361
    2362 void FrameView::invalidateScrollbarRect(Scrollbar* scrollbar, const LayoutRect& rect)
     2362void FrameView::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rect)
    23632363{
    23642364    // Add in our offset within the FrameView.
    2365     LayoutRect dirtyRect = rect;
     2365    IntRect dirtyRect = rect;
    23662366    dirtyRect.moveBy(scrollbar->location());
    23672367    invalidateRect(dirtyRect);
    23682368}
    23692369
    2370 void FrameView::getTickmarks(Vector<LayoutRect>& tickmarks) const
     2370void FrameView::getTickmarks(Vector<IntRect>& tickmarks) const
    23712371{
    23722372    tickmarks = frame()->document()->markers()->renderedRectsForMarkers(DocumentMarker::TextMatch);
     
    23772377    Page* page = frame() ? frame()->page() : 0;
    23782378    if (!page)
    2379         return LayoutRect();
     2379        return IntRect();
    23802380    return page->chrome()->windowResizerRect();
    23812381}
     
    24132413}
    24142414
    2415 void FrameView::setVisibleScrollerThumbRect(const LayoutRect& scrollerThumb)
     2415void FrameView::setVisibleScrollerThumbRect(const IntRect& scrollerThumb)
    24162416{
    24172417    Page* page = m_frame->page();
     
    25092509    RenderObject* renderer = 0;
    25102510    RefPtr<RenderStyle> cornerStyle;
    2511     LayoutRect cornerRect = scrollCornerRect();
     2511    IntRect cornerRect = scrollCornerRect();
    25122512   
    25132513    if (!cornerRect.isEmpty()) {
     
    25492549}
    25502550
    2551 void FrameView::paintScrollCorner(GraphicsContext* context, const LayoutRect& cornerRect)
     2551void FrameView::paintScrollCorner(GraphicsContext* context, const IntRect& cornerRect)
    25522552{
    25532553    if (context->updatingControlTints()) {
     
    26912691}
    26922692
    2693 void FrameView::paintContents(GraphicsContext* p, const LayoutRect& rect)
     2693void FrameView::paintContents(GraphicsContext* p, const IntRect& rect)
    26942694{
    26952695    if (!frame())
     
    28102810}
    28112811
    2812 void FrameView::paintOverhangAreas(GraphicsContext* context, const LayoutRect& horizontalOverhangArea, const LayoutRect& verticalOverhangArea, const LayoutRect& dirtyRect)
     2812void FrameView::paintOverhangAreas(GraphicsContext* context, const IntRect& horizontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect)
    28132813{
    28142814    if (context->paintingDisabled())
     
    29442944}
    29452945
    2946 LayoutRect FrameView::convertFromRenderer(const RenderObject* renderer, const LayoutRect& rendererRect) const
    2947 {
    2948     LayoutRect rect = renderer->localToAbsoluteQuad(FloatRect(rendererRect)).enclosingBoundingBox();
     2946IntRect FrameView::convertFromRenderer(const RenderObject* renderer, const IntRect& rendererRect) const
     2947{
     2948    IntRect rect = renderer->localToAbsoluteQuad(FloatRect(rendererRect)).enclosingBoundingBox();
    29492949
    29502950    // Convert from page ("absolute") to FrameView coordinates.
     
    29542954}
    29552955
    2956 LayoutRect FrameView::convertToRenderer(const RenderObject* renderer, const LayoutRect& viewRect) const
    2957 {
    2958     LayoutRect rect = viewRect;
     2956IntRect FrameView::convertToRenderer(const RenderObject* renderer, const IntRect& viewRect) const
     2957{
     2958    IntRect rect = viewRect;
    29592959   
    29602960    // Convert from FrameView coords into page ("absolute") coordinates.
     
    29632963    // FIXME: we don't have a way to map an absolute rect down to a local quad, so just
    29642964    // move the rect for now.
    2965     rect.setLocation(roundedLayoutPoint(renderer->absoluteToLocal(rect.location(), false, true /* use transforms */)));
     2965    rect.setLocation(roundedIntPoint(renderer->absoluteToLocal(rect.location(), false, true /* use transforms */)));
    29662966    return rect;
    29672967}
    29682968
    2969 LayoutPoint FrameView::convertFromRenderer(const RenderObject* renderer, const LayoutPoint& rendererPoint) const
    2970 {
    2971     LayoutPoint point = roundedLayoutPoint(renderer->localToAbsolute(rendererPoint, false, true /* use transforms */));
     2969IntPoint FrameView::convertFromRenderer(const RenderObject* renderer, const IntPoint& rendererPoint) const
     2970{
     2971    IntPoint point = roundedIntPoint(renderer->localToAbsolute(rendererPoint, false, true /* use transforms */));
    29722972
    29732973    // Convert from page ("absolute") to FrameView coordinates.
     
    29762976}
    29772977
    2978 LayoutPoint FrameView::convertToRenderer(const RenderObject* renderer, const LayoutPoint& viewPoint) const
    2979 {
    2980     LayoutPoint point = viewPoint;
     2978IntPoint FrameView::convertToRenderer(const RenderObject* renderer, const IntPoint& viewPoint) const
     2979{
     2980    IntPoint point = viewPoint;
    29812981   
    29822982    // Convert from FrameView coords into page ("absolute") coordinates.
     
    29862986}
    29872987
    2988 LayoutRect FrameView::convertToContainingView(const LayoutRect& localRect) const
     2988IntRect FrameView::convertToContainingView(const IntRect& localRect) const
    29892989{
    29902990    if (const ScrollView* parentScrollView = parent()) {
     
    29962996                return localRect;
    29972997               
    2998             LayoutRect rect(localRect);
     2998            IntRect rect(localRect);
    29992999            // Add borders and padding??
    30003000            rect.move(renderer->borderLeft() + renderer->paddingLeft(),
     
    30093009}
    30103010
    3011 LayoutRect FrameView::convertFromContainingView(const LayoutRect& parentRect) const
     3011IntRect FrameView::convertFromContainingView(const IntRect& parentRect) const
    30123012{
    30133013    if (const ScrollView* parentScrollView = parent()) {
     
    30203020                return parentRect;
    30213021
    3022             LayoutRect rect = parentView->convertToRenderer(renderer, parentRect);
     3022            IntRect rect = parentView->convertToRenderer(renderer, parentRect);
    30233023            // Subtract borders and padding
    30243024            rect.move(-renderer->borderLeft() - renderer->paddingLeft(),
     
    30333033}
    30343034
    3035 LayoutPoint FrameView::convertToContainingView(const LayoutPoint& localPoint) const
     3035IntPoint FrameView::convertToContainingView(const IntPoint& localPoint) const
    30363036{
    30373037    if (const ScrollView* parentScrollView = parent()) {
     
    30443044                return localPoint;
    30453045               
    3046             LayoutPoint point(localPoint);
     3046            IntPoint point(localPoint);
    30473047
    30483048            // Add borders and padding
     
    30583058}
    30593059
    3060 LayoutPoint FrameView::convertFromContainingView(const LayoutPoint& parentPoint) const
     3060IntPoint FrameView::convertFromContainingView(const IntPoint& parentPoint) const
    30613061{
    30623062    if (const ScrollView* parentScrollView = parent()) {
     
    30693069                return parentPoint;
    30703070
    3071             LayoutPoint point = parentView->convertToRenderer(renderer, parentPoint);
     3071            IntPoint point = parentView->convertToRenderer(renderer, parentPoint);
    30723072            // Subtract borders and padding
    30733073            point.move(-renderer->borderLeft() - renderer->paddingLeft(),
  • trunk/Source/WebCore/page/FrameView.h

    r99511 r100059  
    220220    void removeWidgetToUpdate(RenderEmbeddedObject*);
    221221
    222     virtual void paintContents(GraphicsContext*, const LayoutRect& damageRect);
     222    virtual void paintContents(GraphicsContext*, const IntRect& damageRect);
    223223    void setPaintBehavior(PaintBehavior);
    224224    PaintBehavior paintBehavior() const;
     
    227227    void setNodeToDraw(Node*);
    228228
    229     virtual void paintOverhangAreas(GraphicsContext*, const LayoutRect& horizontalOverhangArea, const LayoutRect& verticalOverhangArea, const LayoutRect& dirtyRect);
    230     virtual void paintScrollCorner(GraphicsContext*, const LayoutRect& cornerRect);
     229    virtual void paintOverhangAreas(GraphicsContext*, const IntRect& horizontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect);
     230    virtual void paintScrollCorner(GraphicsContext*, const IntRect& cornerRect);
    231231
    232232    Color documentBackgroundColor() const;
     
    337337    void performPostLayoutTasks();
    338338
    339     virtual void repaintContentRectangle(const LayoutRect&, bool immediate);
     339    virtual void repaintContentRectangle(const IntRect&, bool immediate);
    340340    virtual void contentsResized();
    341341    virtual void visibleContentsResized();
  • trunk/Source/WebCore/page/Page.cpp

    r99613 r100059  
    620620}
    621621
    622 void Page::setPageScaleFactor(float scale, const LayoutPoint& origin)
     622void Page::setPageScaleFactor(float scale, const IntPoint& origin)
    623623{
    624624    if (scale == m_pageScaleFactor)
  • trunk/Source/WebCore/page/Page.h

    r99613 r100059  
    246246        void setMediaVolume(float volume);
    247247
    248         void setPageScaleFactor(float scale, const LayoutPoint& origin);
     248        void setPageScaleFactor(float scale, const IntPoint& origin);
    249249        float pageScaleFactor() const { return m_pageScaleFactor; }
    250250
  • trunk/Source/WebCore/page/SpatialNavigation.cpp

    r95901 r100059  
    362362        }
    363363
    364         frame->view()->scrollBy(LayoutSize(dx, dy));
     364        frame->view()->scrollBy(IntSize(dx, dy));
    365365        return true;
    366366    }
Note: See TracChangeset for help on using the changeset viewer.