mozilla

比较版本

Firefox OS架构

更改版本

修订版 615965:

由 ReyCG 在 进行的修订 615965

修订版 615979:

由 ReyCG 在 进行的修订 615979

标题:
Firefox OS架构
Firefox OS架构
网址缩略名:
Firefox_OS/Platform/Architecture
Firefox_OS/Platform/Architecture
标签:
"Guide", "Firefox OS", "B2G", "Architecture", "IPDL", "IPC"
"Guide", "Firefox OS", "B2G", "Architecture", "IPDL", "IPC"
内容:

修订版 615965
修订版 615979
n201        <strong>注意:</strong>&nbsp;<code>mediaserver</code>&nbsp;进n201        <strong>注意:</strong>&nbsp;<code>mediaserver</code>&nbsp;进
>程时一个临时的Firefox OS组件, 对我们初始的开发工作帮助,但最终会离开。然而在 Firefox OS 2.0 之>程时一个临时的Firefox OS组件, 对我们初始的开发有帮助,但最终会离开。然而在 Firefox OS 2.0 之前,可能
>前,可能不会发生。>不会发生。
n208      The <code>netd</code> process is used to configure network n208      &nbsp;<code>netd</code>&nbsp;进程用来对网络接口进行配置。
>interfaces. 
n214      The <code>wpa_supplicant</code> process is the standard UNIn214      &nbsp;<code>wpa_supplicant</code>&nbsp;进程时标准的 UNIX样式的守护进程,会
>X-style daemon that handles connectivity with WiFi access points.>处理 WIFI 的连接。
n220      The dbus-daemon implements <a href="http://www.freedesktop.n220      &nbsp;dbus-daemon 实现了&nbsp;<a href="http://www.freedesktop.
>org/wiki/Software/dbus" title="http://www.freedesktop.org/wiki/So>org/wiki/Software/dbus" title="http://www.freedesktop.org/wiki/So
>ftware/dbus">D-Bus</a>, a message bus system that Firefox OS uses>ftware/dbus">D-Bus</a>( DBus 是指Firefox OS 用于蓝牙通信的一种消息总线系统)。
> for Bluetooth communication. 
221    </p>
221    </p>222    <p>
222    <h2 id="Gecko">223      &nbsp;
224    </p>
225    <h2 id="Gecko" style="margin-bottom: 20px; line-height: 30px;
 >">
n226      <a href="/en-US/docs/Gecko" title="/en-US/docs/Gecko">Geckon229      <a href="https://developer.mozilla.org/en-US/docs/Gecko" ti
></a>, as previously mentioned, is the implementation of web stand>tle="/en-US/docs/Gecko">Gecko</a>,正如之前提到的,是对 web标准(&nbsp;<a href=
>ards (<a href="/en-US/docs/HTML" title="/en-US/docs/HTML">HTML</a>"https://developer.mozilla.org/en-US/docs/HTML" style="text-decor
>>, <a href="/en-US/docs/CSS" title="/en-US/docs/CSS">CSS</a>, and>ation: underline;" title="/en-US/docs/HTML">HTML</a>,&nbsp;<a hre
> <a href="/en-US/docs/JavaScript" title="/en-US/docs/JavaScript">>f="https://developer.mozilla.org/en-US/docs/CSS" title="/en-US/do
>JavaScript</a>) that is used to implement everything the user see>cs/CSS">CSS</a>, and<a href="https://developer.mozilla.org/en-US/
>s on Firefox OS.>docs/JavaScript" title="/en-US/docs/JavaScript">JavaScript</a>)的实
 >现,用于实现用户在Firefox OS 上看到的一切界面。
230    </p>
231    <div class="note">
232      <p>
233        <b>注意:</b>&nbsp;您可以使用&nbsp;<a href="http://dxr.mozilla.or
 >g/" style="text-decoration: underline;">http://dxr.mozilla.org</a
 >>&nbsp;来查找Gecko代码库。这个网站非常有趣,并且提供了较好的参照特性,但是代码库的数量有限。或者您可以尝试下传统的&n
 >bsp;&nbsp;&nbsp;<a href="http://mxr.mozilla.org/">http://mxr.mozi
 >lla.org</a>&nbsp;,其中会包括更多的Mozilla 项目。&nbsp;
234      </p>
235    </div>
236    <h3 id="Gecko_files_related_to_Firefox_OS" style="line-height
 >: 24px; letter-spacing: normal;">
237      与Firefox OS 相关联的 Gecko 文件
238    </h3>
239    <h4 id="b2g.2F" style="line-height: 18px; letter-spacing: nor
 >mal;">
240      b2g/
241    </h4>
227    </p>242    <p>
228    <h3 id="Processing_input_events">243      &nbsp;b2g 文件夹会包含了一些主要的Firefox OS 相关的功能。.
244    </p>
245    <h5 id="b2g.2Fchrome.2Fcontent">
246      b2g/chrome/content
247    </h5>
248    <p>
249      包含了在system app 之上运行的 &nbsp;Javascript 文件。&nbsp;
250    </p>
251    <h5 id="b2g.2Fchrome.2Fcontent.2Fshell.html">
252      b2g/chrome/content/shell.html
253    </h5>
254    <p>
255      Gaia的入口 &nbsp;— system app的html。&nbsp;<code>shell.html</cod
 >e>&nbsp;会加载&nbsp;<code>settings.js 和</code>&nbsp;<code>shell.js</
 >code>:
256    </p>
257    <pre class="brush: html language-html" data-number="" style="
 >padding-top: 1em; padding-right: 0px; padding-bottom: 1em; paddin
 >g-left: 30px; border-left-width: 6px; font-family: Consolas, Mona
 >co, 'Andale Mono', monospace; font-size: 14px; background-image: 
 >url(https://developer.cdn.mozilla.net/media/redesign/img/blueprin
 >t-dark.png); background-color: rgba(234, 239, 242, 0.246094); tex
 >t-shadow: none; direction: ltr; text-align: left; white-space: no
 >rmal; word-break: normal; -webkit-hyphens: none; background-posit
 >ion: 50% 0%; background-repeat: repeat repeat;">
258<code class="language-html" style="font-family: Consolas, Monaco,
 > 'Andale Mono', monospace; color: inherit; text-shadow: none; dir
 >ection: ltr; white-space: pre; word-spacing: normal; word-break: 
 >normal; -webkit-hyphens: none;"><span class="token script"><span 
 >class="token tag" style="color: rgb(153, 0, 85);"><span class="to
 >ken tag"><span class="token punctuation" style="color: rgb(153, 1
 >53, 153);">&lt;</span>script</span> <span class="token attr-name"
 > style="color: rgb(102, 153, 0);">type</span><span class="token a
 >ttr-value" style="color: rgb(0, 119, 170);"><span class="token pu
 >nctuation" style="color: rgb(153, 153, 153);">=</span><span class
 >="token punctuation" style="color: rgb(153, 153, 153);">"</span>a
 >pplication/javascript;version<span class="token punctuation" styl
 >e="color: rgb(153, 153, 153);">=</span>1.8<span class="token punc
 >tuation" style="color: rgb(153, 153, 153);">"</span></span> <span
 > class="token attr-name" style="color: rgb(102, 153, 0);">src</sp
 >an><span class="token attr-value" style="color: rgb(0, 119, 170);
 >"><span class="token punctuation" style="color: rgb(153, 153, 153
 >);">=</span><span class="token punctuation" style="color: rgb(153
 >, 153, 153);">"</span>chrome://browser/content/settings.js<span c
 >lass="token punctuation" style="color: rgb(153, 153, 153);">"</sp
 >an></span><span class="token punctuation" style="color: rgb(153, 
 >153, 153);">&gt;</span></span> <span class="token tag" style="col
 >or: rgb(153, 0, 85);"><span class="token tag"><span class="token 
 >punctuation" style="color: rgb(153, 153, 153);">&lt;/</span>scrip
 >t</span><span class="token punctuation" style="color: rgb(153, 15
 >3, 153);">&gt;</span></span></span>
259<span class="token script"><span class="token tag" style="color: 
 >rgb(153, 0, 85);"><span class="token tag"><span class="token punc
 >tuation" style="color: rgb(153, 153, 153);">&lt;</span>script</sp
 >an> <span class="token attr-name" style="color: rgb(102, 153, 0);
 >">type</span><span class="token attr-value" style="color: rgb(0, 
 >119, 170);"><span class="token punctuation" style="color: rgb(153
 >, 153, 153);">=</span><span class="token punctuation" style="colo
 >r: rgb(153, 153, 153);">"</span>application/javascript;version<sp
 >an class="token punctuation" style="color: rgb(153, 153, 153);">=
 ></span>1.8<span class="token punctuation" style="color: rgb(153, 
 >153, 153);">"</span></span> <span class="token attr-name" style="
 >color: rgb(102, 153, 0);">src</span><span class="token attr-value
 >" style="color: rgb(0, 119, 170);"><span class="token punctuation
 >" style="color: rgb(153, 153, 153);">=</span><span class="token p
 >unctuation" style="color: rgb(153, 153, 153);">"</span>chrome://b
 >rowser/content/shell.js<span class="token punctuation" style="col
 >or: rgb(153, 153, 153);">"</span></span><span class="token punctu
 >ation" style="color: rgb(153, 153, 153);">&gt;</span></span> <spa
 >n class="token tag" style="color: rgb(153, 0, 85);"><span class="
 >token tag"><span class="token punctuation" style="color: rgb(153,
 > 153, 153);">&lt;/</span>script</span><span class="token punctuat
 >ion" style="color: rgb(153, 153, 153);">&gt;</span></span></span>
 ></code>
260</pre>
261    <div class="line-number" data-start="1" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 0px;">
262      &nbsp;
263    </div>
264    <div class="line-number" data-start="2" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 19px;">
265      &nbsp;
266    </div>
267    <p>
268      <code>settings.js</code>&nbsp;包含了系统设置的默认参数。
269    </p>
270    <h5 id="b2g.2Fchrome.2Fcontent.2Fshell.js">
271      b2g/chrome/content/shell.js
272    </h5>
273    <p>
274      <code>shell.js</code>&nbsp; 是在 Gaia&nbsp;<code>system</code
 >>&nbsp; app中装载的第一个脚本文件。.
275    </p>
276    <p>
277      <code>shell.js</code>&nbsp;导入了所有需要的模块,注册键值监听,定义了 <code styl
 >e="font-style: normal;">sendCustomEvent</code> m和<code style="fon
 >t-style: normal;">sendChromeEvent</code>&nbsp;与Gaia 通信,并且提供了 weba
 >pp 的安装助手:&nbsp;indexedDB quota, RemoteDebugger, keyboard helper, 
 >和screenshot 工具。
278    </p>
279    <p>
280      但是<code>shell.js</code>&nbsp;最重要的功能就是启动了 Gaia is to launch 
 >the Gaia&nbsp;<code>system</code>&nbsp;app, 之后又将整个系统相关的管理工作移交给了 G
 >aia&nbsp;<code>system</code>&nbsp;app。
281    </p>
282    <pre class="brush: js language-js" data-number="" style="padd
 >ing-top: 1em; padding-right: 0px; padding-bottom: 1em; padding-le
 >ft: 30px; border-left-width: 6px; font-family: Consolas, Monaco, 
 >'Andale Mono', monospace; font-size: 14px; background-image: url(
 >https://developer.cdn.mozilla.net/media/redesign/img/blueprint-da
 >rk.png); background-color: rgba(234, 239, 242, 0.246094); text-sh
 >adow: none; direction: ltr; text-align: left; white-space: normal
 >; word-break: normal; -webkit-hyphens: none; background-position:
 > 50% 0%; background-repeat: repeat repeat;">
283<code class="language-js" style="font-family: Consolas, Monaco, '
 >Andale Mono', monospace; color: inherit; text-shadow: none; direc
 >tion: ltr; white-space: pre; word-spacing: normal; word-break: no
 >rmal; -webkit-hyphens: none;"><span class="token keyword" style="
 >color: rgb(0, 119, 170);">let</span> systemAppFrame <span class="
 >token operator" style="color: rgb(166, 127, 89); background-image
 >: initial; background-attachment: initial; background-origin: ini
 >tial; background-clip: initial; background-color: rgba(255, 255, 
 >255, 0.496094);">=</span>
284  document<span class="token punctuation" style="color: rgb(153, 
 >153, 153);">.</span><span class="token function">createElementNS<
 >span class="token punctuation" style="color: rgb(153, 153, 153);"
 >>(</span></span><span class="token string" style="color: rgb(102,
 > 153, 0);">'http://www.w3.org/1999/xhtml'</span><span class="toke
 >n punctuation" style="color: rgb(153, 153, 153);">,</span> <span 
 >class="token string" style="color: rgb(102, 153, 0);">'html:ifram
 >e'</span><span class="token punctuation" style="color: rgb(153, 1
 >53, 153);">)</span><span class="token punctuation" style="color: 
 >rgb(153, 153, 153);">;</span>
285    <span class="token punctuation" style="color: rgb(153, 153, 1
 >53);">.</span><span class="token punctuation" style="color: rgb(1
 >53, 153, 153);">.</span><span class="token punctuation" style="co
 >lor: rgb(153, 153, 153);">.</span>
286  container<span class="token punctuation" style="color: rgb(153,
 > 153, 153);">.</span><span class="token function">appendChild<spa
 >n class="token punctuation" style="color: rgb(153, 153, 153);">(<
 >/span></span>systemAppFrame<span class="token punctuation" style=
 >"color: rgb(153, 153, 153);">)</span><span class="token punctuati
 >on" style="color: rgb(153, 153, 153);">;</span></code>
287</pre>
288    <div class="line-number" data-start="1" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 0px;">
289      &nbsp;
290    </div>
291    <div class="line-number" data-start="2" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 19px;">
292      &nbsp;
293    </div>
294    <div class="line-number" data-start="3" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 38px;">
295      &nbsp;
296    </div>
297    <div class="line-number" data-start="4" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 57px;">
298      &nbsp;
299    </div>
300    <h5 id="b2g.2Fapp.2Fb2g.js">
301      b2g/app/b2g.js
302    </h5>
303    <p>
304      This script contains predefined settings, like about:config
 > in browser, and the same as Gaia's pref.js. These settings can b
 >e changed from the Settings app, and can be overwritten with Gaia
 >’s user.js in the Gaia build script.
305    </p>
306    <h4 id="mozilla.2Fcentral.2Fdom.2F.7BAPI.7D" style="line-heig
 >ht: 18px; letter-spacing: normal;">
307      mozilla/central/dom/{API}
308    </h4>
309    <p>
310      New API implementations (post-b2g) will be located in&nbsp;
 ><code>dom/</code>. Older APIs will be located in dom/base, for ex
 >ample&nbsp;<code>navigator.cpp</code>.
311    </p>
312    <h5 id="mozilla.2Fcentral.2Fdom.2Fapps">
313      mozilla/central/dom/apps
314    </h5>
315    <p>
316      <code>.jsm</code>&nbsp;will be loaded —&nbsp;<code>.js</cod
 >e>&nbsp;API implementations such as&nbsp;<code>webapp.js</code>&n
 >bsp;install,&nbsp;<code>getSelf</code>, etc.
317    </p>
318    <h5 id="mozilla.2Fcentral.2Fdom.2Fapps.2Fsrc.2F">
319      mozilla/central/dom/apps/src/
320    </h5>
321    <p>
322      All permissions are defined in&nbsp;<a href="http://mxr.moz
 >illa.org/mozilla-central/source/dom/apps/src/PermissionsTable.jsm
 >">PermissionsTable.jsm</a>
323    </p>
324    <h4 id="mozilla.2Fcentral.2Fdom.2Fwebidl" style="line-height:
 > 18px; letter-spacing: normal;">
325      mozilla/central/dom/webidl
326    </h4>
327    <p>
328      WebIDL is the language used to define web APIs. For support
 >ed attributes, read<a href="https://developer.mozilla.org/en-US/d
 >ocs/Mozilla/WebIDL_bindings">WebIDL_bindings</a>.
329    </p>
330    <h4 id="mozilla.2Fcentral.2Fhal.2Fgonk" style="line-height: 1
 >8px; letter-spacing: normal;">
331      mozilla/central/hal/gonk
332    </h4>
333    <p>
334      This directory contains files related to the gonk port laye
 >r.
335    </p>
336    <h4 id="Generated_files" style="line-height: 18px; letter-spa
 >cing: normal;">
337      Generated files
338    </h4>
339    <h5 id="module.2Flibpref.2Fsrc.2Finit.2Fall.js">
340      module/libpref/src/init/all.js
341    </h5>
342    <p>
343      Contains all config files.
344    </p>
345    <h5 id=".2Fsystem.2Fb2g.2F_omni.ja_and_omni.js">
346      /system/b2g/ omni.ja and omni.js
347    </h5>
348    <p>
349      Contains the pack of styles for resources in the device.
350    </p>
351    <p>
352      &nbsp;
353    </p>
354    <h3 id="Processing_input_events" style="line-height: 24px; le
 >tter-spacing: normal;">
n232      Most action inside Gecko is triggered by user actions. Thesn358      Most action inside Gecko is triggered by user actions. Thes
>e actions are represented by input events (such as button presses>e actions are represented by input events (such as button presses
>, touches to a touch screen device, and so forth). These events e>, touches to a touch screen device, and so forth). These events e
>nter Gecko through the {{source("widget/gonk/nsAppShell.cpp", "Go>nter Gecko through the {{source("widget/gonk/nsAppShell.cpp", "Go
>nk implementation")}} of {{interface("nsIAppShell")}}, a Gecko in>nk implementation")}} of {{interface("nsIAppShell")}}, a Gecko in
>terface that is used to represent the primary entrance points for>terface that is used to represent the primary entrance points for
> a Gecko application; that is, the input device driver calls meth> a Gecko application; that is, the input device driver calls meth
>ods on the <code>nsAppShell</code> object that represents the Gec>ods on the&nbsp;<code>nsAppShell</code>&nbsp;object that represen
>ko subsystem in order to send events to the user interface.>ts the Gecko subsystem in order to send events to the user interf
 >ace.
n237    <pre class="brush:cpp;">n363    <pre class="brush:cpp; language-cpp" data-number="" style="pa
 >dding-top: 1em; padding-right: 0px; padding-bottom: 1em; padding-
 >left: 30px; border-left-width: 6px; font-family: Consolas, Monaco
 >, 'Andale Mono', monospace; font-size: 14px; background-image: ur
 >l(https://developer.cdn.mozilla.net/media/redesign/img/blueprint-
 >dark.png); background-color: rgba(234, 239, 242, 0.246094); text-
 >shadow: none; direction: ltr; text-align: left; white-space: norm
 >al; word-break: normal; -webkit-hyphens: none; background-positio
 >n: 50% 0%; background-repeat: repeat repeat;">
238void GeckoInputDispatcher::notifyKey(nsecs_t eventTime,364<code class="language-cpp" style="font-family: Consolas, Monaco, 
 >'Andale Mono', monospace; color: inherit; text-shadow: none; dire
 >ction: ltr; white-space: pre; word-spacing: normal; word-break: n
 >ormal; -webkit-hyphens: none;">void GeckoInputDispatcher<span cla
 >ss="token punctuation" style="color: rgb(153, 153, 153);">:</span
 >><span class="token punctuation" style="color: rgb(153, 153, 153)
 >;">:</span><span class="token function">notifyKey<span class="tok
 >en punctuation" style="color: rgb(153, 153, 153);">(</span></span
 >>nsecs_t eventTime<span class="token punctuation" style="color: r
 >gb(153, 153, 153);">,</span>
239                                     int32_t deviceId,365                                     int32_t deviceId<span class=
 >"token punctuation" style="color: rgb(153, 153, 153);">,</span>
240                                     int32_t source,366                                     int32_t source<span class="t
 >oken punctuation" style="color: rgb(153, 153, 153);">,</span>
241                                     uint32_t policyFlags,367                                     uint32_t policyFlags<span cl
 >ass="token punctuation" style="color: rgb(153, 153, 153);">,</spa
 >n>
242                                     int32_t action,368                                     int32_t action<span class="t
 >oken punctuation" style="color: rgb(153, 153, 153);">,</span>
243                                     int32_t flags,369                                     int32_t flags<span class="to
 >ken punctuation" style="color: rgb(153, 153, 153);">,</span>
244                                     int32_t keyCode,370                                     int32_t keyCode<span class="
 >token punctuation" style="color: rgb(153, 153, 153);">,</span>
245                                     int32_t scanCode,371                                     int32_t scanCode<span class=
 >"token punctuation" style="color: rgb(153, 153, 153);">,</span>
246                                     int32_t metaState,372                                     int32_t metaState<span class
 >="token punctuation" style="color: rgb(153, 153, 153);">,</span>
247                                     nsecs_t downTime) {373                                     nsecs_t downTime<span class=
 >"token punctuation" style="color: rgb(153, 153, 153);">)</span> <
 >span class="token punctuation" style="color: rgb(153, 153, 153);"
 >>{</span>
248  UserInputData data;374  UserInputData data<span class="token punctuation" style="color:
 > rgb(153, 153, 153);">;</span>
249  data.timeMs = nanosecsToMillisecs(eventTime);375  data<span class="token punctuation" style="color: rgb(153, 153,
 > 153);">.</span>timeMs <span class="token operator" style="color:
 > rgb(166, 127, 89); background-image: initial; background-attachm
 >ent: initial; background-origin: initial; background-clip: initia
 >l; background-color: rgba(255, 255, 255, 0.496094);">=</span> <sp
 >an class="token function">nanosecsToMillisecs<span class="token p
 >unctuation" style="color: rgb(153, 153, 153);">(</span></span>eve
 >ntTime<span class="token punctuation" style="color: rgb(153, 153,
 > 153);">)</span><span class="token punctuation" style="color: rgb
 >(153, 153, 153);">;</span>
250  data.type = UserInputData::KEY_DATA;376  data<span class="token punctuation" style="color: rgb(153, 153,
 > 153);">.</span>type <span class="token operator" style="color: r
 >gb(166, 127, 89); background-image: initial; background-attachmen
 >t: initial; background-origin: initial; background-clip: initial;
 > background-color: rgba(255, 255, 255, 0.496094);">=</span> UserI
 >nputData<span class="token punctuation" style="color: rgb(153, 15
 >3, 153);">:</span><span class="token punctuation" style="color: r
 >gb(153, 153, 153);">:</span>KEY_DATA<span class="token punctuatio
 >n" style="color: rgb(153, 153, 153);">;</span>
251  data.action = action;377  data<span class="token punctuation" style="color: rgb(153, 153,
 > 153);">.</span>action <span class="token operator" style="color:
 > rgb(166, 127, 89); background-image: initial; background-attachm
 >ent: initial; background-origin: initial; background-clip: initia
 >l; background-color: rgba(255, 255, 255, 0.496094);">=</span> act
 >ion<span class="token punctuation" style="color: rgb(153, 153, 15
 >3);">;</span>
252  data.flags = flags;378  data<span class="token punctuation" style="color: rgb(153, 153,
 > 153);">.</span>flags <span class="token operator" style="color: 
 >rgb(166, 127, 89); background-image: initial; background-attachme
 >nt: initial; background-origin: initial; background-clip: initial
 >; background-color: rgba(255, 255, 255, 0.496094);">=</span> flag
 >s<span class="token punctuation" style="color: rgb(153, 153, 153)
 >;">;</span>
253  data.metaState = metaState;379  data<span class="token punctuation" style="color: rgb(153, 153,
 > 153);">.</span>metaState <span class="token operator" style="col
 >or: rgb(166, 127, 89); background-image: initial; background-atta
 >chment: initial; background-origin: initial; background-clip: ini
 >tial; background-color: rgba(255, 255, 255, 0.496094);">=</span> 
 >metaState<span class="token punctuation" style="color: rgb(153, 1
 >53, 153);">;</span>
254  data.key.keyCode = keyCode;380  data<span class="token punctuation" style="color: rgb(153, 153,
 > 153);">.</span>key<span class="token punctuation" style="color: 
 >rgb(153, 153, 153);">.</span>keyCode <span class="token operator"
 > style="color: rgb(166, 127, 89); background-image: initial; back
 >ground-attachment: initial; background-origin: initial; backgroun
 >d-clip: initial; background-color: rgba(255, 255, 255, 0.496094);
 >">=</span> keyCode<span class="token punctuation" style="color: r
 >gb(153, 153, 153);">;</span>
255  data.key.scanCode = scanCode;381  data<span class="token punctuation" style="color: rgb(153, 153,
 > 153);">.</span>key<span class="token punctuation" style="color: 
 >rgb(153, 153, 153);">.</span>scanCode <span class="token operator
 >" style="color: rgb(166, 127, 89); background-image: initial; bac
 >kground-attachment: initial; background-origin: initial; backgrou
 >nd-clip: initial; background-color: rgba(255, 255, 255, 0.496094)
 >;">=</span> scanCode<span class="token punctuation" style="color:
 > rgb(153, 153, 153);">;</span>
256  {382  <span class="token punctuation" style="color: rgb(153, 153, 153
 >);">{</span>
257    MutexAutoLock lock(mQueueLock);383    MutexAutoLock <span class="token function">lock<span class="t
 >oken punctuation" style="color: rgb(153, 153, 153);">(</span></sp
 >an>mQueueLock<span class="token punctuation" style="color: rgb(15
 >3, 153, 153);">)</span><span class="token punctuation" style="col
 >or: rgb(153, 153, 153);">;</span>
258    mEventQueue.push(data);384    mEventQueue<span class="token punctuation" style="color: rgb(
 >153, 153, 153);">.</span><span class="token function">push<span c
 >lass="token punctuation" style="color: rgb(153, 153, 153);">(</sp
 >an></span>data<span class="token punctuation" style="color: rgb(1
 >53, 153, 153);">)</span><span class="token punctuation" style="co
 >lor: rgb(153, 153, 153);">;</span>
259  }385  <span class="token punctuation" style="color: rgb(153, 153, 153
 >);">}</span>
260  gAppShell-&gt;NotifyNativeEvent();386  gAppShell<span class="token operator" style="color: rgb(166, 12
 >7, 89); background-image: initial; background-attachment: initial
 >; background-origin: initial; background-clip: initial; backgroun
 >d-color: rgba(255, 255, 255, 0.496094);">-</span>&gt;<span class=
 >"token function">NotifyNativeEvent<span class="token punctuation"
 > style="color: rgb(153, 153, 153);">(</span></span><span class="t
 >oken punctuation" style="color: rgb(153, 153, 153);">)</span><spa
 >n class="token punctuation" style="color: rgb(153, 153, 153);">;<
 >/span>
261}387<span class="token punctuation" style="color: rgb(153, 153, 153);
 >">}</span></code>
nn389    <div class="line-number" data-start="1" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 0px;">
390      &nbsp;
391    </div>
392    <div class="line-number" data-start="2" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 19px;">
393      &nbsp;
394    </div>
395    <div class="line-number" data-start="3" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 38px;">
396      &nbsp;
397    </div>
398    <div class="line-number" data-start="4" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 57px;">
399      &nbsp;
400    </div>
401    <div class="line-number" data-start="5" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 76px;">
402      &nbsp;
403    </div>
404    <div class="line-number" data-start="6" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 95px;">
405      &nbsp;
406    </div>
407    <div class="line-number" data-start="7" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 114px;">
408      &nbsp;
409    </div>
410    <div class="line-number" data-start="8" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 133px;">
411      &nbsp;
412    </div>
413    <div class="line-number" data-start="9" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 152px;">
414      &nbsp;
415    </div>
416    <div class="line-number" data-start="10" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 171px;">
417      &nbsp;
418    </div>
419    <div class="line-number" data-start="11" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 190px;">
420      &nbsp;
421    </div>
422    <div class="line-number" data-start="12" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 209px;">
423      &nbsp;
424    </div>
425    <div class="line-number" data-start="13" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 228px;">
426      &nbsp;
427    </div>
428    <div class="line-number" data-start="14" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 247px;">
429      &nbsp;
430    </div>
431    <div class="line-number" data-start="15" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 266px;">
432      &nbsp;
433    </div>
434    <div class="line-number" data-start="16" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 285px;">
435      &nbsp;
436    </div>
437    <div class="line-number" data-start="17" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 304px;">
438      &nbsp;
439    </div>
440    <div class="line-number" data-start="18" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 323px;">
441      &nbsp;
442    </div>
443    <div class="line-number" data-start="19" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 342px;">
444      &nbsp;
445    </div>
446    <div class="line-number" data-start="20" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 361px;">
447      &nbsp;
448    </div>
449    <div class="line-number" data-start="21" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 380px;">
450      &nbsp;
451    </div>
452    <div class="line-number" data-start="22" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 399px;">
453      &nbsp;
454    </div>
455    <div class="line-number" data-start="23" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 418px;">
456      &nbsp;
457    </div>
458    <div class="line-number" data-start="24" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 437px;">
459      &nbsp;
460    </div>
n264      These events come from the standard Linux <code>input_eventn462      These events come from the standard Linux&nbsp;<code>input_
></code> system. Firefox OS uses a {{source("widget/gonk/libui/Inp>event</code>&nbsp;system. Firefox OS uses a {{source("widget/gonk
>utReader.cpp", "light abstraction layer")}} over that; this provi>/libui/InputReader.cpp", "light abstraction layer")}} over that; 
>des some nice features like event filtering. You can see the code>this provides some nice features like event filtering. You can se
> that creates input events in the <code>EventHub::getEvents()</co>e the code that creates input events in the&nbsp;<code>EventHub::
>de> method in {{source2("widget/gonk/libui/EventHub.cpp")}}.>getEvents()</code>&nbsp;method in {{source2("widget/gonk/libui/Ev
 >entHub.cpp")}}.
265    </p>
266    <p>463    </p>
464    <p>
267      Once the events are received by Gecko, they're dispatched i465      Once the events are received by Gecko, they're dispatched i
>nto the DOM by <code>{{source("widget/gonk/nsAppShell.cpp", "nsAp>nto the DOM by<code>{{source("widget/gonk/nsAppShell.cpp", "nsApp
>pShell")}}</code>:>Shell")}}</code>:
268    </p>
269    <pre class="brush:cpp;">
270static nsEventStatus sendKeyEventWithMsg(uint32_t keyCode,
271                                         uint32_t msg,
272                                         uint64_t timeMs,
273                                         uint32_t flags) {
274    nsKeyEvent event(true, msg, NULL);
275    event.keyCode = keyCode;
276    event.location = nsIDOMKeyEvent::DOM_KEY_LOCATION_MOBILE;
277    event.time = timeMs;
278    event.flags |= flags;
279    return nsWindow::DispatchInputEvent(event);
280}
281</pre>
282    <p>466    </p>
283      After that, the events are either consumed by Gecko itself 467    <pre class="brush:cpp; language-cpp" data-number="" style="pa
>or are dispatched to Web applications as <a href="/en-US/docs/DOM>dding-top: 1em; padding-right: 0px; padding-bottom: 1em; padding-
>_Client_Object_Cross-Reference/DOM_Events" title="/en-US/docs/DOM>left: 30px; border-left-width: 6px; font-family: Consolas, Monaco
>_Client_Object_Cross-Reference/DOM_Events">DOM events</a> for fur>, 'Andale Mono', monospace; font-size: 14px; background-image: ur
>ther processing.>l(https://developer.cdn.mozilla.net/media/redesign/img/blueprint-
 >dark.png); background-color: rgba(234, 239, 242, 0.246094); text-
 >shadow: none; direction: ltr; text-align: left; white-space: norm
 >al; word-break: normal; -webkit-hyphens: none; background-positio
 >n: 50% 0%; background-repeat: repeat repeat;">
468<code class="language-cpp" style="font-family: Consolas, Monaco, 
 >'Andale Mono', monospace; color: inherit; text-shadow: none; dire
 >ction: ltr; white-space: pre; word-spacing: normal; word-break: n
 >ormal; -webkit-hyphens: none;">static nsEventStatus <span class="
 >token function">sendKeyEventWithMsg<span class="token punctuation
 >" style="color: rgb(153, 153, 153);">(</span></span>uint32_t keyC
 >ode<span class="token punctuation" style="color: rgb(153, 153, 15
 >3);">,</span>
469                                         uint32_t msg<span class=
 >"token punctuation" style="color: rgb(153, 153, 153);">,</span>
470                                         uint64_t timeMs<span cla
 >ss="token punctuation" style="color: rgb(153, 153, 153);">,</span
 >>
471                                         uint32_t flags<span clas
 >s="token punctuation" style="color: rgb(153, 153, 153);">)</span>
 > <span class="token punctuation" style="color: rgb(153, 153, 153)
 >;">{</span>
472    nsKeyEvent <span class="token function">event<span class="tok
 >en punctuation" style="color: rgb(153, 153, 153);">(</span></span
 >><span class="token boolean" style="color: rgb(153, 0, 85);">true
 ></span><span class="token punctuation" style="color: rgb(153, 153
 >, 153);">,</span> msg<span class="token punctuation" style="color
 >: rgb(153, 153, 153);">,</span> NULL<span class="token punctuatio
 >n" style="color: rgb(153, 153, 153);">)</span><span class="token 
 >punctuation" style="color: rgb(153, 153, 153);">;</span>
473    event<span class="token punctuation" style="color: rgb(153, 1
 >53, 153);">.</span>keyCode <span class="token operator" style="co
 >lor: rgb(166, 127, 89); background-image: initial; background-att
 >achment: initial; background-origin: initial; background-clip: in
 >itial; background-color: rgba(255, 255, 255, 0.496094);">=</span>
 > keyCode<span class="token punctuation" style="color: rgb(153, 15
 >3, 153);">;</span>
474    event<span class="token punctuation" style="color: rgb(153, 1
 >53, 153);">.</span>location <span class="token operator" style="c
 >olor: rgb(166, 127, 89); background-image: initial; background-at
 >tachment: initial; background-origin: initial; background-clip: i
 >nitial; background-color: rgba(255, 255, 255, 0.496094);">=</span
 >> nsIDOMKeyEvent<span class="token punctuation" style="color: rgb
 >(153, 153, 153);">:</span><span class="token punctuation" style="
 >color: rgb(153, 153, 153);">:</span>DOM_KEY_LOCATION_MOBILE<span 
 >class="token punctuation" style="color: rgb(153, 153, 153);">;</s
 >pan>
475    event<span class="token punctuation" style="color: rgb(153, 1
 >53, 153);">.</span>time <span class="token operator" style="color
 >: rgb(166, 127, 89); background-image: initial; background-attach
 >ment: initial; background-origin: initial; background-clip: initi
 >al; background-color: rgba(255, 255, 255, 0.496094);">=</span> ti
 >meMs<span class="token punctuation" style="color: rgb(153, 153, 1
 >53);">;</span>
476    event<span class="token punctuation" style="color: rgb(153, 1
 >53, 153);">.</span>flags <span class="token operator" style="colo
 >r: rgb(166, 127, 89); background-image: initial; background-attac
 >hment: initial; background-origin: initial; background-clip: init
 >ial; background-color: rgba(255, 255, 255, 0.496094);">|</span><s
 >pan class="token operator" style="color: rgb(166, 127, 89); backg
 >round-image: initial; background-attachment: initial; background-
 >origin: initial; background-clip: initial; background-color: rgba
 >(255, 255, 255, 0.496094);">=</span> flags<span class="token punc
 >tuation" style="color: rgb(153, 153, 153);">;</span>
477    <span class="token keyword" style="color: rgb(0, 119, 170);">
 >return</span> nsWindow<span class="token punctuation" style="colo
 >r: rgb(153, 153, 153);">:</span><span class="token punctuation" s
 >tyle="color: rgb(153, 153, 153);">:</span><span class="token func
 >tion">DispatchInputEvent<span class="token punctuation" style="co
 >lor: rgb(153, 153, 153);">(</span></span>event<span class="token 
 >punctuation" style="color: rgb(153, 153, 153);">)</span><span cla
 >ss="token punctuation" style="color: rgb(153, 153, 153);">;</span
 >>
478<span class="token punctuation" style="color: rgb(153, 153, 153);
 >">}</span></code>
479</pre>
480    <div class="line-number" data-start="1" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 0px;">
481      &nbsp;
482    </div>
483    <div class="line-number" data-start="2" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 19px;">
484      &nbsp;
485    </div>
486    <div class="line-number" data-start="3" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 38px;">
487      &nbsp;
488    </div>
489    <div class="line-number" data-start="4" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 57px;">
490      &nbsp;
491    </div>
492    <div class="line-number" data-start="5" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 76px;">
493      &nbsp;
494    </div>
495    <div class="line-number" data-start="6" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 95px;">
496      &nbsp;
497    </div>
498    <div class="line-number" data-start="7" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 114px;">
499      &nbsp;
500    </div>
501    <div class="line-number" data-start="8" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 133px;">
502      &nbsp;
503    </div>
504    <div class="line-number" data-start="9" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 152px;">
505      &nbsp;
506    </div>
507    <div class="line-number" data-start="10" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 171px;">
508      &nbsp;
509    </div>
510    <div class="line-number" data-start="11" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 190px;">
511      &nbsp;
512    </div>
284    </p>513    <p>
285    <h3 id="Graphics">514      After that, the events are either consumed by Gecko itself 
 >or are dispatched to Web applications as&nbsp;<a href="https://de
 >veloper.mozilla.org/en-US/docs/DOM_Client_Object_Cross-Reference/
 >DOM_Events" title="/en-US/docs/DOM_Client_Object_Cross-Reference/
 >DOM_Events">DOM events</a>&nbsp;for further processing.
515    </p>
516    <h3 id="Graphics" style="line-height: 24px; letter-spacing: n
 >ormal;">
n289      At the very lowest level, Gecko uses <a href="http://www.khn520      At the very lowest level, Gecko uses&nbsp;<a href="http://w
>ronos.org/opengles/2_X/" title="http://www.khronos.org/opengles/2>ww.khronos.org/opengles/2_X/" title="http://www.khronos.org/openg
>_X/">OpenGL ES 2.0</a> to draw to an GL context that wraps the ha>les/2_X/">OpenGL ES 2.0</a>&nbsp;to draw to a GL context that wra
>rdware frame buffers. This is done in the Gonk implementation of >ps the hardware frame buffers. This is done in the Gonk implement
><code>{{source("widget/gonk/nsWindow.cpp", "nsWindow")}}</code> b>ation of<code>{{source("widget/gonk/nsWindow.cpp", "nsWindow")}}<
>y code similar to this:>/code>&nbsp;by code similar to this:
290    </p>
291    <pre class="brush:cpp;">
292gNativeWindow = new android::FramebufferNativeWindow();
293sGLContext = GLContextProvider::CreateForWindow(this);
294</pre>
295    <p>521    </p>
296      The <code>FramebufferNativeWindow</code> class is brought i522    <pre class="brush:cpp; language-cpp" data-number="" style="pa
>n directly from Android; see <a href="https://github.com/android/>dding-top: 1em; padding-right: 0px; padding-bottom: 1em; padding-
>platform_frameworks_base/blob/ics-mr1-release/libs/ui/Framebuffer>left: 30px; border-left-width: 6px; font-family: Consolas, Monaco
>NativeWindow.cpp" title="https://github.com/android/platform_fram>, 'Andale Mono', monospace; font-size: 14px; background-image: ur
>eworks_base/blob/ics-mr1-release/libs/ui/FramebufferNativeWindow.>l(https://developer.cdn.mozilla.net/media/redesign/img/blueprint-
>cpp"><code>FramebufferNativeWindow.cpp</code></a>. This uses the >dark.png); background-color: rgba(234, 239, 242, 0.246094); text-
><strong>gralloc</strong> API to access the graphics driver in ord>shadow: none; direction: ltr; text-align: left; white-space: norm
>er to map buffers from the framebuffer device into memory.>al; word-break: normal; -webkit-hyphens: none; background-positio
 >n: 50% 0%; background-repeat: repeat repeat;">
523<code class="language-cpp" style="font-family: Consolas, Monaco, 
 >'Andale Mono', monospace; color: inherit; text-shadow: none; dire
 >ction: ltr; white-space: pre; word-spacing: normal; word-break: n
 >ormal; -webkit-hyphens: none;">gNativeWindow <span class="token o
 >perator" style="color: rgb(166, 127, 89); background-image: initi
 >al; background-attachment: initial; background-origin: initial; b
 >ackground-clip: initial; background-color: rgba(255, 255, 255, 0.
 >496094);">=</span> <span class="token keyword" style="color: rgb(
 >0, 119, 170);">new</span> <span class="token class-name">android<
 >/span><span class="token punctuation" style="color: rgb(153, 153,
 > 153);">:</span><span class="token punctuation" style="color: rgb
 >(153, 153, 153);">:</span><span class="token function">Framebuffe
 >rNativeWindow<span class="token punctuation" style="color: rgb(15
 >3, 153, 153);">(</span></span><span class="token punctuation" sty
 >le="color: rgb(153, 153, 153);">)</span><span class="token punctu
 >ation" style="color: rgb(153, 153, 153);">;</span>
524sGLContext <span class="token operator" style="color: rgb(166, 12
 >7, 89); background-image: initial; background-attachment: initial
 >; background-origin: initial; background-clip: initial; backgroun
 >d-color: rgba(255, 255, 255, 0.496094);">=</span> GLContextProvid
 >er<span class="token punctuation" style="color: rgb(153, 153, 153
 >);">:</span><span class="token punctuation" style="color: rgb(153
 >, 153, 153);">:</span><span class="token function">CreateForWindo
 >w<span class="token punctuation" style="color: rgb(153, 153, 153)
 >;">(</span></span>this<span class="token punctuation" style="colo
 >r: rgb(153, 153, 153);">)</span><span class="token punctuation" s
 >tyle="color: rgb(153, 153, 153);">;</span></code>
525</pre>
526    <div class="line-number" data-start="1" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 0px;">
527      &nbsp;
528    </div>
529    <div class="line-number" data-start="2" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 19px;">
530      &nbsp;
531    </div>
297    </p>532    <p>
533      The&nbsp;<code>FramebufferNativeWindow</code>&nbsp;class is
 > brought in directly from Android; see<a href="https://github.com
 >/android/platform_frameworks_base/blob/ics-mr1-release/libs/ui/Fr
 >amebufferNativeWindow.cpp" title="https://github.com/android/plat
 >form_frameworks_base/blob/ics-mr1-release/libs/ui/FramebufferNati
 >veWindow.cpp"><code>FramebufferNativeWindow.cpp</code></a>. This 
 >uses the&nbsp;<strong>gralloc</strong>&nbsp;API to access the gra
 >phics driver in order to map buffers from the framebuffer device 
 >into memory.
298    <p>534    </p>
535    <p>
299      Gecko uses its <a href="/en-US/docs/Gecko/Layers" title="/e536      Gecko uses its&nbsp;<a href="https://developer.mozilla.org/
>n-US/docs/Gecko/Layers">Layers</a> system to composite drawn cont>en-US/docs/Gecko/Layers" title="/en-US/docs/Gecko/Layers">Layers<
>ent to the screen. In summary, what happens is this:>/a>&nbsp;system to composite drawn content to the screen. In summ
 >ary, what happens is this:
n302      <li>Gecko draws separate regions of pages into memory buffen539      <li>Gecko draws separate regions of pages into memory buffe
>rs. Sometimes these buffers are in system memory; other times, th>rs. Sometimes these buffers are in system memory; other times, th
>ey're textures mapped into Gecko's address space, which means tha>ey're textures mapped into Gecko's address space, which means tha
>t Gecko is drawing directly into video memory. This is typically >t Gecko is drawing directly into video memory. This is typically 
>done in the method <a href="http://mxr.mozilla.org/mozilla-centra>done in the method&nbsp;<a href="http://mxr.mozilla.org/mozilla-c
>l/source/gfx/layers/basic/BasicThebesLayer.cpp#83" title="http://>entral/source/gfx/layers/basic/BasicThebesLayer.cpp#83" title="ht
>mxr.mozilla.org/mozilla-central/source/gfx/layers/basic/BasicTheb>tp://mxr.mozilla.org/mozilla-central/source/gfx/layers/basic/Basi
>esLayer.cpp#201"><code>BasicThebesLayer::PaintThebes()</code></a>>cThebesLayer.cpp#201"><code>BasicThebesLayer::PaintThebes()</code
>.>></a>.
n304      <li>Gecko then composites all of these textures to the scren541      <li>Gecko then composites all of these textures to the scre
>en using OpenGL commands. This composition occurs in <a href="htt>en using OpenGL commands. This composition occurs in&nbsp;<a href
>p://mxr.mozilla.org/mozilla-central/source/gfx/layers/opengl/Theb>="http://mxr.mozilla.org/mozilla-central/source/gfx/layers/opengl
>esLayerOGL.cpp#124" title="http://mxr.mozilla.org/mozilla-central>/ThebesLayerOGL.cpp#124" title="http://mxr.mozilla.org/mozilla-ce
>/source/gfx/layers/basic/BasicThebesLayer.cpp#201"><code>ThebesLa>ntral/source/gfx/layers/basic/BasicThebesLayer.cpp#201"><code>The
>yerOGL::RenderTo()</code></a>.>besLayerOGL::RenderTo()</code></a>.
n310    <h3 id="Hardware_Abstraction_Layer_(HAL)">n547    <h3 id="Hardware_Abstraction_Layer_(HAL)" style="line-height:
 > 24px; letter-spacing: normal;">
n316    <h4 id="How_the_HAL_works">n553    <h4 id="How_the_HAL_works" style="line-height: 18px; letter-s
 >pacing: normal;">
n322    <pre>n559    <pre class="language-html" style="padding-top: 1em; padding-r
 >ight: 1em; padding-bottom: 1em; padding-left: 1em; border-left-wi
 >dth: 6px; font-family: Consolas, Monaco, 'Andale Mono', monospace
 >; font-size: 14px; background-image: url(https://developer.cdn.mo
 >zilla.net/media/redesign/img/blueprint-dark.png); background-colo
 >r: rgba(234, 239, 242, 0.246094); text-shadow: none; direction: l
 >tr; text-align: left; white-space: normal; word-break: normal; -w
 >ebkit-hyphens: none; background-position: 50% 0%; background-repe
 >at: repeat repeat;">
n326      This is the function called by Gecko code to turn on vibratn563      This is the function called by Gecko code to turn on vibrat
>ion of the device according to the specified pattern; a correspon>ion of the device according to the specified pattern; a correspon
>ding function exists to cancel any ongoing vibration. The Gonk im>ding function exists to cancel any ongoing vibration. The Gonk im
>plementation of this method is in {{source2("hal/conk/GonkHal.cpp>plementation of this method is in {{source2("hal/gonk/GonkHal.cpp
>")}}:>")}}:
327    </p>
328    <pre class="brush:cpp;">
329void Vibrate(const nsTArray&lt;uint32_t&gt; &amp;pattern) {
330  EnsureVibratorThreadInitialized();
331  sVibratorRunnable-&gt;Vibrate(pattern);
332}
333</pre>
334    <p>564    </p>
565    <pre class="brush:cpp; language-cpp" data-number="" style="pa
 >dding-top: 1em; padding-right: 0px; padding-bottom: 1em; padding-
 >left: 30px; border-left-width: 6px; font-family: Consolas, Monaco
 >, 'Andale Mono', monospace; font-size: 14px; background-image: ur
 >l(https://developer.cdn.mozilla.net/media/redesign/img/blueprint-
 >dark.png); background-color: rgba(234, 239, 242, 0.246094); text-
 >shadow: none; direction: ltr; text-align: left; white-space: norm
 >al; word-break: normal; -webkit-hyphens: none; background-positio
 >n: 50% 0%; background-repeat: repeat repeat;">
566<code class="language-cpp" style="font-family: Consolas, Monaco, 
 >'Andale Mono', monospace; color: inherit; text-shadow: none; dire
 >ction: ltr; white-space: pre; word-spacing: normal; word-break: n
 >ormal; -webkit-hyphens: none;">void <span class="token function">
 >Vibrate<span class="token punctuation" style="color: rgb(153, 153
 >, 153);">(</span></span>const nsTArray<span class="token operator
 >" style="color: rgb(166, 127, 89); background-image: initial; bac
 >kground-attachment: initial; background-origin: initial; backgrou
 >nd-clip: initial; background-color: rgba(255, 255, 255, 0.496094)
 >;">&lt;</span>uint32_t&gt; <span class="token operator" style="co
 >lor: rgb(166, 127, 89); background-image: initial; background-att
 >achment: initial; background-origin: initial; background-clip: in
 >itial; background-color: rgba(255, 255, 255, 0.496094);">&amp;</s
 >pan>pattern<span class="token punctuation" style="color: rgb(153,
 > 153, 153);">)</span> <span class="token punctuation" style="colo
 >r: rgb(153, 153, 153);">{</span>
567  <span class="token function">EnsureVibratorThreadInitialized<sp
 >an class="token punctuation" style="color: rgb(153, 153, 153);">(
 ></span></span><span class="token punctuation" style="color: rgb(1
 >53, 153, 153);">)</span><span class="token punctuation" style="co
 >lor: rgb(153, 153, 153);">;</span>
568  sVibratorRunnable<span class="token operator" style="color: rgb
 >(166, 127, 89); background-image: initial; background-attachment:
 > initial; background-origin: initial; background-clip: initial; b
 >ackground-color: rgba(255, 255, 255, 0.496094);">-</span>&gt;<spa
 >n class="token function">Vibrate<span class="token punctuation" s
 >tyle="color: rgb(153, 153, 153);">(</span></span>pattern<span cla
 >ss="token punctuation" style="color: rgb(153, 153, 153);">)</span
 >><span class="token punctuation" style="color: rgb(153, 153, 153)
 >;">;</span>
569<span class="token punctuation" style="color: rgb(153, 153, 153);
 >">}</span></code>
570</pre>
571    <div class="line-number" data-start="1" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 0px;">
572      &nbsp;
573    </div>
574    <div class="line-number" data-start="2" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 19px;">
575      &nbsp;
576    </div>
577    <div class="line-number" data-start="3" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 38px;">
578      &nbsp;
579    </div>
580    <div class="line-number" data-start="4" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 57px;">
581      &nbsp;
582    </div>
583    <p>
335      This code sends the request to start vibrating the device t584      This code sends the request to start vibrating the device t
>o another thread, which is implemented in <code>VibratorRunnable:>o another thread, which is implemented in&nbsp;<code>VibratorRunn
>:Run()</code>. This thread's main loop looks like this:>able::Run()</code>. This thread's main loop looks like this:
336    </p>
337    <pre class="brush:cpp;">
338while (!mShuttingDown) {
339  if (mIndex &lt; mPattern.Length()) {
340    uint32_t duration = mPattern[mIndex];
341    if (mIndex % 2 == 0) {
342      vibrator_on(duration);
343    }
344    mIndex++;
345    mMonitor.Wait(PR_MillisecondsToInterval(duration));
346  }
347  else {
348    mMonitor.Wait();
349  }
350}
351</pre>
352    <p>585    </p>
586    <pre class="brush:cpp; language-cpp" data-number="" style="pa
 >dding-top: 1em; padding-right: 0px; padding-bottom: 1em; padding-
 >left: 30px; border-left-width: 6px; font-family: Consolas, Monaco
 >, 'Andale Mono', monospace; font-size: 14px; background-image: ur
 >l(https://developer.cdn.mozilla.net/media/redesign/img/blueprint-
 >dark.png); background-color: rgba(234, 239, 242, 0.246094); text-
 >shadow: none; direction: ltr; text-align: left; white-space: norm
 >al; word-break: normal; -webkit-hyphens: none; background-positio
 >n: 50% 0%; background-repeat: repeat repeat;">
587<code class="language-cpp" style="font-family: Consolas, Monaco, 
 >'Andale Mono', monospace; color: inherit; text-shadow: none; dire
 >ction: ltr; white-space: pre; word-spacing: normal; word-break: n
 >ormal; -webkit-hyphens: none;"><span class="token keyword" style=
 >"color: rgb(0, 119, 170);">while</span> <span class="token punctu
 >ation" style="color: rgb(153, 153, 153);">(</span><span class="to
 >ken operator" style="color: rgb(166, 127, 89); background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: rgba(255, 255, 25
 >5, 0.496094);">!</span>mShuttingDown<span class="token punctuatio
 >n" style="color: rgb(153, 153, 153);">)</span> <span class="token
 > punctuation" style="color: rgb(153, 153, 153);">{</span>
588  <span class="token keyword" style="color: rgb(0, 119, 170);">if
 ></span> <span class="token punctuation" style="color: rgb(153, 15
 >3, 153);">(</span>mIndex <span class="token operator" style="colo
 >r: rgb(166, 127, 89); background-image: initial; background-attac
 >hment: initial; background-origin: initial; background-clip: init
 >ial; background-color: rgba(255, 255, 255, 0.496094);">&lt;</span
 >> mPattern<span class="token punctuation" style="color: rgb(153, 
 >153, 153);">.</span><span class="token function">Length<span clas
 >s="token punctuation" style="color: rgb(153, 153, 153);">(</span>
 ></span><span class="token punctuation" style="color: rgb(153, 153
 >, 153);">)</span><span class="token punctuation" style="color: rg
 >b(153, 153, 153);">)</span> <span class="token punctuation" style
 >="color: rgb(153, 153, 153);">{</span>
589    uint32_t duration <span class="token operator" style="color: 
 >rgb(166, 127, 89); background-image: initial; background-attachme
 >nt: initial; background-origin: initial; background-clip: initial
 >; background-color: rgba(255, 255, 255, 0.496094);">=</span> mPat
 >tern<span class="token punctuation" style="color: rgb(153, 153, 1
 >53);">[</span>mIndex<span class="token punctuation" style="color:
 > rgb(153, 153, 153);">]</span><span class="token punctuation" sty
 >le="color: rgb(153, 153, 153);">;</span>
590    <span class="token keyword" style="color: rgb(0, 119, 170);">
 >if</span> <span class="token punctuation" style="color: rgb(153, 
 >153, 153);">(</span>mIndex <span class="token operator" style="co
 >lor: rgb(166, 127, 89); background-image: initial; background-att
 >achment: initial; background-origin: initial; background-clip: in
 >itial; background-color: rgba(255, 255, 255, 0.496094);">%</span>
 > <span class="token number" style="color: rgb(153, 0, 85);">2</sp
 >an> <span class="token operator" style="color: rgb(166, 127, 89);
 > background-image: initial; background-attachment: initial; backg
 >round-origin: initial; background-clip: initial; background-color
 >: rgba(255, 255, 255, 0.496094);">==</span> <span class="token nu
 >mber" style="color: rgb(153, 0, 85);">0</span><span class="token 
 >punctuation" style="color: rgb(153, 153, 153);">)</span> <span cl
 >ass="token punctuation" style="color: rgb(153, 153, 153);">{</spa
 >n>
591      <span class="token function">vibrator_on<span class="token 
 >punctuation" style="color: rgb(153, 153, 153);">(</span></span>du
 >ration<span class="token punctuation" style="color: rgb(153, 153,
 > 153);">)</span><span class="token punctuation" style="color: rgb
 >(153, 153, 153);">;</span>
592    <span class="token punctuation" style="color: rgb(153, 153, 1
 >53);">}</span>
593    mIndex<span class="token operator" style="color: rgb(166, 127
 >, 89); background-image: initial; background-attachment: initial;
 > background-origin: initial; background-clip: initial; background
 >-color: rgba(255, 255, 255, 0.496094);">++</span><span class="tok
 >en punctuation" style="color: rgb(153, 153, 153);">;</span>
594    mMonitor<span class="token punctuation" style="color: rgb(153
 >, 153, 153);">.</span><span class="token function">Wait<span clas
 >s="token punctuation" style="color: rgb(153, 153, 153);">(</span>
 ></span><span class="token function">PR_MillisecondsToInterval<spa
 >n class="token punctuation" style="color: rgb(153, 153, 153);">(<
 >/span></span>duration<span class="token punctuation" style="color
 >: rgb(153, 153, 153);">)</span><span class="token punctuation" st
 >yle="color: rgb(153, 153, 153);">)</span><span class="token punct
 >uation" style="color: rgb(153, 153, 153);">;</span>
595  <span class="token punctuation" style="color: rgb(153, 153, 153
 >);">}</span>
596  <span class="token keyword" style="color: rgb(0, 119, 170);">el
 >se</span> <span class="token punctuation" style="color: rgb(153, 
 >153, 153);">{</span>
597    mMonitor<span class="token punctuation" style="color: rgb(153
 >, 153, 153);">.</span><span class="token function">Wait<span clas
 >s="token punctuation" style="color: rgb(153, 153, 153);">(</span>
 ></span><span class="token punctuation" style="color: rgb(153, 153
 >, 153);">)</span><span class="token punctuation" style="color: rg
 >b(153, 153, 153);">;</span>
598  <span class="token punctuation" style="color: rgb(153, 153, 153
 >);">}</span>
599<span class="token punctuation" style="color: rgb(153, 153, 153);
 >">}</span></code>
600</pre>
601    <div class="line-number" data-start="1" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 0px;">
602      &nbsp;
603    </div>
604    <div class="line-number" data-start="2" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 19px;">
605      &nbsp;
606    </div>
607    <div class="line-number" data-start="3" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 38px;">
608      &nbsp;
609    </div>
610    <div class="line-number" data-start="4" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 57px;">
611      &nbsp;
612    </div>
613    <div class="line-number" data-start="5" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 76px;">
614      &nbsp;
615    </div>
616    <div class="line-number" data-start="6" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 95px;">
617      &nbsp;
618    </div>
619    <div class="line-number" data-start="7" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 114px;">
620      &nbsp;
621    </div>
622    <div class="line-number" data-start="8" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 133px;">
623      &nbsp;
624    </div>
625    <div class="line-number" data-start="9" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 152px;">
626      &nbsp;
627    </div>
628    <div class="line-number" data-start="10" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 171px;">
629      &nbsp;
630    </div>
631    <div class="line-number" data-start="11" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 190px;">
632      &nbsp;
633    </div>
634    <div class="line-number" data-start="12" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 209px;">
635      &nbsp;
636    </div>
637    <div class="line-number" data-start="13" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 228px;">
638      &nbsp;
639    </div>
640    <p>
353      <code>vibrator_on()</code> is the Gonk HAL API that turns o641      <code>vibrator_on()</code>&nbsp;is the Gonk HAL API that tu
>n the vibrator motor. Internally, this method sends a message to >rns on the vibrator motor. Internally, this method sends a messag
>the kernel driver by writing a value to a kernel object using <co>e to the kernel driver by writing a value to a kernel object usin
>de>sysfs</code>.>g<code>sysfs</code>.
n355    <h4 id="Fallback_HAL_API_implementations">n643    <h4 id="Fallback_HAL_API_implementations" style="line-height:
 > 18px; letter-spacing: normal;">
n361    <pre class="brush:cpp;">n649    <pre class="brush:cpp; language-cpp" data-number="" style="pa
 >dding-top: 1em; padding-right: 0px; padding-bottom: 1em; padding-
 >left: 30px; border-left-width: 6px; font-family: Consolas, Monaco
 >, 'Andale Mono', monospace; font-size: 14px; background-image: ur
 >l(https://developer.cdn.mozilla.net/media/redesign/img/blueprint-
 >dark.png); background-color: rgba(234, 239, 242, 0.246094); text-
 >shadow: none; direction: ltr; text-align: left; white-space: norm
 >al; word-break: normal; -webkit-hyphens: none; background-positio
 >n: 50% 0%; background-repeat: repeat repeat;">
362void Vibrate(const nsTArray&lt;uint32_t&gt; &amp;pattern) {650<code class="language-cpp" style="font-family: Consolas, Monaco, 
 >'Andale Mono', monospace; color: inherit; text-shadow: none; dire
 >ction: ltr; white-space: pre; word-spacing: normal; word-break: n
 >ormal; -webkit-hyphens: none;">void <span class="token function">
 >Vibrate<span class="token punctuation" style="color: rgb(153, 153
 >, 153);">(</span></span>const nsTArray<span class="token operator
 >" style="color: rgb(166, 127, 89); background-image: initial; bac
 >kground-attachment: initial; background-origin: initial; backgrou
 >nd-clip: initial; background-color: rgba(255, 255, 255, 0.496094)
 >;">&lt;</span>uint32_t&gt; <span class="token operator" style="co
 >lor: rgb(166, 127, 89); background-image: initial; background-att
 >achment: initial; background-origin: initial; background-clip: in
 >itial; background-color: rgba(255, 255, 255, 0.496094);">&amp;</s
 >pan>pattern<span class="token punctuation" style="color: rgb(153,
 > 153, 153);">)</span> <span class="token punctuation" style="colo
 >r: rgb(153, 153, 153);">{</span>
363}651<span class="token punctuation" style="color: rgb(153, 153, 153);
 >">}</span></code>
n365    <h4 id="Sandbox_implementations">n653    <div class="line-number" data-start="1" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 0px;">
654      &nbsp;
655    </div>
656    <div class="line-number" data-start="2" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 19px;">
657      &nbsp;
658    </div>
659    <h4 id="Sandbox_implementations" style="line-height: 18px; le
 >tter-spacing: normal;">
n372      For vibration, this is handled by the <code>Vibrate()</coden666      For vibration, this is handled by the&nbsp;<code>Vibrate()<
>> function implemented in {{source2("hal/sandbox/SandboxHal.cpp")>/code>&nbsp;function implemented in {{source2("hal/sandbox/Sandbo
>}}:>xHal.cpp")}}:
n374    <pre class="brush:cpp;">n668    <pre class="brush:cpp; language-cpp" data-number="" style="pa
 >dding-top: 1em; padding-right: 0px; padding-bottom: 1em; padding-
 >left: 30px; border-left-width: 6px; font-family: Consolas, Monaco
 >, 'Andale Mono', monospace; font-size: 14px; background-image: ur
 >l(https://developer.cdn.mozilla.net/media/redesign/img/blueprint-
 >dark.png); background-color: rgba(234, 239, 242, 0.246094); text-
 >shadow: none; direction: ltr; text-align: left; white-space: norm
 >al; word-break: normal; -webkit-hyphens: none; background-positio
 >n: 50% 0%; background-repeat: repeat repeat;">
375void Vibrate(const nsTArray&lt;uint32_t&gt;&amp; pattern, const W669<code class="language-cpp" style="font-family: Consolas, Monaco, 
>indowIdentifier &amp;id) {>'Andale Mono', monospace; color: inherit; text-shadow: none; dire
 >ction: ltr; white-space: pre; word-spacing: normal; word-break: n
 >ormal; -webkit-hyphens: none;">void <span class="token function">
 >Vibrate<span class="token punctuation" style="color: rgb(153, 153
 >, 153);">(</span></span>const nsTArray<span class="token operator
 >" style="color: rgb(166, 127, 89); background-image: initial; bac
 >kground-attachment: initial; background-origin: initial; backgrou
 >nd-clip: initial; background-color: rgba(255, 255, 255, 0.496094)
 >;">&lt;</span>uint32_t&gt;<span class="token operator" style="col
 >or: rgb(166, 127, 89); background-image: initial; background-atta
 >chment: initial; background-origin: initial; background-clip: ini
 >tial; background-color: rgba(255, 255, 255, 0.496094);">&amp;</sp
 >an> pattern<span class="token punctuation" style="color: rgb(153,
 > 153, 153);">,</span> const WindowIdentifier <span class="token o
 >perator" style="color: rgb(166, 127, 89); background-image: initi
 >al; background-attachment: initial; background-origin: initial; b
 >ackground-clip: initial; background-color: rgba(255, 255, 255, 0.
 >496094);">&amp;</span>id<span class="token punctuation" style="co
 >lor: rgb(153, 153, 153);">)</span> <span class="token punctuation
 >" style="color: rgb(153, 153, 153);">{</span>
376  AutoInfallibleTArray&lt;uint32_t, 8&gt; p(pattern);670  AutoInfallibleTArray<span class="token operator" style="color: 
 >rgb(166, 127, 89); background-image: initial; background-attachme
 >nt: initial; background-origin: initial; background-clip: initial
 >; background-color: rgba(255, 255, 255, 0.496094);">&lt;</span>ui
 >nt32_t<span class="token punctuation" style="color: rgb(153, 153,
 > 153);">,</span> <span class="token number" style="color: rgb(153
 >, 0, 85);">8</span>&gt; <span class="token function">p<span class
 >="token punctuation" style="color: rgb(153, 153, 153);">(</span><
 >/span>pattern<span class="token punctuation" style="color: rgb(15
 >3, 153, 153);">)</span><span class="token punctuation" style="col
 >or: rgb(153, 153, 153);">;</span>
n378  WindowIdentifier newID(id);n672  WindowIdentifier <span class="token function">newID<span class=
 >"token punctuation" style="color: rgb(153, 153, 153);">(</span></
 >span>id<span class="token punctuation" style="color: rgb(153, 153
 >, 153);">)</span><span class="token punctuation" style="color: rg
 >b(153, 153, 153);">;</span>
379  newID.AppendProcessID();673  newID<span class="token punctuation" style="color: rgb(153, 153
 >, 153);">.</span><span class="token function">AppendProcessID<spa
 >n class="token punctuation" style="color: rgb(153, 153, 153);">(<
 >/span></span><span class="token punctuation" style="color: rgb(15
 >3, 153, 153);">)</span><span class="token punctuation" style="col
 >or: rgb(153, 153, 153);">;</span>
380  Hal()-&gt;SendVibrate(p, newID.AsArray(), GetTabChildFrom(newID674  <span class="token function">Hal<span class="token punctuation"
>.GetWindow()));> style="color: rgb(153, 153, 153);">(</span></span><span class="t
 >oken punctuation" style="color: rgb(153, 153, 153);">)</span><spa
 >n class="token operator" style="color: rgb(166, 127, 89); backgro
 >und-image: initial; background-attachment: initial; background-or
 >igin: initial; background-clip: initial; background-color: rgba(2
 >55, 255, 255, 0.496094);">-</span>&gt;<span class="token function
 >">SendVibrate<span class="token punctuation" style="color: rgb(15
 >3, 153, 153);">(</span></span>p<span class="token punctuation" st
 >yle="color: rgb(153, 153, 153);">,</span> newID<span class="token
 > punctuation" style="color: rgb(153, 153, 153);">.</span><span cl
 >ass="token function">AsArray<span class="token punctuation" style
 >="color: rgb(153, 153, 153);">(</span></span><span class="token p
 >unctuation" style="color: rgb(153, 153, 153);">)</span><span clas
 >s="token punctuation" style="color: rgb(153, 153, 153);">,</span>
 > <span class="token function">GetTabChildFrom<span class="token p
 >unctuation" style="color: rgb(153, 153, 153);">(</span></span>new
 >ID<span class="token punctuation" style="color: rgb(153, 153, 153
 >);">.</span><span class="token function">GetWindow<span class="to
 >ken punctuation" style="color: rgb(153, 153, 153);">(</span></spa
 >n><span class="token punctuation" style="color: rgb(153, 153, 153
 >);">)</span><span class="token punctuation" style="color: rgb(153
 >, 153, 153);">)</span><span class="token punctuation" style="colo
 >r: rgb(153, 153, 153);">)</span><span class="token punctuation" s
 >tyle="color: rgb(153, 153, 153);">;</span>
381}675<span class="token punctuation" style="color: rgb(153, 153, 153);
 >">}</span></code>
nn677    <div class="line-number" data-start="1" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 0px;">
678      &nbsp;
679    </div>
680    <div class="line-number" data-start="2" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 19px;">
681      &nbsp;
682    </div>
683    <div class="line-number" data-start="3" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 38px;">
684      &nbsp;
685    </div>
686    <div class="line-number" data-start="4" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 57px;">
687      &nbsp;
688    </div>
689    <div class="line-number" data-start="5" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 76px;">
690      &nbsp;
691    </div>
692    <div class="line-number" data-start="6" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 95px;">
693      &nbsp;
694    </div>
695    <div class="line-number" data-start="7" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 114px;">
696      &nbsp;
697    </div>
n384      This sends a message defined by the <code>PHal</code> intern699      This sends a message defined by the&nbsp;<code>PHal</code>&
>face, described by IPDL in {{source2("hal/sandbox/PHal.ipdl")}}. >nbsp;interface, described by IPDL in {{source2("hal/sandbox/PHal.
>This method is described more or less as follows:>ipdl")}}. This method is described more or less as follows:
385    </p>
386    <pre>700    </p>
701    <pre class="language-html" style="padding-top: 1em; padding-r
 >ight: 1em; padding-bottom: 1em; padding-left: 1em; border-left-wi
 >dth: 6px; font-family: Consolas, Monaco, 'Andale Mono', monospace
 >; font-size: 14px; background-image: url(https://developer.cdn.mo
 >zilla.net/media/redesign/img/blueprint-dark.png); background-colo
 >r: rgba(234, 239, 242, 0.246094); text-shadow: none; direction: l
 >tr; text-align: left; white-space: normal; word-break: normal; -w
 >ebkit-hyphens: none; background-position: 50% 0%; background-repe
 >at: repeat repeat;">
n390      The receiver of this message is the <code>HalParent::RecvVin705      The receiver of this message is the&nbsp;<code>HalParent::R
>brate()</code> method in {{source2("hal/sandbox/SandboxHal.cpp")}>ecvVibrate()</code>&nbsp;method in {{source2("hal/sandbox/Sandbox
>}, which looks like this:>Hal.cpp")}}, which looks like this:
n392    <pre class="brush:cpp;">n707    <pre class="brush:cpp; language-cpp" data-number="" style="pa
 >dding-top: 1em; padding-right: 0px; padding-bottom: 1em; padding-
 >left: 30px; border-left-width: 6px; font-family: Consolas, Monaco
 >, 'Andale Mono', monospace; font-size: 14px; background-image: ur
 >l(https://developer.cdn.mozilla.net/media/redesign/img/blueprint-
 >dark.png); background-color: rgba(234, 239, 242, 0.246094); text-
 >shadow: none; direction: ltr; text-align: left; white-space: norm
 >al; word-break: normal; -webkit-hyphens: none; background-positio
 >n: 50% 0%; background-repeat: repeat repeat;">
393virtual bool RecvVibrate(const InfallibleTArray&lt;unsigned int&g708<code class="language-cpp" style="font-family: Consolas, Monaco, 
>t;&amp; pattern,>'Andale Mono', monospace; color: inherit; text-shadow: none; dire
 >ction: ltr; white-space: pre; word-spacing: normal; word-break: n
 >ormal; -webkit-hyphens: none;">virtual bool <span class="token fu
 >nction">RecvVibrate<span class="token punctuation" style="color: 
 >rgb(153, 153, 153);">(</span></span>const InfallibleTArray<span c
 >lass="token operator" style="color: rgb(166, 127, 89); background
 >-image: initial; background-attachment: initial; background-origi
 >n: initial; background-clip: initial; background-color: rgba(255,
 > 255, 255, 0.496094);">&lt;</span>unsigned int&gt;<span class="to
 >ken operator" style="color: rgb(166, 127, 89); background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: rgba(255, 255, 25
 >5, 0.496094);">&amp;</span> pattern<span class="token punctuation
 >" style="color: rgb(153, 153, 153);">,</span>
394            const InfallibleTArray&lt;uint64_t&gt; &amp;id,709            const InfallibleTArray<span class="token operator" st
 >yle="color: rgb(166, 127, 89); background-image: initial; backgro
 >und-attachment: initial; background-origin: initial; background-c
 >lip: initial; background-color: rgba(255, 255, 255, 0.496094);">&
 >lt;</span>uint64_t&gt; <span class="token operator" style="color:
 > rgb(166, 127, 89); background-image: initial; background-attachm
 >ent: initial; background-origin: initial; background-clip: initia
 >l; background-color: rgba(255, 255, 255, 0.496094);">&amp;</span>
 >id<span class="token punctuation" style="color: rgb(153, 153, 153
 >);">,</span>
395            PBrowserParent *browserParent) MOZ_OVERRIDE {710            PBrowserParent <span class="token operator" style="co
 >lor: rgb(166, 127, 89); background-image: initial; background-att
 >achment: initial; background-origin: initial; background-clip: in
 >itial; background-color: rgba(255, 255, 255, 0.496094);">*</span>
 >browserParent<span class="token punctuation" style="color: rgb(15
 >3, 153, 153);">)</span> MOZ_OVERRIDE <span class="token punctuati
 >on" style="color: rgb(153, 153, 153);">{</span>
n397  hal::Vibrate(pattern, newID);n712  hal<span class="token punctuation" style="color: rgb(153, 153, 
 >153);">:</span><span class="token punctuation" style="color: rgb(
 >153, 153, 153);">:</span><span class="token function">Vibrate<spa
 >n class="token punctuation" style="color: rgb(153, 153, 153);">(<
 >/span></span>pattern<span class="token punctuation" style="color:
 > rgb(153, 153, 153);">,</span> newID<span class="token punctuatio
 >n" style="color: rgb(153, 153, 153);">)</span><span class="token 
 >punctuation" style="color: rgb(153, 153, 153);">;</span>
398  return true;713  <span class="token keyword" style="color: rgb(0, 119, 170);">re
 >turn</span> <span class="token boolean" style="color: rgb(153, 0,
 > 85);">true</span><span class="token punctuation" style="color: r
 >gb(153, 153, 153);">;</span>
399}714<span class="token punctuation" style="color: rgb(153, 153, 153);
 >">}</span></code>
nn716    <div class="line-number" data-start="1" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 0px;">
717      &nbsp;
718    </div>
719    <div class="line-number" data-start="2" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 19px;">
720      &nbsp;
721    </div>
722    <div class="line-number" data-start="3" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 38px;">
723      &nbsp;
724    </div>
725    <div class="line-number" data-start="4" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 57px;">
726      &nbsp;
727    </div>
728    <div class="line-number" data-start="5" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 76px;">
729      &nbsp;
730    </div>
731    <div class="line-number" data-start="6" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 95px;">
732      &nbsp;
733    </div>
734    <div class="line-number" data-start="7" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 114px;">
735      &nbsp;
736    </div>
n402      This omits some details that aren't relevant to this discusn738      This omits some details that aren't relevant to this discus
>sion; however, it shows how the message progresses from a content>sion; however, it shows how the message progresses from a content
> process through Gecko to Gonk, then to the Gonk HAL implementati> process through Gecko to Gonk, then to the Gonk HAL implementati
>on of <code>Vibrate()</code>, and eventually to the graphics driv>on of&nbsp;<code>Vibrate()</code>, and eventually to the Vibratio
>er.>n driver.
n404    <h3 id="DOM_APIs">n740    <h3 id="DOM_APIs" style="line-height: 24px; letter-spacing: n
 >ormal;">
n408      <strong>DOM interfaces</strong> are, in essence, how web con744      <strong>DOM interfaces</strong>&nbsp;are, in essence, how w
>ntent communicates with Gecko. There's more involved than that, a>eb content communicates with Gecko. There's more involved than th
>nd if you're interested in added details, you can read <a href="/>at, and if you're interested in added details, you can read&nbsp;
>en-US/docs/DOM/About_the_Document_Object_Model" title="/en-US/doc><a href="https://developer.mozilla.org/en-US/docs/DOM/About_the_D
>s/DOM/About_the_Document_Object_Model">about the DOM</a>. DOM int>ocument_Object_Model" title="/en-US/docs/DOM/About_the_Document_O
>erfaces are defined using <a href="/en-US/docs/XPIDL" title="/en->bject_Model">about the DOM</a>. DOM interfaces are defined using&
>US/docs/XPIDL">IDL</a>, which comprises both a foreign function i>nbsp;<a href="https://developer.mozilla.org/en-US/docs/XPIDL" tit
>nterface (FFI) and object model (OM) between JavaScript and C++.>le="/en-US/docs/XPIDL">IDL</a>, which comprises both a foreign fu
 >nction interface (FFI) and object model (OM) between JavaScript a
 >nd C++.
409    </p>
410    <p>745    </p>
746    <p>
411      The vibration API is exposed to web content through an IDL 747      The vibration API is exposed to web content through an IDL 
>interface, which is provided in <code>{{source("dom/interfaces/ba>interface, which is provided in&nbsp;<code>{{source("dom/interfac
>se/nsIDOMNavigator.idl", "nsIDOMNavigator.idl")}}:</code>>es/base/nsIDOMNavigator.idl", "nsIDOMNavigator.idl")}}:</code>
412    </p>
413    <pre>748    </p>
749    <pre class="language-html" style="padding-top: 1em; padding-r
 >ight: 1em; padding-bottom: 1em; padding-left: 1em; border-left-wi
 >dth: 6px; font-family: Consolas, Monaco, 'Andale Mono', monospace
 >; font-size: 14px; background-image: url(https://developer.cdn.mo
 >zilla.net/media/redesign/img/blueprint-dark.png); background-colo
 >r: rgba(234, 239, 242, 0.246094); text-shadow: none; direction: l
 >tr; text-align: left; white-space: normal; word-break: normal; -w
 >ebkit-hyphens: none; background-position: 50% 0%; background-repe
 >at: repeat repeat;">
n417      The <a href="/en-US/docs/SpiderMonkey/JSAPI_Reference/Jsvaln753      The&nbsp;<a href="https://developer.mozilla.org/en-US/docs/
>" title="/en-US/docs/SpiderMonkey/JSAPI_Reference/JSVAL_IS_OBJECT>SpiderMonkey/JSAPI_Reference/Jsval" title="/en-US/docs/SpiderMonk
>"><code>jsval</code></a> argument indicates that <code>mozVibrate>ey/JSAPI_Reference/JSVAL_IS_OBJECT"><code>jsval</code></a>&nbsp;a
>()</code> (which is our vendor-prefixed implementation of this no>rgument indicates that&nbsp;<code>mozVibrate()</code>&nbsp;(which
>n-finalized vibration specification) accepts as input any JavaScr> is our vendor-prefixed implementation of this non-finalized vibr
>ipt value. The IDL compiler, <a href="/en-US/docs/XPIDL/xpidl" ti>ation specification) accepts as input any JavaScript value. The I
>tle="/en-US/docs/XPIDL/xpidl"><code>xpidl</code></a>, generates a>DL compiler,&nbsp;<a href="https://developer.mozilla.org/en-US/do
> C++ interface that's then implemented by the <code>Navigator</co>cs/XPIDL/xpidl" title="/en-US/docs/XPIDL/xpidl"><code>xpidl</code
>de> class in <code>{{source("dom/base/Navigator.cpp", "Navigator.>></a>, generates a C++ interface that's then implemented by the&n
>cpp")}}</code>.>bsp;<code>Navigator</code>&nbsp;class in&nbsp;<code>{{source("dom
 >/base/Navigator.cpp", "Navigator.cpp")}}</code>.
418    </p>
419    <pre class="brush:cpp;">
420NS_IMETHODIMP Navigator::MozVibrate(const jsval&amp; aPattern, JS
>Context* cx) { 
421  // ...
422  hal::Vibrate(pattern);
423  return NS_OK;
424}
425</pre>
426    <p>754    </p>
755    <pre class="brush:cpp; language-cpp" data-number="" style="pa
 >dding-top: 1em; padding-right: 0px; padding-bottom: 1em; padding-
 >left: 30px; border-left-width: 6px; font-family: Consolas, Monaco
 >, 'Andale Mono', monospace; font-size: 14px; background-image: ur
 >l(https://developer.cdn.mozilla.net/media/redesign/img/blueprint-
 >dark.png); background-color: rgba(234, 239, 242, 0.246094); text-
 >shadow: none; direction: ltr; text-align: left; white-space: norm
 >al; word-break: normal; -webkit-hyphens: none; background-positio
 >n: 50% 0%; background-repeat: repeat repeat;">
756<code class="language-cpp" style="font-family: Consolas, Monaco, 
 >'Andale Mono', monospace; color: inherit; text-shadow: none; dire
 >ction: ltr; white-space: pre; word-spacing: normal; word-break: n
 >ormal; -webkit-hyphens: none;">NS_IMETHODIMP Navigator<span class
 >="token punctuation" style="color: rgb(153, 153, 153);">:</span><
 >span class="token punctuation" style="color: rgb(153, 153, 153);"
 >>:</span><span class="token function">MozVibrate<span class="toke
 >n punctuation" style="color: rgb(153, 153, 153);">(</span></span>
 >const jsval<span class="token operator" style="color: rgb(166, 12
 >7, 89); background-image: initial; background-attachment: initial
 >; background-origin: initial; background-clip: initial; backgroun
 >d-color: rgba(255, 255, 255, 0.496094);">&amp;</span> aPattern<sp
 >an class="token punctuation" style="color: rgb(153, 153, 153);">,
 ></span> JSContext<span class="token operator" style="color: rgb(1
 >66, 127, 89); background-image: initial; background-attachment: i
 >nitial; background-origin: initial; background-clip: initial; bac
 >kground-color: rgba(255, 255, 255, 0.496094);">*</span> cx<span c
 >lass="token punctuation" style="color: rgb(153, 153, 153);">)</sp
 >an> <span class="token punctuation" style="color: rgb(153, 153, 1
 >53);">{</span>
757 <span class="token comment" spellcheck="true" style="display: in
 >herit; color: rgb(112, 128, 144);"> // ...
758</span>  hal<span class="token punctuation" style="color: rgb(153
 >, 153, 153);">:</span><span class="token punctuation" style="colo
 >r: rgb(153, 153, 153);">:</span><span class="token function">Vibr
 >ate<span class="token punctuation" style="color: rgb(153, 153, 15
 >3);">(</span></span>pattern<span class="token punctuation" style=
 >"color: rgb(153, 153, 153);">)</span><span class="token punctuati
 >on" style="color: rgb(153, 153, 153);">;</span>
759  <span class="token keyword" style="color: rgb(0, 119, 170);">re
 >turn</span> NS_OK<span class="token punctuation" style="color: rg
 >b(153, 153, 153);">;</span>
760<span class="token punctuation" style="color: rgb(153, 153, 153);
 >">}</span></code>
761</pre>
762    <div class="line-number" data-start="1" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 0px;">
763      &nbsp;
764    </div>
765    <div class="line-number" data-start="2" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 19px;">
766      &nbsp;
767    </div>
768    <div class="line-number" data-start="3" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 38px;">
769      &nbsp;
770    </div>
771    <div class="line-number" data-start="4" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 57px;">
772      &nbsp;
773    </div>
774    <div class="line-number" data-start="5" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 76px;">
775      &nbsp;
776    </div>
777    <p>
427      There's a lot more code in this method than what you see he778      There's a lot more code in this method than what you see he
>re, but it's not important for the purposes of this discussion. T>re, but it's not important for the purposes of this discussion. T
>he point is that the call to <code>hal::Vibrate()</code> transfer>he point is that the call to&nbsp;<code>hal::Vibrate()</code>&nbs
>s control from the DOM to the Gecko HAL. From there, we enter the>p;transfers control from the DOM to the Gecko HAL. From there, we
> HAL implementation discussed in the previous section and work ou> enter the HAL implementation discussed in the previous section a
>r way down toward the graphics driver. On top of that, the DOM im>nd work our way down toward the graphics driver. On top of that, 
>plementation doesn't care at all what platform it's running on (G>the DOM implementation doesn't care at all what platform it's run
>onk, Windows, Mac OS X, or anything else). It also doesn't care w>ning on (Gonk, Windows, Mac OS X, or anything else). It also does
>hether the code is running in a content process or in the Gecko s>n't care whether the code is running in a content process or in t
>erver process. Those details are all left to lower levels of the >he Gecko server process. Those details are all left to lower leve
>system to deal with.>ls of the system to deal with.
428    </p>
429    <p>779    </p>
430      The vibration API is a very simple API, which makes it a go
>od example. The <a href="/en-US/docs/API/WebSMS" title="/en-US/do 
>cs/API/WebSMS">SMS API</a> is an example of a more complex API wh 
>ich uses its own "remoting" layer connecting content processes to 
> the server. 
431    </p>780    <p>
432    <h2 id="Radio_Interface_Layer_(RIL)">781      The vibration API is a very simple API, which makes it a go
 >od example. The&nbsp;<a href="https://developer.mozilla.org/en-US
 >/docs/API/WebSMS" title="/en-US/docs/API/WebSMS">SMS API</a>&nbsp
 >;is an example of a more complex API which uses its own "remoting
 >" layer connecting content processes to the server.
782    </p>
783    <h2 id="Radio_Interface_Layer_(RIL)" style="margin-bottom: 20
 >px; line-height: 30px;">
n452        The daemon that proxies messages between <code>rild</coden803        The daemon that proxies messages between&nbsp;<code>rild<
>> and Gecko (which is implemented in the <code>b2g</code> process>/code>&nbsp;and Gecko (which is implemented in the&nbsp;<code>b2g
>). This overcomes the permission problem that arises when trying ></code>&nbsp;process). This overcomes the permission problem that
>to talk to <code>rild</code> directly, since <code>rild</code> ca> arises when trying to talk to&nbsp;<code>rild</code>&nbsp;direct
>n only be communicated with from within the <code>radio</code> gr>ly, since&nbsp;<code>rild</code>&nbsp;can only be communicated wi
>oup.>th from within the&nbsp;<code>radio</code>group.
n458        This process, also known as the <strong>chrome process</sn809        This process, also known as the&nbsp;<strong>chrome proce
>trong>, implements Gecko. The portions of it that relate to the R>ss</strong>, implements Gecko. The portions of it that relate to 
>adio Interface Layer are {{source2("dom/system/gonk/ril_worker.js>the Radio Interface Layer are {{source2("dom/system/gonk/ril_work
>")}} (which implements a worker thread that talks to <code>rild</>er.js")}} (which implements a worker thread that talks to&nbsp;<c
>code> through <code>rilproxy</code> and implements the radio stat>ode>rild</code>&nbsp;through&nbsp;<code>rilproxy</code>&nbsp;and 
>e machine; and the {{interface("nsIRadioInterfaceLayer")}} interf>implements the radio state machine; and the {{interface("nsIRadio
>ace, which is the main thread's <a href="/en-US/docs/XPCOM" title>InterfaceLayer")}} interface, which is the main thread's&nbsp;<a 
>="/en-US/docs/XPCOM">XPCOM</a> service that acts primarily as a m>href="https://developer.mozilla.org/en-US/docs/XPCOM" title="/en-
>essage exchange between the <code>ril_worker.js</code> thread and>US/docs/XPCOM">XPCOM</a>service that acts primarily as a message 
> various other Gecko components, including the Gecko content proc>exchange between the&nbsp;<code>ril_worker.js</code>&nbsp;thread 
>ess.>and various other Gecko components, including the Gecko content p
 >rocess.
n464        Within Gecko's content process, the {{interface("nsIRILCon815        Within Gecko's content process, the {{interface("nsIRILCo
>ntentHelper")}} interface provides an XPCOM service that lets cod>ntentHelper")}} interface provides an XPCOM service that lets cod
>e implementing parts of the DOM, such as the <a href="/en-US/docs>e implementing parts of the DOM, such as the<a href="https://deve
>/API/WebTelephony" title="/en-US/docs/API/WebTelephony">Telephony>loper.mozilla.org/en-US/docs/API/WebTelephony" title="/en-US/docs
></a> and <a href="/en-US/docs/API/WebSMS" title="/en-US/docs/API/>/API/WebTelephony">Telephony</a>&nbsp;and&nbsp;<a href="https://d
>WebSMS">SMS</a> APIs talk to the radio interface, which is in the>eveloper.mozilla.org/en-US/docs/API/WebSMS" title="/en-US/docs/AP
> chrome process.>I/WebSMS">SMS</a>&nbsp;APIs talk to the radio interface, which is
 > in the chrome process.
n467    <h3 id="Example.3A_Communicating_from_rild_to_the_DOM">n818    <h3 id="Example.3A_Communicating_from_rild_to_the_DOM" style=
 >"line-height: 24px; letter-spacing: normal;">
n471      Let's take a look at an example of how the lower level partn822      Let's take a look at an example of how the lower level part
>s of the system communicate with DOM code. When the modem receive>s of the system communicate with DOM code. When the modem receive
>s an incoming call, it notifies <code>rild</code> using a proprie>s an incoming call, it notifies&nbsp;<code>rild</code>&nbsp;using
>tary mechanism. <code>rild</code> then prepares a message for its> a proprietary mechanism.&nbsp;<code>rild</code>&nbsp;then prepar
> client according to the "open" protocol, which is described in <>es a message for its client according to the "open" protocol, whi
>a href="https://github.com/mozilla-b2g/android-hardware-ril/blob/>ch is described in&nbsp;<a href="https://github.com/mozilla-b2g/a
>master/include/telephony/ril.h" title="https://github.com/mozilla>ndroid-hardware-ril/blob/master/include/telephony/ril.h" title="h
>-b2g/android-hardware-ril/blob/master/include/telephony/ril.h"><c>ttps://github.com/mozilla-b2g/android-hardware-ril/blob/master/in
>ode>ril.h</code></a>. In the case of an incoming call, a <code>RI>clude/telephony/ril.h"><code>ril.h</code></a>. In the case of an 
>L_UNSOL_RESPONSE_CALL_STATE_CHANGED</code> message is generated a>incoming call, a<code>RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED</code
>nd sent by <code>rild</code> to <code>rilproxy</code>.>>&nbsp;message is generated and sent by&nbsp;<code>rild</code>&nb
 >sp;to<code>rilproxy</code>.
472    </p>
473    <p>823    </p>
474      <code>rilproxy</code>, implemented in <a href="https://gith
>ub.com/mozilla-b2g/rilproxy/blob/master/src/rilproxy.c" title="ht 
>tps://github.com/mozilla-b2g/rilproxy/blob/master/src/rilproxy.c" 
>><code>rilproxy.c</code></a>, receives this message in its main l 
>oop, which polls its connection to <code>rild</code> using code l 
>ike this: 
475    </p>824    <p>
476    <pre class="brush:cpp;">825      <code>rilproxy</code>, implemented in&nbsp;<a href="https:/
 >/github.com/mozilla-b2g/rilproxy/blob/master/src/rilproxy.c" titl
 >e="https://github.com/mozilla-b2g/rilproxy/blob/master/src/rilpro
 >xy.c"><code>rilproxy.c</code></a>, receives this message in its m
 >ain loop, which polls its connection to&nbsp;<code>rild</code>&nb
 >sp;using code like this:
477ret = read(rilproxy_rw, data, 1024);826    </p>
827    <pre class="brush:cpp; language-cpp" data-number="" style="pa
 >dding-top: 1em; padding-right: 0px; padding-bottom: 1em; padding-
 >left: 30px; border-left-width: 6px; font-family: Consolas, Monaco
 >, 'Andale Mono', monospace; font-size: 14px; background-image: ur
 >l(https://developer.cdn.mozilla.net/media/redesign/img/blueprint-
 >dark.png); background-color: rgba(234, 239, 242, 0.246094); text-
 >shadow: none; direction: ltr; text-align: left; white-space: norm
 >al; word-break: normal; -webkit-hyphens: none; background-positio
 >n: 50% 0%; background-repeat: repeat repeat;">
828<code class="language-cpp" style="font-family: Consolas, Monaco, 
 >'Andale Mono', monospace; color: inherit; text-shadow: none; dire
 >ction: ltr; white-space: pre; word-spacing: normal; word-break: n
 >ormal; -webkit-hyphens: none;">ret <span class="token operator" s
 >tyle="color: rgb(166, 127, 89); background-image: initial; backgr
 >ound-attachment: initial; background-origin: initial; background-
 >clip: initial; background-color: rgba(255, 255, 255, 0.496094);">
 >=</span> <span class="token function">read<span class="token punc
 >tuation" style="color: rgb(153, 153, 153);">(</span></span>rilpro
 >xy_rw<span class="token punctuation" style="color: rgb(153, 153, 
 >153);">,</span> data<span class="token punctuation" style="color:
 > rgb(153, 153, 153);">,</span> <span class="token number" style="
 >color: rgb(153, 0, 85);">1024</span><span class="token punctuatio
 >n" style="color: rgb(153, 153, 153);">)</span><span class="token 
 >punctuation" style="color: rgb(153, 153, 153);">;</span>
n479if(ret &gt; 0) {n830<span class="token keyword" style="color: rgb(0, 119, 170);">if</
 >span><span class="token punctuation" style="color: rgb(153, 153, 
 >153);">(</span>ret &gt; <span class="token number" style="color: 
 >rgb(153, 0, 85);">0</span><span class="token punctuation" style="
 >color: rgb(153, 153, 153);">)</span> <span class="token punctuati
 >on" style="color: rgb(153, 153, 153);">{</span>
480  writeToSocket(rild_rw, data, ret);831  <span class="token function">writeToSocket<span class="token pu
 >nctuation" style="color: rgb(153, 153, 153);">(</span></span>rild
 >_rw<span class="token punctuation" style="color: rgb(153, 153, 15
 >3);">,</span> data<span class="token punctuation" style="color: r
 >gb(153, 153, 153);">,</span> ret<span class="token punctuation" s
 >tyle="color: rgb(153, 153, 153);">)</span><span class="token punc
 >tuation" style="color: rgb(153, 153, 153);">;</span>
481}832<span class="token punctuation" style="color: rgb(153, 153, 153);
 >">}</span></code>
nn834    <div class="line-number" data-start="1" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 0px;">
835      &nbsp;
836    </div>
837    <div class="line-number" data-start="2" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 19px;">
838      &nbsp;
839    </div>
840    <div class="line-number" data-start="3" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 38px;">
841      &nbsp;
842    </div>
843    <div class="line-number" data-start="4" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 57px;">
844      &nbsp;
845    </div>
846    <div class="line-number" data-start="5" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 76px;">
847      &nbsp;
848    </div>
n484      Once the message is received from <code>rild</code>, it's tn850      Once the message is received from&nbsp;<code>rild</code>, i
>hen forwarded along to Gecko on the socket that connects <code>ri>t's then forwarded along to Gecko on the socket that connects&nbs
>lproxy</code> to Gecko. Gecko receives the forwarded message on i>p;<code>rilproxy</code>&nbsp;to Gecko. Gecko receives the forward
>ts {{source("ipc/ril/Ril.cpp", "IPC thread")}}:>ed message on its {{source("ipc/ril/Ril.cpp", "IPC thread")}}:
n486    <pre class="brush:cpp;">n852    <pre class="brush:cpp; language-cpp" data-number="" style="pa
 >dding-top: 1em; padding-right: 0px; padding-bottom: 1em; padding-
 >left: 30px; border-left-width: 6px; font-family: Consolas, Monaco
 >, 'Andale Mono', monospace; font-size: 14px; background-image: ur
 >l(https://developer.cdn.mozilla.net/media/redesign/img/blueprint-
 >dark.png); background-color: rgba(234, 239, 242, 0.246094); text-
 >shadow: none; direction: ltr; text-align: left; white-space: norm
 >al; word-break: normal; -webkit-hyphens: none; background-positio
 >n: 50% 0%; background-repeat: repeat repeat;">
487int ret = read(fd, mIncoming-&gt;Data, 1024);853<code class="language-cpp" style="font-family: Consolas, Monaco, 
 >'Andale Mono', monospace; color: inherit; text-shadow: none; dire
 >ction: ltr; white-space: pre; word-spacing: normal; word-break: n
 >ormal; -webkit-hyphens: none;">int ret <span class="token operato
 >r" style="color: rgb(166, 127, 89); background-image: initial; ba
 >ckground-attachment: initial; background-origin: initial; backgro
 >und-clip: initial; background-color: rgba(255, 255, 255, 0.496094
 >);">=</span> <span class="token function">read<span class="token 
 >punctuation" style="color: rgb(153, 153, 153);">(</span></span>fd
 ><span class="token punctuation" style="color: rgb(153, 153, 153);
 >">,</span> mIncoming<span class="token operator" style="color: rg
 >b(166, 127, 89); background-image: initial; background-attachment
 >: initial; background-origin: initial; background-clip: initial; 
 >background-color: rgba(255, 255, 255, 0.496094);">-</span>&gt;Dat
 >a<span class="token punctuation" style="color: rgb(153, 153, 153)
 >;">,</span> <span class="token number" style="color: rgb(153, 0, 
 >85);">1024</span><span class="token punctuation" style="color: rg
 >b(153, 153, 153);">)</span><span class="token punctuation" style=
 >"color: rgb(153, 153, 153);">;</span><span class="token comment" 
 >spellcheck="true" style="display: inherit; color: rgb(112, 128, 1
 >44);">
n489mIncoming-&gt;mSize = ret;n855</span>mIncoming<span class="token operator" style="color: rgb(16
 >6, 127, 89); background-image: initial; background-attachment: in
 >itial; background-origin: initial; background-clip: initial; back
 >ground-color: rgba(255, 255, 255, 0.496094);">-</span>&gt;mSize <
 >span class="token operator" style="color: rgb(166, 127, 89); back
 >ground-image: initial; background-attachment: initial; background
 >-origin: initial; background-clip: initial; background-color: rgb
 >a(255, 255, 255, 0.496094);">=</span> ret<span class="token punct
 >uation" style="color: rgb(153, 153, 153);">;</span>
490sConsumer-&gt;MessageReceived(mIncoming.forget());856sConsumer<span class="token operator" style="color: rgb(166, 127,
 > 89); background-image: initial; background-attachment: initial; 
 >background-origin: initial; background-clip: initial; background-
 >color: rgba(255, 255, 255, 0.496094);">-</span>&gt;<span class="t
 >oken function">MessageReceived<span class="token punctuation" sty
 >le="color: rgb(153, 153, 153);">(</span></span>mIncoming<span cla
 >ss="token punctuation" style="color: rgb(153, 153, 153);">.</span
 >><span class="token function">forget<span class="token punctuatio
 >n" style="color: rgb(153, 153, 153);">(</span></span><span class=
 >"token punctuation" style="color: rgb(153, 153, 153);">)</span><s
 >pan class="token punctuation" style="color: rgb(153, 153, 153);">
 >)</span><span class="token punctuation" style="color: rgb(153, 15
 >3, 153);">;</span></code>
nn858    <div class="line-number" data-start="1" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 0px;">
859      &nbsp;
860    </div>
861    <div class="line-number" data-start="2" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 19px;">
862      &nbsp;
863    </div>
864    <div class="line-number" data-start="3" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 38px;">
865      &nbsp;
866    </div>
867    <div class="line-number" data-start="4" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 57px;">
868      &nbsp;
869    </div>
n493      The consumer of these messages is {{source("dom/system/gonkn871      The consumer of these messages is {{source("dom/system/gonk
>/SystemWorkerManager.cpp", "SystemWorkerManager")}}, which repack>/SystemWorkerManager.cpp", "SystemWorkerManager")}}, which repack
>ages the messages and dispatches them to the <code>{{source("dom/>ages the messages and dispatches them to the<code>{{source("dom/s
>system/gonk/ril_worker.js", "ril_worker.js")}}</code> thread that>ystem/gonk/ril_worker.js", "ril_worker.js")}}</code>&nbsp;thread 
> implements the RIL state machine; this is done in the <code>RILR>that implements the RIL state machine; this is done in the<code>R
>eceiver::MessageReceived()</code> method:>ILReceiver::MessageReceived()</code>&nbsp;method:
494    </p>
495    <pre class="brush:cpp;">
496virtual void MessageReceived(RilRawData *aMessage) {
497  nsRefPtr&lt;DispatchRILEvent&gt; dre(new DispatchRILEvent(aMess
>age)); 
498  mDispatcher-&gt;PostTask(dre);
499}
500</pre>
501    <p>872    </p>
502      The task posted to that thread in turn calls the <code>onRI873    <pre class="brush:cpp; language-cpp" data-number="" style="pa
>LMessage()</code> function, which is implemented in JavaScript. T>dding-top: 1em; padding-right: 0px; padding-bottom: 1em; padding-
>his is done using the JavaScript API function <code><a href="/en->left: 30px; border-left-width: 6px; font-family: Consolas, Monaco
>US/docs/SpiderMonkey/JSAPI_Reference/JS_CallFunctionName" title=">, 'Andale Mono', monospace; font-size: 14px; background-image: ur
>/en-US/docs/SpiderMonkey/JSAPI_Reference/JS_CallFunctionName">JS_>l(https://developer.cdn.mozilla.net/media/redesign/img/blueprint-
>CallFunctionName</a>()</code>:>dark.png); background-color: rgba(234, 239, 242, 0.246094); text-
 >shadow: none; direction: ltr; text-align: left; white-space: norm
 >al; word-break: normal; -webkit-hyphens: none; background-positio
 >n: 50% 0%; background-repeat: repeat repeat;">
874<code class="language-cpp" style="font-family: Consolas, Monaco, 
 >'Andale Mono', monospace; color: inherit; text-shadow: none; dire
 >ction: ltr; white-space: pre; word-spacing: normal; word-break: n
 >ormal; -webkit-hyphens: none;">virtual void <span class="token fu
 >nction">MessageReceived<span class="token punctuation" style="col
 >or: rgb(153, 153, 153);">(</span></span>RilRawData <span class="t
 >oken operator" style="color: rgb(166, 127, 89); background-image:
 > initial; background-attachment: initial; background-origin: init
 >ial; background-clip: initial; background-color: rgba(255, 255, 2
 >55, 0.496094);">*</span>aMessage<span class="token punctuation" s
 >tyle="color: rgb(153, 153, 153);">)</span> <span class="token pun
 >ctuation" style="color: rgb(153, 153, 153);">{</span>
875  nsRefPtr<span class="token operator" style="color: rgb(166, 127
 >, 89); background-image: initial; background-attachment: initial;
 > background-origin: initial; background-clip: initial; background
 >-color: rgba(255, 255, 255, 0.496094);">&lt;</span>DispatchRILEve
 >nt&gt; <span class="token function">dre<span class="token punctua
 >tion" style="color: rgb(153, 153, 153);">(</span></span><span cla
 >ss="token keyword" style="color: rgb(0, 119, 170);">new</span> <s
 >pan class="token class-name">DispatchRILEvent</span><span class="
 >token punctuation" style="color: rgb(153, 153, 153);">(</span>aMe
 >ssage<span class="token punctuation" style="color: rgb(153, 153, 
 >153);">)</span><span class="token punctuation" style="color: rgb(
 >153, 153, 153);">)</span><span class="token punctuation" style="c
 >olor: rgb(153, 153, 153);">;</span>
876  mDispatcher<span class="token operator" style="color: rgb(166, 
 >127, 89); background-image: initial; background-attachment: initi
 >al; background-origin: initial; background-clip: initial; backgro
 >und-color: rgba(255, 255, 255, 0.496094);">-</span>&gt;<span clas
 >s="token function">PostTask<span class="token punctuation" style=
 >"color: rgb(153, 153, 153);">(</span></span>dre<span class="token
 > punctuation" style="color: rgb(153, 153, 153);">)</span><span cl
 >ass="token punctuation" style="color: rgb(153, 153, 153);">;</spa
 >n>
877<span class="token punctuation" style="color: rgb(153, 153, 153);
 >">}</span></code>
878</pre>
879    <div class="line-number" data-start="1" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 0px;">
880      &nbsp;
881    </div>
882    <div class="line-number" data-start="2" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 19px;">
883      &nbsp;
884    </div>
885    <div class="line-number" data-start="3" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 38px;">
886      &nbsp;
887    </div>
888    <div class="line-number" data-start="4" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 57px;">
889      &nbsp;
890    </div>
503    </p>891    <p>
504    <pre>892      The task posted to that thread in turn calls the&nbsp;<code
 >>onRILMessage()</code>&nbsp;function, which is implemented in Jav
 >aScript. This is done using the JavaScript API function<code><a h
 >ref="https://developer.mozilla.org/en-US/docs/SpiderMonkey/JSAPI_
 >Reference/JS_CallFunctionName" title="/en-US/docs/SpiderMonkey/JS
 >API_Reference/JS_CallFunctionName">JS_CallFunctionName</a>()</cod
 >e>:
505return JS_CallFunctionName(aCx, obj, "onRILMessage", NS_ARRAY_LEN
>GTH(argv), 
506                           argv, argv);
507</pre>
508    <p>893    </p>
509      <code>onRILMessage()</code> is implemented in {{source2("do894    <pre class="language-html" style="padding-top: 1em; padding-r
>m/system/gonk/ril_worker.js")}}, which processes the message byte>ight: 1em; padding-bottom: 1em; padding-left: 1em; border-left-wi
>s and chops them into parcels. Each complete parcel is then dispa>dth: 6px; font-family: Consolas, Monaco, 'Andale Mono', monospace
>tched to individual handler methods as appropriate:>; font-size: 14px; background-image: url(https://developer.cdn.mo
 >zilla.net/media/redesign/img/blueprint-dark.png); background-colo
 >r: rgba(234, 239, 242, 0.246094); text-shadow: none; direction: l
 >tr; text-align: left; white-space: normal; word-break: normal; -w
 >ebkit-hyphens: none; background-position: 50% 0%; background-repe
 >at: repeat repeat;">
895return JS_CallFunctionName(aCx, obj, "onRILMessage", NS_ARRAY_LEN
 >GTH(argv), argv, argv);
896</pre>
510    </p>897    <p>
511    <pre class="brush:js;">898      <code>onRILMessage()</code>&nbsp;is implemented in {{source
 >2("dom/system/gonk/ril_worker.js")}}, which processes the message
 > bytes and chops them into parcels. Each complete parcel is then 
 >dispatched to individual handler methods as appropriate:
512handleParcel: function handleParcel(request_type, length) {899    </p>
513  let method = this[request_type];900    <pre class="brush:js; language-js" data-number="" style="padd
 >ing-top: 1em; padding-right: 0px; padding-bottom: 1em; padding-le
 >ft: 30px; border-left-width: 6px; font-family: Consolas, Monaco, 
 >'Andale Mono', monospace; font-size: 14px; background-image: url(
 >https://developer.cdn.mozilla.net/media/redesign/img/blueprint-da
 >rk.png); background-color: rgba(234, 239, 242, 0.246094); text-sh
 >adow: none; direction: ltr; text-align: left; white-space: normal
 >; word-break: normal; -webkit-hyphens: none; background-position:
 > 50% 0%; background-repeat: repeat repeat;">
514  if (typeof method == "function") {901<code class="language-js" style="font-family: Consolas, Monaco, '
 >Andale Mono', monospace; color: inherit; text-shadow: none; direc
 >tion: ltr; white-space: pre; word-spacing: normal; word-break: no
 >rmal; -webkit-hyphens: none;">handleParcel<span class="token punc
 >tuation" style="color: rgb(153, 153, 153);">:</span> <span class=
 >"token keyword" style="color: rgb(0, 119, 170);">function</span> 
 ><span class="token function">handleParcel<span class="token punct
 >uation" style="color: rgb(153, 153, 153);">(</span></span>request
 >_type<span class="token punctuation" style="color: rgb(153, 153, 
 >153);">,</span> length<span class="token punctuation" style="colo
 >r: rgb(153, 153, 153);">)</span> <span class="token punctuation" 
 >style="color: rgb(153, 153, 153);">{</span>
515    if (DEBUG) debug("Handling parcel as " + method.name);902  <span class="token keyword" style="color: rgb(0, 119, 170);">le
 >t</span> method <span class="token operator" style="color: rgb(16
 >6, 127, 89); background-image: initial; background-attachment: in
 >itial; background-origin: initial; background-clip: initial; back
 >ground-color: rgba(255, 255, 255, 0.496094);">=</span> this<span 
 >class="token punctuation" style="color: rgb(153, 153, 153);">[</s
 >pan>request_type<span class="token punctuation" style="color: rgb
 >(153, 153, 153);">]</span><span class="token punctuation" style="
 >color: rgb(153, 153, 153);">;</span>
516    method.call(this, length);903  <span class="token keyword" style="color: rgb(0, 119, 170);">if
 ></span> <span class="token punctuation" style="color: rgb(153, 15
 >3, 153);">(</span><span class="token keyword" style="color: rgb(0
 >, 119, 170);">typeof</span> method <span class="token operator" s
 >tyle="color: rgb(166, 127, 89); background-image: initial; backgr
 >ound-attachment: initial; background-origin: initial; background-
 >clip: initial; background-color: rgba(255, 255, 255, 0.496094);">
 >==</span> <span class="token string" style="color: rgb(102, 153, 
 >0);">"function"</span><span class="token punctuation" style="colo
 >r: rgb(153, 153, 153);">)</span> <span class="token punctuation" 
 >style="color: rgb(153, 153, 153);">{</span>
517  }904    <span class="token keyword" style="color: rgb(0, 119, 170);">
 >if</span> <span class="token punctuation" style="color: rgb(153, 
 >153, 153);">(</span>DEBUG<span class="token punctuation" style="c
 >olor: rgb(153, 153, 153);">)</span> <span class="token function">
 >debug<span class="token punctuation" style="color: rgb(153, 153, 
 >153);">(</span></span><span class="token string" style="color: rg
 >b(102, 153, 0);">"Handling parcel as "</span> <span class="token 
 >operator" style="color: rgb(166, 127, 89); background-image: init
 >ial; background-attachment: initial; background-origin: initial; 
 >background-clip: initial; background-color: rgba(255, 255, 255, 0
 >.496094);">+</span> method<span class="token punctuation" style="
 >color: rgb(153, 153, 153);">.</span>name<span class="token punctu
 >ation" style="color: rgb(153, 153, 153);">)</span><span class="to
 >ken punctuation" style="color: rgb(153, 153, 153);">;</span>
518}905    method<span class="token punctuation" style="color: rgb(153, 
 >153, 153);">.</span><span class="token function">call<span class=
 >"token punctuation" style="color: rgb(153, 153, 153);">(</span></
 >span>this<span class="token punctuation" style="color: rgb(153, 1
 >53, 153);">,</span> length<span class="token punctuation" style="
 >color: rgb(153, 153, 153);">)</span><span class="token punctuatio
 >n" style="color: rgb(153, 153, 153);">;</span>
906  <span class="token punctuation" style="color: rgb(153, 153, 153
 >);">}</span>
907<span class="token punctuation" style="color: rgb(153, 153, 153);
 >">}</span></code>
nn909    <div class="line-number" data-start="1" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 0px;">
910      &nbsp;
911    </div>
912    <div class="line-number" data-start="2" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 19px;">
913      &nbsp;
914    </div>
915    <div class="line-number" data-start="3" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 38px;">
916      &nbsp;
917    </div>
918    <div class="line-number" data-start="4" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 57px;">
919      &nbsp;
920    </div>
921    <div class="line-number" data-start="5" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 76px;">
922      &nbsp;
923    </div>
924    <div class="line-number" data-start="6" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 95px;">
925      &nbsp;
926    </div>
927    <div class="line-number" data-start="7" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 114px;">
928      &nbsp;
929    </div>
n524      In our example, <code>RIL_UNSOL_RESPONSE_CALL_STATE_CHANGEDn934      In our example,&nbsp;<code>RIL_UNSOL_RESPONSE_CALL_STATE_CH
></code>, the following handler is called:>ANGED</code>, the following handler is called:
525    </p>
526    <pre class="brush:js;">
527RIL[UNSOLICITED_RESPONSE_CALL_STATE_CHANGED] = function UNSOLICIT
>ED_RESPONSE_CALL_STATE_CHANGED() { 
528  this.getCurrentCalls();
529};
530</pre>
531    <p>935    </p>
936    <pre class="brush:js; language-js" data-number="" style="padd
 >ing-top: 1em; padding-right: 0px; padding-bottom: 1em; padding-le
 >ft: 30px; border-left-width: 6px; font-family: Consolas, Monaco, 
 >'Andale Mono', monospace; font-size: 14px; background-image: url(
 >https://developer.cdn.mozilla.net/media/redesign/img/blueprint-da
 >rk.png); background-color: rgba(234, 239, 242, 0.246094); text-sh
 >adow: none; direction: ltr; text-align: left; white-space: normal
 >; word-break: normal; -webkit-hyphens: none; background-position:
 > 50% 0%; background-repeat: repeat repeat;">
937<code class="language-js" style="font-family: Consolas, Monaco, '
 >Andale Mono', monospace; color: inherit; text-shadow: none; direc
 >tion: ltr; white-space: pre; word-spacing: normal; word-break: no
 >rmal; -webkit-hyphens: none;">RIL<span class="token punctuation" 
 >style="color: rgb(153, 153, 153);">[</span>UNSOLICITED_RESPONSE_C
 >ALL_STATE_CHANGED<span class="token punctuation" style="color: rg
 >b(153, 153, 153);">]</span> <span class="token operator" style="c
 >olor: rgb(166, 127, 89); background-image: initial; background-at
 >tachment: initial; background-origin: initial; background-clip: i
 >nitial; background-color: rgba(255, 255, 255, 0.496094);">=</span
 >> <span class="token keyword" style="color: rgb(0, 119, 170);">fu
 >nction</span> <span class="token function">UNSOLICITED_RESPONSE_C
 >ALL_STATE_CHANGED<span class="token punctuation" style="color: rg
 >b(153, 153, 153);">(</span></span><span class="token punctuation"
 > style="color: rgb(153, 153, 153);">)</span> <span class="token p
 >unctuation" style="color: rgb(153, 153, 153);">{</span>
938  this<span class="token punctuation" style="color: rgb(153, 153,
 > 153);">.</span><span class="token function">getCurrentCalls<span
 > class="token punctuation" style="color: rgb(153, 153, 153);">(</
 >span></span><span class="token punctuation" style="color: rgb(153
 >, 153, 153);">)</span><span class="token punctuation" style="colo
 >r: rgb(153, 153, 153);">;</span>
939<span class="token punctuation" style="color: rgb(153, 153, 153);
 >">}</span><span class="token punctuation" style="color: rgb(153, 
 >153, 153);">;</span></code>
940</pre>
941    <div class="line-number" data-start="1" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 0px;">
942      &nbsp;
943    </div>
944    <div class="line-number" data-start="2" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 19px;">
945      &nbsp;
946    </div>
947    <div class="line-number" data-start="3" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 38px;">
948      &nbsp;
949    </div>
950    <p>
532      As you see in the code above, when notification is received951      As you see in the code above, when notification is received
> that the call state has changed, the state machine simply fetche> that the call state has changed, the state machine simply fetche
>s the current call state by calling the <code>getCurrentCall()</c>s the current call state by calling the<code>getCurrentCall()</co
>ode> method:>de>&nbsp;method:
533    </p>
534    <pre class="brush:js;">
535getCurrentCalls: function getCurrentCalls() {
536  Buf.simpleRequest(REQUEST_GET_CURRENT_CALLS);
537}
538</pre>
539    <p>952    </p>
953    <pre class="brush:js; language-js" data-number="" style="padd
 >ing-top: 1em; padding-right: 0px; padding-bottom: 1em; padding-le
 >ft: 30px; border-left-width: 6px; font-family: Consolas, Monaco, 
 >'Andale Mono', monospace; font-size: 14px; background-image: url(
 >https://developer.cdn.mozilla.net/media/redesign/img/blueprint-da
 >rk.png); background-color: rgba(234, 239, 242, 0.246094); text-sh
 >adow: none; direction: ltr; text-align: left; white-space: normal
 >; word-break: normal; -webkit-hyphens: none; background-position:
 > 50% 0%; background-repeat: repeat repeat;">
954<code class="language-js" style="font-family: Consolas, Monaco, '
 >Andale Mono', monospace; color: inherit; text-shadow: none; direc
 >tion: ltr; white-space: pre; word-spacing: normal; word-break: no
 >rmal; -webkit-hyphens: none;">getCurrentCalls<span class="token p
 >unctuation" style="color: rgb(153, 153, 153);">:</span> <span cla
 >ss="token keyword" style="color: rgb(0, 119, 170);">function</spa
 >n> <span class="token function">getCurrentCalls<span class="token
 > punctuation" style="color: rgb(153, 153, 153);">(</span></span><
 >span class="token punctuation" style="color: rgb(153, 153, 153);"
 >>)</span> <span class="token punctuation" style="color: rgb(153, 
 >153, 153);">{</span>
955  Buf<span class="token punctuation" style="color: rgb(153, 153, 
 >153);">.</span><span class="token function">simpleRequest<span cl
 >ass="token punctuation" style="color: rgb(153, 153, 153);">(</spa
 >n></span>REQUEST_GET_CURRENT_CALLS<span class="token punctuation"
 > style="color: rgb(153, 153, 153);">)</span><span class="token pu
 >nctuation" style="color: rgb(153, 153, 153);">;</span>
956<span class="token punctuation" style="color: rgb(153, 153, 153);
 >">}</span></code>
957</pre>
958    <div class="line-number" data-start="1" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 0px;">
959      &nbsp;
960    </div>
961    <div class="line-number" data-start="2" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 19px;">
962      &nbsp;
963    </div>
964    <div class="line-number" data-start="3" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 38px;">
965      &nbsp;
966    </div>
967    <p>
540      This sends a request back to <code>rild</code> to request t968      This sends a request back to&nbsp;<code>rild</code>&nbsp;to
>he state of all currently active calls. The request flows back al> request the state of all currently active calls. The request flo
>ong a similar path the <code>RIL_UNSOL_RESPONSE_CALL_STATE_CHANGE>ws back along a similar path the&nbsp;<code>RIL_UNSOL_RESPONSE_CA
>D</code> message followed, but in the opposite direction (that is>LL_STATE_CHANGED</code>message followed, but in the opposite dire
>, from <code>ril_worker.js</code> to <code>SystemWorkerManager</c>ction (that is, from&nbsp;<code>ril_worker.js</code>&nbsp;to<code
>ode> to <code>Ril.cpp</code>, then <code>rilproxy</code> and fina>>SystemWorkerManager</code>&nbsp;to&nbsp;<code>Ril.cpp</code>, th
>lly to the <code>rild</code> socket). <code>rild</code> then resp>en&nbsp;<code>rilproxy</code>&nbsp;and finally to the&nbsp;<code>
>onds in kind, back along the same path, eventually arriving in <c>rild</code>&nbsp;socket).&nbsp;<code>rild</code>then responds in 
>ode>ril_worker.js</code>'s handler for the <code>REQUEST_GET_CURR>kind, back along the same path, eventually arriving in&nbsp;<code
>ENT_CALLS</code> message. And thus bidirectional communication oc>>ril_worker.js</code>'s handler for the&nbsp;<code>REQUEST_GET_CU
>curs.>RRENT_CALLS</code>&nbsp;message. And thus bidirectional communica
 >tion occurs.
n545    <pre class="brush:js;">n973    <pre class="brush:js; language-js" data-number="" style="padd
 >ing-top: 1em; padding-right: 0px; padding-bottom: 1em; padding-le
 >ft: 30px; border-left-width: 6px; font-family: Consolas, Monaco, 
 >'Andale Mono', monospace; font-size: 14px; background-image: url(
 >https://developer.cdn.mozilla.net/media/redesign/img/blueprint-da
 >rk.png); background-color: rgba(234, 239, 242, 0.246094); text-sh
 >adow: none; direction: ltr; text-align: left; white-space: normal
 >; word-break: normal; -webkit-hyphens: none; background-position:
 > 50% 0%; background-repeat: repeat repeat;">
546_handleChangedCallState: function _handleChangedCallState(changed974<code class="language-js" style="font-family: Consolas, Monaco, '
>Call) {>Andale Mono', monospace; color: inherit; text-shadow: none; direc
 >tion: ltr; white-space: pre; word-spacing: normal; word-break: no
 >rmal; -webkit-hyphens: none;">_handleChangedCallState<span class=
 >"token punctuation" style="color: rgb(153, 153, 153);">:</span> <
 >span class="token keyword" style="color: rgb(0, 119, 170);">funct
 >ion</span> <span class="token function">_handleChangedCallState<s
 >pan class="token punctuation" style="color: rgb(153, 153, 153);">
 >(</span></span>changedCall<span class="token punctuation" style="
 >color: rgb(153, 153, 153);">)</span> <span class="token punctuati
 >on" style="color: rgb(153, 153, 153);">{</span>
547  let message = {type: "callStateChange",975  <span class="token keyword" style="color: rgb(0, 119, 170);">le
 >t</span> message <span class="token operator" style="color: rgb(1
 >66, 127, 89); background-image: initial; background-attachment: i
 >nitial; background-origin: initial; background-clip: initial; bac
 >kground-color: rgba(255, 255, 255, 0.496094);">=</span> <span cla
 >ss="token punctuation" style="color: rgb(153, 153, 153);">{</span
 >>type<span class="token punctuation" style="color: rgb(153, 153, 
 >153);">:</span> <span class="token string" style="color: rgb(102,
 > 153, 0);">"callStateChange"</span><span class="token punctuation
 >" style="color: rgb(153, 153, 153);">,</span>
548                 call: changedCall};976                 call<span class="token punctuation" style="color
 >: rgb(153, 153, 153);">:</span> changedCall<span class="token pun
 >ctuation" style="color: rgb(153, 153, 153);">}</span><span class=
 >"token punctuation" style="color: rgb(153, 153, 153);">;</span>
549  this.sendDOMMessage(message);977  this<span class="token punctuation" style="color: rgb(153, 153,
 > 153);">.</span><span class="token function">sendDOMMessage<span 
 >class="token punctuation" style="color: rgb(153, 153, 153);">(</s
 >pan></span>message<span class="token punctuation" style="color: r
 >gb(153, 153, 153);">)</span><span class="token punctuation" style
 >="color: rgb(153, 153, 153);">;</span>
550}978<span class="token punctuation" style="color: rgb(153, 153, 153);
 >">}</span></code>
nn980    <div class="line-number" data-start="1" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 0px;">
981      &nbsp;
982    </div>
983    <div class="line-number" data-start="2" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 19px;">
984      &nbsp;
985    </div>
986    <div class="line-number" data-start="3" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 38px;">
987      &nbsp;
988    </div>
989    <div class="line-number" data-start="4" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 57px;">
990      &nbsp;
991    </div>
992    <div class="line-number" data-start="5" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 76px;">
993      &nbsp;
994    </div>
n553      {{interface("nsIRadioInterfaceLayer")}} is implemented in {n996      {{interface("nsIRadioInterfaceLayer")}} is implemented in {
>{source2("dom/system/gonk/RadioInterfaceLayer.js")}}; the message>{source2("dom/system/gonk/RadioInterfaceLayer.js")}}; the message
> is received by its <code>onmessage()</code> method:> is received by its<code>onmessage()</code>&nbsp;method:
997    </p>
998    <pre class="brush:js; language-js" data-number="" style="padd
 >ing-top: 1em; padding-right: 0px; padding-bottom: 1em; padding-le
 >ft: 30px; border-left-width: 6px; font-family: Consolas, Monaco, 
 >'Andale Mono', monospace; font-size: 14px; background-image: url(
 >https://developer.cdn.mozilla.net/media/redesign/img/blueprint-da
 >rk.png); background-color: rgba(234, 239, 242, 0.246094); text-sh
 >adow: none; direction: ltr; text-align: left; white-space: normal
 >; word-break: normal; -webkit-hyphens: none; background-position:
 > 50% 0%; background-repeat: repeat repeat;">
999<code class="language-js" style="font-family: Consolas, Monaco, '
 >Andale Mono', monospace; color: inherit; text-shadow: none; direc
 >tion: ltr; white-space: pre; word-spacing: normal; word-break: no
 >rmal; -webkit-hyphens: none;"> onmessage<span class="token punctu
 >ation" style="color: rgb(153, 153, 153);">:</span> <span class="t
 >oken keyword" style="color: rgb(0, 119, 170);">function</span> <s
 >pan class="token function">onmessage<span class="token punctuatio
 >n" style="color: rgb(153, 153, 153);">(</span></span>event<span c
 >lass="token punctuation" style="color: rgb(153, 153, 153);">)</sp
 >an> <span class="token punctuation" style="color: rgb(153, 153, 1
 >53);">{</span>
1000   <span class="token keyword" style="color: rgb(0, 119, 170);">l
 >et</span> message <span class="token operator" style="color: rgb(
 >166, 127, 89); background-image: initial; background-attachment: 
 >initial; background-origin: initial; background-clip: initial; ba
 >ckground-color: rgba(255, 255, 255, 0.496094);">=</span> event<sp
 >an class="token punctuation" style="color: rgb(153, 153, 153);">.
 ></span>data<span class="token punctuation" style="color: rgb(153,
 > 153, 153);">;</span>
1001   <span class="token function">debug<span class="token punctuati
 >on" style="color: rgb(153, 153, 153);">(</span></span><span class
 >="token string" style="color: rgb(102, 153, 0);">"Received messag
 >e from worker: "</span> <span class="token operator" style="color
 >: rgb(166, 127, 89); background-image: initial; background-attach
 >ment: initial; background-origin: initial; background-clip: initi
 >al; background-color: rgba(255, 255, 255, 0.496094);">+</span> JS
 >ON<span class="token punctuation" style="color: rgb(153, 153, 153
 >);">.</span><span class="token function">stringify<span class="to
 >ken punctuation" style="color: rgb(153, 153, 153);">(</span></spa
 >n>message<span class="token punctuation" style="color: rgb(153, 1
 >53, 153);">)</span><span class="token punctuation" style="color: 
 >rgb(153, 153, 153);">)</span><span class="token punctuation" styl
 >e="color: rgb(153, 153, 153);">;</span>
1002   switch <span class="token punctuation" style="color: rgb(153, 
 >153, 153);">(</span>message<span class="token punctuation" style=
 >"color: rgb(153, 153, 153);">.</span>type<span class="token punct
 >uation" style="color: rgb(153, 153, 153);">)</span> <span class="
 >token punctuation" style="color: rgb(153, 153, 153);">{</span>
1003     case <span class="token string" style="color: rgb(102, 153, 
 >0);">"callStateChange"</span><span class="token punctuation" styl
 >e="color: rgb(153, 153, 153);">:</span>
1004      <span class="token comment" spellcheck="true" style="displa
 >y: inherit; color: rgb(112, 128, 144);"> // This one will handle 
 >its own notifications.
1005</span>       this<span class="token punctuation" style="color: r
 >gb(153, 153, 153);">.</span><span class="token function">handleCa
 >llStateChange<span class="token punctuation" style="color: rgb(15
 >3, 153, 153);">(</span></span>message<span class="token punctuati
 >on" style="color: rgb(153, 153, 153);">.</span>call<span class="t
 >oken punctuation" style="color: rgb(153, 153, 153);">)</span><spa
 >n class="token punctuation" style="color: rgb(153, 153, 153);">;<
 >/span>
1006       <span class="token keyword" style="color: rgb(0, 119, 170)
 >;">break</span><span class="token punctuation" style="color: rgb(
 >153, 153, 153);">;</span>
1007   <span class="token punctuation" style="color: rgb(153, 153, 15
 >3);">.</span><span class="token punctuation" style="color: rgb(15
 >3, 153, 153);">.</span><span class="token punctuation" style="col
 >or: rgb(153, 153, 153);">.</span></code>
1008</pre>
1009    <div class="line-number" data-start="1" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 0px;">
1010      &nbsp;
554    </p>1011    </div>
555    <pre class="brush:js;">1012    <div class="line-number" data-start="2" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 19px;">
556 onmessage: function onmessage(event) {1013      &nbsp;
557   let message = event.data;1014    </div>
558   debug("Received message from worker: " + JSON.stringify(messag1015    <div class="line-number" data-start="3" style="margin-top: 1e
>e));>m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 38px;">
559   switch (message.type) {1016      &nbsp;
560     case "callStateChange":1017    </div>
561       // This one will handle its own notifications.1018    <div class="line-number" data-start="4" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 57px;">
562       this.handleCallStateChange(message.call);1019      &nbsp;
563       break;1020    </div>
564   ...1021    <div class="line-number" data-start="5" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 76px;">
565</pre>1022      &nbsp;
1023    </div>
1024    <div class="line-number" data-start="6" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 95px;">
1025      &nbsp;
1026    </div>
1027    <div class="line-number" data-start="7" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 114px;">
1028      &nbsp;
1029    </div>
1030    <div class="line-number" data-start="8" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 133px;">
1031      &nbsp;
1032    </div>
1033    <div class="line-number" data-start="9" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 152px;">
1034      &nbsp;
1035    </div>
n569    <pre class="brush:js;">n1039    <pre class="brush:js; language-js" data-number="" style="padd
 >ing-top: 1em; padding-right: 0px; padding-bottom: 1em; padding-le
 >ft: 30px; border-left-width: 6px; font-family: Consolas, Monaco, 
 >'Andale Mono', monospace; font-size: 14px; background-image: url(
 >https://developer.cdn.mozilla.net/media/redesign/img/blueprint-da
 >rk.png); background-color: rgba(234, 239, 242, 0.246094); text-sh
 >adow: none; direction: ltr; text-align: left; white-space: normal
 >; word-break: normal; -webkit-hyphens: none; background-position:
 > 50% 0%; background-repeat: repeat repeat;">
570handleCallStateChange: function handleCallStateChange(call) {1040<code class="language-js" style="font-family: Consolas, Monaco, '
 >Andale Mono', monospace; color: inherit; text-shadow: none; direc
 >tion: ltr; white-space: pre; word-spacing: normal; word-break: no
 >rmal; -webkit-hyphens: none;">handleCallStateChange<span class="t
 >oken punctuation" style="color: rgb(153, 153, 153);">:</span> <sp
 >an class="token keyword" style="color: rgb(0, 119, 170);">functio
 >n</span> <span class="token function">handleCallStateChange<span 
 >class="token punctuation" style="color: rgb(153, 153, 153);">(</s
 >pan></span>call<span class="token punctuation" style="color: rgb(
 >153, 153, 153);">)</span> <span class="token punctuation" style="
 >color: rgb(153, 153, 153);">{</span>
571  [some internal state updating]1041  <span class="token punctuation" style="color: rgb(153, 153, 153
 >);">[</span>some internal state updating<span class="token punctu
 >ation" style="color: rgb(153, 153, 153);">]</span>
572  ppmm.sendAsyncMessage("RIL:CallStateChanged", call);1042  ppmm<span class="token punctuation" style="color: rgb(153, 153,
 > 153);">.</span><span class="token function">sendAsyncMessage<spa
 >n class="token punctuation" style="color: rgb(153, 153, 153);">(<
 >/span></span><span class="token string" style="color: rgb(102, 15
 >3, 0);">"RIL:CallStateChanged"</span><span class="token punctuati
 >on" style="color: rgb(153, 153, 153);">,</span> call<span class="
 >token punctuation" style="color: rgb(153, 153, 153);">)</span><sp
 >an class="token punctuation" style="color: rgb(153, 153, 153);">;
 ></span>
573}1043<span class="token punctuation" style="color: rgb(153, 153, 153);
 >">}</span></code>
nn1045    <div class="line-number" data-start="1" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 0px;">
1046      &nbsp;
1047    </div>
1048    <div class="line-number" data-start="2" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 19px;">
1049      &nbsp;
1050    </div>
1051    <div class="line-number" data-start="3" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 38px;">
1052      &nbsp;
1053    </div>
1054    <div class="line-number" data-start="4" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 57px;">
1055      &nbsp;
1056    </div>
n576      In the content process, the message is received by <code>ren1058      In the content process, the message is received by&nbsp;<co
>ceiveMessage()</code> method in the {{interface("nsIRILContentHel>de>receiveMessage()</code>&nbsp;method in the {{interface("nsIRIL
>per")}} service, from the Child Process Message Manager (CPMM):>ContentHelper")}} service, from the Child Process Message Manager
 > (CPMM):
577    </p>
578    <pre class="brush:js;">
579receiveMessage: function receiveMessage(msg) {
580  let request;
581  debug("Received message '" + msg.name + "': " + JSON.stringify(
>msg.json)); 
582  switch (msg.name) {
583    case "RIL:CallStateChanged":
584      this._deliverTelephonyCallback("callStateChanged",
585                                     [msg.json.callIndex, msg.jso
>n.state, 
586                                     msg.json.number, msg.json.is
>Active]); 
587      break;
588</pre>
589    <p>1059    </p>
1060    <pre class="brush:js; language-js" data-number="" style="padd
 >ing-top: 1em; padding-right: 0px; padding-bottom: 1em; padding-le
 >ft: 30px; border-left-width: 6px; font-family: Consolas, Monaco, 
 >'Andale Mono', monospace; font-size: 14px; background-image: url(
 >https://developer.cdn.mozilla.net/media/redesign/img/blueprint-da
 >rk.png); background-color: rgba(234, 239, 242, 0.246094); text-sh
 >adow: none; direction: ltr; text-align: left; white-space: normal
 >; word-break: normal; -webkit-hyphens: none; background-position:
 > 50% 0%; background-repeat: repeat repeat;">
1061<code class="language-js" style="font-family: Consolas, Monaco, '
 >Andale Mono', monospace; color: inherit; text-shadow: none; direc
 >tion: ltr; white-space: pre; word-spacing: normal; word-break: no
 >rmal; -webkit-hyphens: none;">receiveMessage<span class="token pu
 >nctuation" style="color: rgb(153, 153, 153);">:</span> <span clas
 >s="token keyword" style="color: rgb(0, 119, 170);">function</span
 >> <span class="token function">receiveMessage<span class="token p
 >unctuation" style="color: rgb(153, 153, 153);">(</span></span>msg
 ><span class="token punctuation" style="color: rgb(153, 153, 153);
 >">)</span> <span class="token punctuation" style="color: rgb(153,
 > 153, 153);">{</span>
1062  <span class="token keyword" style="color: rgb(0, 119, 170);">le
 >t</span> request<span class="token punctuation" style="color: rgb
 >(153, 153, 153);">;</span>
1063  <span class="token function">debug<span class="token punctuatio
 >n" style="color: rgb(153, 153, 153);">(</span></span><span class=
 >"token string" style="color: rgb(102, 153, 0);">"Received message
 > '"</span> <span class="token operator" style="color: rgb(166, 12
 >7, 89); background-image: initial; background-attachment: initial
 >; background-origin: initial; background-clip: initial; backgroun
 >d-color: rgba(255, 255, 255, 0.496094);">+</span> msg<span class=
 >"token punctuation" style="color: rgb(153, 153, 153);">.</span>na
 >me <span class="token operator" style="color: rgb(166, 127, 89); 
 >background-image: initial; background-attachment: initial; backgr
 >ound-origin: initial; background-clip: initial; background-color:
 > rgba(255, 255, 255, 0.496094);">+</span> <span class="token stri
 >ng" style="color: rgb(102, 153, 0);">"': "</span> <span class="to
 >ken operator" style="color: rgb(166, 127, 89); background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: rgba(255, 255, 25
 >5, 0.496094);">+</span> JSON<span class="token punctuation" style
 >="color: rgb(153, 153, 153);">.</span><span class="token function
 >">stringify<span class="token punctuation" style="color: rgb(153,
 > 153, 153);">(</span></span>msg<span class="token punctuation" st
 >yle="color: rgb(153, 153, 153);">.</span>json<span class="token p
 >unctuation" style="color: rgb(153, 153, 153);">)</span><span clas
 >s="token punctuation" style="color: rgb(153, 153, 153);">)</span>
 ><span class="token punctuation" style="color: rgb(153, 153, 153);
 >">;</span>
1064  switch <span class="token punctuation" style="color: rgb(153, 1
 >53, 153);">(</span>msg<span class="token punctuation" style="colo
 >r: rgb(153, 153, 153);">.</span>name<span class="token punctuatio
 >n" style="color: rgb(153, 153, 153);">)</span> <span class="token
 > punctuation" style="color: rgb(153, 153, 153);">{</span>
1065    case <span class="token string" style="color: rgb(102, 153, 0
 >);">"RIL:CallStateChanged"</span><span class="token punctuation" 
 >style="color: rgb(153, 153, 153);">:</span>
1066      this<span class="token punctuation" style="color: rgb(153, 
 >153, 153);">.</span><span class="token function">_deliverTelephon
 >yCallback<span class="token punctuation" style="color: rgb(153, 1
 >53, 153);">(</span></span><span class="token string" style="color
 >: rgb(102, 153, 0);">"callStateChanged"</span><span class="token 
 >punctuation" style="color: rgb(153, 153, 153);">,</span>
1067                                     <span class="token punctuati
 >on" style="color: rgb(153, 153, 153);">[</span>msg<span class="to
 >ken punctuation" style="color: rgb(153, 153, 153);">.</span>json<
 >span class="token punctuation" style="color: rgb(153, 153, 153);"
 >>.</span>callIndex<span class="token punctuation" style="color: r
 >gb(153, 153, 153);">,</span> msg<span class="token punctuation" s
 >tyle="color: rgb(153, 153, 153);">.</span>json<span class="token 
 >punctuation" style="color: rgb(153, 153, 153);">.</span>state<spa
 >n class="token punctuation" style="color: rgb(153, 153, 153);">,<
 >/span>
1068                                     msg<span class="token punctu
 >ation" style="color: rgb(153, 153, 153);">.</span>json<span class
 >="token punctuation" style="color: rgb(153, 153, 153);">.</span>n
 >umber<span class="token punctuation" style="color: rgb(153, 153, 
 >153);">,</span> msg<span class="token punctuation" style="color: 
 >rgb(153, 153, 153);">.</span>json<span class="token punctuation" 
 >style="color: rgb(153, 153, 153);">.</span>isActive<span class="t
 >oken punctuation" style="color: rgb(153, 153, 153);">]</span><spa
 >n class="token punctuation" style="color: rgb(153, 153, 153);">)<
 >/span><span class="token punctuation" style="color: rgb(153, 153,
 > 153);">;</span>
1069      <span class="token keyword" style="color: rgb(0, 119, 170);
 >">break</span><span class="token punctuation" style="color: rgb(1
 >53, 153, 153);">;</span></code>
1070</pre>
1071    <div class="line-number" data-start="1" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 0px;">
1072      &nbsp;
1073    </div>
1074    <div class="line-number" data-start="2" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 19px;">
1075      &nbsp;
1076    </div>
1077    <div class="line-number" data-start="3" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 38px;">
1078      &nbsp;
1079    </div>
1080    <div class="line-number" data-start="4" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 57px;">
1081      &nbsp;
1082    </div>
1083    <div class="line-number" data-start="5" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 76px;">
1084      &nbsp;
1085    </div>
1086    <div class="line-number" data-start="6" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 95px;">
1087      &nbsp;
1088    </div>
1089    <div class="line-number" data-start="7" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 114px;">
1090      &nbsp;
1091    </div>
1092    <div class="line-number" data-start="8" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 133px;">
1093      &nbsp;
1094    </div>
1095    <div class="line-number" data-start="9" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 152px;">
1096      &nbsp;
1097    </div>
1098    <p>
590      This, in turn, calls the {{ifmethod("nsIRILTelephonyCallbac1099      This, in turn, calls the {{ifmethod("nsIRILTelephonyCallbac
>k", "callStateChanged")}} methods on every registered telephony c>k", "callStateChanged")}} methods on every registered telephony c
>allback object. Every web application that accesses the {{domxref>allback object. Every web application that accesses the {{domxref
>("window.navigator.mozTelephony")}} API has registered one such c>("window.navigator.mozTelephony")}} API has registered one such c
>allback object that dispatches events to the JavaScript code in t>allback object that dispatches events to the JavaScript code in t
>he web application, either as a state change of an existing call >he web application, either as a state change of an existing call 
>object or a new <code>incoming</code> call event.>object or a new&nbsp;<code>incoming</code>&nbsp;call event.
n592    <pre class="brush:cpp;">n1101    <pre class="brush:cpp; language-cpp" data-number="" style="pa
 >dding-top: 1em; padding-right: 0px; padding-bottom: 1em; padding-
 >left: 30px; border-left-width: 6px; font-family: Consolas, Monaco
 >, 'Andale Mono', monospace; font-size: 14px; background-image: ur
 >l(https://developer.cdn.mozilla.net/media/redesign/img/blueprint-
 >dark.png); background-color: rgba(234, 239, 242, 0.246094); text-
 >shadow: none; direction: ltr; text-align: left; white-space: norm
 >al; word-break: normal; -webkit-hyphens: none; background-positio
 >n: 50% 0%; background-repeat: repeat repeat;">
593NS_IMETHODIMP Telephony::CallStateChanged(PRUint32 aCallIndex, PR1102<code class="language-cpp" style="font-family: Consolas, Monaco, 
>Uint16 aCallState,>'Andale Mono', monospace; color: inherit; text-shadow: none; dire
 >ction: ltr; white-space: pre; word-spacing: normal; word-break: n
 >ormal; -webkit-hyphens: none;">NS_IMETHODIMP Telephony<span class
 >="token punctuation" style="color: rgb(153, 153, 153);">:</span><
 >span class="token punctuation" style="color: rgb(153, 153, 153);"
 >>:</span><span class="token function">CallStateChanged<span class
 >="token punctuation" style="color: rgb(153, 153, 153);">(</span><
 >/span>PRUint32 aCallIndex<span class="token punctuation" style="c
 >olor: rgb(153, 153, 153);">,</span> PRUint16 aCallState<span clas
 >s="token punctuation" style="color: rgb(153, 153, 153);">,</span>
594                                          const nsAString&amp; aN1103                                          const nsAString<span cl
>umber, bool aIsActive) {>ass="token operator" style="color: rgb(166, 127, 89); background-
 >image: initial; background-attachment: initial; background-origin
 >: initial; background-clip: initial; background-color: rgba(255, 
 >255, 255, 0.496094);">&amp;</span> aNumber<span class="token punc
 >tuation" style="color: rgb(153, 153, 153);">,</span> bool aIsActi
 >ve<span class="token punctuation" style="color: rgb(153, 153, 153
 >);">)</span> <span class="token punctuation" style="color: rgb(15
 >3, 153, 153);">{</span>
595  [...]1104  <span class="token punctuation" style="color: rgb(153, 153, 153
 >);">[</span><span class="token punctuation" style="color: rgb(153
 >, 153, 153);">.</span><span class="token punctuation" style="colo
 >r: rgb(153, 153, 153);">.</span><span class="token punctuation" s
 >tyle="color: rgb(153, 153, 153);">.</span><span class="token punc
 >tuation" style="color: rgb(153, 153, 153);">]</span>
n597  if (modifiedCall) {n1106  <span class="token keyword" style="color: rgb(0, 119, 170);">if
 ></span> <span class="token punctuation" style="color: rgb(153, 15
 >3, 153);">(</span>modifiedCall<span class="token punctuation" sty
 >le="color: rgb(153, 153, 153);">)</span> <span class="token punct
 >uation" style="color: rgb(153, 153, 153);">{</span>
598    // Change state.1107   <span class="token comment" spellcheck="true" style="display: 
 >inherit; color: rgb(112, 128, 144);"> // Change state.
599    modifiedCall-&gt;ChangeState(aCallState);1108</span>    modifiedCall<span class="token operator" style="color:
 > rgb(166, 127, 89); background-image: initial; background-attachm
 >ent: initial; background-origin: initial; background-clip: initia
 >l; background-color: rgba(255, 255, 255, 0.496094);">-</span>&gt;
 ><span class="token function">ChangeState<span class="token punctu
 >ation" style="color: rgb(153, 153, 153);">(</span></span>aCallSta
 >te<span class="token punctuation" style="color: rgb(153, 153, 153
 >);">)</span><span class="token punctuation" style="color: rgb(153
 >, 153, 153);">;</span>
n601    // See if this should replace our current active call.n1110   <span class="token comment" spellcheck="true" style="display: 
 >inherit; color: rgb(112, 128, 144);"> // See if this should repla
 >ce our current active call.
602    if (aIsActive) {1111</span>    <span class="token keyword" style="color: rgb(0, 119, 
 >170);">if</span> <span class="token punctuation" style="color: rg
 >b(153, 153, 153);">(</span>aIsActive<span class="token punctuatio
 >n" style="color: rgb(153, 153, 153);">)</span> <span class="token
 > punctuation" style="color: rgb(153, 153, 153);">{</span>
603      mActiveCall = modifiedCall;1112      mActiveCall <span class="token operator" style="color: rgb(
 >166, 127, 89); background-image: initial; background-attachment: 
 >initial; background-origin: initial; background-clip: initial; ba
 >ckground-color: rgba(255, 255, 255, 0.496094);">=</span> modified
 >Call<span class="token punctuation" style="color: rgb(153, 153, 1
 >53);">;</span>
604    }1113    <span class="token punctuation" style="color: rgb(153, 153, 1
 >53);">}</span>
n606    return NS_OK;n1115    <span class="token keyword" style="color: rgb(0, 119, 170);">
 >return</span> NS_OK<span class="token punctuation" style="color: 
 >rgb(153, 153, 153);">;</span>
607  }1116  <span class="token punctuation" style="color: rgb(153, 153, 153
 >);">}</span>
n609  nsRefPtr&lt;TelephonyCall&gt; call =n1118  nsRefPtr<span class="token operator" style="color: rgb(166, 127
 >, 89); background-image: initial; background-attachment: initial;
 > background-origin: initial; background-clip: initial; background
 >-color: rgba(255, 255, 255, 0.496094);">&lt;</span>TelephonyCall&
 >gt; call <span class="token operator" style="color: rgb(166, 127,
 > 89); background-image: initial; background-attachment: initial; 
 >background-origin: initial; background-clip: initial; background-
 >color: rgba(255, 255, 255, 0.496094);">=</span>
610          TelephonyCall::Create(this, aNumber, aCallState, aCallI1119          TelephonyCall<span class="token punctuation" style="col
>ndex);>or: rgb(153, 153, 153);">:</span><span class="token punctuation" 
 >style="color: rgb(153, 153, 153);">:</span><span class="token fun
 >ction">Create<span class="token punctuation" style="color: rgb(15
 >3, 153, 153);">(</span></span>this<span class="token punctuation"
 > style="color: rgb(153, 153, 153);">,</span> aNumber<span class="
 >token punctuation" style="color: rgb(153, 153, 153);">,</span> aC
 >allState<span class="token punctuation" style="color: rgb(153, 15
 >3, 153);">,</span> aCallIndex<span class="token punctuation" styl
 >e="color: rgb(153, 153, 153);">)</span><span class="token punctua
 >tion" style="color: rgb(153, 153, 153);">;</span>
611  nsRefPtr&lt;CallEvent&gt; event = CallEvent::Create(call);1120  nsRefPtr<span class="token operator" style="color: rgb(166, 127
 >, 89); background-image: initial; background-attachment: initial;
 > background-origin: initial; background-clip: initial; background
 >-color: rgba(255, 255, 255, 0.496094);">&lt;</span>CallEvent&gt; 
 >event <span class="token operator" style="color: rgb(166, 127, 89
 >); background-image: initial; background-attachment: initial; bac
 >kground-origin: initial; background-clip: initial; background-col
 >or: rgba(255, 255, 255, 0.496094);">=</span> CallEvent<span class
 >="token punctuation" style="color: rgb(153, 153, 153);">:</span><
 >span class="token punctuation" style="color: rgb(153, 153, 153);"
 >>:</span><span class="token function">Create<span class="token pu
 >nctuation" style="color: rgb(153, 153, 153);">(</span></span>call
 ><span class="token punctuation" style="color: rgb(153, 153, 153);
 >">)</span><span class="token punctuation" style="color: rgb(153, 
 >153, 153);">;</span>
612  nsresult rv = event-&gt;Dispatch(ToIDOMEventTarget(), NS_LITERA1121  nsresult rv <span class="token operator" style="color: rgb(166,
>L_STRING("incoming"));> 127, 89); background-image: initial; background-attachment: init
 >ial; background-origin: initial; background-clip: initial; backgr
 >ound-color: rgba(255, 255, 255, 0.496094);">=</span> event<span c
 >lass="token operator" style="color: rgb(166, 127, 89); background
 >-image: initial; background-attachment: initial; background-origi
 >n: initial; background-clip: initial; background-color: rgba(255,
 > 255, 255, 0.496094);">-</span>&gt;<span class="token function">D
 >ispatch<span class="token punctuation" style="color: rgb(153, 153
 >, 153);">(</span></span><span class="token function">ToIDOMEventT
 >arget<span class="token punctuation" style="color: rgb(153, 153, 
 >153);">(</span></span><span class="token punctuation" style="colo
 >r: rgb(153, 153, 153);">)</span><span class="token punctuation" s
 >tyle="color: rgb(153, 153, 153);">,</span> <span class="token fun
 >ction">NS_LITERAL_STRING<span class="token punctuation" style="co
 >lor: rgb(153, 153, 153);">(</span></span><span class="token strin
 >g" style="color: rgb(102, 153, 0);">"incoming"</span><span class=
 >"token punctuation" style="color: rgb(153, 153, 153);">)</span><s
 >pan class="token punctuation" style="color: rgb(153, 153, 153);">
 >)</span><span class="token punctuation" style="color: rgb(153, 15
 >3, 153);">;</span>
613  NS_ENSURE_SUCCESS(rv, rv);1122  <span class="token function">NS_ENSURE_SUCCESS<span class="toke
 >n punctuation" style="color: rgb(153, 153, 153);">(</span></span>
 >rv<span class="token punctuation" style="color: rgb(153, 153, 153
 >);">,</span> rv<span class="token punctuation" style="color: rgb(
 >153, 153, 153);">)</span><span class="token punctuation" style="c
 >olor: rgb(153, 153, 153);">;</span>
614  return NS_OK;1123  <span class="token keyword" style="color: rgb(0, 119, 170);">re
 >turn</span> NS_OK<span class="token punctuation" style="color: rg
 >b(153, 153, 153);">;</span>
615}1124<span class="token punctuation" style="color: rgb(153, 153, 153);
 >">}</span></code>
nn1126    <div class="line-number" data-start="1" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 0px;">
1127      &nbsp;
1128    </div>
1129    <div class="line-number" data-start="2" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 19px;">
1130      &nbsp;
1131    </div>
1132    <div class="line-number" data-start="3" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 38px;">
1133      &nbsp;
1134    </div>
1135    <div class="line-number" data-start="4" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 57px;">
1136      &nbsp;
1137    </div>
1138    <div class="line-number" data-start="5" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 76px;">
1139      &nbsp;
1140    </div>
1141    <div class="line-number" data-start="6" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 95px;">
1142      &nbsp;
1143    </div>
1144    <div class="line-number" data-start="7" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 114px;">
1145      &nbsp;
1146    </div>
1147    <div class="line-number" data-start="8" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 133px;">
1148      &nbsp;
1149    </div>
1150    <div class="line-number" data-start="9" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 152px;">
1151      &nbsp;
1152    </div>
1153    <div class="line-number" data-start="10" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 171px;">
1154      &nbsp;
1155    </div>
1156    <div class="line-number" data-start="11" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 190px;">
1157      &nbsp;
1158    </div>
1159    <div class="line-number" data-start="12" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 209px;">
1160      &nbsp;
1161    </div>
1162    <div class="line-number" data-start="13" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 228px;">
1163      &nbsp;
1164    </div>
1165    <div class="line-number" data-start="14" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 247px;">
1166      &nbsp;
1167    </div>
1168    <div class="line-number" data-start="15" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 266px;">
1169      &nbsp;
1170    </div>
1171    <div class="line-number" data-start="16" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 285px;">
1172      &nbsp;
1173    </div>
1174    <div class="line-number" data-start="17" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 304px;">
1175      &nbsp;
1176    </div>
1177    <div class="line-number" data-start="18" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 323px;">
1178      &nbsp;
1179    </div>
1180    <div class="line-number" data-start="19" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 342px;">
1181      &nbsp;
1182    </div>
1183    <div class="line-number" data-start="20" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 361px;">
1184      &nbsp;
1185    </div>
1186    <div class="line-number" data-start="21" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 380px;">
1187      &nbsp;
1188    </div>
1189    <div class="line-number" data-start="22" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 399px;">
1190      &nbsp;
1191    </div>
1192    <div class="line-number" data-start="23" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 418px;">
1193      &nbsp;
1194    </div>
n620    <pre class="brush:js;">n1198    <pre class="brush:js; language-js" data-number="" style="padd
 >ing-top: 1em; padding-right: 0px; padding-bottom: 1em; padding-le
 >ft: 30px; border-left-width: 6px; font-family: Consolas, Monaco, 
 >'Andale Mono', monospace; font-size: 14px; background-image: url(
 >https://developer.cdn.mozilla.net/media/redesign/img/blueprint-da
 >rk.png); background-color: rgba(234, 239, 242, 0.246094); text-sh
 >adow: none; direction: ltr; text-align: left; white-space: normal
 >; word-break: normal; -webkit-hyphens: none; background-position:
 > 50% 0%; background-repeat: repeat repeat;">
621handleEvent: function fm_handleEvent(evt) {1199<code class="language-js" style="font-family: Consolas, Monaco, '
 >Andale Mono', monospace; color: inherit; text-shadow: none; direc
 >tion: ltr; white-space: pre; word-spacing: normal; word-break: no
 >rmal; -webkit-hyphens: none;">handleEvent<span class="token punct
 >uation" style="color: rgb(153, 153, 153);">:</span> <span class="
 >token keyword" style="color: rgb(0, 119, 170);">function</span> <
 >span class="token function">fm_handleEvent<span class="token punc
 >tuation" style="color: rgb(153, 153, 153);">(</span></span>evt<sp
 >an class="token punctuation" style="color: rgb(153, 153, 153);">)
 ></span> <span class="token punctuation" style="color: rgb(153, 15
 >3, 153);">{</span>
622  switch (evt.call.state) {1200  switch <span class="token punctuation" style="color: rgb(153, 1
 >53, 153);">(</span>evt<span class="token punctuation" style="colo
 >r: rgb(153, 153, 153);">.</span>call<span class="token punctuatio
 >n" style="color: rgb(153, 153, 153);">.</span>state<span class="t
 >oken punctuation" style="color: rgb(153, 153, 153);">)</span> <sp
 >an class="token punctuation" style="color: rgb(153, 153, 153);">{
 ></span>
623    case 'connected':1201    case <span class="token string" style="color: rgb(102, 153, 0
 >);">'connected'</span><span class="token punctuation" style="colo
 >r: rgb(153, 153, 153);">:</span>
624      this.connected();1202      this<span class="token punctuation" style="color: rgb(153, 
 >153, 153);">.</span><span class="token function">connected<span c
 >lass="token punctuation" style="color: rgb(153, 153, 153);">(</sp
 >an></span><span class="token punctuation" style="color: rgb(153, 
 >153, 153);">)</span><span class="token punctuation" style="color:
 > rgb(153, 153, 153);">;</span>
625      break;1203      <span class="token keyword" style="color: rgb(0, 119, 170);
 >">break</span><span class="token punctuation" style="color: rgb(1
 >53, 153, 153);">;</span>
626    case 'disconnected':1204    case <span class="token string" style="color: rgb(102, 153, 0
 >);">'disconnected'</span><span class="token punctuation" style="c
 >olor: rgb(153, 153, 153);">:</span>
627      this.disconnected();1205      this<span class="token punctuation" style="color: rgb(153, 
 >153, 153);">.</span><span class="token function">disconnected<spa
 >n class="token punctuation" style="color: rgb(153, 153, 153);">(<
 >/span></span><span class="token punctuation" style="color: rgb(15
 >3, 153, 153);">)</span><span class="token punctuation" style="col
 >or: rgb(153, 153, 153);">;</span>
628      break;1206      <span class="token keyword" style="color: rgb(0, 119, 170);
 >">break</span><span class="token punctuation" style="color: rgb(1
 >53, 153, 153);">;</span>
629    default:1207    default<span class="token punctuation" style="color: rgb(153,
 > 153, 153);">:</span>
630      break;1208      <span class="token keyword" style="color: rgb(0, 119, 170);
 >">break</span><span class="token punctuation" style="color: rgb(1
 >53, 153, 153);">;</span>
631  }1209  <span class="token punctuation" style="color: rgb(153, 153, 153
 >);">}</span>
632}1210<span class="token punctuation" style="color: rgb(153, 153, 153);
 >">}</span></code>
nn1212    <div class="line-number" data-start="1" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 0px;">
1213      &nbsp;
1214    </div>
1215    <div class="line-number" data-start="2" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 19px;">
1216      &nbsp;
1217    </div>
1218    <div class="line-number" data-start="3" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 38px;">
1219      &nbsp;
1220    </div>
1221    <div class="line-number" data-start="4" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 57px;">
1222      &nbsp;
1223    </div>
1224    <div class="line-number" data-start="5" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 76px;">
1225      &nbsp;
1226    </div>
1227    <div class="line-number" data-start="6" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 95px;">
1228      &nbsp;
1229    </div>
1230    <div class="line-number" data-start="7" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 114px;">
1231      &nbsp;
1232    </div>
1233    <div class="line-number" data-start="8" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 133px;">
1234      &nbsp;
1235    </div>
1236    <div class="line-number" data-start="9" style="margin-top: 1e
 >m; position: absolute; left: 0px; right: 0px; background-image: i
 >nitial; background-attachment: initial; background-origin: initia
 >l; background-clip: initial; background-color: transparent; point
 >er-events: none; line-height: inherit; top: 152px;">
1237      &nbsp;
1238    </div>
1239    <div class="line-number" data-start="10" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 171px;">
1240      &nbsp;
1241    </div>
1242    <div class="line-number" data-start="11" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 190px;">
1243      &nbsp;
1244    </div>
1245    <div class="line-number" data-start="12" style="margin-top: 1
 >em; position: absolute; left: 0px; right: 0px; background-image: 
 >initial; background-attachment: initial; background-origin: initi
 >al; background-clip: initial; background-color: transparent; poin
 >ter-events: none; line-height: inherit; top: 209px;">
1246      &nbsp;
1247    </div>
n635      Take a