summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp
AgeCommit message (Collapse)Author
2022-04-12LibWeb: Improve HTMLImageElement::{width,height}()Igor Pissolati
With this change, it will correctly return the width/height when the image element has an assigned width/height attribute.
2022-04-12LibWeb: Bring HTMLImageElement closer to specIgor Pissolati
2022-04-11LibWeb: Honor "display:block" on IMG elementsAndreas Kling
Previously we forced all image elements to be inline-level. Now they can participate in block layout if they prefer. :^)
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-03-26LibWeb: Move HTML dimension value parsing from CSS to HTML namespaceAndreas Kling
These are part of HTML, not CSS, so let's not confuse things.
2022-03-26LibWeb: Support the hspace and vspace attributes on img elementsAndreas Kling
These map HTML dimension values to CSS margin values.
2022-03-26LibWeb: Treat img width/height attributes as HTML dimension valuesAndreas Kling
2022-03-24LibWeb: Remove inheritance of FormAssociatedElement from HTMLElementTimothy Flynn
HTMLObjectElement will need to be both a FormAssociatedElement and a BrowsingContextContainer. Currently, both of these classes inherit from HTMLElement. This can work in C++, but is generally frowned upon, and doesn't play particularly well with the rest of LibWeb. Instead, we can essentially revert commit 3bb5c62 to remove HTMLElement from FormAssociatedElement's hierarchy. This means that objects such as HTMLObjectElement individually inherit from FormAssociatedElement and HTMLElement now. Some caveats are: * FormAssociatedElement still needs to know when the HTMLElement is inserted into and removed from the DOM. This hook is automatically injected via a macro now, while still allowing classes like HTMLInputElement to also know when the element is inserted. * Casting from a DOM::Element to a FormAssociatedElement is now a sideways cast, rather than directly following an inheritance chain. This means static_cast cannot be used here; but we can safely use dynamic_cast since the only 2 instances of this already use RTTI to verify the cast.
2022-03-17Libraries: Use default constructors/destructors in LibWebLenny Maiorani
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules "The compiler is more likely to get the default semantics right and you cannot implement these functions better than the compiler."
2022-03-16LibWeb: Schedule a relayout after <image> and <object> elements loadAndreas Kling
Otherwise we'll be stuck with the intrinsic dimensions of the replacement content.
2022-03-11LibWeb: Move PaintingBox to its own .cpp and .h filesAndreas Kling
2022-03-11LibWeb: Rename Painting::Box => PaintableAndreas Kling
Calling this "Box" made it very confusing to look at code that used both Layout::Box and Painting::Box. Let's try calling it Paintable instead.
2022-03-11LibWeb: Add Painting::Box and move things from Layout::Box into itAndreas Kling
The "paintable" state in Layout::Box was actually not safe to access until after layout had been performed. As a first step towards making this harder to mess up accidentally, this patch moves painting information from Layout::Box to a new class: Painting::Box. Every layout can have a corresponding paint box, and it holds the final used metrics determined by layout. The paint box is created and populated by FormattingState::commit(). I've also added DOM::Node::paint_box() as a convenient way to access the paint box (if available) of a given DOM node. Going forward, I believe this will allow us to better separate data that belongs to layout vs painting, and also open up opportunities for naturally invalidating caches in the paint box (since it's reconstituted by every layout.)
2022-02-25LibWeb: Implement HTMLImageElement.width and HTMLImageElement.heightAndreas Kling
2022-02-19LibWeb: Move QualifiedName into the Web::DOM namespaceAndreas Kling
2022-02-08LibWeb: Make FormAssociatedElement inherit from HTMLElementLuke Wilde
The new event target implementation requires us to downcast an EventTarget to a FormAssociatedElement to check if the current Element EventTarget has a form owner to setup a with scope for the form owner. This also makes all form associated elements inherit from FormAssociatedElement where it was previously missing. https://html.spec.whatwg.org/#form-associated-element
2022-02-05LibWeb: Compute element style in Layout::TreeBuilderAndreas Kling
Instead of making each Layout::Node compute style for itself, we now compute it in TreeBuilder before even calling create_layout_node(). For non-element DOM nodes, we create the style and layout tree node in TreeBuilder. This allows us to move create_layout_node() from DOM::Node to DOM::Element.
2021-10-18LibWeb: Update <img> style on resource load/failureAndreas Kling
2021-10-06LibWeb: Start work towards modern CSS "display" valuesAndreas Kling
Until now, we've internally thought of the CSS "display" property as a single-value property. In practice, "display" is a much more complex property that comes in a number of configurations. The most interesting one is the two-part format that describes the outside and inside behavior of a box. Switching our own internal representation towards this model will allow for much cleaner abstractions around layout and the various formatting contexts. Note that we don't *parse* two-part "display" yet, this is only about changing the internal representation of the property. Spec: https://drafts.csswg.org/css-display
2021-10-06LibWeb: Make CSS layout lazierAndreas Kling
Instead of doing layout synchronously whenever something changes, we now use a basic event loop timer to defer and coalesce relayouts. If you did something that requires a relayout of the page, make sure to call Document::set_needs_layout() and it will get coalesced with all the other layout updates. There's lots of room for improvement here, but this already makes many web pages significantly snappier. :^) Also, note that this exposes a number of layout bugs where we have been relying on multiple relayouts to calculate the correct dimensions for things. Now that we only do a single layout in many cases, these kind of problems are much more noticeable. That should also make them easier to figure out and fix. :^)
2021-09-24LibWeb: Rename CSS::StyleResolver => StyleComputerAndreas Kling
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-09LibWeb: Rename Document::complete_url() => parse_url()Andreas Kling
This better matches the spec nomenclature.
2021-09-09LibWeb: Use the task queue to fire "load" and "error" events on imagesAndreas Kling
2021-08-02LibWeb: Switch to new CSS Parser :^)Sam Atkins
Change all the places that were including the deprecated parser, to include the new one instead, and then delete the old parser code. `ParentNode::query_selector[_all]()` now treat their input as a comma-separated list of selectors, instead of just one, and return elements that match any of the selectors in that list. This is according to these specs: - querySelector/querySelectorAll: https://dom.spec.whatwg.org/#ref-for-dom-parentnode-queryselector%E2%91%A0 - selector matching algorithm: https://www.w3.org/TR/selectors-4/#match-against-tree
2021-05-24LibWeb: Don't try to load anything if src is empty in <img>Tobias Christiansen
Previously we tried to load "" if the src was present but empty and essentially only waited for RequestServer to time out.
2021-04-23AK: Rename adopt() to adopt_ref()Andreas Kling
This makes it more symmetrical with adopt_own() (which is used to create a NonnullOwnPtr from the result of a naked new.)
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-15LibWeb: Set Cookie header on <img> and <object> resource requestsTimothy Flynn
This required passing a reference to the owning HTML*Element to ImageLoader, the same way that CSSLoader has a reference to its owner.
2021-03-09LibWeb: Rename CSSParser => DeprecatedCSSParserAndreas Kling
2021-03-07LibWeb: Split CSS::StyleSheet into StyleSheet and CSSStyleSheetAndreas Kling
This is a little convoluted but matches the CSSOM specification.
2021-02-07LibWeb: Use move semantics for QualifiedName more oftenAndreas Kling
2021-01-29ImageDecoder+LibImageDecoder+LibWeb: Support animations in ImageDecoderAndreas Kling
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-12Libraries: Move to Userland/Libraries/Andreas Kling