Commit Graph

9511 Commits

Author SHA1 Message Date
Andreas Kling
3b9f110161 LibWeb+LibImageDecoderClient: Reuse ImageDecoder service process
The overhead from spawning a new ImageDecoder for every decoding job is
way too large and causing other problems as well (#5421)

Let's keep the same decoder open and reuse it as long as it's working.
2021-02-20 11:37:55 +01:00
Linus Groh
14058b6858 LibWeb: Use DOMException in XMLHttpRequest::send() 2021-02-20 09:14:19 +01:00
Linus Groh
70878290b9 LibWeb: Use DOMException in XMLHttpRequest::open() 2021-02-20 09:14:19 +01:00
Linus Groh
c4d8cce9a2 LibWeb: Use DOMException in XMLHttpRequest::set_request_header() 2021-02-20 09:14:19 +01:00
Linus Groh
4e1de09340 LibWeb: Use DOMException in HTMLElement::set_content_editable() 2021-02-20 09:14:19 +01:00
Linus Groh
dd621cc650 LibWeb: Use DOMException in Document::set_body() 2021-02-20 09:14:19 +01:00
Linus Groh
e064194061 LibWeb: Return InvalidCharacterError from Element::set_attribute() for empty attr
This is the first user of the new DOMException, using ExceptionOr. :^)
2021-02-20 00:09:11 +01:00
Linus Groh
3da2b51d74 LibWeb: Generate code for throwing DOMExceptions based on ExceptionOr<T>
There's a little bit of template magic involved here to make it work,
but this seems alright. Very cool! :^)

Co-authored-by: AnotherTest <ali.mpfard@gmail.com>
2021-02-20 00:09:11 +01:00
Linus Groh
e708f1c3a2 LibWeb: Add DOM::ExceptionOr<T> container
Much like AK::Result this carries either a DOM::DOMException or regular
return value and will be used by DOM functions for exceptions that
should be thrown.
2021-02-20 00:09:11 +01:00
Linus Groh
ada71dc71b LibWeb: Add DOM::DOMException class and bindings 2021-02-20 00:09:11 +01:00
Linus Groh
13867600c3 LibWeb: Add constructor to XMLHttpRequest IDL interface 2021-02-17 23:45:07 +01:00
Linus Groh
8f8f7bfd0f LibWeb: Add constructor to Range IDL interface 2021-02-17 23:45:07 +01:00
Linus Groh
0ac07c7351 LibWeb: Add constructor to Event IDL interface 2021-02-17 23:45:07 +01:00
Linus Groh
0f1da7d40c LibWeb: Add constructor to Document IDL interface 2021-02-17 23:45:07 +01:00
Linus Groh
8c7d1986b8 LibWeb: Actually construct impl and wrapper in construct() :^)
FooConstructor::construct() is no longer a dummy but now generates
either code to throw an exception (for interfaces without constructor)
or code to construct the wrapper and its impl object.

Constructor overloads are not currenly handled, but that's not something
we need right now anyway. Instead of  regular create() this uses a new
static function create_with_global_object() and passes the WindowObject,
which may be needed - e.g. for XMLHttpRequest, which has an IDL and
JavaScript constructor with no arguments, but needs a DOM::Window in its
create().
2021-02-17 23:45:07 +01:00
Linus Groh
e3577f871b LibWeb: Parse IDL interface constructors
WrapperGenerator will now parse and store IDL interface constructors,
including parameters and overloads.
See https://heycam.github.io/webidl/#idl-constructors.
2021-02-17 23:45:07 +01:00
Linus Groh
ff324fe989 LibWeb: Fix .length of functions generated from IDL
Function::length() is computing the right function length based on its
parameters, but we never called it - instead the *function name length*
was being used, which is obviously wrong. How silly! :^)
2021-02-17 23:45:07 +01:00
Andreas Kling
2d64ba7b9d LibWeb: Convert dbgprintf() => dbgln() 2021-02-17 15:59:13 +01:00
Andreas Kling
2323b6fb74 LibWeb: Use the correct DOM node when moving text cursor with mouse
We should use the DOM node returned by the TextCursor hit test,
and not the one we got from the earlier Exact hit test.
2021-02-15 23:25:29 +01:00
Andreas Kling
c51209a06a LibWeb: Move cursor along when drag-selecting in editable content 2021-02-15 18:12:14 +01:00
Andreas Kling
8743ea3149 LibWeb: Relayout document on CharacterData data change
This can definitely be optimized to avoid full relayouts in many
situations, but for now let's just go for correctness.
2021-02-10 19:06:20 +01:00
Andreas Kling
29a2aac89a LibWeb: Start implementing <input type=text> using a shadow DOM
Text <input> fields will now generate a basic shadow DOM and attach it
to the input element.

The shadow DOM contains a <div> with some inline style, and an always-
editable text node inside it. Accessing the "value" attribute on such
an input element will get/set the value from that text node.

This is really cool, although not super stable since HTML editing is
not super stable. But it's a start! :^)
2021-02-10 19:06:20 +01:00
Andreas Kling
e4e325ff61 LibWeb: Include shadow DOM subtrees in DOM dumps 2021-02-10 19:06:20 +01:00
Andreas Kling
e562819a7e LibWeb: Generate layout nodes for shadow subtrees
Elements with shadow roots will now recurse into those shadow trees
while building the layout tree.

This is the first step towards basic Shadow DOM support. :^)
2021-02-10 19:06:20 +01:00
Andreas Kling
41ff7268db LibWeb: Add a way to make a DOM::Text always editable
This will be useful for input element purposes.
2021-02-10 19:06:20 +01:00
Andreas Kling
2eddd74e85 LibWeb: Add DOM::Node::parent_or_shadow_host()
This is useful when you want to traverse across shadow boundaries.
2021-02-10 19:06:20 +01:00
Andreas Kling
d597626ea1 LibWeb: Add a way to give DOM::Element a ShadowRoot
You can now attach a shadow root to your favorite Element. It doesn't
do anything yet, but you can.
2021-02-10 19:06:20 +01:00
Andreas Kling
bf82e7fba2 LibWeb: Add DOM::ShadowRoot to forwarding header 2021-02-10 19:06:20 +01:00
Andreas Kling
bbce1ab1c1 LibWeb: Use the DOM::Node::node_name() a bit more in dumps 2021-02-10 17:15:16 +01:00
Andreas Kling
acd46dcb0c LibWeb: Respect the bgcolor attribute on <marquee> elements
We don't yet animate marquees, but we can at least fill them with the
right background color.
2021-02-10 09:54:16 +01:00
Andreas Kling
5e91e61900 LibWeb: Remove WidgetBox layout node
The approach of attaching sub-widgets to the web view widget was only
ever going to work in single-process mode, and that's not what we're
about anymore, so let's just get rid of WidgetBox so we don't have the
dead-end architecture hanging over us.

The next step here is to re-implement <input type=text> using LibWeb
primitives.
2021-02-10 09:13:30 +01:00
Andreas Kling
1ad65b173b LibWeb+WebContent: Support window.confirm() in OOPWV 2021-02-10 09:13:30 +01:00
Andreas Kling
abf7c02acb LibWeb: Move window.confirm() to using a PageClient callback
This allows us to move the GUI::MessageBox out of DOM::Window and up to
the widget layer.
2021-02-10 09:13:30 +01: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
f24b674d7a LibWeb+WebContent: Don't relayout page on every scroll event
The WebContent process was redoing page layout every time you scrolled
the page. This was a huge CPU hog for no reason. Fix this by only doing
a relayout when the viewport is resized, not when it moves around.
2021-02-09 22:40:16 +01:00
Andreas Kling
c9aa7539a6 LibWeb: Make OOPWV resizing flicker-free :^)
When resizing, keep a copy of the last good bitmap we have, and keep
using that until we receive a new one from the WebContent process.
2021-02-09 22:08:55 +01:00
Andreas Kling
ace1b34798 LibWeb: Reset the HTML editing cursor blink cycle on arrow key movement
Also stop exposing the DOM cursor as a mutable reference on Frame,
since event handling code was using that to mess with the text offset
directly. Setting the cursor now always goes through the Frame where
we can reset the blink cycle appropriately.

This makes cursor movement look a lot more natural. :^)
2021-02-09 21:25:38 +01:00
Andreas Kling
2c4829cb14 LibWeb: Remove duplicated locals in EventHandler::handle_mousedown() 2021-02-09 20:49:37 +01:00
AnotherTest
09a43969ba Everywhere: Replace dbgln<flag>(...) with dbgln_if(flag, ...)
Replacement made by `find Kernel Userland -name '*.h' -o -name '*.cpp' | sed -i -Ee 's/dbgln\b<(\w+)>\(/dbgln_if(\1, /g'`
2021-02-08 18:08:55 +01:00
Linus Groh
79bab28f5e LibWeb: Implement Element.getElementsBy{Tag,Class}Name()
Just like the Document variants, but using the given Element as
for_each_in_subtree_of_type() root.
2021-02-08 17:59:04 +01:00
Linus Groh
2a38f008bf LibWeb: Make getElementsByClassName() case-insensitive in quirks mode
From https://dom.spec.whatwg.org/#concept-getelementsbyclassname:

    The comparisons for the classes must be done in an ASCII case-
    insensitive manner if root’s node document’s mode is "quirks", and
    in an identical to manner otherwise.
2021-02-08 17:59:04 +01:00
Linus Groh
5a9094a70a LibWeb: Make getElementsByTagName() case-insensitive for HTML elements
From https://dom.spec.whatwg.org/#concept-getelementsbytagname:

    2. Otherwise, if root’s node document is an HTML document, return a
       HTMLCollection rooted at root, whose filter matches the following
       descendant elements:

       * Whose namespace is the HTML namespace and whose qualified name
         is qualifiedName, in ASCII lowercase.

       * Whose namespace is not the HTML namespace and whose qualified
         name is qualifiedName.
2021-02-08 17:59:04 +01:00
Andreas Kling
0eac44af49 LibWeb: Don't assert on <colgroup> & friends
Let's just construct a placeholder BlockBox layout node for now.

Fixes #5081.
2021-02-07 11:47:33 +01:00
Andreas Kling
796c31a52b LibWeb: Reorganize Element::create_layout_node() into a switch
This allows us to see which CSS::Display types are not yet handled.
2021-02-07 11:40:42 +01:00
Andreas Kling
e6712fcd82 LibWeb: Use any_of() for DOM::Element::has_class() 2021-02-07 11:35:26 +01:00
Andreas Kling
330c3fcb59 LibWeb: Use move semantics for QualifiedName more often 2021-02-07 11:20:15 +01:00
Andreas Kling
0c66e53544 LibWeb: Honor font sizes specified by CSS
Instead of trying to coerce them into some font size we think we might
have, let's just honor the request and do our best to find a font.
2021-02-07 10:57:07 +01:00
Andreas Kling
ce1c8e0bde LibWeb: Anonymous table cells should have colspan=1
Otherwise the column widths calculation algorithm will assert.

Fixes #5078.
2021-02-06 23:27:03 +01:00
Andreas Kling
a59b1825ce LibWeb: Basic implementation of global event handlers :^)
Document and HTMLElement now inherit from HTML::GlobalEventHandlers
which allows them to support "onfoo" event handler attributes.

These are assignable both via IDL attributes and content attributes.

Event listeners constructed this way get a special "attribute" flag
on them so we know which one to replace if you reassign them.
This also allows them to coexist with EventTarget.addEventListener().

This is all a bit sloppy, but it works decently for a first cut.
The Window object should also inherit GlobalEventHandlers, but since
we don't generate it from IDL, I haven't taken that step here.

Also this would be a lot nicer if we supported IDL mixins.
2021-02-03 23:03:05 +01:00
Andreas Kling
b43db4cc50 LibWeb: Add enumerator macro for all the "global event handlers" 2021-02-03 23:03:05 +01:00
Andreas Kling
14a6ec6fc9 LibWeb: Add a whole bunch of onfooevent names to HTML::AttributeNames 2021-02-03 23:03:05 +01:00
Andreas Kling
342b787d1c LibWeb: Move main thread JavaScript VM to its own file
Instead of being a weird little global function in DOM/Document.cpp,
you can now get the main thread JS VM via Bindings::main_thread_vm().
2021-02-03 10:45:39 +01:00
Andreas Kling
1ce03f4f34 LibIPC: Stop sending client ID to clients
The client ID is not useful to normal clients anymore, so stop telling
everyone what their ID is.
2021-02-01 11:32:00 +01:00
Linus Groh
521a38d9c5 LibWeb: Use URL::to_string_encoded() for the crash error page URL's href
Just wrapping to_string() in urlencode() will break the link as too many
characters are encoded. Also wrap in escape_html_entities() as well -
most relevant chars are already URL-encoded, but this will change '&' to
'&amp;', for example.
2021-01-31 19:05:55 +01:00
Andreas Kling
1b5be4a342 LibIPC: Stop exchanging client/server PIDs in greeting handshake
The PIDs were used for sharing shbufs between processes, but now that
we have migrated to file descriptor passing, we no longer need to know
the PID of the other side.
2021-01-31 09:29:27 +01:00
Andreas Kling
df2a4adcd2 Browser+LibWeb+WebContent: Make the "Debug" menu work in multi-process
This patch adds an IPC call for debugging requests. It's stringly typed
and very simple, and allows us to easily implement all the features in
the Browser's Debug menu.
2021-01-31 09:07:46 +01:00
Andreas Kling
74c8490acd LibWeb: Don't try to create GUI::TextBox inside multi-process web views
This is a workaround until we can implement a proper <input type=text>
in terms of LibWeb primitives.

This makes google.com not crash in multi-process mode (but there is no
search box.)
2021-01-30 23:16:41 +01:00
Linus Groh
e8aae033f1 LibWeb: URL-encode/escape variables used in OOPWV's crash error page
This fixes arbitrary HTML injections via the URL on OOPWV's crash error
page - probably not a security issue, but annoying nonetheless.
2021-01-30 22:49:34 +01:00
Andreas Kling
f3e85e43c7 LibWeb: Handle WebContent process crashes gracefully :^)
The OOPWV will now detect WebContent process crashes/disconnections and
simply create a new WebContent process in its place. We also generate a
little error page with a link to the crashing URL so you can reload and
try again.

This a huge step forward for OOPWV since it now has a feature that IPWV
can never replicate. :^)
2021-01-30 18:27:39 +01:00
Andreas Kling
9b0ca75f84 LibWeb: Add Frame::ViewportClient and use it for Layout::ImageBox
Image boxes want to know whether they are inside the visible viewport.
This is used to pause/resume animations, and to update the purgeable
memory volatility state.

Previously we would traverse the entire layout tree on every resize,
calling a helper on each ImageBox. Make those boxes register with the
frame they are interested in instead, saving us all that traversal.

This also makes it easier for other parts of the code to learn about
viewport changes in the future. :^)
2021-01-30 12:29:11 +01:00
Andreas Kling
7449c1b27f ImageDecoder+LibImageDecoder+LibWeb: Support animations in ImageDecoder
The ImageDecoder service now returns a list of image frames, each with
a duration value.

The code for in-process image decoding is removed from LibWeb, an all
image decode requests are sent out-of-process to ImageDecoder. :^)

This won't scale super well to very long and/or large animations, but
we can work on improving that separately. The main goal here is simply
to stop doing any image decoding inside LibWeb.

Fixes #5165.
2021-01-29 22:38:22 +01:00
Andreas Kling
0324144e2a LibWeb: Update the ICB's idea of the viewport rect after Frame resize
This makes animations start if they are uncovered by a resize.
2021-01-29 22:03:04 +01:00
Luke
3f5532d43e LibWeb: Flesh out prepare_script and execute_script
This fills in a bunch of the FIXMEs that was in prepare_script.

execute_script is almost finished, it's just missing the module side.

As an aside, let's not assert when inserting a script element with
innerHTML.
2021-01-29 08:49:50 +01:00
Luke
449c6c5604 LibWeb: Add simple implementation of Document.createElementNS 2021-01-28 22:18:46 +01:00
Andreas Kling
a0bcfa30bf LibWeb: Add simple implementation of Node.removeChild() 2021-01-28 08:58:22 +01:00
Andreas Kling
5a58f42e3c LibWeb: Remove accidentally committed changes from b72f067f0d 2021-01-28 08:57:12 +01:00
Andreas Kling
b72f067f0d Kernel+Userland: Remove unused "effective priority" from threads
This has been merged with the regular Thread::priority field after
the recent changes to the scheduler.
2021-01-28 08:25:53 +01:00
asynts
eea72b9b5c Everywhere: Hook up remaining debug macros to Debug.h. 2021-01-25 09:47:36 +01:00
asynts
8465683dcf Everywhere: Debug macros instead of constexpr.
This was done with the following script:

    find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/dbgln<debug_([a-z_]+)>/dbgln<\U\1_DEBUG>/' {} \;

    find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/if constexpr \(debug_([a-z0-9_]+)/if constexpr \(\U\1_DEBUG/' {} \;
2021-01-25 09:47:36 +01:00
asynts
bb483f7ef4 Everywhere: Name debug macros more consistently.
Personally, I prefer the naming convention DEBUG_FOO over FOO_DEBUG, but
the majority of the debug macros are already named in the latter naming
convention, so I just enforce consistency here.

This was done with the following script:

    find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/DEBUG_PATH/PATH_DEBUG/' {} \;
2021-01-25 09:47:36 +01:00
asynts
acdcf59a33 Everywhere: Remove unnecessary debug comments.
It would be tempting to uncomment these statements, but that won't work
with the new changes.

This was done with the following commands:

    find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec awk -i inplace '$0 !~ /\/\/#define/ { if (!toggle) { print; } else { toggle = !toggle } } ; $0 ~/\/\/#define/ { toggle = 1 }' {} \;

    find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec awk -i inplace '$0 !~ /\/\/ #define/ { if (!toggle) { print; } else { toggle = !toggle } } ; $0 ~/\/\/ #define/ { toggle = 1 }' {} \;
2021-01-25 09:47:36 +01:00
asynts
1a3a0836c0 Everywhere: Use CMake to generate AK/Debug.h.
This was done with the help of several scripts, I dump them here to
easily find them later:

    awk '/#ifdef/ { print "#cmakedefine01 "$2 }' AK/Debug.h.in

    for debug_macro in $(awk '/#ifdef/ { print $2 }' AK/Debug.h.in)
    do
        find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/#ifdef '$debug_macro'/#if '$debug_macro'/' {} \;
    done

    # Remember to remove WRAPPER_GERNERATOR_DEBUG from the list.
    awk '/#cmake/ { print "set("$2" ON)" }' AK/Debug.h.in
2021-01-25 09:47:36 +01:00
Andreas Kling
ae0be7797f LibWeb: Disable resource cache for file:// URLs
This makes the browser a bit less annoying when testing local files,
since you no longer have to restart it for changes to take effect.

Longer-term we should have a proper way to decide which resources
are cacheable.
2021-01-24 12:11:08 +01:00
Luke
397f432aed LibWeb: Add XHREventTarget and ProgressEvent constructors to Window 2021-01-23 22:29:21 +01:00
Luke
0a1226344a LibWeb: Add XHREventTarget and have XHR inherit from it 2021-01-23 22:29:21 +01:00
Luke
4f2e154dbe LibWeb: Flesh out existing XHR methods a bit more
This makes open, send and setRequestHeader a bit more spec compliant and
adds a bunch of FIXMEs for unimplemented parts.
2021-01-23 22:29:21 +01:00
Andreas Kling
c68148efc5 LibWeb: Remove Range constructor/prototype caches from WindowObject
These are constructed on the code generator path now instead.
2021-01-23 19:02:02 +01:00
Andreas Kling
cfa2fb2eb3 LibWeb: Generate JS bindings for Range from IDL :^) 2021-01-23 17:59:42 +01:00
Andreas Kling
cf836e6bff LibWeb: Make WrapperGenerator consider "unsigned" part of a type 2021-01-23 17:59:42 +01:00
Andreas Kling
8363b3ae99 LibWeb: Generate JS bindings for XMLHttpRequest from IDL :^)
Remove the hand-written XHR bindings in favor of generated ones.
2021-01-23 15:06:09 +01:00
Andreas Kling
25056830f0 LibWeb: Add very basic support for IDL constants
You can now put constants on an IDL interface and they will pop up on
both the constructor and prototype objects.
2021-01-23 13:20:24 +01:00
Andreas Kling
5b91362d4e LibWeb: Move XMLHttpRequest to separate XHR directory
In keeping with the one-directory-per-web-spec layout, let's move XHR
into its own clubhouse.
2021-01-23 11:51:36 +01:00
Emanuele Torre
68c8b52612 Build: Use cmake's make_directory utility instead of env(1) and mkdir(1)
..in CMake files.

Also, the `-S`s were unnecessary here since "mkdir" doesn't have any
spaces and these are not shebangs.
2021-01-22 22:14:42 +01:00
asynts
ea7b7d8ceb Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-22 22:14:30 +01:00
asynts
3f23a58fa1 Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-22 22:14:30 +01:00
asynts
7d783d8b84 Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-22 22:14:30 +01:00
Ben Wiederhake
67cda61b7f Libraries: Add missing headers
A C++ source file containing just
    #include <LibFoo/Bar.h>
should always compile cleanly.

This patch adds missing header inclusions that could have caused weird error
messages if they were used in a different context. Also, this confused QtCreator.
2021-01-22 21:49:54 +01:00
Jonathan Turner
0bf5669ba3
Meta: Get building on NixOS (#5005) 2021-01-22 17:44:05 +01:00
Nico Weber
5f9c42c404 LibGfx: Give Bitmap a scale factor
Gfx::Bitmap can now store its scale factor. Normally it's 1, but
in high dpi mode it can be 2.

If a Bitmap with a scale factor of 2 is blitted to a Painter with
scale factor of 2, the pixels can be copied over without any resampling.
(When blitting a Bitmap with a scale factor of 1 to a Painter with scale
factor of 2, the Bitmap is painted at twice its width and height at
paint time. Blitting a Bitmap with a scale factor of 2 to a Painter with
scale factor 1 is not supported.)

A Bitmap with scale factor of 2 reports the same width() and height() as
one with scale factor 1. That's important because many places in the
codebase use a bitmap's width() and height() to layout Widgets, and all
widget coordinates are in logical coordinates as well, per
Documentation/HighDPI.md.

Bitmap grows physical_width() / physical_height() to access the actual
pixel size. Update a few callers that work with pixels to call this
instead.

Make Painter's constructor take its scale factor from the target bitmap
that's passed in, and update its various blit() methods to handle
blitting a 2x bitmap to a 2x painter. This allows removing some gnarly
code in Compositor. (In return, put some new gnarly code in
LibGfxScaleDemo to preserve behavior there.)

No intended behavior change.
2021-01-20 10:28:27 +01:00
Andreas Kling
93831ef456 LibWeb: Very basic support for CSS flex-direction
The FFC now supports both vertical and horizontal flex layout, based on
the flex-direction property. It's still extremely naive, but at least
now you can be naive in two directions! :^)

This implementation of flexbox is going to take a lot of work, but at
least now we've gotten started.
2021-01-18 20:20:24 +01:00
Andreas Kling
3e8873b63e LibWeb: Add Layout::Box::margin_box_height() 2021-01-18 20:20:20 +01:00
Andreas Kling
149f10b0b9 LibWeb: Parse the CSS "flex-direction" property 2021-01-18 20:20:16 +01:00
Andreas Kling
fd7920fa8f LibWeb: Add a very naive Layout::FlexFormattingContext :^)
This is very dumb and only lays out its child boxes on a horizontal
line with their shrink-to-fit widths.

You have to start somewhere! :^)
2021-01-18 20:20:13 +01:00
Andreas Kling
d18bc9ccd2 LibWeb: Add Layout::Box::margin_box_width() 2021-01-18 20:20:07 +01:00
Andreas Kling
140463e833 LibWeb: Parse "display: flex" and create BlockBox layout nodes for them
I'm not 100% sure that BlockBox is the right layout node for flex
containers, but it's the most obviously fitting one we already have.
2021-01-18 20:20:00 +01:00
Andreas Kling
9e45594dc8 LibWeb: Stub out the PerformanceTiming object from Navigation Timing
Just have all the timing functions return 0 for now.

We can now run the Shynet JS on https://linus.dev/ although the XHR
is rejected by our same-origin policy.
2021-01-18 15:11:20 +01:00
Andreas Kling
c99e35485a LibWeb: Add support for XMLHttpRequest request headers
Implement XMLHttpRequest.setRequestHeader() and include the headers in
the outgoing HTTP request.
2021-01-18 14:02:58 +01:00
Andreas Kling
0639e77898 LibWeb: Make the Window object "inherit" from EventTarget :^)
Since Web::Bindings::WindowObject inherits from JS::GlobalObject, it
cannot also inherit from Web::Bindings::EventTargetWrapper.

However, that's not actually necessary. Instead, we simply set the
Window object's prototype to the EventTargetPrototype, and add a little
extra branch in the impl_from() function that turns the JS "this" value
into a DOM::EventTarget*.

With this, you can now call window.addEventListener()! Very cool :^)

Fixes #4758.
2021-01-18 12:18:29 +01:00
Andreas Kling
fd83918476 LibWeb: Move IDL attributes and functions to the prototype
Instead of each IDL interface wrapper having its own set of all the
attributes and functions, they are moved to the prototype. This matches
what we already do in LibJS.

Also, this should be spec compliant with the web as well, though there
may be *some* content out there that expects some things to be directly
on the wrapper since that's how things used to work in major browsers
a long time ago. But let's just not worry about that for now.

More work towards #4789
2021-01-18 12:18:29 +01:00
Andreas Kling
630cbc947a LibWeb: Construct the IDL interface prototype chains automatically
Have each IDL prototype trigger the construction of its own prototype.
2021-01-18 12:18:29 +01:00
Andreas Kling
ee7fa49b88 LibWeb: Actually instantiate all the web constructors/prototypes
We now instantiate all the generated web API constructors and expose
them on the window object. We also set the generated prototypes on
instantiated wrappers.

Also, we should obviously find a way to generate this code. :^)
2021-01-18 12:18:29 +01:00
Andreas Kling
252a98042d LibWeb: Generate constructor and prototype classes for IDL interfaces
This patch adds a FooPrototype and FooConstructor class for each IDL
interface we generate JS bindings for.

These classes are very primitive and don't do everything they should
yet, but we have to start somewhere. :^)

Work towards #4789
2021-01-18 12:18:29 +01:00
Andreas Kling
0db6835e73 LibWeb: Move HTML::SubmitEvent functions out of line 2021-01-18 12:18:29 +01:00
Andreas Kling
fd441b954d LibWeb: Add fast_is<T>() for some DOM and layout node subclasses
The generic is<T>() uses dynamic_cast which is fine in the majority
of cases, but when one of them shows up in profiles, we can make it
faster by answering the is-a question manually.
2021-01-17 14:42:50 +01:00
Andreas Kling
1cb44ec5ee Everywhere: Remove more <AK/SharedBuffer.h> includes 2021-01-17 00:04:42 +01:00
Andreas Kling
b5d98c0945 LibWeb+WebContent: Use anonymous files for OOPWV backing stores
To support this, the GUI process and the WebContent service will now
coordinate their backing store bitmaps. Each backing store can be
referred to by a serial ID, and we don't need to keep resending it
as a file descriptor.

We should probably do something similar in WindowServer. :^)
2021-01-16 23:21:52 +01:00
Andreas Kling
04f95f9160 WindowServer+LibGUI: Pass the system theme using Core::AnonymousBuffer
This was the last remaining user of shbufs in WindowServer, and so
WindowServer no longer pledges "shared_buffer" :^)
2021-01-16 17:20:53 +01:00
asynts
adbb8d62d1 Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-16 11:54:35 +01:00
Andreas Kling
64610ca80e Everywhere: Remove a bunch of <AK/SharedBuffer.h> includes 2021-01-16 11:26:53 +01:00
Andreas Kling
13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00