Commit graph

15195 commits

Author SHA1 Message Date
Andreas Kling 195ef5e26f LibWeb: Bring CSS line-height implementation closer to spec
We now distribute the line-height evenly between the space above and
below inline-level boxes. This noticeably improves our baseline
alignment in many cases.

Note that the "vertical-align: <length>" case is quite awkward, as the
extra height added by the offset baseline must count towards the line
box height.

There's a lot of room for improvement here, but this makes the buckets
container on Acid3 show up in the right place, with the right size.
2022-03-24 22:52:44 +01:00
Timothy Flynn 430559ea51 LibWeb: Weakly store a reference to the Window object in timer tasks
This prevents a crash when refreshing or navigating away from the Acid3
test page while it is actively running.
2022-03-24 21:37:58 +01:00
Idan Horowitz 02004b7055 LibWeb: Handle XML MIME types in HTMLObjectElement 2022-03-24 21:37:49 +01:00
Idan Horowitz 215432c3e8 LibWeb: Discard ObjectElement's nested browsing context on image load 2022-03-24 21:37:49 +01:00
Idan Horowitz f82d4d001d LibWeb: Implement getSVGDocument() for BrowsingContextContainer
Specifically HTMLIFrameElement and HTMLObjectElement. HTMLEmbedElement
will gain it automatically once it's also converted to inherit from
BrowsingContextContainer.
2022-03-24 21:37:49 +01:00
Idan Horowitz fed11e625e LibWeb: Expose contentDocument on HTMLObjectElement 2022-03-24 21:37:49 +01:00
Idan Horowitz 5626e1b324 LibWeb: Rename PARSER_DEBUG => HTML_PARSER_DEBUG
Since this macro was created we gained a couple more parsers in the
system :^)
2022-03-24 21:37:49 +01:00
Sam Atkins 1499d2421e LibWeb: Align text shadows the same way we align text
This makes the shadow line-up correctly on Acid3. :^)
2022-03-24 20:30:26 +01:00
Sahan Fernando 05f9146af8 3DFileViewer: Enable smooth shading in viewer + teapot model 2022-03-24 19:22:27 +01:00
Andreas Kling ed1576eea8 LibWeb: Align baseline of inline-block with non-zero top border/padding
We were not adjusting the fragment baseline for inline-blocks that had
some border and/or padding size up top.
2022-03-24 18:30:56 +01:00
Andreas Kling 54ffe79d70 LibWeb: Fix missing line-height & font-size on some anonymous blocks
Make sure we use the create_anonymous_wrapper() helper function whenever
wrapping inline content in anonymous wrapper blocks. We were forgetting
to do this in one case, which led to some wrapper blocks having 0px
font-size and line-height.
2022-03-24 18:30:56 +01:00
Andreas Kling d5aca1c6c4 LibWeb: Treate SVG paintable coordinates as relative to <svg> element
Normally, paintable coordinates are relative to the nearest containing
block, but in the SVG case, since <svg> doesn't form a containing block,
we have to specialize the computation of SVGPaintable::absolute_rect().
2022-03-24 18:14:01 +01:00
Andreas Kling 88aca4c996 LibWeb: Add fast-path for absolute lengths in Length::to_px()
Absolute lengths can be resolved immediately without looking up the
viewport size, etc.
2022-03-24 18:14:01 +01:00
Andreas Kling 30b1772eeb LibWeb: Rename "specified_style" to "computed_style" in Layout::Node
The specified style was turned into computed style long before it
arrived here (StyleComputer took care of that.)
2022-03-24 18:14:01 +01:00
Andreas Kling 40af665a49 LibWeb: Add margin box helpers to Layout::FormattingState 2022-03-24 18:14:01 +01:00
Andreas Kling 329f06d59a LibWeb: Add Layout::Node::line_height()
This allows you to call line_height() on any layout node, even if it's a
text node (in which case we'll ask the parent node for its line-height.)
2022-03-24 18:14:01 +01:00
Sam Atkins c914e732d2 LibWeb+Base: Fix An+B of foo parsing
When I wrote the An+B parser, it was guaranteed to have no
non-whitespace tokens after it. This is no longer true with the `of
foo` syntax, so this patch corrects the logic when there is no `+B`
segment.

This makes this case shown on Twitter work correctly. :^)
https://twitter.com/simevidas/status/1506657566012678151
2022-03-24 18:08:45 +01:00
Sam Atkins 5aad32b504 LibWeb: Implement text-shadow painting
We don't yet take the spread-distance parameter into account, since we
don't have a way to "inflate" the text shadow.

Also, I'm not sure if we need to inflate the shadow slightly anyway.
Blurred shadows of our pixel fonts seem very faint. Part of this is
that a blur of < 3px does nothing, see #13231, but even so we might
want to inflate it a little.
2022-03-24 18:08:34 +01:00
Sam Atkins 03daa4653f LibWeb: Parse and compute text-shadow property 2022-03-24 18:08:34 +01:00
Sam Atkins f078bb8294 LibWeb: Implement disallowing inset when parsing shadows
`text-shadow` does not support this, so this way we can still use the
same parsing code.

It's OK that we still assign a ShadowPlacement value to the
ShadowStyleValue, since it will just get ignored when painting
text-shadows, but if it appears in the property value then that is a
syntax error.
2022-03-24 18:08:34 +01:00
Sam Atkins 1094654adc LbWeb: Rename BoxShadowFoo => ShadowFoo
The `text-shadow` property is almost identical to `box-shadow`:
> Values are interpreted as for box-shadow [CSS-BACKGROUNDS-3].
> (But note that the inset keyword are not allowed.)

So, let's use the same data structures and parsing code for both. :^)
2022-03-24 18:08:34 +01:00
Timothy Flynn f9367a5fdb LibWeb: Ignore application objects until we can support them
The HTMLObjectElement spec is set up to ignore application/octet-stream
MIME types only. For this to work, we need to implement the MIME type
sniffing algorithm so that all unknown MIME types become mapped to the
application/octet-stream type. Until then, ignore all application/ MIME
types as we won't be able to display them anyways.
2022-03-24 16:56:38 +01:00
Timothy Flynn d744f04a03 LibWeb: Discard an object's nested browsing contexts when falling back 2022-03-24 16:56:38 +01:00
Timothy Flynn 23915d0977 LibWeb: Implement falling back early to an object's child representation 2022-03-24 16:56:38 +01:00
Timothy Flynn a002c8156b LibWeb: Conditionally update an object's children when its state changes
We should only update the object children of an object when the parent's
representation changes to/from falling back to its children.
2022-03-24 16:56:38 +01:00
Timothy Flynn f11d6e137c LibWeb: Correctly handle unknown MIME types in HTMLObjectElement
We were using the literal string "unknown" as the unknown MIME type,
which caused us to treat the object as a nested browsing context (as
"unknown" does not start with "image/"). Use an Optional instead to
prevent this mishap.
2022-03-24 16:56:38 +01:00
Jelle Raaijmakers c0513999d6 LibGfx: TrueTypeFont cleanup
No functional changes.
2022-03-24 16:53:21 +01:00
Jelle Raaijmakers b17fb76ace LibGfx: Implement TTF kerning tables
If a TTF font contains kern tables, we now read through all of them and
apply any kerning values to character rendering.
2022-03-24 16:53:21 +01:00
Simon Wanner e72f59cd23 Profiler: Render signposts behind histograms
Since signposts render along the full height they could hide CPU usage
spikes. This way that won't be an issue. :^)
2022-03-24 14:35:47 +01:00
Simon Wanner 3d80d38954 LibWeb: Emit signposts for resource loads 2022-03-24 14:35:47 +01:00
Nukiloco b47bd95087 LibWeb: Add missing spec comment in focusing logic 2022-03-24 08:39:26 -04:00
Nicholas Cellino 626ea5007a sql: Re-prompt user for input after unrecognized command
This fixes a bug in the SQL REPL where after a user enters an
unrecognized command, the REPL would not print another "> " prompt and
would not accept any more input.
2022-03-24 07:25:04 -04:00
Kenneth Myhra 546a6a80a7 readlink: Use StringView instead of const char* 2022-03-24 11:57:51 +01:00
Kenneth Myhra 45ac5e90b7 readlink: Port to LibMain 2022-03-24 11:57:51 +01:00
Kenneth Myhra 4a57be824c Userland+Tests: Convert File::read_link() from String to ErrorOr<String>
This converts the return value of File::read_link() from String to
ErrorOr<String>.

The rest of the change is to support the potential of an Error being
returned and subsequent release of the value when no Error is returned.
Unfortunately at this stage none of the places affected can utililize
our TRY() macro.
2022-03-24 11:57:51 +01:00
Timothy Flynn 69749b044c LibWeb: Begin supporting non-image HTMLObjectElement data representation
We currently only supported loading image data from an HTMLObjectElement
node. This adds (some) support for non-image data. A big FIXME is to
actually paint that data. We will need to make FrameBox and
NestedBrowsingContextPaintable work with HTMLObjectElement for this
(they currently only work with HTMLIFrameElement).
2022-03-24 03:35:11 +01:00
Timothy Flynn f733385cc4 LibWeb: Move automatic browsing context creation to HTMLIFrameElement
We will soon have two DOM nodes which contain nested browsing contexts:
HTMLIFrameElement and HTMLObjectElement. Only HTMLIFrameElement should
have its nested context created automatically upon insertion, so move
the invocation of that logic to HTMLIFrameElement.
2022-03-24 03:35:11 +01:00
Timothy Flynn 5608bc4eaf LibWeb: Remove inheritance of FormAssociatedElement from HTMLElement
HTMLObjectElement will need to be both a FormAssociatedElement and a
BrowsingContextContainer. Currently, both of these classes inherit from
HTMLElement. This can work in C++, but is generally frowned upon, and
doesn't play particularly well with the rest of LibWeb.

Instead, we can essentially revert commit 3bb5c62 to remove HTMLElement
from FormAssociatedElement's hierarchy. This means that objects such as
HTMLObjectElement individually inherit from FormAssociatedElement and
HTMLElement now.

Some caveats are:

* FormAssociatedElement still needs to know when the HTMLElement is
  inserted into and removed from the DOM. This hook is automatically
  injected via a macro now, while still allowing classes like
  HTMLInputElement to also know when the element is inserted.

* Casting from a DOM::Element to a FormAssociatedElement is now a
  sideways cast, rather than directly following an inheritance chain.
  This means static_cast cannot be used here; but we can safely use
  dynamic_cast since the only 2 instances of this already use RTTI to
  verify the cast.
2022-03-24 03:35:11 +01:00
Lenny Maiorani f7f0195fae LibMain: Statically link LibMain
LibMain is dynamically linked in every binary. This results in a
slightly slower load time. In the past people have pegged this at 0.7
ms on some hardware.

This change makes it statically linked and eliminates 0.6 ms of
run-time on my machine. This is tested by running a script which just
executed `/bin/true` in a loop 10,000 times. Before this patch it
reliably executed in ~90,000 ms. After this patch it is ~84,000
ms. This is a speed up of 6,000 ms over 10,000 executions, or 0.6 ms
per execution.
2022-03-24 03:04:57 +01:00
GeekFiftyFive ff8a6d8e59 PixelPaint: Call set_modified on window
Call set_modified on window in order to reflect unsaved
changed in the titlebar's close button
2022-03-24 03:03:50 +01:00
Timothy Flynn 7774c9bb9e LibWeb: Update HTMLObjectElement's children on fallback state changes
This is another event upon which the task to determine an object's
respresentation must be queued:

    * one of the element's ancestor object elements changes to or from
      showing its fallback content

For example, on Acid2, the image for the eyes is nested below an object
that is designed to fail to load. This ensures the eyes will render as
the fallback of the failed parent object.
2022-03-23 21:26:35 +01:00
Timothy Flynn 8f7e642a96 LibWeb: Move HTMLObjectElement spec link to correct method 2022-03-23 21:26:35 +01:00
Timothy Flynn 20eb441cba LibWeb: Evict replaced Resource objects from cache
When a Resource is converted to an ImageResource, evict the original
resource from cache. The original resource's data has been moved, so on
a warm reload of a page, when that resource is loaded from cache, it
would not have any data to actually show.
2022-03-23 21:26:35 +01:00
Sam Atkins 004f69b535 LibWeb: Restore :is() and :where() selector parsing
This was a casualty in a recent merge-conflict resolution. Oops!
2022-03-23 15:46:48 -04:00
Nicholas Cellino 0e51d99322 sql: Do not indent next line when current one is blank
Previously, if a user pressed Enter without typing a command at
the SQL REPL, the next line would be automatically indented. This
change makes it so we check if there were any tokens in the command
before applying the indentation logic.
2022-03-23 15:27:09 -04:00
Andreas Kling e0c7727934 LibWeb: Fill the whole viewport with the correct background color
CSS2 tells us to use the HTML element's background color if not
transparent. Otherwise, the BODY element's background color.
2022-03-23 17:38:00 +01:00
Andreas Kling ca85ac26d4 WebContent: Fill OOPWV with palette base color when there's no content 2022-03-23 17:27:20 +01:00
Andreas Kling fb9ee26c43 LibWeb: Resolve numeric line-heights against element's own font size
For things like "line-height: 2" to work, the font size must be assigned
before resolving the line height. Previously, the line-height was
resolved first, which meant that numeric and other relative units were
resolved against the default font-size instead.
2022-03-23 15:57:05 +01:00
Andreas Kling 5118a4c1e7 LibWeb: Parse CSS "font-variant" as part of "font"
This allows us to parse CSS "font" values that contain e.g "small-caps"
or "normal", as used on Acid3.
2022-03-23 14:54:21 +01:00
Andreas Kling 632928a11e LibWeb: Pass font sizes in pt rather than px to Gfx::FontDatabase
Our font database uses point sizes for fonts, and we were passing it
px sizes. This caused all fonts to be 1.333x larger than they should
be on the web. Of course it wasn't always noticeable with bitmap fonts,
but noticeable everywhere with scalable fonts.
2022-03-23 14:13:15 +01:00