Confirmed users
512
edits
| Line 232: | Line 232: | ||
"DOM interfaces", approximately, are how web content communicates with Gecko. There's a lot more to the DOM than that, but the longer discussion is beyond the scope of this document. DOM interfaces are defined in [https://developer.mozilla.org/en/XPIDL IDL], which comprises both a foreign function interface (ffi) and object model (OM) between JavaScript and C++. Again, there are more details that could be discussed here which are beyond the scope of this document. Let's learn a bit of IDL by example. | "DOM interfaces", approximately, are how web content communicates with Gecko. There's a lot more to the DOM than that, but the longer discussion is beyond the scope of this document. DOM interfaces are defined in [https://developer.mozilla.org/en/XPIDL IDL], which comprises both a foreign function interface (ffi) and object model (OM) between JavaScript and C++. Again, there are more details that could be discussed here which are beyond the scope of this document. Let's learn a bit of IDL by example. | ||
The very simple vibration API is exposed to web content through [https://mxr.mozilla.org/mozilla-central/source/dom/interfaces/base/nsIDOMNavigator.idl# | The very simple vibration API is exposed to web content through [https://mxr.mozilla.org/mozilla-central/source/dom/interfaces/base/nsIDOMNavigator.idl?rev=b405f493e834#80 an IDL interface]. | ||
<pre> | <pre> | ||
[implicit_jscontext] | [implicit_jscontext] | ||
void mozVibrate(in jsval aPattern); | void mozVibrate(in jsval aPattern); | ||
</pre> | </pre> | ||
The <code>jsval</code> argument indicates that <code>mozVibrate</code> (our vendor-prefixed implementation of the vibration specification) accepts any JS value. Details of working with jsvals are beyond the scope of this document. The IDL compiler generates a C++ interface that's implemented in [https://mxr.mozilla.org/mozilla-central/source/dom/base/Navigator.cpp# | The <code>jsval</code> argument indicates that <code>mozVibrate</code> (our vendor-prefixed implementation of the vibration specification) accepts any JS value. Details of working with jsvals are beyond the scope of this document. The IDL compiler generates a C++ interface that's implemented in [https://mxr.mozilla.org/mozilla-central/source/dom/base/Navigator.cpp?rev=af40e0f0ce26#775 the Navigator class] | ||
<pre> | <pre> | ||
NS_IMETHODIMP | NS_IMETHODIMP | ||