0

From what I understand so far,

WebIDL plays as the same rule as DOM does.

The original DOMs (before WebIDL) were created by OMG IDL. However, this IDL is not specified for Javascript.

Hence, W3C creates webidl which is kinda subset of OMG IDL and it provides more flexibility to JS to create API than before.

Please let me know if I am incorrect here.

The followings are my questions:

  1. DOM is provided for JS developer to access markup language. Does WebIDL act as DOM do? Does it provide the interface for JS developer to access markup language? Does WebIDL do something else?

  2. Does WebIDL play different rules in Firefox browser and b2g (Firefox OS)?

  3. Why the system has better performance after using webidl?

  4. For DOM, the code flow should be Javascript--->DOM--->HTML For WebIDL, will this flow change? or WebIDL can access C++ code directly?

  5. Can I use WebIDL to create an interface to access to CSS?

  6. JS language binding appendices <----what do appendices mean?

Thanks for the reply

Sam
  • 4,521
  • 13
  • 46
  • 81

1 Answers1

2

WebIDL is not a replacement for the DOM. Instead, it is a language used for specifying APIs, including the most recent version of the DOM API as well as other recent web standards.

The DOM4 standard contains WebIDL code for all of the interfaces and types it defines. For example, take a look at the WebIDL definition of the DOM ParentNode interface. It's just a format for listing the properties and methods of this interface. The IDL lists the name of each method, its return type and parameters, and a few other pieces of information about it. When you write document.body.childElementCount you are accessing a DOM API, and you can read the WebIDL code in the DOM standard to find out what type of data that API will return.

If you are a web developer, WebIDL doesn't change how you write your code at all, and it doesn't necessarily change anything about how browsers run your code. It's just a way for browser developers to specify interfaces in a standard, language-independent way.

"Appendices" (plural of "appendix") are sections or chapters of a document that are appended after the main content. A "JS language binding appendix" is an addition to an IDL spec that defines how the IDL interfaces should look when accessed by JavaScript programs.

mbrubeck
  • 564
  • 3
  • 7
  • Hi Matt, Thanks for the reply. By reading your post, I have some further questions sill puzzle me. 1. Be more specified, Can I say that before DOM 4, some DOMs are written by OMG IDL and some are written by WebIDL. After DOM4, 2. Since WebIDL is an IDL language that used for accessing markup language, how does it work with C++ code? 3. Can you provide an example about JavaScript appendix? Thanks! – Sam Feb 13 '14 at 00:34
  • 1. I don't know exactly when W3C specs migrated from OMGIDL to WebIDL, and I suspect it happened at different times for different specs. 2. In Gecko, a WebIDL processor reads IDL files and generates [bindings](https://developer.mozilla.org/en-US/docs/Mozilla/WebIDL_bindings) for both JavaScript and Gecko-internal C++ code. 3. [DOM Level 3 Core Appendix H](http://www.w3.org/TR/DOM-Level-3-Core/ecma-script-binding.html). – mbrubeck Feb 13 '14 at 00:55
  • About the point2 you reply, so WebIDL acts differently in browser and OS? Can you explain why WebIDL has better performance than the original IDL? – Sam Feb 13 '14 at 01:44
  • Again, WebIDL and OMGIDL are not programming languages. You don't "run" code written in IDL. They are specification languages, used for documenting web standards. They do not have "performance." They do not "act" like anything in a browser or OS. The only programmers who use WebIDL and OMGIDL are the developers like myself who build web browsers, who must translate interfaces specified in IDL into implementation code written in C++ or JavaScript. Only the C++ or JS implementation code actually runs on your computer. The IDL is used only at build time, not at run time. – mbrubeck Feb 14 '14 at 01:04