Commit Graph

481 Commits

Author SHA1 Message Date
Tobias Christiansen
ae3e6510d6 LibWeb: Parse flex-basis
Flex-basis accepts either 'content' or a Length.
2021-06-06 01:46:06 +04:30
Tobias Christiansen
27704f5f9e LibWeb: Add support for 'definite size' determination
This is pretty naive and there are more nuances in the spec but should
be enough for now.
2021-06-06 01:46:06 +04:30
Tobias Christiansen
ead864acf3 LibWeb: Parse and resolve flex-flow property 2021-06-06 01:46:06 +04:30
Tobias Christiansen
e6545d5259 LibWeb: Add parsing for flex-wrap property 2021-06-06 01:46:06 +04:30
Tobias Christiansen
72d5394b8c LibWeb: Flex-items aren't affected by float nor clear
There are a few other things to notice, but they don't seem to be
implemented yet.
2021-06-06 01:46:06 +04:30
Tobias Christiansen
7f81c8fba2 LibWeb: LayoutNodes know whether they are flex-items
This is useful for debugging when dumping the layout tree.
2021-06-06 01:46:06 +04:30
dylanbobb
2205239d9a LibWeb: Change BlockBox to not want mouse events 2021-06-05 22:35:22 +02:00
Ali Mohammad Pur
51c2c69357 AK+Everywhere: Disallow constructing Functions from incompatible types
Previously, AK::Function would accept _any_ callable type, and try to
call it when called, first with the given set of arguments, then with
zero arguments, and if all of those failed, it would simply not call the
function and **return a value-constructed Out type**.
This lead to many, many, many hard to debug situations when someone
forgot a `const` in their lambda argument types, and many cases of
people taking zero arguments in their lambdas to ignore them.
This commit reworks the Function interface to not include any such
surprising behaviour, if your function instance is not callable with
the declared argument set of the Function, it can simply not be
assigned to that Function instance, end of story.
2021-06-06 00:27:30 +04:30
Max Wipfli
282a623853 LibWeb: Change a few source end positions in HTMLTokenizer
This patch aims to fix wrong highlighting for some cases in HTML's
syntax highlighter. The values were somewhat experimentally determined
are are subject to change. Regardless, it should be more correct with
this patch than without it. :^)
2021-06-05 00:32:28 +04:30
Max Wipfli
44c438d0ca LibWeb: Fix off-by-one error in SyntaxHighlighter
This changes the HTML SyntaxHighlighter to conform to the now-fixed
rendering of syntax highlighting spans in GUI::TextEditor. It also
avoids emitting tokens if they have a zero or negative length.

This fixes a bug where single-character tokens were not highlighted
properly.
2021-06-05 00:32:28 +04:30
Max Wipfli
932161e581 LibWeb: Be more forgiving when adding source positions in HTMLTokenizer
This patch changes HTMLTokenizer::nth_last_position to not fail if the
requested position is not available. Rather, it will just return (0-0).

While this is not the correct solution, it prevents the tokenizer from
crashing just because it cannot find a source position. This should only
affect SyntaxHighlighter.
2021-06-05 00:32:28 +04:30
Max Wipfli
93d830b5cc LibWeb: Add debugging statements in SyntaxHighlighter
This also changes SyntaxHighlighter.{h,cpp} to use east const style.
2021-06-05 00:32:28 +04:30
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
Ali Mohammad Pur
56bf80251c LibWasm: Implement reference instructions (ref.{null,func,is_null}) 2021-06-02 16:09:16 +04:30
Luke
70a575d75f LibWeb: Use correct percent encode set for form submissions
We currently only support application/x-www-form-urlencoded for
form submissions, which uses a special percent encode set when
percent encoding the body/query. However, we were not using this
percent encode set.

With the new URL implementation, we can now specify the percent encode
set to be used, allowing us to use this special percent encode set.

This is one of the fixes needed to make the Google cookie consent work.
2021-06-01 23:26:03 +04:30
Max Wipfli
33396494f6 AK+LibWeb: Remove URL::to_string_encoded()
This replaces URL::to_string_encoded() with to_string() and removes the
former, since they are now equivalent.
2021-06-01 12:23:16 +02:00
Andreas Kling
12a42edd13 Everywhere: codepoint => code point 2021-06-01 10:01:11 +02:00
Andreas Kling
407d6cd9e4 AK: Rename Utf8CodepointIterator => Utf8CodePointIterator 2021-06-01 09:45:52 +02:00
Max Wipfli
1c4854824b LibWeb: Remove usage of URL::set_path() in FrameLoader
This replaces a call to URL::set_path() with URL::set_paths(), as
set_path() will be deprecated and removed.
2021-06-01 09:28:05 +02:00
Max Wipfli
0d41a7d39a AK: Remove URLParser
This removes URLParser, because its two exposed functions, urlencode()
and urldecode(), have been superseded by URL::percent_encode() and
URL::percent_decode(). This is in preparation for the introduction of a
new URL parser.
2021-06-01 09:28:05 +02:00
Max Wipfli
a603e69599 AK+Everywhere: Replace usages of URLParser::urlencode() and urldecode()
This replaces all occurrences of those functions with the newly
implemented functions URL::percent_encode() and URL::percent_decode().
The old functions will be removed in a further commit.
2021-06-01 09:28:05 +02:00
Linus Groh
ff914fabeb LibWeb/WrapperGenerator: Replace a fprintf() with warnln() 2021-05-31 17:43:54 +01:00
Luke
59cfc4a8db LibWeb: Rename "FrameHostElement" to "BrowsingContextContainer"
With the renaming of "Frame" to "BrowsingContext", this changes
"FrameHostElement" to "BrowsingContextContainer" to further
match the spec.

https://html.spec.whatwg.org/#browsing-context-container
2021-05-31 16:25:13 +02:00
Luke
2ad25aa8f8 LibWeb: Return null in Window.{top,parent} if browsing context is null
We were asserting that it exists, but the spec says to return null in
this case.

Top: https://html.spec.whatwg.org/multipage/browsers.html#dom-top
Parent: https://html.spec.whatwg.org/multipage/browsers.html#dom-parent
2021-05-31 14:22:38 +04:30
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
Linus Groh
d947253c51 LibWeb: Also call page_did_start_loading() for FrameLoader::Type::Reload
Surprisingly this is not used by the browser's page reload functionality
but only JS's location.reload() - that's probably why this hasn't been
noticed yet. Make sure we notify the page client about the load start in
that case as well. :^)
2021-05-29 01:27:06 +01:00
Linus Groh
56e69c4f2e LibWeb: Call page_did_start_loading() before load_resource()
Otherwise we would sometimes (dependent on the load time, I believe) end
up setting the document and eventually calling title change callbacks
before communicating that the page started loading.
2021-05-29 01:17:36 +01:00
Tobias Christiansen
301eb998c6 LibWeb: Improve performance of CSS custom property resolution
By memoizing already resolved custom properties in the DOM::Element,
we achieve a notable speed increase when loading SerenityOS on GitHub.
2021-05-29 00:58:07 +04:30
Tobias Christiansen
3ede1d08f5 LibWeb: Avoid unnecessary String copy in parsing CSS custom properties 2021-05-29 00:58:07 +04:30
Tobias Christiansen
fd6b04055c LibWeb: Resolve custom properties
The way to get the custom properties is pretty weird and this code is
as far from optimized as it gets but somehow it works :^)
2021-05-28 10:45:38 +01:00
Tobias Christiansen
bf9c5ffb3f LibWeb: StyleResolver: Keep track of specificity of matched selector
This way it gets easier to compare matches.
2021-05-28 10:45:38 +01:00
Tobias Christiansen
c4588a2cde LibWeb: Add parsing for custom properties
This parses 'some-property: var(--some-name)' and stores its findings
in a CustomStyleValue.
It also parses the custom properties like '--some-name: some-value' and
puts them into the StyleProperty.
2021-05-28 10:45:38 +01:00
Tobias Christiansen
0d7169b91a LibWeb: Store custom properties in CSSStyleDeclaration
Keep them around when parsing and store them in the CSSStyleDeclaration
when done.
2021-05-28 10:45:38 +01:00
Tobias Christiansen
f0c6160362 LibWeb: Add CustomStyleValue
This extends StyleValue and can hold the identifier of the custom
property.
2021-05-28 10:45:38 +01:00
Tobias Christiansen
8396099e0e LibWeb: Add PropertyID::Custom to code generator 2021-05-28 10:45:38 +01:00
Ali Mohammad Pur
6af596d9e8 LibJS+LibWeb: Make Uint8ClampedArray use TypedArray
Instead of being its own separate unrelated class.
This automatically makes typed array properties available to it,
as well as making it available to the runtime.
2021-05-26 15:34:13 +04:30
Ali Mohammad Pur
cf8b75c2e5 LibWasm+LibWeb: Partially resolve memory exports
This allows the JS side to access the wasm memory, assuming it's
exported by the module.
This can be used to draw stuff on the wasm side and display them from
the js side, for example :^)
2021-05-26 15:34:13 +04:30
Ali Mohammad Pur
3926eab3b7 LibWasm+LibWeb: Implement (a very basic version of) the JS link/import
This allows Wasm code to call javascript functions.
2021-05-26 15:34:13 +04:30
Ali Mohammad Pur
a2af04837e LibWeb: Implement a very basic WebAssembly JS API
This impl is *extremely* simple, and is missing a lot of things, it's
also not particularly spec-compliant in some places, but it's definitely
a start :^)
2021-05-26 15:34:13 +04:30
Tobias Christiansen
820224bb48 LibWeb: Match the :not pseudoclass
When a Selector features a :not() pseudoclass we now check whether the
current element matches with the given selector in the :not and act
accordingly.
2021-05-24 22:10:08 +01:00
Tobias Christiansen
1ab82afee6 LibWeb: Add :not pseudoclass to the CSS parser
The selector given in the :not() is stored in the SimpleSelector as a
String.
2021-05-24 22:10:08 +01:00
Tobias Christiansen
9a1ac662f1 LibWeb: Don't try to load anything if src is empty in <img>
Previously we tried to load "" if the src was present but empty and
essentially only waited for RequestServer to time out.
2021-05-24 17:45:09 +01:00
Andreas Kling
de395a3df2 AK+Everywhere: Consolidate String::index_of() and String::find()
We had two functions for doing mostly the same thing. Combine both
of them into String::find() and use that everywhere.

Also add some tests to cover basic behavior.
2021-05-24 11:59:18 +02:00
Tobias Christiansen
b53dac6e88 LibWeb: Add support for more pseudoclasses
:disabled, :enabled and :checked are now parsed and matched. There
surely are more nuances to consider.
2021-05-24 02:14:11 +04:30
Andreas Kling
c1c252ddb2 LibIPC: Remove unnecessary IPC::ServerConnection::handshake()
This is no longer used by any of our IPC pairs.
2021-05-23 09:53:55 +02:00
Andreas Kling
67b47d62f3 WebContent: Remove unnecessary greet() message 2021-05-23 09:53:55 +02:00
Max Wipfli
9440a3c280 LibWeb: Improve Unicode compatibility of HTML contenteditable
This patch updates the Page::keydown_event event handler to implement
crude Unicode support. It implements new method in EditEventHandler to
more easily handle deleting a single character after the cursor.
Furthermore, it makes use of the previously implemented methods to
increment and decrement the cursor position, which take into account
that Unicode codepoint may be multiple bytes wide.

This means it is now possible to mostly edit Unicode in editable DOM
nodes without any crashes. :^)
2021-05-21 21:57:03 +02:00
Max Wipfli
7181cb3a9c LibWeb: Frame/Position: Implement cursor increment/decrement methods
This introduces methods to increment and decrement the cursor position.
This is non-trivial as the cursor position is specified in bytes rather
than codepoints. Thus, it sometimes needs to be incremented or
decremented by more than one, depending on the codepoint to "jump over".

Because the cursor blink cycle needs to be reset after moving the
cursor, methods calling the ones in DOM::Position are implemented in
Frame. Furthermore, this allows the cursor_position() getter to stay
const. :^)

Additionally, it adds a offset_is_at_end_of_node() method which checks
if the current offset points to the end of the node.
2021-05-21 21:57:03 +02:00