Changeset 113431 in webkit


Ignore:
Timestamp:
Apr 6, 2012 7:10:43 AM (12 years ago)
Author:
leviw@chromium.org
Message:

Update LayoutUnit usage in RenderView
https://bugs.webkit.org/show_bug.cgi?id=83147

Reviewed by Julien Chaffraix.

Updating the usage of LayoutUnits in RenderView in preparation for sub-pixel layout. This mostly
affects paint and repaint functions, which take LayoutRects up to the RenderView level. This is
necessary as we continue to accumulate sub-pixel offsets up to this level.

No new tests. No change in behavior.

  • rendering/RenderView.cpp:

(WebCore::RenderView::paint): Adding an assert that we're being called to paint on pixel
boundaries. We don't currently ever position RenderViews at sub-pixel offsets.
(WebCore::RenderView::shouldRepaint):
(WebCore::RenderView::repaintViewRectangle): Switching to a LayoutRect and cleaning up a fixme
that used decomposed offsets. Pixel snapping is applied before handing the rect up to the
FrameView.
(WebCore::RenderView::repaintRectangleInViewAndCompositedLayers): Pixel snapping before handing
the rect up to the Compositor.
(WebCore::RenderView::computeRectForRepaint):
(WebCore::RenderView::selectionBounds):
(WebCore::RenderView::viewRect):
(WebCore::RenderView::unscaledDocumentRect):

  • rendering/RenderView.h:

(RenderView):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r113428 r113431  
     12012-04-06  Levi Weintraub  <leviw@chromium.org>
     2
     3        Update LayoutUnit usage in RenderView
     4        https://bugs.webkit.org/show_bug.cgi?id=83147
     5
     6        Reviewed by Julien Chaffraix.
     7
     8        Updating the usage of LayoutUnits in RenderView in preparation for sub-pixel layout. This mostly
     9        affects paint and repaint functions, which take LayoutRects up to the RenderView level. This is
     10        necessary as we continue to accumulate sub-pixel offsets up to this level.
     11
     12        No new tests. No change in behavior.
     13
     14        * rendering/RenderView.cpp:
     15        (WebCore::RenderView::paint): Adding an assert that we're being called to paint on pixel
     16        boundaries. We don't currently ever position RenderViews at sub-pixel offsets.
     17        (WebCore::RenderView::shouldRepaint):
     18        (WebCore::RenderView::repaintViewRectangle): Switching to a LayoutRect and cleaning up a fixme
     19        that used decomposed offsets. Pixel snapping is applied before handing the rect up to the
     20        FrameView.
     21        (WebCore::RenderView::repaintRectangleInViewAndCompositedLayers): Pixel snapping before handing
     22        the rect up to the Compositor.
     23        (WebCore::RenderView::computeRectForRepaint):
     24        (WebCore::RenderView::selectionBounds):
     25        (WebCore::RenderView::viewRect):
     26        (WebCore::RenderView::unscaledDocumentRect):
     27        * rendering/RenderView.h:
     28        (RenderView):
     29
    1302012-04-06  Andrey Kosyakov  <caseq@chromium.org>
    231
  • trunk/Source/WebCore/rendering/RenderView.cpp

    r112453 r113431  
    218218    // If we ever require layout but receive a paint anyway, something has gone horribly wrong.
    219219    ASSERT(!needsLayout());
     220    // RenderViews should never be called to paint with an offset not on device pixels.
     221    ASSERT(LayoutPoint(IntPoint(paintOffset.x(), paintOffset.y())) == paintOffset);
    220222    paintObject(paintInfo, paintOffset);
    221223}
     
    295297}
    296298
    297 bool RenderView::shouldRepaint(const IntRect& r) const
     299bool RenderView::shouldRepaint(const LayoutRect& r) const
    298300{
    299301    if (printing() || r.width() == 0 || r.height() == 0)
     
    309311}
    310312
    311 void RenderView::repaintViewRectangle(const IntRect& ur, bool immediate)
     313void RenderView::repaintViewRectangle(const LayoutRect& ur, bool immediate)
    312314{
    313315    if (!shouldRepaint(ur))
     
    318320    Element* elt = document()->ownerElement();
    319321    if (!elt)
    320         m_frameView->repaintContentRectangle(ur, immediate);
     322        m_frameView->repaintContentRectangle(pixelSnappedIntRect(ur), immediate);
    321323    else if (RenderBox* obj = elt->renderBox()) {
    322         IntRect vr = viewRect();
    323         IntRect r = intersection(ur, vr);
     324        LayoutRect vr = viewRect();
     325        LayoutRect r = intersection(ur, vr);
    324326       
    325327        // Subtract out the contentsX and contentsY offsets to get our coords within the viewing
    326328        // rectangle.
    327329        r.moveBy(-vr.location());
    328        
     330
    329331        // FIXME: Hardcoded offsets here are not good.
    330         r.move(obj->borderLeft() + obj->paddingLeft(),
    331                obj->borderTop() + obj->paddingTop());
     332        r.moveBy(obj->contentBoxRect().location());
    332333        obj->repaintRectangle(r, immediate);
    333334    }
    334335}
    335336
    336 void RenderView::repaintRectangleInViewAndCompositedLayers(const IntRect& ur, bool immediate)
     337void RenderView::repaintRectangleInViewAndCompositedLayers(const LayoutRect& ur, bool immediate)
    337338{
    338339    if (!shouldRepaint(ur))
     
    343344#if USE(ACCELERATED_COMPOSITING)
    344345    if (compositor()->inCompositingMode())
    345         compositor()->repaintCompositedLayersAbsoluteRect(ur);
     346        compositor()->repaintCompositedLayersAbsoluteRect(pixelSnappedIntRect(ur));
    346347#endif
    347348}
    348349
    349 void RenderView::computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect& rect, bool fixed) const
     350void RenderView::computeRectForRepaint(RenderBoxModelObject* repaintContainer, LayoutRect& rect, bool fixed) const
    350351{
    351352    // If a container was specified, and was not 0 or the RenderView,
     
    421422
    422423    // Now create a single bounding box rect that encloses the whole selection.
    423     IntRect selRect;
     424    LayoutRect selRect;
    424425    SelectionMap::iterator end = selectedObjects.end();
    425426    for (SelectionMap::iterator i = selectedObjects.begin(); i != end; ++i) {
    426427        RenderSelectionInfo* info = i->second;
    427428        // RenderSelectionInfo::rect() is in the coordinates of the repaintContainer, so map to page coordinates.
    428         IntRect currRect = info->rect();
     429        LayoutRect currRect = info->rect();
    429430        if (RenderBoxModelObject* repaintContainer = info->repaintContainer()) {
    430431            FloatQuad absQuad = repaintContainer->localToAbsoluteQuad(FloatRect(currRect));
     
    434435        delete info;
    435436    }
    436     return selRect;
     437    return pixelSnappedIntRect(selRect);
    437438}
    438439
     
    707708}
    708709
    709 IntRect RenderView::viewRect() const
     710LayoutRect RenderView::viewRect() const
    710711{
    711712    if (printing())
    712         return IntRect(IntPoint(), size());
     713        return LayoutRect(LayoutPoint(), size());
    713714    if (m_frameView)
    714715        return m_frameView->visibleContentRect();
    715     return IntRect();
     716    return LayoutRect();
    716717}
    717718
     
    719720IntRect RenderView::unscaledDocumentRect() const
    720721{
    721     IntRect overflowRect(layoutOverflowRect());
     722    LayoutRect overflowRect(layoutOverflowRect());
    722723    flipForWritingMode(overflowRect);
    723     return overflowRect;
     724    return pixelSnappedIntRect(overflowRect);
    724725}
    725726
  • trunk/Source/WebCore/rendering/RenderView.h

    r112453 r113431  
    6969    FrameView* frameView() const { return m_frameView; }
    7070
    71     virtual void computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect&, bool fixed = false) const;
    72     virtual void repaintViewRectangle(const IntRect&, bool immediate = false);
     71    virtual void computeRectForRepaint(RenderBoxModelObject* repaintContainer, LayoutRect&, bool fixed = false) const OVERRIDE;
     72    virtual void repaintViewRectangle(const LayoutRect&, bool immediate = false) OVERRIDE;
    7373    // Repaint the view, and all composited layers that intersect the given absolute rectangle.
    7474    // FIXME: ideally we'd never have to do this, if all repaints are container-relative.
    75     virtual void repaintRectangleInViewAndCompositedLayers(const IntRect&, bool immediate = false);
     75    virtual void repaintRectangleInViewAndCompositedLayers(const LayoutRect&, bool immediate = false) OVERRIDE;
    7676
    7777    virtual void paint(PaintInfo&, const LayoutPoint&);
    78     virtual void paintBoxDecorations(PaintInfo&, const IntPoint&);
     78    virtual void paintBoxDecorations(PaintInfo&, const LayoutPoint&) OVERRIDE;
    7979
    8080    enum SelectionRepaintMode { RepaintNewXOROld, RepaintNewMinusOld, RepaintNothing };
     
    9999    int maximalOutlineSize() const { return m_maximalOutlineSize; }
    100100
    101     virtual IntRect viewRect() const;
     101    virtual LayoutRect viewRect() const OVERRIDE;
    102102
    103103    void updateWidgetPositions();
     
    202202    virtual ColumnInfo::PaginationUnit paginationUnit() const OVERRIDE;
    203203
    204     bool shouldRepaint(const IntRect& r) const;
     204    bool shouldRepaint(const LayoutRect&) const;
    205205
    206206    // These functions may only be accessed by LayoutStateMaintainer.
Note: See TracChangeset for help on using the changeset viewer.