From a065e04d529da1d847b5062a12c46d916408bf32 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 21:46:22 -0500 Subject: update based on https://github.com/mdn/yari/issues/2028 --- files/zh-tw/mozilla/tech/index.html | 14 - .../zh-tw/mozilla/tech/xpcom/reference/index.html | 27 -- .../tech/xpcom/reference/interface/index.html | 19 - .../interface/nsicontentpolicy/index.html | 491 --------------------- 4 files changed, 551 deletions(-) delete mode 100644 files/zh-tw/mozilla/tech/index.html delete mode 100644 files/zh-tw/mozilla/tech/xpcom/reference/index.html delete mode 100644 files/zh-tw/mozilla/tech/xpcom/reference/interface/index.html delete mode 100644 files/zh-tw/mozilla/tech/xpcom/reference/interface/nsicontentpolicy/index.html (limited to 'files/zh-tw/mozilla/tech') diff --git a/files/zh-tw/mozilla/tech/index.html b/files/zh-tw/mozilla/tech/index.html deleted file mode 100644 index f9682e62e1..0000000000 --- a/files/zh-tw/mozilla/tech/index.html +++ /dev/null @@ -1,14 +0,0 @@ ---- -title: Mozilla technologies -slug: Mozilla/Tech -tags: - - Landing - - Mozilla - - NeedsTranslation - - Reference - - TopicStub - - XUL -translation_of: Mozilla/Tech ---- -

Mozilla has several technologies used as components of its projects. These are documented here. (flesh out this text).

-

{{LandingPageListSubpages}}

diff --git a/files/zh-tw/mozilla/tech/xpcom/reference/index.html b/files/zh-tw/mozilla/tech/xpcom/reference/index.html deleted file mode 100644 index 29d07953d6..0000000000 --- a/files/zh-tw/mozilla/tech/xpcom/reference/index.html +++ /dev/null @@ -1,27 +0,0 @@ ---- -title: XPCOM reference -slug: Mozilla/Tech/XPCOM/Reference -tags: - - Add-ons - - Extensions - - Landing - - Mozilla - - NeedsTranslation - - Reference - - TopicStub - - XPCOM -translation_of: Mozilla/Tech/XPCOM/Reference ---- -

This reference describes the interfaces and functions provided by the XPCOM library. In addition, it details the various helper classes and functions, as well as the components, provided by the XPCOM glue library. The contents herein are oriented primarily toward extension developers and people embedding XPCOM in other projects.

- -
-

WebExtensions are becoming the new standard for creating add-ons. Eventually support for XPCOM add-ons will be deprecated, so you should begin to investigate porting your add-ons to use the WebExtensions API, and report any missing functionality so we can be sure to address your concerns. Work is ongoing on WebExtension capabilities, so your input will help prioritize and plan the work. To learn more about the kinds of changes that will be needed, see Comparison with XUL/XPCOM extensions. In addition, any binaries you use will then need to be converted for use with the WebExtensions native messaging API, or compiled using WebAssembly or Emscripten.

-
- -
-

If you're working on a module in the Mozilla codebase that's compiled with the MOZILLA_INTERNAL_API flag set, some of these APIs -- the string functions and classes in particular -- are not the ones you should be using. See the XPCOM internal string guide for documentation of the internal string API used within the Mozilla codebase.

-
- -

{{LandingPageListSubpages}}

- -

Many XPCOM pages return an nsresult. Prior to Gecko 19 {{geckoRelease(19)}}, this was an integer that simply returned an error code. It is now a strongly typed enum when XPCOM is built using a C++11 compiler. This causes compile-time errors to occur when improper values are returned as nsresult values, thereby making it easier to catch many bugs.

diff --git a/files/zh-tw/mozilla/tech/xpcom/reference/interface/index.html b/files/zh-tw/mozilla/tech/xpcom/reference/interface/index.html deleted file mode 100644 index d098cf8402..0000000000 --- a/files/zh-tw/mozilla/tech/xpcom/reference/interface/index.html +++ /dev/null @@ -1,19 +0,0 @@ ---- -title: XPCOM Interface Reference -slug: Mozilla/Tech/XPCOM/Reference/Interface -tags: - - NeedsTranslation - - TopicStub - - XPCOM - - XPCOM Interface Reference -translation_of: Mozilla/Tech/XPCOM/Reference/Interface ---- -

This is a reference to the XPCOM interfaces provided by the Mozilla platform.

- -
{{tree('','1')}}
- -

See also

- - diff --git a/files/zh-tw/mozilla/tech/xpcom/reference/interface/nsicontentpolicy/index.html b/files/zh-tw/mozilla/tech/xpcom/reference/interface/nsicontentpolicy/index.html deleted file mode 100644 index 6ed47b6c80..0000000000 --- a/files/zh-tw/mozilla/tech/xpcom/reference/interface/nsicontentpolicy/index.html +++ /dev/null @@ -1,491 +0,0 @@ ---- -title: nsIContentPolicy -slug: Mozilla/Tech/XPCOM/Reference/Interface/nsIContentPolicy -translation_of: Archive/Mozilla/nsIContentPolicy ---- -

{{IFSummaryStart(“DOM /鹼/ nsIContentPolicy.idl”,“編寫腳本”)}}接口用於實現內容策略的機制。這個接口的實現可以被用來控制各種類型的外的線的內容,或者某些類型的內聯內容的處理的負荷。{{IFSummaryEnd(“nsIContentPolicyBase”,42,“1.0”)}}

- -

可以觀察到,正在通過實施{{接口(“nsIContentPolicy”)}}加載到瀏覽器中的內容。如果你正在開發一個內容感知的插件(攔截廣告或改變內容的外觀,例如)該接口是非常有用的,或者如果你想停止或允許用戶瀏覽的網址。

- -

{{WarningStart()}}不要阻塞調用者在你的實施方式{{manch(“shouldLoad”)}}或{{manch(“為ShouldProcess”)}}(例如,通過啟動一個對話框,以提示用戶東西)。“){{WarningEnd()}}

- -
-

注:在現實中,很多這種接口在{{接口(“nsIContentPolicyBase”)}}接口定義,但現在,直到有人有時間來拆東西記錄在這裡。

-
- -

方法概述

- - - - - - - - - - -
short shouldLoad(in unsigned long aContentType, in nsIURI aContentLocation, in nsIURI aRequestOrigin, in nsISupports aContext, in ACString aMimeTypeGuess, in nsISupports aExtra, in nsIPrincipal aRequestPrincipal);
short shouldProcess(in unsigned long aContentType, in nsIURI aContentLocation, in nsIURI aRequestOrigin, in nsISupports aContext, in ACString aMimeType, in nsISupports aExtra, in nsIPrincipal aRequestPrincipal);
- -

常量

- -

內容類型

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
不變描述
TYPE_OTHER1指示內容,其類型是未知的,或者是不感興趣的一個有限的使用情況之外。在一般情況下,你應該盡量不要使用這種類型的,除非沒有其他人是合適的。{{gecko_minversion_inline(“1.8”)}}
TYPE_SCRIPT2表示的可執行script(例如JavaScript)。{{gecko_minversion_inline(“1.8”)}}
TYPE_IMAGE3指示image(例如,{{HTMLElement的(“IMG”)}}的元素)。{{gecko_minversion_inline(“1.8”)}}
TYPE_STYLESHEET4指示stylesheet(例如,{{HTMLElement的(“風格”)}}的元素)。{{gecko_minversion_inline(“1.8”)}}
TYPE_OBJECT5代表一個普通object(插件,處理內容通常這一類下降)。{{gecko_minversion_inline(“1.8”)}}
TYPE_DOCUMENT6表示DOM {{domxref(“文件”)}}在頂層(即,直接在瀏覽器標籤)。{{gecko_minversion_inline(“1.8”)}}
TYPE_SUBDOCUMENT7 -

表示包含在另一個一{{domxref(“文件”)}} document例如,{{HTMLElement的(“IFRAME”)}}和{{HTMLElement的(“幀”)}}的元素)。{{gecko_minversion_inline(“1.8”)}}

- -
-

注:壁虎使用TYPE_INTERNAL_FRAME,並TYPE_INTERNAL_IFRAME以內部辨別其差異。這些類型映射到TYPE_SUBDOCUMENT被傳遞到內容政策實施前,不應外壁虎代碼中使用。{{gecko_minversion_inline(41)}}

-
-
TYPE_REFRESH8 -

指示定時刷新。

- -

{{manch(“shouldLoad”)}}將永遠不會得到這個,因為它並不代表內容被加載(通過刷新觸發的實際負載將通過{{manch(“shouldLoad”)}}如預期)。

- {{manch(“為ShouldProcess”)}}將收到此為,例如{{HTMLElement的(“元”)}}刷新元件和HTTP刷新頭。{{gecko_minversion_inline(“1.8”)}}
TYPE_XBL9指示XBL綁定請求,觸發或者通過{{cssxref(“ - MOZ結合”)}} CSS屬性或{{domxref(“Document.addBinding()”)}}方法。{{gecko_minversion_inline(“1.8”)}}
TYPE_PING10表示通過在{{HTML元素(“A”)}}使用元素{{htmlattrxref(“平”,“一”)}}屬性的點擊觸發的平。{{gecko_minversion_inline(“1.9”)}}
TYPE_XMLHTTPREQUEST11表示{{domxref(“XMLHttpRequest的”)}}。也用於{{domxref(“Document.load()”)}} {{gecko_minversion_inline(“1.9”)}}
TYPE_OBJECT_SUBREQUEST12表示由一個插件的請求。{{gecko_minversion_inline(“1.9”)}}
TYPE_DTD13表示通過XML加載的DTD document{{gecko_minversion_inline(“1.9”)}}
TYPE_FONT14指示經由{{cssxref(“@字體面”)}}規則加載的字體。{{gecko_minversion_inline(“1.9.1”)}}
TYPE_MEDIA15表示視頻或音頻負載。{{gecko_minversion_inline(“1.9.1”)}}
TYPE_WEBSOCKET16表示的WebSocket的負荷。{{gecko_minversion_inline(“11”)}}
TYPE_CSP_REPORT17表示一個內容安全策略報告。{{gecko_minversion_inline(“20”)}}
TYPE_XSLT18表示一個樣式表轉換。{{gecko_minversion_inline(“27”)}}
TYPE_BEACON19表示信標後。{{gecko_minversion_inline(“30”)}}
TYPE_FETCH20指示通過發起的負載的{{domxref(“GlobalFetch.fetch()”)}}方法,其可作為在全球都{{domxref(“窗口”)}}和{{domxref(“工人”)} }上下文。{{gecko_minversion_inline(36)}}
TYPE_IMAGESET21指示要加載的{{HTML元素(“IMG”)}}(與該{{htmlattrxref(“srcset”,“IMG”)}}屬性或{{HTMLElement的(“圖片”)}}。{{gecko_minversion_inline(請求36)}}
TYPE_WEB_MANIFEST22指示要加載一個Web清單的請求。{{gecko_minversion_inline(41)}}
TYPE_INTERNAL_SCRIPT23 -

用於表示使用{{HTMLElement的(“腳本”)}}元素加載的腳本的內部常數。{{gecko_minversion_inline(41)}}

- -
-

重要說明:此類型映射到TYPE_SCRIPT傳遞給內容政策實施之前,不宜在室外的Gecko內核代碼中使用。

-
-
TYPE_INTERNAL_WORKER24 -

用於表示通過專用工人加載的腳本的內部常數。{{gecko_minversion_inline(41)}}

- -
-

重要說明:此類型映射到TYPE_SCRIPT傳遞給內容政策實施之前,不宜在室外的Gecko內核代碼中使用。

-
-
TYPE_INTERNAL_SHARED_WORKER25 -

用於表示通過共享工人加載的腳本的內部常數。{{gecko_minversion_inline(41)}}

- -
-

重要說明:此類型映射到TYPE_SCRIPT傳遞給內容政策實施之前,不宜在室外的Gecko內核代碼中使用。

-
-
TYPE_INTERNAL_EMBED26 -

內部常量用於表示從{{HTML元素(“嵌入”)}}元素加載的內容。{{gecko_minversion_inline(41)}}

- -
-

重要說明:此類型映射到TYPE_OBJECT傳遞給內容政策實施之前,不宜在室外的Gecko內核代碼中使用。

-
-
TYPE_INTERNAL_OBJECT27 -

內部常量用於表示從{{HTMLElement的(“對象”)}}元素加載的內容。{{gecko_minversion_inline(41)}}

- -
-

重要說明:此類型映射到TYPE_OBJECT傳遞給內容政策實施之前,不宜在室外的Gecko內核代碼中使用。

-
-
TYPE_INTERNAL_FRAME28 -

內部常量用於表示從{{HTML元素(“幀”)}}元素加載的內容。{{gecko_minversion_inline(41)}}

- -
-

重要說明:此類型映射到TYPE_SUBDOCUMENT傳遞給內容政策實施之前,不宜在室外的Gecko內核代碼中使用。

-
-
TYPE_INTERNAL_IFRAME29 -

內部常量用於表示從{{HTML元素(“IFRAME”)}}元素加載的內容。{{gecko_minversion_inline(41)}}

- -
-

重要說明:此類型映射到TYPE_SUBDOCUMENT傳遞給內容政策實施之前,不宜在室外的Gecko內核代碼中使用。

-
-
TYPE_INTERNAL_AUDIO30 -

內部常量用於表示從{{HTML元素(“音頻”)}}元素加載的內容。{{gecko_minversion_inline(41)}}

- -
-

重要說明:此類型映射到TYPE_MEDIA傳遞給內容政策實施之前,不宜在室外的Gecko內核代碼中使用。

-
-
TYPE_INTERNAL_VIDEO31 -

內部常量用於表示從{{HTML元素(“視頻”)}}元素加載的內容。{{gecko_minversion_inline(41)}}

- -
-

重要說明:此類型映射到TYPE_MEDIA傳遞給內容政策實施之前,不宜在室外的Gecko內核代碼中使用。

-
-
TYPE_INTERNAL_TRACK32 -

內部常量用於表示從{{HTML元素(“軌道”)}}元素加載的內容。{{gecko_minversion_inline(41)}}

- -
-

重要說明:此類型映射到TYPE_MEDIA傳遞給內容政策實施之前,不宜在室外的Gecko內核代碼中使用。

-
-
REJECT_REQUEST-1從{{manch(“shouldLoad”)}}或{{manch(“為ShouldProcess”)}}返回如果負載或處理請求是基於所述請求的細節拒絕。{{gecko_minversion_inline(“1.8”)}}
REJECT_TYPE-2 -

從{{manch(“shouldLoad”)}}或{{manch(“為ShouldProcess”)}}返回如果負載/過程僅僅基於(上述標誌)它的類型拒絕。

- {{注(“這甩只適用於該服務器上的當前請求,而不是同一類型的未來需求。”)}} {{gecko_minversion_inline(“1.8”)}}
REJECT_SERVER-3 -

從{{manch(“shouldLoad”)}}或{{manch(“為ShouldProcess”)}}如果負載/過程是基於在服務器上拒絕它託管在或從請求(返回aContentLocationaRequestOrigin),例如,如果塊的IMAGE,因為它是從goatse.cx服務(即使你不一定阻止other從該服務器/域類型)。

- {{注(“這甩只適用於該服務器上的當前請求,而不是同一類型的未來需求。”)}} {{gecko_minversion_inline(“1.8”)}}
REJECT_OTHER-4 -

從{{manch(“shouldLoad”)}}或返回{{manch(“為ShouldProcess”)}}如果負載/過程是基於一些拒絕other標準。Mozilla的呼叫者會處理這個喜歡REJECT_REQUEST; 第三方實現者,例如,用這個來指導自己的來電諮詢額外參數的更多細節。{{gecko_minversion_inline(“1.8”)}}

- -

{{注(“這甩只適用於該服務器上的當前請求,而不是同一類型的未來需求。”)}}

-
ACCEPT1從{{manch(“shouldLoad”)}}或{{manch(“為ShouldProcess”)}}如果負載或處理請求不被拒絕返回。{{gecko_minversion_inline(“1.8”)}}
OTHER0{{obsolete_inline(“1.8”)}}
SCRIPT1{{obsolete_inline(“1.8”)}}
IMAGE2{{obsolete_inline(“1.8”)}}
STYLESHEET3{{obsolete_inline(“1.8”)}}
OBJECT4{{obsolete_inline(“1.8”)}}
SUBDOCUMENT5{{obsolete_inline(“1.8”)}}
CONTROL_TAG6{{obsolete_inline(“1.8”)}}
RAW_URL7{{obsolete_inline(“1.8”)}}
DOCUMENT8{{obsolete_inline(“1.8”)}}
- -

方法

- -

shouldLoad()

- -

打電話讓自己的內容政策的執行決定在給定位置的資源是否應該被加載。這種方法是通過加載指定aContentLocation的資源,以確定是否要開始加載所請求的資源之前調用。

- -

shouldLoad()可以稱為同時所涉及的文檔的DOM和佈局是不一致的狀態。這意味著,該方法的實施者不得做任何以下內容:

- -
    -
  1. 以任何方式修改DOM中(例如,設置屬性是一個沒有沒有)。
  2. -
  3. 查詢依賴於佈局(例如,任何DOM屬性offset*屬性)。
  4. -
  5. 查詢依賴於任何風格的DOM屬性(例如,計算方式)。
  6. -
  7. 查詢依賴於DOM的當前狀態的“上下文”節點(例如,節點列表的長度)之外的任何DOM屬性。
  8. -
  9. [JavaScript實現僅]不使用XPCNativeWrapper(顯式或隱式地)的任何對象上的任何類型的訪問屬性。由於各種DOM0的事情,這會導致項目4。
  10. -
- -

如果你在做這些事情shouldLoad()的實現,期望不可預知的行為,可能包括死機,沒有顯示出來的內容,內容顯示了一倍,等等。如果你不需要做任何的事情上面,做他們關閉超時或事件。

- -
:當多個內容策略用於(例如,通過幾個擴展),如果其中一人拒絕的請求,該政策的其餘部分不叫。參考:http://mxr.mozilla.org/mozilla-central/source/content/base/src/nsContentPolicy.cpp#146
- -
:內容政策在上述情況下的順序取決於安裝的優先級。
- -
短shouldLoad(
-  在無符號長aContentType,
-  在nsIURI aContentLocation,
-  在nsIURI aRequestOrigin,
-  在nsISupports aContext,
-  在ACString aMimeTypeGuess,
-  在nsISupports aExtra,
-  在nsIPrincipal aRequestPrincipal
-);
-
- -
參數
- -
-
aContentType
-
的類型的內容進行測試。這將是一個一個{{ANCH(“內容類型”)}}在上面列出。
-
aContentLocation
-
的內容的URI被檢查; 一定不能null
-
aRequestOrigin {optional_inline}}
-
啟動此加載請求的資源的位置; null如果不適用。
-
aContext {optional_inline}}
-
的{{接口(“nsIDOMNode”)}}或{{接口(“nsIDOMWindow”)}}發起請求,或一些可以QueryInterface()向其中的一個; null如果不適用。
-
{{音符(“aContext是當用戶使用的上下文菜單中的新選項卡/窗口或CMD / CTRL +打開鏈接的新選項卡/窗口點擊鏈接(即,aContext不是該鏈路是在拉片在這些情況下)。“)}}
-
 
-
 
-
aMimeTypeGuess
-
可選的。用於所請求的內容的MIME類型猜測,基於可用於請求發起(例如,信息OBJECT的類型屬性); 不能可靠地反映實際的MIME類型所請求的內容。
-
aExtra
-
一個可選的參數,直通非壁虎呼叫者額外的數據傳遞給被調用者。
-
- -
-
aRequestPrincipal
-
可選的。定義了導致負載的主體。這僅適用於可選的非壁虎代碼:所有的壁虎代碼應該設置此參數。對於導航事件,這是導致該加載頁面的主體。
-
- -
返回值
- -

ACCEPT 要么 REJECT_*

- -

為ShouldProcess()

- -

如果資源被處理?{{manch(“為ShouldProcess”)}}將被調用一次傳遞給它的所有資料已被確定有關資源,資源的一部分已經被加載後一般。“處理”是指通過處理應用程序。例如,為ShouldProcess可以用來允許來自服務器的響應根據MIME類型的響應的處理或忽略。

- -

{{NoteStart()}} {{manch(“為ShouldProcess”)}}可以被稱為當DOM和佈局document涉及處於不一致的狀態。查看{{manch(“shouldLoad”)}}筆記,看看這是什麼意思了這種方法的實現者。{{NoteEnd()}}

- -
短為ShouldProcess(
-  在無符號長aContentType,
-  在nsIURI aContentLocation,
-  在nsIURI aRequestOrigin,
-  在nsISupports aContext,
-  在ACString aMimeType,
-  在nsISupports aExtra,
-  在nsIPrincipal aRequestPrincipal
-);
-
- -
參數
- -
-
aContentType
-
的類型的內容進行測試。這將是TYPE_ *常量之一。
-
aContentLocation
-
可選的。被請求的資源的位置:可能是,例如,一個重定向後的URI資源。
-
aRequestOrigin
-
可選的。啟動此加載請求的資源的位置; null如果不適用。
-
aContext
-
可選的。的{{接口(“nsIDOMNode”)}}或發起請求{{接口(“nsIDOMWindow”)}},或一些可以查詢接口的那些中的一個; null如果不適用。
-
aMimeType
-
MIME類型所請求的資源(例如,圖像/ PNG)的,所報告的網絡庫,如果可用的話(可以是空的,如果不適合的類型,例如,TYPE_REFRESH)。
-
aExtra
-
一個可選的參數,直通非壁虎呼叫者額外的數據傳遞給被調用者。
-
- -
-
aRequestPrincipal
-
可選的。提出請求的主體。
-
- -
返回值
- -

ACCEPT 要么 REJECT_*

- -

- -

您可以通過包括容易實現這個接口nsIContentPolicy.h的頭文件和實現public nsIContentPolicy到類,如下所示:

- -
//將這個變成你的頭文件
-
-#包括“_path_to_sdk /包括/內容/ nsIContentPolicy.h”
-
-MyClass類:公共nsISupports,公共nsIContentPolicy {
-  ...
-  NS_DECL_NSICONTENTPOLICY
-  ...
-}
-
-//這到您的實現文件 
-NS_IMPL_ISUPPORTSn(MyClass的,nsISupports,nsIContentPolicy,...)
-
- -

{{NoteStart()}}之前,你能接受的通知,你必須註冊你的插件{{接口(“nsICategoryManager”)}}。見下面的例子。{{NoteEnd()}}

- -
字符*以前= nsnull; 
-
-nsCOMPtr的的<nsICategoryManager> catman; 
-
-servman-> GetServiceByContractID(NS_CATEGORYMANAGER_CONTRACTID,
-NS_GET_IID(nsICategoryManager)
-getter_AddRefs(catman)); 
-
-RV = catman-> AddCategoryEntry(“內容的策略”,
-COMPONENT_CLASSNAME,
-COMPONENT_CONTRACTID,
-PR_TRUE,   
-PR_TRUE,
-以前);
- -

JavaScript開發人員也可以實現XPCOM組件擴展nsIContentPolicy

-- cgit v1.2.3-54-g00ecf