Changeset 271133 in webkit
- Timestamp:
- Jan 4, 2021 10:13:04 AM (3 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r271131 r271133 1 2020-12-30 Simon Fraser <simon.fraser@apple.com> 2 3 [LFC Display] Give display boxes a back reference to the tree 4 https://bugs.webkit.org/show_bug.cgi?id=220205 5 6 Reviewed by Zalan Bujtas. 7 8 Display box code will need a back pointer to the display tree for things 9 like paint invalidation. Pass a Tree& to box constructors, which requires 10 that the Tree has been constructed before we make any boxes. 11 12 * display/DisplayTree.cpp: 13 (WebCore::Display::Tree::setRootStackingItem): 14 (WebCore::Display::Tree::Tree): Deleted. 15 * display/DisplayTree.h: 16 (WebCore::Display::Tree::view const): 17 (WebCore::Display::Tree::setView): 18 * display/DisplayTreeBuilder.cpp: 19 (WebCore::Display::TreeBuilder::TreeBuilder): 20 (WebCore::Display::TreeBuilder::build): 21 * display/DisplayTreeBuilder.h: 22 (WebCore::Display::TreeBuilder::tree const): 23 * display/css/DisplayBox.cpp: 24 (WebCore::Display::Box::Box): 25 * display/css/DisplayBox.h: 26 (WebCore::Display::Box::Box): 27 * display/css/DisplayBoxFactory.cpp: 28 (WebCore::Display::BoxFactory::BoxFactory): 29 (WebCore::Display::BoxFactory::displayBoxForRootBox const): 30 (WebCore::Display::BoxFactory::displayBoxForLayoutBox const): 31 (WebCore::Display::BoxFactory::displayBoxForTextRun const): 32 * display/css/DisplayBoxFactory.h: 33 * display/css/DisplayBoxModelBox.cpp: 34 (WebCore::Display::BoxModelBox::BoxModelBox): 35 * display/css/DisplayBoxModelBox.h: 36 (WebCore::Display::BoxModelBox::BoxModelBox): 37 * display/css/DisplayContainerBox.cpp: 38 (WebCore::Display::ContainerBox::ContainerBox): 39 * display/css/DisplayContainerBox.h: 40 * display/css/DisplayImageBox.cpp: 41 (WebCore::Display::ImageBox::ImageBox): 42 * display/css/DisplayImageBox.h: 43 * display/css/DisplayReplacedBox.cpp: 44 (WebCore::Display::ReplacedBox::ReplacedBox): 45 * display/css/DisplayReplacedBox.h: 46 * display/css/DisplayTextBox.cpp: 47 (WebCore::Display::TextBox::TextBox): 48 * display/css/DisplayTextBox.h: 49 1 50 2021-01-04 Jeff Miller <jeffm@apple.com> 2 51 -
trunk/Source/WebCore/display/DisplayTree.cpp
r270474 r271133 31 31 #include "DisplayContainerBox.h" 32 32 #include "DisplayStackingItem.h" 33 #include "DisplayView.h" 33 34 #include <wtf/IsoMallocInlines.h> 34 35 … … 36 37 namespace Display { 37 38 38 Tree::Tree(std::unique_ptr<StackingItem>&& rootStackingItem) 39 : m_rootStackingItem(WTFMove(rootStackingItem)) 39 Tree::Tree() = default; 40 Tree::~Tree() = default; 41 42 void Tree::setRootStackingItem(std::unique_ptr<StackingItem>&& rootItem) 40 43 { 41 ASSERT(m_rootStackingItem);44 m_rootStackingItem = WTFMove(rootItem); 42 45 } 43 44 Tree::~Tree() = default;45 46 46 47 const ContainerBox& Tree::rootBox() const -
trunk/Source/WebCore/display/DisplayTree.h
r270474 r271133 35 35 class ContainerBox; 36 36 class StackingItem; 37 class View; 37 38 38 39 class Tree { 39 40 WTF_MAKE_FAST_ALLOCATED(Tree); 41 friend class TreeBuilder; 40 42 public: 41 explicit Tree(std::unique_ptr<StackingItem>&&);43 Tree(); 42 44 ~Tree(); 45 46 View* view() const { return m_view; } 47 void setView(View* view) { m_view = view; } 43 48 44 49 const StackingItem& rootStackingItem() const { return *m_rootStackingItem; } 45 const ContainerBox& rootBox() const;50 const ContainerBox& rootBox() const; 46 51 47 52 private: 53 void setRootStackingItem(std::unique_ptr<StackingItem>&&); 54 48 55 std::unique_ptr<StackingItem> m_rootStackingItem; 56 View* m_view { nullptr }; 49 57 }; 50 58 -
trunk/Source/WebCore/display/DisplayTreeBuilder.cpp
r271109 r271133 110 110 111 111 TreeBuilder::TreeBuilder(float pixelSnappingFactor) 112 : m_boxFactory( pixelSnappingFactor)112 : m_boxFactory(*this, pixelSnappingFactor) 113 113 , m_stateStack(makeUnique<Vector<BuildingState>>()) 114 114 { … … 127 127 LOG_WITH_STREAM(FormattingContextLayout, stream << "Building display tree for:\n" << layoutTreeAsText(rootLayoutBox, &layoutState)); 128 128 #endif 129 130 ASSERT(!m_tree); 131 m_tree = makeUnique<Tree>(); 129 132 130 133 m_rootBackgroundPropgation = BoxFactory::determineRootBackgroundPropagation(rootLayoutBox); … … 145 148 LOG_WITH_STREAM(FormattingContextLayout, stream << "Display tree:\n" << displayTreeAsText(*rootStackingItem)); 146 149 #endif 147 return makeUnique<Tree>(WTFMove(rootStackingItem)); 150 m_tree->setRootStackingItem(WTFMove(rootStackingItem)); 151 return WTFMove(m_tree); 148 152 } 149 153 -
trunk/Source/WebCore/display/DisplayTreeBuilder.h
r271109 r271133 56 56 57 57 class TreeBuilder { 58 friend class BoxFactory; 58 59 public: 59 60 explicit TreeBuilder(float pixelSnappingFactor); … … 82 83 void didAppendNonContainerStackingItem(StackingItem&); 83 84 85 Tree& tree() const { return *m_tree; } 86 84 87 BuildingState& currentState(); 85 88 const PositioningContext& positioningContext(); … … 88 91 RootBackgroundPropagation m_rootBackgroundPropgation { RootBackgroundPropagation::None }; 89 92 93 std::unique_ptr<Tree> m_tree; 90 94 std::unique_ptr<Vector<BuildingState>> m_stateStack; 91 95 }; -
trunk/Source/WebCore/display/css/DisplayBox.cpp
r271123 r271133 29 29 #if ENABLE(LAYOUT_FORMATTING_CONTEXT) 30 30 31 #include "DisplayTree.h" 31 32 #include "FillLayer.h" 32 33 #include "ShadowData.h" … … 37 38 namespace Display { 38 39 39 Box::Box(AbsoluteFloatRect absoluteRect, Style&& displayStyle, OptionSet<TypeFlags> flags) 40 : m_absoluteBoxRect(absoluteRect) 40 Box::Box(Tree& tree, AbsoluteFloatRect absoluteRect, Style&& displayStyle, OptionSet<TypeFlags> flags) 41 : m_tree(tree) 42 , m_absoluteBoxRect(absoluteRect) 41 43 , m_style(WTFMove(displayStyle)) 42 44 , m_typeFlags(flags) 43 45 { 46 UNUSED_PARAM(m_tree); 44 47 } 45 48 -
trunk/Source/WebCore/display/css/DisplayBox.h
r271123 r271133 36 36 namespace Display { 37 37 38 class Tree; 39 38 40 // FIXME: Make this a strong type. 39 41 using AbsoluteFloatRect = FloatRect; … … 50 52 }; 51 53 52 Box( AbsoluteFloatRect, Style&&, OptionSet<TypeFlags> = { });54 Box(Tree&, AbsoluteFloatRect, Style&&, OptionSet<TypeFlags> = { }); 53 55 virtual ~Box(); 54 56 … … 76 78 virtual const char* boxName() const; 77 79 80 const Tree& m_tree; 78 81 AbsoluteFloatRect m_absoluteBoxRect; 79 82 Style m_style; -
trunk/Source/WebCore/display/css/DisplayBoxFactory.cpp
r271123 r271133 37 37 #include "DisplayImageBox.h" 38 38 #include "DisplayTextBox.h" 39 #include "DisplayTree.h" 40 #include "DisplayTreeBuilder.h" 39 41 #include "FloatPoint3D.h" 40 42 #include "InlineLineGeometry.h" … … 49 51 namespace Display { 50 52 51 BoxFactory::BoxFactory(float pixelSnappingFactor) 52 : m_pixelSnappingFactor(pixelSnappingFactor) 53 BoxFactory::BoxFactory(TreeBuilder& builder, float pixelSnappingFactor) 54 : m_treeBuilder(builder) 55 , m_pixelSnappingFactor(pixelSnappingFactor) 53 56 { 54 57 } … … 86 89 auto style = Style { rootLayoutBox.style(), styleForBackground }; 87 90 88 auto rootBox = makeUnique<ContainerBox>( snapRectToDevicePixels(borderBoxRect, m_pixelSnappingFactor), WTFMove(style));91 auto rootBox = makeUnique<ContainerBox>(m_treeBuilder.tree(), snapRectToDevicePixels(borderBoxRect, m_pixelSnappingFactor), WTFMove(style)); 89 92 // We pass rootBox as its own containingBlockBox here to allow it to be a reference everywhere else. 90 93 setupBoxModelBox(*rootBox, rootLayoutBox, geometry, { *rootBox, { 0, 0 } }, styleForBackground); … … 124 127 image = cachedImage->image(); 125 128 126 auto imageBox = makeUnique<ImageBox>( pixelSnappedBorderBoxRect, WTFMove(style), WTFMove(image));129 auto imageBox = makeUnique<ImageBox>(m_treeBuilder.tree(), pixelSnappedBorderBoxRect, WTFMove(style), WTFMove(image)); 127 130 setupBoxModelBox(*imageBox, layoutBox, geometry, containingBlockContext, styleForBackground); 128 131 return imageBox; … … 131 134 if (is<Layout::ContainerBox>(layoutBox)) { 132 135 // FIXME: The decision to make a ContainerBox should be made based on whether this Display::Box will have children. 133 auto containerBox = makeUnique<ContainerBox>( pixelSnappedBorderBoxRect, WTFMove(style));136 auto containerBox = makeUnique<ContainerBox>(m_treeBuilder.tree(), pixelSnappedBorderBoxRect, WTFMove(style)); 134 137 setupBoxModelBox(*containerBox, layoutBox, geometry, containingBlockContext, styleForBackground); 135 138 return containerBox; … … 141 144 flags.add(Box::TypeFlags::LineBreakBox); 142 145 143 return makeUnique<Box>( snapRectToDevicePixels(borderBoxRect, m_pixelSnappingFactor), WTFMove(style), flags);146 return makeUnique<Box>(m_treeBuilder.tree(), snapRectToDevicePixels(borderBoxRect, m_pixelSnappingFactor), WTFMove(style), flags); 144 147 } 145 148 … … 155 158 156 159 auto style = Style { run.layoutBox().style() }; 157 return makeUnique<TextBox>( snapRectToDevicePixels(runRect, m_pixelSnappingFactor), WTFMove(style), run);160 return makeUnique<TextBox>(m_treeBuilder.tree(), snapRectToDevicePixels(runRect, m_pixelSnappingFactor), WTFMove(style), run); 158 161 } 159 162 -
trunk/Source/WebCore/display/css/DisplayBoxFactory.h
r270474 r271133 53 53 class ContainerBox; 54 54 class Style; 55 class TreeBuilder; 55 56 56 57 enum class RootBackgroundPropagation : uint8_t { … … 66 67 class BoxFactory { 67 68 public: 68 explicit BoxFactory(float pixelSnappingFactor);69 69 BoxFactory(TreeBuilder&, float pixelSnappingFactor); 70 70 71 static RootBackgroundPropagation determineRootBackgroundPropagation(const Layout::ContainerBox& rootLayoutBox); 71 72 … … 92 93 static const Layout::Box* bodyBoxFromRootBox(const Layout::ContainerBox& rootLayoutBox); 93 94 95 TreeBuilder& m_treeBuilder; 94 96 float m_pixelSnappingFactor { 1 }; 95 97 }; -
trunk/Source/WebCore/display/css/DisplayBoxModelBox.cpp
r271123 r271133 39 39 namespace Display { 40 40 41 BoxModelBox::BoxModelBox( AbsoluteFloatRect borderBox, Style&& displayStyle, OptionSet<TypeFlags> flags)42 : Box( borderBox, WTFMove(displayStyle), flags | TypeFlags::BoxModelBox)41 BoxModelBox::BoxModelBox(Tree& tree, AbsoluteFloatRect borderBox, Style&& displayStyle, OptionSet<TypeFlags> flags) 42 : Box(tree, borderBox, WTFMove(displayStyle), flags | TypeFlags::BoxModelBox) 43 43 { 44 44 } -
trunk/Source/WebCore/display/css/DisplayBoxModelBox.h
r271123 r271133 44 44 friend class BoxFactory; 45 45 public: 46 BoxModelBox( AbsoluteFloatRect borderBox, Style&&, OptionSet<TypeFlags> = { });46 BoxModelBox(Tree&, AbsoluteFloatRect borderBox, Style&&, OptionSet<TypeFlags> = { }); 47 47 virtual ~BoxModelBox(); 48 48 -
trunk/Source/WebCore/display/css/DisplayContainerBox.cpp
r271123 r271133 36 36 namespace Display { 37 37 38 ContainerBox::ContainerBox( AbsoluteFloatRect borderBox, Style&& displayStyle)39 : BoxModelBox( borderBox, WTFMove(displayStyle), { TypeFlags::ContainerBox })38 ContainerBox::ContainerBox(Tree& tree, AbsoluteFloatRect borderBox, Style&& displayStyle) 39 : BoxModelBox(tree, borderBox, WTFMove(displayStyle), { TypeFlags::ContainerBox }) 40 40 { 41 41 } -
trunk/Source/WebCore/display/css/DisplayContainerBox.h
r271108 r271133 36 36 WTF_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(ContainerBox); 37 37 public: 38 ContainerBox( AbsoluteFloatRect borderBox, Style&&);38 ContainerBox(Tree&, AbsoluteFloatRect borderBox, Style&&); 39 39 40 40 const Box* firstChild() const { return m_firstChild.get(); } -
trunk/Source/WebCore/display/css/DisplayImageBox.cpp
r271123 r271133 35 35 namespace Display { 36 36 37 ImageBox::ImageBox( AbsoluteFloatRect borderBox, Style&& displayStyle, RefPtr<Image>&& image)38 : ReplacedBox( borderBox, WTFMove(displayStyle), { TypeFlags::ImageBox })37 ImageBox::ImageBox(Tree& tree, AbsoluteFloatRect borderBox, Style&& displayStyle, RefPtr<Image>&& image) 38 : ReplacedBox(tree, borderBox, WTFMove(displayStyle), { TypeFlags::ImageBox }) 39 39 , m_image(WTFMove(image)) 40 40 { -
trunk/Source/WebCore/display/css/DisplayImageBox.h
r271108 r271133 41 41 WTF_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(ImageBox); 42 42 public: 43 ImageBox( AbsoluteFloatRect borderBox, Style&&, RefPtr<Image>&&);43 ImageBox(Tree&, AbsoluteFloatRect borderBox, Style&&, RefPtr<Image>&&); 44 44 45 45 Image* image() const { return m_image.get(); } -
trunk/Source/WebCore/display/css/DisplayReplacedBox.cpp
r271123 r271133 34 34 namespace Display { 35 35 36 ReplacedBox::ReplacedBox( AbsoluteFloatRect borderBox, Style&& displayStyle, OptionSet<TypeFlags> flags)37 : BoxModelBox( borderBox, WTFMove(displayStyle), flags)36 ReplacedBox::ReplacedBox(Tree& tree, AbsoluteFloatRect borderBox, Style&& displayStyle, OptionSet<TypeFlags> flags) 37 : BoxModelBox(tree, borderBox, WTFMove(displayStyle), flags) 38 38 { 39 39 } -
trunk/Source/WebCore/display/css/DisplayReplacedBox.h
r271123 r271133 37 37 friend class BoxFactory; 38 38 public: 39 ReplacedBox( AbsoluteFloatRect borderBox, Style&&, OptionSet<TypeFlags>);39 ReplacedBox(Tree&, AbsoluteFloatRect borderBox, Style&&, OptionSet<TypeFlags>); 40 40 41 41 AbsoluteFloatRect replacedContentRect() const { return m_replacedContentRect; } -
trunk/Source/WebCore/display/css/DisplayTextBox.cpp
r271123 r271133 35 35 namespace Display { 36 36 37 TextBox::TextBox( AbsoluteFloatRect borderBox, Style&& displayStyle, const Layout::LineRun& lineRun)38 : Box( borderBox, WTFMove(displayStyle), { TypeFlags::TextBox })37 TextBox::TextBox(Tree& tree, AbsoluteFloatRect borderBox, Style&& displayStyle, const Layout::LineRun& lineRun) 38 : Box(tree, borderBox, WTFMove(displayStyle), { TypeFlags::TextBox }) 39 39 , m_expansion(lineRun.expansion()) 40 40 , m_text(lineRun.text().value()) -
trunk/Source/WebCore/display/css/DisplayTextBox.h
r271108 r271133 37 37 WTF_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(TextBox); 38 38 public: 39 40 TextBox(AbsoluteFloatRect borderBox, Style&&, const Layout::LineRun&); 39 TextBox(Tree&, AbsoluteFloatRect borderBox, Style&&, const Layout::LineRun&); 41 40 42 41 Layout::LineRun::Expansion expansion() const { return m_expansion; }
Note: See TracChangeset
for help on using the changeset viewer.