IT翻訳 Nobuyuki の仕事部屋

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

JavaScript-DOM Prototypes in Mozilla 草稿化 2

2006-03-13 23:32:59 | InDraft


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


var obj = document.images[0];

Here, obj will not really have any properties (except for the standard JSObject properties such as constructor, and the non-standard __parent__, __proto__, ...), all the DOM functionality of |obj| comes from obj's prototype (obj.__proto__) that XPConnect sets up when exposing the first image in |document| to JS. Here's a few of the properties of obj's prototype:

obj.__proto__
- parentNode (getter Function)
- src (getter and setter Functions)
- getElementsByTagName (Function)
- TEXT_NODE (Number property, constant)
- ...



var obj = document.images[0];

ここでは、 obj は実際プロパティを備えることはありません(例外として constructor などの標準の JSObject のプロパティや非標準の __parent__、__proto__などがあります)。 |obj| のすべての DOM の機能は、XPConnect が |document| で JS へ最初のイメージを示す時に設定する obj のプロトタイプ (obj.__proto__) から発生します。以下に obj のプロトタイプのプロパティのいくつかを示します:

obj.__proto__
- parentNode (getter Function)
- src (getter and setter Functions)
- getElementsByTagName (Function)
- TEXT_NODE (Number property, constant)
- ...


All those properties come from the interfaces that the C++ image object (nsHTMLImageElement) implements and chooses to expose to XPConnect through the object's class info. One of these interfaces is nsIDOMHTMLImageElement, others are nsIDOMNSHTMLImageElement (Netscape extensions to the standard interface), nsIDOMEventTarget, nsIDOMEventListener, nsIDOM3Node, and so on...

これらのプロパティのすべては、 C++ イメージオブジェクト (nsHTMLImageElement) がオブジェクトの class info を通して XPConnect へ示すのに実装し選択するインターフェイスに由来します。これらのインターフェイスのひとつが nsIDOMHTMLImageElement であり、その他に nsIDOMNSHTMLImageElement (標準インターフェイスへの Netscape の拡張)、 nsIDOMEventTarget、nsIDOMEventListener、 nsIDOM3Node などがあります。