Bug 78107 - Replace [CustomPutFunction] with [CustomNamedSetter]
Summary: Replace [CustomPutFunction] with [CustomNamedSetter]
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Kentaro Hara
URL:
Keywords:
Depends on:
Blocks: 77393
  Show dependency treegraph
 
Reported: 2012-02-08 05:21 PST by Kentaro Hara
Modified: 2017-07-18 08:29 PDT (History)
4 users (show)

See Also:


Attachments
Patch (10.86 KB, patch)
2012-02-08 05:32 PST, Kentaro Hara
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kentaro Hara 2012-02-08 05:21:01 PST
[CustomPutFunction] means that a given class has a custom setter for named properties. [CustomPutFunction] is used by DOMWindow only. We can replace [CustomPutFunction] with [CustomNamedSetter].
Comment 1 Kentaro Hara 2012-02-08 05:32:50 PST
Created attachment 126064 [details]
Patch
Comment 2 Kentaro Hara 2012-02-10 03:43:07 PST
Darin: would you take a look?
Comment 3 Darin Adler 2012-02-13 15:37:59 PST
Comment on attachment 126064 [details]
Patch

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

> Source/WebCore/ChangeLog:10
> +        [CustomPutFunction] means that a given class has a custom setter for named properties.
> +        [CustomPutFunction] is used by DOMWindow only. This patch replaces [CustomPutFunction]
> +        with [CustomNamedSetter].

Generally speaking this does not seem like a good change.

While it’s possible to use putDelegate to implement all of put, it’s really not a good use of that feature. A putDelegate that always returns true is not really a custom named setter; it’s an entire customization of the put function.

While this does remove one of the attributes the script supports, I think it makes things more twisted rather than making things more clear.

> Source/WebCore/bindings/js/JSDOMWindowCustom.cpp:360
> +    if (allowsAccessFrom(exec))
> +        Base::put(this, exec, propertyName, value, slot);

It seems awkward to call Base::put from “putDelegate”.

> Source/WebCore/bindings/js/JSDOMWindowCustom.cpp:362
> +    // Always returns true to have JSDOMWindow::put() return immediately after JSDOMWindow::putDelegate().

This seems like a mechanical comment. A better comment would explain why.

> Source/WebCore/bindings/scripts/CodeGeneratorV8.pm:569
> +    my $hasCustomNamedSetter = $dataNode->extendedAttributes->{"CustomNamedSetter"} && !$dataNode->extendedAttributes->{"CheckDomainSecurity"};

Making this change seems strange. There’s no logical reason for this, so I can only assume that checking CheckDomainSecurity is just a sideways way of checking for DOMString. What in particular requires that this be false for DOMWindow?

It’s not a step forward to have $hasCustomNamedSetter be false for an object that does indeed have a custom named setter!

> Source/WebCore/bindings/scripts/CodeGeneratorV8.pm:2171
> +    my $hasCustomNamedSetter = $dataNode->extendedAttributes->{"CustomNamedSetter"} && !$dataNode->extendedAttributes->{"CheckDomainSecurity"};

Same question here.
Comment 4 Kentaro Hara 2012-02-13 15:57:28 PST
Comment on attachment 126064 [details]
Patch

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

Darin: thanks for reviewing!

>> Source/WebCore/ChangeLog:10
>> +        with [CustomNamedSetter].
> 
> Generally speaking this does not seem like a good change.
> 
> While it’s possible to use putDelegate to implement all of put, it’s really not a good use of that feature. A putDelegate that always returns true is not really a custom named setter; it’s an entire customization of the put function.
> 
> While this does remove one of the attributes the script supports, I think it makes things more twisted rather than making things more clear.

OK, then keep [CustomPutFunction] as-is, and let us just rename [CustomPutFunction] to [JSCustomPut].

>> Source/WebCore/bindings/scripts/CodeGeneratorV8.pm:569
>> +    my $hasCustomNamedSetter = $dataNode->extendedAttributes->{"CustomNamedSetter"} && !$dataNode->extendedAttributes->{"CheckDomainSecurity"};
> 
> Making this change seems strange. There’s no logical reason for this, so I can only assume that checking CheckDomainSecurity is just a sideways way of checking for DOMString. What in particular requires that this be false for DOMWindow?
> 
> It’s not a step forward to have $hasCustomNamedSetter be false for an object that does indeed have a custom named setter!

This change would make sense, because for named setters of CheckDomainSecurity objects, V8 needs to call namedSecurityCheck() instead of namedPropertySetter().

>> Source/WebCore/bindings/scripts/CodeGeneratorV8.pm:2171
>> +    my $hasCustomNamedSetter = $dataNode->extendedAttributes->{"CustomNamedSetter"} && !$dataNode->extendedAttributes->{"CheckDomainSecurity"};
> 
> Same question here.

Ditto.
Comment 5 Darin Adler 2012-02-14 15:38:31 PST
Comment on attachment 126064 [details]
Patch

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

>>> Source/WebCore/bindings/scripts/CodeGeneratorV8.pm:569
>>> +    my $hasCustomNamedSetter = $dataNode->extendedAttributes->{"CustomNamedSetter"} && !$dataNode->extendedAttributes->{"CheckDomainSecurity"};
>> 
>> Making this change seems strange. There’s no logical reason for this, so I can only assume that checking CheckDomainSecurity is just a sideways way of checking for DOMString. What in particular requires that this be false for DOMWindow?
>> 
>> It’s not a step forward to have $hasCustomNamedSetter be false for an object that does indeed have a custom named setter!
> 
> This change would make sense, because for named setters of CheckDomainSecurity objects, V8 needs to call namedSecurityCheck() instead of namedPropertySetter().

OK, but then the local variable name, hasCustomNamedSetter, is not good.

>>> Source/WebCore/bindings/scripts/CodeGeneratorV8.pm:2171
>>> +    my $hasCustomNamedSetter = $dataNode->extendedAttributes->{"CustomNamedSetter"} && !$dataNode->extendedAttributes->{"CheckDomainSecurity"};
>> 
>> Same question here.
> 
> Ditto.

Ditto.
Comment 6 Kentaro Hara 2012-02-14 15:50:07 PST
(In reply to comment #4)
> > While this does remove one of the attributes the script supports, I think it makes things more twisted rather than making things more clear.
> 
> OK, then keep [CustomPutFunction] as-is, and let us just rename [CustomPutFunction] to [JSCustomPut].

Before renaming it, let me check how DOMWindow-only IDL attributes (e.g. [CustomPutFunction] etc) are used.