Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

Commit 4b3f8d1

Browse files
[LFC Display] Implement background image painting
https://bugs.webkit.org/show_bug.cgi?id=218155 Reviewed by Zalan Bujtas. Introduce BoxDecorationData, which stores per-Box box pixel-snapped geometry for backgrounds and borders. A BoxModelBox that has box decorations will own one. BoxDecorationData has a vector of FillLayerImageGeometry, which stores pixel-snapped geometry for background image painting. Code in DisplayFillLayerImageGeometry computes this geometry (code based on rendering code). BoxModelBox needs to store pixel snapped padding and content boxes for decoration painting. Currently TreeBuilder::computeBoxDecorationData() sets up these rects and makes BoxDecorationData, but this isn't really tree building, so I'd like to move that code somewhere else in future patches. * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * display/DisplayTreeBuilder.cpp: (WebCore::Display::TreeBuilder::computeBoxDecorationData const): (WebCore::Display::TreeBuilder::displayBoxForLayoutBox const): * display/DisplayTreeBuilder.h: * display/css/DisplayBox.cpp: * display/css/DisplayBox.h: * display/css/DisplayBoxDecorationData.cpp: Copied from Source/WebCore/display/css/DisplayBox.cpp. (WebCore::Display::BoxDecorationData::create): * display/css/DisplayBoxDecorationData.h: Copied from Source/WebCore/display/css/DisplayCSSPainter.h. (WebCore::Display::BoxDecorationData::backgroundImageGeometry const): (WebCore::Display::BoxDecorationData::setBackgroundImageGeometry): (WebCore::Display::BoxDecorationData::roundedBorderRect const): (WebCore::Display::BoxDecorationData::setRoundedBorderRect): * display/css/DisplayBoxModelBox.cpp: (WebCore::Display::BoxModelBox::setBoxDecorationData): * display/css/DisplayBoxModelBox.h: (WebCore::Display::BoxModelBox::absolutePaddingBoxRect const): (WebCore::Display::BoxModelBox::setAbsolutePaddingBoxRect): (WebCore::Display::BoxModelBox::absoluteContentBoxRect const): (WebCore::Display::BoxModelBox::setAbsoluteContentBoxRect): (WebCore::Display::BoxModelBox::boxDecorationData const): * display/css/DisplayCSSPainter.cpp: (WebCore::Display::CSSPainter::paintFillLayer): (WebCore::Display::CSSPainter::paintBackgroundImages): (WebCore::Display::CSSPainter::paintBoxDecorations): * display/css/DisplayCSSPainter.h: * display/css/DisplayFillLayerImageGeometry.cpp: Added. (WebCore::Display::resolveWidthForRatio): (WebCore::Display::resolveHeightForRatio): (WebCore::Display::resolveAgainstIntrinsicWidthOrHeightAndRatio): (WebCore::Display::resolveAgainstIntrinsicRatio): (WebCore::Display::calculateImageIntrinsicDimensions): (WebCore::Display::calculateFillTileSize): (WebCore::Display::getSpace): (WebCore::Display::resolveEdgeRelativeLength): (WebCore::Display::pixelSnappedFillLayerImageGeometry): (WebCore::Display::geometryForLayer): (WebCore::Display::calculateFillLayerImageGeometry): * display/css/DisplayFillLayerImageGeometry.h: Copied from Source/WebCore/display/DisplayTreeBuilder.h. (WebCore::Display::FillLayerImageGeometry::FillLayerImageGeometry): (WebCore::Display::FillLayerImageGeometry::destRect const): (WebCore::Display::FillLayerImageGeometry::phase const): (WebCore::Display::FillLayerImageGeometry::tileSize const): (WebCore::Display::FillLayerImageGeometry::spaceSize const): (WebCore::Display::FillLayerImageGeometry::hasNonLocalGeometry const): (WebCore::Display::FillLayerImageGeometry::relativePhase const): (WebCore::Display::FillLayerImageGeometry::clip): * display/css/DisplayStyle.cpp: (WebCore::Display::deepCopy): (WebCore::Display::Style::Style): (WebCore::Display::Style::hasBackgroundImage const): * display/css/DisplayStyle.h: (WebCore::Display::Style::backgroundLayers const): (WebCore::Display::Style::hasBackgroundImage const): Deleted. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@268955 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 2679527 commit 4b3f8d1

17 files changed

+874
-12
lines changed

Source/WebCore/ChangeLog

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,80 @@
1+
2020-10-24 Simon Fraser <[email protected]>
2+
3+
[LFC Display] Implement background image painting
4+
https://bugs.webkit.org/show_bug.cgi?id=218155
5+
6+
Reviewed by Zalan Bujtas.
7+
8+
Introduce BoxDecorationData, which stores per-Box box pixel-snapped geometry for
9+
backgrounds and borders. A BoxModelBox that has box decorations will own one.
10+
11+
BoxDecorationData has a vector of FillLayerImageGeometry, which stores pixel-snapped
12+
geometry for background image painting. Code in DisplayFillLayerImageGeometry computes
13+
this geometry (code based on rendering code).
14+
15+
BoxModelBox needs to store pixel snapped padding and content boxes for decoration painting.
16+
17+
Currently TreeBuilder::computeBoxDecorationData() sets up these rects and makes BoxDecorationData,
18+
but this isn't really tree building, so I'd like to move that code somewhere else in
19+
future patches.
20+
21+
* Sources.txt:
22+
* WebCore.xcodeproj/project.pbxproj:
23+
* display/DisplayTreeBuilder.cpp:
24+
(WebCore::Display::TreeBuilder::computeBoxDecorationData const):
25+
(WebCore::Display::TreeBuilder::displayBoxForLayoutBox const):
26+
* display/DisplayTreeBuilder.h:
27+
* display/css/DisplayBox.cpp:
28+
* display/css/DisplayBox.h:
29+
* display/css/DisplayBoxDecorationData.cpp: Copied from Source/WebCore/display/css/DisplayBox.cpp.
30+
(WebCore::Display::BoxDecorationData::create):
31+
* display/css/DisplayBoxDecorationData.h: Copied from Source/WebCore/display/css/DisplayCSSPainter.h.
32+
(WebCore::Display::BoxDecorationData::backgroundImageGeometry const):
33+
(WebCore::Display::BoxDecorationData::setBackgroundImageGeometry):
34+
(WebCore::Display::BoxDecorationData::roundedBorderRect const):
35+
(WebCore::Display::BoxDecorationData::setRoundedBorderRect):
36+
* display/css/DisplayBoxModelBox.cpp:
37+
(WebCore::Display::BoxModelBox::setBoxDecorationData):
38+
* display/css/DisplayBoxModelBox.h:
39+
(WebCore::Display::BoxModelBox::absolutePaddingBoxRect const):
40+
(WebCore::Display::BoxModelBox::setAbsolutePaddingBoxRect):
41+
(WebCore::Display::BoxModelBox::absoluteContentBoxRect const):
42+
(WebCore::Display::BoxModelBox::setAbsoluteContentBoxRect):
43+
(WebCore::Display::BoxModelBox::boxDecorationData const):
44+
* display/css/DisplayCSSPainter.cpp:
45+
(WebCore::Display::CSSPainter::paintFillLayer):
46+
(WebCore::Display::CSSPainter::paintBackgroundImages):
47+
(WebCore::Display::CSSPainter::paintBoxDecorations):
48+
* display/css/DisplayCSSPainter.h:
49+
* display/css/DisplayFillLayerImageGeometry.cpp: Added.
50+
(WebCore::Display::resolveWidthForRatio):
51+
(WebCore::Display::resolveHeightForRatio):
52+
(WebCore::Display::resolveAgainstIntrinsicWidthOrHeightAndRatio):
53+
(WebCore::Display::resolveAgainstIntrinsicRatio):
54+
(WebCore::Display::calculateImageIntrinsicDimensions):
55+
(WebCore::Display::calculateFillTileSize):
56+
(WebCore::Display::getSpace):
57+
(WebCore::Display::resolveEdgeRelativeLength):
58+
(WebCore::Display::pixelSnappedFillLayerImageGeometry):
59+
(WebCore::Display::geometryForLayer):
60+
(WebCore::Display::calculateFillLayerImageGeometry):
61+
* display/css/DisplayFillLayerImageGeometry.h: Copied from Source/WebCore/display/DisplayTreeBuilder.h.
62+
(WebCore::Display::FillLayerImageGeometry::FillLayerImageGeometry):
63+
(WebCore::Display::FillLayerImageGeometry::destRect const):
64+
(WebCore::Display::FillLayerImageGeometry::phase const):
65+
(WebCore::Display::FillLayerImageGeometry::tileSize const):
66+
(WebCore::Display::FillLayerImageGeometry::spaceSize const):
67+
(WebCore::Display::FillLayerImageGeometry::hasNonLocalGeometry const):
68+
(WebCore::Display::FillLayerImageGeometry::relativePhase const):
69+
(WebCore::Display::FillLayerImageGeometry::clip):
70+
* display/css/DisplayStyle.cpp:
71+
(WebCore::Display::deepCopy):
72+
(WebCore::Display::Style::Style):
73+
(WebCore::Display::Style::hasBackgroundImage const):
74+
* display/css/DisplayStyle.h:
75+
(WebCore::Display::Style::backgroundLayers const):
76+
(WebCore::Display::Style::hasBackgroundImage const): Deleted.
77+
178
2020-10-24 Simon Fraser <[email protected]>
279

380
[LFC Display] Create display boxes for atomic inlines and inline blocks

Source/WebCore/Sources.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,9 +813,11 @@ css/typedom/TypedOMCSSUnitValue.cpp
813813
css/typedom/TypedOMCSSUnparsedValue.cpp
814814
cssjit/SelectorCompiler.cpp
815815
display/css/DisplayBox.cpp
816+
display/css/DisplayBoxDecorationData.cpp
816817
display/css/DisplayBoxModelBox.cpp
817818
display/css/DisplayContainerBox.cpp
818819
display/css/DisplayCSSPainter.cpp
820+
display/css/DisplayFillLayerImageGeometry.cpp
819821
display/css/DisplayImageBox.cpp
820822
display/css/DisplayReplacedBox.cpp
821823
display/css/DisplayStyle.cpp

Source/WebCore/WebCore.xcodeproj/project.pbxproj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6010,6 +6010,10 @@
60106010
0F8B45741DC41DBA00443C3F /* JSIntersectionObserverCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSIntersectionObserverCallback.h; sourceTree = "<group>"; };
60116011
0F94721E2534010900F153C8 /* DisplayBoxModelBox.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayBoxModelBox.h; sourceTree = "<group>"; };
60126012
0F9472202534010900F153C8 /* DisplayBoxModelBox.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayBoxModelBox.cpp; sourceTree = "<group>"; };
6013+
0F9472292534B04500F153C8 /* DisplayBoxDecorationData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayBoxDecorationData.h; sourceTree = "<group>"; };
6014+
0F94722B2534B04500F153C8 /* DisplayBoxDecorationData.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayBoxDecorationData.cpp; sourceTree = "<group>"; };
6015+
0F94722C2534BA7300F153C8 /* DisplayFillLayerImageGeometry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayFillLayerImageGeometry.cpp; sourceTree = "<group>"; };
6016+
0F94722D2534BA7300F153C8 /* DisplayFillLayerImageGeometry.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayFillLayerImageGeometry.h; sourceTree = "<group>"; };
60136017
0F94A3951EF1B10500FBAFFB /* JSDOMQuadCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMQuadCustom.cpp; sourceTree = "<group>"; };
60146018
0F94B6422208F70100157014 /* ScrollingTreeFixedNode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ScrollingTreeFixedNode.h; path = page/scrolling/cocoa/ScrollingTreeFixedNode.h; sourceTree = SOURCE_ROOT; };
60156019
0F94B6432208F70200157014 /* ScrollingTreeStickyNode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ScrollingTreeStickyNode.h; path = page/scrolling/cocoa/ScrollingTreeStickyNode.h; sourceTree = SOURCE_ROOT; };
@@ -17617,12 +17621,16 @@
1761717621
children = (
1761817622
0FFF1B72251BC6570098795A /* DisplayBox.cpp */,
1761917623
0FFF1B78251BC6570098795A /* DisplayBox.h */,
17624+
0F94722B2534B04500F153C8 /* DisplayBoxDecorationData.cpp */,
17625+
0F9472292534B04500F153C8 /* DisplayBoxDecorationData.h */,
1762017626
0F9472202534010900F153C8 /* DisplayBoxModelBox.cpp */,
1762117627
0F94721E2534010900F153C8 /* DisplayBoxModelBox.h */,
1762217628
0FFF1B74251BC6570098795A /* DisplayContainerBox.cpp */,
1762317629
0FFF1B7A251BC6570098795A /* DisplayContainerBox.h */,
1762417630
0FFF1B7D251BC6570098795A /* DisplayCSSPainter.cpp */,
1762517631
0FFF1B77251BC6570098795A /* DisplayCSSPainter.h */,
17632+
0F94722C2534BA7300F153C8 /* DisplayFillLayerImageGeometry.cpp */,
17633+
0F94722D2534BA7300F153C8 /* DisplayFillLayerImageGeometry.h */,
1762617634
0FFF1B75251BC6570098795A /* DisplayImageBox.cpp */,
1762717635
0FFF1B7B251BC6570098795A /* DisplayImageBox.h */,
1762817636
0FFF1B7C251BC6570098795A /* DisplayReplacedBox.cpp */,
@@ -35473,7 +35481,6 @@
3547335481
A8D06B3A0A265DCD005E7203 /* HTMLNames.cpp in Sources */,
3547435482
1AC900C31943C0FC008625B5 /* HTTPHeaderNames.cpp in Sources */,
3547535483
CD19FEAF1F574B6D000C42FB /* ImageDecoderAVFObjC.mm in Sources */,
35476-
CA3A4AAE25416E40006CDAE2 /* ImageResolution.cpp in Sources */,
3547735484
CD27AE5122A9868700947FF9 /* ImageRotationSessionVT.mm in Sources */,
3547835485
07E9E13018F62B370011A3A4 /* InbandMetadataTextTrackPrivateAVF.cpp in Sources */,
3547935486
07B442D6166C70B000556CAD /* InbandTextTrackPrivateAVF.cpp in Sources */,

Source/WebCore/display/DisplayTreeBuilder.cpp

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
3030

31+
#include "DisplayBoxDecorationData.h"
3132
#include "DisplayContainerBox.h"
3233
#include "DisplayImageBox.h"
3334
#include "DisplayStyle.h"
@@ -123,6 +124,28 @@ void TreeBuilder::buildInlineDisplayTree(const Layout::LayoutState& layoutState,
123124
}
124125
}
125126

127+
// FIXME: This should happen as part of Display::Box creation.
128+
void TreeBuilder::computeBoxDecorationData(BoxModelBox& box, const Layout::Box& layoutBox, const Layout::BoxGeometry& geometry, LayoutSize offsetFromRoot) const
129+
{
130+
auto borderBoxRect = LayoutRect { Layout::BoxGeometry::borderBoxRect(geometry) };
131+
borderBoxRect.move(offsetFromRoot);
132+
133+
auto paddingBoxRect = LayoutRect { geometry.paddingBox() };
134+
paddingBoxRect.moveBy(borderBoxRect.location());
135+
box.setAbsolutePaddingBoxRect(snapRectToDevicePixels(paddingBoxRect, m_pixelSnappingFactor));
136+
137+
auto contentBoxRect = LayoutRect { geometry.contentBox() };
138+
contentBoxRect.moveBy(borderBoxRect.location());
139+
box.setAbsoluteContentBoxRect(snapRectToDevicePixels(contentBoxRect, m_pixelSnappingFactor));
140+
141+
// FIXME: Check for rounded borders when supported.
142+
if (!box.style().hasBackground())
143+
return;
144+
145+
auto boxDecorationData = BoxDecorationData::create(box, layoutBox, geometry, offsetFromRoot, m_pixelSnappingFactor);
146+
box.setBoxDecorationData(WTFMove(boxDecorationData));
147+
}
148+
126149
void TreeBuilder::recursiveBuildDisplayTree(const Layout::LayoutState& layoutState, LayoutSize offsetFromRoot, const Layout::Box& box, InsertionPosition& insertionPosition) const
127150
{
128151
auto geometry = layoutState.geometryForBox(box);
@@ -187,12 +210,15 @@ std::unique_ptr<Box> TreeBuilder::displayBoxForLayoutBox(const Layout::BoxGeomet
187210
if (auto* cachedImage = downcast<Layout::ReplacedBox>(layoutBox).cachedImage())
188211
imageBox->setImage(cachedImage->image());
189212

213+
computeBoxDecorationData(*imageBox, layoutBox, geometry, offsetFromRoot);
190214
return imageBox;
191215
}
192216

193217
if (is<Layout::ContainerBox>(layoutBox)) {
194218
// FIXME: The decision to make a ContainerBox should be made based on whether this Display::Box will have children.
195-
return makeUnique<ContainerBox>(pixelSnappedBorderBoxRect, WTFMove(style));
219+
auto containerBox = makeUnique<ContainerBox>(pixelSnappedBorderBoxRect, WTFMove(style));
220+
computeBoxDecorationData(*containerBox, layoutBox, geometry, offsetFromRoot);
221+
return containerBox;
196222
}
197223

198224
return makeUnique<Box>(snapRectToDevicePixels(borderBoxRect, m_pixelSnappingFactor), WTFMove(style));

Source/WebCore/display/DisplayTreeBuilder.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ class TreeBuilder {
6565
std::unique_ptr<Box> displayBoxForRootBox(const Layout::BoxGeometry&, const Layout::ContainerBox&) const;
6666
std::unique_ptr<Box> displayBoxForLayoutBox(const Layout::BoxGeometry&, const Layout::Box&, LayoutSize offsetFromRoot) const;
6767

68+
void computeBoxDecorationData(BoxModelBox&, const Layout::Box&, const Layout::BoxGeometry&, LayoutSize offsetFromRoot) const;
69+
6870
void recursiveBuildDisplayTree(const Layout::LayoutState&, LayoutSize offsetFromRoot, const Layout::Box&, InsertionPosition&) const;
6971

7072
void buildInlineDisplayTree(const Layout::LayoutState&, LayoutSize offsetFromRoot, const Layout::ContainerBox&, InsertionPosition&) const;

Source/WebCore/display/css/DisplayBox.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ Box::Box(AbsoluteFloatRect absoluteRect, Style&& displayStyle, OptionSet<Flags>
4141
{
4242
}
4343

44+
Box::~Box() = default;
45+
4446
void Box::setNextSibling(std::unique_ptr<Box>&& box)
4547
{
4648
m_nextSibling = WTFMove(box);

Source/WebCore/display/css/DisplayBox.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class Box {
4949
};
5050

5151
Box(AbsoluteFloatRect, Style&&, OptionSet<Flags> = { });
52-
virtual ~Box() = default;
52+
virtual ~Box();
5353

5454
const Style& style() const { return m_style; }
5555

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright (C) 2020 Apple Inc. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
* 1. Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* 2. Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
*
13+
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15+
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17+
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23+
* THE POSSIBILITY OF SUCH DAMAGE.
24+
*/
25+
26+
#include "config.h"
27+
#include "DisplayBox.h"
28+
29+
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
30+
31+
#include "LayoutBox.h"
32+
#include "LayoutBoxGeometry.h"
33+
34+
namespace WebCore {
35+
namespace Display {
36+
37+
std::unique_ptr<BoxDecorationData> BoxDecorationData::create(const Box& displayBox, const Layout::Box& layoutBox, const Layout::BoxGeometry& layoutGeometry, LayoutSize offsetFromRoot, float pixelSnappingFactor)
38+
{
39+
auto backgroundImageGeometry = calculateFillLayerImageGeometry(displayBox, layoutBox, layoutGeometry, offsetFromRoot, pixelSnappingFactor);
40+
41+
auto boxDecorationData = makeUnique<BoxDecorationData>();
42+
boxDecorationData->setBackgroundImageGeometry(backgroundImageGeometry);
43+
44+
// FIXME: Compute rounded border rect.
45+
46+
return boxDecorationData;
47+
}
48+
49+
BoxDecorationData::BoxDecorationData() = default;
50+
51+
} // namespace Display
52+
} // namespace WebCore
53+
54+
#endif // ENABLE(LAYOUT_FORMATTING_CONTEXT)
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Copyright (C) 2020 Apple Inc. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
* 1. Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* 2. Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
*
13+
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15+
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17+
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23+
* THE POSSIBILITY OF SUCH DAMAGE.
24+
*/
25+
26+
#pragma once
27+
28+
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
29+
30+
#include "DisplayFillLayerImageGeometry.h"
31+
#include "FloatRoundedRect.h"
32+
#include <wtf/IsoMalloc.h>
33+
34+
namespace WebCore {
35+
36+
namespace Layout {
37+
class Box;
38+
class BoxGeometry;
39+
}
40+
41+
namespace Display {
42+
43+
// Per-box data with pixel-snapped geometry for background images and border-radius.
44+
class BoxDecorationData {
45+
WTF_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(BoxDecorationData);
46+
public:
47+
static std::unique_ptr<BoxDecorationData> create(const Box&, const Layout::Box&, const Layout::BoxGeometry&, LayoutSize offsetFromRoot, float pixelSnappingFactor);
48+
49+
BoxDecorationData();
50+
51+
const Vector<FillLayerImageGeometry, 1> backgroundImageGeometry() const { return m_backgroundImageGeometry; }
52+
void setBackgroundImageGeometry(const Vector<FillLayerImageGeometry, 1>& geometry) { m_backgroundImageGeometry = geometry; }
53+
54+
const FloatRoundedRect& roundedBorderRect() const { return m_roundedBorderRect; }
55+
void setRoundedBorderRect(const FloatRoundedRect& roundedRect) { m_roundedBorderRect = roundedRect; }
56+
57+
private:
58+
Vector<FillLayerImageGeometry, 1> m_backgroundImageGeometry;
59+
FloatRoundedRect m_roundedBorderRect;
60+
};
61+
62+
} // namespace Display
63+
} // namespace WebCore
64+
65+
66+
#endif // ENABLE(LAYOUT_FORMATTING_CONTEXT)

Source/WebCore/display/css/DisplayBoxModelBox.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
3030

31+
#include "DisplayBoxDecorationData.h"
3132
#include <wtf/IsoMallocInlines.h>
3233
#include <wtf/text/TextStream.h>
3334

@@ -39,6 +40,14 @@ BoxModelBox::BoxModelBox(AbsoluteFloatRect borderBox, Style&& displayStyle, Opti
3940
{
4041
}
4142

43+
BoxModelBox::~BoxModelBox() = default;
44+
45+
void BoxModelBox::setBoxDecorationData(std::unique_ptr<BoxDecorationData>&& decorationData)
46+
{
47+
m_boxDecorationData = WTFMove(decorationData);
48+
}
49+
50+
4251
String BoxModelBox::debugDescription() const
4352
{
4453
TextStream stream;

0 commit comments

Comments
 (0)