Commit graph

1074 commits

Author SHA1 Message Date
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
AnotherTest
b03e8a6d06 LibWeb: Re-enable favicons after forgotten if-0 2020-12-30 20:37:41 +01:00
AnotherTest
4a2da10e38 ProtocolServer: Stream the downloaded data if possible
This patchset makes ProtocolServer stream the downloads to its client
(LibProtocol), and as such changes the download API; a possible
download lifecycle could be as such:
notation = client->server:'>', server->client:'<', pipe activity:'*'
```
> StartDownload(GET, url, headers, {})
< Response(0, fd 8)
* {data, 1024b}
< HeadersBecameAvailable(0, response_headers, 200)
< DownloadProgress(0, 4K, 1024)
* {data, 1024b}
* {data, 1024b}
< DownloadProgress(0, 4K, 2048)
* {data, 1024b}
< DownloadProgress(0, 4K, 1024)
< DownloadFinished(0, true, 4K)
```

Since managing the received file descriptor is a pain, LibProtocol
implements `Download::stream_into(OutputStream)`, which can be used to
stream the download into any given output stream (be it a file, or
memory, or writing stuff with a delay, etc.).
Also, as some of the users of this API require all the downloaded data
upfront, LibProtocol also implements `set_should_buffer_all_input()`,
which causes the download instance to buffer all the data until the
download is complete, and to call the `on_buffered_download_finish`
hook.
2020-12-30 13:31:55 +01:00
Luke
18d99919be LibWeb: Expose three more attribute methods on Element
Exposes removeAttribute, hasAttribute and hasAttributes.
2020-12-29 23:38:14 +01:00
Luke
6ffcd53479 LibWeb: Fix character references losing characters in certain situations
This fixes 4 issues:
- RECONSUME_IN_RETURN_STATE was functionally equivalent to
  SWITCH_TO_RETURN_STATE, which caused us to lose characters.
  For example, &test= would lose the =

- & characters by themselves would be lost. For example, 1 & 2
  would become 1 2. This is because we forgot to flush
  characters in the the ANYTHING_ELSE path in CharacterReference

- Named character references didn't work at all in attributes.
  This is because there was a path that was checking the entity
  code points instead of the entity itself. Plus, the path that
  was checking the entity itself wasn't quite spec compliant.

- If we fail to match a named character reference, the first
  character is lost. For example &test would become &est.
  However, this relies on a little hack since I can't wrap my
  head around on how to change the code to do as the spec says.
  The hack is to reconsume in AmbigiousAmpersand instead of
  just switching to it.

Fixes #3957
2020-12-29 17:39:08 +01:00
Andreas Kling
cdf87d2204 LibWeb: Fill OOPWV with the palette base color until we have pixels
We were painting unfinished pixels while waiting for the WebContent
process to render the page. This caused OOPWV to flicker black
sometimes, which looked pretty bad.

This way we still flicker, but at least we flicker with the correct
palette color. :^)
2020-12-29 00:47:30 +01:00
Andreas Kling
7e79563bb9 LibGUI: Show tooltip after a small delay
It always felt a bit jarring that tooltips would pop in right away when
you hover over a toolbar button. This patch adds a 700ms delay before
they appear, and a 50ms delay before they disappear.

Once a tooltip is up, moving the cursor between two widgets that both
have tooltips will leave the tooltip on screen without delays.
2020-12-28 21:28:40 +01:00
Linus Groh
5122f98198 Base+LibJS+LibWeb: Make prettier clean
Also use "// prettier-ignore" comments where necessary rather than
excluding whole files (via .prettierignore).
2020-12-27 21:25:27 +01:00
Sahan Fernando
d780e2265d LibC: Fix some incorrect printf usages 2020-12-26 10:05:50 +01:00
Lenny Maiorani
765936ebae
Everywhere: Switch from (void) to [[maybe_unused]] (#4473)
Problem:
- `(void)` simply casts the expression to void. This is understood to
  indicate that it is ignored, but this is really a compiler trick to
  get the compiler to not generate a warning.

Solution:
- Use the `[[maybe_unused]]` attribute to indicate the value is unused.

Note:
- Functions taking a `(void)` argument list have also been changed to
  `()` because this is not needed and shows up in the same grep
  command.
2020-12-21 00:09:48 +01:00
Andreas Kling
18f1c49804 LibWeb: Don't leave "border" CSS property around after expansion
The "border" property is a shorthand that expands into multiple
longhand properties. We shouldn't leave it set in a StyleProperties
after expanding it.
2020-12-20 11:59:40 +01:00
Andreas Kling
497f1fd472 LibWeb: Don't use ByteBuffer::wrap() when loading about: URLs
Let's just copy an empty string here to make ourselves a ByteBuffer.
2020-12-19 18:29:13 +01:00
Andreas Kling
685d5f4e25 LibProtocol: Remove use of ByteBuffer::wrap() in protocol API 2020-12-19 13:09:02 +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
Linus Groh
3436317c08 LibWeb: Escape text nodes in innerHTML getter 2020-12-17 19:39:48 +01:00
Linus Groh
4833f0066e LibWeb: Include element attributes in innerHTML getter 2020-12-17 19:39:48 +01:00
Andreas Kling
4c8dbc908c LibWeb: Notify the PageClient when the children of <title> change 2020-12-17 02:02:00 +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
613764b83c LibWeb: Actually apply recomputed style to element's layout node
Otherwise fetching stuff via LayoutNode::style() will have stale values
since we were only updating the specified_style() here.

LayoutNode::specified_style() should eventually go away since there's
no need to carry those uncooked values around with the layout tree.
2020-12-15 20:49:11 +01:00
Andreas Kling
ef61430738 LibWeb: Update text-decoration hack to use text-decoration-line
We have a hack that propagates text-decoration-line through inheritance
even though it's not an inherited property. Once we implement the CSS
cascade properly we can stop doing this.
2020-12-15 20:48:16 +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
30685a7714 LibWeb: Add equals() for LengthStyleValue and ColorStyleValue
The default equals() does to_string() on both sides which is pretty
silly when they are of the same type.
2020-12-15 19:40:06 +01:00
Andreas Kling
58bade25dd LibWeb: Add hack to disable StyleInvalidator while parsing document
Running a StyleInvalidator for every attribute set in a new document
was making it impossible to load larger sites. :^)
2020-12-15 19:33:53 +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
4a9dcd974a LibWeb: Remove unused Element::set_attributes() 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
7e78e4b232 LibWeb: Make CSS "background: none" work again
This broke since "none" is now always going to be an identifier value.
2020-12-15 19:33:53 +01:00
Linus Groh
5e7945e26f LibWeb: Add a simple StyleInvalidator class
This patch adds a simple, naive & inefficient class for document-wide
style invalidation, e.g. after element attribute updates. During
construction it collects a HashMap of a document's elements and their
matching rules, during destruction it does the same and then compares
the results; dirtying all elements that have a different number or order
of matching rules afterwards.

Much room for improvement, but it solves the problem of stale element
styling after attribute updates for now :^)

Fixes #4404.
2020-12-14 23:38:08 +01:00
Andreas Kling
6e7edd6e77 LibWeb: Convert remaining CSS identifiers to use IdentifierStyleValue 2020-12-14 22:22:35 +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
08517daa5a LibWeb: Improvements to font lookup
Parse out the font-family, font-size and font-weight values from CSS
and use them to perform a kinda-best-effort lookup against the system
font library.

We also now handle standard font names like "sans-serif", "monospace"
and others.
2020-12-14 20:43:25 +01:00
Andreas Kling
861d22838d LibWeb: Virtualize StyleValue equality check
And use this to simplify comparing two IdentifierStyleValues.
2020-12-14 20:43:25 +01:00
Andreas Kling
bceb5b60f7 LibWeb: Add a little assertion in Document::detach_from_frame()
Let's just assert that we're detaching from the frame we thought we
were in.. just in case.
2020-12-14 13:47:07 +01:00
Andreas Kling
34d0141da3 LibWeb: Simplify <iframe> content frame construction
Now that documents are attached to their frame *before* parsing, we can
create the content frame of <iframe> elements right away, instead of
waiting for the host frame attachment.

Fixes #4408.
2020-12-14 13:45:57 +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
6809be436b LibWeb: Limit style update tree traversal to dirty subtrees
This patch adds a second style dirty bit that tracks whether a DOM node
has one or more children with dirty style. This allows the style update
to skip over entire subtrees where all nodes are clean.
2020-12-14 12:04:30 +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
8b9f2c41fa LibWeb: Don't replace selection on key press in non-editable content 2020-12-14 10:58:10 +01:00