Changeset 37146 in webkit


Ignore:
Timestamp:
Oct 1, 2008 10:51:02 AM (16 years ago)
Author:
hyatt@apple.com
Message:

Make ScrollView::paint cross-platform.

Location:
trunk
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/dom/Document.cpp

    r37113 r37146  
    11091109{
    11101110    // we should not enter style recalc while painting
    1111     if (frame() && frame()->isPainting()) {
    1112         ASSERT(!frame()->isPainting());
     1111    if (frame() && frame()->view() && frame()->view()->isPainting()) {
     1112        ASSERT(!frame()->view()->isPainting());
    11131113        return;
    11141114    }
  • trunk/WebCore/loader/Cache.cpp

    r36321 r37146  
    3131#include "DocLoader.h"
    3232#include "Document.h"
    33 #include "Frame.h"
    3433#include "FrameLoader.h"
     34#include "FrameView.h"
    3535#include "Image.h"
    3636#include "ResourceHandle.h"
     
    270270
    271271    unsigned targetSize = static_cast<unsigned>(capacity * cTargetPrunePercentage); // Cut by a percentage to avoid immediately pruning again.
    272     double currentTime = Frame::currentPaintTimeStamp();
     272    double currentTime = FrameView::currentPaintTimeStamp();
    273273    if (!currentTime) // In case prune is called directly, outside of a Frame paint.
    274274        currentTime = WebCore::currentTime();
  • trunk/WebCore/loader/CachedImage.cpp

    r36096 r37146  
    3030#include "CachedResourceClientWalker.h"
    3131#include "DocLoader.h"
    32 #include "Frame.h"
     32#include "FrameView.h"
    3333#include "Request.h"
    3434#include "SystemTime.h"
     
    302302        return;
    303303   
    304     double timeStamp = Frame::currentPaintTimeStamp();
     304    double timeStamp = FrameView::currentPaintTimeStamp();
    305305    if (!timeStamp) // If didDraw is called outside of a Frame paint.
    306306        timeStamp = currentTime();
  • trunk/WebCore/page/Frame.cpp

    r37112 r37146  
    9696using namespace HTMLNames;
    9797
    98 double Frame::s_currentPaintTimeStamp = 0.0;
    99 
    10098#ifndef NDEBUG   
    10199static WTF::RefCountedLeakCounter frameCounter("Frame");
     
    12401238}
    12411239
    1242 // FIXME: why is this here instead of on the FrameView?
    1243 void Frame::paint(GraphicsContext* p, const IntRect& rect)
    1244 {
    1245 #ifndef NDEBUG
    1246     bool fillWithRed;
    1247     if (!document() || document()->printing())
    1248         fillWithRed = false; // Printing, don't fill with red (can't remember why).
    1249     else if (document()->ownerElement())
    1250         fillWithRed = false; // Subframe, don't fill with red.
    1251     else if (view() && view()->isTransparent())
    1252         fillWithRed = false; // Transparent, don't fill with red.
    1253     else if (d->m_paintRestriction == PaintRestrictionSelectionOnly || d->m_paintRestriction == PaintRestrictionSelectionOnlyBlackText)
    1254         fillWithRed = false; // Selections are transparent, don't fill with red.
    1255     else if (d->m_elementToDraw)
    1256         fillWithRed = false; // Element images are transparent, don't fill with red.
    1257     else
    1258         fillWithRed = true;
    1259    
    1260     if (fillWithRed)
    1261         p->fillRect(rect, Color(0xFF, 0, 0));
    1262 #endif
    1263 
    1264     bool isTopLevelPainter = !s_currentPaintTimeStamp;
    1265     if (isTopLevelPainter)
    1266         s_currentPaintTimeStamp = currentTime();
    1267    
    1268     if (contentRenderer()) {
    1269         ASSERT(d->m_view && !d->m_view->needsLayout());
    1270         ASSERT(!d->m_isPainting);
    1271        
    1272         d->m_isPainting = true;
    1273        
    1274         // d->m_elementToDraw is used to draw only one element
    1275         RenderObject* eltRenderer = d->m_elementToDraw ? d->m_elementToDraw->renderer() : 0;
    1276         if (d->m_paintRestriction == PaintRestrictionNone)
    1277             document()->invalidateRenderedRectsForMarkersInRect(rect);
    1278         contentRenderer()->layer()->paint(p, rect, d->m_paintRestriction, eltRenderer);
    1279        
    1280         d->m_isPainting = false;
    1281 
    1282 #if ENABLE(DASHBOARD_SUPPORT)
    1283         // Regions may have changed as a result of the visibility/z-index of element changing.
    1284         if (document()->dashboardRegionsDirty())
    1285             view()->updateDashboardRegions();
    1286 #endif
    1287     } else
    1288         LOG_ERROR("called Frame::paint with nil renderer");
    1289        
    1290     if (isTopLevelPainter)
    1291         s_currentPaintTimeStamp = 0;
    1292 }
    1293 
    1294 void Frame::setPaintRestriction(PaintRestriction pr)
    1295 {
    1296     d->m_paintRestriction = pr;
    1297 }
    1298    
    1299 bool Frame::isPainting() const
    1300 {
    1301     return d->m_isPainting;
    1302 }
    1303 
    13041240void Frame::adjustPageHeight(float *newBottom, float oldTop, float oldBottom, float bottomLimit)
    13051241{
     
    16231559            GraphicsContext context((PlatformGraphicsContext*)0);
    16241560            context.setPaintingDisabled(true);
    1625             paint(&context, visibleRect);
     1561            d->m_view->paintContents(&context, visibleRect);
    16261562        }
    16271563    }
     
    18751811    , m_animationController(thisFrame)
    18761812    , m_lifeSupportTimer(thisFrame, &Frame::lifeSupportTimerFired)
    1877     , m_paintRestriction(PaintRestrictionNone)
    18781813    , m_caretVisible(false)
    18791814    , m_caretPaint(true)
    1880     , m_isPainting(false)
    18811815    , m_highlightTextMatches(false)
    18821816    , m_inViewSourceMode(false)
  • trunk/WebCore/page/Frame.h

    r37112 r37146  
    164164// === to be moved into FrameView
    165165
    166 public:
    167     void paint(GraphicsContext*, const IntRect&);
    168     void setPaintRestriction(PaintRestriction);
    169     bool isPainting() const;
    170 
    171     static double currentPaintTimeStamp() { return s_currentPaintTimeStamp; } // returns 0 if not painting
    172    
     166public:
    173167    void forceLayout(bool allowSubtree = false);
    174168    void forceLayoutWithPageWidthRange(float minPageWidth, float maxPageWidth, bool adjustViewSize);
     
    187181    void setProhibitsScrolling(const bool);
    188182
    189 private:
    190     static double s_currentPaintTimeStamp; // used for detecting decoded resource thrash in the cache
    191 
    192183// === to be moved into Chrome
    193184
  • trunk/WebCore/page/FramePrivate.h

    r37112 r37146  
    8282        Timer<Frame> m_lifeSupportTimer;
    8383
    84         RefPtr<Node> m_elementToDraw;
    85         PaintRestriction m_paintRestriction;
    86        
    8784        bool m_caretVisible;
    8885        bool m_caretPaint;
    89         bool m_isPainting;
    90 
     86       
    9187        bool m_highlightTextMatches;
    9288        bool m_inViewSourceMode;
  • trunk/WebCore/page/FrameView.cpp

    r37105 r37146  
    4646#include "RenderView.h"
    4747#include "Settings.h"
     48#include "SystemTime.h"
    4849
    4950namespace WebCore {
    5051
    5152using namespace HTMLNames;
     53
     54double FrameView::sCurrentPaintTimeStamp = 0.0;
    5255
    5356struct ScheduledEvent {
     
    101104        m_repaintRect = IntRect();
    102105        m_repaintRects.clear();
     106        m_paintRestriction = PaintRestrictionNone;
     107        m_isPainting = false;
    103108    }
    104109
     
    149154
    150155    bool m_shouldUpdateWhileOffscreen;
     156
     157    RefPtr<Node> m_nodeToDraw;
     158    PaintRestriction m_paintRestriction;
     159    bool m_isPainting;
    151160};
    152161
     
    350359   
    351360    // we shouldn't enter layout() while painting
    352     ASSERT(!m_frame->isPainting());
    353     if (m_frame->isPainting())
     361    ASSERT(!isPainting());
     362    if (isPainting())
    354363        return;
    355364
     
    10501059        GraphicsContext context(noContext);
    10511060        context.setUpdatingControlTints(true);
    1052 #if !PLATFORM(MAC)
    1053         ScrollView::paint(&context, frameRect());
    1054 #else
    1055         m_frame->paint(&context, visibleContentRect());
     1061        if (platformWidget())
     1062            paintContents(&context, visibleContentRect());
     1063        else
     1064            paint(&context, frameRect());
     1065    }
     1066}
     1067
     1068bool FrameView::wasScrolledByUser() const
     1069{
     1070    return d->m_wasScrolledByUser;
     1071}
     1072
     1073void FrameView::setWasScrolledByUser(bool wasScrolledByUser)
     1074{
     1075    if (d->m_inProgrammaticScroll)
     1076        return;
     1077    d->m_wasScrolledByUser = wasScrolledByUser;
     1078}
     1079
     1080void FrameView::paintContents(GraphicsContext* p, const IntRect& rect)
     1081{
     1082    if (!frame())
     1083        return;
     1084   
     1085    Document* document = frame()->document();
     1086    if (!document)
     1087        return;
     1088
     1089#ifndef NDEBUG
     1090    bool fillWithRed;
     1091    if (document || document->printing())
     1092        fillWithRed = false; // Printing, don't fill with red (can't remember why).
     1093    else if (document->ownerElement())
     1094        fillWithRed = false; // Subframe, don't fill with red.
     1095    else if (isTransparent())
     1096        fillWithRed = false; // Transparent, don't fill with red.
     1097    else if (d->m_paintRestriction == PaintRestrictionSelectionOnly || d->m_paintRestriction == PaintRestrictionSelectionOnlyBlackText)
     1098        fillWithRed = false; // Selections are transparent, don't fill with red.
     1099    else if (d->m_nodeToDraw)
     1100        fillWithRed = false; // Element images are transparent, don't fill with red.
     1101    else
     1102        fillWithRed = true;
     1103   
     1104    if (fillWithRed)
     1105        p->fillRect(rect, Color(0xFF, 0, 0));
    10561106#endif
    1057     }
    1058 }
    1059 
    1060 bool FrameView::wasScrolledByUser() const
    1061 {
    1062     return d->m_wasScrolledByUser;
    1063 }
    1064 
    1065 void FrameView::setWasScrolledByUser(bool wasScrolledByUser)
    1066 {
    1067     if (d->m_inProgrammaticScroll)
    1068         return;
    1069     d->m_wasScrolledByUser = wasScrolledByUser;
     1107
     1108    bool isTopLevelPainter = !sCurrentPaintTimeStamp;
     1109    if (isTopLevelPainter)
     1110        sCurrentPaintTimeStamp = currentTime();
     1111   
     1112    RenderView* contentRenderer = frame()->contentRenderer();
     1113    if (!contentRenderer) {
     1114        LOG_ERROR("called Frame::paint with nil renderer");
     1115        return;
     1116    }
     1117
     1118    ASSERT(!needsLayout());
     1119    ASSERT(!d->m_isPainting);
     1120       
     1121    d->m_isPainting = true;
     1122       
     1123    // m_nodeToDraw is used to draw only one element (and its descendants)
     1124    RenderObject* eltRenderer = d->m_nodeToDraw ? d->m_nodeToDraw->renderer() : 0;
     1125    if (d->m_paintRestriction == PaintRestrictionNone)
     1126        document->invalidateRenderedRectsForMarkersInRect(rect);
     1127    contentRenderer->layer()->paint(p, rect, d->m_paintRestriction, eltRenderer);
     1128       
     1129    d->m_isPainting = false;
     1130
     1131#if ENABLE(DASHBOARD_SUPPORT)
     1132    // Regions may have changed as a result of the visibility/z-index of element changing.
     1133    if (document->dashboardRegionsDirty())
     1134        updateDashboardRegions();
     1135#endif
     1136
     1137    if (isTopLevelPainter)
     1138        sCurrentPaintTimeStamp = 0;
     1139}
     1140
     1141void FrameView::setPaintRestriction(PaintRestriction pr)
     1142{
     1143    d->m_paintRestriction = pr;
     1144}
     1145   
     1146bool FrameView::isPainting() const
     1147{
     1148    return d->m_isPainting;
     1149}
     1150
     1151void FrameView::setNodeToDraw(Node* node)
     1152{
     1153    d->m_nodeToDraw = node;
    10701154}
    10711155
  • trunk/WebCore/page/FrameView.h

    r37105 r37146  
    2626#define FrameView_h
    2727
     28#include "IntSize.h"
     29#include "RenderLayer.h"
    2830#include "ScrollView.h"
    29 #include "IntSize.h"
    3031#include <wtf/Forward.h>
    3132#include <wtf/OwnPtr.h>
     
    9495
    9596    bool needsFullRepaint() const;
    96  
     97
    9798    void resetScrollbars();
    9899
     
    149150    void removeWidgetToUpdate(RenderPartObject*);
    150151
     152    virtual void paintContents(GraphicsContext*, const IntRect& damageRect);
     153    void setPaintRestriction(PaintRestriction);
     154    bool isPainting() const;
     155    void setNodeToDraw(Node*);
     156
     157    static double currentPaintTimeStamp() { return sCurrentPaintTimeStamp; } // returns 0 if not painting
     158   
    151159    // FIXME: This function should be used by all platforms, but currently depends on ScrollView::children,
    152160    // which not all platforms have. Once FrameView and ScrollView are merged, this #if should be removed.
     
    171179    virtual void repaintContentRectangle(const IntRect&, bool immediate);
    172180
     181    static double sCurrentPaintTimeStamp; // used for detecting decoded resource thrash in the cache
     182
    173183    unsigned m_refCount;
    174184    IntSize m_size;
  • trunk/WebCore/page/mac/FrameMac.mm

    r37061 r37146  
    317317NSImage* Frame::selectionImage(bool forceBlackText) const
    318318{
    319     d->m_paintRestriction = forceBlackText ? PaintRestrictionSelectionOnlyBlackText : PaintRestrictionSelectionOnly;
     319    d->m_view->setPaintRestriction(forceBlackText ? PaintRestrictionSelectionOnlyBlackText : PaintRestrictionSelectionOnly);
    320320    d->m_doc->updateLayout();
    321321    NSImage* result = imageFromRect(selectionRect());
    322     d->m_paintRestriction = PaintRestrictionNone;
     322    d->m_view->setPaintRestriction(PaintRestrictionNone);
    323323    return result;
    324324}
     
    336336    NSRect paintingRect = renderer->paintingRootRect(topLevelRect);
    337337
    338     d->m_elementToDraw = node;              // invoke special sub-tree drawing mode
     338    d->m_view->setNodeToDraw(node);              // invoke special sub-tree drawing mode
    339339    NSImage* result = imageFromRect(paintingRect);
    340340    renderer->updateDragState(false);
    341341    d->m_doc->updateLayout();
    342     d->m_elementToDraw = 0;
     342    d->m_view->setNodeToDraw(0);
    343343
    344344    if (elementRect)
     
    360360    NSRect paintingRect = renderer->paintingRootRect(topLevelRect);
    361361
    362     d->m_elementToDraw = node; // invoke special sub-tree drawing mode
     362    d->m_view->setNodeToDraw(node); // invoke special sub-tree drawing mode
    363363    NSImage* result = imageFromRect(paintingRect);
    364     d->m_elementToDraw = 0;
     364    d->m_view->setNodeToDraw(0);
    365365
    366366    return result;
  • trunk/WebCore/page/win/FrameCGWin.cpp

    r30674 r37146  
    5252HBITMAP imageFromSelection(Frame* frame, bool forceBlackText)
    5353{
    54     frame->setPaintRestriction(forceBlackText ? PaintRestrictionSelectionOnlyBlackText : PaintRestrictionSelectionOnly);
     54    frame->view()->setPaintRestriction(forceBlackText ? PaintRestrictionSelectionOnlyBlackText : PaintRestrictionSelectionOnly);
    5555    FloatRect fr = frame->selectionRect();
    5656    IntRect ir(static_cast<int>(fr.x()), static_cast<int>(fr.y()),
     
    8080    DeleteDC(hdc);
    8181
    82     frame->setPaintRestriction(PaintRestrictionNone);
     82    frame->view()->setPaintRestriction(PaintRestrictionNone);
    8383
    8484    return hbmp;
  • trunk/WebCore/platform/ScrollView.cpp

    r37127 r37146  
    2727#include "ScrollView.h"
    2828
     29#include "GraphicsContext.h"
    2930#include "HostWindow.h"
    3031#include "PlatformMouseEvent.h"
    3132#include "PlatformWheelEvent.h"
    3233#include "Scrollbar.h"
     34#include "ScrollbarTheme.h"
    3335
    3436using std::max;
     
    4446    m_scrollbarsAvoidingResizer = 0;
    4547    m_scrollbarsSuppressed = false;
     48    m_drawPanScrollIcon = false;
    4649}
    4750
     
    355358}
    356359
     360void ScrollView::paint(GraphicsContext* context, const IntRect& rect)
     361{
     362    if (platformWidget()) {
     363        Widget::paint(context, rect);
     364        return;
     365    }
     366
     367    if (context->paintingDisabled() && !context->updatingControlTints())
     368        return;
     369
     370    IntRect documentDirtyRect = rect;
     371    documentDirtyRect.intersect(frameRect());
     372
     373    context->save();
     374
     375    context->translate(x(), y());
     376    documentDirtyRect.move(-x(), -y());
     377
     378    context->translate(-scrollX(), -scrollY());
     379    documentDirtyRect.move(scrollX(), scrollY());
     380
     381    context->clip(visibleContentRect());
     382
     383    paintContents(context, documentDirtyRect);
     384
     385    context->restore();
     386
     387    // Now paint the scrollbars.
     388    if (!m_scrollbarsSuppressed && (m_horizontalScrollbar || m_verticalScrollbar)) {
     389        context->save();
     390        IntRect scrollViewDirtyRect = rect;
     391        scrollViewDirtyRect.intersect(frameRect());
     392        context->translate(x(), y());
     393        scrollViewDirtyRect.move(-x(), -y());
     394        if (m_horizontalScrollbar)
     395            m_horizontalScrollbar->paint(context, scrollViewDirtyRect);
     396        if (m_verticalScrollbar)
     397            m_verticalScrollbar->paint(context, scrollViewDirtyRect);
     398
     399        IntRect hCorner;
     400        if (m_horizontalScrollbar && width() - m_horizontalScrollbar->width() > 0) {
     401            hCorner = IntRect(m_horizontalScrollbar->width(),
     402                              height() - m_horizontalScrollbar->height(),
     403                              width() - m_horizontalScrollbar->width(),
     404                              m_horizontalScrollbar->height());
     405            if (hCorner.intersects(scrollViewDirtyRect))
     406                ScrollbarTheme::nativeTheme()->paintScrollCorner(this, context, hCorner);
     407        }
     408
     409        if (m_verticalScrollbar && height() - m_verticalScrollbar->height() > 0) {
     410            IntRect vCorner(width() - m_verticalScrollbar->width(),
     411                            m_verticalScrollbar->height(),
     412                            m_verticalScrollbar->width(),
     413                            height() - m_verticalScrollbar->height());
     414            if (vCorner != hCorner && vCorner.intersects(scrollViewDirtyRect))
     415                ScrollbarTheme::nativeTheme()->paintScrollCorner(this, context, vCorner);
     416        }
     417
     418        context->restore();
     419    }
     420
     421    // Paint the panScroll Icon
     422    static RefPtr<Image> panScrollIcon;
     423    if (m_drawPanScrollIcon) {
     424        if (!panScrollIcon)
     425            panScrollIcon = Image::loadPlatformResource("panIcon");
     426        context->drawImage(panScrollIcon.get(), m_panScrollIconPoint);
     427    }
     428}
     429
    357430#if !PLATFORM(MAC)
    358431void ScrollView::platformSetCanBlitOnScroll()
  • trunk/WebCore/platform/ScrollView.h

    r37113 r37146  
    185185#endif
    186186
     187    virtual void paint(GraphicsContext*, const IntRect&);
     188
    187189protected:
    188190    virtual void repaintContentRectangle(const IntRect&, bool now = false);
     191    virtual void paintContents(GraphicsContext*, const IntRect& damageRect) = 0;
     192
    189193    void updateWindowRect(const IntRect&, bool now = false);
    190194
     
    202206    int m_scrollbarsAvoidingResizer;
    203207    bool m_scrollbarsSuppressed;
     208
     209    IntPoint m_panScrollIconPoint;
     210    bool m_drawPanScrollIcon;
    204211
    205212    void init();
     
    236243#if !PLATFORM(MAC) && !PLATFORM(WX)
    237244public:
    238     virtual void paint(GraphicsContext*, const IntRect&);
    239 
    240245    virtual void setFrameRect(const IntRect&);
    241246
  • trunk/WebCore/platform/ScrollbarTheme.h

    r37118 r37146  
    2727#define ScrollbarTheme_h
    2828
     29#include "GraphicsContext.h"
    2930#include "IntRect.h"
    3031#include "ScrollTypes.h"
     
    3233namespace WebCore {
    3334
    34 class GraphicsContext;
    3535class PlatformMouseEvent;
    3636class Scrollbar;
     37class ScrollView;
    3738
    3839class ScrollbarTheme {
     
    4041    virtual ~ScrollbarTheme() {};
    4142
    42     virtual bool paint(Scrollbar*, GraphicsContext* context, const IntRect& damageRect) { return false; }
     43    virtual bool paint(Scrollbar*, GraphicsContext*, const IntRect& damageRect) { return false; }
    4344    virtual ScrollbarPart hitTest(Scrollbar*, const PlatformMouseEvent&) { return NoPart; }
    4445   
     
    7374    virtual void invalidatePart(Scrollbar*, ScrollbarPart) {}
    7475
     76    virtual void paintScrollCorner(ScrollView*, GraphicsContext* context, const IntRect& cornerRect) { context->fillRect(cornerRect, Color::white); }
     77
    7578    virtual bool shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent&) { return false; }
    7679    virtual int thumbPosition(Scrollbar*) { return 0; } // The position of the thumb relative to the track.
  • trunk/WebCore/platform/ScrollbarThemeComposite.cpp

    r37118 r37146  
    282282}
    283283
    284 }
     284void ScrollbarThemeComposite::paintScrollCorner(ScrollView* view, GraphicsContext* context, const IntRect& cornerRect)
     285{
     286    FrameView* frameView = static_cast<FrameView*>(view);
     287    Page* page = frameView->frame() ? frameView->frame()->page() : 0;
     288    if (page && page->settings()->shouldPaintCustomScrollbars()) {
     289        if (!page->chrome()->client()->paintCustomScrollCorner(context, cornerRect))
     290            context->fillRect(cornerRect, Color::white);
     291    }
     292}
     293
     294}
  • trunk/WebCore/platform/ScrollbarThemeComposite.h

    r37118 r37146  
    4444    virtual int trackLength(Scrollbar*);
    4545
     46    virtual void paintScrollCorner(ScrollView*, GraphicsContext*, const IntRect& cornerRect);
     47
    4648protected:
    4749    virtual bool hasButtons(Scrollbar*) = 0;
  • trunk/WebCore/platform/gtk/ScrollViewGtk.cpp

    r37113 r37146  
    466466}
    467467
    468 void ScrollView::paint(GraphicsContext* context, const IntRect& rect)
    469 {
    470     // FIXME: This code is here so we don't have to fork FrameView.h/.cpp.
    471     // In the end, FrameView should just merge with ScrollView.
    472     ASSERT(isFrameView());
    473 
    474     if (context->paintingDisabled())
    475         return;
    476 
    477     IntRect documentDirtyRect = rect;
    478     documentDirtyRect.intersect(frameRect());
    479 
    480     context->save();
    481 
    482     context->translate(x(), y());
    483     documentDirtyRect.move(-x(), -y());
    484 
    485     context->translate(-scrollX(), -scrollY());
    486     documentDirtyRect.move(scrollX(), scrollY());
    487 
    488     context->clip(enclosingIntRect(visibleContentRect()));
    489     static_cast<const FrameView*>(this)->frame()->paint(context, documentDirtyRect);
    490     context->restore();
    491 
    492     // Now paint the scrollbars.
    493     if (!m_scrollbarsSuppressed && (m_horizontalScrollbar || m_verticalScrollbar)) {
    494         context->save();
    495         IntRect scrollViewDirtyRect = rect;
    496         scrollViewDirtyRect.intersect(frameRect());
    497         context->translate(x(), y());
    498         scrollViewDirtyRect.move(-x(), -y());
    499         if (m_horizontalScrollbar)
    500             m_horizontalScrollbar->paint(context, scrollViewDirtyRect);
    501         if (m_verticalScrollbar)
    502             m_verticalScrollbar->paint(context, scrollViewDirtyRect);
    503 
    504         /*
    505          * FIXME: TODO: Check if that works with RTL
    506          */
    507         // Fill the scroll corner with white.
    508         IntRect hCorner;
    509         if (m_horizontalScrollbar && width() - m_horizontalScrollbar->width() > 0) {
    510             hCorner = IntRect(m_horizontalScrollbar->width(),
    511                               height() - m_horizontalScrollbar->height(),
    512                               width() - m_horizontalScrollbar->width(),
    513                               m_horizontalScrollbar->height());
    514             if (hCorner.intersects(scrollViewDirtyRect))
    515                 context->fillRect(hCorner, Color::white);
    516         }
    517 
    518         if (m_verticalScrollbar && height() - m_verticalScrollbar->height() > 0) {
    519             IntRect vCorner(width() - m_verticalScrollbar->width(),
    520                             m_verticalScrollbar->height(),
    521                             m_verticalScrollbar->width(),
    522                             height() - m_verticalScrollbar->height());
    523             if (vCorner != hCorner && vCorner.intersects(scrollViewDirtyRect))
    524                 context->fillRect(vCorner, Color::white);
    525         }
    526 
    527         context->restore();
    528     }
    529 }
    530 
    531468void ScrollView::addToDirtyRegion(const IntRect& containingWindowRect)
    532469{
  • trunk/WebCore/platform/qt/ScrollViewQt.cpp

    r37113 r37146  
    360360}
    361361
    362 static void drawScrollbarCorner(GraphicsContext* context, const IntRect& rect)
    363 {
    364 #if QT_VERSION < 0x040500
    365     context->fillRect(rect, QApplication::palette().color(QPalette::Normal, QPalette::Window));
    366 #else
    367     QStyleOption option;
    368     option.rect = rect;
    369     QApplication::style()->drawPrimitive(QStyle::PE_PanelScrollAreaCorner,
    370             &option, context->platformContext(), 0);
    371 #endif
    372 }
    373 
    374 
    375 void ScrollView::paint(GraphicsContext* context, const IntRect& rect)
    376 {
    377     // FIXME: This code is here so we don't have to fork FrameView.h/.cpp.
    378     // In the end, FrameView should just merge with ScrollView.
    379     ASSERT(isFrameView());
    380 
    381     if (context->paintingDisabled())
    382         return;
    383 
    384     IntRect documentDirtyRect = rect;
    385 
    386     context->save();
    387 
    388     context->translate(x(), y());
    389     documentDirtyRect.move(-x(), -y());
    390 
    391     context->translate(-scrollX(), -scrollY());
    392     documentDirtyRect.move(scrollX(), scrollY());
    393 
    394     documentDirtyRect.intersect(enclosingIntRect(visibleContentRect()));
    395     context->clip(documentDirtyRect);
    396 
    397     static_cast<const FrameView*>(this)->frame()->paint(context, documentDirtyRect);
    398 
    399     context->restore();
    400 
    401     // Now paint the scrollbars.
    402     if (!m_scrollbarsSuppressed && (m_horizontalScrollbar || m_verticalScrollbar)) {
    403         context->save();
    404         IntRect scrollViewDirtyRect = rect;
    405         scrollViewDirtyRect.intersect(frameRect());
    406         context->translate(x(), y());
    407         scrollViewDirtyRect.move(-x(), -y());
    408         if (m_horizontalScrollbar)
    409             m_horizontalScrollbar->paint(context, scrollViewDirtyRect);
    410         if (m_verticalScrollbar)
    411             m_verticalScrollbar->paint(context, scrollViewDirtyRect);
    412 
    413         // Fill the scroll corners using the current Qt style
    414         IntRect hCorner;
    415         if (m_horizontalScrollbar && width() - m_horizontalScrollbar->width() > 0) {
    416             hCorner = IntRect(m_horizontalScrollbar->width(),
    417                               height() - m_horizontalScrollbar->height(),
    418                               width() - m_horizontalScrollbar->width(),
    419                               m_horizontalScrollbar->height());
    420             if (hCorner.intersects(scrollViewDirtyRect))
    421                 drawScrollbarCorner(context, hCorner);
    422         }
    423 
    424         if (m_verticalScrollbar && height() - m_verticalScrollbar->height() > 0) {
    425             IntRect vCorner(width() - m_verticalScrollbar->width(),
    426                             m_verticalScrollbar->height(),
    427                             m_verticalScrollbar->width(),
    428                             height() - m_verticalScrollbar->height());
    429             if (vCorner != hCorner && vCorner.intersects(scrollViewDirtyRect))
    430                 drawScrollbarCorner(context, vCorner);
    431         }
    432 
    433         context->restore();
    434     }
    435 }
    436 
    437362void ScrollView::addToDirtyRegion(const IntRect& containingWindowRect)
    438363{
  • trunk/WebCore/platform/qt/ScrollbarThemeQt.cpp

    r37118 r37146  
    211211}
    212212
    213 }
    214 
     213void ScrollbarThemeQt::paintScrollbarCorner(ScrollView*, GraphicsContext* context, const IntRect& rect)
     214{
     215#if QT_VERSION < 0x040500
     216    context->fillRect(rect, QApplication::palette().color(QPalette::Normal, QPalette::Window));
     217#else
     218    QStyleOption option;
     219    option.rect = rect;
     220    QApplication::style()->drawPrimitive(QStyle::PE_PanelScrollAreaCorner,
     221            &option, context->platformContext(), 0);
     222#endif
     223}
     224
     225}
     226
  • trunk/WebCore/platform/qt/ScrollbarThemeQt.h

    r37118 r37146  
    3535    virtual ~ScrollbarThemeQt();
    3636
    37     virtual bool paint(Scrollbar*, GraphicsContext* context, const IntRect& damageRect);
     37    virtual bool paint(Scrollbar*, GraphicsContext*, const IntRect& damageRect);
     38    virtual void paintScrollCorner(ScrollView*, GraphicsContext*, const IntRect& cornerRect);
     39
    3840    virtual ScrollbarPart hitTest(Scrollbar*, const PlatformMouseEvent&);
    3941
  • trunk/WebCore/platform/win/ScrollViewWin.cpp

    r37113 r37146  
    6060        : m_view(view)
    6161        , m_inUpdateScrollbars(false)
    62         , m_panScrollIconPoint(0,0)
    63         , m_drawPanScrollIcon(false)
    6462    {
    6563    }
     
    8482    bool m_inUpdateScrollbars;
    8583    HRGN m_dirtyRegion;
    86     IntPoint m_panScrollIconPoint;
    87     bool m_drawPanScrollIcon;
    8884};
    8985
     
    146142    ::InvalidateRect(containingWindowHandle, &r, false);
    147143
    148     if (m_drawPanScrollIcon) {
     144    if (m_view->m_drawPanScrollIcon) {
    149145        int panIconDirtySquareSizeLength = 2 * (panIconSizeLength + max(abs(scrollDelta.width()), abs(scrollDelta.height()))); // We only want to repaint what's necessary
    150         IntPoint panIconDirtySquareLocation = IntPoint(m_panScrollIconPoint.x() - (panIconDirtySquareSizeLength / 2), m_panScrollIconPoint.y() - (panIconDirtySquareSizeLength / 2));
     146        IntPoint panIconDirtySquareLocation = IntPoint(m_view->m_panScrollIconPoint.x() - (panIconDirtySquareSizeLength / 2), m_view->m_panScrollIconPoint.y() - (panIconDirtySquareSizeLength / 2));
    151147        IntRect panScrollIconDirtyRect = IntRect(panIconDirtySquareLocation , IntSize(panIconDirtySquareSizeLength, panIconDirtySquareSizeLength));
    152148       
     
    357353void ScrollView::printPanScrollIcon(const IntPoint& iconPosition)
    358354{
    359     m_data->m_drawPanScrollIcon = true;   
    360     m_data->m_panScrollIconPoint = IntPoint(iconPosition.x() - panIconSizeLength / 2 , iconPosition.y() - panIconSizeLength / 2) ;
    361 
    362     updateWindowRect(IntRect(m_data->m_panScrollIconPoint, IntSize(panIconSizeLength,panIconSizeLength)), true);   
     355    m_drawPanScrollIcon = true;   
     356    m_panScrollIconPoint = IntPoint(iconPosition.x() - panIconSizeLength / 2 , iconPosition.y() - panIconSizeLength / 2) ;
     357
     358    updateWindowRect(IntRect(m_panScrollIconPoint, IntSize(panIconSizeLength,panIconSizeLength)), true);   
    363359}
    364360
    365361void ScrollView::removePanScrollIcon()
    366362{
    367     m_data->m_drawPanScrollIcon = false;
    368 
    369     updateWindowRect(IntRect(m_data->m_panScrollIconPoint, IntSize(panIconSizeLength, panIconSizeLength)), true);
    370 }
    371 
    372 void ScrollView::paint(GraphicsContext* context, const IntRect& rect)
    373 {
    374     // FIXME: This code is here so we don't have to fork FrameView.h/.cpp.
    375     // In the end, FrameView should just merge with ScrollView.
    376     ASSERT(isFrameView());
    377 
    378     if (context->paintingDisabled() && !context->updatingControlTints())
    379         return;
    380 
    381     IntRect documentDirtyRect = rect;
    382     documentDirtyRect.intersect(frameRect());
    383 
    384     context->save();
    385 
    386     context->translate(x(), y());
    387     documentDirtyRect.move(-x(), -y());
    388 
    389     context->translate(-scrollX(), -scrollY());
    390     documentDirtyRect.move(scrollX(), scrollY());
    391 
    392     context->clip(visibleContentRect());
    393 
    394     const FrameView* frameView = static_cast<const FrameView*>(this);
    395     frameView->frame()->paint(context, documentDirtyRect);
    396 
    397     context->restore();
    398 
    399     // Now paint the scrollbars.
    400     if (!m_scrollbarsSuppressed && (m_horizontalScrollbar || m_verticalScrollbar)) {
    401         context->save();
    402         IntRect scrollViewDirtyRect = rect;
    403         scrollViewDirtyRect.intersect(frameRect());
    404         context->translate(x(), y());
    405         scrollViewDirtyRect.move(-x(), -y());
    406         if (m_horizontalScrollbar)
    407             m_horizontalScrollbar->paint(context, scrollViewDirtyRect);
    408         if (m_verticalScrollbar)
    409             m_verticalScrollbar->paint(context, scrollViewDirtyRect);
    410 
    411         // Fill the scroll corner with white.
    412         IntRect hCorner;
    413         if (m_horizontalScrollbar && width() - m_horizontalScrollbar->width() > 0) {
    414             hCorner = IntRect(m_horizontalScrollbar->width(),
    415                               height() - m_horizontalScrollbar->height(),
    416                               width() - m_horizontalScrollbar->width(),
    417                               m_horizontalScrollbar->height());
    418             if (hCorner.intersects(scrollViewDirtyRect)) {
    419                 Page* page = frameView->frame() ? frameView->frame()->page() : 0;
    420                 if (page && page->settings()->shouldPaintCustomScrollbars()) {
    421                     if (!page->chrome()->client()->paintCustomScrollCorner(context, hCorner))
    422                         context->fillRect(hCorner, Color::white);
    423                 }
    424             }
    425         }
    426 
    427         if (m_verticalScrollbar && height() - m_verticalScrollbar->height() > 0) {
    428             IntRect vCorner(width() - m_verticalScrollbar->width(),
    429                             m_verticalScrollbar->height(),
    430                             m_verticalScrollbar->width(),
    431                             height() - m_verticalScrollbar->height());
    432             if (vCorner != hCorner && vCorner.intersects(scrollViewDirtyRect)) {
    433                 Page* page = frameView->frame() ? frameView->frame()->page() : 0;
    434                 if (page && page->settings()->shouldPaintCustomScrollbars()) {
    435                     if (!page->chrome()->client()->paintCustomScrollCorner(context, vCorner))
    436                         context->fillRect(vCorner, Color::white);
    437                 }
    438             }
    439         }
    440 
    441         context->restore();
    442     }
    443 
    444     //Paint the panScroll Icon
    445     static RefPtr<Image> panScrollIcon;
    446     if (m_data->m_drawPanScrollIcon) {
    447         if (!panScrollIcon)
    448             panScrollIcon = Image::loadPlatformResource("panIcon");
    449         context->drawImage(panScrollIcon.get(), m_data->m_panScrollIconPoint);
    450     }
     363    m_drawPanScrollIcon = false;
     364
     365    updateWindowRect(IntRect(m_panScrollIconPoint, IntSize(panIconSizeLength, panIconSizeLength)), true);
    451366}
    452367
  • trunk/WebCore/svg/graphics/SVGImage.cpp

    r37112 r37146  
    154154    if (m_frame->view()->needsLayout())
    155155        m_frame->view()->layout();
    156     m_frame->paint(context, enclosingIntRect(srcRect));
     156    m_frame->view()->paint(context, enclosingIntRect(srcRect));
    157157
    158158    if (compositeOp != CompositeSourceOver)
  • trunk/WebKit/mac/ChangeLog

    r37131 r37146  
     12008-09-30   Dave Hyatt  <hyatt@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=21269
     4 
     5        This patch makes the ScrollView::paint method cross-platform.  The paint method calls the base class
     6        Widget paint on platforms with native widgets (Mac and wx).  Otherwise it calls a virtual function,
     7        paintContents, to paint the ScrollView's contents, and then it paints each of the two scrollbars and
     8        the scrollbar corner.
     9       
     10        The scrollbar themes are now responsible for painting scrollbar corners.  At the moment ScrollbarThemeWin still
     11        paints white (which is incorrect), so a future patch will actually implement proper native scroll corner painting
     12        for Windows.
     13       
     14        paintContents is implemented by FrameView, and replaces Frame::paint.  All of the FramePrivate member
     15        variables used by Frame::paint have moved to FrameViewPrivate instead.  All callers of Frame::paint have
     16        been patched to use FrameView::paintContents instead.
     17       
     18        Reviewed by Darin Adler
     19
     20        * WebView/WebFrame.mm:
     21        (-[WebFrame _drawRect:]):
     22
    1232008-09-30  Kevin Decker  <kdecker@apple.com>
    224
  • trunk/WebKit/mac/WebView/WebFrame.mm

    r36553 r37146  
    560560    GraphicsContext context(platformContext);
    561561   
    562     _private->coreFrame->paint(&context, enclosingIntRect(rect));
     562    _private->coreFrame->view()->paintContents(&context, enclosingIntRect(rect));
    563563}
    564564
  • trunk/WebKit/win/ChangeLog

    r37105 r37146  
     12008-09-30   Dave Hyatt  <hyatt@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=21269
     4 
     5        This patch makes the ScrollView::paint method cross-platform.  The paint method calls the base class
     6        Widget paint on platforms with native widgets (Mac and wx).  Otherwise it calls a virtual function,
     7        paintContents, to paint the ScrollView's contents, and then it paints each of the two scrollbars and
     8        the scrollbar corner.
     9       
     10        The scrollbar themes are now responsible for painting scrollbar corners.  At the moment ScrollbarThemeWin still
     11        paints white (which is incorrect), so a future patch will actually implement proper native scroll corner painting
     12        for Windows.
     13       
     14        paintContents is implemented by FrameView, and replaces Frame::paint.  All of the FramePrivate member
     15        variables used by Frame::paint have moved to FrameViewPrivate instead.  All callers of Frame::paint have
     16        been patched to use FrameView::paintContents instead.
     17       
     18        Reviewed by Darin Adler
     19
     20        * WebFrame.cpp:
     21        (WebFrame::paintDocumentRectToContext):
     22        (WebFrame::spoolPages):
     23
    1242008-09-30  Dave Hyatt  <hyatt@apple.com>
    225
  • trunk/WebKit/win/WebFrame.cpp

    r36971 r37146  
    322322    gc.clip(dirtyRect);
    323323    gc.translate(-rect.left, -rect.top);
    324     coreFrame->paint(&gc, rect);
     324    view->paintContents(&gc, rect);
    325325    gc.restore();
    326326
     
    18401840        CGContextSetBaseCTM(pctx, ctm);
    18411841
    1842         coreFrame->paint(&spoolCtx, pageRect);
     1842        coreFrame->view()->paintContents(&spoolCtx, pageRect);
    18431843
    18441844        if (ui2) {
Note: See TracChangeset for help on using the changeset viewer.