Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Side by Side Diff: third_party/WebKit/Source/bindings/IDLExtendedAttributes.md

Issue 2544253002: Update documentation for [CallWith] and [ConstructorCallWith] (Closed)
Patch Set: temp Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Blink IDL Extended Attributes 1 # Blink IDL Extended Attributes
2 2
3 [TOC] 3 [TOC]
4 4
5 ## Introduction 5 ## Introduction
6 6
7 The main interest in extended attributes are their _semantics_: Blink implements many more extended attributes than the Web IDL standard, to specify various beh avior. 7 The main interest in extended attributes are their _semantics_: Blink implements many more extended attributes than the Web IDL standard, to specify various beh avior.
8 8
9 The authoritative list of allowed extended attributes and values is [bindings/ID LExtendedAttributes.txt](https://code.google.com/p/chromium/codesearch#chromium/ src/third_party/WebKit/Source/bindings/IDLExtendedAttributes.txt). This is compl ete but not necessarily precise (there may be unused extended attributes or valu es), since validation is run on build, but coverage isn't checked. 9 The authoritative list of allowed extended attributes and values is [bindings/ID LExtendedAttributes.txt](https://code.google.com/p/chromium/codesearch#chromium/ src/third_party/WebKit/Source/bindings/IDLExtendedAttributes.txt). This is compl ete but not necessarily precise (there may be unused extended attributes or valu es), since validation is run on build, but coverage isn't checked.
10 10
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 543
544 * Valid values for attributes are: `GetterOnly`, `SetterOnly`, (no value) 544 * Valid values for attributes are: `GetterOnly`, `SetterOnly`, (no value)
545 * Valid values for methods are: (no value) 545 * Valid values for methods are: (no value)
546 546
547 For methods all calls are logged, and by default for attributes all access (call s to getter or setter) are logged, but this can be restricted to just read (gett er) or just write (setter). 547 For methods all calls are logged, and by default for attributes all access (call s to getter or setter) are logged, but this can be restricted to just read (gett er) or just write (setter).
548 548
549 ### [CallWith] _(m, a)_, [SetterCallWith] _(a)_, [ConstructorCallWith] _(i)_ 549 ### [CallWith] _(m, a)_, [SetterCallWith] _(a)_, [ConstructorCallWith] _(i)_
550 550
551 Summary: `[CallWith]` indicates that the bindings code calls the Blink implement ation with additional information. 551 Summary: `[CallWith]` indicates that the bindings code calls the Blink implement ation with additional information.
552 552
553 Each value changes the signature of the Blink methods by adding an additional pa rameter to the head of the parameter list, such as `&state` for `[CallWith=Scrip tState]`. 553 Each value changes the signature of the Blink methods by adding an additional pa rameter to the head of the parameter list, such as `ScriptState*` for `[CallWith =ScriptState]`.
554
555 Multiple values can be specified e.g. `[CallWith=ScriptState|ScriptArguments]`. The order of the values in the IDL file doesn't matter: the generated parameter list is always in a fixed order (specifically `&state`, `scriptContext`, `script Arguments.release()`, if present, corresponding to `ScriptState`, `ScriptExecuti onContext`, `ScriptArguments`, respectively).
556 554
557 There are also three rarely used values: `CurrentWindow`, `EnteredWindow`, `This Value`. 555 There are also three rarely used values: `CurrentWindow`, `EnteredWindow`, `This Value`.
558 556
559 `[SetterCallWith]` applies to attributes, and only affects the signature of the setter; this is only used in Location.idl, with `CurrentWindow&EnteredWindow`. 557 `[SetterCallWith]` applies to attributes, and only affects the signature of the setter; this is only used in Location.idl, with `CurrentWindow&EnteredWindow`.
560 558
561 Syntax: 559 #### [CallWith=ScriptState] _(m, a*)_
562 `CallWith=ScriptState|ScriptExecutionContext|ScriptArguments|CurrentWindow|Enter edWindow|ThisValue`
563 560
564 #### [CallWith=ScriptState] _(m, a*)_
565 `[CallWith=ScriptState]` is used in a number of places for methods. 561 `[CallWith=ScriptState]` is used in a number of places for methods.
566 562 ScriptState holds all information about script execution.
567 `[CallWith=ScriptState]` _can_ be used for attributes, but is not used in real I DL files. 563 You can retrieve Frame, ExcecutionContext, v8::Context, v8::Isolate etc
564 from ScriptState.
568 565
569 IDL example: 566 IDL example:
570 567
571 ```webidl 568 ```webidl
572 interface Example { 569 interface Example {
573 [CallWith=ScriptState] attribute DOMString str; 570 [CallWith=ScriptState] attribute DOMString str;
574 [CallWith=ScriptState] DOMString func(boolean a, boolean b); 571 [CallWith=ScriptState] DOMString func(boolean a, boolean b);
575 }; 572 };
576 ``` 573 ```
577 574
578 C++ Blink function signatures: 575 C++ Blink function signatures:
579 576
580 ```c++ 577 ```c++
581 String Example::str(ScriptState* state); 578 String Example::str(ScriptState* state);
582 String Example::func(ScriptState* state, bool a, bool b); 579 String Example::func(ScriptState* state, bool a, bool b);
583 ``` 580 ```
584 581
585 #### [CallWith=ExecutionContext] _(m,a)_ 582 Be careful when you use `[CallWith=ScriptState]`.
583 You should not store the passed-in ScriptState on a DOM object (using RefPtr<Scr iptState>).
584 This is because if the stored ScriptState is used by some method called by a dif ferent
585 world (note that the DOM object is shared among multiple worlds), it leaks the S criptState
586 to the world. ScriptState must be carefully maintained in a way that doesn't lea k
587 to another world.
588
589 #### [CallWith=ExecutionContext] _(m,a)_ _deprecated_
590
591 `[CallWith=ExecutionContext]` is a less convenient version of `[CallWith=ScriptS tate]`
592 because you can just retrieve ExecutionContext from ScriptState.
593 Use `[CallWith=ScriptState]` instead.
586 594
587 IDL example: 595 IDL example:
588 596
589 ```webidl 597 ```webidl
590 interface Example { 598 interface Example {
591 [CallWith=ExecutionContext] attribute DOMString str; 599 [CallWith=ExecutionContext] attribute DOMString str;
592 [CallWith=ExecutionContext] DOMString func(boolean a, boolean b); 600 [CallWith=ExecutionContext] DOMString func(boolean a, boolean b);
593 }; 601 };
594 ``` 602 ```
595 603
596 C++ Blink function signatures: 604 C++ Blink function signatures:
597 605
598 ```c++ 606 ```c++
599 String Example::str(ExecutionContext* context); 607 String Example::str(ExecutionContext* context);
600 String Example::func(ExecutionContext* context, bool a, bool b); 608 String Example::func(ExecutionContext* context, bool a, bool b);
601 ``` 609 ```
602 610
603 You can retrieve the document and frame from a `ExecutionContext*`.
604
605 #### [CallWith=ScriptArguments] _(m)_
606
607 IDL example:
608
609 ```webidl
610 interface Example {
611 [CallWith=ScriptState] DOMString func(boolean a, boolean b);
612 };
613 ```
614
615 C++ Blink function signature:
616
617 ```c++
618 String Example::func(ScriptArguments* arguments, bool a, bool b);
619 ```
620
621 _(rare CallWith values)_ 611 _(rare CallWith values)_
622 612
623 #### [CallWith=CurrentWindow&EnteredWindow] _(m, a)_ 613 #### [CallWith=CurrentWindow&EnteredWindow] _(m, a)_
624 614
625 `EnteredWindow` is the `Window` object that corresponds to the responsible docum ent of the entry settings object. 615 `EnteredWindow` is the `Window` object that corresponds to the responsible docum ent of the entry settings object.
626 616
627 #### [CallWith=ThisValue] _(m)_ 617 #### [CallWith=ThisValue] _(m)_
628 618
629 `[CallWith=ThisValue]` only applies to methods in callback interfaces, and is us ed in only one place (CSSVariablesMapForEachCallback.idl). 619 `[CallWith=ThisValue]` only applies to methods in callback interfaces, and is us ed in only one place (CSSVariablesMapForEachCallback.idl).
630 620
(...skipping 17 matching lines...) Expand all
648 638
649 #### [ConstructorCallWith] _(i)_ 639 #### [ConstructorCallWith] _(i)_
650 640
651 Analogous to `[CallWith]`, but applied to interfaces with constructors, and take s different values. 641 Analogous to `[CallWith]`, but applied to interfaces with constructors, and take s different values.
652 642
653 If `[Constructor]` is specified on an interface, `[ConstructorCallWith]` can be also specified to refine the arguments passed to the callback: 643 If `[Constructor]` is specified on an interface, `[ConstructorCallWith]` can be also specified to refine the arguments passed to the callback:
654 644
655 ```webidl 645 ```webidl
656 [ 646 [
657 Constructor(float x, float y, DOMString str), 647 Constructor(float x, float y, DOMString str),
658 ConstructorCallWith=Document|ExecutionContext, 648 ConstructorCallWith=ExecutionContext,
659 ] 649 ]
660 interface XXX { 650 interface XXX {
661 ... 651 ...
662 }; 652 };
663 ``` 653 ```
664 654
665 Then XXX::create(...) can have the following signature 655 Then XXX::create(...) can have the following signature
666 656
667 *** note 657 *** note
668 **FIXME:** outdated 658 **FIXME:** outdated
669 *** 659 ***
670 660
671 ```c++ 661 ```c++
672 PassRefPtr<XXX> XXX::create(ScriptExecutionContext* context, ScriptState* state, float x, float y, String str) 662 PassRefPtr<XXX> XXX::create(ExecutionContext* context, float x, float y, String str)
673 { 663 {
674 ...; 664 ...;
675 } 665 }
676 ``` 666 ```
677 667
678 You can retrieve document or frame from ScriptExecutionContext. 668 Be careful when you use `[ConstructorCallWith=ScriptState]`.
669 You should not store the passed-in ScriptState on a DOM object (using RefPtr<Scr iptState>).
670 This is because if the stored ScriptState is used by some method called by a dif ferent
671 world (note that the DOM object is shared among multiple worlds), it leaks the S criptState
672 to the world. ScriptState must be carefully maintained in a way that doesn't lea k
673 to another world.
679 674
680 ### [Custom] _(i, m, s, a, f)_ 675 ### [Custom] _(i, m, s, a, f)_
681 676
682 Summary: They allow you to write bindings code manually as you like: full bindin gs for methods and attributes, certain functions for interfaces. 677 Summary: They allow you to write bindings code manually as you like: full bindin gs for methods and attributes, certain functions for interfaces.
683 678
684 Custom bindings are _strongly discouraged_. They are likely to be buggy, a sourc e of security holes, and represent a significant maintenance burden. Before usin g `[Custom]`, you should doubly consider if you really need custom bindings. You are recommended to modify code generators and add specialized extended attribut es or special cases if necessary to avoid using `[Custom]`. 679 Custom bindings are _strongly discouraged_. They are likely to be buggy, a sourc e of security holes, and represent a significant maintenance burden. Before usin g `[Custom]`, you should doubly consider if you really need custom bindings. You are recommended to modify code generators and add specialized extended attribut es or special cases if necessary to avoid using `[Custom]`.
685 680
686 Usage: `[Custom]` can be specified on methods or attributes. `[Custom=CallEpilog ue]` can be specified on methods. `[Custom=Getter]` and `[Custom=Setter]` can be specified on attributes. `[Custom=A|B]` can be specified on interfaces, with va rious values (see below). 681 Usage: `[Custom]` can be specified on methods or attributes. `[Custom=CallEpilog ue]` can be specified on methods. `[Custom=Getter]` and `[Custom=Setter]` can be specified on attributes. `[Custom=A|B]` can be specified on interfaces, with va rious values (see below).
687 682
688 On read only attributes (that are not `[Replaceable]`), `[Custom]` is equivalent to `[Custom=Getter]` (since there is no setter) and `[Custom=Getter]` is prefer red. 683 On read only attributes (that are not `[Replaceable]`), `[Custom]` is equivalent to `[Custom=Getter]` (since there is no setter) and `[Custom=Getter]` is prefer red.
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 { 815 {
821 ...; 816 ...;
822 } 817 }
823 818
824 v8::Handle<v8::Array> V8XXX::namedPropertyEnumerator(const v8::AccessorInfo& inf o) 819 v8::Handle<v8::Array> V8XXX::namedPropertyEnumerator(const v8::AccessorInfo& inf o)
825 { 820 {
826 ...; 821 ...;
827 } 822 }
828 ``` 823 ```
829 824
830 #### [Custom=LegacyCallAsFunction] _(i) _deprecated__ 825 #### [Custom=LegacyCallAsFunction] _(i) _deprecated_
831 826
832 Summary: `[Custom=LegacyCallAsFunction]` allows you to write custom bindings for call(...) of a given interface. 827 Summary: `[Custom=LegacyCallAsFunction]` allows you to write custom bindings for call(...) of a given interface.
833 828
834 Usage: `[Custom=LegacyCallAsFunction]` can be specified on interfaces: 829 Usage: `[Custom=LegacyCallAsFunction]` can be specified on interfaces:
835 830
836 ```webidl 831 ```webidl
837 [ 832 [
838 Custom=LegacyCallAsFunction, 833 Custom=LegacyCallAsFunction,
839 ] interface XXX { 834 ] interface XXX {
840 ... 835 ...
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 m_attributeDirty = true; 1372 m_attributeDirty = true;
1378 } 1373 }
1379 1374
1380 // Called by generated binding code 1375 // Called by generated binding code
1381 bool Object::isAttributeDirty() 1376 bool Object::isAttributeDirty()
1382 { 1377 {
1383 return m_attributeDirty; 1378 return m_attributeDirty;
1384 } 1379 }
1385 1380
1386 // Called by generated binding code if no value cached or isAttributeDirty() ret urns true 1381 // Called by generated binding code if no value cached or isAttributeDirty() ret urns true
1387 ScriptValue Object::attribute(ScriptExecutionContext* context) 1382 ScriptValue Object::attribute(ExecutionContext* context)
1388 { 1383 {
1389 m_attributeDirty = false; 1384 m_attributeDirty = false;
1390 return convertDataToScriptValue(m_data); 1385 return convertDataToScriptValue(m_data);
1391 } 1386 }
1392 ``` 1387 ```
1393 1388
1394 ### [CheckSecurity] _(i, m, a)_ 1389 ### [CheckSecurity] _(i, m, a)_
1395 1390
1396 ### [DoNotCheckSecurity] _(m, a)_ 1391 ### [DoNotCheckSecurity] _(m, a)_
1397 1392
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1627 Copyright (C) 2009 Apple Inc. All rights reserved. 1622 Copyright (C) 2009 Apple Inc. All rights reserved.
1628 1623
1629 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1624 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1630 1625
1631 1. Redistributions of source code must retain the above copyright notice, this l ist of conditions and the following disclaimer. 1626 1. Redistributions of source code must retain the above copyright notice, this l ist of conditions and the following disclaimer.
1632 1627
1633 2. Redistributions in binary form must reproduce the above copyright notice, thi s list of conditions and the following disclaimer in the documentation and/or ot her materials provided with the distribution. 1628 2. Redistributions in binary form must reproduce the above copyright notice, thi s list of conditions and the following disclaimer in the documentation and/or ot her materials provided with the distribution.
1634 1629
1635 THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS “AS IS” AND ANY EXP RESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIE S OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, I NCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMI TED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFI TS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHE THER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI BILITY OF SUCH DAMAGE. 1630 THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS “AS IS” AND ANY EXP RESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIE S OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, I NCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMI TED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFI TS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHE THER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI BILITY OF SUCH DAMAGE.
1636 *** 1631 ***
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698