1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:07:45 +00:00

LibWeb: Port CanvasRenderingContext2D from DeprecatedString to String

This commit is contained in:
Shannon Booth 2023-09-06 19:41:48 +12:00 committed by Andrew Kaster
parent da1f137967
commit d312fdc2d3
8 changed files with 29 additions and 29 deletions

View file

@ -18,14 +18,14 @@ public:
virtual void begin_path() = 0;
virtual void fill(DeprecatedString const& fill_rule) = 0;
virtual void fill(Path2D& path, DeprecatedString const& fill_rule) = 0;
virtual void fill(StringView fill_rule) = 0;
virtual void fill(Path2D& path, StringView fill_rule) = 0;
virtual void stroke() = 0;
virtual void stroke(Path2D const& path) = 0;
virtual void clip(DeprecatedString const& fill_rule) = 0;
virtual void clip(Path2D& path, DeprecatedString const& fill_rule) = 0;
virtual void clip(StringView fill_rule) = 0;
virtual void clip(Path2D& path, StringView fill_rule) = 0;
protected:
CanvasDrawPath() = default;

View file

@ -9,7 +9,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/String.h>
#include <LibWeb/HTML/Canvas/CanvasState.h>
#include <LibWeb/HTML/CanvasGradient.h>
#include <LibWeb/HTML/CanvasPattern.h>
@ -21,12 +21,12 @@ template<typename IncludingClass>
class CanvasFillStrokeStyles {
public:
~CanvasFillStrokeStyles() = default;
using FillOrStrokeStyleVariant = Variant<DeprecatedString, JS::Handle<CanvasGradient>, JS::Handle<CanvasPattern>>;
using FillOrStrokeStyleVariant = Variant<String, JS::Handle<CanvasGradient>, JS::Handle<CanvasPattern>>;
static CanvasState::FillOrStrokeStyle to_canvas_state_fill_or_stroke_style(auto const& style)
{
return style.visit(
[&](DeprecatedString const& string) -> CanvasState::FillOrStrokeStyle {
[&](String const& string) -> CanvasState::FillOrStrokeStyle {
return Gfx::Color::from_string(string).value_or(Color::Black);
},
[&](auto fill_or_stroke_style) -> CanvasState::FillOrStrokeStyle {

View file

@ -52,13 +52,13 @@ public:
Optional<Gfx::Color> as_color() const;
Gfx::Color to_color_but_fixme_should_accept_any_paint_style() const;
using JsFillOrStrokeStyle = Variant<DeprecatedString, JS::Handle<CanvasGradient>, JS::Handle<CanvasPattern>>;
using JsFillOrStrokeStyle = Variant<String, JS::Handle<CanvasGradient>, JS::Handle<CanvasPattern>>;
JsFillOrStrokeStyle to_js_fill_or_stroke_style() const
{
return m_fill_or_stroke_style.visit(
[&](Gfx::Color color) -> JsFillOrStrokeStyle {
return color.to_deprecated_string();
return MUST(String::from_deprecated_string(color.to_deprecated_string()));
},
[&](auto handle) -> JsFillOrStrokeStyle {
return handle;

View file

@ -17,9 +17,9 @@ class CanvasText {
public:
virtual ~CanvasText() = default;
virtual void fill_text(DeprecatedString const&, float x, float y, Optional<double> max_width) = 0;
virtual void stroke_text(DeprecatedString const&, float x, float y, Optional<double> max_width) = 0;
virtual JS::NonnullGCPtr<TextMetrics> measure_text(DeprecatedString const& text) = 0;
virtual void fill_text(StringView, float x, float y, Optional<double> max_width) = 0;
virtual void stroke_text(StringView, float x, float y, Optional<double> max_width) = 0;
virtual JS::NonnullGCPtr<TextMetrics> measure_text(StringView text) = 0;
protected:
CanvasText() = default;

View file

@ -36,7 +36,7 @@ public:
font_style_value.font_families()->to_string());
}
void set_font(DeprecatedString const& font)
void set_font(StringView font)
{
// The font IDL attribute, on setting, must be parsed as a CSS <'font'> value (but without supporting property-independent style sheet syntax like 'inherit'),
// and the resulting font must be assigned to the context, with the 'line-height' component forced to 'normal', with the 'font-size' component converted to CSS pixels,