summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/SVG
AgeCommit message (Collapse)Author
2022-04-12LibWeb: Move CSS Parser into new Web::CSS::Parser namespaceSam Atkins
The goal here is to move the parser-internal classes into this namespace so they can have more convenient names without causing collisions. The Parser itself won't collide, and would be more convenient to just remain `CSS::Parser`, but having a namespace and a class with the same name makes C++ unhappy.
2022-04-11LibWeb: Add SVGDefsElementSimon Danner
* Similarly to clipPath, this doesn't need to get rendered, so return no LayoutNode.
2022-04-10LibWeb: Sketch out a very basic SVG <clipPath> elementAndreas Kling
This element doesn't actually support anything at the moment, but it still massively speeds up painting performance on Wikipedia! :^) How? Because we no longer paint SVG <path> elements found inside <clipPath> elements. SVGClipPathElement::create_layout_node() returns nullptr which stops the layout tree builder from recursing further into the subtree, and so the <path> element never gets a layout or paint box. Mousing over Wikipedia now barely break 50% CPU usage on my machine :^)
2022-04-10LibWeb: Resolve SVG "scaled viewport size" without triggering layoutAndreas Kling
Percentage stroke widths are resolved against the scaled viewport size which we were retrieving by calling client_width() and client_height() on the element. Now that those accessors may trigger layout, this means that we can't use them from the stroke_width() getter, which is itself used *from within* layout.
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-03-31LibWeb: Add the HTMLOrSVGElement IDL interface mixinIdan Horowitz
2022-03-26LibWeb: Fix typo in SVGSVGElement::apply_presentational_hints()Andreas Kling
Regressed in 7df62c64b7116842e43f2c8fcd1a7b0e71f456b7. Thanks to Dex for spotting this! :^)
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: Treat width/height on <svg> element as HTML dimension valuesAndreas Kling
This might not be entirely correct, but neither was using the completely ad-hoc parse_html_length(), and this is the last user of that API so let's move off of it.
2022-03-22LibWeb: Expose SVGEllipseElement attributes to JSSam Atkins
2022-03-22LibWeb: Expose SVGCircleElement attributes to JSSam Atkins
2022-03-22LibWeb: Expose SVGLineElement attributes to JSSam Atkins
2022-03-21LibWeb: Begin implementing SVGRectElement's SVGAnimatedLength attributesTimothy Flynn
2022-03-21LibWeb: Implement the SVGAnimatedLength typeTimothy Flynn
2022-03-21LibWeb: Begin implementing the SVGLength typeTimothy Flynn
There are a few unimplemented features for this type: 1. The value setter should throw a DOMException if it is invoked on an SVGLength that was declared readonly in another IDL file. 2. SVG::AttributeParser does not parse unit types when it parses lengths so all SVGLength will have an "unknown" unit for now. 3. Due to (2), methods which convert between units are unimplemented.
2022-03-20LibWeb: Add a barebones SVGTextContentElement with getNumberOfChars()Andreas Kling
2022-03-18LibWeb: Apply the 'transform' presentational attribute to SVG elementsSimon Wanner
2022-03-13LibWeb: Add fast_is<SVG::SVGSVGElement>()Andreas Kling
2022-03-04LibWeb: Correct SVG smooth curve reflected control point calculationIdan Horowitz
We were calculating the reflected control points in the svg smooth curve instructions incorrectly, and this issue was masked by the fact that we were treating it as a relative coordinate in relative mode.
2022-02-28LibWeb: Make SVGSVGElement's view_box() constTobias Christiansen
2022-02-21LibWeb: SVG parse signed numbers in eliptical arcSimon Danner
2022-02-19LibWeb: Move QualifiedName into the Web::DOM namespaceAndreas Kling
2022-02-16LibWeb: Give SVG geometry elements a positionSam Atkins
This makes the selected-in-the-inspector outline appear in the right place. We take the stroke-width into account when producing the bounding box, which makes the fit nice and snug. :^)
2022-02-16LibWeb: Give `<svg>` elements a size againSam Atkins
This replaces the unused width() and height() methods. The size now defaults to 100% by 100% as in the spec.
2022-02-16LibWeb: Add imports to all IDL files that depend on othersAli Mohammad Pur
2022-02-11LibWeb: Clear the path of a SVGPathElement if the attribute changesSam Atkins
Otherwise, modifying the `d` attribute would not cause any visual changes to the path.
2022-02-11LibWeb: Make SVG AttributeParser::parse_path_data() staticSam Atkins
This is mostly a style thing, but it matches the other APIs.
2022-02-11LibWeb: Use StringView instead of String in SVG::AttributeParserSam Atkins
This saves copying the string data, since the AttributeParser is always temporary.
2022-02-11LibWeb: Add SVG `<polygon>` element and test case :^)Sam Atkins
2022-02-11LibWeb: Add SVG `<polyline>` element and test case :^)Sam Atkins
2022-02-11LibWeb: Add SVG `<line>` element and test case :^)Sam Atkins
2022-02-11LibWeb: Add SVG `<ellipse>` element and test case :^)Sam Atkins
2022-02-11LibWeb: Add SVG `<circle>` element and test case :^)Sam Atkins
2022-02-11LibWeb: Add SVG `<rect>` element and test case :^)Sam Atkins
2022-02-11LibWeb: Expose SVG length/coordinate parsing methodsSam Atkins
This is all still quite ad-hoc. Eventually these will both need to support units (like with CSS Lengths) but for now we can continue only using numbers.
2022-02-11LibWeb: Move SVG::PathDataParser into its own file and rename itSam Atkins
I've chosen the name `AttributeParser` since it parses data from attributes. Rather than duplicate the parsing of numbers and other basic types, let's make use of this existing parsing code for parsing the data for `<line>`, `<polyline>`, etc.
2022-02-11LibWeb: Rename SVGPathBox -> SVGGeometryBoxSam Atkins
This fits better since it's now used by all SVGGeometryElements.
2022-02-11LibWeb: Move SVGPathElement methods into SVGGeometryElementSam Atkins
From the spec: > Interface SVGGeometryElement represents SVG elements whose rendering > is defined by geometry with an equivalent path, and which can be > filled and stroked. This includes paths and the basic shapes. - https://svgwg.org/svg2-draft/types.html#InterfaceSVGGeometryElement Making them all create an SVGPathBox, and return a Path from get_path(), means we can implement the "basic shapes" using the path system we already have. :^)
2022-02-06LibWeb: Implement SVG `S` (SmoothCurve) commandsSam Atkins
These were being parsed, but skipped when rendering. With this fix, the SVG on discord's invite screen looks pretty nice! :^)
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.
2022-02-04LibWeb: Allow LengthPercentage to hold a calculated valueSam Atkins
Most of the time, we cannot resolve a `calc()` expression until we go to use it. Since any `<length-percentage>` can legally be a `calc ()`, let's store it in `LengthPercentage` rather than make every single user care about this distinction.
2022-01-24LibWeb: Treat SVG fill/stroke/stroke-width attributes as CSS propertiesSam Atkins
Rather than having separate systems for the attributes and their CSS equivalents, we can treat the attributes as presentational hints and convert them to CSS properties. This means they can be inherited, as they should. :^) As noted, the `fill` and `stroke` attributes do not fully match the `fill` and `stroke` properties. The CSS spec is still an early draft and not entirely helpful, so we can just pretend they are the same for now.
2022-01-20LibWeb: Convert `stroke-width` to LengthPercentageSam Atkins
This is a guinea pig. So far so good?
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-09-27LibWeb: Make SVG <path> tolerate relative first path coordinatesAndreas Kling
If the first element of an SVG path spec uses relative coordinates, we'll now treat them as absolute. This is achieved by defaulting to (0,0) as the initial "last point" in the path.
2021-09-26LibWeb: Add support for HTMLOrSVGElement.datasetLuke Wilde
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-18LibWeb: Add a bare-bones SVG <g> elementAndreas Kling
2021-09-16LibWeb: Add for CSS `fill/stroke/stroke-color` properties for SVGSam Atkins
In the spec, `fill` and `stroke` are supposed to be a shorthands for various properties. But since the spec is still a working draft, and neither Firefox or Chrome support the `fill-color` or `stroke-color` properties, we'll stick with `fill` and `stroke` as simple colors for now. Also, note that SVG expects things in "user units", and we are assuming that 1px = 1 user unit for now.
2021-09-15LibWeb: Support "c" and "C" curves in SVG <path> dataAndreas Kling
These instructions now generate cubic Bézier curves.