Andreas Kling
e5490ae1d1
LibWeb: Rename Layout::Node::style() => computed_values()
2021-01-06 14:58:48 +01:00
Andreas Kling
e187a5365a
LibWeb: Store the used font in Layout::NodeWithStyle
...
This is a step towards not having to carry the full set of specified
values around with every layout node.
2021-01-06 14:58:48 +01:00
Andreas Kling
5721b2a3da
LibWeb: Rename LayoutStyle => CSS::ComputedValues
...
This object represents the CSS "computed values" so let's call it that.
2021-01-06 14:58:48 +01:00
Andreas Kling
4a7d948f14
LibWeb: Simplify one kind of whitespace collapsing
...
For a non-empty TextNode chunk that begins with collapsible whitespace,
we can simply step right over the whitespace by adjusting the chunk.
2021-01-06 00:54:54 +01:00
Andreas Kling
22325dd63e
LibWeb: Don't careleslly insert inline-level boxes into inline-blocks
...
Just because an inline-block is inline doesn't mean it's ready to
accept random inline children. If it's a block, we may need to create
an anonymous wrapper first.
Fixes #4604 .
2021-01-04 22:32:34 +01:00
Andreas Kling
bf3772362a
LibWeb: When collapsing margins, consider border box heights
...
Empty boxes should be fully collapsed, but a box with border and/or
padding is not empty.
This fixes an issue where <hr> elements were getting weirdly collapsed
since they have zero content height (but some border height.)
2021-01-02 03:48:35 +01:00
Andreas Kling
5116b94114
LibWeb: Fix unnecessary wrapping of block boxes in anonymous blocks
...
Outside of tables, we don't need to wrap block-level boxes in anymous
blocks. Only inline-level boxes need this treatment.
2021-01-02 03:48:35 +01:00
Andreas Kling
07dd73c351
LibWeb: Remove hand-rolled is_foo() helpers in Layout::Node classes
2021-01-01 18:56:49 +01:00
Andreas Kling
fc86717f43
LibWeb: Demangle the names returned by Layout::Node::class_name()
...
Note that these are only used in debugging/test output so it's not
performance sensitive.
2021-01-01 16:42:44 +01:00
Andreas Kling
730af2c524
LibWeb: Simplify Layout::Node::class_name() with RTTI
2021-01-01 16:08:49 +01:00
Andreas Kling
865f524d5b
AK+LibGUI+LibWeb: Remove AK::TypeTraits in favor of RTTI-based helpers
...
Now that we have RTTI in userspace, we can do away with all this manual
hackery and use dynamic_cast.
We keep the is<T> and downcast<T> helpers since they still provide good
readability improvements. Note that unlike dynamic_cast<T>, downcast<T>
does not fail in a recoverable way, but will assert if the object being
casted is not a T.
2021-01-01 15:33:30 +01:00
Stephan Unverwerth
b4d1390714
LibGFX: Move default_xxx_font() methods from Font to FontDatabase
...
When we have an abstract font class it makes no sense to keep
these methods in the Font class.
2020-12-30 20:40:30 +01:00
Andreas Kling
18f1f4e1a2
LibWeb: Only preserve full whitspace for white-space: pre{,-wrap}
2020-12-18 11:04:29 +01:00
Andreas Kling
b322452ef4
LibWeb: Silence BFC spam about not knowing how to place boxes
...
This gets way too noisy on some pages, and isn't even interesting.
2020-12-18 10:25:50 +01:00
Andreas Kling
6d7892cfc4
LibWeb: Whitespace that causes a line to wrap should be hidden
...
We were only pruning trailing whitespace on lines. This patch makes it
so we also don't add whitespace as the leading line box fragment on new
lines.
This logic is pretty crufty and I think we can do better, but for now
I've just made it handle this extra case so we can stop having lines
that start with a space character. :^)
2020-12-17 21:10:57 +01:00
Andreas Kling
2a5877b02c
LibWeb: Fix shrink-to-fit layout for position:absolute
...
We were following the spec incorrectly. The comment was right, but the
code was wrong.
2020-12-17 01:47:42 +01:00
Andreas Kling
a5422a210f
LibWeb: Use the correct containing block for position:absolute width
2020-12-17 01:46:51 +01:00
Andreas Kling
f0a4a6bb11
LibWeb: Always break around inline-blocks in AllPossibleLineBreaks mode
2020-12-17 01:42:03 +01:00
Andreas Kling
f35f605a24
LibWeb: Make sure the ICB is at least as tall as the viewport
...
This is a hack until we implement a proper overflow mechanism. For now,
this allows us to right-click below the lowest content on the page.
2020-12-17 00:58:23 +01:00
Andreas Kling
525509cfe6
LibWeb: The fallback 'color' value should be black, not transparent
...
Fixes #4425 .
2020-12-16 15:46:43 +01:00
Andreas Kling
72bd672da0
LibWeb: Remove use of specified_style() in Layout::ImageBox
2020-12-15 20:50:58 +01:00
Andreas Kling
17c529e6c5
LibWeb: Generate the CSS::ValueID enum and its helper functions
2020-12-15 20:40:10 +01:00
Andreas Kling
92d8e559ba
LibWeb: Oops, not all length boxes should default to 'auto' values
...
Only the offset box (left/top/right/bottom) box defaults to 'auto'.
Both the padding and margin boxes default to '0' for all values.
2020-12-15 20:01:00 +01:00
Andreas Kling
23f70535e2
LibWeb: Dimension inline-block and replaced boxes during splitting
...
Don't wait until fragment layout to compute width/height of boxes on
the line, just do it while we're splitting into lines.
2020-12-15 19:33:53 +01:00
Andreas Kling
9c76c4f0cf
LibWeb: Use IdentifierStyleValue for CSS 'list-style-type'
2020-12-15 19:33:53 +01:00
Andreas Kling
c630ae517e
LibWeb: Put final foreground/background colors in LayoutStyle
...
This way we don't have to look them up in the CSS::StyleProperties
every time we want to paint with them.
2020-12-15 19:33:53 +01:00
Andreas Kling
78a51933ad
LibWeb: Use IdentifierStyleValue for CSS 'text-transform'
2020-12-15 19:33:53 +01:00
Andreas Kling
4d7ce81835
LibWeb: Use IdentifierStyleValue for CSS 'text-decoration-line'
...
Also 'text-decoration' is actually a shorthand, so treat it that way.
2020-12-15 19:33:53 +01:00
Andreas Kling
dd2e8b7dd0
LibWeb: Use IdentifierStyleValue for CSS 'position'
2020-12-14 20:43:25 +01:00
Andreas Kling
3247ea3581
LibWeb: Use CSS::ValueID for 'text-align' values
...
Let's start moving away from using raw strings for CSS identifiers.
The idea here is to use IdentifierStyleValue with a CSS::ValueID inside
for all CSS identifier values.
2020-12-14 20:43:25 +01:00
Andreas Kling
b861de0a13
LibWeb: Use final box model metrics for absolute 'right' and 'bottom'
...
We've already converted these to floats, so no need to do it again.
2020-12-14 12:49:35 +01:00
Andreas Kling
d1479aef56
LibWeb: Layout absolutely positioned children *after* computing height
...
This is required for CSS "bottom" to work correctly on absolutely
positioned elements.
2020-12-14 11:33:11 +01:00
Andreas Kling
9d442ba606
LibWeb: Store layout box model metrics as floats
...
Instead of storing them as CSS::Lengths, we now store the resolved
values for margin/padding/border/offset top/right/bottom/left with
each Layout::NodeWithStyleAndBoxModelMetrics.
This simplifies a lot of code since it's no longer necessary to
resolve values before using them.
2020-12-12 21:28:29 +01:00
Andreas Kling
2b8c7faee4
LibWeb: Use the margin box of floating elements for flowing around
...
Inline content flows around the entire margin box of floating elements,
not just the content box.
2020-12-12 19:59:24 +01:00
Andreas Kling
66e9dde86f
LibWeb: Don't place floating boxes before everything else
...
Instead, just handle them as we go about laying out block-level boxes.
2020-12-12 19:31:46 +01:00
Andreas Kling
b60801a9ba
LibWeb: Apply 'min-width' and 'max-width' constraints to replaced boxes
...
This is definitely not 100% correct but I tried implementing the basic
algorithms described in CSS 2.2. It's good enough to render the penguin
on @linusg's homepage at the right size. :^)
2020-12-12 00:29:49 +01:00
Andreas Kling
552ba1b0a3
LibWeb: Remove some unnecessary is_replaced() checks in BFC
...
BFC::compute_width() has a short-circuit path for replaced elements.
2020-12-11 22:59:46 +01:00
Andreas Kling
67732df034
LibWeb: Move replaced element layout out of Layout::ReplacedBox
...
Replaced elements are now laid out by the current formatting context.
Since the logic is almost identical in BFC and IFC, it's implemented
by static helpers in FormattingContext.
2020-12-11 22:59:46 +01:00
Andreas Kling
e8d6691470
LibWeb: Fix inline-block width computation with no specified width
...
Undefined width should be treated the same as width:auto;
2020-12-11 22:59:46 +01:00
Andreas Kling
350b2c6d9e
LibWeb: Use the surrounding text color as the caret color
...
This way you can always see the cursor as long (as you can see the text
you are editing.)
2020-12-10 11:39:47 +01:00
asynts
10f9c85090
LibWeb: Make DOM::Range more suitable for JS.
2020-12-09 21:05:06 +01:00
asynts
43dc47a494
LibWeb: Add support for range deletion.
2020-12-09 21:05:06 +01:00
asynts
bbcc5a9332
LibWeb: Move editing stuff into EditEventHandler.
2020-12-09 21:05:06 +01:00
Andreas Kling
3852168c84
LibWeb: Compute final line box width *after* placing all fragments
...
We were doing this after every fragment instead of after every line.
2020-12-07 21:48:23 +01:00
Andreas Kling
56ff2c112b
LibWeb: When adding inline-block fragment to line, use border box width
...
We were only using the content box width for inline-block fragments,
which caused them to not to claim the space needed for padding+border.
2020-12-07 21:47:13 +01:00
Andreas Kling
a3acbf1db2
LibWeb: Include padding+border in shrink-to-fit preferred min width
2020-12-07 21:13:41 +01:00
Andreas Kling
5a57f618ad
LibWeb: Resolve width in relative length units on inline-block properly
...
Element-relative width units like em, ex, etc. should be resolved
against the inline block itself, not against its containing block.
2020-12-07 20:55:44 +01:00
Andreas Kling
70de5fd056
LibWeb: Simplify final line box width computation
...
The width of a line box is the distance from the left edge of the first
fragment to the right edge of the last fragment. We don't have to loop
over all the fragments to figure this out. :^)
2020-12-07 20:48:26 +01:00
Andreas Kling
be18ac36b2
LibWeb: Use CSS::Length::resolved_or_zero() in a few places
2020-12-07 20:46:01 +01:00
Andreas Kling
cb04a5c52c
LibWeb: Forget floating boxes once we've gone past them
...
Once we've generated enough lines to make it past all the floating
boxes on either side, just forget those boxes. This simplifies the
available space computation since we don't have to consider boxes
that can't vertically intersect the current line anyway.
2020-12-06 21:11:28 +01:00