Changeset 207319 in webkit


Ignore:
Timestamp:
Oct 13, 2016 7:50:07 PM (7 years ago)
Author:
Chris Dumez
Message:

[Web IDL] Add support for [SameObject] extended attribute
https://bugs.webkit.org/show_bug.cgi?id=163414

Reviewed by Darin Adler.

Source/WebCore:

Add support for [SameObject] Web IDL extended attribute:

Start using it on DOM / HTML attributes where the specification
mandates it.

Test: js/dom/SameObject-support.html

  • bindings/scripts/CodeGeneratorJS.pm:

(ShouldCacheAttribute):
(GenerateHeader):
(GenerateImplementation):

  • bindings/scripts/IDLAttributes.txt:
  • dom/DataTransfer.idl:
  • dom/Document.idl:
  • dom/Element.idl:
  • dom/MutationRecord.idl:
  • dom/Node.idl:
  • dom/NodeIterator.idl:
  • dom/ParentNode.idl:
  • dom/TreeWalker.idl:
  • html/HTMLAnchorElement.idl:
  • html/HTMLAreaElement.idl:
  • html/HTMLButtonElement.idl:
  • html/HTMLDataListElement.idl:
  • html/HTMLDocument.idl:
  • html/HTMLElement.idl:
  • html/HTMLFieldSetElement.idl:
  • html/HTMLFormElement.idl:
  • html/HTMLIFrameElement.idl:
  • html/HTMLInputElement.idl:
  • html/HTMLKeygenElement.idl:
  • html/HTMLLinkElement.idl:
  • html/HTMLMapElement.idl:
  • html/HTMLMediaElement.idl:
  • html/HTMLMeterElement.idl:
  • html/HTMLOutputElement.idl:
  • html/HTMLProgressElement.idl:
  • html/HTMLSelectElement.idl:
  • html/HTMLTableElement.idl:
  • html/HTMLTableRowElement.idl:
  • html/HTMLTableSectionElement.idl:
  • html/HTMLTextAreaElement.idl:
  • page/Location.idl:
  • page/Navigator.idl:

LayoutTests:

Add layout test coverage.

  • js/dom/SameObject-support-expected.txt: Added.
  • js/dom/SameObject-support.html: Added.
Location:
trunk
Files:
2 added
36 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r207314 r207319  
     12016-10-13  Chris Dumez  <cdumez@apple.com>
     2
     3        [Web IDL] Add support for [SameObject] extended attribute
     4        https://bugs.webkit.org/show_bug.cgi?id=163414
     5
     6        Reviewed by Darin Adler.
     7
     8        Add layout test coverage.
     9
     10        * js/dom/SameObject-support-expected.txt: Added.
     11        * js/dom/SameObject-support.html: Added.
     12
    1132016-10-13  Nan Wang  <n_wang@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r207318 r207319  
     12016-10-13  Chris Dumez  <cdumez@apple.com>
     2
     3        [Web IDL] Add support for [SameObject] extended attribute
     4        https://bugs.webkit.org/show_bug.cgi?id=163414
     5
     6        Reviewed by Darin Adler.
     7
     8        Add support for [SameObject] Web IDL extended attribute:
     9        - https://heycam.github.io/webidl/#SameObject
     10
     11        Start using it on DOM / HTML attributes where the specification
     12        mandates it.
     13
     14        Test: js/dom/SameObject-support.html
     15
     16        * bindings/scripts/CodeGeneratorJS.pm:
     17        (ShouldCacheAttribute):
     18        (GenerateHeader):
     19        (GenerateImplementation):
     20        * bindings/scripts/IDLAttributes.txt:
     21        * dom/DataTransfer.idl:
     22        * dom/Document.idl:
     23        * dom/Element.idl:
     24        * dom/MutationRecord.idl:
     25        * dom/Node.idl:
     26        * dom/NodeIterator.idl:
     27        * dom/ParentNode.idl:
     28        * dom/TreeWalker.idl:
     29        * html/HTMLAnchorElement.idl:
     30        * html/HTMLAreaElement.idl:
     31        * html/HTMLButtonElement.idl:
     32        * html/HTMLDataListElement.idl:
     33        * html/HTMLDocument.idl:
     34        * html/HTMLElement.idl:
     35        * html/HTMLFieldSetElement.idl:
     36        * html/HTMLFormElement.idl:
     37        * html/HTMLIFrameElement.idl:
     38        * html/HTMLInputElement.idl:
     39        * html/HTMLKeygenElement.idl:
     40        * html/HTMLLinkElement.idl:
     41        * html/HTMLMapElement.idl:
     42        * html/HTMLMediaElement.idl:
     43        * html/HTMLMeterElement.idl:
     44        * html/HTMLOutputElement.idl:
     45        * html/HTMLProgressElement.idl:
     46        * html/HTMLSelectElement.idl:
     47        * html/HTMLTableElement.idl:
     48        * html/HTMLTableRowElement.idl:
     49        * html/HTMLTableSectionElement.idl:
     50        * html/HTMLTextAreaElement.idl:
     51        * page/Location.idl:
     52        * page/Navigator.idl:
     53
    1542016-10-13  Andy Estes  <aestes@apple.com>
    255
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r207302 r207319  
    351351
    352352    return IsDOMGlobalObject($interface);
     353}
     354
     355sub ShouldCacheAttribute
     356{
     357    my $attribute = shift;
     358
     359    return 1 if $attribute->signature->extendedAttributes->{CachedAttribute};
     360    return 1 if $attribute->signature->extendedAttributes->{SameObject};
     361    return 0;
    353362}
    354363
     
    14821491            $numCustomAttributes++ if HasCustomGetter($attribute->signature->extendedAttributes);
    14831492            $numCustomAttributes++ if HasCustomSetter($attribute->signature->extendedAttributes);
    1484             if ($attribute->signature->extendedAttributes->{CachedAttribute}) {
     1493            if (ShouldCacheAttribute($attribute)) {
    14851494                my $conditionalString = $codeGenerator->GenerateConditionalString($attribute->signature);
    14861495                push(@headerContent, "#if ${conditionalString}\n") if $conditionalString;
     
    30653074            }
    30663075
    3067             $needsVisitChildren = 1 if $attribute->signature->extendedAttributes->{CachedAttribute};
     3076            $needsVisitChildren = 1 if ShouldCacheAttribute($attribute);
    30683077
    30693078            if ($interface->extendedAttributes->{CheckSecurity} &&
     
    31403149            } elsif (!$attribute->signature->extendedAttributes->{GetterMayThrowLegacyException}) {
    31413150                my $cacheIndex = 0;
    3142                 if ($attribute->signature->extendedAttributes->{CachedAttribute}) {
     3151                if (ShouldCacheAttribute($attribute)) {
    31433152                    $cacheIndex = $currentCachedAttribute;
    31443153                    $currentCachedAttribute++;
     
    31833192                }
    31843193
    3185                 push(@implContent, "    thisObject.m_" . $attribute->signature->name . ".set(state.vm(), &thisObject, result);\n") if $attribute->signature->extendedAttributes->{CachedAttribute};
     3194                push(@implContent, "    thisObject.m_" . $attribute->signature->name . ".set(state.vm(), &thisObject, result);\n") if ShouldCacheAttribute($attribute);
    31863195                push(@implContent, "    return result;\n");
    31873196
     
    37633772            foreach (@{$interface->attributes}) {
    37643773                my $attribute = $_;
    3765                 if ($attribute->signature->extendedAttributes->{CachedAttribute}) {
     3774                if (ShouldCacheAttribute($attribute)) {
    37663775                    push(@implContent, "    visitor.append(&thisObject->m_" . $attribute->signature->name . ");\n");
    37673776                }
  • trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt

    r207302 r207319  
    115115ReportExternalMemoryCost
    116116RequiresExistingAtomicString
     117SameObject
    117118SetterCallWith=ScriptExecutionContext|ScriptState|ScriptArguments|CallStack|ActiveWindow|FirstWindow
    118119SetterMayThrowException
  • trunk/Source/WebCore/dom/DataTransfer.idl

    r199500 r207319  
    3434
    3535    [CustomGetter] readonly attribute Array types;
    36     readonly attribute FileList files;
     36    [SameObject] readonly attribute FileList files;
    3737
    3838    void clearData(optional DOMString type);
     
    4141    void setDragImage(Element? image, long x, long y); // FIXME: Element argument is not nullable in the HTML standard.
    4242
     43    // FIXME: Should be [SameObject].
    4344    [Conditional=DATA_TRANSFER_ITEMS] readonly attribute DataTransferItemList items;
    4445};
  • trunk/Source/WebCore/dom/Document.idl

    r207170 r207319  
    2929] interface Document : Node {
    3030    readonly attribute DocumentType? doctype;
    31     readonly attribute DOMImplementation implementation;
     31    [SameObject] readonly attribute DOMImplementation implementation;
    3232    readonly attribute Element? documentElement;
    3333
     
    106106
    107107    readonly attribute HTMLHeadElement? head;
    108     readonly attribute HTMLCollection images;
    109     readonly attribute HTMLCollection applets;
    110     readonly attribute HTMLCollection links;
    111     readonly attribute HTMLCollection forms;
    112     readonly attribute HTMLCollection anchors;
    113     readonly attribute HTMLCollection embeds;
    114     readonly attribute HTMLCollection plugins;
    115     readonly attribute HTMLCollection scripts;
     108    [SameObject] readonly attribute HTMLCollection images;
     109    [SameObject] readonly attribute HTMLCollection applets;
     110    [SameObject] readonly attribute HTMLCollection links;
     111    [SameObject] readonly attribute HTMLCollection forms;
     112    [SameObject] readonly attribute HTMLCollection anchors;
     113    [SameObject] readonly attribute HTMLCollection embeds;
     114    [SameObject] readonly attribute HTMLCollection plugins;
     115    [SameObject] readonly attribute HTMLCollection scripts;
    116116    readonly attribute DOMString lastModified;
    117117
  • trunk/Source/WebCore/dom/Element.idl

    r207170 r207319  
    3939    HTMLCollection getElementsByTagName(DOMString name);
    4040
    41     readonly attribute NamedNodeMap attributes;
     41    [SameObject] readonly attribute NamedNodeMap attributes;
    4242    boolean hasAttributes();
    4343
     
    102102
    103103    [CEReactions, Reflect=class] attribute DOMString className;
    104     [PutForwards=value] readonly attribute DOMTokenList classList;
     104    [SameObject, PutForwards=value] readonly attribute DOMTokenList classList;
    105105
    106106    [MayThrowLegacyException] boolean matches(DOMString selectors);
  • trunk/Source/WebCore/dom/MutationRecord.idl

    r197060 r207319  
    3333] interface MutationRecord {
    3434    readonly attribute DOMString type;
    35     readonly attribute Node target;
     35    [SameObject] readonly attribute Node target;
    3636
    37     readonly attribute NodeList addedNodes;
    38     readonly attribute NodeList removedNodes;
     37    [SameObject] readonly attribute NodeList addedNodes;
     38    [SameObject] readonly attribute NodeList removedNodes;
    3939    readonly attribute Node previousSibling;
    4040    readonly attribute Node nextSibling;
  • trunk/Source/WebCore/dom/Node.idl

    r207239 r207319  
    4949    [DOMJIT, CustomGetter] readonly attribute unsigned short nodeType;
    5050    [DOMJIT] readonly attribute Node? parentNode;
    51     readonly attribute NodeList childNodes;
     51    [SameObject] readonly attribute NodeList childNodes;
    5252    [DOMJIT] readonly attribute Node? firstChild;
    5353    [DOMJIT] readonly attribute Node? lastChild;
  • trunk/Source/WebCore/dom/NodeIterator.idl

    r204717 r207319  
    2424    JSCustomMarkFunction,
    2525] interface NodeIterator {
    26     readonly attribute Node root;
     26    [SameObject] readonly attribute Node root;
    2727    readonly attribute unsigned long whatToShow;
    2828    readonly attribute NodeFilter filter;
  • trunk/Source/WebCore/dom/ParentNode.idl

    r207170 r207319  
    2929    NoInterfaceObject,
    3030] interface ParentNode {
    31     readonly attribute HTMLCollection children;
     31    [SameObject] readonly attribute HTMLCollection children;
    3232    readonly attribute Element firstElementChild;
    3333    readonly attribute Element lastElementChild;
  • trunk/Source/WebCore/dom/TreeWalker.idl

    r204717 r207319  
    2424    JSCustomMarkFunction,
    2525] interface TreeWalker {
    26     readonly attribute Node root;
     26    [SameObject] readonly attribute Node root;
    2727    readonly attribute unsigned long whatToShow;
    2828    readonly attribute NodeFilter filter;
  • trunk/Source/WebCore/html/HTMLAnchorElement.idl

    r206561 r207319  
    3434    attribute DOMString text;
    3535
    36     [PutForwards=value] readonly attribute DOMTokenList relList;
     36    [SameObject, PutForwards=value] readonly attribute DOMTokenList relList;
    3737};
    3838
  • trunk/Source/WebCore/html/HTMLAreaElement.idl

    r206630 r207319  
    3030    [Conditional=DOWNLOAD_ATTRIBUTE, EnabledAtRuntime=DownloadAttribute, Reflect] attribute DOMString download;
    3131
    32     [PutForwards=value] readonly attribute DOMTokenList relList;
     32    [SameObject, PutForwards=value] readonly attribute DOMTokenList relList;
    3333};
    3434
  • trunk/Source/WebCore/html/HTMLButtonElement.idl

    r205839 r207319  
    4040    void setCustomValidity(DOMString? error);
    4141
    42     readonly attribute NodeList labels;
     42    [SameObject] readonly attribute NodeList labels;
    4343};
  • trunk/Source/WebCore/html/HTMLDataListElement.idl

    r131172 r207319  
    3232    Conditional=DATALIST_ELEMENT,
    3333] interface HTMLDataListElement : HTMLElement {
    34     readonly attribute HTMLCollection options;
     34    [SameObject] readonly attribute HTMLCollection options;
    3535};
  • trunk/Source/WebCore/html/HTMLDocument.idl

    r205280 r207319  
    3131    [Custom] void writeln(optional DOMString text);
    3232
     33    // FIXME: Should be [SameObject].
    3334    [Custom, Replaceable, Deletable] readonly attribute HTMLAllCollection all;
    3435
  • trunk/Source/WebCore/html/HTMLElement.idl

    r206723 r207319  
    3737    [Reflect] attribute DOMString webkitdropzone;
    3838    // FIXME: Support the standard HTML equivalent.
    39     // [PutForwards=value] readonly attribute DOMTokenList dropzone;
     39    // [SameObject, PutForwards=value] readonly attribute DOMTokenList dropzone;
    4040
    4141    [Reflect] attribute boolean hidden;
     
    5555    void blur();
    5656
    57     readonly attribute DOMStringMap dataset;
     57    [SameObject] readonly attribute DOMStringMap dataset;
    5858};
    5959
  • trunk/Source/WebCore/html/HTMLFieldSetElement.idl

    r205280 r207319  
    2525    readonly attribute DOMString type;
    2626
    27     readonly attribute HTMLFormControlsCollection elements;
     27    [SameObject] readonly attribute HTMLFormControlsCollection elements;
    2828
    2929    readonly attribute boolean         willValidate;
    30     readonly attribute ValidityState  validity;
     30    [SameObject] readonly attribute ValidityState validity;
    3131    readonly attribute DOMString       validationMessage;
    3232    boolean  checkValidity();
  • trunk/Source/WebCore/html/HTMLFormElement.idl

    r205280 r207319  
    3636    [Reflect] attribute DOMString target;
    3737
    38     readonly attribute HTMLFormControlsCollection elements;
     38    [SameObject] readonly attribute HTMLFormControlsCollection elements;
    3939    readonly attribute long length;
    4040
  • trunk/Source/WebCore/html/HTMLIFrameElement.idl

    r206723 r207319  
    2828    [Reflect] attribute DOMString name;
    2929
    30     [PutForwards=value] readonly attribute DOMTokenList sandbox;
     30    [SameObject, PutForwards=value] readonly attribute DOMTokenList sandbox;
    3131    [Reflect] attribute boolean allowFullscreen;
    3232
  • trunk/Source/WebCore/html/HTMLInputElement.idl

    r206723 r207319  
    7474    void setCustomValidity(DOMString? error);
    7575
    76     readonly attribute NodeList labels;
     76    [SameObject] readonly attribute NodeList labels;
    7777
    7878    void select();
  • trunk/Source/WebCore/html/HTMLKeygenElement.idl

    r197864 r207319  
    4545    void setCustomValidity(DOMString? error);
    4646
    47     readonly attribute NodeList labels;
     47    [SameObject] readonly attribute NodeList labels;
    4848};
    4949
  • trunk/Source/WebCore/html/HTMLLinkElement.idl

    r204259 r207319  
    3131    [Reflect] attribute DOMString rel;
    3232    [Reflect] attribute DOMString rev;
    33     [PutForwards=value] readonly attribute DOMTokenList sizes;
     33    [SameObject, PutForwards=value] readonly attribute DOMTokenList sizes;
    3434    [Reflect] attribute DOMString target;
    3535    [Reflect] attribute DOMString type;
     
    4040    readonly attribute StyleSheet sheet;
    4141
    42     [PutForwards=value] readonly attribute DOMTokenList relList;
     42    [SameObject, PutForwards=value] readonly attribute DOMTokenList relList;
    4343};
    4444
  • trunk/Source/WebCore/html/HTMLMapElement.idl

    r131172 r207319  
    2020
    2121interface HTMLMapElement : HTMLElement {
    22     readonly attribute HTMLCollection areas;
     22    [SameObject] readonly attribute HTMLCollection areas;
    2323    [Reflect] attribute DOMString name;
    2424};
  • trunk/Source/WebCore/html/HTMLMediaElement.idl

    r206983 r207319  
    9696
    9797    [Conditional=VIDEO_TRACK, MayThrowLegacyException] TextTrack addTextTrack(DOMString kind, optional DOMString label = "", optional DOMString language = "");
    98     [Conditional=VIDEO_TRACK] readonly attribute AudioTrackList audioTracks;
    99     [Conditional=VIDEO_TRACK] readonly attribute TextTrackList textTracks;
    100     [Conditional=VIDEO_TRACK] readonly attribute VideoTrackList videoTracks;
     98    [Conditional=VIDEO_TRACK, SameObject] readonly attribute AudioTrackList audioTracks;
     99    [Conditional=VIDEO_TRACK, SameObject] readonly attribute TextTrackList textTracks;
     100    [Conditional=VIDEO_TRACK, SameObject] readonly attribute VideoTrackList videoTracks;
    101101
    102102    [Reflect] attribute DOMString mediaGroup;
  • trunk/Source/WebCore/html/HTMLMeterElement.idl

    r206243 r207319  
    2727    attribute double high;
    2828    attribute double optimum;
    29     readonly attribute NodeList labels;
     29    [SameObject] readonly attribute NodeList labels;
    3030};
  • trunk/Source/WebCore/html/HTMLOutputElement.idl

    r197353 r207319  
    2424
    2525interface HTMLOutputElement : HTMLElement {
    26     [PutForwards=value] readonly attribute DOMTokenList htmlFor;
     26    [SameObject, PutForwards=value] readonly attribute DOMTokenList htmlFor;
    2727
    2828    readonly attribute HTMLFormElement form;
     
    3939    void setCustomValidity(DOMString? error);
    4040
    41     readonly attribute NodeList labels;
     41    [SameObject] readonly attribute NodeList labels;
    4242};
  • trunk/Source/WebCore/html/HTMLProgressElement.idl

    r206723 r207319  
    1919
    2020interface HTMLProgressElement : HTMLElement {
    21     [SetterMayThrowLegacyException] attribute  unrestricted double value;
    22     [SetterMayThrowLegacyException] attribute  unrestricted double max;
    23     readonly attribute  unrestricted double                position;
    24     readonly attribute  NodeList              labels;
     21    [SetterMayThrowLegacyException] attribute unrestricted double value;
     22    [SetterMayThrowLegacyException] attribute unrestricted double max;
     23    readonly attribute  unrestricted double position;
     24    [SameObject] readonly attribute NodeList labels;
    2525};
    2626
  • trunk/Source/WebCore/html/HTMLSelectElement.idl

    r206723 r207319  
    3535    readonly attribute DOMString type;
    3636
    37     readonly attribute HTMLOptionsCollection options;
     37    [SameObject] readonly attribute HTMLOptionsCollection options;
    3838    [SetterMayThrowLegacyException] attribute unsigned long length;
    3939
     
    5151    [ImplementedAs=removeByIndex] void remove(long index);
    5252
    53     readonly attribute HTMLCollection selectedOptions;
     53    [SameObject] readonly attribute HTMLCollection selectedOptions;
    5454    attribute long selectedIndex;
    5555
     
    6262    void setCustomValidity(DOMString? error); // FIXME: Argument should not be nullable.
    6363
    64     readonly attribute NodeList labels;
     64    [SameObject] readonly attribute NodeList labels;
    6565
    6666    attribute DOMString autocomplete;
  • trunk/Source/WebCore/html/HTMLTableElement.idl

    r206723 r207319  
    2424    [SetterMayThrowLegacyException] attribute HTMLTableSectionElement? tFoot;
    2525
    26     readonly attribute HTMLCollection rows;
    27     readonly attribute HTMLCollection tBodies;
     26    [SameObject] readonly attribute HTMLCollection rows;
     27    [SameObject] readonly attribute HTMLCollection tBodies;
    2828    [Reflect] attribute DOMString align;
    2929    [Reflect, TreatNullAs=EmptyString] attribute DOMString bgColor;
  • trunk/Source/WebCore/html/HTMLTableRowElement.idl

    r206723 r207319  
    2222    readonly attribute long rowIndex;
    2323    readonly attribute long sectionRowIndex;
    24     readonly attribute HTMLCollection cells;
     24    [SameObject] readonly attribute HTMLCollection cells;
    2525    [Reflect] attribute DOMString align;
    2626    [Reflect, TreatNullAs=EmptyString] attribute DOMString bgColor;
  • trunk/Source/WebCore/html/HTMLTableSectionElement.idl

    r206723 r207319  
    2626    [Reflect=charoff] attribute DOMString chOff;
    2727    [Reflect] attribute DOMString vAlign;
    28     readonly attribute HTMLCollection rows;
     28    [SameObject] readonly attribute HTMLCollection rows;
    2929    [MayThrowLegacyException] HTMLElement insertRow(optional long index = -1);
    3030    [MayThrowLegacyException] void deleteRow(long index);
  • trunk/Source/WebCore/html/HTMLTextAreaElement.idl

    r206723 r207319  
    4646    void setCustomValidity(DOMString? error);
    4747
    48     readonly attribute NodeList labels;
     48    [SameObject] readonly attribute NodeList labels;
    4949
    5050    void select();
  • trunk/Source/WebCore/page/Location.idl

    r206723 r207319  
    5959    readonly attribute USVString origin;
    6060
    61     // FIXME: Add support for SameObject
    62     [Unforgeable, CachedAttribute] readonly attribute FrozenArray<USVString> ancestorOrigins;
     61    [Unforgeable, SameObject] readonly attribute FrozenArray<USVString> ancestorOrigins;
    6362};
  • trunk/Source/WebCore/page/Navigator.idl

    r201970 r207319  
    2121    GenerateIsReachable=ImplFrame,
    2222] interface Navigator {
    23     readonly attribute DOMPluginArray plugins;
    24     readonly attribute DOMMimeTypeArray mimeTypes;
     23    [SameObject] readonly attribute DOMPluginArray plugins;
     24    [SameObject] readonly attribute DOMMimeTypeArray mimeTypes;
    2525    [Nondeterministic] readonly attribute boolean cookieEnabled;
    2626    [Nondeterministic] boolean javaEnabled();
Note: See TracChangeset for help on using the changeset viewer.