IT翻訳 Nobuyuki の仕事部屋

ボランティアでソフトウエアーローカライズのために翻訳をしている。

JavaScript-DOM Prototypes in Mozilla 草稿化 8

2006-03-21 21:04:31 | InDraft
昨日フォーラムで長く草稿公開の状態にあったGecko Info for Windows Accessibility Vendorsの和訳草稿をようやく完成稿にした。原文も頻繁に見直されており、改訂変更が著しいこともあってしばらく放置状態にあった。しかし、そのような変更も出尽くした感があり、その後 Mozilla community の方々の草稿に対する新たな指摘もないので、最終的見直しをして完成稿とした。原著者の Aaron さんにその旨を報告すると以下のような返信があった。

Thank you!

Would you be so kind as to help find Japanese assistive technology vendors and notify them about your document?

I will keep this URL safe so I can send it if I get any requests, but I do not have connections in Japan.

- Aaron

Aaron Leventhal
IBM web accessibility architect

ようするに、日本のアクセシビリティ関連のベンダーに上記の文書を紹介して欲しいという依頼である。この件は、以前草稿作成中に原文について何かの照会を入れた際にも同様の依頼をうけていた。そこで、その時は Mozilla Japan org. の和訳部門経由で Mozilla Japan へ Aaron さんのご希望を伝えた。さらに、自分としては Aaron さんの紹介をする小さなサイトを作った。その時、日本IBM がアクセシビリティ関連の vendor でもあることを知ったので、今回その件を Aaron さんに伝えた。というのは、現在 Aaron さんご自身も本家の IMB で働いておられるからである。すると、日本IMBへコンタクトしてみるという返事があった。
----------------------------------------------------------------------------

原文青色表示
訳文黒色表示
注記/訂正: 赤色表示

As the prototype property of the constructor function is being defined, the code also sets up the prototype of the prototype property of the constructor function (i.e. HTMLImageElement.prototype.__proto__). To do this, the code figures out what the name of the immediate prototype of the class is by looking at the parent of the primary interface in the class info (if the name is a class constructor, such as HTMLImageElement) or by looking at the parent of the interface that the IID stored in the nsScriptNameSpaceManager for this name represents (if the name is a class prototype, such as Node). Once the name of the parent interface is known (and the name is not nsISupports) the code will look up a property by that name on the global object. This will cause the code to recurse down along the parent chain of the interface of interest for the name we started out resolving (i.e. nsWindowSH::GlobalResolve() will be called for every name on the parent chain). The result of this recursion is that by resolving the name HTMLImageElement, we'll create the constructor functions HTMLImageElement, HTMLElement, Element, and Node, and the prototype properties on all those constructor functions will be correctly set up. This means that the next time the name of a class constructor is resolved in the same scope, say HTMLAnchorElement, the code will resolve the name HTMLAnchorElement, find the parent name, which is HTMLElement, and resolve that, but since we've already resolved HTMLElement as a result of resolving the name HTMLImageElement earlier, the recursion will stop right there.

コンストラクタ関数のプロトタイププロパティが定義されている中で、コードはコンストラクタ関数のプロトタイププロパティのプロトタイプ(例 HTMLImageElement.prototype.__proto__) も設定します。そのために、コードは class info の主要なインターフェイスの親を調べることで (HTMLImageElement などクラスコンストラクタの名前であれば)、クラスの直接のプロトタイプ名がなんであるかが分かります。あるいは、この名前に対して nsScriptNameSpaceManager クラスに保持された IID 【訳注:一意なインタフェース識別子】 が表す(名前が Node などクラスプロトタイプの名前であれば)インターフェイスの親を調べることで分かります。一度親インターフェイス名が分かると(それが nsISupports でなければ)コードはグローバルオブジェクトの親インターフェイス名によってプロパティを調べます。こうすることで、コードは関連するインターフェイスの親の連鎖にそって、解析を始めていた名前を求めて再帰呼び出しをします(例えば、nsWindowSH::GlobalResolve() が親の連鎖にある名前毎に呼び出されます)。再帰呼び出しの結果、HTMLImageElement 名を解析することで、コンストラクタ関数である HTMLImageElement、HTMLElement、Element、Node が生成され、これらのコンストラクタ関数のすべてのプロトタイプのプロパティが正しく設定されます。つまり、次回は同じ領域でクラスコンストラクタの名前が解析されることになります。例えば HTMLAnchorElement では、HTMLAnchorElement 名を解析し、HTMLElement であると親の名を見つけ、さらにそれを解析しますが、以前に HTMLImageElement 名を解析した結果 HTMLElement はすでに解析済なので、ここで再帰呼び出しは停止します。