Commit Graph

11605 Commits

Author SHA1 Message Date
Andreas Kling
d1fdc1a2cf LibWeb: Use [Reflect] for Element.id and Element.className :^) 2020-07-24 13:25:42 +02:00
Andreas Kling
8f31331e68 LibWeb: Allow specifying a custom attribute name for [Reflect]
Sometimes the IDL attribute and the DOM attribute don't have the same
exact name. In those cases, we can now do this:

    [Reflect=foobar] attribute DOMString fooBar;
2020-07-24 13:23:47 +02:00
Andreas Kling
cb35a8ea83 LibWeb: Add HTMLElement.lang (and make HTMLElement.title reflecting) 2020-07-24 13:16:11 +02:00
Andreas Kling
ea451cea6a LibWeb: Add HTMLImageElement.src and HTMLImageElement.alt
These are reflecting attributes! :^)
2020-07-24 13:12:14 +02:00
Andreas Kling
3eff6024b1 LibWeb: Add code generation for reflecting IDL attributes
You can now tag reflecting attributes with [Reflect] to generate code
that does basic DOM element attribute get/set.

(This patch also makes it easy to add more extended attributes like
that going forward.)

From the HTML spec:

"Some IDL attributes are defined to reflect a particular content
attribute. This means that on getting, the IDL attribute returns
the current value of the content attribute, and on setting,
the IDL attribute changes the value of the content attribute
to the given value."
2020-07-24 13:06:02 +02:00
Andreas Kling
dc4327c54b Build: Remove two unnecessary CXXFLAGS
Seems like we can build without these two flags now:

    -Wno-sized-deallocation
    -fno-sized-deallocation

I don't remember why they were needed in the first place.
2020-07-24 02:57:11 +02:00
Andreas Kling
cd4bc81dbb AK: Add a couple more helper templates to StdLibExtras 2020-07-24 02:38:17 +02:00
Andreas Kling
a655cf5b41 LibGUI: Break up Window::event() into many smaller functions
This function was unbearably huge. Handle each event type in its own
function instead so you can see what's going on.
2020-07-24 01:03:24 +02:00
Nico Weber
3f45e9ab1e Lagom: Add LibGemini, LibGfx
They are dependencies of LibWeb and might be useful for
running test-web on GitHub actions one day.
2020-07-23 23:02:28 +02:00
Nico Weber
c4d9d5cc54 Browser: Escape JS source operators for HTML display in console
Console inputs to try before and after this patch:
- `0xffff & 0xff`
- `"a & b"`
- `"<div>"`
- `a &` (to see the escaping in the error hint)
2020-07-23 23:01:16 +02:00
Andreas Kling
65ec655b0d PixelPaint: Add GUI for editing layer names :^) 2020-07-23 20:48:28 +02:00
Andreas Kling
955d3c22c7 PixelPaint: Tidy up the LayerPropertiesWidget GUI layout a bit :^) 2020-07-23 20:43:52 +02:00
Andreas Kling
3a4351b2b5 PixelPaint: Don't hit test non-visible layers 2020-07-23 20:36:07 +02:00
Andreas Kling
b560445c84 PixelPaint: Add a GUI for editing opacity and visibility of layers
Also, make the layer stack rendering respect opacity and visibility.
2020-07-23 20:33:38 +02:00
Andreas Kling
d7be3faab5 LibGfx: Add an "opacity" argument to Painter::draw_scaled_bitmap()
This API is not super perfect as it merely overrides the source alpha
on all source pixels instead of blending the alpha values. There is
room for improvement here for sure.
2020-07-23 20:32:39 +02:00
Andreas Kling
0a95f8d346 LibGUI: Add {Horizontal,Vertical}Slider to the forwarding header 2020-07-23 19:59:38 +02:00
Andreas Kling
7973f76790 PixelPaint: Scope tool actions to the containing window
We achieve this by deferring the construction of the tool buttons until
the toolbox widget has been added to a window.
2020-07-23 19:53:48 +02:00
Andreas Kling
4392413cd1 LibGUI: Make window-parented actions actually scoped to the window
We were relying on Core::is<Window>() to tell us whether the parent
of an action is a window. This didn't work since we only saw a forward
declaration of GUI::Window in Action.cpp.

This is an unfortunate flaw in the is<T> pattern and we should solve
it somehow but not in this patch.
2020-07-23 19:52:18 +02:00
Andreas Kling
3cb50a4714 LibWeb: Rename Element::tag_name() => local_name()
To prepare for fully qualified tag names, let's call this local_name.
Note that we still keep an Element::tag_name() around since that's what
the JS bindings end up calling into for the Element.tagName property.
2020-07-23 18:18:13 +02:00
Andreas Kling
9d4cd565e3 LibGUI: Fix build after renaming Image => ImageWidget 2020-07-23 17:43:44 +02:00
Andreas Kling
6e02ef19d1 LibWeb: Add a helper for creating a fake (start tag) HTML token
Sometimes the parsing rules say we need to insert a fake HTML token.
Let's have a convenient way of doing that!
2020-07-23 17:31:08 +02:00
Andreas Kling
aaf6014ae1 LibJS: Simplify Cell::initialize()
Remove the Interpreter& argument and pass only GlobalObject&. We can
find everything we need via the global object anyway.
2020-07-23 17:31:08 +02:00
Andreas Kling
299824de73 LibGUI: Rename GUI::Image => GUI::ImageWidget
"Image" was a bit too vague, "ImageWidget" is obviously a widget of
some sort.
2020-07-23 17:31:08 +02:00
Nico Weber
a92f7aea7a LibWeb: Add tests for atob() and btoa() 2020-07-23 15:18:25 +02:00
Luke
60599d03dd LibWeb+test-web: Create test-web program, add doctype test
LibWeb currently has no test suite or program. Let's change that :^)

test-web is mostly a copy of test-js, but modified for LibWeb.
test-web imports both LibJS/Tests/test-common.js and
LibWeb/Test/test-common.js

LibWeb's suite provides the ability to specify the page to load,
what to do before the page is loaded, and what to do after it's
loaded.

This also provides a test of document.doctype and its close sibling
document.compatMode.

Currently, this isn't added to Lagom because of CodeGenerators.
2020-07-23 13:11:41 +02:00
Sasan Hezarkhani
a2bbacbfc8 TextEditor: Jump to word break when deleting and holding Ctrl modifier 2020-07-23 13:08:55 +02:00
Nico Weber
107db38a51 Browser: Focus input text field in JS console by default 2020-07-23 13:07:30 +02:00
Nico Weber
79a5ba58a5 LibJS: Add tests for bitwise & and ^
And fix some edge case conversion bugs found by the tests.
2020-07-23 13:06:49 +02:00
Brian Gianforcaro
bbc7e8429b LibC: Remove duplicate gs touch during gettid()/getpid() fast path
While profiling I noticed that gettid() was hitting gs register
twice, once for the initial fetch of s_cache_tid out of TLS for
the initialization check, and then again when we return the actual
value.

Optimize the implementation to cache the value so we avoid the
double fetch during the 99% case where it's already set. With
this change gettid() goes from being the 3rd most sampled function
in test-js, to pretty much disappearing into  ~20th place.

Additionally add the same optimization to getpid().
2020-07-23 12:28:11 +02:00
Nico Weber
b9ce56aee6 LibWeb: Make btoa() and atob() correctly handle values between 128 and 255
btoa() takes a byte string, so it must decode the UTF-8 argument into
a Vector<u8> before calling encode_base64.

Likewise, in atob() decode_base64 returns a byte string, so that needs
to be converted to UTF-8.

With this, `btoa(String.fromCharCode(255))` is '/w==' as it should
be, and `atob(btoa(String.fromCharCode(255))) == String.fromCharCode(255)`
remains true.
2020-07-22 19:22:00 +02:00
Nico Weber
5ba8aba197 AK: Make encode_base64 take a ByteBuffer and return a String
That makes the interface symmetric with decode_base64 and it's
what all current callers want (except for one, which is buggy).
2020-07-22 19:22:00 +02:00
Nico Weber
9e32ad6c99 LibJS: Fix \x escapes of bytes with high bit set
With this, typing `"\xff"` into Browser's console no longer
makes the app crash.

While here, also make the \u handler call append_codepoint()
instead of calling an overload where it's not immediately clear
which overload is getting called. This has no behavior change.
2020-07-22 19:21:35 +02:00
Nico Weber
01522b8d71 LibTextCodec: Simplify Latin1Decoder::to_utf8
No intended behavior change.
2020-07-22 19:16:00 +02:00
AnotherTest
c9c7069f9e LibGUI: Remove unnecessary LibHTTP #include
This closes #2848.
2020-07-22 17:48:11 +02:00
Nico Weber
248b79d687 LibJS: Add FIXMEs to a few functions that need UTF-16 handling 2020-07-22 17:26:34 +02:00
Nico Weber
979e02c0a8 LibJS: Implement String.prototype.charCodeAt
It's broken for strings with characters outside 7-bit ASCII, but
it's broken in the same way as several existing functions (e.g.
charAt()), so that's probably ok for now.
2020-07-22 15:48:01 +02:00
Andreas Kling
7230b7aad7 LibWeb: Replaced elements had backwards application of intrinsic ratio
If we know the width, but not the height, we have to *divide* with the
intrinsic ratio to get the height (not multiply.) :^)

This makes things like <img width=300 src=image.png> work right.
2020-07-22 01:47:36 +02:00
Andreas Kling
f43590f534 LibWeb: Set the intrinsic width/height of <img> instead of hacking it
Images were added before replaced element layout knew about intrinsic
sizes, so this was a bit backwards. We now instead transfer the known
intrinsic sizes from the ImageLoader to the LayoutImage.
2020-07-22 01:39:51 +02:00
Andreas Kling
a3feb46ad7 LibWeb: Parse "width" and "height" presentation attributes on <img>
These are HTML lengths that map to CSS width and height respectively.
2020-07-22 01:16:27 +02:00
Andreas Kling
5a7e57457e LibWeb: Add a dedicated function for parsing HTML length values
Presentation attribute lengths (width, height, etc.) can always be
unit-less (e.g "400") so going via the normal CSS parsing path only
works when the document is in quirks mode.

Add a separate parse_html_length() that always allows unit-less values.
2020-07-22 01:13:18 +02:00
Andreas Kling
9fc00d5d12 UserspaceEmulator: XLAT BX should not check full EBX shadow bits
Thanks to Rick van Schijndel for pointing this out. :^)
2020-07-22 00:07:15 +02:00
Luke
201cc1bfcc LibWeb: Assert we're parsing a fragment on fragment cases
The specification says that parts labelled as a "fragment case" will
only occur when parsing a fragment. It says that if it occurs when
not parsing a fragment, then it is a specification error.

We should probably assume at this point that it's an implementation
error. This fixes a few little mistakes that were caught out by this.

Also moves the context element outside insertion mode reset,
as other (unimplemented) parts refer to it, such as
"adjusted current node".

Also cleans up insertion mode reset.
2020-07-22 00:02:40 +02:00
Andreas Kling
9c155c8f35 UserspaceEmulator: Tweak some output strings 2020-07-21 23:35:09 +02:00
Andreas Kling
223b96c820 LibC: Make sure malloc chunks are 8-byte aligned
I noticed this while doing some instruction-level debugging. :^)
2020-07-21 22:48:17 +02:00
Andreas Kling
a819c35904 UserspaceEmulator: Include flag taint state in dump output 2020-07-21 19:21:52 +02:00
Andreas Kling
abebec0e04 UserspaceEmulator: Use the base address of instructions in backtraces
Instead of using SoftCPU::eip() which points at the *next* instruction
most of the time, stash away a "base EIP" so we can use it when making
backtraces. This makes the correct line number show up! :^)
2020-07-21 19:08:01 +02:00
Andreas Kling
5c29f4e326 UserspaceEmulator: Add a newline before uninitialized op warnings 2020-07-21 19:08:01 +02:00
Andreas Kling
0f91dfa139 UserspaceEmulator: Show file and line numbers in backtraces :^)
This was super easy thanks to the awesome LibDebug work by @itamar8910!
2020-07-21 19:08:01 +02:00
Andreas Kling
d1dd5013ea UserspaceEmulator: Remove unnecessary local getpid() caches
Now that LibC caches this for us, we can stop worrying.
2020-07-21 19:08:01 +02:00
Andreas Kling
b820e4626c LibC: Add a cache for getpid()
This works the same as gettid(). No sense in making a syscall to the
kernel every time you ask for the PID since it won't change.
Just like gettid(), the cache is invalidated on fork().
2020-07-21 19:08:01 +02:00