Skip to content

Commit 112fff4

Browse files
committed
[cssom] add support for partial interfaces on existing interfaces and extended attributes on members
1 parent 6afd3d5 commit 112fff4

7 files changed

Lines changed: 165 additions & 86 deletions

File tree

cssom/Overview.html

Lines changed: 75 additions & 38 deletions
Large diffs are not rendered by default.

cssom/README

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ directory that contains this README:
6666
% cd $CSSOM_TOOLS
6767

6868
# Fetch node.js 0.10.0
69-
% wget http://nodejs.org/dist/v0.10.0/ $CSSOM_TOOLS/node-v0.10.0.pkg
69+
% wget http://nodejs.org/dist/v0.10.5/node-v0.10.5.pkg node-v0.10.5.pkg
7070

7171
# Install node.js 0.10.0
72-
% open $CSSOM_TOOLS/node-v0.10.0.pkg
72+
% open $CSSOM_TOOLS/node-v0.10.5.pkg
7373

7474
# Fetch html5.js
7575
% git clone http://dinhe.net/~aredridel/projects/js/html5.git/ $CSSOM_TOOLS/html5.js
@@ -104,7 +104,6 @@ TO DO
104104
* Enumerate constructors in a manner similar to attributes/operations.
105105
* Perform keyword substitution in constructor documentation.
106106
* Generate typedef and implements definitions.
107-
* Generate extended attributes, e.g., PutForwards, NoInterfaceObject, etc.
108107
* Generate setters, getters (not presently used in CSSOM IDL definitions).
109108

110109
2. Content Related

cssom/cssom-generate.js

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@
137137
return formatIDLDef ( args );
138138
} else if ( method == 'idlDocMembers' ) {
139139
return formatIDLDocMembers ( args );
140+
} else if ( method == 'idlPartials' ) {
141+
return formatIDLPartials ( args );
140142
} else {
141143
return '';
142144
}
@@ -146,6 +148,7 @@
146148
s += formatIDLDoc ( args );
147149
s += formatIDLDef ( args );
148150
s += formatIDLDocMembers ( args );
151+
s += formatIDLPartials ( args );
149152
return s;
150153
}
151154
function findIDL(name) {
@@ -188,7 +191,7 @@
188191
s += eol;
189192
s += eltStart ( 'pre', [ newAttr ( 'class', 'idl' ) ], false );
190193
s += eltStart ( 'span', [ newAttr ( 'class', 'idlInterface' ), newAttr ( 'id', generateIDLDefinitionID ( def ) ) ], false );
191-
s += formatIDLExtendedAttributes ( def, args );
194+
s += formatIDLExtendedAttributes ( def, args, true );
192195
if ( partial ) {
193196
s += 'partial ';
194197
}
@@ -222,7 +225,7 @@
222225
s += eltEnd ( 'pre', true );
223226
return s;
224227
}
225-
function formatIDLExtendedAttributes(def,args) {
228+
function formatIDLExtendedAttributes(def,args,useEol) {
226229
var s = '';
227230
var numExposed = 0;
228231
for ( var i in def.extAttrs ) {
@@ -257,10 +260,14 @@
257260
}
258261
}
259262
if ( numExposed > 0 ) {
260-
if ( numOutput > 1 ) {
261-
s += eol;
263+
if (useEol) {
264+
if ( numOutput > 1 ) {
265+
s += eol;
266+
}
267+
s += ']' + eol;
268+
} else {
269+
s += ']' + ' ';
262270
}
263-
s += ']' + eol;
264271
}
265272
return s;
266273
}
@@ -350,6 +357,7 @@
350357
var s = '';
351358
s += eltStart ( 'span', [ newAttr ( 'class', 'idlConst' ) ], false );
352359
s += ' ';
360+
s += formatIDLExtendedAttributes ( mem, args, false );
353361
s += 'const ';
354362
s += formatIDLConstType ( def, mem, mem.idlType, false, args );
355363
s += ' ';
@@ -372,14 +380,14 @@
372380
var n = mem.name;
373381
var s = '';
374382
s += eltStart ( 'span', [ newAttr ( 'class', 'idlAttribute' ) ], false );
375-
s += ' ';
383+
s += ' ';
384+
s += formatIDLExtendedAttributes ( mem, args, false );
376385
if ( mem.stringifier ) {
377-
s += ' stringifier';
386+
s += 'stringifier ';
378387
}
379388
if ( mem.readonly ) {
380-
s += ' readonly';
389+
s += 'readonly ';
381390
}
382-
s += ' ';
383391
s += 'attribute ';
384392
s += formatIDLAttrType ( def, mem, mem.idlType, false, args );
385393
s += ' ';
@@ -451,6 +459,7 @@
451459
var s = '';
452460
s += eltStart ( 'span', [ newAttr ( 'class', 'idlMethod' ) ], false );
453461
s += ' ';
462+
s += formatIDLExtendedAttributes ( mem, args, false );
454463
s += formatIDLOperType ( def, mem, mem.idlType, false, args );
455464
s += ' ';
456465
s += eltStart ( 'span', [ newAttr ( 'class', 'idlMethName' ) ], false );
@@ -912,6 +921,33 @@
912921
function formatIDLMemberNameAsLink(def,mem,args) {
913922
return formatAsLink ( mem.name, getIDLMemberCSSClass ( def, mem, args ), generateIDRef ( generateIDLMemberID ( def, mem, args ) ), args );
914923
}
924+
function findIDLPartials(name) {
925+
var partials = [];
926+
for ( var i in idl ) {
927+
var d = idl[i];
928+
if ( d.type != 'partialinterface' ) {
929+
continue;
930+
} else if ( !! d.name && ( d.name == name ) ) {
931+
partials.push(d);
932+
}
933+
}
934+
return partials;
935+
}
936+
function formatIDLPartial(d, args) {
937+
var s = '';
938+
s += formatIDLDefinitionDoc ( d, args );
939+
s += formatIDLDefinition ( d, args );
940+
s += formatIDLDefinitionDocMembers ( d, args );
941+
return s;
942+
}
943+
function formatIDLPartials(args) {
944+
var s = '';
945+
var partials = findIDLPartials ( args[0] );
946+
for ( var i in partials ) {
947+
s += formatIDLPartial ( partials[i], args );
948+
}
949+
return s;
950+
}
915951
function newAttr(n,v) {
916952
return { nodeName: n, nodeValue: v };
917953
}

cssom/cssom-source

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,41 +1535,6 @@
15351535

15361536
<!--{@idl(CSSStyleDeclaration)}-->
15371537

1538-
<p>If the user agent supports the 'float' CSS property, the following partial interface
1539-
applies.
1540-
1541-
<pre class=idl>partial interface CSSStyleDeclaration {
1542-
[TreatNullAs=EmptyString] attribute DOMString cssFloat;
1543-
};</pre>
1544-
1545-
<p>The <code><dfn title=dom-CSSStyleDeclaration-cssFloat>cssFloat</dfn></code>
1546-
attribute, on getting, must return the result of invoking
1547-
<code title=dom-CSSStyleDeclaration-getPropertyValue>getPropertyValue()</code> with
1548-
"float" as argument. On setting, the attribute must invoke
1549-
<code title=dom-CSSStyleDeclaration-setProperty>setProperty()</code> with
1550-
"float" as first argument, as second argument the given value, and no third argument.
1551-
Any exceptions thrown must be re-thrown.
1552-
1553-
<p>For each CSS property <var>property</var> that the user agent supports, except for
1554-
the 'float' property, and except for open-ended sets of properties, the following
1555-
partial interface applies where <var>attribute</var> is obtained by running the
1556-
<span>CSS property to IDL attribute</span> algorithm for <var>property</var>.
1557-
1558-
<pre class=idl>partial interface CSSStyleDeclaration {
1559-
[TreatNullAs=EmptyString] attribute DOMString <var>attribute</var>;
1560-
};</pre>
1561-
1562-
<p>Getting the <var>attribute</var> attribute must return the result of invoking
1563-
<code title=dom-CSSStyleDeclaration-getPropertyValue>getPropertyValue()</code> with as
1564-
argument the result of running the <span>IDL attribute to CSS property</span>
1565-
algorithm for <var>attribute</var>.</p>
1566-
1567-
<p>Setting the <var>attribute</var> attribute must invoke
1568-
<code title=dom-CSSStyleDeclaration-setProperty>setProperty()</code> with as
1569-
first argument the result of running the <span>IDL attribute to CSS property</span>
1570-
algorithm for <var>attribute</var>, as second argument the given value, and no third argument. Any
1571-
exceptions thrown must be re-thrown.</p>
1572-
15731538
<p>The <dfn>CSS property to IDL attribute</dfn> algorithm for <var>property</var> is as
15741539
follows:</p>
15751540

cssom/cssom.idl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "CSSRule.idl"
77
#include "CSSRuleList.idl"
88
#include "CSSStyleDeclaration.idl"
9+
#include "CSSStyleDeclarationProperties.idl"
910
#include "CSSStyleRule.idl"
1011
#include "CSSStyleSheet.idl"
1112
#include "Document.idl"

cssom/data/xrefs/css/cssom.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"css rule": "rule",
1616
"css style sheet": "css-style-sheet",
1717
"document style sheets": "document-style-sheets",
18-
"dom-cssstyledeclaration-cssfloat": "dom-cssstyledeclaration-cssfloat",
1918
"enable a style sheet set": "enable-a-style-sheet-set",
2019
"enabled style sheet set": "enabled-style-sheet-set",
2120
"escape a character": "escape-a-character",
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
[Documentation=
3+
"<p>If the user agent supports the 'float' CSS property, the following partial interface applies.</p>"
4+
]
5+
partial interface CSSStyleDeclaration {
6+
7+
[Documentation=
8+
"<p>The <code>cssFloat</code>\
9+
attribute, on getting, must return the result of invoking\
10+
<code title=dom-CSSStyleDeclaration-getPropertyValue>getPropertyValue()</code> with\
11+
<code>'float'</code> as argument. On setting, the attribute must invoke\
12+
<code title=dom-CSSStyleDeclaration-setProperty>setProperty()</code> with\
13+
<code>'float'</code> as first argument, as second argument the given value, and no third argument.\
14+
Any exceptions thrown must be re-thrown.",
15+
TreatNullAs=EmptyString
16+
]
17+
attribute DOMString cssFloat;
18+
};
19+
20+
21+
[Documentation=
22+
"<p>For each CSS property <var>property</var> that the user agent supports, except for\
23+
the 'float' property, the following partial interface applies where <var>attribute</var>\
24+
is obtained by running the <span>CSS property to IDL attribute</span> algorithm for\
25+
<var>property</var>.</p>"
26+
]
27+
partial interface CSSStyleDeclaration {
28+
29+
[Documentation=
30+
"<p>Getting the <var>attribute</var> attribute must return the result of invoking\
31+
<code title=dom-CSSStyleDeclaration-getPropertyValue>getPropertyValue()</code> with as\
32+
argument the result of running the <span>IDL attribute to CSS property</span>\
33+
algorithm for <var>attribute</var>.</p>\
34+
<p>Setting the <var>attribute</var> attribute must invoke\
35+
<code title=dom-CSSStyleDeclaration-setProperty>setProperty()</code> with as\
36+
first argument the result of running the <span>IDL attribute to CSS property</span>\
37+
algorithm for <var>attribute</var>, as second argument the given value, and no third argument. Any\
38+
exceptions thrown must be re-thrown.</p>",
39+
TreatNullAs=EmptyString
40+
]
41+
attribute DOMString attribute;
42+
};

0 commit comments

Comments
 (0)