mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-26 04:07:51 +00:00
LibWeb+LibGfx: Refactor CSS filters into LibGfx
CSS filters work similarly to canvas filters, so it makes sense to have Gfx::Filter that can be used by both libraries in an analogous way as Gfx::Color.
This commit is contained in:
parent
bc971a4ccc
commit
9fd1223992
Notes:
github-actions[bot]
2024-12-18 17:55:46 +00:00
Author: https://github.com/ananas-dev
Commit: 9fd1223992
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2876
Reviewed-by: https://github.com/kalenikaliaksandr
Reviewed-by: https://github.com/shlyakpavel
18 changed files with 365 additions and 367 deletions
|
@ -92,19 +92,19 @@ String FilterValueListStyleValue::to_string(SerializationMode) const
|
|||
builder.appendff("{}(",
|
||||
[&] {
|
||||
switch (color.operation) {
|
||||
case FilterOperation::Color::Type::Brightness:
|
||||
case Gfx::ColorFilter::Type::Brightness:
|
||||
return "brightness"sv;
|
||||
case FilterOperation::Color::Type::Contrast:
|
||||
case Gfx::ColorFilter::Type::Contrast:
|
||||
return "contrast"sv;
|
||||
case FilterOperation::Color::Type::Grayscale:
|
||||
case Gfx::ColorFilter::Type::Grayscale:
|
||||
return "grayscale"sv;
|
||||
case FilterOperation::Color::Type::Invert:
|
||||
case Gfx::ColorFilter::Type::Invert:
|
||||
return "invert"sv;
|
||||
case FilterOperation::Color::Type::Opacity:
|
||||
case Gfx::ColorFilter::Type::Opacity:
|
||||
return "opacity"sv;
|
||||
case FilterOperation::Color::Type::Saturate:
|
||||
case Gfx::ColorFilter::Type::Saturate:
|
||||
return "saturate"sv;
|
||||
case FilterOperation::Color::Type::Sepia:
|
||||
case Gfx::ColorFilter::Type::Sepia:
|
||||
return "sepia"sv;
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibGfx/Filter.h>
|
||||
#include <LibWeb/CSS/Angle.h>
|
||||
#include <LibWeb/CSS/CalculatedOr.h>
|
||||
#include <LibWeb/CSS/Length.h>
|
||||
|
@ -44,15 +45,7 @@ struct HueRotate {
|
|||
};
|
||||
|
||||
struct Color {
|
||||
enum class Type {
|
||||
Brightness,
|
||||
Contrast,
|
||||
Grayscale,
|
||||
Invert,
|
||||
Opacity,
|
||||
Saturate,
|
||||
Sepia
|
||||
} operation;
|
||||
Gfx::ColorFilter::Type operation;
|
||||
Optional<NumberPercentage> amount {};
|
||||
float resolved_amount() const;
|
||||
bool operator==(Color const&) const = default;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue