Changeset 86195 in webkit


Ignore:
Timestamp:
May 10, 2011 4:45:03 PM (13 years ago)
Author:
leviw@chromium.org
Message:

2011-05-10 Levi Weintraub <leviw@chromium.org>

Reviewed by Eric Seidel.

Create LayerOffset class
https://bugs.webkit.org/show_bug.cgi?id=60490

Adding a LayerOffset class that will replace existing usage of tx/ty.
LayerOffset is necessary since these values are commonly used as both
a size and a point. Updating paintIntoRect to use this new class.

No new tests since this doesn't change any behavior.

  • GNUmakefile.list.am:
  • WebCore.gypi:
  • WebCore.pro:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:
  • page/FrameView.cpp: (WebCore::FrameView::paintScrollCorner):
  • platform/graphics/LayerOffset.h: Added. (WebCore::LayerOffset::LayerOffset): (WebCore::LayerOffset::x): (WebCore::LayerOffset::y): (WebCore::LayerOffset::setX): (WebCore::LayerOffset::setY): (WebCore::LayerOffset::toSize): (WebCore::LayerOffset::toPoint): (WebCore::operator+=): (WebCore::operator-=): (WebCore::operator+): (WebCore::operator-): (WebCore::operator==): (WebCore::operator!=):
  • rendering/RenderLayer.cpp: (WebCore::RenderLayer::paintScrollCorner): (WebCore::RenderLayer::paintResizer):
  • rendering/RenderScrollbar.cpp: (WebCore::RenderScrollbar::paintPart):
  • rendering/RenderScrollbarPart.cpp: (WebCore::RenderScrollbarPart::paintIntoRect):
  • rendering/RenderScrollbarPart.h:
Location:
trunk/Source/WebCore
Files:
1 added
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r86193 r86195  
     12011-05-10  Levi Weintraub  <leviw@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Create LayerOffset class
     6        https://bugs.webkit.org/show_bug.cgi?id=60490
     7
     8        Adding a LayerOffset class that will replace existing usage of tx/ty.
     9        LayerOffset is necessary since these values are commonly used as both
     10        a size and a point. Updating paintIntoRect to use this new class.
     11
     12        No new tests since this doesn't change any behavior.
     13
     14        * GNUmakefile.list.am:
     15        * WebCore.gypi:
     16        * WebCore.pro:
     17        * WebCore.vcproj/WebCore.vcproj:
     18        * WebCore.xcodeproj/project.pbxproj:
     19        * page/FrameView.cpp:
     20        (WebCore::FrameView::paintScrollCorner):
     21        * platform/graphics/LayerOffset.h: Added.
     22        (WebCore::LayerOffset::LayerOffset):
     23        (WebCore::LayerOffset::x):
     24        (WebCore::LayerOffset::y):
     25        (WebCore::LayerOffset::setX):
     26        (WebCore::LayerOffset::setY):
     27        (WebCore::LayerOffset::toSize):
     28        (WebCore::LayerOffset::toPoint):
     29        (WebCore::operator+=):
     30        (WebCore::operator-=):
     31        (WebCore::operator+):
     32        (WebCore::operator-):
     33        (WebCore::operator==):
     34        (WebCore::operator!=):
     35        * rendering/RenderLayer.cpp:
     36        (WebCore::RenderLayer::paintScrollCorner):
     37        (WebCore::RenderLayer::paintResizer):
     38        * rendering/RenderScrollbar.cpp:
     39        (WebCore::RenderScrollbar::paintPart):
     40        * rendering/RenderScrollbarPart.cpp:
     41        (WebCore::RenderScrollbarPart::paintIntoRect):
     42        * rendering/RenderScrollbarPart.h:
     43
    1442011-05-10  Ryosuke Niwa  <rniwa@webkit.org>
    245
  • trunk/Source/WebCore/GNUmakefile.list.am

    r86177 r86195  
    24402440        Source/WebCore/platform/graphics/IntSize.h \
    24412441        Source/WebCore/platform/graphics/IntSizeHash.h \
     2442        Source/WebCore/platform/graphics/LayerOffset.h \
    24422443        Source/WebCore/platform/graphics/MediaPlayer.cpp \
    24432444        Source/WebCore/platform/graphics/MediaPlayer.h \
  • trunk/Source/WebCore/WebCore.gypi

    r86128 r86195  
    849849            'platform/graphics/IntSize.h',
    850850            'platform/graphics/IntSizeHash.h',
     851            'platform/graphics/LayerOffset.h',
    851852            'platform/graphics/MediaPlayer.h',
    852853            'platform/graphics/Path.h',
  • trunk/Source/WebCore/WebCore.pro

    r86152 r86195  
    19521952    platform/graphics/IntPointHash.h \
    19531953    platform/graphics/IntRect.h \
     1954    platform/graphics/LayerOffset.h \
    19541955    platform/graphics/MediaPlayer.h \
    19551956    platform/graphics/Path.h \
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r86128 r86195  
    2691826918                                </File>
    2691926919                                <File
     26920                                        RelativePath="..\platform\graphics\LayerOffset.h"
     26921                                        >
     26922                                </File>
     26923                                <File
    2692026924                                        RelativePath="..\platform\graphics\MediaPlayer.cpp"
    2692126925                                        >
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r86128 r86195  
    47994799                B8DBDB4D130B0F8A00F5CDB1 /* SpellingCorrectionCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B8DBDB49130B0F8A00F5CDB1 /* SpellingCorrectionCommand.cpp */; };
    48004800                B8DBDB4E130B0F8A00F5CDB1 /* SpellingCorrectionCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = B8DBDB4A130B0F8A00F5CDB1 /* SpellingCorrectionCommand.h */; };
     4801                BA5175C813789735008BFCBF /* LayerOffset.h in Headers */ = {isa = PBXBuildFile; fileRef = BA5175C713789735008BFCBF /* LayerOffset.h */; settings = {ATTRIBUTES = (Private, ); }; };
    48014802                BC00F0040E0A185500FD04E3 /* DOMFile.h in Headers */ = {isa = PBXBuildFile; fileRef = BC00EFFE0E0A185500FD04E3 /* DOMFile.h */; };
    48024803                BC00F0050E0A185500FD04E3 /* DOMFile.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC00EFFF0E0A185500FD04E3 /* DOMFile.mm */; };
     
    1120811209                B8DBDB49130B0F8A00F5CDB1 /* SpellingCorrectionCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpellingCorrectionCommand.cpp; sourceTree = "<group>"; };
    1120911210                B8DBDB4A130B0F8A00F5CDB1 /* SpellingCorrectionCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpellingCorrectionCommand.h; sourceTree = "<group>"; };
     11211                BA5175C713789735008BFCBF /* LayerOffset.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayerOffset.h; sourceTree = "<group>"; };
    1121011212                BC00EFFE0E0A185500FD04E3 /* DOMFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMFile.h; sourceTree = "<group>"; };
    1121111213                BC00EFFF0E0A185500FD04E3 /* DOMFile.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMFile.mm; sourceTree = "<group>"; };
     
    1768317685                                B27535470B053814002CE64F /* IntSize.h */,
    1768417686                                B27535480B053814002CE64F /* IntSizeHash.h */,
     17687                                BA5175C713789735008BFCBF /* LayerOffset.h */,
    1768517688                                E4B41E0C0CBF90BD00AF2ECE /* MediaPlayer.cpp */,
    1768617689                                E4B41E0D0CBF90BD00AF2ECE /* MediaPlayer.h */,
     
    2274922752                                37AFFDF71370A0B800E895C0 /* SharedBufferCRLFLineReader.h in Headers */,
    2275022753                                379E371713736A6600B9E919 /* QuotedPrintable.h in Headers */,
     22754                                BA5175C813789735008BFCBF /* LayerOffset.h in Headers */,
    2275122755                                FD1660A513787C6D001FFA7B /* DenormalDisabler.h in Headers */,
    2275222756                        );
  • trunk/Source/WebCore/page/FrameView.cpp

    r86184 r86195  
    22622262
    22632263    if (m_scrollCorner) {
    2264         m_scrollCorner->paintIntoRect(context, cornerRect.x(), cornerRect.y(), cornerRect);
     2264        m_scrollCorner->paintIntoRect(context, cornerRect.location(), cornerRect);
    22652265        return;
    22662266    }
  • trunk/Source/WebCore/rendering/InlineTextBox.cpp

    r85512 r86195  
    547547        // Custom highlighters go behind everything else.
    548548        if (styleToUse->highlight() != nullAtom && !context->paintingDisabled())
    549             paintCustomHighlight(tx, ty, styleToUse->highlight());
     549            paintCustomHighlight(LayerOffset(tx, ty), styleToUse->highlight());
    550550#endif
    551551
     
    858858#if PLATFORM(MAC)
    859859
    860 void InlineTextBox::paintCustomHighlight(int tx, int ty, const AtomicString& type)
     860void InlineTextBox::paintCustomHighlight(LayerOffset layerOffset, const AtomicString& type)
    861861{
    862862    Frame* frame = renderer()->frame();
     
    868868
    869869    RootInlineBox* r = root();
    870     FloatRect rootRect(tx + r->x(), ty + selectionTop(), r->logicalWidth(), selectionHeight());
    871     FloatRect textRect(tx + x(), rootRect.y(), logicalWidth(), rootRect.height());
     870    FloatRect rootRect(layerOffset.x() + r->x(), layerOffset.y() + selectionTop(), r->logicalWidth(), selectionHeight());
     871    FloatRect textRect(layerOffset.x() + x(), rootRect.y(), logicalWidth(), rootRect.height());
    872872
    873873    page->chrome()->client()->paintCustomHighlight(renderer()->node(), type, textRect, rootRect, true, false);
  • trunk/Source/WebCore/rendering/InlineTextBox.h

    r86028 r86195  
    166166    void paintCompositionUnderline(GraphicsContext*, const FloatPoint& boxOrigin, const CompositionUnderline&);
    167167#if PLATFORM(MAC)
    168     void paintCustomHighlight(int tx, int ty, const AtomicString& type);
     168    void paintCustomHighlight(LayerOffset, const AtomicString& type);
    169169#endif
    170170
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r86188 r86195  
    10781078#if PLATFORM(MAC)
    10791079
    1080 void RenderBox::paintCustomHighlight(int tx, int ty, const AtomicString& type, bool behindText)
     1080void RenderBox::paintCustomHighlight(LayerOffset layoutOffset, const AtomicString& type, bool behindText)
    10811081{
    10821082    Frame* frame = this->frame();
     
    10901090    RootInlineBox* r = boxWrap ? boxWrap->root() : 0;
    10911091    if (r) {
    1092         FloatRect rootRect(tx + r->x(), ty + r->selectionTop(), r->logicalWidth(), r->selectionHeight());
    1093         FloatRect imageRect(tx + x(), rootRect.y(), width(), rootRect.height());
     1092        FloatRect rootRect(layoutOffset.x() + r->x(), layoutOffset.y() + r->selectionTop(), r->logicalWidth(), r->selectionHeight());
     1093        FloatRect imageRect(location() + layoutOffset, IntSize(width(), rootRect.height()));
    10941094        page->chrome()->client()->paintCustomHighlight(node(), type, imageRect, rootRect, behindText, false);
    10951095    } else {
    1096         FloatRect imageRect(tx + x(), ty + y(), width(), height());
     1096        FloatRect imageRect(location() + layoutOffset, IntSize(width(), height()));
    10971097        page->chrome()->client()->paintCustomHighlight(node(), type, imageRect, imageRect, behindText, false);
    10981098    }
  • trunk/Source/WebCore/rendering/RenderBox.h

    r84341 r86195  
    413413
    414414#if PLATFORM(MAC)
    415     void paintCustomHighlight(int tx, int ty, const AtomicString& type, bool behindText);
     415    void paintCustomHighlight(LayerOffset, const AtomicString& type, bool behindText);
    416416#endif
    417417
  • trunk/Source/WebCore/rendering/RenderImage.cpp

    r85864 r86195  
    303303#if PLATFORM(MAC)
    304304        if (style()->highlight() != nullAtom && !paintInfo.context->paintingDisabled())
    305             paintCustomHighlight(tx - x(), ty - y(), style()->highlight(), true);
     305            paintCustomHighlight(LayerOffset(tx - x(), ty - y()), style()->highlight(), true);
    306306#endif
    307307
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r85990 r86195  
    23112311
    23122312    if (m_scrollCorner) {
    2313         m_scrollCorner->paintIntoRect(context, tx, ty, absRect);
     2313        m_scrollCorner->paintIntoRect(context, LayerOffset(tx, ty), absRect);
    23142314        return;
    23152315    }
     
    23402340   
    23412341    if (m_resizer) {
    2342         m_resizer->paintIntoRect(context, tx, ty, absRect);
     2342        m_resizer->paintIntoRect(context, LayerOffset(tx, ty), absRect);
    23432343        return;
    23442344    }
  • trunk/Source/WebCore/rendering/RenderListMarker.cpp

    r84504 r86195  
    11291129#if PLATFORM(MAC)
    11301130        if (style()->highlight() != nullAtom && !paintInfo.context->paintingDisabled())
    1131             paintCustomHighlight(tx, ty, style()->highlight(), true);
     1131            paintCustomHighlight(LayerOffset(tx, ty), style()->highlight(), true);
    11321132#endif
    11331133        context->drawImage(m_image->image(this, marker.size()).get(), style()->colorSpace(), marker);
     
    11431143    // FIXME: paint gap between marker and list item proper
    11441144    if (style()->highlight() != nullAtom && !paintInfo.context->paintingDisabled())
    1145         paintCustomHighlight(tx, ty, style()->highlight(), true);
     1145        paintCustomHighlight(LayerOffset(tx, ty), style()->highlight(), true);
    11461146#endif
    11471147
  • trunk/Source/WebCore/rendering/RenderObject.h

    r86128 r86195  
    3131#include "Element.h"
    3232#include "FloatQuad.h"
     33#include "LayerOffset.h"
    3334#include "PaintPhase.h"
    3435#include "RenderObjectChildList.h"
  • trunk/Source/WebCore/rendering/RenderScrollbar.cpp

    r84538 r86195  
    276276    if (!partRenderer)
    277277        return;
    278     partRenderer->paintIntoRect(graphicsContext, x(), y(), rect);
     278    partRenderer->paintIntoRect(graphicsContext, pos(), rect);
    279279}
    280280
  • trunk/Source/WebCore/rendering/RenderScrollbarPart.cpp

    r75837 r86195  
    160160}
    161161
    162 void RenderScrollbarPart::paintIntoRect(GraphicsContext* graphicsContext, int tx, int ty, const IntRect& rect)
     162void RenderScrollbarPart::paintIntoRect(GraphicsContext* graphicsContext, LayerOffset layerOffset, const IntRect& rect)
    163163{
    164164    // Make sure our dimensions match the rect.
    165     setLocation(rect.x() - tx, rect.y() - ty);
     165    setLocation(rect.location() - layerOffset.toSize());
    166166    setWidth(rect.width());
    167167    setHeight(rect.height());
     
    172172    // Now do the paint.
    173173    PaintInfo paintInfo(graphicsContext, rect, PaintPhaseBlockBackground, false, 0, 0);
    174     paint(paintInfo, tx, ty);
     174    paint(paintInfo, layerOffset.x(), layerOffset.y());
    175175    paintInfo.phase = PaintPhaseChildBlockBackgrounds;
    176     paint(paintInfo, tx, ty);
     176    paint(paintInfo, layerOffset.x(), layerOffset.y());
    177177    paintInfo.phase = PaintPhaseFloat;
    178     paint(paintInfo, tx, ty);
     178    paint(paintInfo, layerOffset.x(), layerOffset.y());
    179179    paintInfo.phase = PaintPhaseForeground;
    180     paint(paintInfo, tx, ty);
     180    paint(paintInfo, layerOffset.x(), layerOffset.y());
    181181    paintInfo.phase = PaintPhaseOutline;
    182     paint(paintInfo, tx, ty);
     182    paint(paintInfo, layerOffset.x(), layerOffset.y());
    183183}
    184184
  • trunk/Source/WebCore/rendering/RenderScrollbarPart.h

    r68276 r86195  
    2727#define RenderScrollbarPart_h
    2828
     29#include "LayerOffset.h"
    2930#include "RenderBlock.h"
    3031#include "ScrollTypes.h"
     
    4647    virtual void computePreferredLogicalWidths();
    4748   
    48     void paintIntoRect(GraphicsContext*, int tx, int ty, const IntRect&);
     49    void paintIntoRect(GraphicsContext*, LayerOffset, const IntRect&);
    4950   
    5051protected:
  • trunk/Source/WebCore/rendering/RenderTable.cpp

    r85355 r86195  
    481481
    482482    if (paintPhase == PaintPhaseMask) {
    483         paintMask(paintInfo, tx, ty);
     483        paintMask(paintInfo, LayerOffset(tx, ty));
    484484        return;
    485485    }
     
    574574}
    575575
    576 void RenderTable::paintMask(PaintInfo& paintInfo, int tx, int ty)
     576void RenderTable::paintMask(PaintInfo& paintInfo, LayerOffset layerOffset)
    577577{
    578578    if (style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask)
    579579        return;
    580580
    581     IntRect rect(tx, ty, width(), height());
     581    IntRect rect(layerOffset.toPoint(), IntSize(width(), height()));
    582582    subtractCaptionRect(rect);
    583583
  • trunk/Source/WebCore/rendering/RenderTable.h

    r85355 r86195  
    218218    virtual void paintObject(PaintInfo&, int tx, int ty);
    219219    virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);
    220     virtual void paintMask(PaintInfo&, int tx, int ty);
     220    virtual void paintMask(PaintInfo&, LayerOffset);
    221221    virtual void layout();
    222222    virtual void computePreferredLogicalWidths();
  • trunk/Source/WebCore/rendering/RenderWidget.cpp

    r84143 r86195  
    268268#if PLATFORM(MAC)
    269269    if (style()->highlight() != nullAtom && !paintInfo.context->paintingDisabled())
    270         paintCustomHighlight(tx - x(), ty - y(), style()->highlight(), true);
     270        paintCustomHighlight(LayerOffset(tx - x(), ty - y()), style()->highlight(), true);
    271271#endif
    272272
  • trunk/Source/WebCore/rendering/RootInlineBox.cpp

    r85512 r86195  
    158158}
    159159
    160 void RootInlineBox::paintCustomHighlight(PaintInfo& paintInfo, int tx, int ty, const AtomicString& highlightType)
     160void RootInlineBox::paintCustomHighlight(PaintInfo& paintInfo, LayerOffset layerOffset, const AtomicString& highlightType)
    161161{
    162162    if (!paintInfo.shouldPaintWithinRoot(renderer()) || renderer()->style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseForeground)
     
    171171
    172172    // Get the inflated rect so that we can properly hit test.
    173     FloatRect rootRect(tx + x(), ty + selectionTop(), logicalWidth(), selectionHeight());
     173    FloatRect rootRect(layerOffset.x() + x(), layerOffset.y() + selectionTop(), logicalWidth(), selectionHeight());
    174174    FloatRect inflatedRect = page->chrome()->client()->customHighlightRect(renderer()->node(), highlightType, rootRect);
    175175    if (inflatedRect.intersects(paintInfo.rect))
     
    186186    RenderStyle* styleToUse = renderer()->style(m_firstLine);
    187187    if (styleToUse->highlight() != nullAtom && !paintInfo.context->paintingDisabled())
    188         paintCustomHighlight(paintInfo, tx, ty, styleToUse->highlight());
     188        paintCustomHighlight(paintInfo, LayerOffset(tx, ty), styleToUse->highlight());
    189189#endif
    190190}
  • trunk/Source/WebCore/rendering/RootInlineBox.h

    r85512 r86195  
    9393#if PLATFORM(MAC)
    9494    void addHighlightOverflow();
    95     void paintCustomHighlight(PaintInfo&, int tx, int ty, const AtomicString& highlightType);
     95    void paintCustomHighlight(PaintInfo&, LayerOffset, const AtomicString& highlightType);
    9696#endif
    9797
Note: See TracChangeset for help on using the changeset viewer.