WebKit Bugzilla
Attachment 345808 Details for
Bug 187002
: Templatize DisplayListItems and use std::tuple to store the arguments
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-187002-20180725182811.patch (text/plain), 166.57 KB, created by
Said Abou-Hallawa
on 2018-07-25 18:28:12 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Said Abou-Hallawa
Created:
2018-07-25 18:28:12 PDT
Size:
166.57 KB
patch
obsolete
>Index: Source/WebCore/ChangeLog >=================================================================== >--- Source/WebCore/ChangeLog (revision 234224) >+++ Source/WebCore/ChangeLog (working copy) >@@ -1,3 +1,375 @@ >+2018-07-25 Said Abou-Hallawa <sabouhallawa@apple.com> >+ >+ Templatize DisplayListItems and use std::tuple to store the arguments >+ https://bugs.webkit.org/show_bug.cgi?id=187002 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ DisplayListItems are simple objects which represent graphics commands and >+ their arguments. The arguments are stored while recording the DisplayList >+ and used when replaying it back. In fact, we do not care much about knowing >+ these arguments except when debugging the DisplayList. So a mechanical way >+ to store the arguments and passing them to GraphicsContext should be sufficient. >+ This will make adding a new DisplayListItem easier and in makes the code >+ a lot shorter. >+ >+ This patch templatizes the DisplayListItems classes and uses std::tuple to >+ store the arguments. The GraphicsContext function is passed as an argument >+ to the template along with the types of the std::tuple items. The class >+ hierarchy is a little bit different from the original one: >+ >+ -- Item: This is the base class and this is what DisplayList stores. >+ -- GeomtryItem: It is derived from Item and the only difference between >+ it and Item is it knows the extent of the Item. >+ -- GraphicsApplier: It's a template class which takes a pointer to a >+ GraphicsContext function, set of arguments' types. Its constructor saves >+ the arguments in std::tuple. Its apply method calls the GraphicsContext >+ function by passing the arguments it stores. >+ -- SettingItem: It is derived from Item and GraphicsApplier. >+ -- DrawingItem: It is derived from GeomtryItem and GraphicsApplier. >+ >+ Notes and some drawbacks of this patch are: >+ -- The DisplayListItems appliers have be methods of GraphicsContext. >+ -- The operator << has to be defined for all the arguments' types. >+ -- When an arguments is a RefCounted and the GraphicsContex function takes >+ a raw pointer or reference to the object itself, the GraphicsApplier can >+ store a Ref or a RefPtr to the object. The implicit casting of RefPtr and >+ Ref will do the magic when the arguments are passed to GraphicsContext. >+ >+ * platform/graphics/Font.h: >+ (WebCore::operator<<): >+ * platform/graphics/GlyphBuffer.h: >+ (WebCore::operator<<): >+ * platform/graphics/Gradient.h: >+ (WebCore::operator<<): >+ * platform/graphics/GraphicsContext.cpp: >+ (WebCore::GraphicsContext::applyStateChange): >+ * platform/graphics/GraphicsContext.h: >+ (WebCore::operator<<): >+ * platform/graphics/GraphicsContextImpl.h: >+ * platform/graphics/cairo/GraphicsContextCairo.cpp: >+ (WebCore::GraphicsContext::drawLinesForText): >+ * platform/graphics/cairo/GraphicsContextImplCairo.cpp: >+ (WebCore::GraphicsContextImplCairo::drawLinesForText): >+ (WebCore::GraphicsContextImplCairo::drawPath): Deleted. >+ * platform/graphics/cairo/GraphicsContextImplCairo.h: >+ * platform/graphics/cg/GraphicsContextCG.cpp: >+ (WebCore::GraphicsContext::drawLinesForText): >+ * platform/graphics/displaylists/DisplayList.cpp: >+ (WebCore::DisplayList::DisplayList::sizeInBytes const): >+ * platform/graphics/displaylists/DisplayList.h: >+ * platform/graphics/displaylists/DisplayListItems.cpp: >+ (WebCore::DisplayList::itemsDescriptors): >+ (WebCore::DisplayList::itemDescriptor): >+ (WebCore::DisplayList::Item::name const): >+ (WebCore::DisplayList::Item::argumentName const): >+ (WebCore::DisplayList::Item::description const): Deleted. >+ (WebCore::DisplayList::Item::sizeInBytes): Deleted. >+ (WebCore::DisplayList::operator<<): Deleted. >+ (WebCore::DisplayList::Save::apply const): Deleted. >+ (WebCore::DisplayList::Restore::apply const): Deleted. >+ (WebCore::DisplayList::Translate::apply const): Deleted. >+ (WebCore::DisplayList::Rotate::apply const): Deleted. >+ (WebCore::DisplayList::Scale::apply const): Deleted. >+ (WebCore::DisplayList::ConcatenateCTM::ConcatenateCTM): Deleted. >+ (WebCore::DisplayList::ConcatenateCTM::apply const): Deleted. >+ (WebCore::DisplayList::SetState::apply const): Deleted. >+ (WebCore::DisplayList::SetState::accumulate): Deleted. >+ (WebCore::DisplayList::SetLineCap::apply const): Deleted. >+ (WebCore::DisplayList::SetLineDash::apply const): Deleted. >+ (WebCore::DisplayList::SetLineJoin::apply const): Deleted. >+ (WebCore::DisplayList::SetMiterLimit::apply const): Deleted. >+ (WebCore::DisplayList::ClearShadow::apply const): Deleted. >+ (WebCore::DisplayList::Clip::apply const): Deleted. >+ (WebCore::DisplayList::ClipOut::apply const): Deleted. >+ (WebCore::DisplayList::ClipOutToPath::apply const): Deleted. >+ (WebCore::DisplayList::ClipPath::apply const): Deleted. >+ (WebCore::DisplayList::DrawGlyphs::DrawGlyphs): Deleted. >+ (WebCore::DisplayList::DrawGlyphs::generateGlyphBuffer const): Deleted. >+ (WebCore::DisplayList::DrawGlyphs::apply const): Deleted. >+ (WebCore::DisplayList::DrawGlyphs::computeBounds): Deleted. >+ (WebCore::DisplayList::DrawGlyphs::localBounds const): Deleted. >+ (WebCore::DisplayList::DrawImage::DrawImage): Deleted. >+ (WebCore::DisplayList::DrawImage::apply const): Deleted. >+ (WebCore::DisplayList::DrawTiledImage::DrawTiledImage): Deleted. >+ (WebCore::DisplayList::DrawTiledImage::apply const): Deleted. >+ (WebCore::DisplayList::DrawTiledScaledImage::DrawTiledScaledImage): Deleted. >+ (WebCore::DisplayList::DrawTiledScaledImage::apply const): Deleted. >+ (WebCore::DisplayList::DrawNativeImage::DrawNativeImage): Deleted. >+ (WebCore::DisplayList::DrawNativeImage::apply const): Deleted. >+ (WebCore::DisplayList::DrawPattern::DrawPattern): Deleted. >+ (WebCore::DisplayList::DrawPattern::apply const): Deleted. >+ (WebCore::DisplayList::DrawRect::apply const): Deleted. >+ (WebCore::DisplayList::DrawLine::localBounds const): Deleted. >+ (WebCore::DisplayList::DrawLine::apply const): Deleted. >+ (WebCore::DisplayList::DrawLinesForText::apply const): Deleted. >+ (WebCore::DisplayList::DrawLinesForText::localBounds const): Deleted. >+ (WebCore::DisplayList::DrawLineForDocumentMarker::apply const): Deleted. >+ (WebCore::DisplayList::DrawLineForDocumentMarker::localBounds const): Deleted. >+ (WebCore::DisplayList::DrawEllipse::apply const): Deleted. >+ (WebCore::DisplayList::DrawPath::apply const): Deleted. >+ (WebCore::DisplayList::DrawFocusRingPath::apply const): Deleted. >+ (WebCore::DisplayList::DrawFocusRingPath::localBounds const): Deleted. >+ (WebCore::DisplayList::DrawFocusRingRects::apply const): Deleted. >+ (WebCore::DisplayList::DrawFocusRingRects::localBounds const): Deleted. >+ (WebCore::DisplayList::FillRect::apply const): Deleted. >+ (WebCore::DisplayList::FillRectWithColor::apply const): Deleted. >+ (WebCore::DisplayList::FillRectWithGradient::apply const): Deleted. >+ (WebCore::DisplayList::FillCompositedRect::apply const): Deleted. >+ (WebCore::DisplayList::FillRoundedRect::apply const): Deleted. >+ (WebCore::DisplayList::FillRectWithRoundedHole::apply const): Deleted. >+ (WebCore::DisplayList::FillPath::apply const): Deleted. >+ (WebCore::DisplayList::FillEllipse::apply const): Deleted. >+ (WebCore::DisplayList::StrokeRect::localBounds const): Deleted. >+ (WebCore::DisplayList::StrokeRect::apply const): Deleted. >+ (WebCore::DisplayList::StrokePath::localBounds const): Deleted. >+ (WebCore::DisplayList::StrokePath::apply const): Deleted. >+ (WebCore::DisplayList::StrokeEllipse::localBounds const): Deleted. >+ (WebCore::DisplayList::StrokeEllipse::apply const): Deleted. >+ (WebCore::DisplayList::ClearRect::apply const): Deleted. >+ (WebCore::DisplayList::BeginTransparencyLayer::apply const): Deleted. >+ (WebCore::DisplayList::EndTransparencyLayer::apply const): Deleted. >+ (WebCore::DisplayList::ApplyStrokePattern::apply const): Deleted. >+ (WebCore::DisplayList::ApplyFillPattern::apply const): Deleted. >+ (WebCore::DisplayList::ApplyDeviceScaleFactor::apply const): Deleted. >+ * platform/graphics/displaylists/DisplayListItems.h: >+ (WebCore::DisplayList::Item::isGeometryItem const): >+ (WebCore::DisplayList::Item::dump const): >+ (WebCore::DisplayList::Item::type const): >+ (WebCore::DisplayList::Item::Item): >+ (WebCore::DisplayList::GeometryItem::setExtent): >+ (WebCore::DisplayList::GeometryItem::extent const): >+ (WebCore::DisplayList::GeometryItem::localBounds const): >+ (WebCore::DisplayList::GeometryItem::GeometryItem): >+ (WebCore::DisplayList::GraphicsApplier::GraphicsApplier): >+ (WebCore::DisplayList::GraphicsApplier::argument const): >+ (WebCore::DisplayList::GraphicsApplier::apply const): >+ (WebCore::DisplayList::GraphicsApplier::iterateOverArguments const): >+ (WebCore::DisplayList::SettingItem::create): >+ (WebCore::DisplayList::SettingItem::SettingItem): >+ (WebCore::DisplayList::DrawingItem::create): >+ (WebCore::DisplayList::DrawingItem::DrawingItem): >+ (WebCore::DisplayList::Save::restoreIndex const): >+ (WebCore::DisplayList::Save::setRestoreIndex): >+ (WebCore::DisplayList::SetState::state const): >+ (WebCore::DisplayList::DrawGlyphs::create): >+ (WebCore::DisplayList::DrawGlyphs::subGlyphBuffer): >+ (WebCore::DisplayList::operator<<): >+ (WebCore::DisplayList::Item::isDrawingItem const): Deleted. >+ (WebCore::DisplayList::Item::isStateItem const): Deleted. >+ (WebCore::DisplayList::Item::isStateItemType): Deleted. >+ (WebCore::DisplayList::DrawingItem::setExtent): Deleted. >+ (WebCore::DisplayList::DrawingItem::extent const): Deleted. >+ (WebCore::DisplayList::DrawingItem::extentKnown const): Deleted. >+ (WebCore::DisplayList::DrawingItem::localBounds const): Deleted. >+ (WebCore::DisplayList::Save::create): Deleted. >+ (WebCore::DisplayList::Save::Save): Deleted. >+ (WebCore::DisplayList::Restore::create): Deleted. >+ (WebCore::DisplayList::Restore::Restore): Deleted. >+ (WebCore::DisplayList::Translate::create): Deleted. >+ (WebCore::DisplayList::Translate::x const): Deleted. >+ (WebCore::DisplayList::Translate::y const): Deleted. >+ (WebCore::DisplayList::Translate::Translate): Deleted. >+ (WebCore::DisplayList::Rotate::create): Deleted. >+ (WebCore::DisplayList::Rotate::angle const): Deleted. >+ (WebCore::DisplayList::Rotate::Rotate): Deleted. >+ (WebCore::DisplayList::Scale::create): Deleted. >+ (WebCore::DisplayList::Scale::amount const): Deleted. >+ (WebCore::DisplayList::Scale::Scale): Deleted. >+ (WebCore::DisplayList::ConcatenateCTM::create): Deleted. >+ (WebCore::DisplayList::ConcatenateCTM::transform const): Deleted. >+ (WebCore::DisplayList::SetState::create): Deleted. >+ (WebCore::DisplayList::SetState::SetState): Deleted. >+ (WebCore::DisplayList::SetLineCap::create): Deleted. >+ (WebCore::DisplayList::SetLineCap::lineCap const): Deleted. >+ (WebCore::DisplayList::SetLineCap::SetLineCap): Deleted. >+ (WebCore::DisplayList::SetLineDash::create): Deleted. >+ (WebCore::DisplayList::SetLineDash::dashArray const): Deleted. >+ (WebCore::DisplayList::SetLineDash::dashOffset const): Deleted. >+ (WebCore::DisplayList::SetLineDash::SetLineDash): Deleted. >+ (WebCore::DisplayList::SetLineJoin::create): Deleted. >+ (WebCore::DisplayList::SetLineJoin::lineJoin const): Deleted. >+ (WebCore::DisplayList::SetLineJoin::SetLineJoin): Deleted. >+ (WebCore::DisplayList::SetMiterLimit::create): Deleted. >+ (WebCore::DisplayList::SetMiterLimit::miterLimit const): Deleted. >+ (WebCore::DisplayList::SetMiterLimit::SetMiterLimit): Deleted. >+ (WebCore::DisplayList::ClearShadow::create): Deleted. >+ (WebCore::DisplayList::ClearShadow::ClearShadow): Deleted. >+ (WebCore::DisplayList::Clip::create): Deleted. >+ (WebCore::DisplayList::Clip::rect const): Deleted. >+ (WebCore::DisplayList::Clip::Clip): Deleted. >+ (WebCore::DisplayList::ClipOut::create): Deleted. >+ (WebCore::DisplayList::ClipOut::rect const): Deleted. >+ (WebCore::DisplayList::ClipOut::ClipOut): Deleted. >+ (WebCore::DisplayList::ClipOutToPath::create): Deleted. >+ (WebCore::DisplayList::ClipOutToPath::path const): Deleted. >+ (WebCore::DisplayList::ClipOutToPath::ClipOutToPath): Deleted. >+ (WebCore::DisplayList::ClipPath::create): Deleted. >+ (WebCore::DisplayList::ClipPath::path const): Deleted. >+ (WebCore::DisplayList::ClipPath::windRule const): Deleted. >+ (WebCore::DisplayList::ClipPath::ClipPath): Deleted. >+ (WebCore::DisplayList::DrawGlyphs::blockLocation const): Deleted. >+ (WebCore::DisplayList::DrawGlyphs::setBlockLocation): Deleted. >+ (WebCore::DisplayList::DrawGlyphs::localAnchor const): Deleted. >+ (WebCore::DisplayList::DrawGlyphs::anchorPoint const): Deleted. >+ (WebCore::DisplayList::DrawGlyphs::glyphs const): Deleted. >+ (WebCore::DisplayList::DrawImage::create): Deleted. >+ (WebCore::DisplayList::DrawImage::image const): Deleted. >+ (WebCore::DisplayList::DrawImage::source const): Deleted. >+ (WebCore::DisplayList::DrawImage::destination const): Deleted. >+ (WebCore::DisplayList::DrawTiledImage::create): Deleted. >+ (WebCore::DisplayList::DrawTiledImage::image const): Deleted. >+ (WebCore::DisplayList::DrawTiledImage::source const): Deleted. >+ (WebCore::DisplayList::DrawTiledImage::destination const): Deleted. >+ (WebCore::DisplayList::DrawTiledImage::tileSize const): Deleted. >+ (WebCore::DisplayList::DrawTiledImage::spacing const): Deleted. >+ (WebCore::DisplayList::DrawTiledScaledImage::create): Deleted. >+ (WebCore::DisplayList::DrawTiledScaledImage::image const): Deleted. >+ (WebCore::DisplayList::DrawTiledScaledImage::source const): Deleted. >+ (WebCore::DisplayList::DrawTiledScaledImage::destination const): Deleted. >+ (WebCore::DisplayList::DrawNativeImage::create): Deleted. >+ (WebCore::DisplayList::DrawNativeImage::source const): Deleted. >+ (WebCore::DisplayList::DrawNativeImage::destination const): Deleted. >+ (WebCore::DisplayList::DrawPattern::create): Deleted. >+ (WebCore::DisplayList::DrawPattern::image const): Deleted. >+ (WebCore::DisplayList::DrawPattern::patternTransform const): Deleted. >+ (WebCore::DisplayList::DrawPattern::tileRect const): Deleted. >+ (WebCore::DisplayList::DrawPattern::destRect const): Deleted. >+ (WebCore::DisplayList::DrawPattern::phase const): Deleted. >+ (WebCore::DisplayList::DrawPattern::spacing const): Deleted. >+ (WebCore::DisplayList::BeginTransparencyLayer::create): Deleted. >+ (WebCore::DisplayList::BeginTransparencyLayer::opacity const): Deleted. >+ (WebCore::DisplayList::BeginTransparencyLayer::BeginTransparencyLayer): Deleted. >+ (WebCore::DisplayList::EndTransparencyLayer::create): Deleted. >+ (WebCore::DisplayList::EndTransparencyLayer::EndTransparencyLayer): Deleted. >+ (WebCore::DisplayList::DrawRect::create): Deleted. >+ (WebCore::DisplayList::DrawRect::rect const): Deleted. >+ (WebCore::DisplayList::DrawRect::borderThickness const): Deleted. >+ (WebCore::DisplayList::DrawRect::DrawRect): Deleted. >+ (WebCore::DisplayList::DrawLine::create): Deleted. >+ (WebCore::DisplayList::DrawLine::point1 const): Deleted. >+ (WebCore::DisplayList::DrawLine::point2 const): Deleted. >+ (WebCore::DisplayList::DrawLine::DrawLine): Deleted. >+ (WebCore::DisplayList::DrawLinesForText::create): Deleted. >+ (WebCore::DisplayList::DrawLinesForText::setBlockLocation): Deleted. >+ (WebCore::DisplayList::DrawLinesForText::blockLocation const): Deleted. >+ (WebCore::DisplayList::DrawLinesForText::localAnchor const): Deleted. >+ (WebCore::DisplayList::DrawLinesForText::point const): Deleted. >+ (WebCore::DisplayList::DrawLinesForText::widths const): Deleted. >+ (WebCore::DisplayList::DrawLinesForText::isPrinting const): Deleted. >+ (WebCore::DisplayList::DrawLinesForText::doubleLines const): Deleted. >+ (WebCore::DisplayList::DrawLinesForText::DrawLinesForText): Deleted. >+ (WebCore::DisplayList::DrawLineForDocumentMarker::create): Deleted. >+ (WebCore::DisplayList::DrawLineForDocumentMarker::point const): Deleted. >+ (WebCore::DisplayList::DrawLineForDocumentMarker::width const): Deleted. >+ (WebCore::DisplayList::DrawLineForDocumentMarker::DrawLineForDocumentMarker): Deleted. >+ (WebCore::DisplayList::DrawEllipse::create): Deleted. >+ (WebCore::DisplayList::DrawEllipse::rect const): Deleted. >+ (WebCore::DisplayList::DrawEllipse::DrawEllipse): Deleted. >+ (WebCore::DisplayList::DrawPath::create): Deleted. >+ (WebCore::DisplayList::DrawPath::path const): Deleted. >+ (WebCore::DisplayList::DrawPath::DrawPath): Deleted. >+ (WebCore::DisplayList::DrawFocusRingPath::create): Deleted. >+ (WebCore::DisplayList::DrawFocusRingPath::path const): Deleted. >+ (WebCore::DisplayList::DrawFocusRingPath::width const): Deleted. >+ (WebCore::DisplayList::DrawFocusRingPath::offset const): Deleted. >+ (WebCore::DisplayList::DrawFocusRingPath::color const): Deleted. >+ (WebCore::DisplayList::DrawFocusRingPath::DrawFocusRingPath): Deleted. >+ (WebCore::DisplayList::DrawFocusRingRects::create): Deleted. >+ (WebCore::DisplayList::DrawFocusRingRects::rects const): Deleted. >+ (WebCore::DisplayList::DrawFocusRingRects::width const): Deleted. >+ (WebCore::DisplayList::DrawFocusRingRects::offset const): Deleted. >+ (WebCore::DisplayList::DrawFocusRingRects::color const): Deleted. >+ (WebCore::DisplayList::DrawFocusRingRects::DrawFocusRingRects): Deleted. >+ (WebCore::DisplayList::FillRect::create): Deleted. >+ (WebCore::DisplayList::FillRect::rect const): Deleted. >+ (WebCore::DisplayList::FillRect::FillRect): Deleted. >+ (WebCore::DisplayList::FillRectWithColor::create): Deleted. >+ (WebCore::DisplayList::FillRectWithColor::rect const): Deleted. >+ (WebCore::DisplayList::FillRectWithColor::color const): Deleted. >+ (WebCore::DisplayList::FillRectWithColor::FillRectWithColor): Deleted. >+ (WebCore::DisplayList::FillRectWithGradient::create): Deleted. >+ (WebCore::DisplayList::FillRectWithGradient::rect const): Deleted. >+ (WebCore::DisplayList::FillRectWithGradient::FillRectWithGradient): Deleted. >+ (WebCore::DisplayList::FillCompositedRect::create): Deleted. >+ (WebCore::DisplayList::FillCompositedRect::rect const): Deleted. >+ (WebCore::DisplayList::FillCompositedRect::color const): Deleted. >+ (WebCore::DisplayList::FillCompositedRect::compositeOperator const): Deleted. >+ (WebCore::DisplayList::FillCompositedRect::blendMode const): Deleted. >+ (WebCore::DisplayList::FillCompositedRect::FillCompositedRect): Deleted. >+ (WebCore::DisplayList::FillRoundedRect::create): Deleted. >+ (WebCore::DisplayList::FillRoundedRect::roundedRect const): Deleted. >+ (WebCore::DisplayList::FillRoundedRect::color const): Deleted. >+ (WebCore::DisplayList::FillRoundedRect::blendMode const): Deleted. >+ (WebCore::DisplayList::FillRoundedRect::FillRoundedRect): Deleted. >+ (WebCore::DisplayList::FillRectWithRoundedHole::create): Deleted. >+ (WebCore::DisplayList::FillRectWithRoundedHole::rect const): Deleted. >+ (WebCore::DisplayList::FillRectWithRoundedHole::roundedHoleRect const): Deleted. >+ (WebCore::DisplayList::FillRectWithRoundedHole::color const): Deleted. >+ (WebCore::DisplayList::FillRectWithRoundedHole::FillRectWithRoundedHole): Deleted. >+ (WebCore::DisplayList::FillPath::create): Deleted. >+ (WebCore::DisplayList::FillPath::path const): Deleted. >+ (WebCore::DisplayList::FillPath::FillPath): Deleted. >+ (WebCore::DisplayList::FillEllipse::create): Deleted. >+ (WebCore::DisplayList::FillEllipse::rect const): Deleted. >+ (WebCore::DisplayList::FillEllipse::FillEllipse): Deleted. >+ (WebCore::DisplayList::StrokeRect::create): Deleted. >+ (WebCore::DisplayList::StrokeRect::rect const): Deleted. >+ (WebCore::DisplayList::StrokeRect::lineWidth const): Deleted. >+ (WebCore::DisplayList::StrokeRect::StrokeRect): Deleted. >+ (WebCore::DisplayList::StrokePath::create): Deleted. >+ (WebCore::DisplayList::StrokePath::path const): Deleted. >+ (WebCore::DisplayList::StrokePath::StrokePath): Deleted. >+ (WebCore::DisplayList::StrokeEllipse::create): Deleted. >+ (WebCore::DisplayList::StrokeEllipse::rect const): Deleted. >+ (WebCore::DisplayList::StrokeEllipse::StrokeEllipse): Deleted. >+ (WebCore::DisplayList::ClearRect::create): Deleted. >+ (WebCore::DisplayList::ClearRect::rect const): Deleted. >+ (WebCore::DisplayList::ClearRect::ClearRect): Deleted. >+ (WebCore::DisplayList::ApplyStrokePattern::create): Deleted. >+ (WebCore::DisplayList::ApplyStrokePattern::ApplyStrokePattern): Deleted. >+ (WebCore::DisplayList::ApplyFillPattern::create): Deleted. >+ (WebCore::DisplayList::ApplyFillPattern::ApplyFillPattern): Deleted. >+ (WebCore::DisplayList::ApplyDeviceScaleFactor::create): Deleted. >+ (WebCore::DisplayList::ApplyDeviceScaleFactor::scaleFactor const): Deleted. >+ (WebCore::DisplayList::ApplyDeviceScaleFactor::ApplyDeviceScaleFactor): Deleted. >+ * platform/graphics/displaylists/DisplayListRecorder.cpp: >+ (WebCore::DisplayList::Recorder::willAppendItem): >+ (WebCore::DisplayList::Recorder::drawGlyphs): >+ (WebCore::DisplayList::Recorder::drawImage): >+ (WebCore::DisplayList::Recorder::drawTiledImage): >+ (WebCore::DisplayList::Recorder::drawNativeImage): >+ (WebCore::DisplayList::Recorder::drawPattern): >+ (WebCore::DisplayList::Recorder::beginTransparencyLayer): >+ (WebCore::DisplayList::Recorder::drawRect): >+ (WebCore::DisplayList::Recorder::drawLine): >+ (WebCore::DisplayList::Recorder::drawLinesForText): >+ (WebCore::DisplayList::Recorder::drawLineForDocumentMarker): >+ (WebCore::DisplayList::Recorder::drawEllipse): >+ (WebCore::DisplayList::Recorder::drawPath): >+ (WebCore::DisplayList::Recorder::drawFocusRing): >+ (WebCore::DisplayList::Recorder::fillRect): >+ (WebCore::DisplayList::Recorder::fillRoundedRect): >+ (WebCore::DisplayList::Recorder::fillRectWithRoundedHole): >+ (WebCore::DisplayList::Recorder::fillPath): >+ (WebCore::DisplayList::Recorder::fillEllipse): >+ (WebCore::DisplayList::Recorder::strokeRect): >+ (WebCore::DisplayList::Recorder::strokePath): >+ (WebCore::DisplayList::Recorder::strokeEllipse): >+ (WebCore::DisplayList::Recorder::clearRect): >+ (WebCore::DisplayList::Recorder::updateItemExtent const): >+ * platform/graphics/displaylists/DisplayListRecorder.h: >+ * platform/graphics/displaylists/DisplayListReplayer.cpp: >+ (WebCore::DisplayList::Replayer::replay): >+ * platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp: >+ (Nicosia::CairoOperationRecorder::drawLinesForText): >+ (Nicosia::CairoOperationRecorder::drawPath): Deleted. >+ * platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.h: >+ * platform/graphics/win/GraphicsContextDirect2D.cpp: >+ (WebCore::GraphicsContext::drawLinesForText): >+ * platform/text/TextFlags.h: >+ (WebCore::operator<<): >+ > 2018-07-25 Justin Fan <justin_fan@apple.com> > > Systems with no NSScreens hitting assertion in rendererIDForDisplay when creating WebGL context >Index: Source/WebCore/platform/graphics/Font.h >=================================================================== >--- Source/WebCore/platform/graphics/Font.h (revision 234218) >+++ Source/WebCore/platform/graphics/Font.h (working copy) >@@ -37,6 +37,7 @@ > #include <wtf/BitVector.h> > #include <wtf/Optional.h> > #include <wtf/text/StringHash.h> >+#include <wtf/text/TextStream.h> > > #if PLATFORM(COCOA) > #include <wtf/RetainPtr.h> >@@ -370,6 +371,12 @@ ALWAYS_INLINE float Font::widthForGlyph( > return width; > } > >+inline WTF::TextStream& operator<<(WTF::TextStream& ts, const Font&) >+{ >+ // FIXME: dump the Font members to the TextStream. >+ return ts; >+} >+ > } // namespace WebCore > > #endif // Font_h >Index: Source/WebCore/platform/graphics/GlyphBuffer.h >=================================================================== >--- Source/WebCore/platform/graphics/GlyphBuffer.h (revision 234218) >+++ Source/WebCore/platform/graphics/GlyphBuffer.h (working copy) >@@ -34,6 +34,7 @@ > #include "Glyph.h" > #include <climits> > #include <wtf/Vector.h> >+#include <wtf/text/TextStream.h> > > #if USE(CG) > #include <CoreGraphics/CGGeometry.h> >@@ -228,5 +229,11 @@ private: > #endif > }; > >+inline WTF::TextStream& operator<<(WTF::TextStream& ts, const GlyphBuffer&) >+{ >+ // FIXME: dump the GlyphBuffer members to the TextStream. >+ return ts; >+} >+ > } > #endif >Index: Source/WebCore/platform/graphics/Gradient.h >=================================================================== >--- Source/WebCore/platform/graphics/Gradient.h (revision 234218) >+++ Source/WebCore/platform/graphics/Gradient.h (working copy) >@@ -34,6 +34,7 @@ > #include <wtf/RefCounted.h> > #include <wtf/Variant.h> > #include <wtf/Vector.h> >+#include <wtf/text/TextStream.h> > > #if USE(CG) > typedef struct CGContext* CGContextRef; >@@ -156,4 +157,10 @@ private: > PlatformGradient m_gradient; > }; > >+inline WTF::TextStream& operator<<(WTF::TextStream& ts, const Gradient&) >+{ >+ // FIXME: dump the Gradient members to the TextStream. >+ return ts; >+} >+ > } >Index: Source/WebCore/platform/graphics/GraphicsContext.cpp >=================================================================== >--- Source/WebCore/platform/graphics/GraphicsContext.cpp (revision 234218) >+++ Source/WebCore/platform/graphics/GraphicsContext.cpp (working copy) >@@ -1129,6 +1129,11 @@ void GraphicsContext::applyState(const G > setPlatformShouldAntialias(state.shouldAntialias); > setPlatformShouldSmoothFonts(state.shouldSmoothFonts); > } >+ >+void GraphicsContext::applyStateChange(const GraphicsContextStateChange& state) >+{ >+ state.apply(*this); >+} > > float GraphicsContext::dashedLineCornerWidthForStrokeWidth(float strokeWidth) const > { >Index: Source/WebCore/platform/graphics/GraphicsContext.h >=================================================================== >--- Source/WebCore/platform/graphics/GraphicsContext.h (revision 234218) >+++ Source/WebCore/platform/graphics/GraphicsContext.h (working copy) >@@ -116,6 +116,12 @@ enum class DocumentMarkerLineStyle : uin > AutocorrectionReplacement, > DictationAlternatives > }; >+ >+inline WTF::TextStream& operator<<(WTF::TextStream& ts, const DocumentMarkerLineStyle&) >+{ >+ // FIXME: dump the ImagePaintingOptions to the TextStream. >+ return ts; >+} > > namespace DisplayList { > class Recorder; >@@ -233,6 +239,12 @@ struct ImagePaintingOptions { > ImageOrientationDescription m_orientationDescription; > InterpolationQuality m_interpolationQuality; > }; >+ >+inline WTF::TextStream& operator<<(WTF::TextStream& ts, const ImagePaintingOptions&) >+{ >+ // FIXME: dump the ImagePaintingOptions to the TextStream. >+ return ts; >+} > > struct GraphicsContextStateChange { > GraphicsContextStateChange() = default; >@@ -255,7 +267,6 @@ struct GraphicsContextStateChange { > > WTF::TextStream& operator<<(WTF::TextStream&, const GraphicsContextStateChange&); > >- > class GraphicsContext { > WTF_MAKE_NONCOPYABLE(GraphicsContext); WTF_MAKE_FAST_ALLOCATED; > public: >@@ -412,6 +423,7 @@ public: > void drawBidiText(const FontCascade&, const TextRun&, const FloatPoint&, FontCascade::CustomFontNotReadyAction = FontCascade::DoNotPaintIfFontNotReady); > > void applyState(const GraphicsContextState&); >+ void applyStateChange(const GraphicsContextStateChange&); > > enum RoundingMode { > RoundAllSides, >Index: Source/WebCore/platform/graphics/GraphicsContextImpl.h >=================================================================== >--- Source/WebCore/platform/graphics/GraphicsContextImpl.h (revision 234218) >+++ Source/WebCore/platform/graphics/GraphicsContextImpl.h (working copy) >@@ -78,10 +78,12 @@ public: > > virtual void drawRect(const FloatRect&, float borderThickness) = 0; > virtual void drawLine(const FloatPoint&, const FloatPoint&) = 0; >- virtual void drawLinesForText(const FloatPoint&, const DashArray& widths, bool printing, bool doubleLines, float strokeThickness) = 0; >+ virtual void drawLinesForText(const FloatPoint&, const DashArray& widths, bool printing, bool doubleLines, StrokeStyle) = 0; > virtual void drawLineForDocumentMarker(const FloatPoint&, float width, DocumentMarkerLineStyle) = 0; > virtual void drawEllipse(const FloatRect&) = 0; >+#if USE(CG) > virtual void drawPath(const Path&) = 0; >+#endif > > virtual void drawFocusRing(const Path&, float width, float offset, const Color&) = 0; > virtual void drawFocusRing(const Vector<FloatRect>&, float width, float offset, const Color&) = 0; >Index: Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp >=================================================================== >--- Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp (revision 234218) >+++ Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp (working copy) >@@ -320,7 +320,7 @@ void GraphicsContext::drawLineForText(co > drawLinesForText(origin, DashArray { width, 0 }, printing, doubleUnderlines); > } > >-void GraphicsContext::drawLinesForText(const FloatPoint& point, const DashArray& widths, bool printing, bool doubleUnderlines, StrokeStyle) >+void GraphicsContext::drawLinesForText(const FloatPoint& point, const DashArray& widths, bool printing, bool doubleUnderlines, StrokeStyle strokeStyle) > { > if (paintingDisabled()) > return; >@@ -329,7 +329,7 @@ void GraphicsContext::drawLinesForText(c > return; > > if (m_impl) { >- m_impl->drawLinesForText(point, widths, printing, doubleUnderlines, strokeThickness()); >+ m_impl->drawLinesForText(point, widths, printing, doubleUnderlines, strokeStyle); > return; > } > >Index: Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp >=================================================================== >--- Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp (revision 234218) >+++ Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp (working copy) >@@ -294,9 +294,9 @@ void GraphicsContextImplCairo::drawLine( > Cairo::drawLine(m_platformContext, point1, point2, state.strokeStyle, state.strokeColor, state.strokeThickness, state.shouldAntialias); > } > >-void GraphicsContextImplCairo::drawLinesForText(const FloatPoint& point, const DashArray& widths, bool printing, bool doubleUnderlines, float strokeThickness) >+void GraphicsContextImplCairo::drawLinesForText(const FloatPoint& point, const DashArray& widths, bool printing, bool doubleUnderlines, StrokeStyle strokeStyle) > { >- UNUSED_PARAM(strokeThickness); >+ UNUSED_PARAM(strokeStyle); > auto& state = graphicsContext().state(); > Cairo::drawLinesForText(m_platformContext, point, widths, printing, doubleUnderlines, state.strokeColor, state.strokeThickness); > } >@@ -312,10 +312,6 @@ void GraphicsContextImplCairo::drawEllip > Cairo::drawEllipse(*platformContext(), rect, state.fillColor, state.strokeStyle, state.strokeColor, state.strokeThickness); > } > >-void GraphicsContextImplCairo::drawPath(const Path&) >-{ >-} >- > void GraphicsContextImplCairo::drawFocusRing(const Path& path, float width, float offset, const Color& color) > { > UNUSED_PARAM(offset); >Index: Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.h >=================================================================== >--- Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.h (revision 234218) >+++ Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.h (working copy) >@@ -79,10 +79,9 @@ public: > > void drawRect(const FloatRect&, float) override; > void drawLine(const FloatPoint&, const FloatPoint&) override; >- void drawLinesForText(const FloatPoint&, const DashArray&, bool, bool, float) override; >+ void drawLinesForText(const FloatPoint&, const DashArray&, bool, bool, StrokeStyle) override; > void drawLineForDocumentMarker(const FloatPoint&, float, DocumentMarkerLineStyle) override; > void drawEllipse(const FloatRect&) override; >- void drawPath(const Path&) override; > > void drawFocusRing(const Path&, float, float, const Color&) override; > void drawFocusRing(const Vector<FloatRect>&, float, float, const Color&) override; >Index: Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp >=================================================================== >--- Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp (revision 234218) >+++ Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp (working copy) >@@ -1587,7 +1587,7 @@ void GraphicsContext::drawLinesForText(c > return; > > if (m_impl) { >- m_impl->drawLinesForText(point, widths, printing, doubleLines, strokeThickness()); >+ m_impl->drawLinesForText(point, widths, printing, doubleLines, strokeStyle); > return; > } > >Index: Source/WebCore/platform/graphics/displaylists/DisplayList.cpp >=================================================================== >--- Source/WebCore/platform/graphics/displaylists/DisplayList.cpp (revision 234218) >+++ Source/WebCore/platform/graphics/displaylists/DisplayList.cpp (working copy) >@@ -114,8 +114,8 @@ void DisplayList::dump(TextStream& ts) c > size_t DisplayList::sizeInBytes() const > { > size_t result = 0; >- for (auto& ref : m_list) >- result += Item::sizeInBytes(ref); >+ for (auto& item : m_list) >+ result += item->sizeInBytes(); > > return result; > } >Index: Source/WebCore/platform/graphics/displaylists/DisplayList.h >=================================================================== >--- Source/WebCore/platform/graphics/displaylists/DisplayList.h (revision 234218) >+++ Source/WebCore/platform/graphics/displaylists/DisplayList.h (working copy) >@@ -41,8 +41,6 @@ class GraphicsContext; > > namespace DisplayList { > >-class Item; >- > enum AsTextFlag { > None = 0, > IncludesPlatformOperations = 1 << 0, >Index: Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp >=================================================================== >--- Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp (revision 234218) >+++ Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp (working copy) >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2015 Apple Inc. All rights reserved. >+ * Copyright (C) 2015-2018 Apple Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -26,1121 +26,86 @@ > #include "config.h" > #include "DisplayListItems.h" > >-#include "FontCascade.h" >-#include <wtf/text/TextStream.h> >- > namespace WebCore { > namespace DisplayList { > >-// Should match RenderTheme::platformFocusRingWidth() >-static const float platformFocusRingWidth = 3; >+using ItemDescriptor = struct { >+ String name; >+ Vector<String> argumentsNames; >+}; >+ >+static const Vector<ItemDescriptor>& itemsDescriptors() >+{ >+ static NeverDestroyed<Vector<ItemDescriptor>> itemsDescriptors = Vector<ItemDescriptor>({ >+ { "save", { } }, >+ { "restore", { } }, >+ { "set-state", { "state-change" } }, >+ { "translate", { "x", "y" } }, >+ { "rotate", { "angle" } }, >+ { "scale", { "size" } }, >+ { "concatenate-ctm", { "ctm" } }, >+ { "set-line-cap", { "line-cap" } }, >+ { "set-line-dash", { "dash-array", "dash-offset" } }, >+ { "set-line-join", { "line-join" } }, >+ { "set-miter-limit", { "mitre-limit" } }, >+ { "clear-shadow", { } }, >+ { "clip", { "rect" } }, >+ { "clip-out", { "rect" } }, >+ { "clip-out-to-path", { "path" } }, >+ { "clip-path", { "path", "wind-rule" } }, >+ { "apply-stroke-pattern", { } }, >+ { "apply-fill-pattern", { } }, >+ { "apply-device-scale-factor", { "scale-factor" } }, >+ >+ { "begin-transparency-layer", { "opacity" } }, >+ { "end-transparency-layer", { } }, >+ { "draw-glyphs", { "font", "glyph-buffer", "from", "num-glyphs", "point", "font-smoothing" } }, >+ { "draw-image", { "image", "dest-rect", "source-rect", "image-painting-options" } }, >+ { "draw-tiled-image", { "image", "dest-rect", "source-point", "tile-size", "spacing", "image-painting-options" } }, >+ { "draw-tiled-scaled-image", { "image", "dest-rect", "source-rect", "tile-scalefactor", "h-rule", "v-rule", "image-painting-options" } }, >+ { "draw-native-image", { "image", "self-size", "dest-rect", "source-rect", "composite-operator", "blend-mode", "image-orientation" } }, >+ { "draw-pattern", { "image", "dest-rect", "tile-rect", "pattern-transform", "phase", "spacing", "composite-operator", "blend-mode" } }, >+ { "draw-rect", { "rect", "border-thickness" } }, >+ { "draw-line", { "point-1", "point-2" } }, >+ { "draw-lines-for-text", { "point", "widths", "is-printing", "double-lines", "stroke-style" } }, >+ { "draw-line-for-document-marker", { "point", "width", "document-marker-line-style" } }, >+ { "draw-ellipse", { "rect" } }, >+ { "draw-path", { "path" } }, >+ { "draw-focus-ring-path", { "path", "width", "offset", "color" } }, >+ { "draw-focus-ring-rects", { "rects", "width", "offset", "color" } }, >+ { "fill-rect", { "rect" } }, >+ { "fill-rect-with-color", { "rect", "color" } }, >+ { "fill-rect-with-gradient", { "rect", "gradient" } }, >+ { "fill-composited-rect", { "rect", "color", "composite-operator", "blend-mode" } }, >+ { "fill-rounded-rect", { "rect", "color", "blend-mode" } }, >+ { "fill-rect-with-rounded-hole", { "rect", "rounded-hole-rect", "color" } }, >+ { "fill-path", { "path" } }, >+ { "fill-ellipse", { "rect" } }, >+ { "stroke-rect", { "rect", "line-width" } }, >+ { "stroke-path", { "path" } }, >+ { "stroke-ellipse", { "rect" } }, >+ { "clear-rect", { "rect" } } >+ }); > >-#if !defined(NDEBUG) || !LOG_DISABLED >-WTF::CString Item::description() const >-{ >- TextStream ts; >- ts << *this; >- return ts.release().utf8(); >+ ASSERT(static_cast<size_t>(ItemType::Max) == itemsDescriptors.get().size()); >+ return itemsDescriptors; > } >-#endif > >-size_t Item::sizeInBytes(const Item& item) >+static const ItemDescriptor& itemDescriptor(ItemType itemType) > { >- switch (item.type()) { >- case ItemType::Save: >- return sizeof(downcast<Save>(item)); >- case ItemType::Restore: >- return sizeof(downcast<Restore>(item)); >- case ItemType::Translate: >- return sizeof(downcast<Translate>(item)); >- case ItemType::Rotate: >- return sizeof(downcast<Rotate>(item)); >- case ItemType::Scale: >- return sizeof(downcast<Scale>(item)); >- case ItemType::ConcatenateCTM: >- return sizeof(downcast<ConcatenateCTM>(item)); >- case ItemType::SetState: >- return sizeof(downcast<SetState>(item)); >- case ItemType::SetLineCap: >- return sizeof(downcast<SetLineCap>(item)); >- case ItemType::SetLineDash: >- return sizeof(downcast<SetLineDash>(item)); >- case ItemType::SetLineJoin: >- return sizeof(downcast<SetLineJoin>(item)); >- case ItemType::SetMiterLimit: >- return sizeof(downcast<SetMiterLimit>(item)); >- case ItemType::ClearShadow: >- return sizeof(downcast<ClearShadow>(item)); >- case ItemType::Clip: >- return sizeof(downcast<Clip>(item)); >- case ItemType::ClipOut: >- return sizeof(downcast<ClipOut>(item)); >- case ItemType::ClipOutToPath: >- return sizeof(downcast<ClipOutToPath>(item)); >- case ItemType::ClipPath: >- return sizeof(downcast<ClipPath>(item)); >- case ItemType::DrawGlyphs: >- return sizeof(downcast<DrawGlyphs>(item)); >- case ItemType::DrawImage: >- return sizeof(downcast<DrawImage>(item)); >- case ItemType::DrawTiledImage: >- return sizeof(downcast<DrawTiledImage>(item)); >- case ItemType::DrawTiledScaledImage: >- return sizeof(downcast<DrawTiledScaledImage>(item)); >-#if USE(CG) || USE(CAIRO) >- case ItemType::DrawNativeImage: >- return sizeof(downcast<DrawNativeImage>(item)); >-#endif >- case ItemType::DrawPattern: >- return sizeof(downcast<DrawPattern>(item)); >- case ItemType::DrawRect: >- return sizeof(downcast<DrawRect>(item)); >- case ItemType::DrawLine: >- return sizeof(downcast<DrawLine>(item)); >- case ItemType::DrawLinesForText: >- return sizeof(downcast<DrawLinesForText>(item)); >- case ItemType::DrawLineForDocumentMarker: >- return sizeof(downcast<DrawLineForDocumentMarker>(item)); >- case ItemType::DrawEllipse: >- return sizeof(downcast<DrawEllipse>(item)); >- case ItemType::DrawPath: >- return sizeof(downcast<DrawPath>(item)); >- case ItemType::DrawFocusRingPath: >- return sizeof(downcast<DrawFocusRingPath>(item)); >- case ItemType::DrawFocusRingRects: >- return sizeof(downcast<DrawFocusRingRects>(item)); >- case ItemType::FillRect: >- return sizeof(downcast<FillRect>(item)); >- case ItemType::FillRectWithColor: >- return sizeof(downcast<FillRectWithColor>(item)); >- case ItemType::FillRectWithGradient: >- return sizeof(downcast<FillRectWithGradient>(item)); >- case ItemType::FillCompositedRect: >- return sizeof(downcast<FillCompositedRect>(item)); >- case ItemType::FillRoundedRect: >- return sizeof(downcast<FillRoundedRect>(item)); >- case ItemType::FillRectWithRoundedHole: >- return sizeof(downcast<FillRectWithRoundedHole>(item)); >- case ItemType::FillPath: >- return sizeof(downcast<FillPath>(item)); >- case ItemType::FillEllipse: >- return sizeof(downcast<FillEllipse>(item)); >- case ItemType::StrokeRect: >- return sizeof(downcast<StrokeRect>(item)); >- case ItemType::StrokePath: >- return sizeof(downcast<StrokePath>(item)); >- case ItemType::StrokeEllipse: >- return sizeof(downcast<StrokeEllipse>(item)); >- case ItemType::ClearRect: >- return sizeof(downcast<ClearRect>(item)); >- case ItemType::BeginTransparencyLayer: >- return sizeof(downcast<BeginTransparencyLayer>(item)); >- case ItemType::EndTransparencyLayer: >- return sizeof(downcast<EndTransparencyLayer>(item)); >-#if USE(CG) >- case ItemType::ApplyStrokePattern: >- return sizeof(downcast<ApplyStrokePattern>(item)); >- case ItemType::ApplyFillPattern: >- return sizeof(downcast<ApplyFillPattern>(item)); >-#endif >- case ItemType::ApplyDeviceScaleFactor: >- return sizeof(downcast<ApplyDeviceScaleFactor>(item)); >- } >- return 0; >+ ASSERT(static_cast<size_t>(itemType) < itemsDescriptors().size()); >+ return itemsDescriptors()[static_cast<size_t>(itemType)]; > } >- >-static TextStream& operator<<(TextStream& ts, const DrawingItem& item) >-{ >- ts.startGroup(); >- ts << "extent "; >- if (item.extentKnown()) >- ts << item.extent(); >- else >- ts << "unknown"; > >- ts.endGroup(); >- return ts; >-} >- >-void Save::apply(GraphicsContext& context) const >-{ >- context.save(); >-} >- >-static TextStream& operator<<(TextStream& ts, const Save& item) >-{ >- ts.dumpProperty("restore-index", item.restoreIndex()); >- return ts; >-} >- >-void Restore::apply(GraphicsContext& context) const >-{ >- context.restore(); >-} >- >-void Translate::apply(GraphicsContext& context) const >-{ >- context.translate(m_x, m_y); >-} >- >-static TextStream& operator<<(TextStream& ts, const Translate& item) >-{ >- ts.dumpProperty("x", item.x()); >- ts.dumpProperty("y", item.y()); >- >- return ts; >-} >- >-void Rotate::apply(GraphicsContext& context) const >-{ >- context.rotate(m_angle); >-} >- >-static TextStream& operator<<(TextStream& ts, const Rotate& item) >-{ >- ts.dumpProperty("angle", item.angle()); >- >- return ts; >-} >- >-void Scale::apply(GraphicsContext& context) const >-{ >- context.scale(m_size); >-} >- >-static TextStream& operator<<(TextStream& ts, const Scale& item) >-{ >- ts.dumpProperty("size", item.amount()); >- >- return ts; >-} >- >-ConcatenateCTM::ConcatenateCTM(const AffineTransform& transform) >- : Item(ItemType::ConcatenateCTM) >- , m_transform(transform) >-{ >-} >- >-void ConcatenateCTM::apply(GraphicsContext& context) const >-{ >- context.concatCTM(m_transform); >-} >- >-static TextStream& operator<<(TextStream& ts, const ConcatenateCTM& item) >-{ >- ts.dumpProperty("ctm", item.transform()); >- >- return ts; >-} >- >-void SetState::apply(GraphicsContext& context) const >-{ >- m_state.apply(context); >-} >- >-void SetState::accumulate(const GraphicsContextState& state, GraphicsContextState::StateChangeFlags flags) >-{ >- m_state.accumulate(state, flags); >-} >- >-static TextStream& operator<<(TextStream& ts, const SetState& state) >-{ >- ts << state.state(); >- return ts; >-} >- >-void SetLineCap::apply(GraphicsContext& context) const >-{ >- context.setLineCap(m_lineCap); >-} >- >-static TextStream& operator<<(TextStream& ts, const SetLineCap& lineCap) >-{ >- ts.dumpProperty("line-cap", lineCap.lineCap()); >- return ts; >-} >- >-void SetLineDash::apply(GraphicsContext& context) const >-{ >- context.setLineDash(m_dashArray, m_dashOffset); >-} >- >-static TextStream& operator<<(TextStream& ts, const SetLineDash& lineDash) >-{ >- ts.dumpProperty("dash-array", lineDash.dashArray()); >- ts.dumpProperty("dash-offset", lineDash.dashOffset()); >- return ts; >-} >- >-void SetLineJoin::apply(GraphicsContext& context) const >-{ >- context.setLineJoin(m_lineJoin); >-} >- >-static TextStream& operator<<(TextStream& ts, const SetLineJoin& lineJoin) >-{ >- ts.dumpProperty("line-join", lineJoin.lineJoin()); >- return ts; >-} >- >-void SetMiterLimit::apply(GraphicsContext& context) const >-{ >- context.setMiterLimit(m_miterLimit); >-} >- >-static TextStream& operator<<(TextStream& ts, const SetMiterLimit& miterLimit) >-{ >- ts.dumpProperty("mitre-limit", miterLimit.miterLimit()); >- return ts; >-} >- >-void ClearShadow::apply(GraphicsContext& context) const >-{ >- context.clearShadow(); >-} >- >-void Clip::apply(GraphicsContext& context) const >-{ >- context.clip(m_rect); >-} >- >-static TextStream& operator<<(TextStream& ts, const Clip& item) >-{ >- ts.dumpProperty("rect", item.rect()); >- return ts; >-} >- >-void ClipOut::apply(GraphicsContext& context) const >-{ >- context.clipOut(m_rect); >-} >- >-static TextStream& operator<<(TextStream& ts, const ClipOut& item) >-{ >- ts.dumpProperty("rect", item.rect()); >- return ts; >-} >- >-void ClipOutToPath::apply(GraphicsContext& context) const >-{ >- context.clipOut(m_path); >-} >- >-static TextStream& operator<<(TextStream& ts, const ClipOutToPath& item) >-{ >- ts.dumpProperty("path", item.path()); >- return ts; >-} >- >-void ClipPath::apply(GraphicsContext& context) const >-{ >- context.clipPath(m_path, m_windRule); >-} >- >-static TextStream& operator<<(TextStream& ts, const ClipPath& item) >-{ >- ts.dumpProperty("path", item.path()); >- ts.dumpProperty("wind-rule", item.windRule()); >- return ts; >-} >- >-DrawGlyphs::DrawGlyphs(const Font& font, const GlyphBufferGlyph* glyphs, const GlyphBufferAdvance* advances, unsigned count, const FloatPoint& blockLocation, const FloatSize& localAnchor, FontSmoothingMode smoothingMode) >- : DrawingItem(ItemType::DrawGlyphs) >- , m_font(const_cast<Font&>(font)) >- , m_blockLocation(blockLocation) >- , m_localAnchor(localAnchor) >- , m_smoothingMode(smoothingMode) >-{ >- m_glyphs.reserveInitialCapacity(count); >- m_advances.reserveInitialCapacity(count); >- for (unsigned i = 0; i < count; ++i) { >- m_glyphs.uncheckedAppend(glyphs[i]); >- m_advances.uncheckedAppend(advances[i]); >- } >- computeBounds(); >-} >- >-inline GlyphBuffer DrawGlyphs::generateGlyphBuffer() const >-{ >- GlyphBuffer result; >- for (size_t i = 0; i < m_glyphs.size(); ++i) { >- result.add(m_glyphs[i], &m_font.get(), m_advances[i]); >- } >- return result; >-} >- >-void DrawGlyphs::apply(GraphicsContext& context) const >-{ >- context.drawGlyphs(m_font, generateGlyphBuffer(), 0, m_glyphs.size(), anchorPoint(), m_smoothingMode); >-} >- >-void DrawGlyphs::computeBounds() >-{ >- // FIXME: This code doesn't actually take the extents of the glyphs into consideration. It assumes that >- // the glyph lies entirely within its [(ascent + descent), advance] rect. >- float ascent = m_font->fontMetrics().floatAscent(); >- float descent = m_font->fontMetrics().floatDescent(); >- FloatPoint current = toFloatPoint(localAnchor()); >- size_t numGlyphs = m_glyphs.size(); >- for (size_t i = 0; i < numGlyphs; ++i) { >- GlyphBufferAdvance advance = m_advances[i]; >- FloatRect glyphRect = FloatRect(current.x(), current.y() - ascent, advance.width(), ascent + descent); >- m_bounds.unite(glyphRect); >- >- current.move(advance.width(), advance.height()); >- } >-} >- >-std::optional<FloatRect> DrawGlyphs::localBounds(const GraphicsContext&) const >-{ >- FloatRect localBounds = m_bounds; >- localBounds.move(m_blockLocation.x(), m_blockLocation.y()); >- return localBounds; >-} >- >-static TextStream& operator<<(TextStream& ts, const DrawGlyphs& item) >-{ >- ts << static_cast<const DrawingItem&>(item); >- // FIXME: dump more stuff. >- ts.dumpProperty("block-location", item.blockLocation()); >- ts.dumpProperty("local-anchor", item.localAnchor()); >- ts.dumpProperty("anchor-point", item.anchorPoint()); >- ts.dumpProperty("length", item.glyphs().size()); >- >- return ts; >-} >- >-DrawImage::DrawImage(Image& image, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& imagePaintingOptions) >- : DrawingItem(ItemType::DrawImage) >- , m_image(image) >- , m_destination(destination) >- , m_source(source) >- , m_imagePaintingOptions(imagePaintingOptions) >-{ >-} >- >-void DrawImage::apply(GraphicsContext& context) const >+String Item::name() const > { >- context.drawImage(m_image.get(), m_destination, m_source, m_imagePaintingOptions); >+ return itemDescriptor(m_type).name; > } > >-static TextStream& operator<<(TextStream& ts, const DrawImage& item) >+String Item::argumentName(size_t index) const > { >- ts << static_cast<const DrawingItem&>(item); >- ts.dumpProperty("image", item.image()); >- ts.dumpProperty("source-rect", item.source()); >- ts.dumpProperty("dest-rect", item.destination()); >- return ts; >-} >- >-DrawTiledImage::DrawTiledImage(Image& image, const FloatRect& destination, const FloatPoint& source, const FloatSize& tileSize, const FloatSize& spacing, const ImagePaintingOptions& imagePaintingOptions) >- : DrawingItem(ItemType::DrawTiledImage) >- , m_image(image) >- , m_destination(destination) >- , m_source(source) >- , m_tileSize(tileSize) >- , m_spacing(spacing) >- , m_imagePaintingOptions(imagePaintingOptions) >-{ >-} >- >-void DrawTiledImage::apply(GraphicsContext& context) const >-{ >- context.drawTiledImage(m_image.get(), m_destination, m_source, m_tileSize, m_spacing, m_imagePaintingOptions); >-} >- >-static TextStream& operator<<(TextStream& ts, const DrawTiledImage& item) >-{ >- ts << static_cast<const DrawingItem&>(item); >- ts.dumpProperty("image", item.image()); >- ts.dumpProperty("source-point", item.source()); >- ts.dumpProperty("dest-rect", item.destination()); >- ts.dumpProperty("tile-size", item.tileSize()); >- ts.dumpProperty("spacing", item.spacing()); >- return ts; >-} >- >-DrawTiledScaledImage::DrawTiledScaledImage(Image& image, const FloatRect& destination, const FloatRect& source, const FloatSize& tileScaleFactor, Image::TileRule hRule, Image::TileRule vRule, const ImagePaintingOptions& imagePaintingOptions) >- : DrawingItem(ItemType::DrawTiledScaledImage) >- , m_image(image) >- , m_destination(destination) >- , m_source(source) >- , m_tileScaleFactor(tileScaleFactor) >- , m_hRule(hRule) >- , m_vRule(vRule) >- , m_imagePaintingOptions(imagePaintingOptions) >-{ >-} >- >-void DrawTiledScaledImage::apply(GraphicsContext& context) const >-{ >- context.drawTiledImage(m_image.get(), m_destination, m_source, m_tileScaleFactor, m_hRule, m_vRule, m_imagePaintingOptions); >-} >- >-static TextStream& operator<<(TextStream& ts, const DrawTiledScaledImage& item) >-{ >- ts << static_cast<const DrawingItem&>(item); >- ts.dumpProperty("image", item.image()); >- ts.dumpProperty("source-rect", item.source()); >- ts.dumpProperty("dest-rect", item.destination()); >- return ts; >-} >- >-#if USE(CG) || USE(CAIRO) >-DrawNativeImage::DrawNativeImage(const NativeImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator op, BlendMode blendMode, ImageOrientation orientation) >- : DrawingItem(ItemType::DrawNativeImage) >-#if USE(CG) >- // FIXME: Need to store an image for Cairo. >- , m_image(image) >-#endif >- , m_imageSize(imageSize) >- , m_destination(destRect) >- , m_srcRect(srcRect) >-#if USE(CG) >- , m_op(op) >- , m_blendMode(blendMode) >-#endif >- , m_orientation(orientation) >-{ >-#if !USE(CG) >- UNUSED_PARAM(image); >- UNUSED_PARAM(op); >- UNUSED_PARAM(blendMode); >-#endif >-} >- >-void DrawNativeImage::apply(GraphicsContext& context) const >-{ >-#if USE(CG) >- context.drawNativeImage(m_image, m_imageSize, m_destination, m_srcRect, m_op, m_blendMode, m_orientation); >-#else >- UNUSED_PARAM(context); >-#endif >-} >- >-static TextStream& operator<<(TextStream& ts, const DrawNativeImage& item) >-{ >- ts << static_cast<const DrawingItem&>(item); >- // FIXME: dump more stuff. >- ts.dumpProperty("source-rect", item.source()); >- ts.dumpProperty("dest-rect", item.destination()); >- return ts; >-} >-#endif >- >-DrawPattern::DrawPattern(Image& image, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, CompositeOperator op, BlendMode blendMode) >- : DrawingItem(ItemType::DrawPattern) >- , m_image(image) >- , m_patternTransform(patternTransform) >- , m_tileRect(tileRect) >- , m_destination(destRect) >- , m_phase(phase) >- , m_spacing(spacing) >- , m_op(op) >- , m_blendMode(blendMode) >-{ >-} >- >-void DrawPattern::apply(GraphicsContext& context) const >-{ >- context.drawPattern(m_image.get(), m_destination, m_tileRect, m_patternTransform, m_phase, m_spacing, m_op, m_blendMode); >-} >- >-static TextStream& operator<<(TextStream& ts, const DrawPattern& item) >-{ >- ts << static_cast<const DrawingItem&>(item); >- ts.dumpProperty("image", item.image()); >- ts.dumpProperty("pattern-transform", item.patternTransform()); >- ts.dumpProperty("tile-rect", item.tileRect()); >- ts.dumpProperty("dest-rect", item.destRect()); >- ts.dumpProperty("phase", item.phase()); >- ts.dumpProperty("spacing", item.spacing()); >- return ts; >-} >- >-void DrawRect::apply(GraphicsContext& context) const >-{ >- context.drawRect(m_rect, m_borderThickness); >-} >- >-static TextStream& operator<<(TextStream& ts, const DrawRect& item) >-{ >- ts << static_cast<const DrawingItem&>(item); >- ts.dumpProperty("rect", item.rect()); >- ts.dumpProperty("border-thickness", item.borderThickness()); >- return ts; >-} >- >-std::optional<FloatRect> DrawLine::localBounds(const GraphicsContext&) const >-{ >- FloatRect bounds; >- bounds.fitToPoints(m_point1, m_point2); >- return bounds; >-} >- >-void DrawLine::apply(GraphicsContext& context) const >-{ >- context.drawLine(m_point1, m_point2); >-} >- >-static TextStream& operator<<(TextStream& ts, const DrawLine& item) >-{ >- ts << static_cast<const DrawingItem&>(item); >- ts.dumpProperty("point-1", item.point1()); >- ts.dumpProperty("point-2", item.point2()); >- return ts; >-} >- >-void DrawLinesForText::apply(GraphicsContext& context) const >-{ >- context.drawLinesForText(point(), m_widths, m_printing, m_doubleLines); >-} >- >-std::optional<FloatRect> DrawLinesForText::localBounds(const GraphicsContext&) const >-{ >- // This function needs to return a value equal to or enclosing what GraphicsContext::computeLineBoundsAndAntialiasingModeForText() returns. >- >- if (!m_widths.size()) >- return FloatRect(); >- >- FloatRect result(point(), FloatSize(m_widths.last(), m_strokeWidth)); >- result.inflate(1); // Account for pixel snapping. FIXME: This isn't perfect, as it doesn't take the CTM into account. >- return result; >-} >- >-static TextStream& operator<<(TextStream& ts, const DrawLinesForText& item) >-{ >- ts << static_cast<const DrawingItem&>(item); >- ts.dumpProperty("block-location", item.blockLocation()); >- ts.dumpProperty("local-anchor", item.localAnchor()); >- ts.dumpProperty("point", item.point()); >- ts.dumpProperty("double", item.doubleLines()); >- ts.dumpProperty("widths", item.widths()); >- ts.dumpProperty("is-printing", item.isPrinting()); >- ts.dumpProperty("double", item.doubleLines()); >- return ts; >-} >- >-void DrawLineForDocumentMarker::apply(GraphicsContext& context) const >-{ >- context.drawLineForDocumentMarker(m_point, m_width, m_style); >-} >- >-std::optional<FloatRect> DrawLineForDocumentMarker::localBounds(const GraphicsContext&) const >-{ >- // This function needs to return a value equal to or enclosing what GraphicsContext::drawLineForDocumentMarker() returns. >- >- FloatRect result(m_point, FloatSize(m_width, cMisspellingLineThickness)); >- result.inflate(cMisspellingLineThickness); // Account for "misspelling dot" snapping. >- return result; >-} >- >-static TextStream& operator<<(TextStream& ts, const DrawLineForDocumentMarker& item) >-{ >- ts << static_cast<const DrawingItem&>(item); >- ts.dumpProperty("point", item.point()); >- ts.dumpProperty("width", item.width()); >- return ts; >-} >- >-void DrawEllipse::apply(GraphicsContext& context) const >-{ >- context.drawEllipse(m_rect); >-} >- >-static TextStream& operator<<(TextStream& ts, const DrawEllipse& item) >-{ >- ts.dumpProperty("rect", item.rect()); >- return ts; >-} >- >-void DrawPath::apply(GraphicsContext& context) const >-{ >-#if USE(CG) >- context.drawPath(m_path); >-#else >- UNUSED_PARAM(context); >-#endif >-} >- >-static TextStream& operator<<(TextStream& ts, const DrawPath& item) >-{ >- ts << static_cast<const DrawingItem&>(item); >-// ts.dumpProperty("path", item.path()); // FIXME: add logging for paths. >- return ts; >-} >- >-void DrawFocusRingPath::apply(GraphicsContext& context) const >-{ >- context.drawFocusRing(m_path, m_width, m_offset, m_color); >-} >- >-std::optional<FloatRect> DrawFocusRingPath::localBounds(const GraphicsContext&) const >-{ >- FloatRect result = m_path.fastBoundingRect(); >- result.inflate(platformFocusRingWidth); >- return result; >-} >- >-static TextStream& operator<<(TextStream& ts, const DrawFocusRingPath& item) >-{ >- ts << static_cast<const DrawingItem&>(item); >-// ts.dumpProperty("path", item.path()); // FIXME: add logging for paths. >- ts.dumpProperty("width", item.width()); >- ts.dumpProperty("offset", item.offset()); >- ts.dumpProperty("color", item.color()); >- return ts; >-} >- >-void DrawFocusRingRects::apply(GraphicsContext& context) const >-{ >- context.drawFocusRing(m_rects, m_width, m_offset, m_color); >-} >- >-std::optional<FloatRect> DrawFocusRingRects::localBounds(const GraphicsContext&) const >-{ >- FloatRect result; >- for (auto& rect : m_rects) >- result.unite(rect); >- result.inflate(platformFocusRingWidth); >- return result; >-} >- >-static TextStream& operator<<(TextStream& ts, const DrawFocusRingRects& item) >-{ >- ts << static_cast<const DrawingItem&>(item); >- ts.dumpProperty("rects", item.rects()); >- ts.dumpProperty("width", item.width()); >- ts.dumpProperty("offset", item.offset()); >- ts.dumpProperty("color", item.color()); >- return ts; >-} >- >-void FillRect::apply(GraphicsContext& context) const >-{ >- context.fillRect(m_rect); >-} >- >-static TextStream& operator<<(TextStream& ts, const FillRect& item) >-{ >- ts << static_cast<const DrawingItem&>(item); >- ts.dumpProperty("rect", item.rect()); >- return ts; >-} >- >-void FillRectWithColor::apply(GraphicsContext& context) const >-{ >- context.fillRect(m_rect, m_color); >-} >- >-static TextStream& operator<<(TextStream& ts, const FillRectWithColor& item) >-{ >- ts << static_cast<const DrawingItem&>(item); >- ts.dumpProperty("rect", item.rect()); >- ts.dumpProperty("color", item.color()); >- return ts; >-} >- >-void FillRectWithGradient::apply(GraphicsContext& context) const >-{ >- context.fillRect(m_rect, m_gradient.get()); >-} >- >-static TextStream& operator<<(TextStream& ts, const FillRectWithGradient& item) >-{ >- ts << static_cast<const DrawingItem&>(item); >- // FIXME: log gradient. >- ts.dumpProperty("rect", item.rect()); >- return ts; >-} >- >-void FillCompositedRect::apply(GraphicsContext& context) const >-{ >- context.fillRect(m_rect, m_color, m_op, m_blendMode); >-} >- >-static TextStream& operator<<(TextStream& ts, const FillCompositedRect& item) >-{ >- ts << static_cast<const DrawingItem&>(item); >- ts.dumpProperty("rect", item.rect()); >- ts.dumpProperty("color", item.color()); >- ts.dumpProperty("composite-operation", item.compositeOperator()); >- ts.dumpProperty("blend-mode", item.blendMode()); >- return ts; >-} >- >-void FillRoundedRect::apply(GraphicsContext& context) const >-{ >- context.fillRoundedRect(m_rect, m_color, m_blendMode); >-} >- >-static TextStream& operator<<(TextStream& ts, const FillRoundedRect& item) >-{ >- ts << static_cast<const DrawingItem&>(item); >- ts.dumpProperty("rect", item.roundedRect()); >- ts.dumpProperty("color", item.color()); >- ts.dumpProperty("blend-mode", item.blendMode()); >- return ts; >-} >- >-void FillRectWithRoundedHole::apply(GraphicsContext& context) const >-{ >- context.fillRectWithRoundedHole(m_rect, m_roundedHoleRect, m_color); >-} >- >-static TextStream& operator<<(TextStream& ts, const FillRectWithRoundedHole& item) >-{ >- ts << static_cast<const DrawingItem&>(item); >- ts.dumpProperty("rect", item.rect()); >- ts.dumpProperty("rounded-hole-rect", item.roundedHoleRect()); >- ts.dumpProperty("color", item.color()); >- return ts; >-} >- >-void FillPath::apply(GraphicsContext& context) const >-{ >- context.fillPath(m_path); >-} >- >-static TextStream& operator<<(TextStream& ts, const FillPath& item) >-{ >- ts << static_cast<const DrawingItem&>(item); >- ts.dumpProperty("path", item.path()); >- return ts; >-} >- >-void FillEllipse::apply(GraphicsContext& context) const >-{ >- context.fillEllipse(m_rect); >-} >- >-static TextStream& operator<<(TextStream& ts, const FillEllipse& item) >-{ >- ts << static_cast<const DrawingItem&>(item); >- ts.dumpProperty("rect", item.rect()); >- return ts; >-} >- >-std::optional<FloatRect> StrokeRect::localBounds(const GraphicsContext&) const >-{ >- FloatRect bounds = m_rect; >- bounds.expand(m_lineWidth, m_lineWidth); >- return bounds; >-} >- >-void StrokeRect::apply(GraphicsContext& context) const >-{ >- context.strokeRect(m_rect, m_lineWidth); >-} >- >-static TextStream& operator<<(TextStream& ts, const StrokeRect& item) >-{ >- ts << static_cast<const DrawingItem&>(item); >- ts.dumpProperty("rect", item.rect()); >- ts.dumpProperty("line-width", item.lineWidth()); >- return ts; >-} >- >-std::optional<FloatRect> StrokePath::localBounds(const GraphicsContext& context) const >-{ >- // FIXME: Need to take stroke thickness into account correctly, via CGPathByStrokingPath(). >- float strokeThickness = context.strokeThickness(); >- >- FloatRect bounds = m_path.boundingRect(); >- bounds.expand(strokeThickness, strokeThickness); >- return bounds; >-} >- >-void StrokePath::apply(GraphicsContext& context) const >-{ >- context.strokePath(m_path); >-} >- >-static TextStream& operator<<(TextStream& ts, const StrokePath& item) >-{ >- ts << static_cast<const DrawingItem&>(item); >- ts.dumpProperty("path", item.path()); >- return ts; >-} >- >-std::optional<FloatRect> StrokeEllipse::localBounds(const GraphicsContext& context) const >-{ >- float strokeThickness = context.strokeThickness(); >- >- FloatRect bounds = m_rect; >- bounds.expand(strokeThickness, strokeThickness); >- return bounds; >-} >- >-void StrokeEllipse::apply(GraphicsContext& context) const >-{ >- context.strokeEllipse(m_rect); >-} >- >-static TextStream& operator<<(TextStream& ts, const StrokeEllipse& item) >-{ >- ts << static_cast<const DrawingItem&>(item); >- ts.dumpProperty("rect", item.rect()); >- return ts; >-} >- >-void ClearRect::apply(GraphicsContext& context) const >-{ >- context.clearRect(m_rect); >-} >- >-static TextStream& operator<<(TextStream& ts, const ClearRect& item) >-{ >- ts << static_cast<const DrawingItem&>(item); >- ts.dumpProperty("rect", item.rect()); >- return ts; >-} >- >-void BeginTransparencyLayer::apply(GraphicsContext& context) const >-{ >- context.beginTransparencyLayer(m_opacity); >-} >- >-static TextStream& operator<<(TextStream& ts, const BeginTransparencyLayer& item) >-{ >- ts << static_cast<const DrawingItem&>(item); >- ts.dumpProperty("opacity", item.opacity()); >- return ts; >-} >- >-void EndTransparencyLayer::apply(GraphicsContext& context) const >-{ >- context.endTransparencyLayer(); >-} >- >-#if USE(CG) >-void ApplyStrokePattern::apply(GraphicsContext& context) const >-{ >- context.applyStrokePattern(); >-} >- >-void ApplyFillPattern::apply(GraphicsContext& context) const >-{ >- context.applyFillPattern(); >-} >-#endif >- >-void ApplyDeviceScaleFactor::apply(GraphicsContext& context) const >-{ >- context.applyDeviceScaleFactor(m_scaleFactor); >-} >- >-static TextStream& operator<<(TextStream& ts, const ApplyDeviceScaleFactor& item) >-{ >- ts.dumpProperty("scale-factor", item.scaleFactor()); >- return ts; >-} >- >-static TextStream& operator<<(TextStream& ts, const ItemType& type) >-{ >- switch (type) { >- case ItemType::Save: ts << "save"; break; >- case ItemType::Restore: ts << "restore"; break; >- case ItemType::Translate: ts << "translate"; break; >- case ItemType::Rotate: ts << "rotate"; break; >- case ItemType::Scale: ts << "scale"; break; >- case ItemType::ConcatenateCTM: ts << "concatentate-ctm"; break; >- case ItemType::SetState: ts << "set-state"; break; >- case ItemType::SetLineCap: ts << "set-line-cap"; break; >- case ItemType::SetLineDash: ts << "set-line-dash"; break; >- case ItemType::SetLineJoin: ts << "set-line-join"; break; >- case ItemType::SetMiterLimit: ts << "set-miter-limit"; break; >- case ItemType::Clip: ts << "clip"; break; >- case ItemType::ClipOut: ts << "clip-out"; break; >- case ItemType::ClipOutToPath: ts << "clip-out-to-path"; break; >- case ItemType::ClipPath: ts << "clip-path"; break; >- case ItemType::DrawGlyphs: ts << "draw-glyphs"; break; >- case ItemType::DrawImage: ts << "draw-image"; break; >- case ItemType::DrawTiledImage: ts << "draw-tiled-image"; break; >- case ItemType::DrawTiledScaledImage: ts << "draw-tiled-scaled-image"; break; >-#if USE(CG) || USE(CAIRO) >- case ItemType::DrawNativeImage: ts << "draw-native-image"; break; >-#endif >- case ItemType::DrawPattern: ts << "draw-pattern"; break; >- case ItemType::DrawRect: ts << "draw-rect"; break; >- case ItemType::DrawLine: ts << "draw-line"; break; >- case ItemType::DrawLinesForText: ts << "draw-lines-for-text"; break; >- case ItemType::DrawLineForDocumentMarker: ts << "draw-lines-for-document-marker"; break; >- case ItemType::DrawEllipse: ts << "draw-ellipse"; break; >- case ItemType::DrawPath: ts << "draw-path"; break; >- case ItemType::DrawFocusRingPath: ts << "draw-focus-ring-path"; break; >- case ItemType::DrawFocusRingRects: ts << "draw-focus-ring-rects"; break; >- case ItemType::FillRect: ts << "fill-rect"; break; >- case ItemType::FillRectWithColor: ts << "fill-rect-with-color"; break; >- case ItemType::FillRectWithGradient: ts << "fill-rect-with-gradient"; break; >- case ItemType::FillCompositedRect: ts << "fill-composited-rect"; break; >- case ItemType::FillRoundedRect: ts << "fill-rounded-rect"; break; >- case ItemType::FillRectWithRoundedHole: ts << "fill-rect-with-rounded-hole"; break; >- case ItemType::FillPath: ts << "fill-path"; break; >- case ItemType::FillEllipse: ts << "fill-ellipse"; break; >- case ItemType::StrokeRect: ts << "stroke-rect"; break; >- case ItemType::StrokePath: ts << "stroke-path"; break; >- case ItemType::StrokeEllipse: ts << "stroke-ellipse"; break; >- case ItemType::ClearRect: ts << "clear-rect"; break; >- case ItemType::BeginTransparencyLayer: ts << "begin-transparency-layer"; break; >- case ItemType::EndTransparencyLayer: ts << "end-transparency-layer"; break; >-#if USE(CG) >- case ItemType::ApplyStrokePattern: ts << "apply-stroke-pattern"; break; >- case ItemType::ApplyFillPattern: ts << "apply-fill-pattern"; break; >-#endif >- case ItemType::ApplyDeviceScaleFactor: ts << "apply-device-scale-factor"; break; >- case ItemType::ClearShadow: ts << "clear-shadow"; break; >- } >- return ts; >-} >- >-TextStream& operator<<(TextStream& ts, const Item& item) >-{ >- TextStream::GroupScope group(ts); >- ts << item.type(); >- >- // FIXME: Make a macro which takes a macro for all these enumeration switches >- switch (item.type()) { >- case ItemType::Save: >- ts << downcast<Save>(item); >- break; >- case ItemType::Translate: >- ts << downcast<Translate>(item); >- break; >- case ItemType::Rotate: >- ts << downcast<Rotate>(item); >- break; >- case ItemType::Scale: >- ts << downcast<Scale>(item); >- break; >- case ItemType::ConcatenateCTM: >- ts << downcast<ConcatenateCTM>(item); >- break; >- case ItemType::SetState: >- ts << downcast<SetState>(item); >- break; >- case ItemType::SetLineCap: >- ts << downcast<SetLineCap>(item); >- break; >- case ItemType::SetLineDash: >- ts << downcast<SetLineDash>(item); >- break; >- case ItemType::SetLineJoin: >- ts << downcast<SetLineJoin>(item); >- break; >- case ItemType::SetMiterLimit: >- ts << downcast<SetMiterLimit>(item); >- break; >- case ItemType::Clip: >- ts << downcast<Clip>(item); >- break; >- case ItemType::ClipOut: >- ts << downcast<ClipOut>(item); >- break; >- case ItemType::ClipOutToPath: >- ts << downcast<ClipOutToPath>(item); >- break; >- case ItemType::ClipPath: >- ts << downcast<ClipPath>(item); >- break; >- case ItemType::DrawGlyphs: >- ts << downcast<DrawGlyphs>(item); >- break; >- case ItemType::DrawImage: >- ts << downcast<DrawImage>(item); >- break; >- case ItemType::DrawTiledImage: >- ts << downcast<DrawTiledImage>(item); >- break; >- case ItemType::DrawTiledScaledImage: >- ts << downcast<DrawTiledScaledImage>(item); >- break; >-#if USE(CG) || USE(CAIRO) >- case ItemType::DrawNativeImage: >- ts << downcast<DrawNativeImage>(item); >- break; >-#endif >- case ItemType::DrawPattern: >- ts << downcast<DrawPattern>(item); >- break; >- case ItemType::DrawRect: >- ts << downcast<DrawRect>(item); >- break; >- case ItemType::DrawLine: >- ts << downcast<DrawLine>(item); >- break; >- case ItemType::DrawLinesForText: >- ts << downcast<DrawLinesForText>(item); >- break; >- case ItemType::DrawLineForDocumentMarker: >- ts << downcast<DrawLineForDocumentMarker>(item); >- break; >- case ItemType::DrawEllipse: >- ts << downcast<DrawEllipse>(item); >- break; >- case ItemType::DrawPath: >- ts << downcast<DrawPath>(item); >- break; >- case ItemType::DrawFocusRingPath: >- ts << downcast<DrawFocusRingPath>(item); >- break; >- case ItemType::DrawFocusRingRects: >- ts << downcast<DrawFocusRingRects>(item); >- break; >- case ItemType::FillRect: >- ts << downcast<FillRect>(item); >- break; >- case ItemType::FillRectWithColor: >- ts << downcast<FillRectWithColor>(item); >- break; >- case ItemType::FillRectWithGradient: >- ts << downcast<FillRectWithGradient>(item); >- break; >- case ItemType::FillCompositedRect: >- ts << downcast<FillCompositedRect>(item); >- break; >- case ItemType::FillRoundedRect: >- ts << downcast<FillRoundedRect>(item); >- break; >- case ItemType::FillRectWithRoundedHole: >- ts << downcast<FillRectWithRoundedHole>(item); >- break; >- case ItemType::FillPath: >- ts << downcast<FillPath>(item); >- break; >- case ItemType::FillEllipse: >- ts << downcast<FillEllipse>(item); >- break; >- case ItemType::StrokeRect: >- ts << downcast<StrokeRect>(item); >- break; >- case ItemType::StrokePath: >- ts << downcast<StrokePath>(item); >- break; >- case ItemType::StrokeEllipse: >- ts << downcast<StrokeEllipse>(item); >- break; >- case ItemType::ClearRect: >- ts << downcast<ClearRect>(item); >- break; >- case ItemType::BeginTransparencyLayer: >- ts << downcast<BeginTransparencyLayer>(item); >- break; >- case ItemType::ApplyDeviceScaleFactor: >- ts << downcast<ApplyDeviceScaleFactor>(item); >- break; >- >- // Items with no additional data. >- case ItemType::Restore: >- case ItemType::EndTransparencyLayer: >-#if USE(CG) >- case ItemType::ApplyStrokePattern: >- case ItemType::ApplyFillPattern: >-#endif >- case ItemType::ClearShadow: >- break; >- } >- return ts; >+ ASSERT(index < itemDescriptor(m_type).argumentsNames.size()); >+ return itemDescriptor(m_type).argumentsNames[index]; > } > > } >Index: Source/WebCore/platform/graphics/displaylists/DisplayListItems.h >=================================================================== >--- Source/WebCore/platform/graphics/displaylists/DisplayListItems.h (revision 234218) >+++ Source/WebCore/platform/graphics/displaylists/DisplayListItems.h (working copy) >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2015 Apple Inc. All rights reserved. >+ * Copyright (C) 2015-2018 Apple Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -34,29 +34,24 @@ > #include "Image.h" > #include <wtf/RefCounted.h> > #include <wtf/TypeCasts.h> >+#include <wtf/text/TextStream.h> > > #if USE(CG) > #include "GraphicsContextPlatformPrivateCG.h" > #endif > >-namespace WTF { >-class TextStream; >-} >- > namespace WebCore { >- >-struct ImagePaintingOptions; >- > namespace DisplayList { > > enum class ItemType { >- Save, >+ Min = 0, >+ Save = Min, > Restore, >+ SetState, > Translate, > Rotate, > Scale, > ConcatenateCTM, >- SetState, > SetLineCap, > SetLineDash, > SetLineJoin, >@@ -66,13 +61,17 @@ enum class ItemType { > ClipOut, > ClipOutToPath, > ClipPath, >+ ApplyStrokePattern, >+ ApplyFillPattern, >+ ApplyDeviceScaleFactor, >+ >+ BeginTransparencyLayer, >+ EndTransparencyLayer, > DrawGlyphs, > DrawImage, > DrawTiledImage, > DrawTiledScaledImage, >-#if USE(CG) || USE(CAIRO) > DrawNativeImage, >-#endif > DrawPattern, > DrawRect, > DrawLine, >@@ -94,1295 +93,873 @@ enum class ItemType { > StrokePath, > StrokeEllipse, > ClearRect, >- BeginTransparencyLayer, >- EndTransparencyLayer, >-#if USE(CG) >- ApplyStrokePattern, // FIXME: should not be a recorded item. >- ApplyFillPattern, // FIXME: should not be a recorded item. >-#endif >- ApplyDeviceScaleFactor, >+ Max > }; > > class Item : public RefCounted<Item> { > public: >- Item() = delete; >- >- Item(ItemType type) >- : m_type(type) >- { >- } >- > virtual ~Item() = default; > >- ItemType type() const >- { >- return m_type; >- } >- > virtual void apply(GraphicsContext&) const = 0; > >- static constexpr bool isDisplayListItem = true; >+ virtual bool isGeometryItem() const { return false; } >+ virtual size_t sizeInBytes() const = 0; > >- virtual bool isDrawingItem() const { return false; } >- >- // A state item is one preserved by Save/Restore. >- bool isStateItem() const >+ virtual void dump(WTF::TextStream& ts) const > { >- return isStateItemType(m_type); >+ ts << name(); > } > >- static bool isStateItemType(ItemType itemType) >+ ItemType type() const { return m_type; } >+ WTF::CString dump() const; >+ >+protected: >+ Item(ItemType type) >+ : m_type(type) > { >- switch (itemType) { >- case ItemType:: Translate: >- case ItemType:: Rotate: >- case ItemType:: Scale: >- case ItemType:: ConcatenateCTM: >- case ItemType:: SetState: >- case ItemType:: SetLineCap: >- case ItemType:: SetLineDash: >- case ItemType:: SetLineJoin: >- case ItemType:: SetMiterLimit: >- case ItemType:: ClearShadow: >- return true; >- default: >- return false; >- } >- return false; > } > >-#if !defined(NDEBUG) || !LOG_DISABLED >- WTF::CString description() const; >-#endif >- static size_t sizeInBytes(const Item&); >+ String name() const; >+ String argumentName(size_t index) const; > >-private: > ItemType m_type; > }; > >-class DrawingItem : public Item { >+class GeometryItem : public Item { > public: >- DrawingItem(ItemType type) >- : Item(type) >- { >- } >- >- void setExtent(const FloatRect& r) { m_extent = r; } >- const FloatRect& extent() const { return m_extent.value(); } >- > bool extentKnown() const { return static_cast<bool>(m_extent); } > >- // Return bounds of this drawing operation in local coordinates. >- // Does not include effets of transform, shadow etc in the state. >- virtual std::optional<FloatRect> localBounds(const GraphicsContext&) const { return std::nullopt; } >- >-private: >- bool isDrawingItem() const override { return true; } >- >- std::optional<FloatRect> m_extent; // In base coordinates, taking shadows and transforms into account. >-}; >- >-class Save : public Item { >-public: >- static Ref<Save> create() >+ void setExtent(const FloatRect& extent) { m_extent = extent; } >+ const FloatRect extent() const > { >- return adoptRef(*new Save); >+ return m_extent.value_or(FloatRect()); > } > >- // Index in the display list of the corresponding Restore item. 0 if unmatched. >- size_t restoreIndex() const { return m_restoreIndex; } >- void setRestoreIndex(size_t index) { m_restoreIndex = index; } >- >-private: >- Save() >- : Item(ItemType::Save) >- { >- } >- >- void apply(GraphicsContext&) const override; >+ virtual const std::optional<FloatRect> localBounds(const GraphicsContext&) const { return std::nullopt; } > >- size_t m_restoreIndex { 0 }; >-}; >- >-class Restore : public Item { >-public: >- static Ref<Restore> create() >+protected: >+ GeometryItem(ItemType type) >+ : Item(type) > { >- return adoptRef(*new Restore); > } > >-private: >- Restore() >- : Item(ItemType::Restore) >+ void dump(WTF::TextStream& ts) const override > { >+ Item::dump(ts); >+ ts.startGroup(); >+ ts << "extent "; >+ if (extentKnown()) >+ ts << extent(); >+ else >+ ts << "unknown"; >+ ts.endGroup(); > } > >- void apply(GraphicsContext&) const override; >+ std::optional<FloatRect> m_extent; > }; > >-class Translate : public Item { >-public: >- static Ref<Translate> create(float x, float y) >+template <typename Applier, Applier applier, class... Arguments> >+class GraphicsApplier { >+protected: >+ GraphicsApplier(Arguments... arguments) >+ : m_arguments(std::forward<Arguments>(arguments)...) > { >- return adoptRef(*new Translate(x, y)); > } > >- float x() const { return m_x; } >- float y() const { return m_y; } >- >-private: >- Translate(float x, float y) >- : Item(ItemType::Translate) >- , m_x(x) >- , m_y(y) >+ template< std::size_t I> >+ const auto& argument() const > { >+ return std::get<I>(m_arguments); > } > >- void apply(GraphicsContext&) const override; >- >- float m_x; >- float m_y; >-}; >- >-class Rotate : public Item { >-public: >- static Ref<Rotate> create(float angleInRadians) >+ void apply(GraphicsContext& context) const > { >- return adoptRef(*new Rotate(angleInRadians)); >+ apply(context, std::index_sequence_for<Arguments...>()); > } > >- float angle() const { return m_angle; } >- >-private: >- Rotate(float angle) >- : Item(ItemType::Rotate) >- , m_angle(angle) >+ template <typename Functor> >+ void iterateOverArguments(Functor&& functor) const > { >+ iterateOverArguments(WTFMove(functor), std::index_sequence_for<Arguments...>()); > } > >- void apply(GraphicsContext&) const override; >- >- float m_angle; // In radians. >-}; >- >-class Scale : public Item { >-public: >- static Ref<Scale> create(const FloatSize& size) >+private: >+ template<std::size_t... Indices> >+ void apply(GraphicsContext& context, std::index_sequence<Indices...>) const > { >- return adoptRef(*new Scale(size)); >+ (context.*applier)(std::get<Indices>(m_arguments)...); > } > >- const FloatSize& amount() const { return m_size; } >- >-private: >- Scale(const FloatSize& size) >- : Item(ItemType::Scale) >- , m_size(size) >+ template<typename Functor, std::size_t... Indices> >+ void iterateOverArguments(Functor&& functor, std::index_sequence<Indices...>) const > { >+ using swallow = int[]; >+ (void)swallow { 1, (functor(Indices, std::get<Indices>(m_arguments)), int { })... }; > } > >- void apply(GraphicsContext&) const override; >- >- FloatSize m_size; >+ std::tuple<Arguments...> m_arguments; > }; > >-class ConcatenateCTM : public Item { >+template <ItemType itemType, typename Applier, Applier applier, class... Arguments> >+class SettingItem : public Item, public GraphicsApplier<Applier, applier, Arguments...> { > public: >- static Ref<ConcatenateCTM> create(const AffineTransform& matrix) >+ static Ref<Item> create(Arguments... arguments) > { >- return adoptRef(*new ConcatenateCTM(matrix)); >+ return adoptRef(*new SettingItem(arguments...)); > } > >- const AffineTransform& transform() const { return m_transform; } >- >-private: >- ConcatenateCTM(const AffineTransform&); >- >- void apply(GraphicsContext&) const override; >- >- AffineTransform m_transform; >-}; >- >-class SetState : public Item { >-public: >- static Ref<SetState> create(const GraphicsContextState& state, GraphicsContextState::StateChangeFlags flags) >+ template<typename T> >+ static Ref<Item> create(Arguments... arguments) > { >- return adoptRef(*new SetState(state, flags)); >+ static_assert(std::is_base_of<Self, T>::value, "This function should create classes from SettingItem."); >+ return adoptRef(*new T(std::forward<Arguments>(arguments)...)); > } >- >- const GraphicsContextStateChange& state() const { return m_state; } > >- void accumulate(const GraphicsContextState&, GraphicsContextState::StateChangeFlags); >+ using GraphicsApplierBase = GraphicsApplier<Applier, applier, Arguments...>; > >- void accumulate(GraphicsContextState&) const; >- >- static void applyState(GraphicsContext&, const GraphicsContextState&, GraphicsContextState::StateChangeFlags); >- >- static void dumpStateChanges(WTF::TextStream&, const GraphicsContextState&, GraphicsContextState::StateChangeFlags); >-private: >- SetState(const GraphicsContextState& state, GraphicsContextState::StateChangeFlags flags) >- : Item(ItemType::SetState) >- , m_state(state, flags) >+ SettingItem(Arguments... arguments) >+ : Item(itemType) >+ , GraphicsApplierBase(std::forward<Arguments>(arguments)...) > { > } > >- void apply(GraphicsContext&) const override; >- >- GraphicsContextStateChange m_state; >-}; >- >-class SetLineCap : public Item { >-public: >- static Ref<SetLineCap> create(LineCap lineCap) >+ void dump(WTF::TextStream& ts) const override > { >- return adoptRef(*new SetLineCap(lineCap)); >+ Item::dump(ts); >+ GraphicsApplierBase::iterateOverArguments([this, &ts](size_t index, const auto& argumentValue) { >+ ts.dumpProperty(this->argumentName(index), argumentValue); >+ }); > } >- >- LineCap lineCap() const { return m_lineCap; } > > private: >- SetLineCap(LineCap lineCap) >- : Item(ItemType::SetLineCap) >- , m_lineCap(lineCap) >+ using Self = SettingItem<itemType, Applier, applier, Arguments...>; >+ >+ void apply(GraphicsContext& context) const override > { >+ GraphicsApplierBase::apply(context); > } > >- void apply(GraphicsContext&) const override; >- >- LineCap m_lineCap; >+ size_t sizeInBytes() const override { return sizeof(*this); } > }; > >-class SetLineDash : public Item { >+template <ItemType itemType, typename Applier, Applier applier, class... Arguments> >+class DrawingItem : public GeometryItem, public GraphicsApplier<Applier, applier, Arguments...> { > public: >- static Ref<SetLineDash> create(const DashArray& dashArray, float dashOffset) >+ static Ref<Item> create(Arguments... arguments) > { >- return adoptRef(*new SetLineDash(dashArray, dashOffset)); >+ return adoptRef(*new DrawingItem(std::forward<Arguments>(arguments)...)); > } > >- const DashArray& dashArray() const { return m_dashArray; } >- float dashOffset() const { return m_dashOffset; } >- >-private: >- SetLineDash(const DashArray& dashArray, float dashOffset) >- : Item(ItemType::SetLineDash) >- , m_dashArray(dashArray) >- , m_dashOffset(dashOffset) >+ template<typename T> >+ static Ref<Item> create(Arguments... arguments) > { >+ static_assert(std::is_base_of<Self, T>::value, "This function should create classes from DrawingItem."); >+ return adoptRef(*new T(std::forward<Arguments>(arguments)...)); > } > >- void apply(GraphicsContext&) const override; >+ using GraphicsApplierBase = GraphicsApplier<Applier, applier, Arguments...>; > >- DashArray m_dashArray; >- float m_dashOffset; >-}; >+ // Should match RenderTheme::platformFocusRingWidth() >+ constexpr static float const s_platformFocusRingWidth = 3; > >-class SetLineJoin : public Item { >-public: >- static Ref<SetLineJoin> create(LineJoin lineJoin) >+ DrawingItem(Arguments... arguments) >+ : GeometryItem(itemType) >+ , GraphicsApplierBase(std::forward<Arguments>(arguments)...) > { >- return adoptRef(*new SetLineJoin(lineJoin)); > } >- >- LineJoin lineJoin() const { return m_lineJoin; } > > private: >- SetLineJoin(LineJoin lineJoin) >- : Item(ItemType::SetLineJoin) >- , m_lineJoin(lineJoin) >- { >- } >- >- void apply(GraphicsContext&) const override; >+ using Self = DrawingItem<itemType, Applier, applier, Arguments...>; > >- LineJoin m_lineJoin; >-}; >- >-class SetMiterLimit : public Item { >-public: >- static Ref<SetMiterLimit> create(float limit) >+ void apply(GraphicsContext& context) const override > { >- return adoptRef(*new SetMiterLimit(limit)); >+ GraphicsApplierBase::apply(context); > } > >- float miterLimit() const { return m_miterLimit; } >+ bool isGeometryItem() const override { return true; } >+ size_t sizeInBytes() const override { return sizeof(*this); } > >-private: >- SetMiterLimit(float miterLimit) >- : Item(ItemType::SetMiterLimit) >- , m_miterLimit(miterLimit) >+ void dump(WTF::TextStream& ts) const override > { >+ GeometryItem::dump(ts); >+ GraphicsApplierBase::iterateOverArguments([this, &ts](size_t index, const auto& argumentValue) { >+ ts.dumpProperty(this->argumentName(index), argumentValue); >+ }); > } >- >- void apply(GraphicsContext&) const override; >- >- float m_miterLimit; > }; > >-class ClearShadow : public Item { >-public: >- static Ref<ClearShadow> create() >- { >- return adoptRef(*new ClearShadow); >- } >+using SaveBase = SettingItem< >+ ItemType::Save, >+ void (GraphicsContext::*)(), >+ &GraphicsContext::save >+>; > >-private: >- ClearShadow() >- : Item(ItemType::ClearShadow) >- { >- } >- >- void apply(GraphicsContext&) const override; >-}; >- >-// FIXME: treat as DrawingItem? >-class Clip : public Item { >+class Save : public SaveBase { > public: >- static Ref<Clip> create(const FloatRect& rect) >- { >- return adoptRef(*new Clip(rect)); >- } >+ constexpr static auto create = SaveBase::create<Save>; > >- FloatRect rect() const { return m_rect; } >+ // Index in the display list of the corresponding Restore item. 0 if unmatched. >+ size_t restoreIndex() const { return m_restoreIndex; } >+ void setRestoreIndex(size_t index) { m_restoreIndex = index; } > > private: >- Clip(const FloatRect& rect) >- : Item(ItemType::Clip) >- , m_rect(rect) >+ using SaveBase::SaveBase; >+ >+ void dump(WTF::TextStream& ts) const override > { >+ SaveBase::dump(ts); >+ ts.dumpProperty("restore-index", m_restoreIndex); > } > >- void apply(GraphicsContext&) const override; >- >- FloatRect m_rect; >+ size_t m_restoreIndex { 0 }; > }; > >-class ClipOut : public Item { >-public: >- static Ref<ClipOut> create(const FloatRect& rect) >- { >- return adoptRef(*new ClipOut(rect)); >- } >+using Restore = SettingItem< >+ ItemType::Restore, >+ void (GraphicsContext::*)(), >+ &GraphicsContext::restore >+>; >+ >+using SetStateBase = SettingItem< >+ ItemType::SetState, >+ void (GraphicsContext::*)(const GraphicsContextStateChange&), >+ &GraphicsContext::applyStateChange, >+ GraphicsContextStateChange >+>; >+ >+class SetState : public SetStateBase { >+public: >+ constexpr static auto create = SetStateBase::create<SetState>; >+ using SetStateBase::SetStateBase; >+ const GraphicsContextStateChange& state() const { return argument<0>(); } >+}; >+ >+using Translate = SettingItem< >+ ItemType::Translate, >+ void (GraphicsContext::*)(float, float), >+ &GraphicsContext::translate, >+ float, float >+>; >+ >+using Rotate = SettingItem< >+ ItemType::Rotate, >+ void (GraphicsContext::*)(float), >+ &GraphicsContext::rotate, >+ float >+>; >+ >+using Scale = SettingItem< >+ ItemType::Scale, >+ void (GraphicsContext::*)(const FloatSize&), >+ &GraphicsContext::scale, >+ FloatSize >+>; >+ >+using ConcatenateCTM = SettingItem< >+ ItemType::ConcatenateCTM, >+ void (GraphicsContext::*)(const AffineTransform&), >+ &GraphicsContext::concatCTM, >+ AffineTransform >+>; >+ >+using SetLineCap = SettingItem< >+ ItemType::SetLineCap, >+ void (GraphicsContext::*)(LineCap), >+ &GraphicsContext::setLineCap, >+ LineCap >+>; >+ >+using SetLineDash = SettingItem< >+ ItemType::SetLineDash, >+ void (GraphicsContext::*)(const DashArray&, float), >+ &GraphicsContext::setLineDash, >+ DashArray, float >+>; >+ >+using SetLineJoin = SettingItem< >+ ItemType::SetLineJoin, >+ void (GraphicsContext::*)(LineJoin), >+ &GraphicsContext::setLineJoin, >+ LineJoin >+>; >+ >+using SetMiterLimit = SettingItem< >+ ItemType::SetMiterLimit, >+ void (GraphicsContext::*)(float), >+ &GraphicsContext::setMiterLimit, >+ float >+>; >+ >+using ClearShadow = SettingItem< >+ ItemType::ClearShadow, >+ void (GraphicsContext::*)(), >+ &GraphicsContext::clearShadow >+>; >+ >+using Clip = SettingItem< >+ ItemType::Clip, >+ void (GraphicsContext::*)(const FloatRect&), >+ &GraphicsContext::clip, >+ FloatRect >+>; >+ >+using ClipOut = SettingItem< >+ ItemType::ClipOut, >+ void (GraphicsContext::*)(const FloatRect&), >+ &GraphicsContext::clipOut, >+ FloatRect >+>; >+ >+using ClipOutToPath = SettingItem< >+ ItemType::ClipOutToPath, >+ void (GraphicsContext::*)(const Path&), >+ &GraphicsContext::clipOut, >+ const Path >+>; >+ >+using ClipPath = SettingItem< >+ ItemType::ClipOutToPath, >+ void (GraphicsContext::*)(const Path&, WindRule), >+ &GraphicsContext::clipPath, >+ const Path, WindRule >+>; > >- FloatRect rect() const { return m_rect; } >+#if USE(CG) >+using ApplyStrokePattern = SettingItem< >+ ItemType::ApplyStrokePattern, >+ void (GraphicsContext::*)(), >+ &GraphicsContext::applyStrokePattern >+>; >+ >+using ApplyFillPattern = SettingItem< >+ ItemType::ApplyFillPattern, >+ void (GraphicsContext::*)(), >+ &GraphicsContext::applyFillPattern >+>; >+#endif > >-private: >- ClipOut(const FloatRect& rect) >- : Item(ItemType::ClipOut) >- , m_rect(rect) >- { >- } >+using ApplyDeviceScaleFactor = SettingItem< >+ ItemType::ApplyDeviceScaleFactor, >+ void (GraphicsContext::*)(float), >+ &GraphicsContext::applyDeviceScaleFactor, >+ float >+>; > >- void apply(GraphicsContext&) const override; >+// Is DrawingItem because the size of the transparency layer is implicitly the clip bounds. >+using BeginTransparencyLayer = DrawingItem< >+ ItemType::BeginTransparencyLayer, >+ void (GraphicsContext::*)(float), >+ &GraphicsContext::beginTransparencyLayer, >+ float >+>; > >- FloatRect m_rect; >-}; >+using EndTransparencyLayer = DrawingItem< >+ ItemType::EndTransparencyLayer, >+ void (GraphicsContext::*)(), >+ &GraphicsContext::endTransparencyLayer >+>; > >-class ClipOutToPath : public Item { >+using DrawGlyphsBase = DrawingItem< >+ ItemType::DrawGlyphs, >+ void (GraphicsContext::*)(const Font&, const GlyphBuffer&, unsigned, unsigned, const FloatPoint&, FontSmoothingMode), >+ &GraphicsContext::drawGlyphs, >+ Ref<const Font>, GlyphBuffer, unsigned, unsigned, FloatPoint, FontSmoothingMode >+>; >+ >+class DrawGlyphs : public DrawGlyphsBase { > public: >- static Ref<ClipOutToPath> create(const Path& path) >+ static Ref<Item> create(Ref<const Font>&& font, const GlyphBuffer& buffer, unsigned from, unsigned numGlyphs, const FloatPoint& point, FontSmoothingMode fontSmoothing) > { >- return adoptRef(*new ClipOutToPath(path)); >+ auto subGlyphBuffer = DrawGlyphs::subGlyphBuffer(font.ptr(), buffer, from, numGlyphs); >+ return DrawGlyphsBase::create(WTFMove(font), WTFMove(subGlyphBuffer), 0, numGlyphs, point, fontSmoothing); > } > >- const Path& path() const { return m_path; } >- > private: >- ClipOutToPath(const Path& path) >- : Item(ItemType::ClipOutToPath) >- , m_path(path) >- { >- } >- >- void apply(GraphicsContext&) const override; >- >- const Path m_path; >-}; >+ using DrawGlyphsBase::DrawGlyphsBase; > >-class ClipPath : public Item { >-public: >- static Ref<ClipPath> create(const Path& path, WindRule windRule) >+ static GlyphBuffer subGlyphBuffer(const Font* font, const GlyphBuffer& buffer, unsigned from, unsigned numGlyphs) > { >- return adoptRef(*new ClipPath(path, windRule)); >+ GlyphBuffer subBuffer; >+ const auto* glyphs = buffer.glyphs(from); >+ const auto* advances = buffer.advances(from); >+ for (size_t i = 0; i < numGlyphs; ++i) >+ subBuffer.add(glyphs[i], font, advances[i]); >+ return subBuffer; > } > >- const Path& path() const { return m_path; } >- WindRule windRule() const { return m_windRule; } >- >-private: >- ClipPath(const Path& path, WindRule windRule) >- : Item(ItemType::ClipPath) >- , m_path(path) >- , m_windRule(windRule) >+ const std::optional<FloatRect> localBounds(const GraphicsContext&) const override > { >- } >- >- void apply(GraphicsContext&) const override; >+ const auto& font = argument<0>(); >+ float ascent = font->fontMetrics().floatAscent(); >+ float descent = font->fontMetrics().floatDescent(); > >- const Path m_path; >- WindRule m_windRule; >-}; >+ const auto& glyphBuffer = argument<1>(); >+ size_t numGlyphs = glyphBuffer.size(); >+ auto current = argument<4>(); > >-class DrawGlyphs : public DrawingItem { >-public: >- static Ref<DrawGlyphs> create(const Font& font, const GlyphBufferGlyph* glyphs, const GlyphBufferAdvance* advances, unsigned count, const FloatPoint& blockLocation, const FloatSize& localAnchor, FontSmoothingMode smoothingMode) >- { >- return adoptRef(*new DrawGlyphs(font, glyphs, advances, count, blockLocation, localAnchor, smoothingMode)); >+ FloatRect bounds; >+ for (size_t i = 0; i < numGlyphs; ++i) { >+ GlyphBufferAdvance advance = glyphBuffer.advanceAt(i); >+ FloatRect glyphRect = FloatRect(current.x(), current.y() - ascent, advance.width(), ascent + descent); >+ bounds.unite(glyphRect); >+ current.move(advance.width(), advance.height()); >+ } >+ return bounds; > } >- >- const FloatPoint& blockLocation() const { return m_blockLocation; } >- void setBlockLocation(const FloatPoint& blockLocation) { m_blockLocation = blockLocation; } >- >- const FloatSize& localAnchor() const { return m_localAnchor; } >- >- FloatPoint anchorPoint() const { return m_blockLocation + m_localAnchor; } >- >- const Vector<GlyphBufferGlyph, 128>& glyphs() const { return m_glyphs; } >- >-private: >- DrawGlyphs(const Font&, const GlyphBufferGlyph*, const GlyphBufferAdvance*, unsigned count, const FloatPoint& blockLocation, const FloatSize& localAnchor, FontSmoothingMode); >- >- void computeBounds(); >- >- void apply(GraphicsContext&) const override; >- >- std::optional<FloatRect> localBounds(const GraphicsContext&) const override; >- >- GlyphBuffer generateGlyphBuffer() const; >- >- Ref<Font> m_font; >- Vector<GlyphBufferGlyph, 128> m_glyphs; >- Vector<GlyphBufferAdvance, 128> m_advances; >- FloatRect m_bounds; >- FloatPoint m_blockLocation; >- FloatSize m_localAnchor; >- FontSmoothingMode m_smoothingMode; > }; > >-class DrawImage : public DrawingItem { >-public: >- static Ref<DrawImage> create(Image& image, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& imagePaintingOptions) >- { >- return adoptRef(*new DrawImage(image, destination, source, imagePaintingOptions)); >- } >- >- const Image& image() const { return m_image.get(); } >- FloatRect source() const { return m_source; } >- FloatRect destination() const { return m_destination; } >+using DrawImageBase = DrawingItem< >+ ItemType::DrawImage, >+ ImageDrawResult (GraphicsContext::*)(Image&, const FloatRect&, const FloatRect&, const ImagePaintingOptions&), >+ &GraphicsContext::drawImage, >+ Ref<Image>, FloatRect, FloatRect, ImagePaintingOptions >+>; > >+class DrawImage : public DrawImageBase { >+public: >+ constexpr static auto create = DrawImageBase::create<DrawImage>; >+ using DrawImageBase::DrawImageBase; > private: >- DrawImage(Image&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions&); >- >- void apply(GraphicsContext&) const override; >- >- std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_destination; } >- >- mutable Ref<Image> m_image; // FIXME: Drawing images can cause their animations to progress. This shouldn't have to be mutable. >- FloatRect m_destination; >- FloatRect m_source; >- ImagePaintingOptions m_imagePaintingOptions; >+ const std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return argument<1>(); } > }; > >-class DrawTiledImage : public DrawingItem { >-public: >- static Ref<DrawTiledImage> create(Image& image, const FloatRect& destination, const FloatPoint& source, const FloatSize& tileSize, const FloatSize& spacing, const ImagePaintingOptions& imagePaintingOptions) >- { >- return adoptRef(*new DrawTiledImage(image, destination, source, tileSize, spacing, imagePaintingOptions)); >- } >- >- const Image& image() const { return m_image.get(); } >- FloatPoint source() const { return m_source; } >- FloatRect destination() const { return m_destination; } >- >- FloatSize tileSize() const { return m_tileSize; } >- FloatSize spacing() const { return m_spacing; } >+using DrawTiledImageBase = DrawingItem< >+ ItemType::DrawTiledImage, >+ ImageDrawResult (GraphicsContext::*)(Image&, const FloatRect&, const FloatPoint&, const FloatSize&, const FloatSize&, const ImagePaintingOptions&), >+ &GraphicsContext::drawTiledImage, >+ Ref<Image>, FloatRect, FloatPoint, FloatSize, FloatSize, ImagePaintingOptions >+>; > >+class DrawTiledImage : public DrawTiledImageBase { >+public: >+ constexpr static auto create = DrawTiledImageBase::create<DrawTiledImage>; >+ using DrawTiledImageBase::DrawTiledImageBase; > private: >- DrawTiledImage(Image&, const FloatRect& destination, const FloatPoint& source, const FloatSize& tileSize, const FloatSize& spacing, const ImagePaintingOptions&); >- >- void apply(GraphicsContext&) const override; >- >- std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_destination; } >- >- mutable Ref<Image> m_image; // FIXME: Drawing images can cause their animations to progress. This shouldn't have to be mutable. >- FloatRect m_destination; >- FloatPoint m_source; >- FloatSize m_tileSize; >- FloatSize m_spacing; >- ImagePaintingOptions m_imagePaintingOptions; >+ const std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return argument<1>(); } > }; > >-class DrawTiledScaledImage : public DrawingItem { >-public: >- static Ref<DrawTiledScaledImage> create(Image& image, const FloatRect& destination, const FloatRect& source, const FloatSize& tileScaleFactor, Image::TileRule hRule, Image::TileRule vRule, const ImagePaintingOptions& imagePaintingOptions) >- { >- return adoptRef(*new DrawTiledScaledImage(image, destination, source, tileScaleFactor, hRule, vRule, imagePaintingOptions)); >- } >- >- const Image& image() const { return m_image.get(); } >- FloatRect source() const { return m_source; } >- FloatRect destination() const { return m_destination; } >+using DrawTiledScaledImageBase = DrawingItem< >+ ItemType::DrawTiledScaledImage, >+ ImageDrawResult (GraphicsContext::*)(Image&, const FloatRect&, const FloatRect&, const FloatSize&, Image::TileRule, Image::TileRule, const ImagePaintingOptions&), >+ &GraphicsContext::drawTiledImage, >+ Ref<Image>, FloatRect, FloatRect, FloatSize, Image::TileRule, Image::TileRule, ImagePaintingOptions >+>; > >+class DrawTiledScaledImage : public DrawTiledScaledImageBase { >+public: >+ constexpr static auto create = DrawTiledScaledImageBase::create<DrawTiledScaledImage>; >+ using DrawTiledScaledImageBase::DrawTiledScaledImageBase; > private: >- DrawTiledScaledImage(Image&, const FloatRect& destination, const FloatRect& source, const FloatSize& tileScaleFactor, Image::TileRule hRule, Image::TileRule vRule, const ImagePaintingOptions&); >- >- void apply(GraphicsContext&) const override; >- >- std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_destination; } >- >- mutable Ref<Image> m_image; // FIXME: Drawing images can cause their animations to progress. This shouldn't have to be mutable. >- FloatRect m_destination; >- FloatRect m_source; >- FloatSize m_tileScaleFactor; >- Image::TileRule m_hRule; >- Image::TileRule m_vRule; >- ImagePaintingOptions m_imagePaintingOptions; >+ const std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return argument<1>(); } > }; > >-#if USE(CG) || USE(CAIRO) >-class DrawNativeImage : public DrawingItem { >-public: >- static Ref<DrawNativeImage> create(const NativeImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator op, BlendMode blendMode, ImageOrientation orientation) >- { >- return adoptRef(*new DrawNativeImage(image, imageSize, destRect, srcRect, op, blendMode, orientation)); >- } >- >- FloatRect source() const { return m_srcRect; } >- FloatRect destination() const { return m_destination; } >+#if USE(CG) || USE(DIRECT2D) || USE(CAIRO) >+using DrawNativeImageBase = DrawingItem< >+ ItemType::DrawNativeImage, >+ void (GraphicsContext::*)(const NativeImagePtr&, const FloatSize&, const FloatRect&, const FloatRect&, CompositeOperator, BlendMode, ImageOrientation), >+ &GraphicsContext::drawNativeImage, >+ NativeImagePtr, FloatSize, FloatRect, FloatRect, CompositeOperator, BlendMode, ImageOrientation >+>; > >+class DrawNativeImage : public DrawNativeImageBase { >+public: >+ constexpr static auto create = DrawNativeImageBase::create<DrawNativeImage>; >+ using DrawNativeImageBase::DrawNativeImageBase; > private: >- DrawNativeImage(const NativeImagePtr&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator, BlendMode, ImageOrientation); >- >- void apply(GraphicsContext&) const override; >- >- std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_destination; } >- >-#if USE(CG) >- RetainPtr<CGImageRef> m_image; >-#endif >- FloatSize m_imageSize; >- FloatRect m_destination; >- FloatRect m_srcRect; >-#if USE(CG) >- CompositeOperator m_op; >- BlendMode m_blendMode; >-#endif >- ImageOrientation m_orientation; >+ const std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return argument<2>(); } > }; > #endif > >-class DrawPattern : public DrawingItem { >-public: >- static Ref<DrawPattern> create(Image& image, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, CompositeOperator op, BlendMode blendMode) >- { >- return adoptRef(*new DrawPattern(image, destRect, tileRect, patternTransform, phase, spacing, op, blendMode)); >- } >- >- const Image& image() const { return m_image.get(); } >- const AffineTransform& patternTransform() const { return m_patternTransform; } >- FloatRect tileRect() const { return m_tileRect; } >- FloatRect destRect() const { return m_destination; } >- FloatPoint phase() const { return m_phase; } >- FloatSize spacing() const { return m_spacing; } >- >-private: >- DrawPattern(Image&, const FloatRect& destRect, const FloatRect& srcRect, const AffineTransform&, const FloatPoint& phase, const FloatSize& spacing, CompositeOperator, BlendMode = BlendModeNormal); >- >- void apply(GraphicsContext&) const override; >+using DrawPatternBase = DrawingItem< >+ ItemType::DrawPattern, >+ void (GraphicsContext::*)(Image&, const FloatRect&, const FloatRect&, const AffineTransform&, const FloatPoint&, const FloatSize&, CompositeOperator, BlendMode), >+ &GraphicsContext::drawPattern, >+ Ref<Image>, FloatRect, FloatRect, AffineTransform, FloatPoint, FloatSize, CompositeOperator, BlendMode >+>; > >- std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_destination; } >- >- mutable Ref<Image> m_image; // FIXME: Drawing images can cause their animations to progress. This shouldn't have to be mutable. >- AffineTransform m_patternTransform; >- FloatRect m_tileRect; >- FloatRect m_destination; >- FloatPoint m_phase; >- FloatSize m_spacing; >- CompositeOperator m_op; >- BlendMode m_blendMode; >-}; >- >-// Is DrawingItem because the size of the transparency layer is implicitly the clip bounds. >-class BeginTransparencyLayer : public DrawingItem { >+class DrawPattern : public DrawPatternBase { > public: >- static Ref<BeginTransparencyLayer> create(float opacity) >- { >- return adoptRef(*new BeginTransparencyLayer(opacity)); >- } >- >- float opacity() const { return m_opacity; } >- >+ constexpr static auto create = DrawPatternBase::create<DrawPattern>; >+ using DrawPatternBase::DrawPatternBase; > private: >- BeginTransparencyLayer(float opacity) >- : DrawingItem(ItemType::BeginTransparencyLayer) >- , m_opacity(opacity) >- { >- } >- >- void apply(GraphicsContext&) const override; >- >- float m_opacity; >+ const std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return argument<1>(); } > }; > >-class EndTransparencyLayer : public DrawingItem { >-public: >- static Ref<EndTransparencyLayer> create() >- { >- return adoptRef(*new EndTransparencyLayer); >- } >- >-private: >- EndTransparencyLayer() >- : DrawingItem(ItemType::EndTransparencyLayer) >- { >- } >- >- void apply(GraphicsContext&) const override; >-}; >+using DrawRectBase = DrawingItem<ItemType::DrawRect, void (GraphicsContext::*)(const FloatRect&, float), &GraphicsContext::drawRect, FloatRect, float>; > >-class DrawRect : public DrawingItem { >+class DrawRect : public DrawRectBase { > public: >- static Ref<DrawRect> create(const FloatRect& rect, float borderThickness) >- { >- return adoptRef(*new DrawRect(rect, borderThickness)); >- } >- >- FloatRect rect() const { return m_rect; } >- float borderThickness() const { return m_borderThickness; } >- >+ constexpr static auto create = DrawRectBase::create<DrawRect>; >+ using DrawRectBase::DrawRectBase; > private: >- DrawRect(const FloatRect& rect, float borderThickness) >- : DrawingItem(ItemType::DrawRect) >- , m_rect(rect) >- , m_borderThickness(borderThickness) >- { >- } >- >- void apply(GraphicsContext&) const override; >- std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_rect; } >- >- FloatRect m_rect; >- float m_borderThickness; >+ const std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return argument<0>(); } > }; > >-class DrawLine : public DrawingItem { >-public: >- static Ref<DrawLine> create(const FloatPoint& point1, const FloatPoint& point2) >- { >- return adoptRef(*new DrawLine(point1, point2)); >- } >- >- FloatPoint point1() const { return m_point1; } >- FloatPoint point2() const { return m_point2; } >- >-private: >- DrawLine(const FloatPoint& point1, const FloatPoint& point2) >- : DrawingItem(ItemType::DrawLine) >- , m_point1(point1) >- , m_point2(point2) >- { >- } >- >- void apply(GraphicsContext&) const override; >- std::optional<FloatRect> localBounds(const GraphicsContext&) const override; >- >- FloatPoint m_point1; >- FloatPoint m_point2; >-}; >+using DrawLineBase = DrawingItem< >+ ItemType::DrawLine, >+ void (GraphicsContext::*)(const FloatPoint&, const FloatPoint&), >+ &GraphicsContext::drawLine, >+ FloatPoint, FloatPoint >+>; > >-class DrawLinesForText : public DrawingItem { >+class DrawLine : public DrawLineBase { > public: >- static Ref<DrawLinesForText> create(const FloatPoint& blockLocation, const FloatSize& localAnchor, const DashArray& widths, bool printing, bool doubleLines, float strokeWidth) >- { >- return adoptRef(*new DrawLinesForText(blockLocation, localAnchor, widths, printing, doubleLines, strokeWidth)); >- } >- >- void setBlockLocation(const FloatPoint& blockLocation) { m_blockLocation = blockLocation; } >- const FloatPoint& blockLocation() const { return m_blockLocation; } >- const FloatSize& localAnchor() const { return m_localAnchor; } >- FloatPoint point() const { return m_blockLocation + m_localAnchor; } >- const DashArray& widths() const { return m_widths; } >- bool isPrinting() const { return m_printing; } >- bool doubleLines() const { return m_doubleLines; } >- >+ constexpr static auto create = DrawLineBase::create<DrawLine>; >+ using DrawLineBase::DrawLineBase; > private: >- DrawLinesForText(const FloatPoint& blockLocation, const FloatSize& localAnchor, const DashArray& widths, bool printing, bool doubleLines, float strokeWidth) >- : DrawingItem(ItemType::DrawLinesForText) >- , m_blockLocation(blockLocation) >- , m_localAnchor(localAnchor) >- , m_widths(widths) >- , m_strokeWidth(strokeWidth) >- , m_printing(printing) >- , m_doubleLines(doubleLines) >+ const std::optional<FloatRect> localBounds(const GraphicsContext&) const override > { >+ FloatRect bounds; >+ bounds.fitToPoints(argument<0>(), argument<1>()); >+ return bounds; > } >- >- void apply(GraphicsContext&) const override; >- >- std::optional<FloatRect> localBounds(const GraphicsContext&) const override; >- >- FloatPoint m_blockLocation; >- FloatSize m_localAnchor; >- DashArray m_widths; >- float m_strokeWidth; >- bool m_printing; >- bool m_doubleLines; > }; > >-class DrawLineForDocumentMarker : public DrawingItem { >-public: >- static Ref<DrawLineForDocumentMarker> create(const FloatPoint& point, float width, DocumentMarkerLineStyle style) >- { >- return adoptRef(*new DrawLineForDocumentMarker(point, width, style)); >- } >- >- FloatPoint point() const { return m_point; } >- float width() const { return m_width; } >+using DrawLinesForTextBase = DrawingItem< >+ ItemType::DrawLinesForText, >+ void (GraphicsContext::*)(const FloatPoint&, const DashArray&, bool, bool, StrokeStyle), >+ &GraphicsContext::drawLinesForText, >+ FloatPoint, DashArray, bool, bool, StrokeStyle >+>; > >-private: >- DrawLineForDocumentMarker(const FloatPoint& point, float width, DocumentMarkerLineStyle style) >- : DrawingItem(ItemType::DrawLineForDocumentMarker) >- , m_point(point) >- , m_width(width) >- , m_style(style) >- { >- } >- >- void apply(GraphicsContext&) const override; >- >- std::optional<FloatRect> localBounds(const GraphicsContext&) const override; >- >- FloatPoint m_point; >- float m_width; >- DocumentMarkerLineStyle m_style; >-}; >- >-class DrawEllipse : public DrawingItem { >+class DrawLinesForText : public DrawLinesForTextBase { > public: >- static Ref<DrawEllipse> create(const FloatRect& rect) >- { >- return adoptRef(*new DrawEllipse(rect)); >- } >- >- FloatRect rect() const { return m_rect; } >- >+ constexpr static auto create = DrawLinesForTextBase::create<DrawLinesForText>; >+ using DrawLinesForTextBase::DrawLinesForTextBase; > private: >- DrawEllipse(const FloatRect& rect) >- : DrawingItem(ItemType::DrawEllipse) >- , m_rect(rect) >+ const std::optional<FloatRect> localBounds(const GraphicsContext& context) const override > { >+ // This function needs to return a value equal to or enclosing what GraphicsContext::computeLineBoundsAndAntialiasingModeForText() returns. >+ if (!argument<1>().size()) >+ return FloatRect(); >+ FloatRect bounds(argument<0>(), FloatSize(argument<1>().last(), context.strokeThickness())); >+ bounds.inflate(1); // Account for pixel snapping. FIXME: This isn't perfect, as it doesn't take the CTM into account. >+ return bounds; > } >- >- void apply(GraphicsContext&) const override; >- std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_rect; } >- >- FloatRect m_rect; > }; > >-class DrawPath : public DrawingItem { >-public: >- static Ref<DrawPath> create(const Path& path) >- { >- return adoptRef(*new DrawPath(path)); >- } >- >- const Path& path() const { return m_path; } >- >-private: >- DrawPath(const Path& path) >- : DrawingItem(ItemType::DrawPath) >- , m_path(path) >- { >- } >- >- void apply(GraphicsContext&) const override; >+using DrawLineForDocumentMarkerBase = DrawingItem< >+ ItemType::DrawLineForDocumentMarker, >+ void (GraphicsContext::*)(const FloatPoint&, float, DocumentMarkerLineStyle), >+ &GraphicsContext::drawLineForDocumentMarker, >+ FloatPoint, float, DocumentMarkerLineStyle >+>; > >- std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_path.fastBoundingRect(); } >- >- const Path m_path; >-}; >- >-class DrawFocusRingPath : public DrawingItem { >+class DrawLineForDocumentMarker : public DrawLineForDocumentMarkerBase { > public: >- static Ref<DrawFocusRingPath> create(const Path& path, float width, float offset, const Color& color) >- { >- return adoptRef(*new DrawFocusRingPath(path, width, offset, color)); >- } >- >- const Path& path() const { return m_path; } >- float width() const { return m_width; } >- float offset() const { return m_offset; } >- const Color& color() const { return m_color; } >- >+ constexpr static auto create = DrawLineForDocumentMarkerBase::create<DrawLineForDocumentMarker>; >+ using DrawLineForDocumentMarkerBase::DrawLineForDocumentMarkerBase; > private: >- DrawFocusRingPath(const Path& path, float width, float offset, const Color& color) >- : DrawingItem(ItemType::DrawFocusRingPath) >- , m_path(path) >- , m_width(width) >- , m_offset(offset) >- , m_color(color) >+ const std::optional<FloatRect> localBounds(const GraphicsContext&) const override > { >+ // This function needs to return a value equal to or enclosing what GraphicsContext::drawLineForDocumentMarker() returns. >+ FloatRect bounds(argument<0>(), FloatSize(argument<1>(), cMisspellingLineThickness)); >+ bounds.inflate(cMisspellingLineThickness); // Account for "misspelling dot" snapping. >+ return bounds; > } >- >- void apply(GraphicsContext&) const override; >- >- std::optional<FloatRect> localBounds(const GraphicsContext&) const override; >- >- const Path m_path; >- float m_width; >- float m_offset; >- Color m_color; > }; > >-class DrawFocusRingRects : public DrawingItem { >-public: >- static Ref<DrawFocusRingRects> create(const Vector<FloatRect>& rects, float width, float offset, const Color& color) >- { >- return adoptRef(*new DrawFocusRingRects(rects, width, offset, color)); >- } >- >- const Vector<FloatRect> rects() const { return m_rects; } >- float width() const { return m_width; } >- float offset() const { return m_offset; } >- const Color& color() const { return m_color; } >+using DrawEllipseBase = DrawingItem< >+ ItemType::DrawEllipse, >+ void (GraphicsContext::*)(const FloatRect&), >+ &GraphicsContext::drawEllipse, >+ FloatRect >+>; > >+class DrawEllipse : public DrawEllipseBase { >+public: >+ constexpr static auto create = DrawEllipseBase::create<DrawEllipse>; >+ using DrawEllipseBase::DrawEllipseBase; > private: >- DrawFocusRingRects(const Vector<FloatRect>& rects, float width, float offset, const Color& color) >- : DrawingItem(ItemType::DrawFocusRingRects) >- , m_rects(rects) >- , m_width(width) >- , m_offset(offset) >- , m_color(color) >- { >- } >- >- void apply(GraphicsContext&) const override; >- >- std::optional<FloatRect> localBounds(const GraphicsContext&) const override; >- >- Vector<FloatRect> m_rects; >- float m_width; >- float m_offset; >- Color m_color; >+ const std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return argument<0>(); } > }; > >-class FillRect : public DrawingItem { >-public: >- static Ref<FillRect> create(const FloatRect& rect) >- { >- return adoptRef(*new FillRect(rect)); >- } >- >- FloatRect rect() const { return m_rect; } >+#if USE(CG) >+using DrawPathBase = DrawingItem< >+ ItemType::DrawPath, >+ void (GraphicsContext::*)(const Path&), >+ &GraphicsContext::drawPath, >+ const Path >+>; > >+class DrawPath : public DrawPathBase { >+public: >+ constexpr static auto create = DrawPathBase::create<DrawPath>; >+ using DrawPathBase::DrawPathBase; > private: >- FillRect(const FloatRect& rect) >- : DrawingItem(ItemType::FillRect) >- , m_rect(rect) >- { >- } >- >- void apply(GraphicsContext&) const override; >- std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_rect; } >- >- FloatRect m_rect; >+ const std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return argument<0>().fastBoundingRect(); } > }; >+#endif > >-// FIXME: Make these inherit from FillRect proper. >-class FillRectWithColor : public DrawingItem { >-public: >- static Ref<FillRectWithColor> create(const FloatRect& rect, const Color& color) >- { >- return adoptRef(*new FillRectWithColor(rect, color)); >- } >- >- FloatRect rect() const { return m_rect; } >- const Color& color() const { return m_color; } >+using DrawFocusRingPathBase = DrawingItem< >+ ItemType::DrawFocusRingPath, >+ void (GraphicsContext::*)(const Path&, float, float, const Color&), >+ &GraphicsContext::drawFocusRing, >+ const Path, float, float, Color >+>; > >+class DrawFocusRingPath : public DrawFocusRingPathBase { >+public: >+ constexpr static auto create = DrawFocusRingPathBase::create<DrawFocusRingPath>; >+ using DrawFocusRingPathBase::DrawFocusRingPathBase; > private: >- FillRectWithColor(const FloatRect& rect, const Color& color) >- : DrawingItem(ItemType::FillRectWithColor) >- , m_rect(rect) >- , m_color(color) >+ const std::optional<FloatRect> localBounds(const GraphicsContext&) const override > { >+ FloatRect bounds = argument<0>().fastBoundingRect(); >+ bounds.inflate(s_platformFocusRingWidth); >+ return bounds; > } >- >- void apply(GraphicsContext&) const override; >- std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_rect; } >- >- FloatRect m_rect; >- Color m_color; > }; > >-class FillRectWithGradient : public DrawingItem { >-public: >- static Ref<FillRectWithGradient> create(const FloatRect& rect, Gradient& gradient) >- { >- return adoptRef(*new FillRectWithGradient(rect, gradient)); >- } >- >- FloatRect rect() const { return m_rect; } >+using DrawFocusRingRectsBase = DrawingItem< >+ ItemType::DrawFocusRingRects, >+ void (GraphicsContext::*)(const Vector<FloatRect>&, float, float, const Color&), >+ &GraphicsContext::drawFocusRing, >+ Vector<FloatRect>, float, float, Color >+>; > >+class DrawFocusRingRects : public DrawFocusRingRectsBase { >+public: >+ constexpr static auto create = DrawFocusRingRectsBase::create<DrawFocusRingRects>; >+ using DrawFocusRingRectsBase::DrawFocusRingRectsBase; > private: >- FillRectWithGradient(const FloatRect& rect, Gradient& gradient) >- : DrawingItem(ItemType::FillRectWithGradient) >- , m_rect(rect) >- , m_gradient(gradient) >+ const std::optional<FloatRect> localBounds(const GraphicsContext&) const override > { >+ FloatRect bounds; >+ for (auto& rect : argument<0>()) >+ bounds.unite(rect); >+ bounds.inflate(s_platformFocusRingWidth); >+ return bounds; > } >- >- void apply(GraphicsContext&) const override; >- std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_rect; } >- >- FloatRect m_rect; >- mutable Ref<Gradient> m_gradient; // FIXME: Make this not mutable > }; > >-class FillCompositedRect : public DrawingItem { >-public: >- static Ref<FillCompositedRect> create(const FloatRect& rect, const Color& color, CompositeOperator op, BlendMode blendMode) >- { >- return adoptRef(*new FillCompositedRect(rect, color, op, blendMode)); >- } >- >- FloatRect rect() const { return m_rect; } >- const Color& color() const { return m_color; } >- CompositeOperator compositeOperator() const { return m_op; } >- BlendMode blendMode() const { return m_blendMode; } >+using FillRectBase = DrawingItem< >+ ItemType::FillRect, >+ void (GraphicsContext::*)(const FloatRect&), >+ &GraphicsContext::fillRect, >+ FloatRect >+>; > >+class FillRect : public FillRectBase { >+public: >+ constexpr static auto create = FillRectBase::create<FillRect>; >+ using FillRectBase::FillRectBase; > private: >- FillCompositedRect(const FloatRect& rect, const Color& color, CompositeOperator op, BlendMode blendMode) >- : DrawingItem(ItemType::FillCompositedRect) >- , m_rect(rect) >- , m_color(color) >- , m_op(op) >- , m_blendMode(blendMode) >- { >- } >- >- void apply(GraphicsContext&) const override; >- std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_rect; } >- >- FloatRect m_rect; >- Color m_color; >- CompositeOperator m_op; >- BlendMode m_blendMode; >+ const std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return argument<0>(); } > }; > >-class FillRoundedRect : public DrawingItem { >-public: >- static Ref<FillRoundedRect> create(const FloatRoundedRect& rect, const Color& color, BlendMode blendMode) >- { >- return adoptRef(*new FillRoundedRect(rect, color, blendMode)); >- } >- >- const FloatRoundedRect& roundedRect() const { return m_rect; } >- const Color& color() const { return m_color; } >- BlendMode blendMode() const { return m_blendMode; } >+using FillRectWithColorBase = DrawingItem< >+ ItemType::FillRectWithColor, >+ void (GraphicsContext::*)(const FloatRect&, const Color&), >+ &GraphicsContext::fillRect, >+ FloatRect, Color >+>; > >+class FillRectWithColor : public FillRectWithColorBase { >+public: >+ constexpr static auto create = FillRectWithColorBase::create<FillRectWithColor>; >+ using FillRectWithColorBase::FillRectWithColorBase; > private: >- FillRoundedRect(const FloatRoundedRect& rect, const Color& color, BlendMode blendMode) >- : DrawingItem(ItemType::FillRoundedRect) >- , m_rect(rect) >- , m_color(color) >- , m_blendMode(blendMode) >- { >- } >- >- void apply(GraphicsContext&) const override; >- std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_rect.rect(); } >- >- FloatRoundedRect m_rect; >- Color m_color; >- BlendMode m_blendMode; >+ const std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return argument<0>(); } > }; > >-class FillRectWithRoundedHole : public DrawingItem { >-public: >- static Ref<FillRectWithRoundedHole> create(const FloatRect& rect, const FloatRoundedRect& roundedHoleRect, const Color& color) >- { >- return adoptRef(*new FillRectWithRoundedHole(rect, roundedHoleRect, color)); >- } >- >- const FloatRect& rect() const { return m_rect; } >- const FloatRoundedRect& roundedHoleRect() const { return m_roundedHoleRect; } >- const Color& color() const { return m_color; } >+using FillRectWithGradientBase = DrawingItem< >+ ItemType::FillRectWithGradient, >+ void (GraphicsContext::*)(const FloatRect&, Gradient&), >+ &GraphicsContext::fillRect, >+ FloatRect, Ref<Gradient> >+>; > >+class FillRectWithGradient : public FillRectWithGradientBase { >+public: >+ constexpr static auto create = FillRectWithGradientBase::create<FillRectWithGradient>; >+ using FillRectWithGradientBase::FillRectWithGradientBase; > private: >- FillRectWithRoundedHole(const FloatRect& rect, const FloatRoundedRect& roundedHoleRect, const Color& color) >- : DrawingItem(ItemType::FillRectWithRoundedHole) >- , m_rect(rect) >- , m_roundedHoleRect(roundedHoleRect) >- , m_color(color) >- { >- } >- >- void apply(GraphicsContext&) const override; >- std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_rect; } >- >- FloatRect m_rect; >- FloatRoundedRect m_roundedHoleRect; >- Color m_color; >+ const std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return argument<0>(); } > }; > >-class FillPath : public DrawingItem { >-public: >- static Ref<FillPath> create(const Path& path) >- { >- return adoptRef(*new FillPath(path)); >- } >- >- const Path& path() const { return m_path; } >+using FillCompositedRectBase = DrawingItem< >+ ItemType::FillCompositedRect, >+ void (GraphicsContext::*)(const FloatRect&, const Color&, CompositeOperator, BlendMode), >+ &GraphicsContext::fillRect, >+ FloatRect, Color, CompositeOperator, BlendMode >+>; > >+class FillCompositedRect : public FillCompositedRectBase { >+public: >+ constexpr static auto create = FillCompositedRectBase::create<FillCompositedRect>; >+ using FillCompositedRectBase::FillCompositedRectBase; > private: >- FillPath(const Path& path) >- : DrawingItem(ItemType::FillPath) >- , m_path(path) >- { >- } >- >- void apply(GraphicsContext&) const override; >- std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_path.fastBoundingRect(); } >- >- const Path m_path; >+ const std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return argument<0>(); } > }; > >-class FillEllipse : public DrawingItem { >-public: >- static Ref<FillEllipse> create(const FloatRect& rect) >- { >- return adoptRef(*new FillEllipse(rect)); >- } >- >- FloatRect rect() const { return m_rect; } >+using FillRoundedRectBase = DrawingItem< >+ ItemType::FillRoundedRect, >+ void (GraphicsContext::*)(const FloatRoundedRect&, const Color&, BlendMode), >+ &GraphicsContext::fillRoundedRect, >+ FloatRoundedRect, Color, BlendMode >+>; > >+class FillRoundedRect : public FillRoundedRectBase { >+public: >+ constexpr static auto create = FillRoundedRectBase::create<FillRoundedRect>; >+ using FillRoundedRectBase::FillRoundedRectBase; > private: >- FillEllipse(const FloatRect& rect) >- : DrawingItem(ItemType::FillEllipse) >- , m_rect(rect) >- { >- } >- >- void apply(GraphicsContext&) const override; >- >- std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_rect; } >- >- FloatRect m_rect; >+ const std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return argument<0>().rect(); } > }; > >-class StrokeRect : public DrawingItem { >-public: >- static Ref<StrokeRect> create(const FloatRect& rect, float lineWidth) >- { >- return adoptRef(*new StrokeRect(rect, lineWidth)); >- } >- >- FloatRect rect() const { return m_rect; } >- float lineWidth() const { return m_lineWidth; } >+using FillRectWithRoundedHoleBase = DrawingItem< >+ ItemType::FillRectWithRoundedHole, >+ void (GraphicsContext::*)(const FloatRect&, const FloatRoundedRect&, const Color&), >+ &GraphicsContext::fillRectWithRoundedHole, >+ FloatRect, FloatRoundedRect, Color >+>; > >+class FillRectWithRoundedHole : public FillRectWithRoundedHoleBase { >+public: >+ constexpr static auto create = FillRectWithRoundedHoleBase::create<FillRectWithRoundedHole>; >+ using FillRectWithRoundedHoleBase::FillRectWithRoundedHoleBase; > private: >- StrokeRect(const FloatRect& rect, float lineWidth) >- : DrawingItem(ItemType::StrokeRect) >- , m_rect(rect) >- , m_lineWidth(lineWidth) >- { >- } >- >- void apply(GraphicsContext&) const override; >- std::optional<FloatRect> localBounds(const GraphicsContext&) const override; >- >- FloatRect m_rect; >- float m_lineWidth; >+ const std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return argument<0>(); } > }; > >-class StrokePath : public DrawingItem { >-public: >- static Ref<StrokePath> create(const Path& path) >- { >- return adoptRef(*new StrokePath(path)); >- } >- >- const Path& path() const { return m_path; } >+using FillPathBase = DrawingItem< >+ ItemType::FillPath, >+ void (GraphicsContext::*)(const Path&), >+ &GraphicsContext::fillPath, >+ const Path >+>; > >+class FillPath : public FillPathBase { >+public: >+ constexpr static auto create = FillPathBase::create<FillPath>; >+ using FillPathBase::FillPathBase; > private: >- StrokePath(const Path& path) >- : DrawingItem(ItemType::StrokePath) >- , m_path(path) >- { >- } >- >- void apply(GraphicsContext&) const override; >- std::optional<FloatRect> localBounds(const GraphicsContext&) const override; >- >- const Path m_path; >- FloatPoint m_blockLocation; >+ const std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return argument<0>().fastBoundingRect(); } > }; > >-class StrokeEllipse : public DrawingItem { >-public: >- static Ref<StrokeEllipse> create(const FloatRect& rect) >- { >- return adoptRef(*new StrokeEllipse(rect)); >- } >- >- FloatRect rect() const { return m_rect; } >+using FillEllipseBase = DrawingItem< >+ ItemType::FillEllipse, >+ void (GraphicsContext::*)(const FloatRect&), >+ &GraphicsContext::fillEllipse, >+ FloatRect >+>; > >+class FillEllipse : public FillEllipseBase { >+public: >+ constexpr static auto create = FillEllipseBase::create<FillEllipse>; >+ using FillEllipseBase::FillEllipseBase; > private: >- StrokeEllipse(const FloatRect& rect) >- : DrawingItem(ItemType::StrokeEllipse) >- , m_rect(rect) >- { >- } >- >- void apply(GraphicsContext&) const override; >- std::optional<FloatRect> localBounds(const GraphicsContext&) const override; >- >- FloatRect m_rect; >+ const std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return argument<0>(); } > }; > >-class ClearRect : public DrawingItem { >-public: >- static Ref<ClearRect> create(const FloatRect& rect) >- { >- return adoptRef(*new ClearRect(rect)); >- } >- >- FloatRect rect() const { return m_rect; } >+using StrokeRectBase = DrawingItem< >+ ItemType::StrokeRect, >+ void (GraphicsContext::*)(const FloatRect&, float), >+ &GraphicsContext::strokeRect, >+ FloatRect, float >+>; > >+class StrokeRect : public StrokeRectBase { >+public: >+ constexpr static auto create = StrokeRectBase::create<StrokeRect>; >+ using StrokeRectBase::StrokeRectBase; > private: >- ClearRect(const FloatRect& rect) >- : DrawingItem(ItemType::ClearRect) >- , m_rect(rect) >+ const std::optional<FloatRect> localBounds(const GraphicsContext&) const override > { >+ FloatRect bounds = argument<0>(); >+ bounds.expand(argument<1>(), argument<1>()); >+ return bounds; > } >- >- void apply(GraphicsContext&) const override; >- std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_rect; } >- >- FloatRect m_rect; > }; > >-#if USE(CG) >-class ApplyStrokePattern : public Item { >-public: >- static Ref<ApplyStrokePattern> create() >- { >- return adoptRef(*new ApplyStrokePattern); >- } >+using StrokePathBase = DrawingItem< >+ ItemType::StrokePath, >+ void (GraphicsContext::*)(const Path&), >+ &GraphicsContext::strokePath, >+ const Path >+>; > >+class StrokePath : public StrokePathBase { >+public: >+ constexpr static auto create = StrokePathBase::create<StrokePath>; >+ using StrokePathBase::StrokePathBase; > private: >- ApplyStrokePattern() >- : Item(ItemType::ApplyStrokePattern) >+ const std::optional<FloatRect> localBounds(const GraphicsContext& context) const override > { >- } >+ // FIXME: Need to take stroke thickness into account correctly, via CGPathByStrokingPath(). >+ float strokeThickness = context.strokeThickness(); > >- void apply(GraphicsContext&) const override; >+ FloatRect bounds = argument<0>().boundingRect(); >+ bounds.expand(strokeThickness, strokeThickness); >+ return bounds; >+ } > }; > >-class ApplyFillPattern : public Item { >-public: >- static Ref<ApplyFillPattern> create() >- { >- return adoptRef(*new ApplyFillPattern); >- } >+using StrokeEllipseBase = DrawingItem< >+ ItemType::StrokeEllipse, >+ void (GraphicsContext::*)(const FloatRect&), >+ &GraphicsContext::strokeEllipse, >+ FloatRect >+>; > >+class StrokeEllipse : public StrokeEllipseBase { >+public: >+ constexpr static auto create = StrokeEllipseBase::create<StrokeEllipse>; >+ using StrokeEllipseBase::StrokeEllipseBase; > private: >- ApplyFillPattern() >- : Item(ItemType::ApplyFillPattern) >+ const std::optional<FloatRect> localBounds(const GraphicsContext& context) const override > { >+ float strokeThickness = context.strokeThickness(); >+ FloatRect bounds = argument<0>(); >+ bounds.expand(strokeThickness, strokeThickness); >+ return bounds; > } >- >- void apply(GraphicsContext&) const override; > }; >-#endif >- >-class ApplyDeviceScaleFactor : public Item { >-public: >- static Ref<ApplyDeviceScaleFactor> create(float scaleFactor) >- { >- return adoptRef(*new ApplyDeviceScaleFactor(scaleFactor)); >- } > >- float scaleFactor() const { return m_scaleFactor; } >+using ClearRectBase = DrawingItem< >+ ItemType::ClearRect, >+ void (GraphicsContext::*)(const FloatRect&), >+ &GraphicsContext::clearRect, >+ FloatRect >+>; > >+class ClearRect : public ClearRectBase { >+public: >+ constexpr static auto create = ClearRectBase::create<ClearRect>; >+ using ClearRectBase::ClearRectBase; > private: >- ApplyDeviceScaleFactor(float scaleFactor) >- : Item(ItemType::ApplyDeviceScaleFactor) >- , m_scaleFactor(scaleFactor) >- { >- } >- >- void apply(GraphicsContext&) const override; >- >- float m_scaleFactor; >+ const std::optional<FloatRect> localBounds(const GraphicsContext&) const override { return argument<0>(); } > }; > >-WTF::TextStream& operator<<(WTF::TextStream&, const Item&); >+inline WTF::TextStream& operator<<(WTF::TextStream& ts, const Item& item) >+{ >+ TextStream::GroupScope group(ts); >+ item.dump(ts); >+ return ts; >+} >+ >+inline WTF::CString Item::dump() const >+{ >+ TextStream ts; >+ ts << *this; >+ return ts.release().utf8(); >+} > > } // namespace DisplayList > } // namespace WebCore > >- >-#define SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_DRAWINGITEM(ToValueTypeName, predicate) \ >-SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::DisplayList::ToValueTypeName) \ >- static bool isType(const WebCore::DisplayList::Item& object) { return object.predicate; } \ >+#define SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_GEOMETRYITEM(ToValueTypeName, predicate) \ >+ SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::DisplayList::ToValueTypeName) \ >+ static bool isType(const WebCore::DisplayList::Item& item) { return item.predicate; } \ > SPECIALIZE_TYPE_TRAITS_END() > >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_DRAWINGITEM(DrawingItem, isDrawingItem()) >+SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_GEOMETRYITEM(GeometryItem, isGeometryItem()) > > #define SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(ToValueTypeName) \ >-SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::DisplayList::ToValueTypeName) \ >+ SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::DisplayList::ToValueTypeName) \ > static bool isType(const WebCore::DisplayList::Item& item) { return item.type() == WebCore::DisplayList::ItemType::ToValueTypeName; } \ > SPECIALIZE_TYPE_TRAITS_END() > > SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(Save) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(Restore) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(Translate) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(Rotate) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(Scale) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(ConcatenateCTM) > SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(SetState) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(SetLineCap) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(SetLineDash) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(SetLineJoin) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(SetMiterLimit) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(Clip) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(ClipOut) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(ClipOutToPath) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(ClipPath) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawGlyphs) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawImage) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawTiledImage) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawTiledScaledImage) >-#if USE(CG) || USE(CAIRO) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawNativeImage) >-#endif >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawPattern) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawRect) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawLine) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawLinesForText) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawLineForDocumentMarker) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawEllipse) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawPath) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawFocusRingPath) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawFocusRingRects) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(FillRect) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(FillRectWithColor) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(FillRectWithGradient) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(FillCompositedRect) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(FillRoundedRect) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(FillRectWithRoundedHole) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(FillPath) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(FillEllipse) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(StrokeRect) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(StrokePath) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(StrokeEllipse) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(ClearRect) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(BeginTransparencyLayer) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(EndTransparencyLayer) >-#if USE(CG) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(ApplyStrokePattern) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(ApplyFillPattern) >-#endif >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(ApplyDeviceScaleFactor) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(ClearShadow) >- >Index: Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp >=================================================================== >--- Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp (revision 234218) >+++ Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp (working copy) >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2016 Apple Inc. All rights reserved. >+ * Copyright (C) 2016-2018 Apple Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -52,21 +52,22 @@ Recorder::~Recorder() > > void Recorder::willAppendItem(const Item& item) > { >- if (item.isDrawingItem() > #if USE(CG) >- || item.type() == ItemType::ApplyStrokePattern || item.type() == ItemType::ApplyStrokePattern >+ if (!is<GeometryItem>(item) && item.type() != ItemType::ApplyStrokePattern && item.type() != ItemType::ApplyFillPattern) >+#else >+ if (!is<GeometryItem>(item)) > #endif >- ) { >- GraphicsContextStateChange& stateChanges = currentState().stateChange; >- GraphicsContextState::StateChangeFlags changesFromLastState = stateChanges.changesFromState(currentState().lastDrawingState); >- if (changesFromLastState) { >- LOG_WITH_STREAM(DisplayLists, stream << "pre-drawing, saving state " << GraphicsContextStateChange(stateChanges.m_state, changesFromLastState)); >- m_displayList.append(SetState::create(stateChanges.m_state, changesFromLastState)); >- stateChanges.m_changeFlags = 0; >- currentState().lastDrawingState = stateChanges.m_state; >- } >- currentState().wasUsedForDrawing = true; >+ return; >+ >+ GraphicsContextStateChange& stateChanges = currentState().stateChange; >+ GraphicsContextState::StateChangeFlags changesFromLastState = stateChanges.changesFromState(currentState().lastDrawingState); >+ if (changesFromLastState) { >+ LOG_WITH_STREAM(DisplayLists, stream << "pre-drawing, saving state " << GraphicsContextStateChange(stateChanges.m_state, changesFromLastState)); >+ m_displayList.append(SetState::create(GraphicsContextStateChange(stateChanges.m_state, changesFromLastState))); >+ stateChanges.m_changeFlags = 0; >+ currentState().lastDrawingState = stateChanges.m_state; > } >+ currentState().wasUsedForDrawing = true; > } > > void Recorder::updateState(const GraphicsContextState& state, GraphicsContextState::StateChangeFlags flags) >@@ -99,44 +100,44 @@ void Recorder::setMiterLimit(float miter > appendItem(SetMiterLimit::create(miterLimit)); > } > >-void Recorder::drawGlyphs(const Font& font, const GlyphBuffer& glyphBuffer, unsigned from, unsigned numGlyphs, const FloatPoint& startPoint, FontSmoothingMode smoothingMode) >+void Recorder::drawGlyphs(const Font& font, const GlyphBuffer& glyphBuffer, unsigned from, unsigned numGlyphs, const FloatPoint& startPoint, FontSmoothingMode fontSmoothing) > { >- DrawingItem& newItem = downcast<DrawingItem>(appendItem(DrawGlyphs::create(font, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs, FloatPoint(), toFloatSize(startPoint), smoothingMode))); >+ auto& newItem = downcast<GeometryItem>(appendItem(DrawGlyphs::create(makeRef(font), glyphBuffer, from, numGlyphs, startPoint, fontSmoothing))); > updateItemExtent(newItem); > } > > ImageDrawResult Recorder::drawImage(Image& image, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& imagePaintingOptions) > { >- DrawingItem& newItem = downcast<DrawingItem>(appendItem(DrawImage::create(image, destination, source, imagePaintingOptions))); >+ auto& newItem = downcast<GeometryItem>(appendItem(DrawImage::create(makeRef(image), destination, source, imagePaintingOptions))); > updateItemExtent(newItem); > return ImageDrawResult::DidRecord; > } > > ImageDrawResult Recorder::drawTiledImage(Image& image, const FloatRect& destination, const FloatPoint& source, const FloatSize& tileSize, const FloatSize& spacing, const ImagePaintingOptions& imagePaintingOptions) > { >- DrawingItem& newItem = downcast<DrawingItem>(appendItem(DrawTiledImage::create(image, destination, source, tileSize, spacing, imagePaintingOptions))); >+ auto& newItem = downcast<GeometryItem>(appendItem(DrawTiledImage::create(makeRef(image), destination, source, tileSize, spacing, imagePaintingOptions))); > updateItemExtent(newItem); > return ImageDrawResult::DidRecord; > } > > ImageDrawResult Recorder::drawTiledImage(Image& image, const FloatRect& destination, const FloatRect& source, const FloatSize& tileScaleFactor, Image::TileRule hRule, Image::TileRule vRule, const ImagePaintingOptions& imagePaintingOptions) > { >- DrawingItem& newItem = downcast<DrawingItem>(appendItem(DrawTiledScaledImage::create(image, destination, source, tileScaleFactor, hRule, vRule, imagePaintingOptions))); >+ auto& newItem = downcast<GeometryItem>(appendItem(DrawTiledScaledImage::create(makeRef(image), destination, source, tileScaleFactor, hRule, vRule, imagePaintingOptions))); > updateItemExtent(newItem); > return ImageDrawResult::DidRecord; > } > >-#if USE(CG) || USE(CAIRO) >+#if USE(CG) || USE(DIRECT2D) || USE(CAIRO) > void Recorder::drawNativeImage(const NativeImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator op, BlendMode blendMode, ImageOrientation orientation) > { >- DrawingItem& newItem = downcast<DrawingItem>(appendItem(DrawNativeImage::create(image, imageSize, destRect, srcRect, op, blendMode, orientation))); >+ auto& newItem = downcast<GeometryItem>(appendItem(DrawNativeImage::create(image, imageSize, destRect, srcRect, op, blendMode, orientation))); > updateItemExtent(newItem); > } > #endif > > void Recorder::drawPattern(Image& image, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, CompositeOperator op, BlendMode blendMode) > { >- DrawingItem& newItem = downcast<DrawingItem>(appendItem(DrawPattern::create(image, destRect, tileRect, patternTransform, phase, spacing, op, blendMode))); >+ auto& newItem = downcast<GeometryItem>(appendItem(DrawPattern::create(makeRef(image), destRect, tileRect, patternTransform, phase, spacing, op, blendMode))); > updateItemExtent(newItem); > } > >@@ -209,7 +210,7 @@ AffineTransform Recorder::getCTM(Graphic > > void Recorder::beginTransparencyLayer(float opacity) > { >- DrawingItem& newItem = downcast<DrawingItem>(appendItem(BeginTransparencyLayer::create(opacity))); >+ auto& newItem = downcast<GeometryItem>(appendItem(BeginTransparencyLayer::create(opacity))); > updateItemExtent(newItem); > } > >@@ -220,121 +221,123 @@ void Recorder::endTransparencyLayer() > > void Recorder::drawRect(const FloatRect& rect, float borderThickness) > { >- DrawingItem& newItem = downcast<DrawingItem>(appendItem(DrawRect::create(rect, borderThickness))); >+ auto& newItem = downcast<GeometryItem>(appendItem(DrawRect::create(rect, borderThickness))); > updateItemExtent(newItem); > } > > void Recorder::drawLine(const FloatPoint& point1, const FloatPoint& point2) > { >- DrawingItem& newItem = downcast<DrawingItem>(appendItem(DrawLine::create(point1, point2))); >+ auto& newItem = downcast<GeometryItem>(appendItem(DrawLine::create(point1, point2))); > updateItemExtent(newItem); > } > >-void Recorder::drawLinesForText(const FloatPoint& point, const DashArray& widths, bool printing, bool doubleLines, float strokeThickness) >+void Recorder::drawLinesForText(const FloatPoint& point, const DashArray& widths, bool printing, bool doubleLines, StrokeStyle strokeStyle) > { >- DrawingItem& newItem = downcast<DrawingItem>(appendItem(DrawLinesForText::create(FloatPoint(), toFloatSize(point), widths, printing, doubleLines, strokeThickness))); >+ auto& newItem = downcast<GeometryItem>(appendItem(DrawLinesForText::create(point, widths, printing, doubleLines, strokeStyle))); > updateItemExtent(newItem); > } > > void Recorder::drawLineForDocumentMarker(const FloatPoint& point, float width, DocumentMarkerLineStyle style) > { >- DrawingItem& newItem = downcast<DrawingItem>(appendItem(DrawLineForDocumentMarker::create(point, width, style))); >+ auto& newItem = downcast<GeometryItem>(appendItem(DrawLineForDocumentMarker::create(point, width, style))); > updateItemExtent(newItem); > } > > void Recorder::drawEllipse(const FloatRect& rect) > { >- DrawingItem& newItem = downcast<DrawingItem>(appendItem(DrawEllipse::create(rect))); >+ auto& newItem = downcast<GeometryItem>(appendItem(DrawEllipse::create(rect))); > updateItemExtent(newItem); > } > >+#if USE(CG) > void Recorder::drawPath(const Path& path) > { >- DrawingItem& newItem = downcast<DrawingItem>(appendItem(DrawPath::create(path))); >+ auto& newItem = downcast<GeometryItem>(appendItem(DrawPath::create(path))); > updateItemExtent(newItem); > } >+#endif > > void Recorder::drawFocusRing(const Path& path, float width, float offset, const Color& color) > { >- DrawingItem& newItem = downcast<DrawingItem>(appendItem(DrawFocusRingPath::create(path, width, offset, color))); >+ auto& newItem = downcast<GeometryItem>(appendItem(DrawFocusRingPath::create(path, width, offset, color))); > updateItemExtent(newItem); > } > > void Recorder::drawFocusRing(const Vector<FloatRect>& rects, float width, float offset, const Color& color) > { >- DrawingItem& newItem = downcast<DrawingItem>(appendItem(DrawFocusRingRects::create(rects, width, offset, color))); >+ auto& newItem = downcast<GeometryItem>(appendItem(DrawFocusRingRects::create(rects, width, offset, color))); > updateItemExtent(newItem); > } > > void Recorder::fillRect(const FloatRect& rect) > { >- DrawingItem& newItem = downcast<DrawingItem>(appendItem(FillRect::create(rect))); >+ auto& newItem = downcast<GeometryItem>(appendItem(FillRect::create(rect))); > updateItemExtent(newItem); > } > > void Recorder::fillRect(const FloatRect& rect, const Color& color) > { >- DrawingItem& newItem = downcast<DrawingItem>(appendItem(FillRectWithColor::create(rect, color))); >+ auto& newItem = downcast<GeometryItem>(appendItem(FillRectWithColor::create(rect, color))); > updateItemExtent(newItem); > } > > void Recorder::fillRect(const FloatRect& rect, Gradient& gradient) > { >- DrawingItem& newItem = downcast<DrawingItem>(appendItem(FillRectWithGradient::create(rect, gradient))); >+ auto& newItem = downcast<GeometryItem>(appendItem(FillRectWithGradient::create(rect, gradient))); > updateItemExtent(newItem); > } > > void Recorder::fillRect(const FloatRect& rect, const Color& color, CompositeOperator op, BlendMode blendMode) > { >- DrawingItem& newItem = downcast<DrawingItem>(appendItem(FillCompositedRect::create(rect, color, op, blendMode))); >+ auto& newItem = downcast<GeometryItem>(appendItem(FillCompositedRect::create(rect, color, op, blendMode))); > updateItemExtent(newItem); > } > > void Recorder::fillRoundedRect(const FloatRoundedRect& rect, const Color& color, BlendMode blendMode) > { >- DrawingItem& newItem = downcast<DrawingItem>(appendItem(FillRoundedRect::create(rect, color, blendMode))); >+ auto& newItem = downcast<GeometryItem>(appendItem(FillRoundedRect::create(rect, color, blendMode))); > updateItemExtent(newItem); > } > > void Recorder::fillRectWithRoundedHole(const FloatRect& rect, const FloatRoundedRect& roundedHoleRect, const Color& color) > { >- DrawingItem& newItem = downcast<DrawingItem>(appendItem(FillRectWithRoundedHole::create(rect, roundedHoleRect, color))); >+ auto& newItem = downcast<GeometryItem>(appendItem(FillRectWithRoundedHole::create(rect, roundedHoleRect, color))); > updateItemExtent(newItem); > } > > void Recorder::fillPath(const Path& path) > { >- DrawingItem& newItem = downcast<DrawingItem>(appendItem(FillPath::create(path))); >+ auto& newItem = downcast<GeometryItem>(appendItem(FillPath::create(path))); > updateItemExtent(newItem); > } > > void Recorder::fillEllipse(const FloatRect& rect) > { >- DrawingItem& newItem = downcast<DrawingItem>(appendItem(FillEllipse::create(rect))); >+ auto& newItem = downcast<GeometryItem>(appendItem(FillEllipse::create(rect))); > updateItemExtent(newItem); > } > > void Recorder::strokeRect(const FloatRect& rect, float lineWidth) > { >- DrawingItem& newItem = downcast<DrawingItem>(appendItem(StrokeRect::create(rect, lineWidth))); >+ auto& newItem = downcast<GeometryItem>(appendItem(StrokeRect::create(rect, lineWidth))); > updateItemExtent(newItem); > } > > void Recorder::strokePath(const Path& path) > { >- DrawingItem& newItem = downcast<DrawingItem>(appendItem(StrokePath::create(path))); >+ auto& newItem = downcast<GeometryItem>(appendItem(StrokePath::create(path))); > updateItemExtent(newItem); > } > > void Recorder::strokeEllipse(const FloatRect& rect) > { >- DrawingItem& newItem = downcast<DrawingItem>(appendItem(StrokeEllipse::create(rect))); >+ auto& newItem = downcast<GeometryItem>(appendItem(StrokeEllipse::create(rect))); > updateItemExtent(newItem); > } > > void Recorder::clearRect(const FloatRect& rect) > { >- DrawingItem& newItem = downcast<DrawingItem>(appendItem(ClearRect::create(rect))); >+ auto& newItem = downcast<GeometryItem>(appendItem(ClearRect::create(rect))); > updateItemExtent(newItem); > } > >@@ -402,7 +405,7 @@ Item& Recorder::appendItem(Ref<Item>&& i > return m_displayList.append(WTFMove(item)); > } > >-void Recorder::updateItemExtent(DrawingItem& item) const >+void Recorder::updateItemExtent(GeometryItem& item) const > { > if (std::optional<FloatRect> rect = item.localBounds(graphicsContext())) > item.setExtent(extentFromLocalBounds(rect.value())); >Index: Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h >=================================================================== >--- Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h (revision 234218) >+++ Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h (working copy) >@@ -45,8 +45,6 @@ struct ImagePaintingOptions; > > namespace DisplayList { > >-class DrawingItem; >- > class Recorder : public GraphicsContextImpl { > WTF_MAKE_NONCOPYABLE(Recorder); > public: >@@ -97,10 +95,12 @@ private: > > void drawRect(const FloatRect&, float borderThickness) override; > void drawLine(const FloatPoint&, const FloatPoint&) override; >- void drawLinesForText(const FloatPoint&, const DashArray& widths, bool printing, bool doubleLines, float strokeThickness) override; >+ void drawLinesForText(const FloatPoint&, const DashArray& widths, bool printing, bool doubleLines, StrokeStyle) override; > void drawLineForDocumentMarker(const FloatPoint&, float width, DocumentMarkerLineStyle) override; > void drawEllipse(const FloatRect&) override; >+#if USE(CG) > void drawPath(const Path&) override; >+#endif > > void drawFocusRing(const Path&, float width, float offset, const Color&) override; > void drawFocusRing(const Vector<FloatRect>&, float width, float offset, const Color&) override; >@@ -133,7 +133,7 @@ private: > void willAppendItem(const Item&); > > FloatRect extentFromLocalBounds(const FloatRect&) const; >- void updateItemExtent(DrawingItem&) const; >+ void updateItemExtent(GeometryItem&) const; > > const AffineTransform& ctm() const; > const FloatRect& clipBounds() const; >Index: Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.cpp >=================================================================== >--- Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.cpp (revision 234218) >+++ Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.cpp (working copy) >@@ -55,9 +55,9 @@ std::unique_ptr<DisplayList> Replayer::r > for (size_t i = 0; i < numItems; ++i) { > auto& item = m_displayList.list()[i].get(); > >- if (!initialClip.isZero() && is<DrawingItem>(item)) { >- const DrawingItem& drawingItem = downcast<DrawingItem>(item); >- if (drawingItem.extentKnown() && !drawingItem.extent().intersects(initialClip)) { >+ if (!initialClip.isZero() && is<GeometryItem>(item)) { >+ const auto& geometryItem = downcast<GeometryItem>(item); >+ if (geometryItem.extentKnown() && !geometryItem.extent().intersects(initialClip)) { > LOG_WITH_STREAM(DisplayLists, stream << "skipping " << i << " " << item); > continue; > } >Index: Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp >=================================================================== >--- Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp (revision 234218) >+++ Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp (working copy) >@@ -631,7 +631,7 @@ void CairoOperationRecorder::drawLine(co > append(createCommand<DrawLine>(point1, point2, state.strokeStyle, state.strokeColor, state.strokeThickness, state.shouldAntialias)); > } > >-void CairoOperationRecorder::drawLinesForText(const FloatPoint& point, const DashArray& widths, bool printing, bool doubleUnderlines, float strokeThickness) >+void CairoOperationRecorder::drawLinesForText(const FloatPoint& point, const DashArray& widths, bool printing, bool doubleUnderlines, StrokeStyle strokeStyle) > { > struct DrawLinesForText final : PaintingOperation, OperationData<FloatPoint, DashArray, bool, bool, Color, float> { > virtual ~DrawLinesForText() = default; >@@ -647,7 +647,7 @@ void CairoOperationRecorder::drawLinesFo > } > }; > >- UNUSED_PARAM(strokeThickness); >+ UNUSED_PARAM(strokeStyle); > auto& state = graphicsContext().state(); > append(createCommand<DrawLinesForText>(point, widths, printing, doubleUnderlines, state.strokeColor, state.strokeThickness)); > } >@@ -691,10 +691,6 @@ void CairoOperationRecorder::drawEllipse > append(createCommand<DrawEllipse>(rect, state.fillColor, state.strokeStyle, state.strokeColor, state.strokeThickness)); > } > >-void CairoOperationRecorder::drawPath(const Path&) >-{ >-} >- > void CairoOperationRecorder::drawFocusRing(const Path& path, float width, float offset, const Color& color) > { > struct DrawFocusRing final : PaintingOperation, OperationData<Path, float, Color> { >Index: Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.h >=================================================================== >--- Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.h (revision 234218) >+++ Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.h (working copy) >@@ -72,10 +72,9 @@ private: > > void drawRect(const WebCore::FloatRect&, float) override; > void drawLine(const WebCore::FloatPoint&, const WebCore::FloatPoint&) override; >- void drawLinesForText(const WebCore::FloatPoint&, const DashArray&, bool, bool, float) override; >+ void drawLinesForText(const WebCore::FloatPoint&, const DashArray&, bool, bool, WebCore::StrokeStyle) override; > void drawLineForDocumentMarker(const WebCore::FloatPoint&, float, WebCore::DocumentMarkerLineStyle) override; > void drawEllipse(const WebCore::FloatRect&) override; >- void drawPath(const WebCore::Path&) override; > > void drawFocusRing(const WebCore::Path&, float, float, const WebCore::Color&) override; > void drawFocusRing(const Vector<WebCore::FloatRect>&, float, float, const WebCore::Color&) override; >Index: Source/WebCore/platform/graphics/win/GraphicsContextDirect2D.cpp >=================================================================== >--- Source/WebCore/platform/graphics/win/GraphicsContextDirect2D.cpp (revision 234218) >+++ Source/WebCore/platform/graphics/win/GraphicsContextDirect2D.cpp (working copy) >@@ -1708,7 +1708,7 @@ void GraphicsContext::drawLinesForText(c > return; > > if (isRecording()) { >- m_displayListRecorder->drawLinesForText(point, widths, printing, doubleLines, strokeThickness()); >+ m_displayListRecorder->drawLinesForText(point, widths, printing, doubleLines, strokeStyle); > return; > } > >Index: Source/WebCore/platform/text/TextFlags.h >=================================================================== >--- Source/WebCore/platform/text/TextFlags.h (revision 234218) >+++ Source/WebCore/platform/text/TextFlags.h (working copy) >@@ -25,6 +25,8 @@ > > #pragma once > >+#include <wtf/text/TextStream.h> >+ > namespace WebCore { > > enum class TextRenderingMode : uint8_t { >@@ -40,6 +42,12 @@ enum class FontSmoothingMode : uint8_t { > Antialiased, > SubpixelAntialiased > }; >+ >+inline WTF::TextStream& operator<<(WTF::TextStream& ts, const FontSmoothingMode&) >+{ >+ // FIXME: dump the FontSmoothingMode to the TextStream. >+ return ts; >+} > > // This setting is used to provide ways of switching between multiple rendering modes that may have different > // metrics. It is used to switch between CG and GDI text on Windows. >Index: LayoutTests/ChangeLog >=================================================================== >--- LayoutTests/ChangeLog (revision 234218) >+++ LayoutTests/ChangeLog (working copy) >@@ -1,3 +1,20 @@ >+2018-07-25 Said Abou-Hallawa <sabouhallawa@apple.com> >+ >+ Templatize DisplayListItems and use std::tuple to store the arguments >+ https://bugs.webkit.org/show_bug.cgi?id=187002 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Rebaseline existing layout tests. >+ >+ * displaylists/canvas-display-list-expected.txt: >+ * displaylists/extent-includes-shadow-expected.txt: >+ * displaylists/extent-includes-transforms-expected.txt: >+ * displaylists/layer-dispay-list-expected.txt: >+ * displaylists/replay-skip-clipped-rect-expected.txt: >+ * platform/mac-wk1/displaylists/extent-includes-shadow-expected.txt: >+ * platform/mac-wk1/displaylists/extent-includes-transforms-expected.txt: >+ > 2018-07-25 Zalan Bujtas <zalan@apple.com> > > REGRESSION(r227577) Text on TV & Movies page doesn't wrap properly in iTunes >Index: LayoutTests/displaylists/canvas-display-list-expected.txt >=================================================================== >--- LayoutTests/displaylists/canvas-display-list-expected.txt (revision 234218) >+++ LayoutTests/displaylists/canvas-display-list-expected.txt (working copy) >@@ -1,13 +1,15 @@ > > (set-state >- (change-flags 256) >- (fill-color #C80000)) >+ (state-change >+ (change-flags 256) >+ (fill-color #C80000))) > (fill-rect > (extent at (10,10) size 55x50) > (rect at (10,10) size 55x50)) > (set-state >- (change-flags 256) >- (fill-color #0000C87F)) >+ (state-change >+ (change-flags 256) >+ (fill-color #0000C87F))) > (fill-rect > (extent at (30,30) size 55x50) > (rect at (30,30) size 55x50)) >Index: LayoutTests/displaylists/extent-includes-shadow-expected.txt >=================================================================== >--- LayoutTests/displaylists/extent-includes-shadow-expected.txt (revision 234218) >+++ LayoutTests/displaylists/extent-includes-shadow-expected.txt (working copy) >@@ -5,14 +5,15 @@ > (save > (restore-index 4)) > (set-state >- (change-flags 1024) >- (shadow-blur 12.00) >- (shadow-offset width=10 height=20) >- (shadows-use-legacy-radius 0)) >+ (state-change >+ (change-flags 1024) >+ (shadow-blur 12.00) >+ (shadow-offset width=10 height=20) >+ (shadows-use-legacy-radius 0))) > (fill-composited-rect > (extent at (43,50) size 134x137) > (rect at (50,50) size 100x100) > (color #0000FF) >- (composite-operation source-over) >+ (composite-operator source-over) > (blend-mode normal)) > (restore) >Index: LayoutTests/displaylists/extent-includes-transforms-expected.txt >=================================================================== >--- LayoutTests/displaylists/extent-includes-transforms-expected.txt (revision 234218) >+++ LayoutTests/displaylists/extent-includes-transforms-expected.txt (working copy) >@@ -2,19 +2,20 @@ > (translate > (x 0.00) > (y 22.00)) >-(concatentate-ctm >+(concatenate-ctm > (ctm {m=((0.87,0.50)(-0.50,0.87)) t=(81.70,-18.30)})) > (save > (restore-index 5)) > (set-state >- (change-flags 1024) >- (shadow-blur 12.00) >- (shadow-offset width=10 height=20) >- (shadows-use-legacy-radius 0)) >+ (state-change >+ (change-flags 1024) >+ (shadow-blur 12.00) >+ (shadow-offset width=10 height=20) >+ (shadows-use-legacy-radius 0))) > (fill-composited-rect > (extent at (7.14,0.20) size 184.55x185.65) > (rect at (0,0) size 100x100) > (color #0000FF) >- (composite-operation source-over) >+ (composite-operator source-over) > (blend-mode normal)) > (restore) >Index: LayoutTests/displaylists/layer-dispay-list-expected.txt >=================================================================== >--- LayoutTests/displaylists/layer-dispay-list-expected.txt (revision 234218) >+++ LayoutTests/displaylists/layer-dispay-list-expected.txt (working copy) >@@ -6,13 +6,14 @@ > (extent at (0,0) size 104x104) > (rect at (0,0) size 104x104) > (color #008000) >- (composite-operation source-over) >+ (composite-operator source-over) > (blend-mode normal)) > (set-state >- (change-flags 131456) >- (fill-color #0000FF) >- (stroke-style 0) >- (should-antialias 0)) >+ (state-change >+ (change-flags 131456) >+ (fill-color #0000FF) >+ (stroke-style 0) >+ (should-antialias 0))) > (draw-rect > (extent at (0,0) size 104x2) > (rect at (0,0) size 104x2) >Index: LayoutTests/displaylists/replay-skip-clipped-rect-expected.txt >=================================================================== >--- LayoutTests/displaylists/replay-skip-clipped-rect-expected.txt (revision 234218) >+++ LayoutTests/displaylists/replay-skip-clipped-rect-expected.txt (working copy) >@@ -6,7 +6,7 @@ recorded: > (extent at (412,0) size 100x100) > (rect at (412,0) size 100x100) > (color #0000FF) >- (composite-operation source-over) >+ (composite-operator source-over) > (blend-mode normal)) > > replayed: >Index: LayoutTests/platform/mac-wk1/displaylists/extent-includes-shadow-expected.txt >=================================================================== >--- LayoutTests/platform/mac-wk1/displaylists/extent-includes-shadow-expected.txt (revision 234218) >+++ LayoutTests/platform/mac-wk1/displaylists/extent-includes-shadow-expected.txt (working copy) >@@ -5,15 +5,16 @@ > (save > (restore-index 4)) > (set-state >- (change-flags 525312) >- (shadow-blur 12.00) >- (shadow-offset width=10 height=20) >- (shadows-use-legacy-radius 0) >- (should-subpixel-quantize-fonts 0)) >+ (state-change >+ (change-flags 525312) >+ (shadow-blur 12.00) >+ (shadow-offset width=10 height=20) >+ (shadows-use-legacy-radius 0) >+ (should-subpixel-quantize-fonts 0))) > (fill-composited-rect > (extent at (43,50) size 134x137) > (rect at (50,50) size 100x100) > (color #0000FF) >- (composite-operation source-over) >+ (composite-operator source-over) > (blend-mode normal)) > (restore) >Index: LayoutTests/platform/mac-wk1/displaylists/extent-includes-transforms-expected.txt >=================================================================== >--- LayoutTests/platform/mac-wk1/displaylists/extent-includes-transforms-expected.txt (revision 234218) >+++ LayoutTests/platform/mac-wk1/displaylists/extent-includes-transforms-expected.txt (working copy) >@@ -2,20 +2,21 @@ > (translate > (x 0.00) > (y 22.00)) >-(concatentate-ctm >+(concatenate-ctm > (ctm {m=((0.87,0.50)(-0.50,0.87)) t=(81.70,-18.30)})) > (save > (restore-index 5)) > (set-state >- (change-flags 525312) >- (shadow-blur 12.00) >- (shadow-offset width=10 height=20) >- (shadows-use-legacy-radius 0) >- (should-subpixel-quantize-fonts 0)) >+ (state-change >+ (change-flags 525312) >+ (shadow-blur 12.00) >+ (shadow-offset width=10 height=20) >+ (shadows-use-legacy-radius 0) >+ (should-subpixel-quantize-fonts 0))) > (fill-composited-rect > (extent at (7.14,0.20) size 184.55x185.65) > (rect at (0,0) size 100x100) > (color #0000FF) >- (composite-operation source-over) >+ (composite-operator source-over) > (blend-mode normal)) > (restore)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
ews-watchlist
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 187002
:
343504
|
343507
|
343512
|
343513
|
343754
|
343758
|
343762
|
343772
|
343773
|
343777
|
343778
|
343787
|
345016
|
345019
|
345022
|
345024
|
345026
|
345027
|
345035
|
345036
|
345166
|
345168
|
345172
|
345175
|
345183
|
345187
|
345190
|
345191
|
345196
|
345197
| 345808 |
345872