Changeset 171207 in webkit


Ignore:
Timestamp:
Jul 17, 2014 4:49:21 PM (10 years ago)
Author:
Beth Dakin
Message:

Fixed position elements are misplaced when a WK1 view has contentInsets set
https://bugs.webkit.org/show_bug.cgi?id=135031
-and corresponding-
<rdar://problem/17682335>

Reviewed by Tim Horton.

[NSScrollView documentVisibleRect] is not the rect that we are looking for when
this function is called. WebCore is interested in the rect that does not include
content that is within the inset region.

Implement contract() to avoid the awkwardness of calling expand() with negative
values.

  • platform/graphics/IntSize.h:

(WebCore::IntSize::contract):

Use _insetBounds instead of documentVisibleRect, and when it’s necessary to use
the frame’s dimensions, extract the inset from that size.

  • platform/mac/ScrollViewMac.mm:

(WebCore::ScrollView::platformVisibleContentRect):
(WebCore::ScrollView::platformVisibleContentSize):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r171203 r171207  
     12014-07-17  Beth Dakin  <bdakin@apple.com>
     2
     3        Fixed position elements are misplaced when a WK1 view has contentInsets set
     4        https://bugs.webkit.org/show_bug.cgi?id=135031
     5        -and corresponding-
     6        <rdar://problem/17682335>
     7
     8        Reviewed by Tim Horton.
     9
     10        [NSScrollView documentVisibleRect] is not the rect that we are looking for when
     11        this function is called. WebCore is interested in the rect that does not include
     12        content that is within the inset region.
     13
     14        Implement contract() to avoid the awkwardness of calling expand() with negative
     15        values.
     16        * platform/graphics/IntSize.h:
     17        (WebCore::IntSize::contract):
     18
     19        Use _insetBounds instead of documentVisibleRect, and when it’s necessary to use
     20        the frame’s dimensions, extract the inset from that size.
     21        * platform/mac/ScrollViewMac.mm:
     22        (WebCore::ScrollView::platformVisibleContentRect):
     23        (WebCore::ScrollView::platformVisibleContentSize):
     24
    1252014-07-17  Enrica Casucci  <enrica@apple.com>
    226
  • trunk/Source/WebCore/platform/graphics/IntSize.h

    r166582 r171207  
    8282    }
    8383
     84    void contract(int width, int height)
     85    {
     86        m_width -= width;
     87        m_height -= height;
     88    }
     89
    8490    void scale(float widthScale, float heightScale)
    8591    {
  • trunk/Source/WebCore/platform/mac/ScrollViewMac.mm

    r165676 r171207  
    3535#import "WebCoreFrameView.h"
    3636
     37@interface NSClipView (Details)
     38- (NSRect)_insetBounds;
     39@end
     40
     41@interface NSScrollView (Details)
     42- (NSEdgeInsets)contentInsets;
     43@end
     44
    3745@interface NSWindow (WebWindowDetails)
    3846- (BOOL)_needsToResetDragMargins;
     
    108116{
    109117    BEGIN_BLOCK_OBJC_EXCEPTIONS;
    110     IntRect result = enclosingIntRect([scrollView() documentVisibleRect]);
    111     if (includeScrollbars)
    112         result.setSize(IntSize([scrollView() frame].size));
    113     return result;
    114     END_BLOCK_OBJC_EXCEPTIONS;
     118
     119    IntRect visibleContentRect;
     120#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 10100
     121    visibleContentRect = enclosingIntRect([[scrollView() contentView] _insetBounds]);
     122#else
     123    visibleContentRect = enclosingIntRect([scrollView() documentVisibleRect]);
     124#endif
     125
     126    if (includeScrollbars) {
     127        IntSize frameSize([scrollView() frame].size);
     128#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 10100
     129        frameSize.contract(scrollView().contentInsets.left + scrollView().contentInsets.right, scrollView().contentInsets.top + scrollView().contentInsets.bottom);
     130#endif
     131        visibleContentRect.setSize(frameSize);
     132    }
     133
     134    return visibleContentRect;
     135    END_BLOCK_OBJC_EXCEPTIONS;
     136
    115137    return IntRect();
    116138}
     
    118140IntSize ScrollView::platformVisibleContentSize(bool includeScrollbars) const
    119141{
    120     BEGIN_BLOCK_OBJC_EXCEPTIONS;
    121     if (includeScrollbars)
    122         return IntSize([scrollView() frame].size);
    123 
    124     return expandedIntSize(FloatSize([scrollView() documentVisibleRect].size));
    125     END_BLOCK_OBJC_EXCEPTIONS;
    126     return IntSize();
     142    return platformVisibleContentRect(includeScrollbars).size();
    127143}
    128144
Note: See TracChangeset for help on using the changeset viewer.