Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (267508 => 267509)
--- trunk/Source/WebCore/CMakeLists.txt 2020-09-23 23:28:50 UTC (rev 267508)
+++ trunk/Source/WebCore/CMakeLists.txt 2020-09-23 23:39:29 UTC (rev 267509)
@@ -85,6 +85,7 @@
"${WEBCORE_DIR}/css/typedom"
"${WEBCORE_DIR}/cssjit"
"${WEBCORE_DIR}/display"
+ "${WEBCORE_DIR}/display/css"
"${WEBCORE_DIR}/dom"
"${WEBCORE_DIR}/dom/messageports"
"${WEBCORE_DIR}/domjit"
Modified: trunk/Source/WebCore/ChangeLog (267508 => 267509)
--- trunk/Source/WebCore/ChangeLog 2020-09-23 23:28:50 UTC (rev 267508)
+++ trunk/Source/WebCore/ChangeLog 2020-09-23 23:39:29 UTC (rev 267509)
@@ -1,3 +1,106 @@
+2020-09-20 Simon Fraser <[email protected]>
+
+ [LFC Display] Add the beginnings of a CSS display box hierarchy and CSS painter
+ https://bugs.webkit.org/show_bug.cgi?id=216752
+
+ Reviewed by Zalan Bujtas.
+
+ Add some Display::Box subclasses to display/css, a Display::Tree class to own the
+ display tree, and a DisplayTreeBuilder. Also add css/DisplayCSSPainter which is
+ the beginnings of a class that knows how to paint a CSS stacking context.
+
+ This code other than DisplayCSSPainter is deliberately vague about how much is
+ CSS specific. It's likely that some box classes will be shared with SVG painting.
+
+ * CMakeLists.txt:
+ * Headers.cmake:
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * display/DisplayLayerController.cpp:
+ (WebCore::Display::LayerController::RootLayerClient::paintContents):
+ (WebCore::Display::LayerController::RootLayerClient::deviceScaleFactor const):
+ (WebCore::Display::LayerController::prepareForDisplay):
+ (WebCore::Display::LayerController::ensureRootLayer):
+ (WebCore::Display::LayerController::updateRootLayerGeometry):
+ * display/DisplayLayerController.h:
+ * display/DisplayTree.cpp: Copied from Source/WebCore/display/DisplayView.h.
+ (WebCore::Display::Tree::Tree):
+ * display/DisplayTree.h: Copied from Source/WebCore/display/DisplayView.h.
+ (WebCore::Display::Tree::rootBox const):
+ * display/DisplayTreeBuilder.cpp: Added.
+ (WebCore::Display::TreeBuilder::TreeBuilder):
+ (WebCore::Display::TreeBuilder::build const):
+ (WebCore::Display::TreeBuilder::recursiveBuildDisplayTree const):
+ (WebCore::Display::TreeBuilder::displayBoxForRootBox const):
+ (WebCore::Display::TreeBuilder::displayBoxForLayoutBox const):
+ (WebCore::Display::outputDisplayBox):
+ (WebCore::Display::outputDisplayTree):
+ (WebCore::Display::showDisplayTree):
+ * display/DisplayTreeBuilder.h: Copied from Source/WebCore/display/DisplayView.h.
+ * display/DisplayView.cpp:
+ (WebCore::Display::View::prepareForDisplay):
+ (WebCore::Display::View::deviceScaleFactor const):
+ * display/DisplayView.h:
+ * display/css/DisplayBox.cpp: Copied from Source/WebCore/display/DisplayView.h.
+ (WebCore::Display::Box::Box):
+ (WebCore::Display::Box::setNextSibling):
+ (WebCore::Display::Box::debugDescription const):
+ * display/css/DisplayBox.h: Copied from Source/WebCore/display/DisplayView.h.
+ (WebCore::Display::Box::Box):
+ (WebCore::Display::Box::style const):
+ (WebCore::Display::Box::borderBoxFrame const):
+ (WebCore::Display::Box::isContainerBox const):
+ (WebCore::Display::Box::isImageBox const):
+ (WebCore::Display::Box::isReplacedBox const):
+ (WebCore::Display::Box::nextSibling const):
+ * display/css/DisplayCSSPainter.cpp: Added.
+ (WebCore::Display::CSSPainter::paintBoxDecorations):
+ (WebCore::Display::CSSPainter::paintBoxContent):
+ (WebCore::Display::CSSPainter::paintBox):
+ (WebCore::Display::CSSPainter::recursivePaintDescendants):
+ (WebCore::Display::CSSPainter::paintStackingContext):
+ (WebCore::Display::CSSPainter::isStackingContextPaintingBoundary):
+ (WebCore::Display::CSSPainter::recursiveCollectLayers):
+ (WebCore::Display::CSSPainter::paintTree):
+ * display/css/DisplayCSSPainter.h: Copied from Source/WebCore/display/DisplayView.h.
+ * display/css/DisplayContainerBox.cpp: Copied from Source/WebCore/display/DisplayView.h.
+ (WebCore::Display::ContainerBox::ContainerBox):
+ (WebCore::Display::ContainerBox::setFirstChild):
+ (WebCore::Display::ContainerBox::debugDescription const):
+ * display/css/DisplayContainerBox.h: Copied from Source/WebCore/display/DisplayView.h.
+ (WebCore::Display::ContainerBox::firstChild const):
+ * display/css/DisplayImageBox.cpp: Copied from Source/WebCore/display/DisplayView.h.
+ (WebCore::Display::ImageBox::ImageBox):
+ (WebCore::Display::ImageBox::setImage):
+ (WebCore::Display::ImageBox::debugDescription const):
+ * display/css/DisplayImageBox.h: Copied from Source/WebCore/display/DisplayView.h.
+ (WebCore::Display::ImageBox::image const):
+ * display/css/DisplayReplacedBox.cpp: Copied from Source/WebCore/display/DisplayView.h.
+ (WebCore::Display::ReplacedBox::ReplacedBox):
+ * display/css/DisplayReplacedBox.h: Copied from Source/WebCore/display/DisplayView.h.
+ (WebCore::Display::ReplacedBox::replacedContentRect const):
+ * display/css/DisplayStyle.cpp: Copied from Source/WebCore/display/DisplayView.cpp.
+ (WebCore::Display::Style::Style):
+ (WebCore::Display::Style::hasBackground const):
+ (WebCore::Display::Style::hasVisibleBorder const):
+ * display/css/DisplayStyle.h: Added.
+ (WebCore::Display::Style::backgroundColor const):
+ (WebCore::Display::Style::hasBackgroundImage const):
+ (WebCore::Display::Style::borderLeft const):
+ (WebCore::Display::Style::borderRight const):
+ (WebCore::Display::Style::borderTop const):
+ (WebCore::Display::Style::borderBottom const):
+ (WebCore::Display::Style::zIndex const):
+ (WebCore::Display::Style::isStackingContext const):
+ (WebCore::Display::Style::isPositioned const):
+ (WebCore::Display::Style::isFloating const):
+ (WebCore::Display::Style::participatesInZOrderSorting const):
+ (WebCore::Display::Style::setIsPositioned):
+ (WebCore::Display::Style::setIsFloating):
+ * layout/displaytree/DisplayBox.cpp: Removed.
+ * layout/displaytree/DisplayBox.h: Removed.
+ * layout/layouttree/LayoutIterator.h: Unified sources build fix.
+
2020-09-23 Chris Dumez <[email protected]>
web audio api outputs silence for 302 redirected resource in safari
Modified: trunk/Source/WebCore/Headers.cmake (267508 => 267509)
--- trunk/Source/WebCore/Headers.cmake 2020-09-23 23:28:50 UTC (rev 267508)
+++ trunk/Source/WebCore/Headers.cmake 2020-09-23 23:39:29 UTC (rev 267509)
@@ -362,8 +362,17 @@
css/parser/CSSParserTokenRange.h
display/DisplayLayerController.h
+ display/DisplayTree.h
+ display/DisplayTreeBuilder.h
display/DisplayView.h
+ display/css/DisplayBox.h
+ display/css/DisplayCSSPainter.h
+ display/css/DisplayContainerBox.h
+ display/css/DisplayImageBox.h
+ display/css/DisplayReplacedBox.h
+ display/css/DisplayStyle.h
+
dom/ActiveDOMCallback.h
dom/ActiveDOMObject.h
dom/Attr.h
@@ -696,7 +705,6 @@
layout/LayoutUnits.h
layout/MarginTypes.h
- layout/displaytree/DisplayBox.h
layout/displaytree/DisplayInlineContent.h
layout/displaytree/DisplayLine.h
layout/displaytree/DisplayRect.h
Modified: trunk/Source/WebCore/Sources.txt (267508 => 267509)
--- trunk/Source/WebCore/Sources.txt 2020-09-23 23:28:50 UTC (rev 267508)
+++ trunk/Source/WebCore/Sources.txt 2020-09-23 23:39:29 UTC (rev 267509)
@@ -794,7 +794,15 @@
css/typedom/TypedOMCSSUnitValue.cpp
css/typedom/TypedOMCSSUnparsedValue.cpp
cssjit/SelectorCompiler.cpp
+display/css/DisplayBox.cpp
+display/css/DisplayContainerBox.cpp
+display/css/DisplayCSSPainter.cpp
+display/css/DisplayImageBox.cpp
+display/css/DisplayReplacedBox.cpp
+display/css/DisplayStyle.cpp
display/DisplayLayerController.cpp
+display/DisplayTree.cpp
+display/DisplayTreeBuilder.cpp
display/DisplayView.cpp
dom/AbortController.cpp
dom/AbortSignal.cpp
@@ -1434,7 +1442,6 @@
layout/blockformatting/PrecomputedBlockMarginCollapse.cpp
layout/blockformatting/tablewrapper/TableWrapperBlockFormattingContext.cpp
layout/blockformatting/tablewrapper/TableWrapperBlockFormattingContextQuirks.cpp
-layout/displaytree/DisplayBox.cpp
layout/displaytree/DisplayInlineContent.cpp
layout/displaytree/DisplayPainter.cpp
layout/flexformatting/FlexFormattingContext.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (267508 => 267509)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2020-09-23 23:28:50 UTC (rev 267508)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2020-09-23 23:39:29 UTC (rev 267509)
@@ -391,7 +391,6 @@
119340971FED715500935F1E /* RenderTreeBuilderFormControls.h in Headers */ = {isa = PBXBuildFile; fileRef = 119340951FED715500935F1E /* RenderTreeBuilderFormControls.h */; };
119340A31FEE024000935F1E /* RenderTreeBuilderBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = 119340A11FEE024000935F1E /* RenderTreeBuilderBlock.h */; };
1199FA46208E35A3002358CC /* LayoutContainerBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 1199FA44208E35A3002358CC /* LayoutContainerBox.h */; settings = {ATTRIBUTES = (Private, ); }; };
- 1199FA5B208E3C7F002358CC /* DisplayBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 1199FA59208E3C7F002358CC /* DisplayBox.h */; settings = {ATTRIBUTES = (Private, ); }; };
11CB2789203BA570004A1DC9 /* RenderTreeBuilderFullScreen.h in Headers */ = {isa = PBXBuildFile; fileRef = 11CB2787203BA570004A1DC9 /* RenderTreeBuilderFullScreen.h */; };
11E067EE1E6246E500162D16 /* SimpleLineLayoutCoverage.h in Headers */ = {isa = PBXBuildFile; fileRef = 11E067ED1E6246E500162D16 /* SimpleLineLayoutCoverage.h */; settings = {ATTRIBUTES = (Private, ); }; };
1400D7A817136EA70077CE05 /* ScriptWrappableInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 1400D7A717136EA70077CE05 /* ScriptWrappableInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -6090,6 +6089,22 @@
0FFD45A8243BF257000D4BEA /* ScrollingTreeLatchingController.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollingTreeLatchingController.cpp; sourceTree = "<group>"; };
0FFD4D5E18651FA300512F6E /* AsyncScrollingCoordinator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AsyncScrollingCoordinator.cpp; sourceTree = "<group>"; };
0FFD4D5F18651FA300512F6E /* AsyncScrollingCoordinator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AsyncScrollingCoordinator.h; sourceTree = "<group>"; };
+ 0FFF1B72251BC6570098795A /* DisplayBox.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayBox.cpp; sourceTree = "<group>"; };
+ 0FFF1B73251BC6570098795A /* DisplayStyle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayStyle.h; sourceTree = "<group>"; };
+ 0FFF1B74251BC6570098795A /* DisplayContainerBox.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayContainerBox.cpp; sourceTree = "<group>"; };
+ 0FFF1B75251BC6570098795A /* DisplayImageBox.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayImageBox.cpp; sourceTree = "<group>"; };
+ 0FFF1B76251BC6570098795A /* DisplayStyle.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayStyle.cpp; sourceTree = "<group>"; };
+ 0FFF1B77251BC6570098795A /* DisplayCSSPainter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayCSSPainter.h; sourceTree = "<group>"; };
+ 0FFF1B78251BC6570098795A /* DisplayBox.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayBox.h; sourceTree = "<group>"; };
+ 0FFF1B79251BC6570098795A /* DisplayReplacedBox.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayReplacedBox.h; sourceTree = "<group>"; };
+ 0FFF1B7A251BC6570098795A /* DisplayContainerBox.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayContainerBox.h; sourceTree = "<group>"; };
+ 0FFF1B7B251BC6570098795A /* DisplayImageBox.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayImageBox.h; sourceTree = "<group>"; };
+ 0FFF1B7C251BC6570098795A /* DisplayReplacedBox.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayReplacedBox.cpp; sourceTree = "<group>"; };
+ 0FFF1B7D251BC6570098795A /* DisplayCSSPainter.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayCSSPainter.cpp; sourceTree = "<group>"; };
+ 0FFF1B7F251BC6620098795A /* DisplayTreeBuilder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayTreeBuilder.h; sourceTree = "<group>"; };
+ 0FFF1B80251BC6620098795A /* DisplayTreeBuilder.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayTreeBuilder.cpp; sourceTree = "<group>"; };
+ 0FFF1B81251BC6630098795A /* DisplayTree.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayTree.h; sourceTree = "<group>"; };
+ 0FFF1B82251BC6630098795A /* DisplayTree.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayTree.cpp; sourceTree = "<group>"; };
10FB084A14E15C7E00A3DB98 /* PublicURLManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PublicURLManager.h; sourceTree = "<group>"; };
1100FC6E1FDB3C4D00DD961B /* TrailingFloatsRootInlineBox.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TrailingFloatsRootInlineBox.cpp; sourceTree = "<group>"; };
11100FC72092764C0081AA6C /* LayoutIterator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LayoutIterator.h; sourceTree = "<group>"; };
@@ -6134,8 +6149,6 @@
119340A11FEE024000935F1E /* RenderTreeBuilderBlock.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RenderTreeBuilderBlock.h; sourceTree = "<group>"; };
1199FA44208E35A3002358CC /* LayoutContainerBox.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LayoutContainerBox.h; sourceTree = "<group>"; };
1199FA45208E35A3002358CC /* LayoutContainerBox.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutContainerBox.cpp; sourceTree = "<group>"; };
- 1199FA59208E3C7F002358CC /* DisplayBox.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayBox.h; sourceTree = "<group>"; };
- 1199FA5A208E3C7F002358CC /* DisplayBox.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayBox.cpp; sourceTree = "<group>"; };
11B042FB20B0E21400828A6B /* LayoutDescendantIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutDescendantIterator.h; sourceTree = "<group>"; };
11C5F1162003E7750001AE60 /* RenderTreeBuilderInline.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTreeBuilderInline.cpp; sourceTree = "<group>"; };
11C5F1182003E7760001AE60 /* RenderTreeBuilderInline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderTreeBuilderInline.h; sourceTree = "<group>"; };
@@ -17430,8 +17443,13 @@
0F790F3C2517CE6D009BA034 /* display */ = {
isa = PBXGroup;
children = (
+ 0FFF1B71251BC6570098795A /* css */,
0F790F402517CE6D009BA034 /* DisplayLayerController.cpp */,
0F790F3E2517CE6D009BA034 /* DisplayLayerController.h */,
+ 0FFF1B82251BC6630098795A /* DisplayTree.cpp */,
+ 0FFF1B81251BC6630098795A /* DisplayTree.h */,
+ 0FFF1B80251BC6620098795A /* DisplayTreeBuilder.cpp */,
+ 0FFF1B7F251BC6620098795A /* DisplayTreeBuilder.h */,
0F790F3D2517CE6D009BA034 /* DisplayView.cpp */,
0F790F3F2517CE6D009BA034 /* DisplayView.h */,
);
@@ -17456,6 +17474,25 @@
path = displaylists;
sourceTree = "<group>";
};
+ 0FFF1B71251BC6570098795A /* css */ = {
+ isa = PBXGroup;
+ children = (
+ 0FFF1B72251BC6570098795A /* DisplayBox.cpp */,
+ 0FFF1B78251BC6570098795A /* DisplayBox.h */,
+ 0FFF1B74251BC6570098795A /* DisplayContainerBox.cpp */,
+ 0FFF1B7A251BC6570098795A /* DisplayContainerBox.h */,
+ 0FFF1B7D251BC6570098795A /* DisplayCSSPainter.cpp */,
+ 0FFF1B77251BC6570098795A /* DisplayCSSPainter.h */,
+ 0FFF1B75251BC6570098795A /* DisplayImageBox.cpp */,
+ 0FFF1B7B251BC6570098795A /* DisplayImageBox.h */,
+ 0FFF1B7C251BC6570098795A /* DisplayReplacedBox.cpp */,
+ 0FFF1B79251BC6570098795A /* DisplayReplacedBox.h */,
+ 0FFF1B76251BC6570098795A /* DisplayStyle.cpp */,
+ 0FFF1B73251BC6570098795A /* DisplayStyle.h */,
+ );
+ path = css;
+ sourceTree = "<group>";
+ };
115CFA66208AF720001E6991 /* layout */ = {
isa = PBXGroup;
children = (
@@ -17564,8 +17601,6 @@
1199FA58208E3C4C002358CC /* displaytree */ = {
isa = PBXGroup;
children = (
- 1199FA5A208E3C7F002358CC /* DisplayBox.cpp */,
- 1199FA59208E3C7F002358CC /* DisplayBox.h */,
E4FB4B35239BEB10003C336A /* DisplayInlineContent.cpp */,
E451C6332394058E00993190 /* DisplayInlineContent.h */,
6FB47E612277425A00C7BCB0 /* DisplayLine.h */,
@@ -31074,7 +31109,6 @@
835D54C51F4DE53800E60671 /* DirectoryFileListCreator.h in Headers */,
F47A09D120A93A9700240FAE /* DisabledAdaptations.h in Headers */,
7EDAAFC919A2CCDC0034DFD1 /* DiskCacheMonitorCocoa.h in Headers */,
- 1199FA5B208E3C7F002358CC /* DisplayBox.h in Headers */,
E451C6342394058F00993190 /* DisplayInlineContent.h in Headers */,
0F790F422517CE6E009BA034 /* DisplayLayerController.h in Headers */,
6FB47E632277425A00C7BCB0 /* DisplayLine.h in Headers */,
Modified: trunk/Source/WebCore/display/DisplayLayerController.cpp (267508 => 267509)
--- trunk/Source/WebCore/display/DisplayLayerController.cpp 2020-09-23 23:28:50 UTC (rev 267508)
+++ trunk/Source/WebCore/display/DisplayLayerController.cpp 2020-09-23 23:39:29 UTC (rev 267509)
@@ -30,13 +30,11 @@
#include "Chrome.h"
#include "ChromeClient.h"
-#include "DisplayPainter.h"
+#include "DisplayCSSPainter.h"
+#include "DisplayTree.h"
#include "DisplayView.h"
#include "Frame.h"
#include "FrameView.h"
-#include "LayoutBoxGeometry.h"
-#include "LayoutContext.h"
-#include "LayoutState.h"
#include "Logging.h"
#include "Page.h"
#include "Settings.h"
@@ -60,12 +58,14 @@
{
ASSERT_UNUSED(layer, layer == m_layerController.contentLayer());
- // FIXME: Temporary; once we do scrolling this root layer won't paint anything.
- if (auto* layoutState = m_layerController.view().layoutState())
- Layout::LayoutContext::paint(*layoutState, context, enclosingIntRect(dirtyRect));
+ if (auto* displayTree = m_layerController.m_displayTree.get())
+ CSSPainter::paintTree(*displayTree, context, enclosingIntRect(dirtyRect));
}
-WTF_MAKE_ISO_ALLOCATED_IMPL(LayerController);
+float LayerController::RootLayerClient::deviceScaleFactor() const
+{
+ return m_layerController.view().deviceScaleFactor();
+}
LayerController::LayerController(View& view)
: m_view(view)
@@ -75,23 +75,15 @@
LayerController::~LayerController() = default;
-void LayerController::prepareForDisplay(const Layout::LayoutState& layoutState)
+void LayerController::prepareForDisplay(std::unique_ptr<Display::Tree>&& displayTree)
{
- if (!layoutState.hasRoot())
- return;
+ ASSERT(displayTree);
+ m_displayTree = WTFMove(displayTree);
- auto& rootLayoutBox = layoutState.root();
- if (!rootLayoutBox.firstChild())
- return;
+ auto viewSize = m_displayTree->rootBox().borderBoxFrame().size();
+ // FIXME: Do overflow etc.
+ auto contentSize = viewSize;
- ASSERT(layoutState.hasBoxGeometry(rootLayoutBox));
-
- auto viewSize = layoutState.geometryForBox(rootLayoutBox).logicalSize();
- auto contentSize = layoutState.geometryForBox(*rootLayoutBox.firstChild()).logicalSize();
-
- // FIXME: Using the firstChild() size won't be correct until we compute overflow correctly,
- contentSize.clampToMinimumSize(viewSize);
-
LOG_WITH_STREAM(FormattingContextLayout, stream << "LayerController::prepareForDisplay - viewSize " << viewSize << " contentSize " << contentSize);
ensureRootLayer(viewSize, contentSize);
@@ -136,7 +128,7 @@
page->scheduleRenderingUpdate();
}
-void LayerController::ensureRootLayer(LayoutSize viewSize, LayoutSize contentSize)
+void LayerController::ensureRootLayer(FloatSize viewSize, FloatSize contentSize)
{
if (m_rootLayer) {
updateRootLayerGeometry(viewSize, contentSize);
@@ -171,7 +163,7 @@
m_contentHostLayer->addChild(*m_contentLayer);
}
-void LayerController::updateRootLayerGeometry(LayoutSize viewSize, LayoutSize contentSize)
+void LayerController::updateRootLayerGeometry(FloatSize viewSize, FloatSize contentSize)
{
m_rootLayer->setSize(viewSize);
Modified: trunk/Source/WebCore/display/DisplayLayerController.h (267508 => 267509)
--- trunk/Source/WebCore/display/DisplayLayerController.h 2020-09-23 23:28:50 UTC (rev 267508)
+++ trunk/Source/WebCore/display/DisplayLayerController.h 2020-09-23 23:39:29 UTC (rev 267509)
@@ -27,9 +27,7 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
-#include "DisplayRect.h"
#include "GraphicsLayer.h"
-#include "LayoutUnits.h"
#include <wtf/IsoMalloc.h>
namespace WebCore {
@@ -37,22 +35,19 @@
class GraphicsLayer;
class GraphicsLayerFactory;
-namespace Layout {
-class LayoutState;
-}
-
namespace Display {
+class Tree;
class View;
// A controller object that makes layerization decisions for a display tree, for a single document.
class LayerController {
- WTF_MAKE_ISO_ALLOCATED(LayerController);
+ WTF_MAKE_FAST_ALLOCATED(LayerController);
public:
explicit LayerController(View&);
~LayerController();
- void prepareForDisplay(const Layout::LayoutState&);
+ void prepareForDisplay(std::unique_ptr<Display::Tree>&&);
void flushLayers();
void setIsInWindow(bool);
@@ -60,11 +55,13 @@
const View& view() const { return m_view; }
private:
- void ensureRootLayer(LayoutSize viewSize, LayoutSize contentSize);
void attachRootLayer();
void detachRootLayer();
+
+ void ensureRootLayer(FloatSize viewSize, FloatSize contentSize);
+ void updateRootLayerGeometry(FloatSize viewSize, FloatSize contentSize);
+
void setupRootLayerHierarchy();
- void updateRootLayerGeometry(LayoutSize viewSize, LayoutSize contentSize);
void scheduleRenderingUpdate();
GraphicsLayer* rootGraphicsLayer() const { return m_rootLayer.get(); }
@@ -82,6 +79,7 @@
// GraphicsLayerClient implementation
void notifyFlushRequired(const GraphicsLayer*) final;
void paintContents(const GraphicsLayer*, GraphicsContext&, const FloatRect&, GraphicsLayerPaintBehavior) final;
+ float deviceScaleFactor() const final;
LayerController& m_layerController;
};
@@ -92,6 +90,8 @@
RefPtr<GraphicsLayer> m_rootLayer;
RefPtr<GraphicsLayer> m_contentHostLayer;
RefPtr<GraphicsLayer> m_contentLayer;
+
+ std::unique_ptr<Display::Tree> m_displayTree;
};
} // namespace Display
Copied: trunk/Source/WebCore/display/DisplayTree.cpp (from rev 267508, trunk/Source/WebCore/display/DisplayView.h) (0 => 267509)
--- trunk/Source/WebCore/display/DisplayTree.cpp (rev 0)
+++ trunk/Source/WebCore/display/DisplayTree.cpp 2020-09-23 23:39:29 UTC (rev 267509)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DisplayTree.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include <wtf/IsoMallocInlines.h>
+
+namespace WebCore {
+namespace Display {
+
+Tree::Tree(std::unique_ptr<ContainerBox>&& rootBox)
+ : m_rootBox(WTFMove(rootBox))
+{
+ ASSERT(m_rootBox);
+}
+
+} // namespace Display
+} // namespace WebCore
+
+#endif // ENABLE(LAYOUT_FORMATTING_CONTEXT)
Copied: trunk/Source/WebCore/display/DisplayTree.h (from rev 267508, trunk/Source/WebCore/display/DisplayView.h) (0 => 267509)
--- trunk/Source/WebCore/display/DisplayTree.h (rev 0)
+++ trunk/Source/WebCore/display/DisplayTree.h 2020-09-23 23:39:29 UTC (rev 267509)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "DisplayContainerBox.h"
+#include <wtf/IsoMalloc.h>
+
+namespace WebCore {
+namespace Display {
+
+class Tree {
+ WTF_MAKE_FAST_ALLOCATED(Tree);
+public:
+ Tree(std::unique_ptr<ContainerBox>&&);
+
+ const ContainerBox& rootBox() const { return *m_rootBox; }
+
+private:
+ // Ideally this root box would be agnostic to display type (CSS vs SVG).
+ std::unique_ptr<ContainerBox> m_rootBox;
+};
+
+} // namespace Display
+} // namespace WebCore
+
+#endif // ENABLE(LAYOUT_FORMATTING_CONTEXT)
Added: trunk/Source/WebCore/display/DisplayTreeBuilder.cpp (0 => 267509)
--- trunk/Source/WebCore/display/DisplayTreeBuilder.cpp (rev 0)
+++ trunk/Source/WebCore/display/DisplayTreeBuilder.cpp 2020-09-23 23:39:29 UTC (rev 267509)
@@ -0,0 +1,196 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DisplayTreeBuilder.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "DisplayContainerBox.h"
+#include "DisplayImageBox.h"
+#include "DisplayStyle.h"
+#include "DisplayTree.h"
+#include "LayoutBoxGeometry.h"
+#include "LayoutChildIterator.h"
+#include "LayoutContainerBox.h"
+#include "LayoutReplacedBox.h"
+#include "LayoutState.h"
+#include "LayoutTreeBuilder.h" // Just for showLayoutTree.
+#include "Logging.h"
+#include <wtf/IsoMallocInlines.h>
+#include <wtf/text/TextStream.h>
+
+namespace WebCore {
+namespace Display {
+
+TreeBuilder::TreeBuilder(float pixelSnappingFactor)
+ : m_pixelSnappingFactor(pixelSnappingFactor)
+{
+}
+
+std::unique_ptr<Tree> TreeBuilder::build(const Layout::LayoutState& layoutState) const
+{
+ ASSERT(layoutState.hasRoot());
+
+ auto& rootLayoutBox = layoutState.root();
+
+#if ENABLE(TREE_DEBUGGING)
+ LOG_WITH_STREAM(FormattingContextLayout, stream << "Building display tree for:");
+ showLayoutTree(rootLayoutBox, &layoutState);
+#endif
+
+ auto geometry = layoutState.geometryForBox(rootLayoutBox);
+ auto rootDisplayBox = displayBoxForRootBox(geometry, rootLayoutBox);
+ auto rootDisplayContainerBox = std::unique_ptr<ContainerBox> { downcast<ContainerBox>(rootDisplayBox.release()) };
+
+ if (!rootLayoutBox.firstChild())
+ return makeUnique<Tree>(WTFMove(rootDisplayContainerBox));
+
+ auto borderBox = LayoutRect { geometry.logicalRect() };
+ auto offset = toLayoutSize(borderBox.location());
+ recursiveBuildDisplayTree(layoutState, offset, *rootLayoutBox.firstChild(), *rootDisplayContainerBox);
+
+#if ENABLE(TREE_DEBUGGING)
+ LOG_WITH_STREAM(FormattingContextLayout, stream << "Display tree:");
+ showDisplayTree(*rootDisplayContainerBox);
+#endif
+
+ return makeUnique<Tree>(WTFMove(rootDisplayContainerBox));
+}
+
+Box* TreeBuilder::recursiveBuildDisplayTree(const Layout::LayoutState& layoutState, LayoutSize offsetFromRoot, const Layout::Box& box, Display::ContainerBox& parentDisplayBox, Display::Box* previousSiblingBox) const
+{
+ auto geometry = layoutState.geometryForBox(box);
+ auto displayBox = displayBoxForLayoutBox(geometry, box, offsetFromRoot);
+
+ Box* result = displayBox.get();
+
+ if (previousSiblingBox)
+ previousSiblingBox->setNextSibling(WTFMove(displayBox));
+ else
+ parentDisplayBox.setFirstChild(WTFMove(displayBox));
+
+ if (!is<Layout::ContainerBox>(box))
+ return result;
+
+ auto& layoutContainerBox = downcast<Layout::ContainerBox>(box);
+ if (!layoutContainerBox.hasChild())
+ return result;
+
+ auto borderBox = LayoutRect { geometry.logicalRect() };
+ offsetFromRoot += toLayoutSize(borderBox.location());
+
+ auto& displayContainerBox = downcast<ContainerBox>(*result);
+
+ Display::Box* currSiblingDisplayBox = nullptr;
+ for (auto& child : Layout::childrenOfType<Layout::Box>(layoutContainerBox)) {
+ if (!layoutState.hasBoxGeometry(child))
+ continue;
+
+ currSiblingDisplayBox = recursiveBuildDisplayTree(layoutState, offsetFromRoot, child, displayContainerBox, currSiblingDisplayBox);
+ }
+
+ return result;
+}
+
+std::unique_ptr<Box> TreeBuilder::displayBoxForRootBox(const Layout::BoxGeometry& geometry, const Layout::ContainerBox& rootBox) const
+{
+ // FIXME: Need to do logical -> physical coordinate mapping here.
+ auto borderBox = LayoutRect { geometry.logicalRect() };
+
+ auto style = Style { rootBox.style() };
+ return makeUnique<ContainerBox>(snapRectToDevicePixels(borderBox, m_pixelSnappingFactor), WTFMove(style));
+}
+
+std::unique_ptr<Box> TreeBuilder::displayBoxForLayoutBox(const Layout::BoxGeometry& geometry, const Layout::Box& layoutBox, LayoutSize offsetFromRoot) const
+{
+ // FIXME: Need to map logical to physical rects.
+ auto borderBox = LayoutRect { geometry.logicalRect() };
+ borderBox.move(offsetFromRoot);
+ auto pixelSnappedBorderBox = snapRectToDevicePixels(borderBox, m_pixelSnappingFactor);
+
+ // FIXME: Handle isAnonymous()
+ // FIXME: Do hoisting of <body> styles to the root where appropriate.
+
+ // FIXME: Need to do logical -> physical coordinate mapping here.
+ auto style = Style { layoutBox.style() };
+
+ if (is<Layout::ReplacedBox>(layoutBox)) {
+ // FIXME: Wrong; geometry needs to vend the correct replaced content rect.
+ auto replacedContentRect = LayoutRect { geometry.contentBoxLeft(), geometry.contentBoxTop(), geometry.contentBoxWidth(), geometry.contentBoxHeight() };
+ replacedContentRect.moveBy(borderBox.location());
+ auto pixelSnappedReplacedContentRect = snapRectToDevicePixels(replacedContentRect, m_pixelSnappingFactor);
+
+ // FIXME: Don't assume it's an image.
+ auto imageBox = makeUnique<ImageBox>(pixelSnappedBorderBox, WTFMove(style), pixelSnappedReplacedContentRect);
+
+ if (auto* cachedImage = downcast<Layout::ReplacedBox>(layoutBox).cachedImage())
+ imageBox->setImage(cachedImage->image());
+
+ return imageBox;
+ }
+
+ if (is<Layout::ContainerBox>(layoutBox)) {
+ // FIXME: The decision to make a ContainerBox should be made based on whether this Display::Box will have children.
+ return makeUnique<ContainerBox>(pixelSnappedBorderBox, WTFMove(style));
+ }
+
+ return makeUnique<Box>(snapRectToDevicePixels(borderBox, m_pixelSnappingFactor), WTFMove(style));
+}
+
+#if ENABLE(TREE_DEBUGGING)
+
+static void outputDisplayBox(TextStream& stream, const Box& displayBox, unsigned)
+{
+ stream.writeIndent();
+
+ stream << displayBox.debugDescription();
+ stream.nextLine();
+}
+
+static void outputDisplayTree(TextStream& stream, const Box& displayBox, unsigned depth)
+{
+ outputDisplayBox(stream, displayBox, depth);
+
+ if (is<ContainerBox>(displayBox)) {
+ TextStream::IndentScope indent(stream);
+ for (auto child = downcast<ContainerBox>(displayBox).firstChild(); child; child = child->nextSibling())
+ outputDisplayTree(stream, *child, depth + 1);
+ }
+}
+
+void showDisplayTree(const Box& box)
+{
+ TextStream stream(TextStream::LineMode::MultipleLine, TextStream::Formatting::SVGStyleRect);
+ outputDisplayTree(stream, box, 1);
+ WTFLogAlways("%s", stream.release().utf8().data());
+}
+
+#endif
+
+} // namespace Display
+} // namespace WebCore
+
+#endif // ENABLE(LAYOUT_FORMATTING_CONTEXT)
Copied: trunk/Source/WebCore/display/DisplayTreeBuilder.h (from rev 267508, trunk/Source/WebCore/display/DisplayView.h) (0 => 267509)
--- trunk/Source/WebCore/display/DisplayTreeBuilder.h (rev 0)
+++ trunk/Source/WebCore/display/DisplayTreeBuilder.h 2020-09-23 23:39:29 UTC (rev 267509)
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include <wtf/IsoMalloc.h>
+
+namespace WebCore {
+
+namespace Layout {
+class Box;
+class BoxGeometry;
+class LayoutState;
+}
+
+namespace Display {
+
+class Box;
+class ContainerBox;
+class Tree;
+
+class TreeBuilder {
+public:
+ explicit TreeBuilder(float pixelSnappingFactor);
+
+ std::unique_ptr<Tree> build(const Layout::LayoutState&) const;
+
+private:
+ std::unique_ptr<Box> displayBoxForRootBox(const Layout::BoxGeometry&, const Layout::ContainerBox&) const;
+ std::unique_ptr<Box> displayBoxForLayoutBox(const Layout::BoxGeometry&, const Layout::Box&, LayoutSize offsetFromRoot) const;
+
+ Box* recursiveBuildDisplayTree(const Layout::LayoutState&, LayoutSize offsetFromRoot, const Layout::Box&, Display::ContainerBox& parentDisplayBox, Display::Box* previousSiblingBox = nullptr) const;
+
+ float m_pixelSnappingFactor { 1 };
+};
+
+#if ENABLE(TREE_DEBUGGING)
+void showDisplayTree(const Box&);
+#endif
+
+} // namespace Display
+} // namespace WebCore
+
+#endif // ENABLE(LAYOUT_FORMATTING_CONTEXT)
Modified: trunk/Source/WebCore/display/DisplayView.cpp (267508 => 267509)
--- trunk/Source/WebCore/display/DisplayView.cpp 2020-09-23 23:28:50 UTC (rev 267508)
+++ trunk/Source/WebCore/display/DisplayView.cpp 2020-09-23 23:39:29 UTC (rev 267509)
@@ -28,11 +28,9 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+#include "DisplayTreeBuilder.h"
#include "Frame.h"
#include "FrameView.h"
-#include "FrameViewLayoutContext.h"
-#include "LayoutContext.h"
-#include "LayoutState.h"
#include "Page.h"
#include <wtf/IsoMallocInlines.h>
@@ -72,7 +70,10 @@
if (!layoutState)
return;
- m_layerController.prepareForDisplay(*layoutState);
+ auto treeBuilder = TreeBuilder { deviceScaleFactor() };
+ auto displayTree = treeBuilder.build(*layoutState);
+
+ m_layerController.prepareForDisplay(WTFMove(displayTree));
}
void View::flushLayers()
@@ -85,6 +86,11 @@
m_layerController.setIsInWindow(isInWindow);
}
+float View::deviceScaleFactor() const
+{
+ return page() ? page()->deviceScaleFactor() : 1.0f;
+}
+
} // namespace Display
} // namespace WebCore
Modified: trunk/Source/WebCore/display/DisplayView.h (267508 => 267509)
--- trunk/Source/WebCore/display/DisplayView.h 2020-09-23 23:28:50 UTC (rev 267508)
+++ trunk/Source/WebCore/display/DisplayView.h 2020-09-23 23:39:29 UTC (rev 267509)
@@ -61,9 +61,11 @@
FrameView& frameView() const { return m_frameView; }
Frame& frame() const;
+ float deviceScaleFactor() const;
+
+private:
const Layout::LayoutState* layoutState() const;
-private:
FrameView& m_frameView;
LayerController m_layerController;
};
Copied: trunk/Source/WebCore/display/css/DisplayBox.cpp (from rev 267508, trunk/Source/WebCore/display/DisplayView.h) (0 => 267509)
--- trunk/Source/WebCore/display/css/DisplayBox.cpp (rev 0)
+++ trunk/Source/WebCore/display/css/DisplayBox.cpp 2020-09-23 23:39:29 UTC (rev 267509)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DisplayBox.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include <wtf/IsoMallocInlines.h>
+#include <wtf/text/TextStream.h>
+
+namespace WebCore {
+namespace Display {
+
+Box::Box(AbsoluteFloatRect borderBox, Style&& displayStyle, OptionSet<Flags> flags)
+ : m_borderBoxFrame(borderBox)
+ , m_style(WTFMove(displayStyle))
+ , m_flags(flags)
+{
+}
+
+void Box::setNextSibling(std::unique_ptr<Box>&& box)
+{
+ m_nextSibling = WTFMove(box);
+}
+
+String Box::debugDescription() const
+{
+ TextStream stream;
+ stream << "display box " << borderBoxFrame() << " (" << this << ")";
+ return stream.release();
+}
+
+} // namespace Display
+} // namespace WebCore
+
+#endif // ENABLE(LAYOUT_FORMATTING_CONTEXT)
Copied: trunk/Source/WebCore/display/css/DisplayBox.h (from rev 267508, trunk/Source/WebCore/display/DisplayView.h) (0 => 267509)
--- trunk/Source/WebCore/display/css/DisplayBox.h (rev 0)
+++ trunk/Source/WebCore/display/css/DisplayBox.h 2020-09-23 23:39:29 UTC (rev 267509)
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "DisplayStyle.h"
+#include "FloatRect.h"
+#include <wtf/IsoMalloc.h>
+#include <wtf/OptionSet.h>
+
+namespace WebCore {
+namespace Display {
+
+// FIXME: Make this a strong type.
+using AbsoluteFloatRect = FloatRect;
+
+class Box {
+ WTF_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(Box);
+public:
+ enum class Flags : uint8_t {
+ ContainerBox = 1 << 0,
+ ImageBox = 1 << 1,
+ };
+
+ Box(AbsoluteFloatRect borderBox, Style&&, OptionSet<Flags> = { });
+ virtual ~Box() = default;
+
+ const Style& style() const { return m_style; }
+
+ AbsoluteFloatRect borderBoxFrame() const { return m_borderBoxFrame; }
+
+ bool isContainerBox() const { return m_flags.contains(Flags::ContainerBox); }
+ bool isImageBox() const { return m_flags.contains(Flags::ImageBox); }
+ bool isReplacedBox() const { return m_flags.contains(Flags::ImageBox); /* and other types later. */ }
+
+ const Box* nextSibling() const { return m_nextSibling.get(); }
+ void setNextSibling(std::unique_ptr<Box>&&);
+
+ virtual String debugDescription() const;
+
+private:
+ AbsoluteFloatRect m_borderBoxFrame;
+ Style m_style;
+ std::unique_ptr<Box> m_nextSibling;
+ OptionSet<Flags> m_flags;
+};
+
+} // namespace Display
+} // namespace WebCore
+
+#define SPECIALIZE_TYPE_TRAITS_DISPLAY_BOX(ToValueTypeName, predicate) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::Display::ToValueTypeName) \
+ static bool isType(const WebCore::Display::Box& box) { return box.predicate; } \
+SPECIALIZE_TYPE_TRAITS_END()
+
+#endif // ENABLE(LAYOUT_FORMATTING_CONTEXT)
Added: trunk/Source/WebCore/display/css/DisplayCSSPainter.cpp (0 => 267509)
--- trunk/Source/WebCore/display/css/DisplayCSSPainter.cpp (rev 0)
+++ trunk/Source/WebCore/display/css/DisplayCSSPainter.cpp 2020-09-23 23:39:29 UTC (rev 267509)
@@ -0,0 +1,262 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DisplayCSSPainter.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "CachedImage.h"
+#include "Color.h"
+#include "DisplayContainerBox.h"
+#include "DisplayImageBox.h"
+#include "DisplayStyle.h"
+#include "DisplayTree.h"
+#include "GraphicsContext.h"
+#include "IntRect.h"
+#include "LayoutState.h"
+
+namespace WebCore {
+namespace Display {
+
+void CSSPainter::paintBoxDecorations(const Box& displayBox, GraphicsContext& context)
+{
+ // FIXME: Table decoration painting is special.
+
+ auto borderBoxRect = displayBox.borderBoxFrame();
+
+ const auto& style = displayBox.style();
+
+ // Background color
+ if (style.hasBackground()) {
+ context.fillRect(borderBoxRect, style.backgroundColor());
+ // FIXME: Paint background image.
+ }
+
+ // Border
+ if (style.hasVisibleBorder()) {
+ auto drawBorderSide = [&](auto start, auto end, const auto& borderStyle) {
+ if (!borderStyle.width())
+ return;
+ if (borderStyle.style() == BorderStyle::None || borderStyle.style() == BorderStyle::Hidden)
+ return;
+ context.setStrokeColor(borderStyle.color());
+ context.setStrokeThickness(borderStyle.width());
+ context.drawLine(start, end);
+ };
+
+ context.setFillColor(Color::transparentBlack);
+
+ // Top
+ {
+ auto borderWidth = style.borderTop().width();
+ auto start = borderBoxRect.minXMinYCorner();
+ auto end = FloatPoint { borderBoxRect.maxX(), start.y() + borderWidth };
+ drawBorderSide(start, end, style.borderTop());
+ }
+
+ // Right
+ {
+ auto borderWidth = style.borderRight().width();
+ auto start = FloatPoint { borderBoxRect.maxX() - borderWidth, borderBoxRect.y() };
+ auto end = FloatPoint { start.x() + borderWidth, borderBoxRect.maxY() };
+ drawBorderSide(start, end, style.borderRight());
+ }
+
+ // Bottom
+ {
+ auto borderWidth = style.borderBottom().width();
+ auto start = FloatPoint { borderBoxRect.x(), borderBoxRect.maxY() - borderWidth };
+ auto end = FloatPoint { borderBoxRect.maxX(), start.y() + borderWidth };
+ drawBorderSide(start, end, style.borderBottom());
+ }
+
+ // Left
+ {
+ auto borderWidth = style.borderLeft().width();
+ auto start = borderBoxRect.minXMinYCorner();
+ auto end = FloatPoint { start.x() + borderWidth, borderBoxRect.maxY() };
+ drawBorderSide(start, end, style.borderLeft());
+ }
+ }
+}
+
+void CSSPainter::paintBoxContent(const Box& box, GraphicsContext& context)
+{
+ if (is<ImageBox>(box)) {
+ auto& imageBox = downcast<ImageBox>(box);
+
+ auto* image = imageBox.image();
+ auto imageRect = imageBox.replacedContentRect();
+
+ if (image)
+ context.drawImage(*image, imageRect);
+ }
+}
+
+void CSSPainter::paintBox(const Box& box, GraphicsContext& context, const IntRect& dirtyRect)
+{
+ auto relativeRect = box.borderBoxFrame();
+ if (!dirtyRect.intersects(enclosingIntRect(relativeRect)))
+ return;
+
+ if (is<ImageBox>(box)) {
+ auto& imageBox = downcast<ImageBox>(box);
+
+ auto* image = imageBox.image();
+ auto imageRect = imageBox.replacedContentRect();
+
+ if (image)
+ context.drawImage(*image, imageRect);
+ }
+
+ paintBoxDecorations(box, context);
+ paintBoxContent(box, context);
+}
+
+// FIXME: Make this an iterator.
+void CSSPainter::recursivePaintDescendants(const ContainerBox& containerBox, GraphicsContext& context, PaintPhase paintPhase)
+{
+ for (const auto* child = containerBox.firstChild(); child; child = child->nextSibling()) {
+ auto& box = *child;
+ if (isStackingContextPaintingBoundary(box))
+ continue;
+
+ switch (paintPhase) {
+ case PaintPhase::BlockBackgrounds:
+ if (!box.style().isFloating() && !box.style().isPositioned())
+ paintBoxDecorations(box, context);
+ break;
+ case PaintPhase::Floats:
+ if (box.style().isFloating() && !box.style().isPositioned())
+ paintBoxDecorations(box, context);
+ break;
+ case PaintPhase::BlockForegrounds:
+ if (!box.style().isFloating() && !box.style().isPositioned())
+ paintBoxContent(box, context);
+ };
+ if (is<ContainerBox>(box))
+ recursivePaintDescendants(downcast<ContainerBox>(box), context, paintPhase);
+ }
+}
+
+void CSSPainter::paintStackingContext(const Box& contextRoot, GraphicsContext& context, const IntRect& dirtyRect)
+{
+ UNUSED_PARAM(dirtyRect);
+
+ // Here the paintOffset represents the offset of the top left of contextRoot's borderBoxFrame relative to the root.
+ paintBoxDecorations(contextRoot, context);
+
+ auto paintDescendants = [&](const ContainerBox& containerBox) {
+ // For all its in-flow, non-positioned, block-level descendants in tree order: If the element is a block, list-item, or other block equivalent:
+ // Box decorations.
+ // Table decorations.
+ recursivePaintDescendants(containerBox, context, PaintPhase::BlockBackgrounds);
+
+ // All non-positioned floating descendants, in tree order. For each one of these, treat the element as if it created a new stacking context,
+ // but any positioned descendants and descendants which actually create a new stacking context should be considered part of the parent
+ // stacking context, not this new one.
+ recursivePaintDescendants(containerBox, context, PaintPhase::Floats);
+
+ // If the element is an inline element that generates a stacking context, then:
+ // FIXME: Handle this case.
+
+ // Otherwise: first for the element, then for all its in-flow, non-positioned, block-level descendants in tree order:
+ // 1. If the element is a block-level replaced element, then: the replaced content, atomically.
+ // 2. Otherwise, for each line box of that element...
+ recursivePaintDescendants(containerBox, context, PaintPhase::BlockForegrounds);
+ };
+
+ if (is<ContainerBox>(contextRoot)) {
+ auto& containerBox = downcast<ContainerBox>(contextRoot);
+
+ Vector<const Box*> negativeZOrderList;
+ Vector<const Box*> positiveZOrderList;
+
+ recursiveCollectLayers(containerBox, negativeZOrderList, positiveZOrderList);
+
+ auto compareZIndex = [] (const Box* a, const Box* b) {
+ return a->style().zIndex().valueOr(0) < b->style().zIndex().valueOr(0);
+ };
+
+ std::stable_sort(positiveZOrderList.begin(), positiveZOrderList.end(), compareZIndex);
+ std::stable_sort(negativeZOrderList.begin(), negativeZOrderList.end(), compareZIndex);
+
+ // Stacking contexts formed by positioned descendants with negative z-indices (excluding 0) in z-index order (most negative first) then tree order.
+ for (auto* box : negativeZOrderList)
+ paintStackingContext(*box, context, dirtyRect);
+
+ paintDescendants(containerBox);
+
+ // All positioned descendants with 'z-index: auto' or 'z-index: 0', in tree order. For those with 'z-index: auto', treat the element
+ // as if it created a new stacking context, but any positioned descendants and descendants which actually create a new stacking context
+ // should be considered part of the parent stacking context, not this new one. For those with 'z-index: 0', treat the stacking context
+ // generated atomically.
+ for (auto* box : positiveZOrderList) {
+ if (box->style().isStackingContext())
+ paintStackingContext(*box, context, dirtyRect);
+ else if (is<ContainerBox>(*box)) {
+ paintBoxDecorations(*box, context);
+ paintDescendants(downcast<ContainerBox>(*box));
+ } else
+ paintBox(*box, context, dirtyRect);
+ }
+ }
+}
+
+bool CSSPainter::isStackingContextPaintingBoundary(const Box& box)
+{
+ return box.style().isStackingContext();
+}
+
+void CSSPainter::recursiveCollectLayers(const ContainerBox& containerBox, Vector<const Box*>& negativeZOrderList, Vector<const Box*>& positiveZOrderList)
+{
+ for (const auto* child = containerBox.firstChild(); child; child = child->nextSibling()) {
+ if (child->style().participatesInZOrderSorting()) {
+ auto zIndex = child->style().zIndex().valueOr(0);
+
+ if (zIndex < 0)
+ negativeZOrderList.append(child);
+ else
+ positiveZOrderList.append(child);
+ }
+
+ if (isStackingContextPaintingBoundary(*child))
+ continue;
+
+ if (is<ContainerBox>(*child))
+ recursiveCollectLayers(downcast<ContainerBox>(*child), negativeZOrderList, positiveZOrderList);
+ }
+}
+
+void CSSPainter::paintTree(const Tree& displayTree, GraphicsContext& context, const IntRect& dirtyRect)
+{
+ paintStackingContext(displayTree.rootBox(), context, dirtyRect);
+}
+
+} // namespace Display
+} // namespace WebCore
+
+#endif // ENABLE(LAYOUT_FORMATTING_CONTEXT)
Copied: trunk/Source/WebCore/display/css/DisplayCSSPainter.h (from rev 267508, trunk/Source/WebCore/display/DisplayView.h) (0 => 267509)
--- trunk/Source/WebCore/display/css/DisplayCSSPainter.h (rev 0)
+++ trunk/Source/WebCore/display/css/DisplayCSSPainter.h 2020-09-23 23:39:29 UTC (rev 267509)
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "FloatSize.h"
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+class GraphicsContext;
+class IntRect;
+
+namespace Display {
+
+class Box;
+class ContainerBox;
+class Tree;
+
+class CSSPainter {
+public:
+ static void paintStackingContext(const Box&, GraphicsContext&, const IntRect& dirtyRect);
+
+ static void paintTree(const Tree&, GraphicsContext&, const IntRect& dirtyRect);
+
+
+private:
+ static void paintBox(const Box&, GraphicsContext&, const IntRect& dirtyRect);
+ static void paintBoxDecorations(const Box&, GraphicsContext&);
+ static void paintBoxContent(const Box&, GraphicsContext&);
+
+ enum class PaintPhase {
+ BlockBackgrounds,
+ Floats,
+ BlockForegrounds
+ };
+ static void recursivePaintDescendants(const ContainerBox&, GraphicsContext&, PaintPhase);
+
+ static bool isStackingContextPaintingBoundary(const Box&);
+ static void recursiveCollectLayers(const ContainerBox&, Vector<const Box*>& negativeZOrderList, Vector<const Box*>& positiveZOrderList);
+};
+
+} // namespace Display
+} // namespace WebCore
+
+#endif // ENABLE(LAYOUT_FORMATTING_CONTEXT)
Copied: trunk/Source/WebCore/display/css/DisplayContainerBox.cpp (from rev 267508, trunk/Source/WebCore/display/DisplayView.h) (0 => 267509)
--- trunk/Source/WebCore/display/css/DisplayContainerBox.cpp (rev 0)
+++ trunk/Source/WebCore/display/css/DisplayContainerBox.cpp 2020-09-23 23:39:29 UTC (rev 267509)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DisplayContainerBox.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "DisplayStyle.h"
+#include <wtf/IsoMallocInlines.h>
+
+namespace WebCore {
+namespace Display {
+
+ContainerBox::ContainerBox(AbsoluteFloatRect borderBox, Style&& displayStyle)
+ : Box(borderBox, WTFMove(displayStyle), { Flags::ContainerBox })
+{
+}
+
+void ContainerBox::setFirstChild(std::unique_ptr<Box>&& box)
+{
+ m_firstChild = WTFMove(box);
+}
+
+String ContainerBox::debugDescription() const
+{
+ TextStream stream;
+ stream << "container box " << borderBoxFrame() << " (" << this << ")";
+ return stream.release();
+}
+
+} // namespace Display
+} // namespace WebCore
+
+#endif // ENABLE(LAYOUT_FORMATTING_CONTEXT)
Copied: trunk/Source/WebCore/display/css/DisplayContainerBox.h (from rev 267508, trunk/Source/WebCore/display/DisplayView.h) (0 => 267509)
--- trunk/Source/WebCore/display/css/DisplayContainerBox.h (rev 0)
+++ trunk/Source/WebCore/display/css/DisplayContainerBox.h 2020-09-23 23:39:29 UTC (rev 267509)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "DisplayBox.h"
+
+namespace WebCore {
+namespace Display {
+
+class ContainerBox : public Box {
+ WTF_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(ContainerBox);
+public:
+ ContainerBox(AbsoluteFloatRect borderBox, Style&&);
+
+ const Box* firstChild() const { return m_firstChild.get(); }
+ void setFirstChild(std::unique_ptr<Box>&&);
+
+private:
+ String debugDescription() const override;
+
+ std::unique_ptr<Box> m_firstChild;
+};
+
+} // namespace Display
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_DISPLAY_BOX(ContainerBox, isContainerBox())
+
+#endif // ENABLE(LAYOUT_FORMATTING_CONTEXT)
Copied: trunk/Source/WebCore/display/css/DisplayImageBox.cpp (from rev 267508, trunk/Source/WebCore/display/DisplayView.h) (0 => 267509)
--- trunk/Source/WebCore/display/css/DisplayImageBox.cpp (rev 0)
+++ trunk/Source/WebCore/display/css/DisplayImageBox.cpp 2020-09-23 23:39:29 UTC (rev 267509)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DisplayImageBox.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "Image.h"
+#include <wtf/IsoMallocInlines.h>
+
+namespace WebCore {
+namespace Display {
+
+ImageBox::ImageBox(AbsoluteFloatRect borderBox, Style&& displayStyle, AbsoluteFloatRect replacedContentRect)
+ : ReplacedBox(borderBox, WTFMove(displayStyle), { Flags::ImageBox }, replacedContentRect)
+{
+}
+
+void ImageBox::setImage(Image* image)
+{
+ m_image = image;
+}
+
+String ImageBox::debugDescription() const
+{
+ TextStream stream;
+ stream << "image box " << borderBoxFrame() << " (" << this << ") replaced content rect: " << replacedContentRect() << " image: " << m_image.get();
+ return stream.release();
+}
+
+} // namespace Display
+} // namespace WebCore
+
+#endif // ENABLE(LAYOUT_FORMATTING_CONTEXT)
Copied: trunk/Source/WebCore/display/css/DisplayImageBox.h (from rev 267508, trunk/Source/WebCore/display/DisplayView.h) (0 => 267509)
--- trunk/Source/WebCore/display/css/DisplayImageBox.h (rev 0)
+++ trunk/Source/WebCore/display/css/DisplayImageBox.h 2020-09-23 23:39:29 UTC (rev 267509)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "DisplayReplacedBox.h"
+
+namespace WebCore {
+
+class Image;
+
+namespace Display {
+
+class Style;
+
+class ImageBox : public ReplacedBox {
+ WTF_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(ImageBox);
+public:
+ ImageBox(AbsoluteFloatRect borderBox, Style&&, AbsoluteFloatRect replacedContentRect);
+
+ Image* image() const { return m_image.get(); }
+ void setImage(Image*);
+
+private:
+ String debugDescription() const final;
+
+ RefPtr<Image> m_image;
+};
+
+} // namespace Display
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_DISPLAY_BOX(ImageBox, isImageBox())
+
+#endif // ENABLE(LAYOUT_FORMATTING_CONTEXT)
Copied: trunk/Source/WebCore/display/css/DisplayReplacedBox.cpp (from rev 267508, trunk/Source/WebCore/display/DisplayView.h) (0 => 267509)
--- trunk/Source/WebCore/display/css/DisplayReplacedBox.cpp (rev 0)
+++ trunk/Source/WebCore/display/css/DisplayReplacedBox.cpp 2020-09-23 23:39:29 UTC (rev 267509)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DisplayReplacedBox.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include <wtf/IsoMallocInlines.h>
+
+namespace WebCore {
+namespace Display {
+
+ReplacedBox::ReplacedBox(AbsoluteFloatRect borderBox, Style&& displayStyle, OptionSet<Flags> flags, AbsoluteFloatRect replacedContentRect)
+ : Box(borderBox, WTFMove(displayStyle), flags)
+ , m_replacedContentRect(replacedContentRect)
+{
+}
+
+} // namespace Display
+} // namespace WebCore
+
+#endif // ENABLE(LAYOUT_FORMATTING_CONTEXT)
Copied: trunk/Source/WebCore/display/css/DisplayReplacedBox.h (from rev 267508, trunk/Source/WebCore/display/DisplayView.h) (0 => 267509)
--- trunk/Source/WebCore/display/css/DisplayReplacedBox.h (rev 0)
+++ trunk/Source/WebCore/display/css/DisplayReplacedBox.h 2020-09-23 23:39:29 UTC (rev 267509)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "DisplayBox.h"
+
+namespace WebCore {
+namespace Display {
+
+class ReplacedBox : public Box {
+ WTF_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(ReplacedBox);
+public:
+ ReplacedBox(AbsoluteFloatRect borderBox, Style&&, OptionSet<Flags>, AbsoluteFloatRect replacedContentRect);
+
+ AbsoluteFloatRect replacedContentRect() const { return m_replacedContentRect; }
+
+private:
+ AbsoluteFloatRect m_replacedContentRect;
+};
+
+} // namespace Display
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_DISPLAY_BOX(ReplacedBox, isReplacedBox())
+
+#endif // ENABLE(LAYOUT_FORMATTING_CONTEXT)
Copied: trunk/Source/WebCore/display/css/DisplayStyle.cpp (from rev 267508, trunk/Source/WebCore/display/DisplayView.cpp) (0 => 267509)
--- trunk/Source/WebCore/display/css/DisplayStyle.cpp (rev 0)
+++ trunk/Source/WebCore/display/css/DisplayStyle.cpp 2020-09-23 23:39:29 UTC (rev 267509)
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DisplayStyle.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "BorderData.h"
+#include "RenderStyle.h"
+#include <wtf/IsoMallocInlines.h>
+
+namespace WebCore {
+namespace Display {
+
+Style::Style(const RenderStyle& style)
+{
+ m_backgroundColor = style.visitedDependentColorWithColorFilter(CSSPropertyBackgroundColor);
+
+ const auto& borderData = style.border();
+
+ auto borderValueWithResolvedColor = [&style](const BorderValue& value, CSSPropertyID colorPropertyID) {
+ auto resolvedValue = value;
+ resolvedValue.setColor(style.visitedDependentColorWithColorFilter(colorPropertyID));
+ return resolvedValue;
+ };
+
+ m_border.left = borderValueWithResolvedColor(borderData.left(), CSSPropertyBorderLeftColor);
+ m_border.right = borderValueWithResolvedColor(borderData.right(), CSSPropertyBorderRightColor);
+ m_border.top = borderValueWithResolvedColor(borderData.top(), CSSPropertyBorderTopColor);
+ m_border.bottom = borderValueWithResolvedColor(borderData.bottom(), CSSPropertyBorderBottomColor);
+
+ m_border.image = borderData.image();
+
+ if (!style.hasAutoUsedZIndex())
+ m_zIndex = style.usedZIndex();
+
+ setIsPositioned(style.position() != PositionType::Static);
+ setIsFloating(style.floating() != Float::No);
+}
+
+bool Style::hasBackground() const
+{
+ return m_backgroundColor.isVisible() || hasBackgroundImage();
+}
+
+bool Style::hasVisibleBorder() const
+{
+ bool haveImage = m_border.image.hasImage();
+ return m_border.left.isVisible(!haveImage) || m_border.right.isVisible(!haveImage) || m_border.top.isVisible(!haveImage) || m_border.bottom.isVisible(!haveImage);
+}
+
+} // namespace Display
+} // namespace WebCore
+
+#endif // ENABLE(LAYOUT_FORMATTING_CONTEXT)
Added: trunk/Source/WebCore/display/css/DisplayStyle.h (0 => 267509)
--- trunk/Source/WebCore/display/css/DisplayStyle.h (rev 0)
+++ trunk/Source/WebCore/display/css/DisplayStyle.h 2020-09-23 23:39:29 UTC (rev 267509)
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "BorderValue.h"
+#include "Color.h"
+#include "NinePieceImage.h"
+#include <wtf/IsoMalloc.h>
+#include <wtf/OptionSet.h>
+#include <wtf/Optional.h>
+
+namespace WebCore {
+
+class RenderStyle;
+
+namespace Display {
+
+// Style information needed to paint a Display::Box.
+// All colors should be resolved to their painted values [visitedDependentColorWithColorFilter()].
+// Should contain only absolute float values; no Lengths (which can contain calc values).
+
+class Style {
+ WTF_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(Style);
+public:
+
+ enum class Flags : uint8_t {
+ Positioned = 1 << 0,
+ Floating = 1 << 1,
+ };
+
+ explicit Style(const RenderStyle&);
+
+ const Color& backgroundColor() const { return m_backgroundColor; }
+ bool hasBackground() const;
+ bool hasBackgroundImage() const { return false; } // FIXME
+
+ bool hasVisibleBorder() const;
+ const BorderValue& borderLeft() const { return m_border.left; }
+ const BorderValue& borderRight() const { return m_border.right; }
+ const BorderValue& borderTop() const { return m_border.top; }
+ const BorderValue& borderBottom() const { return m_border.bottom; }
+
+ Optional<int> zIndex() const { return m_zIndex; }
+ bool isStackingContext() const { return m_zIndex.hasValue(); }
+
+ bool isPositioned() const { return m_flags.contains(Flags::Positioned); }
+ bool isFloating() const { return m_flags.contains(Flags::Floating); }
+
+ bool participatesInZOrderSorting() const { return isPositioned() || isStackingContext(); }
+
+private:
+ void setIsPositioned(bool value) { m_flags.set({ Flags::Positioned }, value); }
+ void setIsFloating(bool value) { m_flags.set({ Flags::Floating }, value); }
+
+ Color m_backgroundColor;
+
+ struct {
+ BorderValue left;
+ BorderValue right;
+ BorderValue top;
+ BorderValue bottom;
+
+ NinePieceImage image;
+ } m_border;
+
+ Optional<int> m_zIndex;
+ OptionSet<Flags> m_flags;
+};
+
+} // namespace Display
+} // namespace WebCore
+
+#endif // ENABLE(LAYOUT_FORMATTING_CONTEXT)
Deleted: trunk/Source/WebCore/layout/displaytree/DisplayBox.cpp (267508 => 267509)
--- trunk/Source/WebCore/layout/displaytree/DisplayBox.cpp 2020-09-23 23:28:50 UTC (rev 267508)
+++ trunk/Source/WebCore/layout/displaytree/DisplayBox.cpp 2020-09-23 23:39:29 UTC (rev 267509)
@@ -1,110 +0,0 @@
-/*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "DisplayBox.h"
-
-#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
-
-#include <wtf/IsoMallocInlines.h>
-
-namespace WebCore {
-namespace Display {
-
-WTF_MAKE_ISO_ALLOCATED_IMPL(Box);
-
-Box::Box(const Box& other)
- : m_topLeft(other.m_topLeft)
- , m_contentWidth(other.m_contentWidth)
- , m_contentHeight(other.m_contentHeight)
- , m_horizontalMargin(other.m_horizontalMargin)
- , m_verticalMargin(other.m_verticalMargin)
- , m_hasClearance(other.m_hasClearance)
- , m_border(other.m_border)
- , m_padding(other.m_padding)
-#if ASSERT_ENABLED
- , m_hasValidTop(other.m_hasValidTop)
- , m_hasValidLeft(other.m_hasValidLeft)
- , m_hasValidHorizontalMargin(other.m_hasValidHorizontalMargin)
- , m_hasValidVerticalMargin(other.m_hasValidVerticalMargin)
- , m_hasValidBorder(other.m_hasValidBorder)
- , m_hasValidPadding(other.m_hasValidPadding)
- , m_hasValidContentHeight(other.m_hasValidContentHeight)
- , m_hasValidContentWidth(other.m_hasValidContentWidth)
- , m_hasPrecomputedMarginBefore(other.m_hasPrecomputedMarginBefore)
-#endif
-{
-}
-
-Box::~Box()
-{
-}
-
-Rect Box::marginBox() const
-{
- auto borderBox = this->borderBox();
-
- Rect marginBox;
- marginBox.setTop(borderBox.top() - marginBefore());
- marginBox.setLeft(borderBox.left() - marginStart());
- marginBox.setHeight(borderBox.height() + marginBefore() + marginAfter());
- marginBox.setWidth(borderBox.width() + marginStart() + marginEnd());
- return marginBox;
-}
-
-Rect Box::borderBox() const
-{
- Rect borderBox;
- borderBox.setTopLeft({ });
- borderBox.setSize({ width(), height() });
- return borderBox;
-}
-
-Rect Box::paddingBox() const
-{
- auto borderBox = this->borderBox();
-
- Rect paddingBox;
- paddingBox.setTop(borderBox.top() + borderTop());
- paddingBox.setLeft(borderBox.left() + borderLeft());
- paddingBox.setHeight(borderBox.bottom() - borderTop() - borderBottom());
- paddingBox.setWidth(borderBox.width() - borderLeft() - borderRight());
- return paddingBox;
-}
-
-Rect Box::contentBox() const
-{
- Rect contentBox;
- contentBox.setTop(contentBoxTop());
- contentBox.setLeft(contentBoxLeft());
- contentBox.setWidth(contentBoxWidth());
- contentBox.setHeight(contentBoxHeight());
- return contentBox;
-}
-
-}
-}
-
-#endif
Deleted: trunk/Source/WebCore/layout/displaytree/DisplayBox.h (267508 => 267509)
--- trunk/Source/WebCore/layout/displaytree/DisplayBox.h 2020-09-23 23:28:50 UTC (rev 267508)
+++ trunk/Source/WebCore/layout/displaytree/DisplayBox.h 2020-09-23 23:39:29 UTC (rev 267509)
@@ -1,417 +0,0 @@
-/*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
-
-#include "DisplayRect.h"
-#include "LayoutUnits.h"
-#include <wtf/IsoMalloc.h>
-
-namespace WebCore {
-namespace Display {
-
-class Box {
- WTF_MAKE_ISO_ALLOCATED(Box);
-public:
- Box(const Box&);
- Box() = default;
- ~Box();
-
- LayoutUnit top() const;
- LayoutUnit left() const;
- LayoutUnit bottom() const { return top() + height(); }
- LayoutUnit right() const { return left() + width(); }
-
- LayoutPoint topLeft() const;
- LayoutPoint bottomRight() const { return { right(), bottom() }; }
-
- LayoutSize size() const { return { width(), height() }; }
- LayoutUnit width() const { return borderLeft() + paddingBoxWidth() + borderRight(); }
- LayoutUnit height() const { return borderTop() + paddingBoxHeight() + borderBottom(); }
- bool isEmpty() const { return size().isEmpty(); }
- Rect rect() const { return { top(), left(), width(), height() }; }
- Rect rectWithMargin() const { return { top() - marginBefore(), left() - marginStart(), marginStart() + width() + marginEnd(), marginBefore() + height() + marginAfter() }; }
-
- struct VerticalMargin {
- LayoutUnit before;
- LayoutUnit after;
- };
- VerticalMargin verticalMargin() const;
-
- struct HorizontalMargin {
- LayoutUnit start;
- LayoutUnit end;
- };
- HorizontalMargin horizontalMargin() const;
- LayoutUnit marginBefore() const;
- LayoutUnit marginStart() const;
- LayoutUnit marginAfter() const;
- LayoutUnit marginEnd() const;
- bool hasClearance() const { return m_hasClearance; }
-
- LayoutUnit borderTop() const;
- LayoutUnit borderLeft() const;
- LayoutUnit borderBottom() const;
- LayoutUnit borderRight() const;
- LayoutUnit verticalBorder() const { return borderTop() + borderBottom(); }
- LayoutUnit horizontalBorder() const { return borderLeft() + borderRight(); }
-
- Optional<LayoutUnit> paddingTop() const;
- Optional<LayoutUnit> paddingLeft() const;
- Optional<LayoutUnit> paddingBottom() const;
- Optional<LayoutUnit> paddingRight() const;
- Optional<LayoutUnit> verticalPadding() const;
- Optional<LayoutUnit> horizontalPadding() const;
-
- LayoutUnit contentBoxTop() const { return paddingBoxTop() + paddingTop().valueOr(0); }
- LayoutUnit contentBoxLeft() const { return paddingBoxLeft() + paddingLeft().valueOr(0); }
- LayoutUnit contentBoxBottom() const { return contentBoxTop() + contentBoxHeight(); }
- LayoutUnit contentBoxRight() const { return contentBoxLeft() + contentBoxWidth(); }
- LayoutUnit contentBoxHeight() const;
- LayoutUnit contentBoxWidth() const;
-
- LayoutUnit paddingBoxTop() const { return borderTop(); }
- LayoutUnit paddingBoxLeft() const { return borderLeft(); }
- LayoutUnit paddingBoxBottom() const { return paddingBoxTop() + paddingBoxHeight(); }
- LayoutUnit paddingBoxRight() const { return paddingBoxLeft() + paddingBoxWidth(); }
- LayoutUnit paddingBoxHeight() const { return paddingTop().valueOr(0) + contentBoxHeight() + paddingBottom().valueOr(0); }
- LayoutUnit paddingBoxWidth() const { return paddingLeft().valueOr(0) + contentBoxWidth() + paddingRight().valueOr(0); }
-
- LayoutUnit borderBoxHeight() const { return borderTop() + paddingBoxHeight() + borderBottom(); }
- LayoutUnit borderBoxWidth() const { return borderLeft() + paddingBoxWidth() + borderRight(); }
- LayoutUnit marginBoxHeight() const { return marginBefore() + borderBoxHeight() + marginAfter(); }
- LayoutUnit marginBoxWidth() const { return marginStart() + borderBoxWidth() + marginEnd(); }
-
- LayoutUnit verticalMarginBorderAndPadding() const { return marginBefore() + verticalBorder() + verticalPadding().valueOr(0) + marginAfter(); }
- LayoutUnit horizontalMarginBorderAndPadding() const { return marginStart() + horizontalBorder() + horizontalPadding().valueOr(0) + marginEnd(); }
-
- Rect marginBox() const;
- Rect borderBox() const;
- Rect paddingBox() const;
- Rect contentBox() const;
-
-#if ASSERT_ENABLED
- void setHasPrecomputedMarginBefore() { m_hasPrecomputedMarginBefore = true; }
-#endif
-
- void setTopLeft(const LayoutPoint&);
- void setTop(LayoutUnit);
- void setLeft(LayoutUnit);
- void moveHorizontally(LayoutUnit offset) { m_topLeft.move(offset, 0_lu); }
- void moveVertically(LayoutUnit offset) { m_topLeft.move(0_lu, offset); }
- void move(const LayoutSize& size) { m_topLeft.move(size); }
- void moveBy(LayoutPoint offset) { m_topLeft.moveBy(offset); }
-
- void setContentBoxHeight(LayoutUnit);
- void setContentBoxWidth(LayoutUnit);
-
- void setHorizontalMargin(HorizontalMargin);
- void setVerticalMargin(VerticalMargin);
- void setHasClearance() { m_hasClearance = true; }
-
- void setBorder(Layout::Edges);
-
- void setVerticalPadding(Layout::VerticalEdges);
- void setPadding(Optional<Layout::Edges>);
-
-private:
-#if ASSERT_ENABLED
- void invalidateMargin();
- void invalidateBorder() { m_hasValidBorder = false; }
- void invalidatePadding() { m_hasValidPadding = false; }
- void invalidatePrecomputedMarginBefore() { m_hasPrecomputedMarginBefore = false; }
-
- void setHasValidTop() { m_hasValidTop = true; }
- void setHasValidLeft() { m_hasValidLeft = true; }
- void setHasValidVerticalMargin() { m_hasValidVerticalMargin = true; }
- void setHasValidHorizontalMargin() { m_hasValidHorizontalMargin = true; }
-
- void setHasValidBorder() { m_hasValidBorder = true; }
- void setHasValidPadding() { m_hasValidPadding = true; }
-
- void setHasValidContentHeight() { m_hasValidContentHeight = true; }
- void setHasValidContentWidth() { m_hasValidContentWidth = true; }
-#endif // ASSERT_ENABLED
-
- LayoutPoint m_topLeft;
- LayoutUnit m_contentWidth;
- LayoutUnit m_contentHeight;
-
- HorizontalMargin m_horizontalMargin;
- VerticalMargin m_verticalMargin;
- bool m_hasClearance { false };
-
- Layout::Edges m_border;
- Optional<Layout::Edges> m_padding;
-
-#if ASSERT_ENABLED
- bool m_hasValidTop { false };
- bool m_hasValidLeft { false };
- bool m_hasValidHorizontalMargin { false };
- bool m_hasValidVerticalMargin { false };
- bool m_hasValidBorder { false };
- bool m_hasValidPadding { false };
- bool m_hasValidContentHeight { false };
- bool m_hasValidContentWidth { false };
- bool m_hasPrecomputedMarginBefore { false };
-#endif // ASSERT_ENABLED
-};
-
-#if ASSERT_ENABLED
-inline void Box::invalidateMargin()
-{
- m_hasValidHorizontalMargin = false;
- m_hasValidVerticalMargin = false;
-}
-#endif
-
-inline LayoutUnit Box::top() const
-{
- ASSERT(m_hasValidTop && (m_hasPrecomputedMarginBefore || m_hasValidVerticalMargin));
- return m_topLeft.y();
-}
-
-inline LayoutUnit Box::left() const
-{
- ASSERT(m_hasValidLeft && m_hasValidHorizontalMargin);
- return m_topLeft.x();
-}
-
-inline LayoutPoint Box::topLeft() const
-{
- ASSERT(m_hasValidTop && (m_hasPrecomputedMarginBefore || m_hasValidVerticalMargin));
- ASSERT(m_hasValidLeft && m_hasValidHorizontalMargin);
- return m_topLeft;
-}
-
-inline void Box::setTopLeft(const LayoutPoint& topLeft)
-{
-#if ASSERT_ENABLED
- setHasValidTop();
- setHasValidLeft();
-#endif
- m_topLeft = topLeft;
-}
-
-inline void Box::setTop(LayoutUnit top)
-{
-#if ASSERT_ENABLED
- setHasValidTop();
-#endif
- m_topLeft.setY(top);
-}
-
-inline void Box::setLeft(LayoutUnit left)
-{
-#if ASSERT_ENABLED
- setHasValidLeft();
-#endif
- m_topLeft.setX(left);
-}
-
-inline void Box::setContentBoxHeight(LayoutUnit height)
-{
-#if ASSERT_ENABLED
- setHasValidContentHeight();
-#endif
- m_contentHeight = height;
-}
-
-inline void Box::setContentBoxWidth(LayoutUnit width)
-{
-#if ASSERT_ENABLED
- setHasValidContentWidth();
-#endif
- m_contentWidth = width;
-}
-
-inline LayoutUnit Box::contentBoxHeight() const
-{
- ASSERT(m_hasValidContentHeight);
- return m_contentHeight;
-}
-
-inline LayoutUnit Box::contentBoxWidth() const
-{
- ASSERT(m_hasValidContentWidth);
- return m_contentWidth;
-}
-
-inline void Box::setHorizontalMargin(HorizontalMargin margin)
-{
-#if ASSERT_ENABLED
- setHasValidHorizontalMargin();
-#endif
- m_horizontalMargin = margin;
-}
-
-inline void Box::setVerticalMargin(VerticalMargin margin)
-{
-#if ASSERT_ENABLED
- setHasValidVerticalMargin();
- invalidatePrecomputedMarginBefore();
-#endif
- m_verticalMargin = margin;
-}
-
-inline void Box::setBorder(Layout::Edges border)
-{
-#if ASSERT_ENABLED
- setHasValidBorder();
-#endif
- m_border = border;
-}
-
-inline void Box::setPadding(Optional<Layout::Edges> padding)
-{
-#if ASSERT_ENABLED
- setHasValidPadding();
-#endif
- m_padding = padding;
-}
-
-inline void Box::setVerticalPadding(Layout::VerticalEdges verticalPadding)
-{
-#if ASSERT_ENABLED
- setHasValidPadding();
-#endif
- m_padding = Layout::Edges { m_padding ? m_padding->horizontal : Layout::HorizontalEdges(), verticalPadding };
-}
-
-inline Box::VerticalMargin Box::verticalMargin() const
-{
- ASSERT(m_hasValidVerticalMargin);
- return m_verticalMargin;
-}
-
-inline Box::HorizontalMargin Box::horizontalMargin() const
-{
- ASSERT(m_hasValidHorizontalMargin);
- return m_horizontalMargin;
-}
-
-inline LayoutUnit Box::marginBefore() const
-{
- ASSERT(m_hasValidVerticalMargin);
- return m_verticalMargin.before;
-}
-
-inline LayoutUnit Box::marginStart() const
-{
- ASSERT(m_hasValidHorizontalMargin);
- return m_horizontalMargin.start;
-}
-
-inline LayoutUnit Box::marginAfter() const
-{
- ASSERT(m_hasValidVerticalMargin);
- return m_verticalMargin.after;
-}
-
-inline LayoutUnit Box::marginEnd() const
-{
- ASSERT(m_hasValidHorizontalMargin);
- return m_horizontalMargin.end;
-}
-
-inline Optional<LayoutUnit> Box::paddingTop() const
-{
- ASSERT(m_hasValidPadding);
- if (!m_padding)
- return { };
- return m_padding->vertical.top;
-}
-
-inline Optional<LayoutUnit> Box::paddingLeft() const
-{
- ASSERT(m_hasValidPadding);
- if (!m_padding)
- return { };
- return m_padding->horizontal.left;
-}
-
-inline Optional<LayoutUnit> Box::paddingBottom() const
-{
- ASSERT(m_hasValidPadding);
- if (!m_padding)
- return { };
- return m_padding->vertical.bottom;
-}
-
-inline Optional<LayoutUnit> Box::paddingRight() const
-{
- ASSERT(m_hasValidPadding);
- if (!m_padding)
- return { };
- return m_padding->horizontal.right;
-}
-
-inline Optional<LayoutUnit> Box::verticalPadding() const
-{
- auto paddingTop = this->paddingTop();
- auto paddingBottom = this->paddingBottom();
- if (!paddingTop && !paddingBottom)
- return { };
- return paddingTop.valueOr(0) + paddingBottom.valueOr(0);
-}
-
-inline Optional<LayoutUnit> Box::horizontalPadding() const
-{
- auto paddingLeft = this->paddingLeft();
- auto paddingRight = this->paddingRight();
- if (!paddingLeft && !paddingRight)
- return { };
- return paddingLeft.valueOr(0) + paddingRight.valueOr(0);
-}
-
-inline LayoutUnit Box::borderTop() const
-{
- ASSERT(m_hasValidBorder);
- return m_border.vertical.top;
-}
-
-inline LayoutUnit Box::borderLeft() const
-{
- ASSERT(m_hasValidBorder);
- return m_border.horizontal.left;
-}
-
-inline LayoutUnit Box::borderBottom() const
-{
- ASSERT(m_hasValidBorder);
- return m_border.vertical.bottom;
-}
-
-inline LayoutUnit Box::borderRight() const
-{
- ASSERT(m_hasValidBorder);
- return m_border.horizontal.right;
-}
-
-}
-}
-#endif
Modified: trunk/Source/WebCore/layout/layouttree/LayoutIterator.h (267508 => 267509)
--- trunk/Source/WebCore/layout/layouttree/LayoutIterator.h 2020-09-23 23:28:50 UTC (rev 267508)
+++ trunk/Source/WebCore/layout/layouttree/LayoutIterator.h 2020-09-23 23:39:29 UTC (rev 267509)
@@ -27,6 +27,8 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+#include "LayoutInitialContainingBlock.h"
+
namespace WebCore {
namespace Layout {