mirror of
https://github.com/SerenityOS/serenity
synced 2024-11-05 17:46:52 +00:00
LibWeb/SVG: Implement SVGElement.ownerSVGElement
(cherry picked from commit 6f3c5f5ae9f0ee055c44ace5efab0c443626bb5d)
This commit is contained in:
parent
219c40a4ba
commit
40eaf964d2
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…
Reference in a new issue