summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/CSS/ComputedValues.h7
-rw-r--r--Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp8
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleProperties.cpp6
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleProperties.h2
-rw-r--r--Userland/Libraries/LibWeb/Layout/Node.cpp5
-rw-r--r--Userland/Libraries/LibWeb/Painting/StackingContext.cpp6
6 files changed, 14 insertions, 20 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/ComputedValues.h b/Userland/Libraries/LibWeb/CSS/ComputedValues.h
index c6d2a605f3..ae0c51b002 100644
--- a/Userland/Libraries/LibWeb/CSS/ComputedValues.h
+++ b/Userland/Libraries/LibWeb/CSS/ComputedValues.h
@@ -36,6 +36,7 @@ public:
static CSS::PointerEvents pointer_events() { return CSS::PointerEvents::Auto; }
static float flex_grow() { return 0.0f; }
static float flex_shrink() { return 1.0f; }
+ static float opacity() { return 1.0f; }
};
struct BorderData {
@@ -83,7 +84,7 @@ public:
float flex_grow() const { return m_noninherited.flex_grow; }
float flex_shrink() const { return m_noninherited.flex_shrink; }
CSS::AlignItems align_items() const { return m_noninherited.align_items; }
- Optional<float> const& opacity() const { return m_noninherited.opacity; }
+ float opacity() const { return m_noninherited.opacity; }
CSS::JustifyContent justify_content() const { return m_noninherited.justify_content; }
Optional<BoxShadowData> const& box_shadow() const { return m_noninherited.box_shadow; }
CSS::BoxSizing box_sizing() const { return m_noninherited.box_sizing; }
@@ -183,7 +184,7 @@ protected:
CSS::JustifyContent justify_content { InitialValues::justify_content() };
CSS::Overflow overflow_x { InitialValues::overflow() };
CSS::Overflow overflow_y { InitialValues::overflow() };
- Optional<float> opacity;
+ float opacity { InitialValues::opacity() };
Optional<BoxShadowData> box_shadow {};
Vector<CSS::Transformation> transformations {};
CSS::BoxSizing box_sizing { InitialValues::box_sizing() };
@@ -236,7 +237,7 @@ public:
void set_flex_grow(float value) { m_noninherited.flex_grow = value; }
void set_flex_shrink(float value) { m_noninherited.flex_shrink = value; }
void set_align_items(CSS::AlignItems value) { m_noninherited.align_items = value; }
- void set_opacity(Optional<float> value) { m_noninherited.opacity = value; }
+ void set_opacity(float value) { m_noninherited.opacity = value; }
void set_justify_content(CSS::JustifyContent value) { m_noninherited.justify_content = value; }
void set_box_shadow(Optional<BoxShadowData> value) { m_noninherited.box_shadow = move(value); }
void set_transformations(Vector<CSS::Transformation> value) { m_noninherited.transformations = move(value); }
diff --git a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp
index 598ee9da90..87d14261e4 100644
--- a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp
+++ b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp
@@ -501,12 +501,8 @@ RefPtr<StyleValue> ResolvedCSSStyleDeclaration::style_value_for_property(Layout:
return NumericStyleValue::create_float(layout_node.computed_values().flex_grow());
case CSS::PropertyID::FlexShrink:
return NumericStyleValue::create_float(layout_node.computed_values().flex_shrink());
- case CSS::PropertyID::Opacity: {
- auto maybe_opacity = layout_node.computed_values().opacity();
- if (!maybe_opacity.has_value())
- return {};
- return NumericStyleValue::create_float(maybe_opacity.release_value());
- }
+ case CSS::PropertyID::Opacity:
+ return NumericStyleValue::create_float(layout_node.computed_values().opacity());
case CSS::PropertyID::JustifyContent:
return IdentifierStyleValue::create(to_css_value_id(layout_node.computed_values().justify_content()));
case CSS::PropertyID::BoxShadow: {
diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp
index c7eeaa66e7..31e45961ac 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp
+++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp
@@ -121,11 +121,11 @@ Optional<int> StyleProperties::z_index() const
return {};
}
-Optional<float> StyleProperties::opacity() const
+float StyleProperties::opacity() const
{
auto maybe_value = property(CSS::PropertyID::Opacity);
if (!maybe_value.has_value())
- return {};
+ return 1.0f;
auto& value = maybe_value.value();
if (value->has_number())
@@ -137,7 +137,7 @@ Optional<float> StyleProperties::opacity() const
return clamp(length.raw_value() / 100.0f, 0.0f, 1.0f);
}
- return {};
+ return 1.0f;
}
Optional<CSS::FlexDirection> StyleProperties::flex_direction() const
diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.h b/Userland/Libraries/LibWeb/CSS/StyleProperties.h
index f908f51785..5115f931a7 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleProperties.h
+++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.h
@@ -59,7 +59,7 @@ public:
float flex_grow() const;
float flex_shrink() const;
Optional<CSS::AlignItems> align_items() const;
- Optional<float> opacity() const;
+ float opacity() const;
Optional<CSS::JustifyContent> justify_content() const;
Optional<CSS::Overflow> overflow_x() const;
Optional<CSS::Overflow> overflow_y() const;
diff --git a/Userland/Libraries/LibWeb/Layout/Node.cpp b/Userland/Libraries/LibWeb/Layout/Node.cpp
index 793a7eccc9..bcbf449d5c 100644
--- a/Userland/Libraries/LibWeb/Layout/Node.cpp
+++ b/Userland/Libraries/LibWeb/Layout/Node.cpp
@@ -77,10 +77,7 @@ bool Node::establishes_stacking_context() const
auto position = computed_values().position();
if (position == CSS::Position::Absolute || position == CSS::Position::Relative || position == CSS::Position::Fixed || position == CSS::Position::Sticky)
return true;
- auto opacity = computed_values().opacity();
- if (opacity.has_value() && opacity.value() != 1.0f)
- return true;
- return false;
+ return computed_values().opacity() < 1.0f;
}
HitTestResult Node::hit_test(const Gfx::IntPoint& position, HitTestType type) const
diff --git a/Userland/Libraries/LibWeb/Painting/StackingContext.cpp b/Userland/Libraries/LibWeb/Painting/StackingContext.cpp
index 9a99ff06aa..4bb3d75c16 100644
--- a/Userland/Libraries/LibWeb/Painting/StackingContext.cpp
+++ b/Userland/Libraries/LibWeb/Painting/StackingContext.cpp
@@ -113,10 +113,10 @@ void StackingContext::paint(PaintContext& context)
}
auto opacity = m_box.computed_values().opacity();
- if (opacity.has_value() && opacity.value() == 0.0f)
+ if (opacity == 0.0f)
return;
- if (opacity.has_value() && opacity.value() != 1.0f) {
+ if (opacity < 1.0f) {
auto bitmap = context.painter().target();
auto new_bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRA8888, bitmap->size());
if (!new_bitmap)
@@ -124,7 +124,7 @@ void StackingContext::paint(PaintContext& context)
Gfx::Painter painter(*new_bitmap);
PaintContext paint_context(painter, context.palette(), context.scroll_offset());
paint_internal(paint_context);
- context.painter().blit(Gfx::IntPoint(m_box.absolute_position()), *new_bitmap, Gfx::IntRect(m_box.absolute_rect()), opacity.value());
+ context.painter().blit(Gfx::IntPoint(m_box.absolute_position()), *new_bitmap, Gfx::IntRect(m_box.absolute_rect()), opacity);
} else {
paint_internal(context);
}