mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:27:46 +00:00
LibWeb: Start absolutizing lengths after performing the CSS cascade
Once we've performed the cascade on a set of values for an element, we should have enough information to resolve/absolutize some lengths. Basically, any CSS length that isn't "auto" or a percentage can be turned into an absolute length (in pixels) as long as we have the following information: - The viewport rect - The parent element's font - The document element's font - The element's own font To ensure that we can absolutize lengths relative to the element's own font, we now do a separate first pass where font-related properties are defaulted (in the cascade spec sense of the word) and become usable. There's a lot more work to do here, but this should open up a lot of simplification in layout code, since it will no longer need to care about relative lengths. Layout still needs to resolve percentages, since we can't do that for some properties until the containing block dimensions are known.
This commit is contained in:
parent
30979c1956
commit
23a08fd35a
6 changed files with 305 additions and 51 deletions
|
@ -33,6 +33,9 @@ public:
|
|||
callback((CSS::PropertyID)it.key, *it.value);
|
||||
}
|
||||
|
||||
HashMap<CSS::PropertyID, NonnullRefPtr<StyleValue>>& properties() { return m_property_values; }
|
||||
HashMap<CSS::PropertyID, NonnullRefPtr<StyleValue>> const& properties() const { return m_property_values; }
|
||||
|
||||
void set_property(CSS::PropertyID, NonnullRefPtr<StyleValue> value);
|
||||
void set_property(CSS::PropertyID, const StringView&);
|
||||
Optional<NonnullRefPtr<StyleValue>> property(CSS::PropertyID) const;
|
||||
|
@ -73,6 +76,17 @@ public:
|
|||
return *m_font;
|
||||
}
|
||||
|
||||
Gfx::Font const& computed_font() const
|
||||
{
|
||||
VERIFY(m_font);
|
||||
return *m_font;
|
||||
}
|
||||
|
||||
void set_computed_font(NonnullRefPtr<Gfx::Font> font)
|
||||
{
|
||||
m_font = move(font);
|
||||
}
|
||||
|
||||
float line_height(const Layout::Node&) const;
|
||||
|
||||
bool operator==(const StyleProperties&) const;
|
||||
|
@ -81,6 +95,8 @@ public:
|
|||
Optional<CSS::Position> position() const;
|
||||
Optional<int> z_index() const;
|
||||
|
||||
static NonnullRefPtr<Gfx::Font> font_fallback(bool monospace, bool bold);
|
||||
|
||||
private:
|
||||
friend class StyleResolver;
|
||||
|
||||
|
@ -88,7 +104,6 @@ private:
|
|||
Optional<CSS::Overflow> overflow(CSS::PropertyID) const;
|
||||
|
||||
void load_font(Layout::Node const&) const;
|
||||
RefPtr<Gfx::Font> font_fallback(bool monospace, bool bold) const;
|
||||
|
||||
mutable RefPtr<Gfx::Font> m_font;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue