Changeset 142045 in webkit


Ignore:
Timestamp:
Feb 6, 2013 3:47:17 PM (11 years ago)
Author:
aelias@chromium.org
Message:

Make ScrollView::paint() clip by visibleContentRect
https://bugs.webkit.org/show_bug.cgi?id=108888

Reviewed by Levi Weintraub.

When applyPageScaleFactorInCompositor or fixedVisibleContentRect
are used, frameRect() and visibleContentRect(true).size() are
no longer synonyms, and the latter is the one that should be
used for clipping paints.

New WebFrameTest: pageScaleFactorScalesPaintClip.

Source/WebCore:

  • platform/ScrollView.cpp:

(WebCore::ScrollView::paint):

Source/WebKit/chromium:

  • tests/WebFrameTest.cpp:
Location:
trunk/Source
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r142043 r142045  
     12013-02-06  Alexandre Elias  <aelias@chromium.org>
     2
     3        Make ScrollView::paint() clip by visibleContentRect
     4        https://bugs.webkit.org/show_bug.cgi?id=108888
     5
     6        Reviewed by Levi Weintraub.
     7
     8        When applyPageScaleFactorInCompositor or fixedVisibleContentRect
     9        are used, frameRect() and visibleContentRect(true).size() are
     10        no longer synonyms, and the latter is the one that should be
     11        used for clipping paints.
     12
     13        New WebFrameTest: pageScaleFactorScalesPaintClip.
     14
     15        * platform/ScrollView.cpp:
     16        (WebCore::ScrollView::paint):
     17
    1182013-02-06  Dima Gorbik  <dgorbik@apple.com>
    219
  • trunk/Source/WebCore/platform/ScrollView.cpp

    r141450 r142045  
    10521052    notifyPageThatContentAreaWillPaint();
    10531053
    1054     IntRect clipRect = frameRect();
    1055     if (verticalScrollbar() && !verticalScrollbar()->isOverlayScrollbar())
    1056         clipRect.setWidth(clipRect.width() - verticalScrollbar()->width());
    1057     if (horizontalScrollbar() && !horizontalScrollbar()->isOverlayScrollbar())
    1058         clipRect.setHeight(clipRect.height() - horizontalScrollbar()->height());
    1059 
    10601054    IntRect documentDirtyRect = rect;
    1061     documentDirtyRect.intersect(clipRect);
     1055    IntRect visibleAreaWithoutScrollbars(location(), visibleContentRect(false).size());
     1056    documentDirtyRect.intersect(visibleAreaWithoutScrollbars);
    10621057
    10631058    if (!documentDirtyRect.isEmpty()) {
     
    10881083        GraphicsContextStateSaver stateSaver(*context);
    10891084        IntRect scrollViewDirtyRect = rect;
    1090         scrollViewDirtyRect.intersect(frameRect());
     1085        IntRect visibleAreaWithScrollbars(location(), visibleContentRect(true).size());
     1086        scrollViewDirtyRect.intersect(visibleAreaWithScrollbars);
    10911087        context->translate(x(), y());
    10921088        scrollViewDirtyRect.moveBy(-location());
  • trunk/Source/WebKit/chromium/ChangeLog

    r142031 r142045  
     12013-02-06  Alexandre Elias  <aelias@chromium.org>
     2
     3        Make ScrollView::paint() clip by visibleContentRect
     4        https://bugs.webkit.org/show_bug.cgi?id=108888
     5
     6        Reviewed by Levi Weintraub.
     7
     8        When applyPageScaleFactorInCompositor or fixedVisibleContentRect
     9        are used, frameRect() and visibleContentRect(true).size() are
     10        no longer synonyms, and the latter is the one that should be
     11        used for clipping paints.
     12
     13        New WebFrameTest: pageScaleFactorScalesPaintClip.
     14
     15        * tests/WebFrameTest.cpp:
     16
    1172013-02-06  Sheriff Bot  <webkit.review.bot@gmail.com>
    218
  • trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp

    r141850 r142045  
    3737#include "FrameTestHelpers.h"
    3838#include "FrameView.h"
     39#include "PlatformContextSkia.h"
    3940#include "Range.h"
    4041#include "RenderView.h"
    4142#include "ResourceError.h"
    4243#include "Settings.h"
     44#include "SkBitmap.h"
     45#include "SkCanvas.h"
    4346#include "URLTestHelpers.h"
    4447#include "WebDataSource.h"
     
    7174namespace {
    7275
     76#define EXPECT_EQ_RECT(a, b) \
     77    EXPECT_EQ(a.x(), b.x()); \
     78    EXPECT_EQ(a.y(), b.y()); \
     79    EXPECT_EQ(a.width(), b.width()); \
     80    EXPECT_EQ(a.height(), b.height());
     81
    7382class WebFrameTest : public testing::Test {
    7483public:
     
    449458}
    450459#endif
     460
     461TEST_F(WebFrameTest, pageScaleFactorScalesPaintClip)
     462{
     463    registerMockedHttpURLLoad("fixed_layout.html");
     464
     465    FixedLayoutTestWebViewClient client;
     466    client.m_screenInfo.deviceScaleFactor = 1;
     467    int viewportWidth = 50;
     468    int viewportHeight = 50;
     469
     470    WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client));
     471    webViewImpl->settings()->setApplyDeviceScaleFactorInCompositor(true);
     472    webViewImpl->settings()->setApplyPageScaleFactorInCompositor(true);
     473    webViewImpl->enableFixedLayoutMode(true);
     474    webViewImpl->settings()->setViewportEnabled(true);
     475    webViewImpl->resize(WebSize(viewportWidth, viewportHeight));
     476    webViewImpl->layout();
     477
     478    // Set <1 page scale so that the clip rect should be larger than
     479    // the viewport size as passed into resize().
     480    webViewImpl->setPageScaleFactor(0.5, WebPoint());
     481
     482    SkBitmap bitmap;
     483    bitmap.setConfig(SkBitmap::kARGB_8888_Config, 200, 200);
     484    bitmap.allocPixels();
     485    bitmap.eraseColor(0);
     486    SkCanvas canvas(bitmap);
     487
     488    WebCore::PlatformContextSkia platformContext(&canvas);
     489    platformContext.setTrackOpaqueRegion(true);
     490    WebCore::GraphicsContext context(&platformContext);
     491
     492    EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 0, 0), platformContext.opaqueRegion().asRect());
     493
     494    WebCore::FrameView* view = webViewImpl->mainFrameImpl()->frameView();
     495    WebCore::IntRect paintRect(0, 0, 200, 200);
     496    view->paint(&context, paintRect);
     497
     498    int viewportWidthMinusScrollbar = 50 - (view->verticalScrollbar()->isOverlayScrollbar() ? 0 : 15);
     499    int viewportHeightMinusScrollbar = 50 - (view->horizontalScrollbar()->isOverlayScrollbar() ? 0 : 15);
     500    WebCore::IntRect clippedRect(0, 0, viewportWidthMinusScrollbar * 2, viewportHeightMinusScrollbar * 2);
     501    EXPECT_EQ_RECT(clippedRect, platformContext.opaqueRegion().asRect());
     502}
    451503
    452504TEST_F(WebFrameTest, CanOverrideMaximumScaleFactor)
Note: See TracChangeset for help on using the changeset viewer.