Changeset 153810 in webkit


Ignore:
Timestamp:
Aug 7, 2013 7:00:07 PM (11 years ago)
Author:
Simon Fraser
Message:

Avoid spurious "all repaint" layouts when scrolling WebViews on Retina displays
https://bugs.webkit.org/show_bug.cgi?id=119564

Reviewed by Beth Dakin.

When scrolling WebViews on Macs with Retina displays, AppKit uses
device pixels for the scroll offset, so [scrollView() documentVisibleRect]
can return a CGRect with non-integral origin. This rect is used by layout,
via layoutSize(), to decide whether the view size changed, which prompts
a full repaint. However, FrameView gets a value which has been rounded
by enclosingIntRect(), which increases the height or width by 1px if the
y or x offset is on a half-pixel, causing spurious full repaints.

Fix by plumbing through platformVisibleContentSize(), which just
gets the size of the -documentVisibleRect.

  • page/FrameView.cpp:

(WebCore::FrameView::layout): Don't get layoutHeight and layoutWidth
separately, since that is two calls down into platformVisibleContentSize.

  • platform/ScrollView.cpp:

(WebCore::ScrollView::unscaledVisibleContentSize):
(WebCore::ScrollView::platformVisibleContentSize):

  • platform/ScrollView.h:
  • platform/mac/ScrollViewMac.mm:

(WebCore::ScrollView::platformVisibleContentSize):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r153809 r153810  
     12013-08-07  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Avoid spurious "all repaint" layouts when scrolling WebViews on Retina displays
     4        https://bugs.webkit.org/show_bug.cgi?id=119564
     5
     6        Reviewed by Beth Dakin.
     7
     8        When scrolling WebViews on Macs with Retina displays, AppKit uses
     9        device pixels for the scroll offset, so [scrollView() documentVisibleRect]
     10        can return a CGRect with non-integral origin. This rect is used by layout,
     11        via layoutSize(), to decide whether the view size changed, which prompts
     12        a full repaint. However, FrameView gets a value which has been rounded
     13        by enclosingIntRect(), which increases the height or width by 1px if the
     14        y or x offset is on a half-pixel, causing spurious full repaints.
     15       
     16        Fix by plumbing through platformVisibleContentSize(), which just
     17        gets the size of the -documentVisibleRect.
     18       
     19        * page/FrameView.cpp:
     20        (WebCore::FrameView::layout): Don't get layoutHeight and layoutWidth
     21        separately, since that is two calls down into platformVisibleContentSize.
     22        * platform/ScrollView.cpp:
     23        (WebCore::ScrollView::unscaledVisibleContentSize):
     24        (WebCore::ScrollView::platformVisibleContentSize):
     25        * platform/ScrollView.h:
     26        * platform/mac/ScrollViewMac.mm:
     27        (WebCore::ScrollView::platformVisibleContentSize):
     28
    1292013-08-07  Simon Fraser  <simon.fraser@apple.com>
    230
  • trunk/Source/WebCore/page/FrameView.cpp

    r153701 r153810  
    12941294            LayoutSize oldSize = m_size;
    12951295
    1296             m_size = LayoutSize(layoutWidth(), layoutHeight());
     1296            m_size = layoutSize();
    12971297
    12981298            if (oldSize != m_size) {
  • trunk/Source/WebCore/platform/ScrollView.cpp

    r152265 r153810  
    222222{
    223223    if (platformWidget())
    224         return platformVisibleContentRect(scrollbarInclusion == IncludeScrollbars).size();
     224        return platformVisibleContentSize(scrollbarInclusion == IncludeScrollbars);
    225225
    226226    if (!m_fixedVisibleContentRect.isEmpty())
     
    14131413}
    14141414
     1415IntSize ScrollView::platformVisibleContentSize(bool) const
     1416{
     1417    return IntSize();
     1418}
     1419
    14151420void ScrollView::platformSetContentsSize()
    14161421{
  • trunk/Source/WebCore/platform/ScrollView.h

    r149417 r153810  
    389389    bool platformCanBlitOnScroll() const;
    390390    IntRect platformVisibleContentRect(bool includeScrollbars) const;
     391    IntSize platformVisibleContentSize(bool includeScrollbars) const;
    391392    void platformSetContentsSize();
    392393    IntRect platformContentsToScreen(const IntRect&) const;
  • trunk/Source/WebCore/platform/mac/ScrollViewMac.mm

    r149980 r153810  
    2929#import "BlockExceptions.h"
    3030#import "FloatRect.h"
     31#import "FloatSize.h"
    3132#import "IntRect.h"
    3233#import "Logging.h"
     
    117118}
    118119
     120IntSize ScrollView::platformVisibleContentSize(bool includeScrollbars) const
     121{
     122    BEGIN_BLOCK_OBJC_EXCEPTIONS;
     123    if (includeScrollbars)
     124        return IntSize([scrollView() frame].size);
     125
     126    return expandedIntSize(FloatSize([scrollView() documentVisibleRect].size));
     127    END_BLOCK_OBJC_EXCEPTIONS;
     128    return IntSize();
     129}
     130
    119131void ScrollView::platformSetContentsSize()
    120132{
Note: See TracChangeset for help on using the changeset viewer.