Commit Graph

393 Commits

Author SHA1 Message Date
Gunnar Beutner
704bfe54b6 LibWeb: Fix incorrect variable names when parsing CSS 2021-05-15 16:27:52 +02:00
Timothy Flynn
dba261f79b LibWeb: Propagate body background properties to root HTML element
The Acid1 test has a bit of an unusual background - the html and body
tags have different background colors. Our painting order of the DOM was
such that the body background was painted first, then all other elements
were painted in-phase according to Appendix E of CSS 2.1. So the html
element's background color was painted over the body background.

This removes the special handling of the body background from
InitialContainingBlockBox and now all boxes are painted in-phase. Doing
this also exposed that we weren't handling Section 2.11.2 of the spec;
when the html background is unset, the body's background should be
propagated to the html element.
2021-05-13 16:16:25 +02:00
Tobias Christiansen
d1ed6bce5d LibWeb: Fix off-by-one for alphabetical markers in <ol>s
The ListItemMarker gets its index 1-based while the
String::bijective_base_from expects its index to be 0-based. This patch
adjusts the index passed around accordingly.
2021-05-13 15:43:51 +02:00
Ali Mohammad Pur
a91a49337c LibCore+Everywhere: Move OpenMode out of IODevice
...and make it an enum class so people don't omit "OpenMode".
2021-05-12 11:00:45 +01:00
Tobias Christiansen
e7498bb918 LibWeb: Position the ListItemMarkers according to their width
Previously they were positioned with a fixed offset. However this lead
to wider markers with more than one character to collide with the
element itself.
Now the ListItemMarkerBox generates and stores the appropriate String
in its constructor and sets its own width according to that.
The ListItemBox then lays out the Marker taking this width into
account.
This also made the painting a lot easier since we don't generate the
needed Strings every time we repaint, just once.
2021-05-12 08:53:18 +01:00
Tobias Christiansen
a51cee748f LibWeb: Remove unused alphabet constants from ListItemMarkerBox
Why exactly the linter didn't whine about this is a mystery. These
constants aren't needed anymore since the functionality moved to
AK/String a while ago.
2021-05-12 08:53:18 +01:00
Timothy Flynn
1ec23f38ed LibWeb: Move clearing boxes below preceding floating boxes
When computing the y-position of a clearing element, use the height of
the border box of the associated floating elements.

This also extracts this block of code to a helper lambda since it is
used twice.
2021-05-12 08:50:20 +01:00
Idan Horowitz
ce86026ac6 LibWeb: Add a maximum redirects limit to FrameLoader
This prevents the browser from crashing when trying to load an infinite
redirects loop. The chosen limit is based on the fetch specification:
"If request's redirect count is twenty, return a network error."
2021-05-11 21:41:48 +01:00
miere43
c4bd4cbd76 LibWeb: Implement :nth-last-child pseudo-class 2021-05-11 21:17:16 +01:00
Timothy Flynn
227ccfc61a LibWeb: Paint an element's foreground before painting its children
The current implementation is missing the emphasized text of the
following rule in the painting order spec:

    7. Otherwise: *first for the element*, then for all its in-flow,
       non-positioned, block-level descendants in tree order...

This ensures the foreground is painted for the current element before
descending into its children.
2021-05-11 18:03:21 +02:00
Luke
1c1b106f6c LibWeb: Make Element::tag_name return the HTML uppercased qualified name
I forgot to change tag_name when this was added.
Also makes html_uppercased_qualified_name return a const reference.
2021-05-11 18:01:36 +02:00
Luke
56d7d28d41 LibWeb: Expose Element.{prefix,localName} 2021-05-11 18:01:36 +02:00
Adam Hodgen
dc9995a5ba LibWeb: Add tests for HTMLTableElement attributes
These tests aim to exercise all attributes on <html> elements, including
all edge cases.
2021-05-09 18:38:34 +02:00
Adam Hodgen
737f6e97b2 LibWeb: Fix nodeName attribute in tests
Commit 19731fc14c (#6864) made all nodeName attributes on HTML elements
uppercased. This change fixes that in all HTML & DOM tests.
2021-05-09 18:38:34 +02:00
Adam Hodgen
37685b0181 LibWeb: Implement HTMLTableElement tbody attributes
* tBodies - returns a HTMLCollection of all tbody elements
* createTBody - If necessary, creates a new tbody element
  and add it to the table after the last tbody element
2021-05-09 18:38:34 +02:00
Adam Hodgen
d2e3e98b6b LibWeb: Implement HTMLTableElement tfoot attributes
* tFoot - Getter for the tfoot element
  The setter is not currently implemented
* createTFoot - If necessary, creates a new tfoot element
  and add it to the table after any tbody elements
* deleteTFoot - If a tfoot element exists in the table, delete it
2021-05-09 18:38:34 +02:00
Adam Hodgen
b3f7ea9914 LibWeb: Implement HTMLTableElement thead attributes
* tHead - Getter for the thead element
  The setter is not currently implemented
* createTHead - If necessary, creates a new thead element
  and add it to the table after any caption or colgroup elements,
  but before anything else
* deleteTHead - If a thead element exists in the table, delete it
2021-05-09 18:38:34 +02:00
Adam Hodgen
0fa0367a39 LibWeb: Implement HTMLTableElement caption attributes
* caption - Getter and setter for the caption element
* createCaption - If necessary, creates a new caption element
  and add it to the table
* deleteCaption - If a caption element exists in the table, delete it
2021-05-09 18:38:34 +02:00
Adam Hodgen
887fa18e32 LibWeb: Implement HTMLTableElement row attributes
rows returns a HTMLCollection of all the tr elements contained within
the table.
We leave the SameObject attribute off the attribute in the IDL as we
cannot currently return the same HTMLCollection every time (see the
FIXME on DOM::Document::applets)

The WrapperGenerator currently does not correctly handle the default
value for the type long on insertRow. Currently not specifying the
index will insert a row at index 0.
2021-05-09 18:38:34 +02:00
miere43
aa83539d7b LibWeb: Implement :nth-child pseudo-class 2021-05-09 11:24:04 +02:00
miere43
1e0e8b27c0 LibWeb: Allow white space inside pseudo-class arguments 2021-05-09 11:24:04 +02:00
Linus Groh
67b47013d2 LibWeb: Use list-style-type circle/square for nested unordered lists
An idea shamelessly stolen from other UAs :^)
2021-05-08 10:49:16 +01:00
Tobias Christiansen
1b6824d296 LibWeb: Make frames nesting-aware and disallow deep nesting
A Frame now knows about its nesting-level.

The FrameLoader checks whether the recursion level of the current
frame allows it to be displayed and if not doesn't even load the
requested resource.

The nesting-check is done on a per-URL-basis, so there can be many many
nested Frames as long as they have different URLs.
If there are however Frames with the same URL nested inside each other
we only allow this to happen 3 times.

This mitigates infinetely recursing <iframe>s in an HTML-document
crashing the browser with an OOM.
2021-05-07 22:34:34 +02:00
Egor Ananyin
d2b6148787 LibWeb: Make painting order more spec-compliant
Now our painting order inside stacking contexts is closer to the
algorithm specified by CSS 2.1 (see section 9.9 and Appendix E)
2021-05-07 22:27:48 +02:00
Andreas Kling
c7e9b6d00f LibWeb: Convert StringBuilder::appendf() => AK::Format 2021-05-07 21:12:09 +02:00
Luke
df52040ce9 LibWeb: Implement replacing the current body when setting document.body
Also adds an exception check to the append at the end.
2021-05-07 08:53:37 +02:00
Luke
b6004a4ce1 LibWeb: Add non-const variants of Document::{html_element,body,head}() 2021-05-07 08:53:37 +02:00
Luke
46f2c278b0 LibWeb: Implement Node.replaceChild
The `if (child->parent())` check seems to be redundant, but I'm keeping
it just to match the spec.
2021-05-07 08:53:37 +02:00
Idan Horowitz
37903db2b4 LibWeb: Remove double comma in FrameLoader debug logging 2021-05-05 16:37:26 +01:00
Luke
2cc6b919f7 LibWeb: Implement EventTarget.dispatchEvent
Used by Web Platform Tests to test events
2021-05-04 23:41:44 +01:00
Luke
7f6baf8b17 LibWeb: Add Document.{images,embeds,plugins,links,forms,scripts} 2021-05-04 23:40:43 +01:00
Luke
19731fc14c LibWeb: Use HTML-uppercased qualified name for the Element node name
For regular elements, this is just the qualified name.
However, for HTML elements in HTML documents, it is the qualified name
uppercased.

This is used by jQuery to determine the document is an HTML document.
Not having this made jQuery assume the document was XML, causing
weird behaviour.

To do this, an internal string of qualified name is created.
This is to prevent constantly regenerating it. This is allowed by
the spec.

This is the same for the HTML-uppercased qualified name.
2021-05-04 23:24:03 +01:00
Luke
7c6c7ca542 LibWeb: Add createDocument and createDocumentType for DOMImplementation
Both required for the acid3 test.
createDocument is used extensively in Web Platform Tests.
2021-05-04 22:59:15 +01:00
Luke
5952bc1ea4 LibWeb: Add support for extended attributes on IDL parameters
Also adds support for [LegacyNullToEmptyString] for parameters.
2021-05-04 22:59:15 +01:00
Luke
b816000d47 LibWeb: Expose HTMLInputElement.name 2021-05-04 22:03:14 +01:00
Timothy Flynn
9a69b9112b LibWeb: Compute intrinsic height of absolute replaced elements
Previously, the method for computing the height of absolutely positioned
replaced elements only invoked the method for non-replaced elements.
That method is now implemented fully enough that it sometimes computed a
height of 0 for replaced elements. This implements section 10.6.5 rule 1
of the CSS spec to avoid that behavior.
2021-05-04 15:36:07 +01:00
Gunnar Beutner
9e22e9ce88 Userland: Use snake case names in .ipc files
This updates all .ipc files to have snake case names for IPC methods.
2021-05-03 21:14:40 +02:00
Gunnar Beutner
5bb79ea0a7 Userland: Update IPC calls to use proxies
This updates all existing code to use the auto-generated client
methods instead of post_message/send_sync.
2021-05-03 21:14:40 +02:00
Gunnar Beutner
065040872f Userland: Change IPC funcs to use plain arguments instead of a struct
Instead of having a single overloaded handle method each method gets
its own unique method name now.
2021-05-03 21:14:06 +02:00
Andreas Kling
d47f15ab8b LibGUI: Rename ScrollableWidget => AbstractScrollableWidget 2021-05-03 21:03:13 +02:00
Luke
8b5ea01cfb LibWeb: Use node_to_insert instead of node in Node::insert_before
It was using the passed in node instead of the node from the vector.
Fixes a crash I found while testing jQuery.
2021-05-03 08:20:02 +02:00
Luke
8bafbdddc6 LibWeb: Expose Node.ownerDocument
Required by jQuery.
2021-05-02 22:51:46 +02:00
Matthew Olsson
88cfaf7bf0 LibGfx: Unify Rect, Point, and Size
This commit unifies methods and method/param names between the above
classes, as well as adds [[nodiscard]] and ALWAYS_INLINE where
appropriate. It also renamed the various move_by methods to
translate_by, as that more closely matches the transformation
terminology.
2021-05-02 22:48:06 +02:00
Gunnar Beutner
889359b6f9 Userland: Make IPC handlers return void if they don't have any outputs 2021-05-02 08:11:38 +02:00
Gunnar Beutner
7cf2839a26 Userland: Get rid of the OwnPtr<...> boilerplate code for IPC handlers 2021-05-02 08:11:38 +02:00
Gunnar Beutner
6cf59b6ae9 Everywhere: Turn #if *_DEBUG into dbgln_if/if constexpr 2021-05-01 21:25:06 +02:00
Tobias Christiansen
22d6fbeb12 LibWeb: Use new way of generating list-style-type: *-alpha
Removed the local conversion from number to alphabet and used the one
offered in AK/String instead.
2021-05-01 01:19:40 +02:00
Egor Ananyin
8f8fbf3487 LibWeb: Position absolute boxes relative to the containing block
In the absolute positioning model, a box is explicitly offset with
respect to its containing block (CSS 2.1 section 9.6).
2021-04-30 15:25:35 +02:00
Egor Ananyin
3ca6d7dd36 LibWeb: Use min-height in calculating block box height
Now we use min-height for calculating the height of block boxes.
Besides, now we check if min-height/max-height are percentage values
and don't use them if parent's height isn't explicitly set (CSS 2.1
section 10.7).
2021-04-30 15:25:35 +02:00
Egor Ananyin
5ae2774018 LibWeb: Fix floating box position calculation
Now we set margins, borders and paddings for floating boxes and include
them into calculating floating box positions by using margin_box() and
margin_box_as_relative_rect().
2021-04-30 15:25:35 +02:00