Commit Graph

18 Commits

Author SHA1 Message Date
Brian Gianforcaro
217179a39f LibWeb: Remove unused header includes 2021-08-01 08:10:16 +02:00
Tobias Christiansen
4c17f389db LibWeb: Add proper support for text-decoration-line property values
The code handling the rendering of the text-decoration-line got moved
into its own function to reduce clutter.
The CSS property text-decoration-line now supports underline, overline
and line-through.
2021-07-29 11:07:56 +02:00
Andreas Kling
ee3a73ddbb AK: Rename downcast<T> => verify_cast<T>
This makes it much clearer what this cast actually does: it will
VERIFY that the thing we're casting is a T (using is<T>()).
2021-06-24 19:57:01 +02:00
Max Wipfli
054c742d17 LibWeb: Remove Utf8View usage and try avoiding StringBuilder in TextNode
This patch completely reworks TextNode::compute_text_for_rendering(). It
removes the unnecessary usage of Utf8View to find spaces in a String.
Furthermore, it adds a couple fast return paths for common but trivial
cases such as empty, single-character and whitespace-less strings.

For the HTML spec bookmarks, around two thirds of all function calls
(which amounts to around 10'000) use the fast paths and thus avoid
allocating a StringBuilder just to build a copy of the already present
String.
2021-06-04 09:39:07 +02:00
DexesTTP
e01f1c949f AK: Do not VERIFY on invalid code point bytes in UTF8View
The previous behavior was to always VERIFY that the UTF-8 bytes were
valid when iterating over the code points of an UTF8View. This change
makes it so we instead output the 0xFFFD 'REPLACEMENT CHARACTER'
code point when encountering invalid bytes, and keep iterating the
view after skipping one byte.

Leaving the decision to the consumer would break symmetry with the
UTF32View API, which would in turn require heavy refactoring and/or
code duplication in generic code such as the one found in
Gfx::Painter and the Shell.

To make it easier for the consumers to detect the original bytes, we
provide a new method on the iterator that returns a Span over the
data that has been decoded. This method is immediately used in the
TextNode::compute_text_for_rendering method, which previously did
this in a ad-hoc waay.

This also add tests for the new behavior in TestUtf8.cpp, as well
as reinforcements to the existing tests to check if the underlying
bytes match up with their expected values.
2021-06-03 18:28:27 +04:30
Max Wipfli
bc8d16ad28 Everywhere: Replace ctype.h to avoid narrowing conversions
This replaces ctype.h with CharacterType.h everywhere I could find
issues with narrowing conversions. While using it will probably make
sense almost everywhere in the future, the most critical places should
have been addressed.
2021-06-03 13:31:46 +02:00
Andreas Kling
4190fd2199 LibWeb: Rename Web::Frame to Web::BrowsingContext
Our "frame" concept very closely matches what the web specs call a
"browsing context", so let's rename it to that. :^)

The "main frame" becomes the "top-level browsing context",
and "sub-frames" are now "nested browsing contexts".
2021-05-30 12:39:53 +02:00
Max Wipfli
08d09c4afb LibWeb: Improving cursor behavior in editable DOM nodes
This patch makes two modifications to improve the behavior of cursors in
editable DOM nodes, such as HTML tags with the contenteditable
attribute.

When the cursor blink cycle is reset in an editable DOM node, a repaint
should be initiated. For this, set_needs_display() needs to be called on
the layout node. Previously, the cursor blink cycle would not reset
properly and moving the cursor with the arrow keys did not feel
intuitive.

Furthermore, this modifies one of the conditions necessary to actually
paint the cursor, which previously prevented it from being painted when
at the end of a text node, after all the text present.
2021-05-21 21:57:03 +02:00
Andreas Kling
d3e7529297 LibWeb: Move Layout::TextNode whitespace collapse to separate function 2021-04-29 10:34:02 +02:00
Andreas Kling
504d622864 LibWeb: Remove unnecessary temporary Vector in text layout
Now that we have Layout::TextNode::ChunkIterator, we don't need to
accumulate all the chunks in a vector before dividing them into lines.
2021-04-27 19:11:59 +02:00
Andreas Kling
37e29a630b LibWeb: Minor cleanup tweak in TextNode::split_into_lines_by_rules()
Merge an unnecessarily nested branch with its parent.
2021-04-27 19:11:59 +02:00
Andreas Kling
5074aaea69 LibWeb: Refactor Layout::TextNode splitting into a chunk iterator
Creating a ChunkIterator allows you to iterate over the text in a
Layout::TextNode at your leisure by calling next() when you want
another chunk.

This is one of many steps towards improving inline layout.
2021-04-27 19:11:59 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Timothy Flynn
1380dbeef3 LibWeb: Protect RadioButton and TextNode against mutating DOM
RadioButton had some protection, but also needed to be protected against
click events originating from its associated label.
2021-04-04 18:30:15 +02:00
Timothy Flynn
e1b5613142 LibWeb: Defer mouse events from TextNode to Label
A label's format is: <label>Label text</label>

So, a TextNode is created as a child of the Label node, and EventHandler
will send events to the TextNode. This changes TextNode to accept mouse
events if its parent is a Label, and to forward those events upward.
2021-04-04 16:13:25 +02:00
Andreas Kling
794ebb699c LibWeb: Remove low-hanging LibGUI fruit from LibWeb
We'll want to remove the LibGUI dependency from the WebContent process.
This is the first basic step of removing unnecessary LibGUI includes
and swapping out GUI::Painter for Gfx::Painter.
2021-02-10 09:13:29 +01:00
Andreas Kling
9de1253f44 LibWeb: Remove a whole bunch of unnecessary #includes 2021-02-10 09:13:29 +01:00
Andreas Kling
13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00