Commit Graph

113 Commits

Author SHA1 Message Date
Andreas Kling
e2eabb4132 LibCore: Use ErrorOr<T> in Core::AnonymousBuffer 2021-11-08 00:35:27 +01:00
Ben Wiederhake
4e55d649d7 Services: Fix visibility of Object-derivative constructors
Derivatives of Core::Object should be constructed through
ClassName::construct(), to avoid handling ref-counted objects with
refcount zero. Fixing the visibility means that misuses like this are
more difficult.
2021-11-02 22:56:53 +01:00
Sam Atkins
53edaa3b26 LibWeb+WebContent: Add set_preferred_color_scheme IPC call
This allows the owner of a WebView to override whether to use a dark
theme or not, instead of just using the system theme's IsDark property.
2021-10-31 18:39:13 +01:00
Idan Horowitz
9d1fb85f93 WebContent: Convert ConsoleGlobalObject functions to ThrowCompletionOr 2021-10-31 18:20:37 +02:00
Andreas Kling
03c3b3b7e5 LibWeb: Null-check document before doing layout in PageHost::paint() 2021-10-28 18:29:49 +02:00
Andreas Kling
23561133aa LibWeb: Always update layout (if needed) before painting 2021-10-28 18:14:38 +02:00
Andreas Kling
398c181c79 LibJS: Rename PropertyName to PropertyKey
Let's use the same name as the spec. :^)
2021-10-24 17:18:07 +02:00
Idan Horowitz
40eb3a39d4 LibJS: Rename define_native_function => define_old_native_function
This method will eventually be removed once all native functions are
converted to ThrowCompletionOr
2021-10-20 12:27:19 +01:00
Idan Horowitz
20163c0584 LibJS: Add ThrowCompletionOr versions of the JS native function macros
The old versions were renamed to JS_DECLARE_OLD_NATIVE_FUNCTION and
JS_DEFINE_OLD_NATIVE_FUNCTION, and will be eventually removed once all
native functions were converted to the new format.
2021-10-20 12:27:19 +01:00
Idan Horowitz
56e769e4ba LibJS: Replace usages of JS_{DECLARE, DEFINE}_NATIVE_GETTER
These macros are equivalent to JS_{DECLARE, DEFINE}_NATIVE_FUNCTION and
were only sometimes used, so let's just get rid of them altogether.
2021-10-20 12:27:19 +01:00
Andreas Kling
27d4ac316f LibWeb: Introduce simple scrollable overflow, size ICB to viewport
Per spec, the initial containing block (ICB) should have the size of the
viewport. We have only done this for the width until now, since we had
no way to express scrollable overflow.

This patch adds Layout::Box::m_overflow_data, an optional struct that
can hold on to information about a box's overflow. Then we have BFC
set the ICB up with some scrollable overflow instead of sizing it to fit
its content vertically.

This fixes a number of broken layouts where correctness depends on
having the appropriate ICB height.
2021-10-14 23:22:59 +02:00
Linus Groh
52976bfac6 LibJS: Convert to_object() to ThrowCompletionOr 2021-10-13 09:55:10 +01:00
Linus Groh
3be26f56db LibJS: Convert has_own_property() to ThrowCompletionOr 2021-10-03 20:14:03 +01:00
davidot
0d73487204 LibWeb: Fix that $0 was no longer accessible
We now set the realm (twice) on every console input. This can probably
be avoided if we use two executing contexts one for the website the
other for the console.
This achieves a similar behavior but is not really nice and not really
spec like.
2021-10-03 17:42:05 +02:00
Idan Horowitz
890d5e45ee Browser: Check m_console_client is non-null before dereferencing it
This added check matches CientConnection::js_console_input and makes
sure the webcontent process doesn't crash if the console is opened
while no page is available (like in a file not found situation)
2021-10-01 01:17:44 +02:00
Linus Groh
ee8380edea LibJS: Convert internal_own_property_keys() to ThrowCompletionOr 2021-09-29 23:49:53 +01:00
Linus Groh
fbfb0bb908 LibJS: Convert internal_delete() to ThrowCompletionOr 2021-09-29 23:49:53 +01:00
Linus Groh
e5409c6ead LibJS: Convert internal_set() to ThrowCompletionOr 2021-09-29 23:49:53 +01:00
Linus Groh
6c2b974db2 LibJS: Convert internal_get() to ThrowCompletionOr 2021-09-29 23:49:53 +01:00
Linus Groh
d9895ec12d LibJS: Convert internal_has_property() to ThrowCompletionOr 2021-09-29 23:49:53 +01:00
Linus Groh
5da210125e LibJS: Convert internal_define_own_property() to ThrowCompletionOr 2021-09-29 23:49:53 +01:00
Linus Groh
0e69a6e487 LibJS: Convert internal_get_own_property() to ThrowCompletionOr 2021-09-29 23:49:53 +01:00
Linus Groh
73bae7d779 LibJS: Convert internal_prevent_extensions() to ThrowCompletionOr 2021-09-29 23:49:53 +01:00
Linus Groh
9b4362f10a LibJS: Convert internal_is_extensible() to ThrowCompletionOr 2021-09-29 23:49:53 +01:00
Linus Groh
8c81c84c18 LibJS: Convert internal_set_prototype_of() to ThrowCompletionOr 2021-09-29 23:49:53 +01:00
Linus Groh
5148150e1c LibJS: Convert internal_get_prototype_of() to ThrowCompletionOr 2021-09-29 23:49:53 +01:00
Andreas Kling
651f30dfbe WebContent: Coalesce paint invalidations to avoid spamming client
Some content cause a lot of paint invalidations (e.g someone drawing to
a <canvas> repeatedly) and we don't need to spam the client about this.
Instead, accumulate a dirty rect, and send it once per event loop step.
2021-09-28 22:53:59 +02:00
Andreas Kling
0af0ee4293 LibWeb: Fire "keyup" events as well :^)
This was easy, now that we have KeyboardEvent.
2021-09-28 16:56:24 +02:00
Andreas Kling
a79bdd2bd5 LibWeb+Browser: Make ad blocking work in the multi-process world
We now send the list of content filters over to new WebContent processes
after creating an OutOfProcessWebView. :^)
2021-09-27 11:40:56 +02:00
Karol Kosek
620e4fd0d2 WebContent: Pass an empty bitmap object if the pointer is null
Prior this commit we were always dereferencing the image bitmap pointer,
even if it was null, which resulted in a crash when trying to open
the context menu when an image wasn't loaded.

Closes: #10178
2021-09-22 22:10:11 +02:00
Andreas Kling
19de6bb1cc LibWeb+Browser: Add Debug menu action for toggling Same-Origin Policy
Sometimes it's useful to turn off the SOP for testing purposes.
Let's make that easy by having a Debug menu item for it. :^)
2021-09-12 02:13:28 +02:00
Timothy Flynn
1139aa45b6 WebContent: Use ErrorType::NotAnObjectOfType instead of NotA 2021-09-12 00:16:39 +02:00
Sam Atkins
83414af9f3 LibWeb+WebContent: Add WebContentClient::did_request_scroll_to() call
This call sets the absolute scroll position for the window.
2021-09-11 15:51:05 +01:00
Sam Atkins
a09219159c LibWeb+WebContent: Modify did_request_scroll() IPC to take x&y deltas
This is in preparation for implementing JS scrolling functions, which
specify both x and y scrolling deltas. The visible behavior has not
changed.

Also, moved the "mouse wheel delta * 20" calculation to the
`EventHandler` since the JS calls will want to work directly in pixels.
2021-09-11 15:51:05 +01:00
Andreas Kling
90cdeebfb3 LibWeb: Rename DOM::Window::document() => associated_document()
Match the spec nomenclature.
2021-09-09 21:25:10 +02:00
Andreas Kling
84fcf879f9 LibWeb: Rename BrowsingContext::document() => active_document()
This better matches the spec nomenclature. Note that we don't yet
*retrieve* the active document according to spec.
2021-09-09 21:25:10 +02:00
Andreas Kling
e91edcaa28 LibWeb: Rename InitialContainingBlockBox => InitialContainingBlock
The "Box" suffix added nothing here.
2021-09-08 11:27:46 +02:00
Andreas Kling
9d9500989a LibWeb: Remove unused PageClient::is_multi_process() 2021-09-08 11:07:14 +02:00
Andreas Kling
9d03ea6f74 LibWeb+WebContent: Port DumpLayoutTree to OutOfProcessWebView
This required adding a simple OOPWV::dump_layout_tree() API that
synchronously requests a dump of the layout tree from the WebContent
process.
2021-09-08 11:07:14 +02:00
Sam Atkins
e255b5dd31 LibWeb+WebContent: Remove old console-logging IPC calls
This patch removes the following WebContent IPC calls, which are no
longer used:

- `Server::js_console_initialize()`
- `Client::did_js_console_output()`
2021-09-06 18:20:26 +02:00
Sam Atkins
95aa6562db Browser+WebContent: Initialize WebContentConsoleClient earlier
With this patch, we now initialize the `WebContentConsoleClient` as soon
as the Page has loaded, instead of waiting for the Console Window to be
shown. This finally lets us see log messages that happened before the
window was opened! :^)

However, it is not perfect. Waiting until the page has loaded means we
lose any messages that happen *during* page load. Ideally we would
initialize the WCCC when the page *starts* loading instead, but it
requires that the page has a document and interpreter assigned and
accessible. As far as I can tell with my limited knowledge, this is not
the case until the page has completed loading.
2021-09-06 18:20:26 +02:00
Sam Atkins
f6a927fa20 WebContent: Store messages in WebContentConsoleClient
The `WebContentConsoleClient` now keeps a list of console messages it
has received, so these are not lost if the ConsoleWidget has not been
initialized yet.

This change does break JS console output, but only until the next
commit. :^)
2021-09-06 18:20:26 +02:00
Sam Atkins
c619a57cf8 LibWeb+WebContent: Add new console-message IPC calls
This patch introduces three new IPC calls for WebContent:

- `Client::did_output_js_console_message(index)`:
  Notifies the client that a new console message was logged.

- `Server::js_console_request_messages(start_index)`:
  Ask the server for console messages starting at the given index.

- `Client::did_get_js_console_messages(start_index, types, messages)`:
  Send the client the messages they requested.

This mechanism will replace the current
`Client::did_js_console_output()` call in the next few commits. This
will allow us to display messages in the console that happened before
the console was opened.
2021-09-06 18:20:26 +02:00
Sam Atkins
5220d6d2e5 WebContent: Implement $0 special variable in Browser JS Console
`$0` is a helpful variable in other browsers' JS consoles, which points
to whichever DOM Node is currently selected in the DOM Inspector. And
now we have it too! :^)
2021-09-06 18:20:26 +02:00
Sam Atkins
7838eab341 WebContent: Implement ConsoleGlobalObject which proxies to WindowObject
ConsoleGlobalObject is used as the global object when running javascript
from the Browser console. This lets us implement console-only functions
and variables (like `$0`) without exposing them to webpage content. It
passes other calls over to the usual WindowObject so any code that would
have worked in the webpage will still work in the console. :^)
2021-09-06 18:20:26 +02:00
Sam Atkins
e2c32a6c65 Everywhere: Use my shiny new serenityos.org email :^) 2021-09-03 12:22:36 +02:00
Sam Atkins
1ccf10789e LibWeb+WebContent: Add query for hovered DOM node to OOPWV
This is needed for the "Inspect Element" context menu action.
2021-09-02 22:16:41 +02:00
Sam Atkins
3b07f49d48 LibWeb+WebContent: Implement asynchronous DOM Node properties call
This lets us "push" a new style-properties list to the DOM Inspector,
for example when JS changes the style of the inspected node.
2021-09-02 22:16:41 +02:00
Sam Atkins
f381f8d63e LibWeb+WebContent: Add inspect_dom_node() IPC call
This is the IPC version of `Document::set_inspected_node()`, using a
node ID.

We return the inspected node's style properties as JSON, so that the DOM
Inspector can immediately display them.
2021-09-02 22:16:41 +02:00
Andreas Kling
fd922cf92f LibWeb+WebContent: Add a simple API for running arbitrary JavaScript
This patch adds OutOfProcessWebView::run_javascript(StringView).
This can be used by the OOPWV embedder to execute arbitrary JavaScript
in the top-level browsing context on the WebContent process side.
2021-08-24 16:56:42 +02:00