This just updates our copied spec steps - new steps are not implemented
here. This is mostly just to highlight new steps we are missing around
MessagePorts.
No behavior change, but this does resolve an outstanding FIXME around
spec step ordering.
(cherry picked from commit 83be2606dba7ac430bab4d61a70e926d12d452ee)
These don't have to worry about the input not being valid UTF-8 and
so can be infallible (and can even return self if no changes needed.)
We use this instead of Infra::to_ascii_{upper,lower}_case in LibWeb.
(cherry picked from commit 073bcfd3866852a4c4bcca2bd131bd65ae53541f)
This API is a relic from the time when it was important for objects to
have easy access to the Window, and to know it was the global object.
We now have more spec-related concepts like relevant_global_object and
current_global_object to pull the Window out of thin air.
(cherry picked from commit 02a56f648000517f191eeaea2abc68783c097486)
This returns the source text of the specified style sheet. StyleComputer
now exposes user agent style sheets so that these can also be requested.
(cherry picked from commit 49b2eb5f51be2ddfd2c6009e7d8064b58d665af3)
This only iterates style sheets that are in use, so make this clear by
renaming it to `for_each_active_css_style_sheet()`.
(cherry picked from commit c29f4f69ef9a16bd63a4bf133618120068e96bf3)
I had made a stab at implementing this to determine whether it could
assist in fixing an issue where scroll_to_the_fragment was not getting
called at the appropriate time. It did not fix that issue, and actually
ended up breaking one of our in tree tests. In the meantime, factor out
this method into a standalone function.
(cherry picked from commit 41f574155df89bb5122646a0978fa8821c35fc16)
Before, the new title element got appended instead of prepended, as
nullptr was passed as the "child" argument to the insert_before()
function.
This change makes two WPT tests pass in:
http://wpt.live/html/dom/documents/dom-tree-accessors/document.title-09.html
(cherry picked from commit 3ff613712132bd3d03f44f27986f7ca5aaea8eb5)
While traversing the DOM tree, looking for nodes that need a style
update, we were recomputing style for every node visited along the way,
even nodes that didn't themselves need a style update (but one of their
descendants did).
This avoids a bunch of completely unnecessary style recomputation on
basically every website.
(cherry picked from commit 5431db8c1c9d366d0a27959cfbf0f146bf4be20d)
We were hard-coding "about:blank" as the document URL for parsed HTML
documents, which was definitely not correct.
This fixes a bunch of WPT tests under /domparsing/ :^)
(cherry picked from commit 55f58eea99c0429dcc39cd0430fafa60eecf5542)
These registrations are not meant to keep the observers alive.
This fixes a handful of world leaks on Speedometer.
(cherry picked from commit b397a0d5350fad04f43e3e5d9bdb9c801a4e712a)
This is not in the spec, but I did see a null pointer dereference here
while browsing the web, and it seems completely harmless for this
function to skip over navigables without an active document.
(cherry picked from commit 56e1c0e7eec813c311c41696063a3a31b4b14f0d)
The only real change here is that we make the document unsalvageable.
Everything else is fixing up spec comments.
(cherry picked from commit faf097bb4168208a7c0250280ff07e638be8058a)
This patch implements `Range::getClientRects` and
`Range::getBoundingClientRect`. Since the rects returned by invoking
getClientRects can be accessed without adding them to the Selection,
`ViewportPaintable::recompute_selection_states` has been updated to
accept a Range as a parameter, rather than acquiring it through the
Document's Selection.
With this change, the following tests now pass:
- wpt[css/cssom-view/range-bounding-client-rect-with-nested-text.html]
- wpt[css/cssom-view/DOMRectList.html]
Note: The test
"css/cssom-view/range-bounding-client-rect-with-display-contents.html"
still fails due to an issue with Element::getClientRects, which will
be addressed in a future commit.
(cherry picked from commit 75c7dbc5d2dd045733a4c319aeab6644b5b7b36d)
`BrowsingContext::m_parent` has been removed from the spec,
and previously `m_parent` was always null.
`BrowsingContext::is_top_level` was already always returning
true before because of that, and the updated spec algorithm
causes assertions to fail.
This fixes the following example:
```html
<a href="about:blank" target="test">a
<iframe name="test">
```
clicking the link twice no longer causes it to open in a new tab.
(cherry picked from commit e6a668ad913f0755840954c188c255fc5fc66606)
I believe this is slightly less confusing, since what the function does
is trigger a full layout tree *rebuild*, not just a relayout.
(cherry picked from commit aa8f17aea4d1aa1950a66969fc8b5c431fbc1b7c)
Previously, unnecessary boundary checks were being done when
constructing the range objects used to represent find in page matches.
These checks are no longer performed leading to a significant speedup
when performing find in page queries on pages containing a lot of text.
(cherry picked from commit e76ad9492e0992f9a6d821240bea2b62f27a03c8)
The first step of the find in page algorithm is to walk the layout tree
of each document on the page and construct a list of strings against
which to search for matches.
Previously, this was being done for each new query, even when the
page content hadn't been updated. The output of this process is now
cached in the viewport node of the associated document. This ensures
that this process is no longer repeated unnceessarily.
(cherry picked from commit 156c1083e9de23a93075ec9e3c55cd5f93c48896)
Elements which are `display: none` or `visibility: hidden` are no
longer included in find in page results.
(cherry picked from commit a3a7a65b1c89af5631436c06d2847fe7ad5c51cb)
Find in page will no longer match text that spans across block elements.
Previously, given the markup `WH<div>F</div>`, the query `WHF` would
find a match. We would now match `WH` and `F` separately, but not `WHF`.
(cherry picked from commit 23166b85d2443cccbdd8fcb1e9d99c9f3f9d04a3)
Previously, the find in page function would fail to find text which was
split across multiple text nodes. For example, given the following
markup: `WH<span>F` the query `WHF` would previously fail to be
matched.
This is done by traversing all of the document's text nodes -
constructing a complete string to query against and keeping track of
the locations where that string is split across multiple nodes.
(cherry picked from commit ec4d29849dc1d0357c73690722aea1a7802dd0bc)
To avoid expensive lookups, we now cache a weak pointer from document to
the last known node navigable. Before using the cache, we validate that
the document is still the navigable's active document.
(cherry picked from commit e746b2b133758b3552ae07941cc6d14332c64d59)
You can now build with STYLE_INVALIDATION_DEBUG and get a debug stream
of reasons why style invalidations are happening and where.
I've rewritten this code many times, so instead of throwing it away once
again, I figured we should at least have it behind a flag.
(cherry picked from commit ddbfac38b0074819470766846fca08fd78630eb0;
minorly amended for conflicts in AK/Debug.h.in and
Meta/CMake/all_the_debug_macros.cmake due to us having more debug
macros. Also, downstream got alphabetical order for
STYLE_INVALIDATION_DEBUG wrong.)
Navigables are re-used for navigations within the same tab. Its current
ownership of the cursor position is a bit ad-hoc, so nothing in the spec
indicates when to reset the cursor, nor do we manually do so. So when a
cursor update happens on one page, that cursor is retained on the next
page.
Instead, let's have the document own the cursor. Each navigation results
in a new document, thus we don't need to worry about resetting cursors.
This also makes many of the callsites feel nicer. We were previously
often going from the node, to the document, to the navigable, to the
cursor. This patch removes the navigable hop.
(cherry picked from commit faebbbc281d1267062770b02fc6d962d92a3bd62)
This passes the DOM encoding down to the URL parser, so the correct
encoder can be used.
(cherry picked from commit c1958437f983bb9761661534da34934c8dddcf6f)
For the SVG <use> element, we want to support loading HTML documents
that have a SVG element inside of it pointed to by the URL fragment.
In this situation we would need to fetch and parse the entire document
in SharedImageRequest (so that we can still cache the SVGs). Rename
SharedImageRequest to SharedResourceRequest to make the class a little
more generic for future usecases.
(cherry picked from commit a342370dfb4f1eeabc7dcb8fbe6f8e4eb6f6b1f4)
We explicitly stopped visting the map of documents to console clients in
commit 44659f2f2a to avoid keeping the
document alive. However, if nothing else visits the console clients, we
may set the top-level console client to a client that has been garbage
collected.
So instead of storing this map, just store the console client on the
document itself. This will allow the document to visit its client.
(cherry picked from commit 0a819e628eb296200b8b5e609b4936a1a4bf330f)
This will allow testing if they are for fragment parsing during methods
invoked from Document::initialize.
(cherry picked from commit c838ca78c81261e6111aa255c79e4a0599759c80)
We were mistakenly executing the current node's script instead of the
document's pending parsing-blocking script.
This caused ~1000 WPT tests to time out, since we never ended up firing
a load event for XHTML pages that load multiple external scripts.
(cherry picked from commit 007c292af3202a85eb146b121720d988a66ed64b)
Previously, we had two implementations of the same function in
`Document` and `Element`, which had inadvertantly diverged.
(cherry picked from commit faf64bfb41393a59e958e21545aa556c9bb9d6a8)
The spec doesn't explicitly forbid calling this when the document
doesn't have a node navigable, so let's handle that situation gracefully
by just returning an empty list of ancestors.
I hit this VERIFY somewhere on the web, but I don't know how to
reproduce it.
These methods were overriding properties specified by the EventInit
property bags in the constructor for WheelEvent and MouseEvent.
They appear to be legacy code and no longer relevant, as they would have
been used for ensuring natively dispatched events had the correct
properties --- This is now done in separate create methods, such as
MouseEvent::create_from_platform_event.
This fixes a couple WPT failures (e.g. in
/dom/events/Event-subclasses-constructors.html)
(cherry picked from commit 2c396b5378fec5f4470e1e1e950806dff8005f08)
The first time Document learns its viewport size, we now suppress firing
of the resize event.
This fixes an issue on multiple websites that were not expecting resize
events to fire so early in the loading process.
(cherry picked from commit 4e7558c88b7a993686bb3dc173731e677efe5e26)
The main intention of this change is to have a consistent look and
behavior across all scrollbars, including elements with
`overflow: scroll` and `overflow: auto`, iframes, and a page.
Before:
- Page's scrollbar is painted by Browser (Qt/AppKit) using the
corresponding UI framework style,
- Both WebContent and Browser know the scroll position offset.
- WebContent uses did_request_scroll_to() IPC call to send updates.
- Browser uses set_viewport_rect() to send updates.
After:
- Page's scrollbar is painted on WebContent side using the same style as
currently used for elements with `overflow: scroll` and
`overflow: auto`. A nice side effects: scrollbars are now painted for
iframes, and page's scrollbar respects scrollbar-width CSS property.
- Only WebContent knows scroll position offset.
- did_request_scroll_to() is no longer used.
- set_viewport_rect() is changed to set_viewport_size().
(cherry picked from commit 5285e22f2aa09152365179865f135e7bc5d254a5)
Co-authored-by: Jamie Mansfield <jmansfield@cadixdev.org>
Co-authored-by: Nico Weber <thakis@chromium.org>