Commit Graph

9456 Commits

Author SHA1 Message Date
Andreas Kling
508edcd217 LibWeb: Add a "page showing" flag to documents
This will be used to determine whether "pageshow" and "pagehide" events
are appropriate. We won't actually make use of it until we implement
more of history traversal and document unloading.
2021-09-26 12:47:51 +02:00
Andreas Kling
a2f77a2e39 LibWeb: Implement "update the current document readiness" from spec
The only difference from what we were already doing is that setting the
same ready state twice no longer fires a "readystatechange" event.
I don't think that could happen in practice though.
2021-09-26 12:47:51 +02:00
Andreas Kling
8496024756 LibWeb: Store HTML document ready state as an enum 2021-09-26 12:47:51 +02:00
Andreas Kling
c4ccbc5b83 LibWeb: Make unhandled JS exception stand out more in debug log
Let's log "unhandled exception" messages in red text so that they stand
out better among lots of other debug logging.
2021-09-26 12:47:51 +02:00
Rodrigo Tobar
5ae384fc33 LibELF: Indicate value of unimplemented dtag
For flags that are not mapped to a string this message prints DT_??,
which isn't really useful.
2021-09-26 12:45:55 +02:00
Rodrigo Tobar
a67e06184b LibC+LibELF: Add definitions for extra dtags
These are found in some libraries, and LibELF doesn't know how to handle
them, not even their name. Adding these definitions should at least help
readelf display information correctly, but more work is needed to
actually implement them.
2021-09-26 12:45:55 +02:00
Rodrigo Tobar
3efd7b458a LibELF+readelf: Remove duplicated dtag->string map
A copy of the same mapping was found both in LibELF and in the readelf
utility, which uses LibELF; keeping them both is redundant and removing
the duplicate saves (a bit of) space.
2021-09-26 12:45:55 +02:00
Karol Kosek
1803c5966d ThemeEditor: Show currently opened theme path in the window title
You can open files since #9979, so let's show the path there
to distinguish open theme files more easily!
2021-09-26 12:44:51 +02:00
Andreas Kling
5ac82efbe1 LibWeb: Mark event listeners generated by event handler attributes
We have to mark the EventListener objects so that we can tell them apart
from listeners added via the addEventListener() API.

This makes element.onfoo getters actually return the handler function.
2021-09-26 02:53:57 +02:00
Andreas Kling
5f4a723e51 LibWeb: Implement more of "completely finish loading the document" 2021-09-26 02:25:02 +02:00
Andreas Kling
bfec16ce46 LibWeb: Remove nonsensical assignment in script-became-ready callback
We don't need to set m_script_ready in the callback that gets invoked
precisely because m_script_ready has been set. :^)
2021-09-26 02:05:54 +02:00
Andreas Kling
65e0f8184d LibWeb: Make parser <script> elements delay the document load event 2021-09-26 02:05:49 +02:00
Andreas Kling
fc2a255c72 LibWeb: Make <link> style sheets delay the document load event 2021-09-26 02:00:24 +02:00
Andreas Kling
dbba0a520f LibWeb: Allow HTML parser to delay delivery of the document "load" event
We will now spin in "the end" until there are no more "things delaying
the load event". Of course, nothing actually uses this yet, and there
are a lot of things that need to.
2021-09-26 02:00:00 +02:00
Andreas Kling
b1529e3202 LibWeb: Remove some unused includes and a member in HTMLScriptElement 2021-09-26 01:03:17 +02:00
Andreas Kling
e7af6af626 LibWeb: Implement more of HTMLParser::the_end() and bring closer to spec 2021-09-26 00:52:19 +02:00
Andreas Kling
c772134e25 LibWeb: Make update_style() a no-op if there's no browsing context
Style is needed to lay out and paint a document, but we can't do either
those when the document isn't attached to a browsing context.
2021-09-26 00:48:30 +02:00
Andreas Kling
e452550fda LibWeb: Split out "The end" from the HTML parsing spec to a function
Also add a spec link and some comments.
2021-09-26 00:04:33 +02:00
Andreas Kling
f67648f872 LibWeb: Rename HTMLDocumentParser => HTMLParser 2021-09-25 23:36:43 +02:00
Andreas Kling
0ee457dfdf LibWeb: Provide a default DOM::EventTarget::dispatch_event()
All EventTarget subclasses except Window do the same exact thing in
their overrides, so let's just share an implementation in the base.
2021-09-25 23:36:43 +02:00
Karol Kosek
5a5f6d11ef PixelPaint: Close image tabs on middle click 2021-09-25 23:34:02 +02:00
Karol Kosek
df195188bc PixelPaint: Close New Image dialog after pressing return key
13e526de43 added the feature to new Layer
dialog. This patch adds it to Image dialog to stay consistent across
the app. :^)
2021-09-25 23:34:02 +02:00
Andreas Kling
926a49cd81 LibWeb: Use Core::EventLoop::spin_until() for the ad-hoc loop spinning
The ideal solution here is to implement a more spec-compliant event
loop, but while we get all the pieces in place for that, this at least
makes the HTML event loop a bit more responsive since it never has to
wait for a 16ms timer to fire.
2021-09-25 19:34:21 +02:00
Andreas Kling
f2b9ec9f8a LibCore: Add Core::EventLoop::spin_until(Function<bool()>)
This function spins the event loop until a goal condition is met.
2021-09-25 19:32:14 +02:00
Andreas Kling
2c0987c93b LibWeb: Move window.scroll{X,Y} from wrapper into DOM::Window
The less we do in WindowObject, the easier it will be to eventually
auto-generate the entire thing.
2021-09-25 18:47:19 +02:00
Linus Groh
38157a6093 LibJS: Move has_constructor() from NativeFunction to FunctionObject
At a later point this will indicate whether some FunctionObject "has a
[[Construct]] internal method" (separate from the current FunctionObject
call() / construct()), to help with a more spec-compliant implementation
of [[Call]] and [[Construct]].
This means that it is no longer relevant to just NativeFunction.
2021-09-25 17:51:30 +02:00
Linus Groh
e14f420a44 LibJS: Add const Value::as_function() 2021-09-25 17:51:30 +02:00
Linus Groh
2dba048146 LibJS: Remove unused FunctionObject::environment()
ECMAScriptFunctionObject::environment() can just be non-virtual.
2021-09-25 17:51:30 +02:00
Linus Groh
9043041dd3 LibJS: Move [[BoundThis]] and [[BoundArguments]] to BoundFunction 2021-09-25 17:51:30 +02:00
Linus Groh
4566472ed6 LibJS: Rename BoundFunction::m_target_function to match spec name 2021-09-25 17:51:30 +02:00
Linus Groh
a08292d76c LibJS: Move has_simple_parameter_list to ECMAScriptFunctionObject 2021-09-25 17:51:30 +02:00
Linus Groh
76eb8fe717 LibJS: Move [[Fields]] to ECMAScriptFunctionObject 2021-09-25 17:51:30 +02:00
Linus Groh
136451c3af LibJS: Move [[HomeObject]] to ECMAScriptFunctionObject 2021-09-25 17:51:30 +02:00
Linus Groh
06726d41ac LibJS: Move [[ConstructorKind]] to ECMAScriptFunctionObject 2021-09-25 17:51:30 +02:00
Linus Groh
1e97a85095 LibJS: Move [[ThisMode]] to ECMAScriptFunctionObject 2021-09-25 17:51:30 +02:00
Linus Groh
ce946dd656 LibJS: Add ECMAScriptFunctionObject forward declaration 2021-09-25 17:51:30 +02:00
Linus Groh
d5f90cf187 LibJS: Rename ECMAScriptFunctionObject members to match spec names
Also add the internal slot names as comments, and separate them into
groups of spec and non-spec members.
This will make it easier to compare the implementation code with the
spec, as well as identify internal slots currently missing or only
present on FunctionObject.
2021-09-25 17:51:30 +02:00
Linus Groh
e37cf73300 LibJS: Rename OrdinaryFunctionObject to ECMAScriptFunctionObject
The old name is the result of the perhaps somewhat confusingly named
abstract operation OrdinaryFunctionCreate(), which creates an "ordinary
object" (https://tc39.es/ecma262/#ordinary-object) in contrast to an
"exotic object" (https://tc39.es/ecma262/#exotic-object).

However, the term "Ordinary Function" is not used anywhere in the spec,
instead the created object is referred to as an "ECMAScript Function
Object" (https://tc39.es/ecma262/#sec-ecmascript-function-objects), so
let's call it that.

The "ordinary" vs. "exotic" distinction is important because there are
also "Built-in Function Objects", which can be either implemented as
ordinary ECMAScript function objects, or as exotic objects (our
NativeFunction).

More work needs to be done to move a lot of infrastructure to
ECMAScriptFunctionObject in order to make FunctionObject nothing more
than an interface for objects that implement [[Call]] and optionally
[[Construct]].
2021-09-25 17:51:30 +02:00
Mandar Kulkarni
d787775806 LibWeb: Skip decoding favicon.ico if downloaded data is empty
Some sites don't have favicon.ico, so we may get 404 response.
In such cases, ResourceLoader still calls success_callback.
For favicon loading, we are not checking response headers or payload
size.
This will ultimately fail in Gfx::ImageDecoder::try_create().

So avoid unnecessary work by returning early, if data is empty.
2021-09-24 19:29:04 +02:00
Andreas Kling
73fe6c541a LibGfx: Forward declare Gfx::FontMetrics as a struct 2021-09-24 19:03:46 +02:00
Andreas Kling
71f371f6b1 LibWeb: Ignore font-size: calc(...) for now
This doesn't work correctly in the new world where fonts are resolved
during the CSS cascade. Let's patch it out with a FIXME and get back to
it once everything has fallen into place.
2021-09-24 15:49:04 +02:00
Andreas Kling
f8dd3e14ba LibWeb: Rename CSS::StyleResolver => StyleComputer
Resolved style is a spec concept that refers to the weird mix of
computed style and used style reflected by getComputedStyle().

The purpose of this class is to produce the *computed* style for a given
element, so let's call it StyleComputer.
2021-09-24 15:12:15 +02:00
Andreas Kling
3dc6f0bc47 LibWeb: Absolutize internal lengths in all StyleValues
StyleValue now has a virtual visit_lengths() that allows us to update
all CSS lengths during the absolutization phase.
2021-09-24 15:12:15 +02:00
Andreas Kling
785ace4fc2 LibWeb: Remove on-demand font resolution
Fonts are now resolved as part of the CSS cascade.
2021-09-24 15:12:15 +02:00
Andreas Kling
1ca33598da LibWeb: Give DOM::Document some default style properties
Add StyleResolver::create_document_style() to help in creating an
"empty" style with nothing but default values.
2021-09-24 15:01:49 +02:00
Andreas Kling
c5b4928f4a LibWeb: Make ListItemMarkerBox inherit style from ListItemBox 2021-09-24 15:01:49 +02:00
Andreas Kling
ca28a118ae LibWeb: Add tightly-typed DOM node accessors for Layout::ListItemBox
ListItemBox is always constructed with a non-null DOM::Element, so we
can make dom_node() return a DOM::Element&.
2021-09-24 15:01:49 +02:00
Andreas Kling
5a7d3e3cc1 LibWeb: Let <br> elements have style
At the very least, we need to respect `<br style="display: none">`
2021-09-24 15:01:49 +02:00
Andreas Kling
c113c092ee LibWeb: Make HTML::EventLoop::process() a no-op if there are no tasks 2021-09-24 15:01:49 +02:00
Andreas Kling
23a08fd35a LibWeb: Start absolutizing lengths after performing the CSS cascade
Once we've performed the cascade on a set of values for an element,
we should have enough information to resolve/absolutize some lengths.

Basically, any CSS length that isn't "auto" or a percentage can be
turned into an absolute length (in pixels) as long as we have the
following information:

- The viewport rect
- The parent element's font
- The document element's font
- The element's own font

To ensure that we can absolutize lengths relative to the element's own
font, we now do a separate first pass where font-related properties are
defaulted (in the cascade spec sense of the word) and become usable.

There's a lot more work to do here, but this should open up a lot of
simplification in layout code, since it will no longer need to care
about relative lengths. Layout still needs to resolve percentages, since
we can't do that for some properties until the containing block
dimensions are known.
2021-09-24 15:01:49 +02:00