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

Changeset 267509 in webkit


Ignore:
Timestamp:
Sep 23, 2020, 4:39:29 PM (6 years ago)
Author:
Simon Fraser
Message:

[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.
Location:
trunk/Source/WebCore
Files:
4 added
2 deleted
10 edited
13 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r267497 r267509  
    8686    "${WEBCORE_DIR}/cssjit"
    8787    "${WEBCORE_DIR}/display"
     88    "${WEBCORE_DIR}/display/css"
    8889    "${WEBCORE_DIR}/dom"
    8990    "${WEBCORE_DIR}/dom/messageports"
  • trunk/Source/WebCore/ChangeLog

    r267507 r267509  
     12020-09-20  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [LFC Display] Add the beginnings of a CSS display box hierarchy and CSS painter
     4        https://bugs.webkit.org/show_bug.cgi?id=216752
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        Add some Display::Box subclasses to display/css, a Display::Tree class to own the
     9        display tree, and a DisplayTreeBuilder. Also add css/DisplayCSSPainter which is
     10        the beginnings of a class that knows how to paint a CSS stacking context.
     11
     12        This code other than DisplayCSSPainter is deliberately vague about how much is
     13        CSS specific. It's likely that some box classes will be shared with SVG painting.
     14
     15        * CMakeLists.txt:
     16        * Headers.cmake:
     17        * Sources.txt:
     18        * WebCore.xcodeproj/project.pbxproj:
     19        * display/DisplayLayerController.cpp:
     20        (WebCore::Display::LayerController::RootLayerClient::paintContents):
     21        (WebCore::Display::LayerController::RootLayerClient::deviceScaleFactor const):
     22        (WebCore::Display::LayerController::prepareForDisplay):
     23        (WebCore::Display::LayerController::ensureRootLayer):
     24        (WebCore::Display::LayerController::updateRootLayerGeometry):
     25        * display/DisplayLayerController.h:
     26        * display/DisplayTree.cpp: Copied from Source/WebCore/display/DisplayView.h.
     27        (WebCore::Display::Tree::Tree):
     28        * display/DisplayTree.h: Copied from Source/WebCore/display/DisplayView.h.
     29        (WebCore::Display::Tree::rootBox const):
     30        * display/DisplayTreeBuilder.cpp: Added.
     31        (WebCore::Display::TreeBuilder::TreeBuilder):
     32        (WebCore::Display::TreeBuilder::build const):
     33        (WebCore::Display::TreeBuilder::recursiveBuildDisplayTree const):
     34        (WebCore::Display::TreeBuilder::displayBoxForRootBox const):
     35        (WebCore::Display::TreeBuilder::displayBoxForLayoutBox const):
     36        (WebCore::Display::outputDisplayBox):
     37        (WebCore::Display::outputDisplayTree):
     38        (WebCore::Display::showDisplayTree):
     39        * display/DisplayTreeBuilder.h: Copied from Source/WebCore/display/DisplayView.h.
     40        * display/DisplayView.cpp:
     41        (WebCore::Display::View::prepareForDisplay):
     42        (WebCore::Display::View::deviceScaleFactor const):
     43        * display/DisplayView.h:
     44        * display/css/DisplayBox.cpp: Copied from Source/WebCore/display/DisplayView.h.
     45        (WebCore::Display::Box::Box):
     46        (WebCore::Display::Box::setNextSibling):
     47        (WebCore::Display::Box::debugDescription const):
     48        * display/css/DisplayBox.h: Copied from Source/WebCore/display/DisplayView.h.
     49        (WebCore::Display::Box::Box):
     50        (WebCore::Display::Box::style const):
     51        (WebCore::Display::Box::borderBoxFrame const):
     52        (WebCore::Display::Box::isContainerBox const):
     53        (WebCore::Display::Box::isImageBox const):
     54        (WebCore::Display::Box::isReplacedBox const):
     55        (WebCore::Display::Box::nextSibling const):
     56        * display/css/DisplayCSSPainter.cpp: Added.
     57        (WebCore::Display::CSSPainter::paintBoxDecorations):
     58        (WebCore::Display::CSSPainter::paintBoxContent):
     59        (WebCore::Display::CSSPainter::paintBox):
     60        (WebCore::Display::CSSPainter::recursivePaintDescendants):
     61        (WebCore::Display::CSSPainter::paintStackingContext):
     62        (WebCore::Display::CSSPainter::isStackingContextPaintingBoundary):
     63        (WebCore::Display::CSSPainter::recursiveCollectLayers):
     64        (WebCore::Display::CSSPainter::paintTree):
     65        * display/css/DisplayCSSPainter.h: Copied from Source/WebCore/display/DisplayView.h.
     66        * display/css/DisplayContainerBox.cpp: Copied from Source/WebCore/display/DisplayView.h.
     67        (WebCore::Display::ContainerBox::ContainerBox):
     68        (WebCore::Display::ContainerBox::setFirstChild):
     69        (WebCore::Display::ContainerBox::debugDescription const):
     70        * display/css/DisplayContainerBox.h: Copied from Source/WebCore/display/DisplayView.h.
     71        (WebCore::Display::ContainerBox::firstChild const):
     72        * display/css/DisplayImageBox.cpp: Copied from Source/WebCore/display/DisplayView.h.
     73        (WebCore::Display::ImageBox::ImageBox):
     74        (WebCore::Display::ImageBox::setImage):
     75        (WebCore::Display::ImageBox::debugDescription const):
     76        * display/css/DisplayImageBox.h: Copied from Source/WebCore/display/DisplayView.h.
     77        (WebCore::Display::ImageBox::image const):
     78        * display/css/DisplayReplacedBox.cpp: Copied from Source/WebCore/display/DisplayView.h.
     79        (WebCore::Display::ReplacedBox::ReplacedBox):
     80        * display/css/DisplayReplacedBox.h: Copied from Source/WebCore/display/DisplayView.h.
     81        (WebCore::Display::ReplacedBox::replacedContentRect const):
     82        * display/css/DisplayStyle.cpp: Copied from Source/WebCore/display/DisplayView.cpp.
     83        (WebCore::Display::Style::Style):
     84        (WebCore::Display::Style::hasBackground const):
     85        (WebCore::Display::Style::hasVisibleBorder const):
     86        * display/css/DisplayStyle.h: Added.
     87        (WebCore::Display::Style::backgroundColor const):
     88        (WebCore::Display::Style::hasBackgroundImage const):
     89        (WebCore::Display::Style::borderLeft const):
     90        (WebCore::Display::Style::borderRight const):
     91        (WebCore::Display::Style::borderTop const):
     92        (WebCore::Display::Style::borderBottom const):
     93        (WebCore::Display::Style::zIndex const):
     94        (WebCore::Display::Style::isStackingContext const):
     95        (WebCore::Display::Style::isPositioned const):
     96        (WebCore::Display::Style::isFloating const):
     97        (WebCore::Display::Style::participatesInZOrderSorting const):
     98        (WebCore::Display::Style::setIsPositioned):
     99        (WebCore::Display::Style::setIsFloating):
     100        * layout/displaytree/DisplayBox.cpp: Removed.
     101        * layout/displaytree/DisplayBox.h: Removed.
     102        * layout/layouttree/LayoutIterator.h: Unified sources build fix.
     103
    11042020-09-23  Chris Dumez  <cdumez@apple.com>
    2105
  • trunk/Source/WebCore/Headers.cmake

    r267328 r267509  
    363363
    364364    display/DisplayLayerController.h
     365    display/DisplayTree.h
     366    display/DisplayTreeBuilder.h
    365367    display/DisplayView.h
     368
     369    display/css/DisplayBox.h
     370    display/css/DisplayCSSPainter.h
     371    display/css/DisplayContainerBox.h
     372    display/css/DisplayImageBox.h
     373    display/css/DisplayReplacedBox.h
     374    display/css/DisplayStyle.h
    366375
    367376    dom/ActiveDOMCallback.h
     
    697706    layout/MarginTypes.h
    698707
    699     layout/displaytree/DisplayBox.h
    700708    layout/displaytree/DisplayInlineContent.h
    701709    layout/displaytree/DisplayLine.h
  • trunk/Source/WebCore/Sources.txt

    r267468 r267509  
    795795css/typedom/TypedOMCSSUnparsedValue.cpp
    796796cssjit/SelectorCompiler.cpp
     797display/css/DisplayBox.cpp
     798display/css/DisplayContainerBox.cpp
     799display/css/DisplayCSSPainter.cpp
     800display/css/DisplayImageBox.cpp
     801display/css/DisplayReplacedBox.cpp
     802display/css/DisplayStyle.cpp
    797803display/DisplayLayerController.cpp
     804display/DisplayTree.cpp
     805display/DisplayTreeBuilder.cpp
    798806display/DisplayView.cpp
    799807dom/AbortController.cpp
     
    14351443layout/blockformatting/tablewrapper/TableWrapperBlockFormattingContext.cpp
    14361444layout/blockformatting/tablewrapper/TableWrapperBlockFormattingContextQuirks.cpp
    1437 layout/displaytree/DisplayBox.cpp
    14381445layout/displaytree/DisplayInlineContent.cpp
    14391446layout/displaytree/DisplayPainter.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r267491 r267509  
    392392                119340A31FEE024000935F1E /* RenderTreeBuilderBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = 119340A11FEE024000935F1E /* RenderTreeBuilderBlock.h */; };
    393393                1199FA46208E35A3002358CC /* LayoutContainerBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 1199FA44208E35A3002358CC /* LayoutContainerBox.h */; settings = {ATTRIBUTES = (Private, ); }; };
    394                 1199FA5B208E3C7F002358CC /* DisplayBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 1199FA59208E3C7F002358CC /* DisplayBox.h */; settings = {ATTRIBUTES = (Private, ); }; };
    395394                11CB2789203BA570004A1DC9 /* RenderTreeBuilderFullScreen.h in Headers */ = {isa = PBXBuildFile; fileRef = 11CB2787203BA570004A1DC9 /* RenderTreeBuilderFullScreen.h */; };
    396395                11E067EE1E6246E500162D16 /* SimpleLineLayoutCoverage.h in Headers */ = {isa = PBXBuildFile; fileRef = 11E067ED1E6246E500162D16 /* SimpleLineLayoutCoverage.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    60916090                0FFD4D5E18651FA300512F6E /* AsyncScrollingCoordinator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AsyncScrollingCoordinator.cpp; sourceTree = "<group>"; };
    60926091                0FFD4D5F18651FA300512F6E /* AsyncScrollingCoordinator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AsyncScrollingCoordinator.h; sourceTree = "<group>"; };
     6092                0FFF1B72251BC6570098795A /* DisplayBox.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayBox.cpp; sourceTree = "<group>"; };
     6093                0FFF1B73251BC6570098795A /* DisplayStyle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayStyle.h; sourceTree = "<group>"; };
     6094                0FFF1B74251BC6570098795A /* DisplayContainerBox.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayContainerBox.cpp; sourceTree = "<group>"; };
     6095                0FFF1B75251BC6570098795A /* DisplayImageBox.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayImageBox.cpp; sourceTree = "<group>"; };
     6096                0FFF1B76251BC6570098795A /* DisplayStyle.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayStyle.cpp; sourceTree = "<group>"; };
     6097                0FFF1B77251BC6570098795A /* DisplayCSSPainter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayCSSPainter.h; sourceTree = "<group>"; };
     6098                0FFF1B78251BC6570098795A /* DisplayBox.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayBox.h; sourceTree = "<group>"; };
     6099                0FFF1B79251BC6570098795A /* DisplayReplacedBox.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayReplacedBox.h; sourceTree = "<group>"; };
     6100                0FFF1B7A251BC6570098795A /* DisplayContainerBox.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayContainerBox.h; sourceTree = "<group>"; };
     6101                0FFF1B7B251BC6570098795A /* DisplayImageBox.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayImageBox.h; sourceTree = "<group>"; };
     6102                0FFF1B7C251BC6570098795A /* DisplayReplacedBox.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayReplacedBox.cpp; sourceTree = "<group>"; };
     6103                0FFF1B7D251BC6570098795A /* DisplayCSSPainter.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayCSSPainter.cpp; sourceTree = "<group>"; };
     6104                0FFF1B7F251BC6620098795A /* DisplayTreeBuilder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayTreeBuilder.h; sourceTree = "<group>"; };
     6105                0FFF1B80251BC6620098795A /* DisplayTreeBuilder.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayTreeBuilder.cpp; sourceTree = "<group>"; };
     6106                0FFF1B81251BC6630098795A /* DisplayTree.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayTree.h; sourceTree = "<group>"; };
     6107                0FFF1B82251BC6630098795A /* DisplayTree.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayTree.cpp; sourceTree = "<group>"; };
    60936108                10FB084A14E15C7E00A3DB98 /* PublicURLManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PublicURLManager.h; sourceTree = "<group>"; };
    60946109                1100FC6E1FDB3C4D00DD961B /* TrailingFloatsRootInlineBox.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TrailingFloatsRootInlineBox.cpp; sourceTree = "<group>"; };
     
    61356150                1199FA44208E35A3002358CC /* LayoutContainerBox.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LayoutContainerBox.h; sourceTree = "<group>"; };
    61366151                1199FA45208E35A3002358CC /* LayoutContainerBox.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutContainerBox.cpp; sourceTree = "<group>"; };
    6137                 1199FA59208E3C7F002358CC /* DisplayBox.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayBox.h; sourceTree = "<group>"; };
    6138                 1199FA5A208E3C7F002358CC /* DisplayBox.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayBox.cpp; sourceTree = "<group>"; };
    61396152                11B042FB20B0E21400828A6B /* LayoutDescendantIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutDescendantIterator.h; sourceTree = "<group>"; };
    61406153                11C5F1162003E7750001AE60 /* RenderTreeBuilderInline.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTreeBuilderInline.cpp; sourceTree = "<group>"; };
     
    1743117444                        isa = PBXGroup;
    1743217445                        children = (
     17446                                0FFF1B71251BC6570098795A /* css */,
    1743317447                                0F790F402517CE6D009BA034 /* DisplayLayerController.cpp */,
    1743417448                                0F790F3E2517CE6D009BA034 /* DisplayLayerController.h */,
     17449                                0FFF1B82251BC6630098795A /* DisplayTree.cpp */,
     17450                                0FFF1B81251BC6630098795A /* DisplayTree.h */,
     17451                                0FFF1B80251BC6620098795A /* DisplayTreeBuilder.cpp */,
     17452                                0FFF1B7F251BC6620098795A /* DisplayTreeBuilder.h */,
    1743517453                                0F790F3D2517CE6D009BA034 /* DisplayView.cpp */,
    1743617454                                0F790F3F2517CE6D009BA034 /* DisplayView.h */,
     
    1745517473                        );
    1745617474                        path = displaylists;
     17475                        sourceTree = "<group>";
     17476                };
     17477                0FFF1B71251BC6570098795A /* css */ = {
     17478                        isa = PBXGroup;
     17479                        children = (
     17480                                0FFF1B72251BC6570098795A /* DisplayBox.cpp */,
     17481                                0FFF1B78251BC6570098795A /* DisplayBox.h */,
     17482                                0FFF1B74251BC6570098795A /* DisplayContainerBox.cpp */,
     17483                                0FFF1B7A251BC6570098795A /* DisplayContainerBox.h */,
     17484                                0FFF1B7D251BC6570098795A /* DisplayCSSPainter.cpp */,
     17485                                0FFF1B77251BC6570098795A /* DisplayCSSPainter.h */,
     17486                                0FFF1B75251BC6570098795A /* DisplayImageBox.cpp */,
     17487                                0FFF1B7B251BC6570098795A /* DisplayImageBox.h */,
     17488                                0FFF1B7C251BC6570098795A /* DisplayReplacedBox.cpp */,
     17489                                0FFF1B79251BC6570098795A /* DisplayReplacedBox.h */,
     17490                                0FFF1B76251BC6570098795A /* DisplayStyle.cpp */,
     17491                                0FFF1B73251BC6570098795A /* DisplayStyle.h */,
     17492                        );
     17493                        path = css;
    1745717494                        sourceTree = "<group>";
    1745817495                };
     
    1756517602                        isa = PBXGroup;
    1756617603                        children = (
    17567                                 1199FA5A208E3C7F002358CC /* DisplayBox.cpp */,
    17568                                 1199FA59208E3C7F002358CC /* DisplayBox.h */,
    1756917604                                E4FB4B35239BEB10003C336A /* DisplayInlineContent.cpp */,
    1757017605                                E451C6332394058E00993190 /* DisplayInlineContent.h */,
     
    3107531110                                F47A09D120A93A9700240FAE /* DisabledAdaptations.h in Headers */,
    3107631111                                7EDAAFC919A2CCDC0034DFD1 /* DiskCacheMonitorCocoa.h in Headers */,
    31077                                 1199FA5B208E3C7F002358CC /* DisplayBox.h in Headers */,
    3107831112                                E451C6342394058F00993190 /* DisplayInlineContent.h in Headers */,
    3107931113                                0F790F422517CE6E009BA034 /* DisplayLayerController.h in Headers */,
  • trunk/Source/WebCore/display/DisplayLayerController.cpp

    r267328 r267509  
    3131#include "Chrome.h"
    3232#include "ChromeClient.h"
    33 #include "DisplayPainter.h"
     33#include "DisplayCSSPainter.h"
     34#include "DisplayTree.h"
    3435#include "DisplayView.h"
    3536#include "Frame.h"
    3637#include "FrameView.h"
    37 #include "LayoutBoxGeometry.h"
    38 #include "LayoutContext.h"
    39 #include "LayoutState.h"
    4038#include "Logging.h"
    4139#include "Page.h"
     
    6159    ASSERT_UNUSED(layer, layer == m_layerController.contentLayer());
    6260
    63     // FIXME: Temporary; once we do scrolling this root layer won't paint anything.
    64     if (auto* layoutState = m_layerController.view().layoutState())
    65         Layout::LayoutContext::paint(*layoutState, context, enclosingIntRect(dirtyRect));
    66 }
    67 
    68 WTF_MAKE_ISO_ALLOCATED_IMPL(LayerController);
     61    if (auto* displayTree = m_layerController.m_displayTree.get())
     62        CSSPainter::paintTree(*displayTree, context, enclosingIntRect(dirtyRect));
     63}
     64
     65float LayerController::RootLayerClient::deviceScaleFactor() const
     66{
     67    return m_layerController.view().deviceScaleFactor();
     68}
    6969
    7070LayerController::LayerController(View& view)
     
    7676LayerController::~LayerController() = default;
    7777
    78 void LayerController::prepareForDisplay(const Layout::LayoutState& layoutState)
    79 {
    80     if (!layoutState.hasRoot())
    81         return;
    82 
    83     auto& rootLayoutBox = layoutState.root();
    84     if (!rootLayoutBox.firstChild())
    85         return;
    86 
    87     ASSERT(layoutState.hasBoxGeometry(rootLayoutBox));
    88 
    89     auto viewSize = layoutState.geometryForBox(rootLayoutBox).logicalSize();
    90     auto contentSize = layoutState.geometryForBox(*rootLayoutBox.firstChild()).logicalSize();
    91    
    92     // FIXME: Using the firstChild() size won't be correct until we compute overflow correctly,
    93     contentSize.clampToMinimumSize(viewSize);
     78void LayerController::prepareForDisplay(std::unique_ptr<Display::Tree>&& displayTree)
     79{
     80    ASSERT(displayTree);
     81    m_displayTree = WTFMove(displayTree);
     82
     83    auto viewSize = m_displayTree->rootBox().borderBoxFrame().size();
     84    // FIXME: Do overflow etc.
     85    auto contentSize = viewSize;
    9486
    9587    LOG_WITH_STREAM(FormattingContextLayout, stream << "LayerController::prepareForDisplay - viewSize " << viewSize << " contentSize " << contentSize);
     
    137129}
    138130
    139 void LayerController::ensureRootLayer(LayoutSize viewSize, LayoutSize contentSize)
     131void LayerController::ensureRootLayer(FloatSize viewSize, FloatSize contentSize)
    140132{
    141133    if (m_rootLayer) {
     
    172164}
    173165
    174 void LayerController::updateRootLayerGeometry(LayoutSize viewSize, LayoutSize contentSize)
     166void LayerController::updateRootLayerGeometry(FloatSize viewSize, FloatSize contentSize)
    175167{
    176168    m_rootLayer->setSize(viewSize);
  • trunk/Source/WebCore/display/DisplayLayerController.h

    r267328 r267509  
    2828#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    2929
    30 #include "DisplayRect.h"
    3130#include "GraphicsLayer.h"
    32 #include "LayoutUnits.h"
    3331#include <wtf/IsoMalloc.h>
    3432
     
    3836class GraphicsLayerFactory;
    3937
    40 namespace Layout {
    41 class LayoutState;
    42 }
    43 
    4438namespace Display {
    4539
     40class Tree;
    4641class View;
    4742
    4843// A controller object that makes layerization decisions for a display tree, for a single document.
    4944class LayerController {
    50     WTF_MAKE_ISO_ALLOCATED(LayerController);
     45    WTF_MAKE_FAST_ALLOCATED(LayerController);
    5146public:
    5247    explicit LayerController(View&);
    5348    ~LayerController();
    5449   
    55     void prepareForDisplay(const Layout::LayoutState&);
     50    void prepareForDisplay(std::unique_ptr<Display::Tree>&&);
    5651    void flushLayers();
    5752
     
    6156
    6257private:
    63     void ensureRootLayer(LayoutSize viewSize, LayoutSize contentSize);
    6458    void attachRootLayer();
    6559    void detachRootLayer();
     60
     61    void ensureRootLayer(FloatSize viewSize, FloatSize contentSize);
     62    void updateRootLayerGeometry(FloatSize viewSize, FloatSize contentSize);
     63
    6664    void setupRootLayerHierarchy();
    67     void updateRootLayerGeometry(LayoutSize viewSize, LayoutSize contentSize);
    6865    void scheduleRenderingUpdate();
    6966   
     
    8380        void notifyFlushRequired(const GraphicsLayer*) final;
    8481        void paintContents(const GraphicsLayer*, GraphicsContext&, const FloatRect&, GraphicsLayerPaintBehavior) final;
     82        float deviceScaleFactor() const final;
    8583
    8684        LayerController& m_layerController;
     
    9391    RefPtr<GraphicsLayer> m_contentHostLayer;
    9492    RefPtr<GraphicsLayer> m_contentLayer;
     93
     94    std::unique_ptr<Display::Tree> m_displayTree;
    9595};
    9696
  • trunk/Source/WebCore/display/DisplayTree.cpp

    r267508 r267509  
    2424 */
    2525
    26 #pragma once
     26#include "config.h"
     27#include "DisplayTree.h"
    2728
    2829#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    2930
    30 #include "DisplayLayerController.h"
    31 #include "DisplayRect.h"
    32 #include "LayoutUnits.h"
    33 #include <wtf/IsoMalloc.h>
     31#include <wtf/IsoMallocInlines.h>
    3432
    3533namespace WebCore {
    36 
    37 class Frame;
    38 class FrameView;
    39 class Page;
    40 
    41 namespace Layout {
    42 class LayoutState;
    43 class LayoutTree;
    44 }
    45 
    4634namespace Display {
    4735
    48 // The root object which renders a display tree for a single document.
    49 class View {
    50     WTF_MAKE_ISO_ALLOCATED(View);
    51 public:
    52     explicit View(FrameView&);
    53     ~View();
    54    
    55     void prepareForDisplay();
    56     void flushLayers();
    57    
    58     void setIsInWindow(bool);
    59 
    60     Page* page() const;
    61     FrameView& frameView() const { return m_frameView; }
    62     Frame& frame() const;
    63 
    64     const Layout::LayoutState* layoutState() const;
    65 
    66 private:
    67     FrameView& m_frameView;
    68     LayerController m_layerController;
    69 };
     36Tree::Tree(std::unique_ptr<ContainerBox>&& rootBox)
     37    : m_rootBox(WTFMove(rootBox))
     38{
     39    ASSERT(m_rootBox);
     40}
    7041
    7142} // namespace Display
  • trunk/Source/WebCore/display/DisplayTree.h

    r267508 r267509  
    2828#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    2929
    30 #include "DisplayLayerController.h"
    31 #include "DisplayRect.h"
    32 #include "LayoutUnits.h"
     30#include "DisplayContainerBox.h"
    3331#include <wtf/IsoMalloc.h>
    3432
    3533namespace WebCore {
    36 
    37 class Frame;
    38 class FrameView;
    39 class Page;
    40 
    41 namespace Layout {
    42 class LayoutState;
    43 class LayoutTree;
    44 }
    45 
    4634namespace Display {
    4735
    48 // The root object which renders a display tree for a single document.
    49 class View {
    50     WTF_MAKE_ISO_ALLOCATED(View);
     36class Tree {
     37    WTF_MAKE_FAST_ALLOCATED(Tree);
    5138public:
    52     explicit View(FrameView&);
    53     ~View();
    54    
    55     void prepareForDisplay();
    56     void flushLayers();
    57    
    58     void setIsInWindow(bool);
     39    Tree(std::unique_ptr<ContainerBox>&&);
    5940
    60     Page* page() const;
    61     FrameView& frameView() const { return m_frameView; }
    62     Frame& frame() const;
    63 
    64     const Layout::LayoutState* layoutState() const;
     41    const ContainerBox& rootBox() const { return *m_rootBox; }
    6542
    6643private:
    67     FrameView& m_frameView;
    68     LayerController m_layerController;
     44    // Ideally this root box would be agnostic to display type (CSS vs SVG).
     45    std::unique_ptr<ContainerBox> m_rootBox;
    6946};
    7047
  • trunk/Source/WebCore/display/DisplayTreeBuilder.h

    r267508 r267509  
    2828#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    2929
    30 #include "DisplayLayerController.h"
    31 #include "DisplayRect.h"
    32 #include "LayoutUnits.h"
    3330#include <wtf/IsoMalloc.h>
    3431
    3532namespace WebCore {
    3633
    37 class Frame;
    38 class FrameView;
    39 class Page;
    40 
    4134namespace Layout {
     35class Box;
     36class BoxGeometry;
    4237class LayoutState;
    43 class LayoutTree;
    4438}
    4539
    4640namespace Display {
    4741
    48 // The root object which renders a display tree for a single document.
    49 class View {
    50     WTF_MAKE_ISO_ALLOCATED(View);
     42class Box;
     43class ContainerBox;
     44class Tree;
     45
     46class TreeBuilder {
    5147public:
    52     explicit View(FrameView&);
    53     ~View();
    54    
    55     void prepareForDisplay();
    56     void flushLayers();
    57    
    58     void setIsInWindow(bool);
     48    explicit TreeBuilder(float pixelSnappingFactor);
    5949
    60     Page* page() const;
    61     FrameView& frameView() const { return m_frameView; }
    62     Frame& frame() const;
    63 
    64     const Layout::LayoutState* layoutState() const;
     50    std::unique_ptr<Tree> build(const Layout::LayoutState&) const;
    6551
    6652private:
    67     FrameView& m_frameView;
    68     LayerController m_layerController;
     53    std::unique_ptr<Box> displayBoxForRootBox(const Layout::BoxGeometry&, const Layout::ContainerBox&) const;
     54    std::unique_ptr<Box> displayBoxForLayoutBox(const Layout::BoxGeometry&, const Layout::Box&, LayoutSize offsetFromRoot) const;
     55
     56    Box* recursiveBuildDisplayTree(const Layout::LayoutState&, LayoutSize offsetFromRoot, const Layout::Box&, Display::ContainerBox& parentDisplayBox, Display::Box* previousSiblingBox = nullptr) const;
     57
     58    float m_pixelSnappingFactor { 1 };
    6959};
     60
     61#if ENABLE(TREE_DEBUGGING)
     62void showDisplayTree(const Box&);
     63#endif
    7064
    7165} // namespace Display
  • trunk/Source/WebCore/display/DisplayView.cpp

    r267328 r267509  
    2929#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    3030
     31#include "DisplayTreeBuilder.h"
    3132#include "Frame.h"
    3233#include "FrameView.h"
    33 #include "FrameViewLayoutContext.h"
    34 #include "LayoutContext.h"
    35 #include "LayoutState.h"
    3634#include "Page.h"
    3735#include <wtf/IsoMallocInlines.h>
     
    7371        return;
    7472
    75     m_layerController.prepareForDisplay(*layoutState);
     73    auto treeBuilder = TreeBuilder { deviceScaleFactor() };
     74    auto displayTree = treeBuilder.build(*layoutState);
     75
     76    m_layerController.prepareForDisplay(WTFMove(displayTree));
    7677}
    7778
     
    8687}
    8788
     89float View::deviceScaleFactor() const
     90{
     91    return page() ? page()->deviceScaleFactor() : 1.0f;
     92}
     93
    8894} // namespace Display
    8995} // namespace WebCore
  • trunk/Source/WebCore/display/DisplayView.h

    r267328 r267509  
    6262    Frame& frame() const;
    6363
     64    float deviceScaleFactor() const;
     65
     66private:
    6467    const Layout::LayoutState* layoutState() const;
    6568
    66 private:
    6769    FrameView& m_frameView;
    6870    LayerController m_layerController;
  • trunk/Source/WebCore/display/css/DisplayBox.cpp

    r267508 r267509  
    11/*
    2  * Copyright (C) 2020 Apple Inc. All rights reserved.
     2 * Copyright (C) 2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #pragma once
     26#include "config.h"
     27#include "DisplayBox.h"
    2728
    2829#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    2930
    30 #include "DisplayLayerController.h"
    31 #include "DisplayRect.h"
    32 #include "LayoutUnits.h"
    33 #include <wtf/IsoMalloc.h>
     31#include <wtf/IsoMallocInlines.h>
     32#include <wtf/text/TextStream.h>
    3433
    3534namespace WebCore {
     35namespace Display {
    3636
    37 class Frame;
    38 class FrameView;
    39 class Page;
    40 
    41 namespace Layout {
    42 class LayoutState;
    43 class LayoutTree;
     37Box::Box(AbsoluteFloatRect borderBox, Style&& displayStyle, OptionSet<Flags> flags)
     38    : m_borderBoxFrame(borderBox)
     39    , m_style(WTFMove(displayStyle))
     40    , m_flags(flags)
     41{
    4442}
    4543
    46 namespace Display {
     44void Box::setNextSibling(std::unique_ptr<Box>&& box)
     45{
     46    m_nextSibling = WTFMove(box);
     47}
    4748
    48 // The root object which renders a display tree for a single document.
    49 class View {
    50     WTF_MAKE_ISO_ALLOCATED(View);
    51 public:
    52     explicit View(FrameView&);
    53     ~View();
    54    
    55     void prepareForDisplay();
    56     void flushLayers();
    57    
    58     void setIsInWindow(bool);
    59 
    60     Page* page() const;
    61     FrameView& frameView() const { return m_frameView; }
    62     Frame& frame() const;
    63 
    64     const Layout::LayoutState* layoutState() const;
    65 
    66 private:
    67     FrameView& m_frameView;
    68     LayerController m_layerController;
    69 };
     49String Box::debugDescription() const
     50{
     51    TextStream stream;
     52    stream << "display box " << borderBoxFrame() << " (" << this << ")";
     53    return stream.release();
     54}
    7055
    7156} // namespace Display
  • trunk/Source/WebCore/display/css/DisplayBox.h

    r267508 r267509  
    11/*
    2  * Copyright (C) 2020 Apple Inc. All rights reserved.
     2 * Copyright (C) 2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2828#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    2929
    30 #include "DisplayLayerController.h"
    31 #include "DisplayRect.h"
    32 #include "LayoutUnits.h"
     30#include "DisplayStyle.h"
     31#include "FloatRect.h"
    3332#include <wtf/IsoMalloc.h>
     33#include <wtf/OptionSet.h>
    3434
    3535namespace WebCore {
    36 
    37 class Frame;
    38 class FrameView;
    39 class Page;
    40 
    41 namespace Layout {
    42 class LayoutState;
    43 class LayoutTree;
    44 }
    45 
    4636namespace Display {
    4737
    48 // The root object which renders a display tree for a single document.
    49 class View {
    50     WTF_MAKE_ISO_ALLOCATED(View);
     38// FIXME: Make this a strong type.
     39using AbsoluteFloatRect = FloatRect;
     40
     41class Box {
     42    WTF_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(Box);
    5143public:
    52     explicit View(FrameView&);
    53     ~View();
    54    
    55     void prepareForDisplay();
    56     void flushLayers();
    57    
    58     void setIsInWindow(bool);
     44    enum class Flags : uint8_t {
     45        ContainerBox    = 1 << 0,
     46        ImageBox        = 1 << 1,
     47    };
    5948
    60     Page* page() const;
    61     FrameView& frameView() const { return m_frameView; }
    62     Frame& frame() const;
     49    Box(AbsoluteFloatRect borderBox, Style&&, OptionSet<Flags> = { });
     50    virtual ~Box() = default;
    6351
    64     const Layout::LayoutState* layoutState() const;
     52    const Style& style() const { return m_style; }
     53
     54    AbsoluteFloatRect borderBoxFrame() const { return m_borderBoxFrame; }
     55
     56    bool isContainerBox() const { return m_flags.contains(Flags::ContainerBox); }
     57    bool isImageBox() const { return m_flags.contains(Flags::ImageBox); }
     58    bool isReplacedBox() const { return m_flags.contains(Flags::ImageBox); /* and other types later. */ }
     59
     60    const Box* nextSibling() const { return m_nextSibling.get(); }
     61    void setNextSibling(std::unique_ptr<Box>&&);
     62
     63    virtual String debugDescription() const;
    6564
    6665private:
    67     FrameView& m_frameView;
    68     LayerController m_layerController;
     66    AbsoluteFloatRect m_borderBoxFrame;
     67    Style m_style;
     68    std::unique_ptr<Box> m_nextSibling;
     69    OptionSet<Flags> m_flags;
    6970};
    7071
     
    7273} // namespace WebCore
    7374
     75#define SPECIALIZE_TYPE_TRAITS_DISPLAY_BOX(ToValueTypeName, predicate) \
     76SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::Display::ToValueTypeName) \
     77    static bool isType(const WebCore::Display::Box& box) { return box.predicate; } \
     78SPECIALIZE_TYPE_TRAITS_END()
     79
    7480#endif // ENABLE(LAYOUT_FORMATTING_CONTEXT)
  • trunk/Source/WebCore/display/css/DisplayCSSPainter.h

    r267508 r267509  
    11/*
    2  * Copyright (C) 2020 Apple Inc. All rights reserved.
     2 * Copyright (C) 2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2828#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    2929
    30 #include "DisplayLayerController.h"
    31 #include "DisplayRect.h"
    32 #include "LayoutUnits.h"
    33 #include <wtf/IsoMalloc.h>
     30#include "FloatSize.h"
     31#include <wtf/Vector.h>
    3432
    3533namespace WebCore {
    3634
    37 class Frame;
    38 class FrameView;
    39 class Page;
    40 
    41 namespace Layout {
    42 class LayoutState;
    43 class LayoutTree;
    44 }
     35class GraphicsContext;
     36class IntRect;
    4537
    4638namespace Display {
    4739
    48 // The root object which renders a display tree for a single document.
    49 class View {
    50     WTF_MAKE_ISO_ALLOCATED(View);
     40class Box;
     41class ContainerBox;
     42class Tree;
     43
     44class CSSPainter {
    5145public:
    52     explicit View(FrameView&);
    53     ~View();
     46    static void paintStackingContext(const Box&, GraphicsContext&, const IntRect& dirtyRect);
    5447   
    55     void prepareForDisplay();
    56     void flushLayers();
    57    
    58     void setIsInWindow(bool);
     48    static void paintTree(const Tree&, GraphicsContext&, const IntRect& dirtyRect);
    5949
    60     Page* page() const;
    61     FrameView& frameView() const { return m_frameView; }
    62     Frame& frame() const;
    63 
    64     const Layout::LayoutState* layoutState() const;
    6550
    6651private:
    67     FrameView& m_frameView;
    68     LayerController m_layerController;
     52    static void paintBox(const Box&, GraphicsContext&, const IntRect& dirtyRect);
     53    static void paintBoxDecorations(const Box&, GraphicsContext&);
     54    static void paintBoxContent(const Box&, GraphicsContext&);
     55
     56    enum class PaintPhase {
     57        BlockBackgrounds,
     58        Floats,
     59        BlockForegrounds
     60    };
     61    static void recursivePaintDescendants(const ContainerBox&, GraphicsContext&, PaintPhase);
     62
     63    static bool isStackingContextPaintingBoundary(const Box&);
     64    static void recursiveCollectLayers(const ContainerBox&, Vector<const Box*>& negativeZOrderList, Vector<const Box*>& positiveZOrderList);
    6965};
    7066
  • trunk/Source/WebCore/display/css/DisplayContainerBox.cpp

    r267508 r267509  
    2424 */
    2525
    26 #pragma once
     26#include "config.h"
     27#include "DisplayContainerBox.h"
    2728
    2829#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    2930
    30 #include "DisplayLayerController.h"
    31 #include "DisplayRect.h"
    32 #include "LayoutUnits.h"
    33 #include <wtf/IsoMalloc.h>
     31#include "DisplayStyle.h"
     32#include <wtf/IsoMallocInlines.h>
    3433
    3534namespace WebCore {
     35namespace Display {
    3636
    37 class Frame;
    38 class FrameView;
    39 class Page;
    40 
    41 namespace Layout {
    42 class LayoutState;
    43 class LayoutTree;
     37ContainerBox::ContainerBox(AbsoluteFloatRect borderBox, Style&& displayStyle)
     38    : Box(borderBox, WTFMove(displayStyle), { Flags::ContainerBox })
     39{
    4440}
    4541
    46 namespace Display {
     42void ContainerBox::setFirstChild(std::unique_ptr<Box>&& box)
     43{
     44    m_firstChild = WTFMove(box);
     45}
    4746
    48 // The root object which renders a display tree for a single document.
    49 class View {
    50     WTF_MAKE_ISO_ALLOCATED(View);
    51 public:
    52     explicit View(FrameView&);
    53     ~View();
    54    
    55     void prepareForDisplay();
    56     void flushLayers();
    57    
    58     void setIsInWindow(bool);
    59 
    60     Page* page() const;
    61     FrameView& frameView() const { return m_frameView; }
    62     Frame& frame() const;
    63 
    64     const Layout::LayoutState* layoutState() const;
    65 
    66 private:
    67     FrameView& m_frameView;
    68     LayerController m_layerController;
    69 };
     47String ContainerBox::debugDescription() const
     48{
     49    TextStream stream;
     50    stream << "container box " << borderBoxFrame() << " (" << this << ")";
     51    return stream.release();
     52}
    7053
    7154} // namespace Display
  • trunk/Source/WebCore/display/css/DisplayContainerBox.h

    r267508 r267509  
    11/*
    2  * Copyright (C) 2020 Apple Inc. All rights reserved.
     2 * Copyright (C) 2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2828#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    2929
    30 #include "DisplayLayerController.h"
    31 #include "DisplayRect.h"
    32 #include "LayoutUnits.h"
    33 #include <wtf/IsoMalloc.h>
     30#include "DisplayBox.h"
    3431
    3532namespace WebCore {
    36 
    37 class Frame;
    38 class FrameView;
    39 class Page;
    40 
    41 namespace Layout {
    42 class LayoutState;
    43 class LayoutTree;
    44 }
    45 
    4633namespace Display {
    4734
    48 // The root object which renders a display tree for a single document.
    49 class View {
    50     WTF_MAKE_ISO_ALLOCATED(View);
     35class ContainerBox : public Box {
     36    WTF_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(ContainerBox);
    5137public:
    52     explicit View(FrameView&);
    53     ~View();
     38    ContainerBox(AbsoluteFloatRect borderBox, Style&&);
    5439   
    55     void prepareForDisplay();
    56     void flushLayers();
    57    
    58     void setIsInWindow(bool);
    59 
    60     Page* page() const;
    61     FrameView& frameView() const { return m_frameView; }
    62     Frame& frame() const;
    63 
    64     const Layout::LayoutState* layoutState() const;
     40    const Box* firstChild() const { return m_firstChild.get(); }
     41    void setFirstChild(std::unique_ptr<Box>&&);
    6542
    6643private:
    67     FrameView& m_frameView;
    68     LayerController m_layerController;
     44    String debugDescription() const override;
     45
     46    std::unique_ptr<Box> m_firstChild;
    6947};
    7048
     
    7250} // namespace WebCore
    7351
     52SPECIALIZE_TYPE_TRAITS_DISPLAY_BOX(ContainerBox, isContainerBox())
     53
    7454#endif // ENABLE(LAYOUT_FORMATTING_CONTEXT)
  • trunk/Source/WebCore/display/css/DisplayImageBox.cpp

    r267508 r267509  
    2424 */
    2525
    26 #pragma once
     26#include "config.h"
     27#include "DisplayImageBox.h"
    2728
    2829#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    2930
    30 #include "DisplayLayerController.h"
    31 #include "DisplayRect.h"
    32 #include "LayoutUnits.h"
    33 #include <wtf/IsoMalloc.h>
     31#include "Image.h"
     32#include <wtf/IsoMallocInlines.h>
    3433
    3534namespace WebCore {
     35namespace Display {
    3636
    37 class Frame;
    38 class FrameView;
    39 class Page;
    40 
    41 namespace Layout {
    42 class LayoutState;
    43 class LayoutTree;
     37ImageBox::ImageBox(AbsoluteFloatRect borderBox, Style&& displayStyle, AbsoluteFloatRect replacedContentRect)
     38    : ReplacedBox(borderBox, WTFMove(displayStyle), { Flags::ImageBox }, replacedContentRect)
     39{
    4440}
    4541
    46 namespace Display {
     42void ImageBox::setImage(Image* image)
     43{
     44    m_image = image;
     45}
    4746
    48 // The root object which renders a display tree for a single document.
    49 class View {
    50     WTF_MAKE_ISO_ALLOCATED(View);
    51 public:
    52     explicit View(FrameView&);
    53     ~View();
    54    
    55     void prepareForDisplay();
    56     void flushLayers();
    57    
    58     void setIsInWindow(bool);
    59 
    60     Page* page() const;
    61     FrameView& frameView() const { return m_frameView; }
    62     Frame& frame() const;
    63 
    64     const Layout::LayoutState* layoutState() const;
    65 
    66 private:
    67     FrameView& m_frameView;
    68     LayerController m_layerController;
    69 };
     47String ImageBox::debugDescription() const
     48{
     49    TextStream stream;
     50    stream << "image box " << borderBoxFrame() << " (" << this << ") replaced content rect: " << replacedContentRect() << " image: " << m_image.get();
     51    return stream.release();
     52}
    7053
    7154} // namespace Display
  • trunk/Source/WebCore/display/css/DisplayImageBox.h

    r267508 r267509  
    2828#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    2929
    30 #include "DisplayLayerController.h"
    31 #include "DisplayRect.h"
    32 #include "LayoutUnits.h"
    33 #include <wtf/IsoMalloc.h>
     30#include "DisplayReplacedBox.h"
    3431
    3532namespace WebCore {
    3633
    37 class Frame;
    38 class FrameView;
    39 class Page;
    40 
    41 namespace Layout {
    42 class LayoutState;
    43 class LayoutTree;
    44 }
     34class Image;
    4535
    4636namespace Display {
    4737
    48 // The root object which renders a display tree for a single document.
    49 class View {
    50     WTF_MAKE_ISO_ALLOCATED(View);
     38class Style;
     39
     40class ImageBox : public ReplacedBox {
     41    WTF_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(ImageBox);
    5142public:
    52     explicit View(FrameView&);
    53     ~View();
     43    ImageBox(AbsoluteFloatRect borderBox, Style&&, AbsoluteFloatRect replacedContentRect);
    5444   
    55     void prepareForDisplay();
    56     void flushLayers();
    57    
    58     void setIsInWindow(bool);
    59 
    60     Page* page() const;
    61     FrameView& frameView() const { return m_frameView; }
    62     Frame& frame() const;
    63 
    64     const Layout::LayoutState* layoutState() const;
     45    Image* image() const { return m_image.get(); }
     46    void setImage(Image*);
    6547
    6648private:
    67     FrameView& m_frameView;
    68     LayerController m_layerController;
     49    String debugDescription() const final;
     50
     51    RefPtr<Image> m_image;
    6952};
    7053
     
    7255} // namespace WebCore
    7356
     57SPECIALIZE_TYPE_TRAITS_DISPLAY_BOX(ImageBox, isImageBox())
     58
    7459#endif // ENABLE(LAYOUT_FORMATTING_CONTEXT)
  • trunk/Source/WebCore/display/css/DisplayReplacedBox.cpp

    r267508 r267509  
    2424 */
    2525
    26 #pragma once
     26#include "config.h"
     27#include "DisplayReplacedBox.h"
    2728
    2829#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    2930
    30 #include "DisplayLayerController.h"
    31 #include "DisplayRect.h"
    32 #include "LayoutUnits.h"
    33 #include <wtf/IsoMalloc.h>
     31#include <wtf/IsoMallocInlines.h>
    3432
    3533namespace WebCore {
    36 
    37 class Frame;
    38 class FrameView;
    39 class Page;
    40 
    41 namespace Layout {
    42 class LayoutState;
    43 class LayoutTree;
    44 }
    45 
    4634namespace Display {
    4735
    48 // The root object which renders a display tree for a single document.
    49 class View {
    50     WTF_MAKE_ISO_ALLOCATED(View);
    51 public:
    52     explicit View(FrameView&);
    53     ~View();
    54    
    55     void prepareForDisplay();
    56     void flushLayers();
    57    
    58     void setIsInWindow(bool);
    59 
    60     Page* page() const;
    61     FrameView& frameView() const { return m_frameView; }
    62     Frame& frame() const;
    63 
    64     const Layout::LayoutState* layoutState() const;
    65 
    66 private:
    67     FrameView& m_frameView;
    68     LayerController m_layerController;
    69 };
     36ReplacedBox::ReplacedBox(AbsoluteFloatRect borderBox, Style&& displayStyle, OptionSet<Flags> flags, AbsoluteFloatRect replacedContentRect)
     37    : Box(borderBox, WTFMove(displayStyle), flags)
     38    , m_replacedContentRect(replacedContentRect)
     39{
     40}
    7041
    7142} // namespace Display
  • trunk/Source/WebCore/display/css/DisplayReplacedBox.h

    r267508 r267509  
    2828#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    2929
    30 #include "DisplayLayerController.h"
    31 #include "DisplayRect.h"
    32 #include "LayoutUnits.h"
    33 #include <wtf/IsoMalloc.h>
     30#include "DisplayBox.h"
    3431
    3532namespace WebCore {
    36 
    37 class Frame;
    38 class FrameView;
    39 class Page;
    40 
    41 namespace Layout {
    42 class LayoutState;
    43 class LayoutTree;
    44 }
    45 
    4633namespace Display {
    4734
    48 // The root object which renders a display tree for a single document.
    49 class View {
    50     WTF_MAKE_ISO_ALLOCATED(View);
     35class ReplacedBox : public Box {
     36    WTF_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(ReplacedBox);
    5137public:
    52     explicit View(FrameView&);
    53     ~View();
     38    ReplacedBox(AbsoluteFloatRect borderBox, Style&&, OptionSet<Flags>, AbsoluteFloatRect replacedContentRect);
    5439   
    55     void prepareForDisplay();
    56     void flushLayers();
    57    
    58     void setIsInWindow(bool);
    59 
    60     Page* page() const;
    61     FrameView& frameView() const { return m_frameView; }
    62     Frame& frame() const;
    63 
    64     const Layout::LayoutState* layoutState() const;
     40    AbsoluteFloatRect replacedContentRect() const { return m_replacedContentRect; }
    6541
    6642private:
    67     FrameView& m_frameView;
    68     LayerController m_layerController;
     43    AbsoluteFloatRect m_replacedContentRect;
    6944};
    7045
     
    7247} // namespace WebCore
    7348
     49SPECIALIZE_TYPE_TRAITS_DISPLAY_BOX(ReplacedBox, isReplacedBox())
     50
    7451#endif // ENABLE(LAYOUT_FORMATTING_CONTEXT)
  • trunk/Source/WebCore/display/css/DisplayStyle.cpp

    r267508 r267509  
    2525
    2626#include "config.h"
    27 #include "DisplayView.h"
     27#include "DisplayStyle.h"
    2828
    2929#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    3030
    31 #include "Frame.h"
    32 #include "FrameView.h"
    33 #include "FrameViewLayoutContext.h"
    34 #include "LayoutContext.h"
    35 #include "LayoutState.h"
    36 #include "Page.h"
     31#include "BorderData.h"
     32#include "RenderStyle.h"
    3733#include <wtf/IsoMallocInlines.h>
    3834
     
    4036namespace Display {
    4137
    42 WTF_MAKE_ISO_ALLOCATED_IMPL(View);
     38Style::Style(const RenderStyle& style)
     39{
     40    m_backgroundColor = style.visitedDependentColorWithColorFilter(CSSPropertyBackgroundColor);
    4341
    44 View::View(FrameView& frameView)
    45     : m_frameView(frameView)
    46     , m_layerController(*this)
    47 {
     42    const auto& borderData = style.border();
     43   
     44    auto borderValueWithResolvedColor = [&style](const BorderValue& value, CSSPropertyID colorPropertyID) {
     45        auto resolvedValue = value;
     46        resolvedValue.setColor(style.visitedDependentColorWithColorFilter(colorPropertyID));
     47        return resolvedValue;
     48    };
     49   
     50    m_border.left = borderValueWithResolvedColor(borderData.left(), CSSPropertyBorderLeftColor);
     51    m_border.right = borderValueWithResolvedColor(borderData.right(), CSSPropertyBorderRightColor);
     52    m_border.top = borderValueWithResolvedColor(borderData.top(), CSSPropertyBorderTopColor);
     53    m_border.bottom = borderValueWithResolvedColor(borderData.bottom(), CSSPropertyBorderBottomColor);
     54
     55    m_border.image = borderData.image();
     56
     57    if (!style.hasAutoUsedZIndex())
     58        m_zIndex = style.usedZIndex();
     59
     60    setIsPositioned(style.position() != PositionType::Static);
     61    setIsFloating(style.floating() != Float::No);
    4862}
    4963
    50 View::~View()
     64bool Style::hasBackground() const
    5165{
     66    return m_backgroundColor.isVisible() || hasBackgroundImage();
    5267}
    5368
    54 Frame& View::frame() const
     69bool Style::hasVisibleBorder() const
    5570{
    56     return m_frameView.frame();
    57 }
    58 
    59 Page* View::page() const
    60 {
    61     return m_frameView.frame().page();
    62 }
    63 
    64 const Layout::LayoutState* View::layoutState() const
    65 {
    66     return m_frameView.layoutContext().layoutFormattingState();
    67 }
    68 
    69 void View::prepareForDisplay()
    70 {
    71     auto* layoutState = this->layoutState();
    72     if (!layoutState)
    73         return;
    74 
    75     m_layerController.prepareForDisplay(*layoutState);
    76 }
    77 
    78 void View::flushLayers()
    79 {
    80     m_layerController.flushLayers();
    81 }
    82 
    83 void View::setIsInWindow(bool isInWindow)
    84 {
    85     m_layerController.setIsInWindow(isInWindow);
     71    bool haveImage = m_border.image.hasImage();
     72    return m_border.left.isVisible(!haveImage) || m_border.right.isVisible(!haveImage) || m_border.top.isVisible(!haveImage) || m_border.bottom.isVisible(!haveImage);
    8673}
    8774
  • trunk/Source/WebCore/layout/layouttree/LayoutIterator.h

    r259180 r267509  
    2828#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    2929
     30#include "LayoutInitialContainingBlock.h"
     31
    3032namespace WebCore {
    3133namespace Layout {
Note: See TracChangeset for help on using the changeset viewer.