Bug 214690 - Add support for SVGAElement's rel / relList attributes
Summary: Add support for SVGAElement's rel / relList attributes
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL: https://www.w3.org/TR/SVG/linking.htm...
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-07-23 10:22 PDT by Chris Dumez
Modified: 2020-07-23 14:06 PDT (History)
18 users (show)

See Also:


Attachments
Patch (10.85 KB, patch)
2020-07-23 10:23 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (12.92 KB, patch)
2020-07-23 10:45 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (13.34 KB, patch)
2020-07-23 11:45 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (14.39 KB, patch)
2020-07-23 12:02 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (15.07 KB, patch)
2020-07-23 12:19 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (15.29 KB, patch)
2020-07-23 12:49 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2020-07-23 10:22:10 PDT
Add support for SVGAElement's rel / relList attributes:
https://www.w3.org/TR/SVG/linking.html#InterfaceSVGAElement
Comment 1 Chris Dumez 2020-07-23 10:23:14 PDT
Created attachment 405052 [details]
Patch
Comment 2 Darin Adler 2020-07-23 10:29:42 PDT
Comment on attachment 405052 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=405052&action=review

> Source/WebCore/svg/SVGAElement.cpp:86
> +        return;

Wish I understood whether we should call to base or return in cases like this. I suppose return is a slight optimization, whereas calling through to base is a little more consistent and allows for each level to implement part of attribute handling, which could be handy in some cases.

> Source/WebCore/svg/SVGAElement.cpp:231
> +        m_relList = makeUnique<DOMTokenList>(const_cast<SVGAElement&>(*this), SVGNames::relAttr, [](Document&, StringView token) {

This const_cast makes me wonder about ever using const for functions in these element classes. Is there anything meaningful to the use of const in the class definition? I understand that conceptually it does not change the state of the element. But also, making a DOMTokenList doesn’t seem to change the element either, so why does it take a non-const reference. Except for the fact that everything takes non-const references to classes like Node and Element.

> Source/WebCore/svg/SVGAElement.cpp:236
> +#if USE(SYSTEM_PREVIEW)
> +            return equalIgnoringASCIICase(token, "noreferrer") || equalIgnoringASCIICase(token, "noopener") || equalIgnoringASCIICase(token, "ar");
> +#else
> +            return equalIgnoringASCIICase(token, "noreferrer") || equalIgnoringASCIICase(token, "noopener");
> +#endif

Is there a less repetitive way to write this? Maybe:

#if USE(SYSTEM_PREVIEW)
    if (equalIgnoringASCIICase(token, "ar"))
        return true;
#endif

Then the rest doesn’t have to be inside #if.

> Source/WebCore/svg/SVGAElement.idl:30
> +    [SameObject, PutForwards=value] readonly attribute DOMTokenList relList;

Not sure I understand the meaning of PutForwards=value, but whatever it is, glad the generator handles it.
Comment 3 Chris Dumez 2020-07-23 10:37:46 PDT
Comment on attachment 405052 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=405052&action=review

>> Source/WebCore/svg/SVGAElement.cpp:86
>> +        return;
> 
> Wish I understood whether we should call to base or return in cases like this. I suppose return is a slight optimization, whereas calling through to base is a little more consistent and allows for each level to implement part of attribute handling, which could be handy in some cases.

Yes, this is a slight optimization and seems to be the existing pattern in parseAttribute() functions.

>> Source/WebCore/svg/SVGAElement.cpp:231
>> +        m_relList = makeUnique<DOMTokenList>(const_cast<SVGAElement&>(*this), SVGNames::relAttr, [](Document&, StringView token) {
> 
> This const_cast makes me wonder about ever using const for functions in these element classes. Is there anything meaningful to the use of const in the class definition? I understand that conceptually it does not change the state of the element. But also, making a DOMTokenList doesn’t seem to change the element either, so why does it take a non-const reference. Except for the fact that everything takes non-const references to classes like Node and Element.

While constructing a DOMTokenList does not modify the element, the JS can modify an element (the element's attribute) via the DOMTokenList. The DOMTokenList needs to be able to update attributes on the element, which is why it takes in a non-const reference. I guess I should just drop the const on relList() function.

>> Source/WebCore/svg/SVGAElement.cpp:236
>> +#endif
> 
> Is there a less repetitive way to write this? Maybe:
> 
> #if USE(SYSTEM_PREVIEW)
>     if (equalIgnoringASCIICase(token, "ar"))
>         return true;
> #endif
> 
> Then the rest doesn’t have to be inside #if.

Ok.

>> Source/WebCore/svg/SVGAElement.idl:30
>> +    [SameObject, PutForwards=value] readonly attribute DOMTokenList relList;
> 
> Not sure I understand the meaning of PutForwards=value, but whatever it is, glad the generator handles it.

causes this:
a.relList = "foo"
to be equivalent to:
a.relList.value = "foo"

The most popular use is likely for window.location which actually sets window.location.href.

https://heycam.github.io/webidl/#PutForwards
Comment 4 Chris Dumez 2020-07-23 10:45:58 PDT
Created attachment 405058 [details]
Patch
Comment 5 Chris Dumez 2020-07-23 11:45:58 PDT
Created attachment 405062 [details]
Patch
Comment 6 Chris Dumez 2020-07-23 12:02:18 PDT
Created attachment 405063 [details]
Patch
Comment 7 Chris Dumez 2020-07-23 12:19:22 PDT
Created attachment 405065 [details]
Patch
Comment 8 Chris Dumez 2020-07-23 12:49:54 PDT
Created attachment 405069 [details]
Patch
Comment 9 EWS 2020-07-23 14:05:32 PDT
Committed r264789: <https://trac.webkit.org/changeset/264789>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 405069 [details].
Comment 10 Radar WebKit Bug Importer 2020-07-23 14:06:30 PDT
<rdar://problem/66011698>