summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
AgeCommit message (Collapse)Author
2022-02-21LibWeb: Support CSSStyleDeclaration.cssFloatAndreas Kling
Unlike all the other CSS properties, 'float' is special, and can only be accessed via 'cssFloat' on CSSStyleDeclaration. So this patch adds support for that. 1 point on ACID3! :^)
2022-02-21LibWeb: Implement Node.removeChild() in terms of "pre-remove"Andreas Kling
This is what the spec wants us to do.
2022-02-21LibWeb: Make document.write() work while document is parsingAndreas Kling
This necessitated making HTMLParser ref-counted, and having it register itself with Document when created. That makes it possible for scripts to add new input at the current parser insertion point. There is now a reference cycle between Document and HTMLParser. This cycle is explicitly broken by calling Document::detach_parser() at the end of HTMLParser::run(). This is a huge progression on ACID3, from 31% to 49%! :^)
2022-02-21LibWeb: Use correct coordinate space when measuring space between floatsAndreas Kling
When calculating how much space is available for inline content between left and right floated elements, we have to use coordinates in the containing block's coordinate space, since that's what floats use. This fixes an issue where text would sometimes overlap floats.
2022-02-21LibWeb: Calculate edge of containing block correctly when floating rightAndreas Kling
2022-02-21LibWeb: Don't shift right-floated boxes too much to the leftAndreas Kling
We were subtracting the content width of right-floated boxes from their X position for no reason. Removing this makes floats snuggle up to each other on the right side. :^)
2022-02-21LibWeb: Fix floating boxes getting stacked on top of each otherAndreas Kling
This was caused by the freestanding margin_box_rect() using 0 for the content height instead of the actual content height.
2022-02-21LibWeb: Compute table cell height after doing its inside layoutAndreas Kling
2022-02-21LibWeb: Rename FormattingState::ensure() -> get_mutable()Andreas Kling
This makes it much more obvious what the difference between get() and get_mutable() is.
2022-02-21LibWeb: Add hack to avoid crashing on !child_display.is_flow_inside()Andreas Kling
When encountering a box that claims to have block-level children, but its CSS display type isn't actually "flow" inside, we would previously crash due to a VERIFY() failure. However, many sites choke on this due to freestanding table-related boxes like those created by "table-row" and "table-row-group". We're supposed to fix those up by wrapping them in a full set of table boxes during layout tree construction, but that algorithm obviously isn't working correctly in all cases. So let's work around the crashes for now, allowing many more sites to load (even if visually incorrect.) This is a rather monstrous hack, and we should get rid of it as soon as it's not needed anymore.
2022-02-21LibWeb: Respect font-size specified by CSS in "em" length calculationsAndreas Kling
"5em" means 5*font-size, but by forcing "em" to mean the presentation size of the bitmap font actually used, we broke a bunch of layouts that depended on a correct interpretation of "em". This means that "em" units will no longer be relative to the exact size of the bitmap font in use, but I think that's a compromise we'll have to make, since accurate layouts are more important. This yields a visual progression on both ACID2 and ACID3. :^)
2022-02-21LibWeb: Store overflow data in the FormattingStateAndreas Kling
2022-02-21LibWeb: Create list-item markers during layout tree constructionAndreas Kling
Previously, these were added during layout. This didn't fit into the new world where layout doesn't mutate the tree incrementally, so this patch adds logic to Layout::TreeBuilder for adding a marker to each list-item box after its children have been constructed.
2022-02-21LibWeb: Start making our layout system "transactional"Andreas Kling
This patch adds a map of Layout::Node to FormattingState::NodeState. Instead of updating layout nodes incrementally as layout progresses through the formatting contexts, all updates are now written to the corresponding NodeState instead. At the end of layout, FormattingState::commit() is called, which transfers all the values from the NodeState objects to the Node. This will soon allow us to perform completely non-destructive layouts which don't affect the tree. Note that there are many imperfections here, and still many places where we assign to the NodeState, but later read directly from the Node instead. I'm just committing at this stage to make subsequent diffs easier to understand.
2022-02-21LibWeb: Add Layout::FormattingStateAndreas Kling
The purpose of this new object will be to keep track of various states during an ongoing layout. Until now, we've been updating layout tree nodes as we go during layout, which adds an invisible layer of implicit serialization to the whole layout system. My idea with FormattingState is that running layout will produce a result entirely contained within the FormattingState object. At the end of layout, it can then be applied to the layout tree, or simply queried for some metrics we were trying to determine. When doing subtree layouts to determine intrinsic sizes, we will eventually be able to clone the current FormattingState, and run the subtree layout in isolation, opening up opportunities for parallelism. This first patch doesn't go very far though, it merely adds the object as a skeleton class, and makes sure the root BFC has one. :^)
2022-02-21LibWeb: Assign correct viewport dimensions when making style for ICBAndreas Kling
The ICB (initial containing block) gets its style from StyleComputer's create_document_style(). It's basically a generic style for the root of the layout tree. With this patch, we now assign the width and height of the viewport rect as two CSS "px" lengths to the "width" and "height" properties of the ICB style. (Previously they were just defaulting to "auto" and we assigned override dimensions during layout.) This fixes an issue where position:absolute elements with relative width and/or height were not dimensioned correctly, since the values were relative to the width and/or height of the ICB style.
2022-02-21LibWeb: Add basic support for dynamic markup insertionLorenz Steinert
This implements basic support for dynamic markup insertion, adding * Document::open() * Document::write(Vector<String> const&) * Document::writeln(Vector<String> const&) * Document::close() The HTMLParser is modified to make it possible to create a script-created parser which initially only contains a HTMLTokenizer without any data. Aditionally the HTMLParser::run method gains an overload which does not modify the Document and does not run HTMLParser::the_end() so that we can reenter the parser at a later time. Furthermore all FIXMEs that consern the insertion point are implemented wich is defined in the HTMLTokenizer. Additionally the following member-variables of the HTMLParser are now exposed by getter funcions: * m_tokenizer * m_aborted * m_script_nesting_level The HTMLTokenizer is modified so that it contains an insertion point which keeps track of where the next input from the Document::write functions will be inserted. The insertion point is implemented as the charakter offset into m_decoded_input and a boolean describing if the insertion point is defined. Functions to update, check and {re}store the insertion point are also added. The function HTMLTokenizer::insert_eof is added to tell a script-created parser that document::close was called and HTMLParser::the_end() should be called. Lastly an explicit default constructor is added to HTMLTokenizer to create a empty HTMLTokenizer into which data can be inserted.
2022-02-21LibWeb: SVG parse signed numbers in eliptical arcSimon Danner
2022-02-21LibWeb: Fix 'Comment end state' in HTML TokenizerAdam Hodgen
Also, update the expected hash in the LibWeb TestHTMLTokenizer regression test. This is due to the "This comment has a few too many dashes." comment token being updated.
2022-02-21LibWeb: Implement tokenization newline preprocessingAdam Hodgen
Newline normalization will replace \r and \r\n with \n. The spec specifically states > Before the tokenization stage, the input stream must be preprocessed > by normalizing newlines. wheras this is implemented the processing during the tokenization itself. This should still exhibit the same behaviour, while keeping the tokenization logic in the same place.
2022-02-21LibWeb: Fix off by one error in HTML TokenizerAdam Hodgen
In 'NamedCharacterReference' we attempt to lookup the code point by a identifier, eg apos; becomes ' This is done by passing the entire rest of the document to the `HTML::code_points_from_entity` function. However, before this change we didn't sent the final character which meant if the document ended in a named character reference the lookup would fail.
2022-02-21LibWeb: Implement `Node.nodeValue` DOM attributeAdam Hodgen
2022-02-20LibWeb: Make i, em, address, cite, dfn and var elements italicKarol Kosek
Although it is not said that some of the elements need to be italic, *most* browsers mark them as such to distinguish them from the normal text, so let's do that too!
2022-02-20LibWeb+Base: Parse font-style CSS propertyKarol Kosek
2022-02-20LibWeb: Handle markers when reconstructing active formatting elements Luke Wilde
The entry we get from the active formatting elements list during the Rewind step of "reconstruct the active formatting elements" can be a marker. Previously we assumed it was not a marker, which can trigger an assertion failure with certain malformed HTML. If the entry in this step is a marker, the spec simply ignores it. This is step 6 of the algorithm. This also makes the index unsigned, as this algorithm is a no-op if the list is empty. Additionally, this also adds spec comments to this algorithm. Fixes #12668.
2022-02-20LibWeb: Add default padding around contents of text <input> elementsKenneth Myhra
This patch adds a default padding around the contents of text <input> elements. It adds these defaults to the existing style attribute in 'HTMLInputElement::create_shadow_tree_if_needed()'. Use a default padding for text <input> elements: - padding-top and padding-bottom: 1px - padding-left and padding-right: 2px These values seems to align with what other browsers do.
2022-02-20LibWeb: Add key code 'Esc' to ignored Keydown Events in EventHandlerKenneth Myhra
This filters out the key code 'Esc' so it won't be printed to editable text nodes, e.g. text <input> elements.
2022-02-20LibWeb: Add support for navigating text <input> with End keyKenneth Myhra
2022-02-20LibWeb: Add support for navigating text <input> with Home keyKenneth Myhra
2022-02-20LibWeb: Add support for the options variant of {add,remove}EventListenerLuke Wilde
This also adds a variant of {add,remove}_event_listener called {add,remove}_event_listener_with_options. This is used internally to perform {add,remove}_event_listener with a default constructed options struct. It was done like this because default constructing the Variant with the options struct requires the struct defintions to be present, which requires us to include AbortSignal.h, which would cause a circular include as AbortSignal.h includes EventTarget.h.
2022-02-19LibWeb: Use DOMParserSupportedType enum for DOMParser.parseFromStringLuke Wilde
Previously it would accept any DOMString, as we didn't support enums at the time. Now it will only accept what's specified in the DOMParserSupportedType enum. This also adds spec comments to DOMParser::parse_from_string.
2022-02-19LibWeb: Implement `@supports selector(.foo)`Sam Atkins
This is defined in https://www.w3.org/TR/css-conditional-4/#at-supports-ext which just became a CR. :^)
2022-02-19LibWeb: Hack BFC to always remember to handle position:absolute elementsAndreas Kling
Normally we don't layout position:absolute elements until after the parent formatting context has assigned dimensions to the current formatting context's root box. However, some of our parent contexts (especially FFC) don't do this reliably, which makes position:absolute children have 0x0 dimensions. Hack this for now by making ~BFC() pretend that the parent assigned dimensions if it hadn't done it already.
2022-02-19LibWeb: Add Layout::Node::debug_description()Andreas Kling
This returns a String with this format: - LayoutNodeClassName<TAG_NAME>#id.class1.class2.class3 I've rewritten this function 10+ times at this point, so I'm just gonna add it to the repository for future debugging needs. :^)
2022-02-19LibWeb: Share QualifiedName data between identical instancesAndreas Kling
Adopt the same pattern as AK::FlyString, reducing sizeof(QualifiedName) to the size of a pointer. This reduces the size of DOM::Element by 24 bytes.
2022-02-19LibWeb: Use Vector::clear_with_capacity() in HTMLTokenizerAndreas Kling
This avoids constantly reallocating the Vector<HTMLToken>.
2022-02-19LibWeb: Move QualifiedName into the Web::DOM namespaceAndreas Kling
2022-02-19LibWeb: Move QualifiedName.h into LibWeb/DOM/Andreas Kling
2022-02-19LibWeb: Shrink DOM::EventTarget by 80 bytesAndreas Kling
Do this by converting two Function members into virtual functions: - legacy_pre_activation_behavior - legacy_cancelled_activation_behavior
2022-02-19LibWeb: Cache and reuse some very common StyleValue objectsAndreas Kling
Length values: auto, 0px, 1px Color values: black, white, transparent
2022-02-19LibWeb: Turn StyleProperties::m_property_values into an ArrayAndreas Kling
After style computation, every StyleProperties has a value for every PropertyID. Given this, it's simpler, faster and less memory-heavy to use an Array instead of a HashMap. :^)
2022-02-19LibWeb: Inspector content_size tooltip in document viewVrins
This adds a small tooltip in the browser showing the size of the element that currently selected in the inspector view. This allows for easier debugging since you dont have to dump the layout tree :^).
2022-02-19LibWeb: Add support for CSS image-rendering propertyMaciej
Currently only "auto" and "pixelated" values are supported.
2022-02-19LibWeb: Return current document URL if form action missing or emptyAdam Plumb
2022-02-19LibWeb: Refresh text-<input> contents when pressing backspace or deleteKenneth Myhra
Make sure to refresh the contents of text-<input> when pressing backspace or delete key. The methods 'handle_insert()' and 'handle_delete()' already had the call to 'm_browsing_context.active_document()->force_layout()' so let us also add it to 'handle_delete_character_after()'.
2022-02-18LibWeb: Use more relevant WebSocket spec linksLinus Groh
Having almost everything point to "3. The WebSocket interface" is kind of pointless.
2022-02-18LibWeb: Move WebSocket into the Web::WebSockets namespaceLinus Groh
WebSockets got moved from the HTML standard to their own, the new WebSockets Standard (https://websockets.spec.whatwg.org). Move the IDL file and implementation into a new WebSockets directory and C++ namespace accordingly.
2022-02-18LibWeb: Add missing is_length() check in FFC::is_cross_auto()Andreas Kling
We can't access LengthPercentage::length() before verifying that it's indeed a length.
2022-02-18LibWeb: Resolve Lengths to pixels earlierSam Atkins
2022-02-18LibWeb: Remove Length::Type::Undefined! :^)Sam Atkins