haikuwebkit/LayoutTests/inspector/canvas/resources
Darin Adler a77a158d4e Fix inspector viewing of canvas save/restore stack, and tighten and simplify CanvasRenderingContext2DBase
https://bugs.webkit.org/show_bug.cgi?id=222532

Reviewed by Sam Weinig.

Source/WebCore:

The inspector code is the only client that looks into the graphics context and gets at
saved states in the save/restore state stack. It was doing so in an inconsistent way, and
in may cases ignoring the state in the stack and simply using the current state. This fixes
almost everything to actually use the state stack.

Separately did some related refactoring. This includes a bit more inlining and removing a
class that was being used in the interface to Path where we can more simply use a Function<>.

* WebCore.xcodeproj/project.pbxproj: Removed StrokeStyleApplier.h.

* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::setFont): Use a global AtomString for the default font
family name so we don't potentially create a new one every time we call this function.
Call usesCSSCompatibilityParseMode so we don't have to get at private member
m_usesCSSCompatibilityParseMode.
(WebCore::CanvasRenderingContext2D::measureText): Call defaultFontFamily(), which returns
an AtomString so we don't have to look it up every time this function is called.
(WebCore::CanvasRenderingContext2D::drawTextInternal): Removed unnecessary allocation of a
TextMetrics object, which we don't use and then deallocate. Update since normalizedSpaces
now uses a return value instead of an in/out argument. Also use && instead of ?: and
update for name change of canDrawTextWithParams.

* html/canvas/CanvasRenderingContext2D.h: Removed unneeded header includes, unneeded
override of webkitBackingStorePixelRatio and made the override of is2d private, since
no one should need to call it on a CanvasRenderingContext2D.

* html/canvas/CanvasRenderingContext2DBase.cpp: Use constexpr for a file-local constant.
(WebCore::CanvasStrokeStyleApplier::CanvasStrokeStyleApplier): Deleted this entire class,
since we now use a function instead of an object.
(WebCore::toCanvasLineCap): Moved these functions to the top of the file since they are
now used in the State class.
(WebCore::fromCanvasLineCap): Ditto.
(WebCore::toCanvasLineJoin): Ditto.
(WebCore::fromCanvasLineJoin): Ditto.
(WebCore::toCanvasTextAlign): Ditto.
(WebCore::fromCanvasTextAlign): Ditto.
(WebCore::toCanvasTextBaseline): Ditto.
(WebCore::fromCanvasTextBaseline): Ditto.
(WebCore::CanvasRenderingContext2DBase::State::operator=): Deleted the copy constructor
and assignment operator since they are the default ones.
(WebCore::CanvasRenderingContext2DBase::State::fontString const): Added. Moved the code
here from the function named font, making it possible to use this in the inspector code.
(WebCore::CanvasRenderingContext2DBase::State::canvasLineCap const): Ditto.
(WebCore::CanvasRenderingContext2DBase::State::canvasLineJoin const): Ditto.
(WebCore::CanvasRenderingContext2DBase::State::canvasTextAlign const): Ditto.
(WebCore::CanvasRenderingContext2DBase::State::canvasTextBaseline const): Ditto.
(WebCore::CanvasRenderingContext2DBase::State::globalCompositeOperationString const): Ditto.
(WebCore::CanvasRenderingContext2DBase::State::shadowColorString const): Ditto.
(WebCore::CanvasRenderingContext2DBase::lineWidth const): Moved to the header.
(WebCore::CanvasRenderingContext2DBase::lineCap const): Ditto.
(WebCore::CanvasRenderingContext2DBase::lineJoin const): Ditto.
(WebCore::CanvasRenderingContext2DBase::miterLimit const): Ditto.
(WebCore::CanvasRenderingContext2DBase::shadowOffsetX const): Ditto.
(WebCore::CanvasRenderingContext2DBase::shadowOffsetY const): Ditto.
(WebCore::CanvasRenderingContext2DBase::shadowBlur const): Ditto.
(WebCore::CanvasRenderingContext2DBase::shadowColor const): Ditto.
(WebCore::CanvasRenderingContext2DBase::getLineDash const): Ditto.
(WebCore::CanvasRenderingContext2DBase::lineDashOffset const): Ditto.
(WebCore::CanvasRenderingContext2DBase::globalAlpha const): Ditto.
(WebCore::CanvasRenderingContext2DBase::globalCompositeOperation const): Ditto.
(WebCore::isFullCanvasCompositeMode): Made this file local, no longer a member function.
(WebCore::CanvasRenderingContext2DBase::isPointInPathInternal): Tweak style to match
the following function.
(WebCore::CanvasRenderingContext2DBase::isPointInStrokeInternal): Use a lambda for the
stroke style applier so we don't need a class.
(WebCore::CanvasRenderingContext2DBase::didDrawEntireCanvas): Updated since didDraw
now takes an OptionSet.
(WebCore::CanvasRenderingContext2DBase::didDraw): Updated to take an OptionSet.
(WebCore::CanvasRenderingContext2DBase::getImageData const): Use a single makeString
instead of a StringBuilder for an error message.
(WebCore::CanvasRenderingContext2DBase::putImageData): Updated since didDraw now
takes an OptionSet.
(WebCore::CanvasRenderingContext2DBase::imageSmoothingQuality const): Moved to the header.
(WebCore::CanvasRenderingContext2DBase::imageSmoothingEnabled const): Ditto.
(WebCore::CanvasRenderingContext2DBase::font const): Ditto. The bulk of the function is
now in CanvasRenderingContext2DBase::State::fontString.
(WebCore::CanvasRenderingContext2DBase::textAlign const): Deleted.
(WebCore::CanvasRenderingContext2DBase::textBaseline const): Deleted.
(WebCore::CanvasRenderingContext2DBase::canDrawText): Renamed from canDrawTextWithParams,
since the fact that a function has parameters doesn't need to be part of its name.
(WebCore::CanvasRenderingContext2DBase::normalizeSpaces): Use a return value instead of
an in/out argument for better clarity. This also matches the needs of all the call sites.
(WebCore::CanvasRenderingContext2DBase::drawText): Updated for changes to canDrawText
and normalizeSpaces.
(WebCore::CanvasRenderingContext2DBase::measureTextInternal): Ditto.

* html/canvas/CanvasRenderingContext2DBase.h: Removed unneeded forward declarations.
Made the constructor protected. Moved the code for many simple getters here so they
can be inlined. The main call site is the JavaScript bindings. Removed unused getLineCap
and getLineJoin functions. Made the webkitBackingStorePixelRatio function static and
constexpr. Removed unused usesDisplayListDrawing function. Marked the FontProxy
class final. Removed the explicit copy constructor and assignment operator from the State
struct: letting the compiler generate it is better for our purposes. Made the state
function protected. Made most formerly-protected members private instead, since there
is no need for derived classes to use them. Made the enumeration CanvasDidDrawOption
into an enum class named DidDrawOption and use it with OptionSet instead of passing it
as an unsigned. Marked hasInvertibleTransform final instead of override.

* html/canvas/OffscreenCanvasRenderingContext2D.cpp:
(WebCore::OffscreenCanvasRenderingContext2D::setFont): Call usesCSSCompatibilityParseMode
so we don't have to get at private member m_usesCSSCompatibilityParseMode.

* html/canvas/OffscreenCanvasRenderingContext2D.h: Made isOffscreen2d private.

* html/canvas/PaintRenderingContext2D.h: Made isPaint private.

* inspector/InspectorCanvas.cpp:
(WebCore::InspectorCanvas::buildInitialState): When iterating the state stack, do not
get anything directly from the context, since it will give the value for the current
state, not the stack element we are iterating. Added a FIXME for the one case where
this was not easy to fix, "setPath", and left it broken as before.

* platform/graphics/ImageBufferBackend.cpp:
(WebCore::ImageBufferBackend::getImageData const): Removed unneeded null check for
the data. ImageData::create will return nullptr, not an object with nullptr for data.

* platform/graphics/Path.h: Use Function<void(GraphicsContext&)> instead of
StrkeStyleApplier.

* platform/graphics/StrokeStyleApplier.h: Removed.

* platform/graphics/cairo/PathCairo.cpp:
(WebCore::Path::strokeBoundingRect const): Use Function<void(GraphicsContext&)>.
(WebCore::Path::strokeContains const): Ditto.
* platform/graphics/cg/PathCG.cpp:
(WebCore::Path::strokeContains const): Ditto.
(WebCore::Path::strokeBoundingRect const): Ditto.
* platform/graphics/win/PathDirect2D.cpp:
(WebCore::Path::strokeContains const): Ditto.
(WebCore::Path::strokeBoundingRect const): Ditto.

* rendering/svg/RenderSVGResourceGradient.cpp:
(WebCore::RenderSVGResourceGradient::applyResource): Pass a reference to
SVGRenderSupport::applyStrokeStyleToContext instead of a pointer.
* rendering/svg/RenderSVGResourcePattern.cpp:
(WebCore::RenderSVGResourcePattern::applyResource): Ditto.
* rendering/svg/RenderSVGResourceSolidColor.cpp:
(WebCore::RenderSVGResourceSolidColor::applyResource): Ditto.
* rendering/svg/RenderSVGShape.cpp:
(WebCore::RenderSVGShape::shapeDependentStrokeContains): Use a lambda instead of
a StrokeStyleApplier object when calling strokeContainer.
(WebCore::RenderSVGShape::calculateStrokeBoundingBox const): Use a lambda instead
of a StrokeStyleApplier object when calling strokeBoundingRect.

* rendering/svg/SVGRenderSupport.cpp:
(WebCore::SVGRenderSupport::applyStrokeStyleToContext): Take a reference rather
than a pointer.
* rendering/svg/SVGRenderSupport.h: Updated for the above.

LayoutTests:

* inspector/canvas/recording-2d-frameCount-expected.txt: Update since the state stack value of
the direction property is now correctly saved.
* inspector/canvas/recording-2d-full-expected.txt: Ditto.
* inspector/canvas/recording-2d-memoryLimit-expected.txt: Ditto.

* inspector/canvas/recording-2d-saves-expected.txt: Updated.
* inspector/canvas/recording-2d-saves.html: Added tests of setting all the properties
that the inspector canvas state machinery serializes, rather than just testing fillStyle.
* inspector/canvas/resources/recording-2d.js:
(performSavePreActions.saveAndSet): Ditto.
(performSavePreActions): Ditto.

Canonical link: https://commits.webkit.org/235035@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274101 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-08 21:47:39 +00:00
..
create-context-utilities.css
create-context-utilities.js
recording-2d.js Fix inspector viewing of canvas save/restore stack, and tighten and simplify CanvasRenderingContext2DBase 2021-03-08 21:47:39 +00:00
recording-bitmaprenderer.js
recording-utilities.js
recording-webgl.js [WebGL2] Various parameters should be non-nullable in IDL 2020-08-18 23:49:22 +00:00
recording-webgl2.js Web Inspector: `RecordCanvasActionVariant` causes a huge symbol to be created in WebCore 2021-03-04 01:34:21 +00:00
shaderProgram-utilities-webgl.js
shaderProgram-utilities-webgpu.js