LibWeb/SVG: Implement SVGElement.ownerSVGElement
This commit is contained in:
parent
89531fb115
commit
6f3c5f5ae9
Notes:
sideshowbarker
2024-07-17 07:14:22 +09:00
Author: https://github.com/jamierocks Commit: https://github.com/LadybirdBrowser/ladybird/commit/6f3c5f5ae9 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/666
5 changed files with 30 additions and 1 deletions
|
@ -0,0 +1,3 @@
|
|||
svg.ownerSVGElement = 'null'
|
||||
linearGradient.ownerSVGElement = '[object SVGSVGElement]'
|
||||
linearGradient.ownerSVGElement == svg = 'true'
|
|
@ -0,0 +1,14 @@
|
|||
<script src="../include.js"></script>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" id="svg-element">
|
||||
<linearGradient id="linear-gradient-element" />
|
||||
</svg>
|
||||
<script>
|
||||
test(() => {
|
||||
const svgElement = document.getElementById("svg-element");
|
||||
println(`svg.ownerSVGElement = '${svgElement.ownerSVGElement}'`);
|
||||
|
||||
const linearGradientElement = document.getElementById("linear-gradient-element");
|
||||
println(`linearGradient.ownerSVGElement = '${linearGradientElement.ownerSVGElement}'`);
|
||||
println(`linearGradient.ownerSVGElement == svg = '${linearGradientElement.ownerSVGElement === svgElement}'`);
|
||||
});
|
||||
</script>
|
|
@ -13,6 +13,7 @@
|
|||
#include <LibWeb/DOM/ShadowRoot.h>
|
||||
#include <LibWeb/HTML/DOMStringMap.h>
|
||||
#include <LibWeb/SVG/SVGElement.h>
|
||||
#include <LibWeb/SVG/SVGSVGElement.h>
|
||||
#include <LibWeb/SVG/SVGUseElement.h>
|
||||
|
||||
namespace Web::SVG {
|
||||
|
@ -125,6 +126,15 @@ JS::NonnullGCPtr<SVGAnimatedString> SVGElement::class_name()
|
|||
return *m_class_name_animated_string;
|
||||
}
|
||||
|
||||
// https://svgwg.org/svg2-draft/types.html#__svg__SVGElement__ownerSVGElement
|
||||
JS::GCPtr<SVGSVGElement> SVGElement::owner_svg_element()
|
||||
{
|
||||
// The ownerSVGElement IDL attribute represents the nearest ancestor ‘svg’ element.
|
||||
// On getting ownerSVGElement, the nearest ancestor ‘svg’ element is returned;
|
||||
// if the current element is the outermost svg element, then null is returned.
|
||||
return first_ancestor_of_type<SVGSVGElement>();
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<SVGAnimatedLength> SVGElement::svg_animated_length_for_property(CSS::PropertyID property) const
|
||||
{
|
||||
// FIXME: Create a proper animated value when animations are supported.
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
void blur();
|
||||
|
||||
JS::NonnullGCPtr<SVGAnimatedString> class_name();
|
||||
JS::GCPtr<SVGSVGElement> owner_svg_element();
|
||||
|
||||
protected:
|
||||
SVGElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#import <HTML/HTMLElement.idl>
|
||||
#import <HTML/DOMStringMap.idl>
|
||||
#import <SVG/SVGAnimatedString.idl>
|
||||
#import <SVG/SVGSVGElement.idl>
|
||||
|
||||
// https://svgwg.org/svg2-draft/types.html#InterfaceSVGElement
|
||||
[Exposed=Window]
|
||||
|
@ -10,7 +11,7 @@ interface SVGElement : Element {
|
|||
|
||||
[SameObject] readonly attribute SVGAnimatedString className;
|
||||
|
||||
[FIXME] readonly attribute SVGSVGElement? ownerSVGElement;
|
||||
readonly attribute SVGSVGElement? ownerSVGElement;
|
||||
[FIXME] readonly attribute SVGElement? viewportElement;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue