⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 184065 in webkit


Ignore:
Timestamp:
May 10, 2015, 8:56:15 PM (11 years ago)
Author:
Simon Fraser
Message:

background-position sometimes doesn't work properly with background-attachment: fixed
https://bugs.webkit.org/show_bug.cgi?id=103757
rdar://problem/18749925

Reviewed by Darin Adler.

Source/WebCore:

Fix sizing issues with fixed backgrounds when top content inset (blurred toolbar) is in
effect.

The primary issue was that positioningAreaSize was including the top content inset
height, and should not have been, but there were also issues with the "fixedBackgroundPaintsInLocalCoordinates"
code path, which kicks in when the root background is fixed.

Tests: platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover-local.html

platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover.html
platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-local.html
platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-positioned.html

  • rendering/RenderBoxModelObject.cpp:

(WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry):

LayoutTests:

Tests various configurations for painting the fixed backgrounds. The existing test was
actually wrong, so fixed to use a gradient (so you can see where the edges of the image are),
and be valid. Testing is complicated by the fact that setting top content inset actually
causes the snapshot to be inset at the top.

  • platform/mac-wk2/tiled-drawing/resources/bordered-image.png: Added.
  • platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover-expected.html: Added.
  • platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover-local-expected.html: Added.
  • platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover-local.html: Copied from LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment.html.
  • platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover.html: Added.
  • platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-expected.html:
  • platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-local-expected.html: Added.
  • platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-local.html: Added.
  • platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-positioned-expected.html: Added.
  • platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-positioned.html: Added.
  • platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment.html:
Location:
trunk
Files:
8 added
5 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r184060 r184065  
     12015-05-10  Simon Fraser  <simon.fraser@apple.com>
     2
     3        background-position sometimes doesn't work properly with background-attachment: fixed
     4        https://bugs.webkit.org/show_bug.cgi?id=103757
     5        rdar://problem/18749925
     6
     7        Reviewed by Darin Adler.
     8       
     9        Tests various configurations for painting the fixed backgrounds. The existing test was
     10        actually wrong, so fixed to use a gradient (so you can see where the edges of the image are),
     11        and be valid. Testing is complicated by the fact that setting top content inset actually
     12        causes the snapshot to be inset at the top.
     13
     14        * platform/mac-wk2/tiled-drawing/resources/bordered-image.png: Added.
     15        * platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover-expected.html: Added.
     16        * platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover-local-expected.html: Added.
     17        * platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover-local.html: Copied from LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment.html.
     18        * platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover.html: Added.
     19        * platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-expected.html:
     20        * platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-local-expected.html: Added.
     21        * platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-local.html: Added.
     22        * platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-positioned-expected.html: Added.
     23        * platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-positioned.html: Added.
     24        * platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment.html:
     25
    1262015-05-10  Martin Robinson  <mrobinson@igalia.com>
    227
  • trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover-local.html

    r184064 r184065  
    33<style>
    44
     5html {
     6    background-color: white;
     7}
    58body {
    6     height:2000px;
    7     margin:0;
    8     overflow:hidden;
    9 }
    10 
    11 #fixed-background-box {
    12     width:400px;
    13     height:600px;
    14     background-image:url(resources/green.png);
    15     background-attachment:fixed;
     9    margin: 0;
     10    height: 2000px;
     11    overflow: hidden;
     12    background-image: url('resources/bordered-image.png');
     13    background-attachment: fixed;
     14    background-size: contain;
     15    background-repeat: no-repeat;
    1616}
    1717
     
    2424    window.scrollTo(0, 100);
    2525}
    26 
    2726window.addEventListener('load', runTest, false);
    2827</script>
    2928</head>
    30 
    3129<body>
    32 
    33 <div id="fixed-background-box"></div>
    34 
    3530</body>
    3631</html>
  • trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-expected.html

    r172417 r184065  
    1010
    1111#fixed-background-box {
     12    position: absolute;
     13    top: -100px;
    1214    width:400px;
    1315    height:600px;
    14     background-image:url(resources/green.png);
     16    background-image: linear-gradient(blue, blue 10px, green 10px, green 490px, black 490px, black);
    1517    background-attachment:fixed;
     18    background-repeat:no-repeat;
    1619}
    1720
    1821</style>
     22<script>
     23function runTest() {
     24    if (window.internals)
     25        window.internals.setTopContentInset(100);
     26}
     27window.addEventListener('load', runTest, false);
     28</script>
    1929</head>
    20 
    2130<body>
    22 
    23 <div id="fixed-background-box"></div>
    24 
     31    <div id="fixed-background-box"></div>
    2532</body>
    2633</html>
  • trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment.html

    r172417 r184065  
    1010
    1111#fixed-background-box {
    12     width:400px;
    13     height:600px;
    14     background-image:url(resources/green.png);
    15     background-attachment:fixed;
     12    width: 400px;
     13    height: 600px;
     14    background-image: linear-gradient(blue, blue 10px, green 10px, green 490px, black 490px, black);
     15    background-attachment: fixed;
     16    background-repeat:no-repeat;
    1617}
    1718
    1819</style>
    19 
    2020<script>
    2121function runTest() {
     
    2424    window.scrollTo(0, 100);
    2525}
    26 
    2726window.addEventListener('load', runTest, false);
    2827</script>
    2928</head>
    30 
    3129<body>
    32 
    33 <div id="fixed-background-box"></div>
    34 
     30    <div id="fixed-background-box"></div>
    3531</body>
    3632</html>
  • trunk/Source/WebCore/ChangeLog

    r184056 r184065  
     12015-05-10  Simon Fraser  <simon.fraser@apple.com>
     2
     3        background-position sometimes doesn't work properly with background-attachment: fixed
     4        https://bugs.webkit.org/show_bug.cgi?id=103757
     5        rdar://problem/18749925
     6
     7        Reviewed by Darin Adler.
     8       
     9        Fix sizing issues with fixed backgrounds when top content inset (blurred toolbar) is in
     10        effect.
     11       
     12        The primary issue was that positioningAreaSize was including the top content inset
     13        height, and should not have been, but there were also issues with the "fixedBackgroundPaintsInLocalCoordinates"
     14        code path, which kicks in when the root background is fixed.
     15
     16        Tests: platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover-local.html
     17               platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover.html
     18               platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-local.html
     19               platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-positioned.html
     20
     21        * rendering/RenderBoxModelObject.cpp:
     22        (WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry):
     23
    1242015-05-10  Sungmann Cho  <sungmann.cho@navercorp.com>
    225
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp

    r184055 r184065  
    11121112    } else {
    11131113        LayoutRect viewportRect;
     1114        float topContentInset = 0;
    11141115        if (frame().settings().fixedBackgroundsPaintRelativeToDocument())
    11151116            viewportRect = view().unscaledDocumentRect();
    11161117        else {
    1117             viewportRect.setSize(view().frameView().unscaledVisibleContentSizeIncludingObscuredArea());
     1118            FrameView& frameView = view().frameView();
     1119            viewportRect.setSize(frameView.unscaledVisibleContentSizeIncludingObscuredArea());
     1120            topContentInset = frameView.topContentInset(ScrollView::TopContentInsetType::WebCoreOrPlatformContentInset);
     1121
    11181122            if (fixedBackgroundPaintsInLocalCoordinates())
    1119                 viewportRect.setLocation(LayoutPoint());
    1120             else {
    1121                 viewportRect.setLocation(toLayoutPoint(view().frameView().documentScrollOffsetRelativeToViewOrigin()));
    1122                 top += view().frameView().topContentInset(ScrollView::TopContentInsetType::WebCoreOrPlatformContentInset);
    1123             }
     1123                viewportRect.setLocation(LayoutPoint(0, -topContentInset));
     1124            else
     1125                viewportRect.setLocation(toLayoutPoint(frameView.documentScrollOffsetRelativeToViewOrigin()));
     1126
     1127            top += topContentInset;
    11241128        }
    11251129       
     
    11291133        destinationRect = viewportRect;
    11301134        positioningAreaSize = destinationRect.size();
     1135        positioningAreaSize.setHeight(positioningAreaSize.height() - topContentInset);
    11311136    }
    11321137
Note: See TracChangeset for help on using the changeset viewer.