Diff
Modified: trunk/Source/WebCore/ChangeLog (268959 => 268960)
--- trunk/Source/WebCore/ChangeLog 2020-10-25 20:26:01 UTC (rev 268959)
+++ trunk/Source/WebCore/ChangeLog 2020-10-25 21:34:47 UTC (rev 268960)
@@ -1,5 +1,34 @@
2020-10-25 Simon Fraser <[email protected]>
+ [LFC Display] Move code for painting a single Display::Box into its own class
+ https://bugs.webkit.org/show_bug.cgi?id=218161
+
+ Reviewed by Antti Koivisto.
+
+ Move box-painting code into its own class, so that CSSPainter is about CSS stacking
+ context logic, and BoxPainter is about how to paint a single box.
+
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * display/css/DisplayBoxPainter.cpp: Copied from Source/WebCore/display/css/DisplayCSSPainter.cpp.
+ (WebCore::Display::BoxPainter::paintFillLayer):
+ (WebCore::Display::BoxPainter::paintBackgroundImages):
+ (WebCore::Display::BoxPainter::paintBoxDecorations):
+ (WebCore::Display::BoxPainter::paintBoxContent):
+ (WebCore::Display::BoxPainter::paintBox):
+ * display/css/DisplayBoxPainter.h: Copied from Source/WebCore/display/css/DisplayCSSPainter.h.
+ * display/css/DisplayCSSPainter.cpp:
+ (WebCore::Display::CSSPainter::recursivePaintDescendants):
+ (WebCore::Display::CSSPainter::paintStackingContext):
+ (WebCore::Display::CSSPainter::paintFillLayer): Deleted.
+ (WebCore::Display::CSSPainter::paintBackgroundImages): Deleted.
+ (WebCore::Display::CSSPainter::paintBoxDecorations): Deleted.
+ (WebCore::Display::CSSPainter::paintBoxContent): Deleted.
+ (WebCore::Display::CSSPainter::paintBox): Deleted.
+ * display/css/DisplayCSSPainter.h:
+
+2020-10-25 Simon Fraser <[email protected]>
+
[LFC Display] Move display box creation and geometry computation out of Display::TreeBuilder
https://bugs.webkit.org/show_bug.cgi?id=218160
Modified: trunk/Source/WebCore/Sources.txt (268959 => 268960)
--- trunk/Source/WebCore/Sources.txt 2020-10-25 20:26:01 UTC (rev 268959)
+++ trunk/Source/WebCore/Sources.txt 2020-10-25 21:34:47 UTC (rev 268960)
@@ -816,6 +816,7 @@
display/css/DisplayBoxDecorationData.cpp
display/css/DisplayBoxFactory.cpp
display/css/DisplayBoxModelBox.cpp
+display/css/DisplayBoxPainter.cpp
display/css/DisplayContainerBox.cpp
display/css/DisplayCSSPainter.cpp
display/css/DisplayFillLayerImageGeometry.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (268959 => 268960)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2020-10-25 20:26:01 UTC (rev 268959)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2020-10-25 21:34:47 UTC (rev 268960)
@@ -5990,6 +5990,8 @@
0F6383DC18615B29003E5DB5 /* ThreadedScrollingTree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadedScrollingTree.h; sourceTree = "<group>"; };
0F656FB525452E5400219F4C /* DisplayBoxFactory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayBoxFactory.h; sourceTree = "<group>"; };
0F656FB625452E5400219F4C /* DisplayBoxFactory.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayBoxFactory.cpp; sourceTree = "<group>"; };
+ 0F656FBC2545FD5600219F4C /* DisplayBoxPainter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayBoxPainter.h; sourceTree = "<group>"; };
+ 0F656FBD2545FD5700219F4C /* DisplayBoxPainter.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayBoxPainter.cpp; sourceTree = "<group>"; };
0F69F2B6228B98FF008D3565 /* LayerOverlapMap.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LayerOverlapMap.h; sourceTree = "<group>"; };
0F69F2B7228B98FF008D3565 /* LayerOverlapMap.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LayerOverlapMap.cpp; sourceTree = "<group>"; };
0F6A12BB1A00923700C6DE72 /* DebugPageOverlays.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DebugPageOverlays.cpp; sourceTree = "<group>"; };
@@ -17629,6 +17631,8 @@
0F656FB525452E5400219F4C /* DisplayBoxFactory.h */,
0F9472202534010900F153C8 /* DisplayBoxModelBox.cpp */,
0F94721E2534010900F153C8 /* DisplayBoxModelBox.h */,
+ 0F656FBD2545FD5700219F4C /* DisplayBoxPainter.cpp */,
+ 0F656FBC2545FD5600219F4C /* DisplayBoxPainter.h */,
0FFF1B74251BC6570098795A /* DisplayContainerBox.cpp */,
0FFF1B7A251BC6570098795A /* DisplayContainerBox.h */,
0FFF1B7D251BC6570098795A /* DisplayCSSPainter.cpp */,
Copied: trunk/Source/WebCore/display/css/DisplayBoxPainter.cpp (from rev 268959, trunk/Source/WebCore/display/css/DisplayCSSPainter.cpp) (0 => 268960)
--- trunk/Source/WebCore/display/css/DisplayBoxPainter.cpp (rev 0)
+++ trunk/Source/WebCore/display/css/DisplayBoxPainter.cpp 2020-10-25 21:34:47 UTC (rev 268960)
@@ -0,0 +1,249 @@
+/*
+ * 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 "DisplayBoxPainter.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "CachedImage.h"
+#include "Color.h"
+#include "DisplayBoxDecorationData.h"
+#include "DisplayContainerBox.h"
+#include "DisplayFillLayerImageGeometry.h"
+#include "DisplayImageBox.h"
+#include "DisplayStyle.h"
+#include "DisplayTextBox.h"
+#include "DisplayTree.h"
+#include "FillLayer.h"
+#include "GraphicsContext.h"
+#include "IntRect.h"
+#include "LayoutPoint.h"
+#include "TextRun.h"
+
+namespace WebCore {
+namespace Display {
+
+void BoxPainter::paintFillLayer(const BoxModelBox& box, const FillLayer& layer, const FillLayerImageGeometry& geometry, GraphicsContext& context)
+{
+ GraphicsContextStateSaver stateSaver(context, false);
+
+ auto clipRectForLayer = [](const BoxModelBox& box, const FillLayer& layer) {
+ switch (layer.clip()) {
+ case FillBox::Border:
+ return box.absoluteBorderBoxRect();
+ case FillBox::Padding:
+ return box.absolutePaddingBoxRect();
+ case FillBox::Content:
+ return box.absoluteContentBoxRect();
+ case FillBox::Text:
+ break;
+ }
+ return AbsoluteFloatRect();
+ };
+
+ switch (layer.clip()) {
+ case FillBox::Border:
+ case FillBox::Padding:
+ case FillBox::Content: {
+ stateSaver.save();
+ context.clip(clipRectForLayer(box, layer));
+ break;
+ }
+ case FillBox::Text:
+ break;
+ }
+
+ // FIXME: Handle background compositing modes.
+
+ auto* backgroundImage = layer.image();
+ CompositeOperator op = CompositeOperator::SourceOver;
+
+ if (geometry.destRect().isEmpty())
+ return;
+
+ auto image = backgroundImage->image(nullptr, geometry.tileSize());
+ if (!image)
+ return;
+
+ // FIXME: call image->updateFromSettings().
+
+ ImagePaintingOptions options = {
+ op == CompositeOperator::SourceOver ? layer.composite() : op,
+ layer.blendMode(),
+ DecodingMode::Synchronous,
+ ImageOrientation::FromImage,
+ InterpolationQuality::Default
+ };
+
+ context.drawTiledImage(*image, geometry.destRect(), toFloatPoint(geometry.relativePhase()), geometry.tileSize(), geometry.spaceSize(), options);
+}
+
+void BoxPainter::paintBackgroundImages(const BoxModelBox& box, GraphicsContext& context)
+{
+ const auto& style = box.style();
+
+ Vector<const FillLayer*, 8> layers;
+
+ for (auto* layer = style.backgroundLayers(); layer; layer = layer->next())
+ layers.append(layer);
+
+ auto* boxDecorationData = box.boxDecorationData();
+ ASSERT(boxDecorationData);
+
+ auto& layerGeometryList = boxDecorationData->backgroundImageGeometry();
+
+ for (int i = layers.size() - 1; i >=0; --i) {
+ const auto* layer = layers[i];
+ const auto& geometry = layerGeometryList[i];
+ paintFillLayer(box, *layer, geometry, context);
+ }
+}
+
+void BoxPainter::paintBoxDecorations(const BoxModelBox& box, GraphicsContext& context)
+{
+ // FIXME: Table decoration painting is special.
+
+ auto borderBoxRect = box.absoluteBorderBoxRect();
+
+ const auto& style = box.style();
+
+ // Background color
+ if (style.hasBackground()) {
+ context.fillRect(borderBoxRect, style.backgroundColor());
+ if (style.hasBackgroundImage())
+ paintBackgroundImages(box, context);
+ }
+
+ // 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 BoxPainter::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);
+
+ return;
+ }
+
+ if (is<TextBox>(box)) {
+ auto& textBox = downcast<TextBox>(box);
+
+ auto& style = box.style();
+ auto textRect = box.absoluteBoxRect();
+
+ context.setStrokeColor(style.color());
+ context.setFillColor(style.color());
+
+ // FIXME: Add non-baseline align painting
+ auto baseline = textRect.y() + style.fontMetrics().ascent();
+ auto expansion = textBox.expansion();
+
+ auto textRun = TextRun { textBox.text().content().substring(textBox.text().start(), textBox.text().length()), textRect.x(), expansion.horizontalExpansion, expansion.behavior };
+ textRun.setTabSize(!style.collapseWhiteSpace(), style.tabSize());
+ context.drawText(style.fontCascade(), textRun, { textRect.x(), baseline });
+
+ return;
+ }
+}
+
+void BoxPainter::paintBox(const Box& box, GraphicsContext& context, const IntRect& dirtyRect)
+{
+ auto absoluteRect = box.absoluteBoxRect();
+ // FIXME: Need to account for visual overflow.
+ if (!dirtyRect.intersects(enclosingIntRect(absoluteRect)))
+ return;
+
+ if (is<ImageBox>(box)) {
+ auto& imageBox = downcast<ImageBox>(box);
+
+ auto* image = imageBox.image();
+ auto imageRect = imageBox.replacedContentRect();
+
+ if (image)
+ context.drawImage(*image, imageRect);
+ }
+
+ if (is<BoxModelBox>(box))
+ paintBoxDecorations(downcast<BoxModelBox>(box), context);
+
+ paintBoxContent(box, context);
+}
+
+} // namespace Display
+} // namespace WebCore
+
+#endif // ENABLE(LAYOUT_FORMATTING_CONTEXT)
Copied: trunk/Source/WebCore/display/css/DisplayBoxPainter.h (from rev 268959, trunk/Source/WebCore/display/css/DisplayCSSPainter.h) (0 => 268960)
--- trunk/Source/WebCore/display/css/DisplayBoxPainter.h (rev 0)
+++ trunk/Source/WebCore/display/css/DisplayBoxPainter.h 2020-10-25 21:34:47 UTC (rev 268960)
@@ -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 "FloatSize.h"
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+class FillLayer;
+class GraphicsContext;
+class IntRect;
+
+namespace Display {
+
+class FillLayerImageGeometry;
+class Box;
+class BoxModelBox;
+
+class BoxPainter {
+public:
+ static void paintBox(const Box&, GraphicsContext&, const IntRect& dirtyRect);
+ static void paintBoxDecorations(const BoxModelBox&, GraphicsContext&);
+ static void paintBoxContent(const Box&, GraphicsContext&);
+
+private:
+ static void paintBackgroundImages(const BoxModelBox&, GraphicsContext&);
+ static void paintFillLayer(const BoxModelBox&, const FillLayer&, const FillLayerImageGeometry&, GraphicsContext&);
+};
+
+} // namespace Display
+} // namespace WebCore
+
+#endif // ENABLE(LAYOUT_FORMATTING_CONTEXT)
Modified: trunk/Source/WebCore/display/css/DisplayCSSPainter.cpp (268959 => 268960)
--- trunk/Source/WebCore/display/css/DisplayCSSPainter.cpp 2020-10-25 20:26:01 UTC (rev 268959)
+++ trunk/Source/WebCore/display/css/DisplayCSSPainter.cpp 2020-10-25 21:34:47 UTC (rev 268960)
@@ -28,222 +28,16 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
-#include "CachedImage.h"
-#include "Color.h"
-#include "DisplayBoxDecorationData.h"
+#include "DisplayBoxPainter.h"
#include "DisplayContainerBox.h"
-#include "DisplayFillLayerImageGeometry.h"
-#include "DisplayImageBox.h"
#include "DisplayStyle.h"
-#include "DisplayTextBox.h"
#include "DisplayTree.h"
-#include "FillLayer.h"
#include "GraphicsContext.h"
#include "IntRect.h"
-#include "LayoutPoint.h"
-#include "LayoutState.h"
-#include "TextRun.h"
namespace WebCore {
namespace Display {
-void CSSPainter::paintFillLayer(const BoxModelBox& box, const FillLayer& layer, const FillLayerImageGeometry& geometry, GraphicsContext& context)
-{
- GraphicsContextStateSaver stateSaver(context, false);
-
- auto clipRectForLayer = [](const BoxModelBox& box, const FillLayer& layer) {
- switch (layer.clip()) {
- case FillBox::Border:
- return box.absoluteBorderBoxRect();
- case FillBox::Padding:
- return box.absolutePaddingBoxRect();
- case FillBox::Content:
- return box.absoluteContentBoxRect();
- case FillBox::Text:
- break;
- }
- return AbsoluteFloatRect();
- };
-
- switch (layer.clip()) {
- case FillBox::Border:
- case FillBox::Padding:
- case FillBox::Content: {
- stateSaver.save();
- context.clip(clipRectForLayer(box, layer));
- break;
- }
- case FillBox::Text:
- break;
- }
-
- // FIXME: Handle background compositing modes.
-
- auto* backgroundImage = layer.image();
- CompositeOperator op = CompositeOperator::SourceOver;
-
- if (geometry.destRect().isEmpty())
- return;
-
- auto image = backgroundImage->image(nullptr, geometry.tileSize());
- if (!image)
- return;
-
- // FIXME: call image->updateFromSettings().
-
- ImagePaintingOptions options = {
- op == CompositeOperator::SourceOver ? layer.composite() : op,
- layer.blendMode(),
- DecodingMode::Synchronous,
- ImageOrientation::FromImage,
- InterpolationQuality::Default
- };
-
- context.drawTiledImage(*image, geometry.destRect(), toFloatPoint(geometry.relativePhase()), geometry.tileSize(), geometry.spaceSize(), options);
-}
-
-void CSSPainter::paintBackgroundImages(const BoxModelBox& box, GraphicsContext& context)
-{
- const auto& style = box.style();
-
- Vector<const FillLayer*, 8> layers;
-
- for (auto* layer = style.backgroundLayers(); layer; layer = layer->next())
- layers.append(layer);
-
- auto* boxDecorationData = box.boxDecorationData();
- ASSERT(boxDecorationData);
-
- auto& layerGeometryList = boxDecorationData->backgroundImageGeometry();
-
- for (int i = layers.size() - 1; i >=0; --i) {
- const auto* layer = layers[i];
- const auto& geometry = layerGeometryList[i];
- paintFillLayer(box, *layer, geometry, context);
- }
-}
-
-void CSSPainter::paintBoxDecorations(const BoxModelBox& box, GraphicsContext& context)
-{
- // FIXME: Table decoration painting is special.
-
- auto borderBoxRect = box.absoluteBorderBoxRect();
-
- const auto& style = box.style();
-
- // Background color
- if (style.hasBackground()) {
- context.fillRect(borderBoxRect, style.backgroundColor());
- if (style.hasBackgroundImage())
- paintBackgroundImages(box, context);
- }
-
- // 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);
-
- return;
- }
-
- if (is<TextBox>(box)) {
- auto& textBox = downcast<TextBox>(box);
-
- auto& style = box.style();
- auto textRect = box.absoluteBoxRect();
-
- context.setStrokeColor(style.color());
- context.setFillColor(style.color());
-
- // FIXME: Add non-baseline align painting
- auto baseline = textRect.y() + style.fontMetrics().ascent();
- auto expansion = textBox.expansion();
-
- auto textRun = TextRun { textBox.text().content().substring(textBox.text().start(), textBox.text().length()), textRect.x(), expansion.horizontalExpansion, expansion.behavior };
- textRun.setTabSize(!style.collapseWhiteSpace(), style.tabSize());
- context.drawText(style.fontCascade(), textRun, { textRect.x(), baseline });
-
- return;
- }
-}
-
-void CSSPainter::paintBox(const Box& box, GraphicsContext& context, const IntRect& dirtyRect)
-{
- auto absoluteRect = box.absoluteBoxRect();
- // FIXME: Need to account for visual overflow.
- if (!dirtyRect.intersects(enclosingIntRect(absoluteRect)))
- return;
-
- if (is<ImageBox>(box)) {
- auto& imageBox = downcast<ImageBox>(box);
-
- auto* image = imageBox.image();
- auto imageRect = imageBox.replacedContentRect();
-
- if (image)
- context.drawImage(*image, imageRect);
- }
-
- if (is<BoxModelBox>(box))
- paintBoxDecorations(downcast<BoxModelBox>(box), context);
-
- paintBoxContent(box, context);
-}
-
// FIXME: Make this an iterator.
void CSSPainter::recursivePaintDescendants(const ContainerBox& containerBox, GraphicsContext& context, PaintPhase paintPhase)
{
@@ -255,15 +49,15 @@
switch (paintPhase) {
case PaintPhase::BlockBackgrounds:
if (!box.style().isFloating() && !box.style().isPositioned() && is<BoxModelBox>(box))
- paintBoxDecorations(downcast<BoxModelBox>(box), context);
+ BoxPainter::paintBoxDecorations(downcast<BoxModelBox>(box), context);
break;
case PaintPhase::Floats:
if (box.style().isFloating() && !box.style().isPositioned() && is<BoxModelBox>(box))
- paintBoxDecorations(downcast<BoxModelBox>(box), context);
+ BoxPainter::paintBoxDecorations(downcast<BoxModelBox>(box), context);
break;
case PaintPhase::BlockForegrounds:
if (!box.style().isFloating() && !box.style().isPositioned())
- paintBoxContent(box, context);
+ BoxPainter::paintBoxContent(box, context);
};
if (is<ContainerBox>(box))
recursivePaintDescendants(downcast<ContainerBox>(box), context, paintPhase);
@@ -274,7 +68,7 @@
{
UNUSED_PARAM(dirtyRect);
- paintBoxDecorations(contextRoot, context);
+ BoxPainter::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:
@@ -325,10 +119,10 @@
if (box->style().isStackingContext())
paintStackingContext(*box, context, dirtyRect);
else if (is<ContainerBox>(*box)) {
- paintBoxDecorations(*box, context);
+ BoxPainter::paintBoxDecorations(*box, context);
paintDescendants(downcast<ContainerBox>(*box));
} else
- paintBox(*box, context, dirtyRect);
+ BoxPainter::paintBox(*box, context, dirtyRect);
}
}
}
Modified: trunk/Source/WebCore/display/css/DisplayCSSPainter.h (268959 => 268960)
--- trunk/Source/WebCore/display/css/DisplayCSSPainter.h 2020-10-25 20:26:01 UTC (rev 268959)
+++ trunk/Source/WebCore/display/css/DisplayCSSPainter.h 2020-10-25 21:34:47 UTC (rev 268960)
@@ -47,17 +47,9 @@
class CSSPainter {
public:
static void paintStackingContext(const BoxModelBox&, 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 BoxModelBox&, GraphicsContext&);
- static void paintBackgroundImages(const BoxModelBox&, GraphicsContext&);
- static void paintFillLayer(const BoxModelBox&, const FillLayer&, const FillLayerImageGeometry&, GraphicsContext&);
- static void paintBoxContent(const Box&, GraphicsContext&);
-
enum class PaintPhase {
BlockBackgrounds,
Floats,