Commit graph

17649 commits

Author SHA1 Message Date
MacDue
d0511ec650 LibWeb: Avoid painting background-images under opaque borders
Without this the background-image can be painted up to 8 extra
times, that contribute nothing to the final image.
2022-08-08 22:39:06 +02:00
MacDue
6a6475673f LibWeb: Convert images to common AbstractImageStyleValue base
This commit moves both the ImageStyleValue and LinearGradientStyleValue
to a common base class of AbstractImageStyleValue. This abstracts
getting the natural_width/height, loading/resolving, and painting
the image.

Now for 'free' you get:

 - Linear gradients working with the various background sizing/repeat
   properties.
 - Linear gradients working as list-markers :^) -- best feature ever!

P.s. This commit is a little large as it's tricky to make this change
incrementally without breaking things.
2022-08-08 22:39:06 +02:00
MacDue
264543b90a LibGfx: Add Size<T>::to_rounded<I>()
Currently this is only specialized for rounding to integer types.
2022-08-08 22:39:06 +02:00
MacDue
361fc56632 LibWeb: Don't allow mixed commas/no commas in rect() css values
This fixes the clip-rect-comma-002, clip-rect-comma-003, and
clip-rect-comma-004 web platform tests.
2022-08-08 14:03:29 +02:00
MacDue
9c8aa5b777 LibWeb: Fix resolution of CSS clip rect
Previously the clip rect was not relative to the top/left egdes
of the element, which lead to it being positioned incorrectly.

This fixes the clip-rect-auto-004 and clip-rect-auto-005 web
platform tests.
2022-08-08 14:03:29 +02:00
MacDue
038017ce11 LibWeb: Enable CSS clip for position: fixed elements
This fixes the clip-absolute-positioned-002 web platform test.
2022-08-08 14:03:29 +02:00
Tom
6b2e93eb7c LibWeb: Fix RectStyleValue to_string() implementation
Fix implementation of to_string() for RectStyleValue so that it can be
used by JS.
2022-08-08 12:16:36 +02:00
MacDue
a6505f6e6d LibWeb: Allow % height of a % height parent in block-formatted elements
With this you can start to see Francine's face in the CSS oil painting
(https://diana-adrianne.com/purecss-francine/)
2022-08-07 22:52:22 +02:00
MacDue
0e8dafcbb8 LibWeb: Allow absolute boxes to have a % height of a % height parent
Previously absolutely positioned boxes could only have a % height if
their parent had a absolute height (a height in pixels, em, etc).

This broke some websites/demos such as the "Francine CSS oil painting",
which starts to appear after this commit.

Francine: https://diana-adrianne.com/purecss-francine/
2022-08-07 22:52:22 +02:00
Tom
5049a56d96 LibWeb: Implement clip property
Implement clip when it is defined in the css property 'clip' as a rect
according to spec; only when the div is absolutely positioned.
2022-08-07 22:40:11 +02:00
Tom
8163ee1500 LibWeb: Use rect value in CSS clip property
When a rect value is passed to the clip property via CSS, keep it in
ComputedValues so that at a later stage can make use of it.
2022-08-07 22:40:11 +02:00
Tom
b4dd477644 LibWeb: Parse rect style value
Add ability to parse a rect when it is used as the value of a style
property.
2022-08-07 22:40:11 +02:00
Karol Kosek
5c4d130af5 Browser: Make Refresh action in tab context menu refresh the chosen tab
It was sending refresh requests to the current tab instead.
2022-08-07 20:49:45 +02:00
Karol Kosek
0db481c763 Browser: Make the bookmark button use an action
This merges 2 duplicated definitions (one for button, second just for
the keyboard shortcut) which also makes the button 'react' on that
shortcut. :^)
2022-08-07 20:49:45 +02:00
Karol Kosek
3b5766d078 Browser: Show bookmark and history page lists under the their buttons
Previously they were showing right under the cursor.
2022-08-07 20:49:45 +02:00
Karol Kosek
8f5968d4ad Browser: Set margins for BookmarkBarWidget
It's just what GUI::Toolbar is using. Changed this to make the bookmark
overflow button align with the bookmark button.
2022-08-07 20:49:45 +02:00
Karol Kosek
d80bc2ba32 Browser: Use overflow-menu icon for hidden bookmarks the button
97b381652a started using that icon for toolbars. Let's also use it here
for the sweet system consistency!
2022-08-07 20:49:45 +02:00
MacDue
ca2e345cdc LibWeb: Support -webkit-linear-gradient() correctly
The -webkit version of linear-gradient does not include the `to`
before a <side or corner>. The angles of the <side or corner>
for the webkit version are also opposite that of the standard one.

So for the standard: linear-gradient(to left, red, blue)
The webkit version is: -webkit-linear-gradient(right, red, blue)

Adding the `to` in the -webkit version is invalid, omitting it in
the standard one is also invalid.
2022-08-07 20:47:31 +02:00
Andreas Kling
e0d7d3c3d5 LibJS: Teach String.prototype.concat() to create rope strings
Defer serialization of the concatenated strings until later. This is
used heavily in SunSpider's string-validate-input subtest, which
sees a small progression.
2022-08-06 13:50:39 +01:00
Linus Groh
8ed28890e4 LibJS: Correct BalanceDurationRelative algorithm
This is a normative change in the Temporal spec.

See:
- https://github.com/tc39/proposal-temporal/commit/cbf5863
- https://github.com/tc39/proposal-temporal/commit/f47d57d
2022-08-06 13:42:37 +01:00
Linus Groh
12edbb51bc LibJS: Rename PrimitiveString::m_{left,right} to m_{lhs,rhs}
The LHS/RHS naming is already widely used as parameter names and local
variables with the same meaning, so let's also use them for the members.
2022-08-06 12:02:48 +02:00
Linus Groh
885004abee LibJS: Support creation of global object in Realm::set_global_object() 2022-08-06 12:02:48 +02:00
Linus Groh
c8f1651761 LibJS+LibWeb: Restore type safety of Realm::set_global_object()
The changes from 8a03b17 to allow any JS::Value aren't a good fit, as
shown by the excessive amount of verify_cast needed :^)
2022-08-06 12:02:48 +02:00
Andreas Kling
64b29eb459 LibJS: Implement string concatenation using ropes
Instead of concatenating string data every time you add two strings
together in JavaScript, we now create a new PrimitiveString that points
to the two concatenated strings instead.

This turns concatenated strings into a tree structure that doesn't have
to be serialized until someone wants the characters in the string.

This *dramatically* reduces the peak memory footprint when running
the SunSpider benchmark (from ~6G to ~1G on my machine). It's also
significantly faster (1.39x) :^)
2022-08-06 00:29:15 +02:00
thankyouverycool
517c03f920 Minesweeper: Update GML and fix layout issues
Converts Minesweeper's main widget to GML, polishes the custom
game window, formats the clock as human readable digital time, and
defers invoking Field's callback until the main widget has finished
relayout. Fixes inability to downsize the main window when shrinking
field size.
2022-08-05 13:55:13 +02:00
thankyouverycool
4d09b5c4ba LibGUI: Register "bitmap" GML property for ImageWidget 2022-08-05 13:55:13 +02:00
thankyouverycool
a808cfa75c LibGUI+Applications: Govern Splitter resizing by opportunistic growth
This patch replaces the concept of fixed resizees with opportunistic
ones which use the new SpecialDimension::OpportunisticGrow UISize.
This lets us simplify splitter resize code and take advantage of
the layout system's automatic calculations for minimum size and
expansion. Functionally the same as before, but fixes Splitter's
unintended ability to grow window size.
2022-08-05 13:54:18 +02:00
thankyouverycool
6f2a304971 LibGUI: Calculate maximum primary size for Splitter resizees 2022-08-05 13:54:18 +02:00
Andreas Kling
aaa4f6d287 LibJS: Run clang-format on Realm.cpp 2022-08-05 12:55:25 +02:00
Andreas Kling
c77a0974ab LibWeb: Port web workers to the "create a new JavaScript realm" API 2022-08-05 12:46:42 +02:00
Andreas Kling
94d54069f4 LibWeb: Don't paint non-visible frames
This fixes an issue where iframes hidden with CSS `visibility: none`
would still be visible.
2022-08-05 12:46:42 +02:00
Andreas Kling
e2ae286132 LibJS: Actually create a new Realm in $262.createRealm() 2022-08-05 12:46:42 +02:00
Andreas Kling
95e011e2a0 LibWeb: Support assigning to window.location
Assignments actually forward to window.location.href, as the spec
requires. Since the window object is implemented by hand, this looks a
little janky. Eventually we should move all this stuff to IDL.
2022-08-05 12:46:42 +02:00
Andreas Kling
2a7924f96c LibWeb: Bring browsing context creation closer to spec
This patch implements the "create a new browsing context" function from
the HTML spec and replaces our existing logic with it.

The big difference is that browsing contexts now initially navigate to
"about:blank" instead of starting out in a strange "empty" state.
This makes it possible for websites to create a new iframe and start
scripting inside it right away, without having to load an URL into it.
2022-08-05 12:46:42 +02:00
Andreas Kling
73f77969a6 LibWeb: Add API for setting a document's referrer 2022-08-05 12:46:42 +02:00
Andreas Kling
6e71e400e6 LibWeb: Store document origin as a HTML::Origin object
This will allow us to remember an arbitrary origin instead of deriving
it from the document's URL.
2022-08-05 12:46:42 +02:00
Andreas Kling
130be479cb LibGfx: Don't use Span<u32> as hash key for cached emojis
We can't rely on the caller to keep the code points alive, and this
was sometimes causing incorrect cache hits, leading to the wrong
emoji being displayed.

Fixes #14693
2022-08-05 12:46:41 +02:00
Andreas Kling
b6bd793ede LibWeb: Clear the "is initial about:blank" flag in Document.write() 2022-08-05 12:46:41 +02:00
Andreas Kling
c46a8194b4 LibWeb: Use Document::m_type to check for XML documents
...instead of doing a string compare on the DOCTYPE node.
2022-08-05 12:46:41 +02:00
Andreas Kling
99ecc216d7 LibWeb: Show iframe URLs in layout tree dumps 2022-08-05 12:46:40 +02:00
Andreas Kling
602f927982 LibWeb: Start implementing "create and initialize a Document" from HTML
The way we've been creating DOM::Document has been pretty far from what
the spec tells us to do, and this is a first big step towards getting us
closer to spec.

The new Document::create_and_initialize() is called by FrameLoader after
loading a "text/html" resource.

We create the JS Realm and the Window object when creating the Document
(previously, we'd do it on first access to Document::interpreter().)

The realm execution context is owned by the Environment Settings Object.
2022-08-05 12:46:40 +02:00
Andreas Kling
0781bdb23e LibWeb: Add HTML::NavigationParams 2022-08-05 12:46:39 +02:00
Andreas Kling
fb1900e79c LibJS: Make Interpreter::create() call InitializeHostDefinedRealm()
Instead of having two implementations of this AO, let's just have
Interpreter::create() call the new full version of the AO in Realm.
2022-08-05 12:46:39 +02:00
Andreas Kling
8a03b17007 LibJS: Implement a more general InitializeHostDefinedRealm AO
The existing implementation of this AO lives in Interpreter::create(),
which makes it impossible to use without also constructing an
Interpreter.

This patch adds a new Realm::initialize_host_defined_realm() and takes
the global object and global this customization steps as Function
callback objects. This will be used by LibWeb to create realms during
Document construction.
2022-08-05 12:46:38 +02:00
Andreas Kling
e756b5450d LibWeb: Add a way to construct HTML::Window without a DOM::Document
This will be used to implement the rather intricate construction order
in the HTML spec.
2022-08-05 12:42:46 +02:00
Andreas Kling
eca0873245 LibWeb: Always put a dummy execution context on the main thread VM stack
A lot of code assumes that there's a current execution context. By
setting up a dummy context right after creating the main thread VM,
we ensure that such code can always run.
2022-08-05 12:42:46 +02:00
Andreas Kling
2801ddfa76 LibWeb: Implement (naive) version of HTMLIFrameElement.contentWindow
This should really return the WindowProxy, but since we don't have the
infrastructure set up just yet, just return the window object itself
for now.
2022-08-05 12:42:46 +02:00
Andreas Kling
8909ef5b90 LibWeb: Add HTML::SandboxingFlagSet 2022-08-05 12:42:46 +02:00
Andreas Kling
5d773732b7 LibWeb: Add HTML::CrossOriginOpenerPolicyEnforcementResult 2022-08-05 12:42:46 +02:00
Andreas Kling
b73bd4f988 LibWeb: Add HTML::CrossOriginOpenerPolicy 2022-08-05 12:42:46 +02:00