mirror of
https://github.com/RGBCube/serenity
synced 2025-07-17 08:47:35 +00:00
LibWeb: Use CSS Pixels for viewport rects
This commit is contained in:
parent
8cc0bdf777
commit
4084c66ad2
7 changed files with 17 additions and 17 deletions
|
@ -70,7 +70,7 @@ Length Length::resolved(Layout::Node const& layout_node) const
|
|||
return *this;
|
||||
}
|
||||
|
||||
CSSPixels Length::relative_length_to_px(Gfx::IntRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, CSSPixels font_size, CSSPixels root_font_size) const
|
||||
CSSPixels Length::relative_length_to_px(CSSPixelRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, CSSPixels font_size, CSSPixels root_font_size) const
|
||||
{
|
||||
switch (m_type) {
|
||||
case Type::Ex:
|
||||
|
@ -105,7 +105,7 @@ CSSPixels Length::to_px(Layout::Node const& layout_node) const
|
|||
|
||||
if (!layout_node.document().browsing_context())
|
||||
return 0;
|
||||
auto const& viewport_rect = layout_node.document().browsing_context()->viewport_rect().to_type<float>().to_type<int>();
|
||||
auto const& viewport_rect = layout_node.document().browsing_context()->viewport_rect();
|
||||
auto* root_element = layout_node.document().document_element();
|
||||
if (!root_element || !root_element->layout_node())
|
||||
return 0;
|
||||
|
|
|
@ -83,7 +83,7 @@ public:
|
|||
|
||||
CSSPixels to_px(Layout::Node const&) const;
|
||||
|
||||
ALWAYS_INLINE CSSPixels to_px(Gfx::IntRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, CSSPixels font_size, CSSPixels root_font_size) const
|
||||
ALWAYS_INLINE CSSPixels to_px(CSSPixelRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, CSSPixels font_size, CSSPixels root_font_size) const
|
||||
{
|
||||
if (is_auto())
|
||||
return 0;
|
||||
|
@ -124,7 +124,7 @@ public:
|
|||
// this file already. To break the cyclic dependency, we must move all method definitions out.
|
||||
bool operator==(Length const& other) const;
|
||||
|
||||
CSSPixels relative_length_to_px(Gfx::IntRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, CSSPixels font_size, CSSPixels root_font_size) const;
|
||||
CSSPixels relative_length_to_px(CSSPixelRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, CSSPixels font_size, CSSPixels root_font_size) const;
|
||||
|
||||
private:
|
||||
char const* unit_name() const;
|
||||
|
|
|
@ -163,7 +163,7 @@ bool MediaFeature::compare(HTML::Window const& window, MediaFeatureValue left, C
|
|||
left_px = left.length().absolute_length_to_px();
|
||||
right_px = right.length().absolute_length_to_px();
|
||||
} else {
|
||||
Gfx::IntRect viewport_rect { 0, 0, window.inner_width(), window.inner_height() };
|
||||
auto viewport_rect = window.page()->web_exposed_screen_area();
|
||||
|
||||
auto const& initial_font = window.associated_document().style_computer().initial_font();
|
||||
Gfx::FontPixelMetrics const& initial_font_metrics = initial_font.pixel_metrics();
|
||||
|
|
|
@ -1437,10 +1437,10 @@ void StyleComputer::invalidate_rule_cache()
|
|||
m_rule_cache = nullptr;
|
||||
}
|
||||
|
||||
Gfx::IntRect StyleComputer::viewport_rect() const
|
||||
CSSPixelRect StyleComputer::viewport_rect() const
|
||||
{
|
||||
if (auto const* browsing_context = document().browsing_context())
|
||||
return browsing_context->viewport_rect().to_type<float>().to_type<int>();
|
||||
return browsing_context->viewport_rect();
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ private:
|
|||
template<typename Callback>
|
||||
void for_each_stylesheet(CascadeOrigin, Callback) const;
|
||||
|
||||
Gfx::IntRect viewport_rect() const;
|
||||
CSSPixelRect viewport_rect() const;
|
||||
CSSPixels root_element_font_size() const;
|
||||
|
||||
struct MatchingRuleSet {
|
||||
|
|
|
@ -2557,7 +2557,7 @@ NonnullRefPtr<LengthStyleValue> LengthStyleValue::create(Length const& length)
|
|||
return adopt_ref(*new LengthStyleValue(length));
|
||||
}
|
||||
|
||||
static Optional<CSS::Length> absolutized_length(CSS::Length const& length, Gfx::IntRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, float font_size, float root_font_size)
|
||||
static Optional<CSS::Length> absolutized_length(CSS::Length const& length, CSSPixelRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, CSSPixels font_size, CSSPixels root_font_size)
|
||||
{
|
||||
if (length.is_px())
|
||||
return {};
|
||||
|
@ -2568,19 +2568,19 @@ static Optional<CSS::Length> absolutized_length(CSS::Length const& length, Gfx::
|
|||
return {};
|
||||
}
|
||||
|
||||
NonnullRefPtr<StyleValue> StyleValue::absolutized(Gfx::IntRect const&, Gfx::FontPixelMetrics const&, float, float) const
|
||||
NonnullRefPtr<StyleValue> StyleValue::absolutized(CSSPixelRect const&, Gfx::FontPixelMetrics const&, CSSPixels, CSSPixels) const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
NonnullRefPtr<StyleValue> LengthStyleValue::absolutized(Gfx::IntRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, float font_size, float root_font_size) const
|
||||
NonnullRefPtr<StyleValue> LengthStyleValue::absolutized(CSSPixelRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, CSSPixels font_size, CSSPixels root_font_size) const
|
||||
{
|
||||
if (auto length = absolutized_length(m_length, viewport_rect, font_metrics, font_size, root_font_size); length.has_value())
|
||||
return LengthStyleValue::create(length.release_value());
|
||||
return *this;
|
||||
}
|
||||
|
||||
NonnullRefPtr<StyleValue> ShadowStyleValue::absolutized(Gfx::IntRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, float font_size, float root_font_size) const
|
||||
NonnullRefPtr<StyleValue> ShadowStyleValue::absolutized(CSSPixelRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, CSSPixels font_size, CSSPixels root_font_size) const
|
||||
{
|
||||
auto absolutized_offset_x = absolutized_length(m_offset_x, viewport_rect, font_metrics, font_size, root_font_size).value_or(m_offset_x);
|
||||
auto absolutized_offset_y = absolutized_length(m_offset_y, viewport_rect, font_metrics, font_size, root_font_size).value_or(m_offset_y);
|
||||
|
@ -2589,7 +2589,7 @@ NonnullRefPtr<StyleValue> ShadowStyleValue::absolutized(Gfx::IntRect const& view
|
|||
return ShadowStyleValue::create(m_color, absolutized_offset_x, absolutized_offset_y, absolutized_blur_radius, absolutized_spread_distance, m_placement);
|
||||
}
|
||||
|
||||
NonnullRefPtr<StyleValue> BorderRadiusStyleValue::absolutized(Gfx::IntRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, float font_size, float root_font_size) const
|
||||
NonnullRefPtr<StyleValue> BorderRadiusStyleValue::absolutized(CSSPixelRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, CSSPixels font_size, CSSPixels root_font_size) const
|
||||
{
|
||||
if (m_horizontal_radius.is_percentage() && m_vertical_radius.is_percentage())
|
||||
return *this;
|
||||
|
|
|
@ -395,7 +395,7 @@ public:
|
|||
virtual bool has_number() const { return false; }
|
||||
virtual bool has_integer() const { return false; }
|
||||
|
||||
virtual NonnullRefPtr<StyleValue> absolutized(Gfx::IntRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, float font_size, float root_font_size) const;
|
||||
virtual NonnullRefPtr<StyleValue> absolutized(CSSPixelRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, CSSPixels font_size, CSSPixels root_font_size) const;
|
||||
|
||||
virtual Color to_color(Layout::NodeWithStyle const&) const { return {}; }
|
||||
virtual EdgeRect to_rect() const { VERIFY_NOT_REACHED(); }
|
||||
|
@ -610,7 +610,7 @@ private:
|
|||
m_is_elliptical = (m_horizontal_radius != m_vertical_radius);
|
||||
}
|
||||
|
||||
virtual NonnullRefPtr<StyleValue> absolutized(Gfx::IntRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, float font_size, float root_font_size) const override;
|
||||
virtual NonnullRefPtr<StyleValue> absolutized(CSSPixelRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, CSSPixels font_size, CSSPixels root_font_size) const override;
|
||||
|
||||
bool m_is_elliptical;
|
||||
LengthPercentage m_horizontal_radius;
|
||||
|
@ -1447,7 +1447,7 @@ public:
|
|||
virtual DeprecatedString to_deprecated_string() const override { return m_length.to_deprecated_string(); }
|
||||
virtual Length to_length() const override { return m_length; }
|
||||
virtual ValueID to_identifier() const override { return has_auto() ? ValueID::Auto : ValueID::Invalid; }
|
||||
virtual NonnullRefPtr<StyleValue> absolutized(Gfx::IntRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, float font_size, float root_font_size) const override;
|
||||
virtual NonnullRefPtr<StyleValue> absolutized(CSSPixelRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, CSSPixels font_size, CSSPixels root_font_size) const override;
|
||||
virtual bool equals(StyleValue const& other) const override;
|
||||
|
||||
private:
|
||||
|
@ -1670,7 +1670,7 @@ private:
|
|||
{
|
||||
}
|
||||
|
||||
virtual NonnullRefPtr<StyleValue> absolutized(Gfx::IntRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, float font_size, float root_font_size) const override;
|
||||
virtual NonnullRefPtr<StyleValue> absolutized(CSSPixelRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, CSSPixels font_size, CSSPixels root_font_size) const override;
|
||||
|
||||
Color m_color;
|
||||
Length m_offset_x;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue