--- title: Firefox 4 技術文件 slug: Mozilla/Firefox/Releases/4 translation_of: Mozilla/Firefox/Releases/4 ---
{{FirefoxSidebar}}

2010 年六月起進入 Beta 測試期的 Firefox 4,增進了效能、加強針對 HTML 5 及其他創新網際科技的支援程度,也更加安全。本文為網頁、附加元件、Gecko 平台開發者們提供這一版的簡要技術相關資訊。

Gecko 1.9.3 即將更名為 Gecko 2,但許多文件還沒有針對此點更新,在接下來的幾個星期中才會有所更動。

以下大部分的功能都已經可以在 逐日建置版中試用。

註:本文、以及本文所連結的其他文件仍持續編修中,很多文件的名稱只是暫定、有些主題的文件也可能會拆成幾份子文件以方便閱讀。中文團隊的目標將僅翻譯這份概覽,其他子文件則有待大家的幫忙。

Features for web developers

Gecko now uses the HTML5 parser, which fixes bugs, improves interoperability, and improves performance. It also lets content embed SVG and MathML directly in the HTML markup.

HTML

Introduction to the HTML5 parser
A look at what the HTML5 parser means to you, and how to embed SVG and MathML into your content inline.
Forms in HTML5
A look at improvements to web forms in HTML5.
HTML5 Sections
Gecko now supports the new HTML5 elements related to sections in a document: {{ HTMLElement("article") }}, {{ HTMLElement("section") }}, {{ HTMLElement("nav") }}, {{ HTMLElement("aside") }}, {{ HTMLElement("hgroup") }}, {{ HTMLElement("header") }} and {{ HTMLElement("footer") }}.
Other HTML5 elements
Gecko now also supports the following new HTML5 elements: {{ HTMLElement("mark") }}, {{ HTMLElement("figure") }} and  {{ HTMLElement("figcaption") }}.
WebSockets
A guide to using the new WebSockets API for real-time communication between a web application and a server.

Miscellaneous HTML changes

CSS

CSS transitions
New CSS transitions support is available in Firefox 4.
Computed values in CSS
Support for calc() to compute values in CSS is in progress. See {{ bug(363249) }}.
Selector grouping
Support for {{ cssxref(":-moz-any") }} to group selectors and factorize combinators.
Background image subrectangle support
The {{ cssxref("-moz-image-rect") }} property makes it possible to use subrectangles of images as a background image.
CSS touch properties
Support for touch properties is added. Details, and real article names, to come later.
Privacy and the :visited selector
Changes have been made to what information can be obtained about the style of visited links using CSS selectors. This may affect some web applications.

Miscellaneous CSS changes

Graphics and video

 
WebGL
The developing WebGL standard is now supported by Firefox.
Optimizing graphics performance
Tips and tricks for getting the most out of graphics and video performance in Firefox 4.
Support for WebM video
The new open WebM video format is supported by Gecko 1.9.3; support is included in nightlies as of 9 June.
Full screen API
Details coming soon.
SMIL animation
Support for SMIL animation of SVG is now available. See {{ bug(482402) }}.
Using SVG as images and as CSS backgrounds
You can now use SVG with the {{ htmlelement("img") }} element, as well as the background image in CSS. See {{ bug(272288) }}, {{ bug(276431) }} and {{ bug(231179) }}.

DOM

Obtaining boundary rectangles for ranges
The Range object now has getClientRects() and getBoundingClientRect() methods. See {{ bug(396392) }}.
Capturing mouse events on arbitrary elements
Support for the Internet Explorer-originated setCapture() and releaseCapture() APIs has been added. See {{ bug(503943) }}.
Manipulating the browser history
The existing document history object, available through the {{ domxref("window.history") }} object, now supports the new HTML5 pushState() and replaceState() methods.
Touch and multi-touch events
Support has been added for touch and multi-touch events.
IndexedDB
The proposed IndexedDB standard, which provides a local database store for web applications, will be supported by Firefox 4.

Miscellaneous DOM changes

Security

Introducing Content Security Policy
Content Security Policy (CSP) is a Mozilla proposal designed to help web designers and server administrators specify how content on their web sites interacts. The goal is to help detect and mitigate attacks including cross-site scripting and data injection attacks.
ForceTLS
Details soon.
The Account Manager
Details soon.

JavaScript

For an overview of the changes implemented in JavaScript 1.8.5, see New in JavaScript 1.8.5. JavaScript in Firefox 4 will have additional adherence to the ECMAScript 5 standard.

Changes for Mozilla and add-on developers

For helpful tips on updating existing extensions for Firefox 4, see Updating extensions for Firefox 4.

JavaScript code modules

Services.jsm
The Services.jsm code module provides getters that make it easy to obtain references to commonly-used services, such as the preferences service or the window mediator, among others.
JS-ctypes API
The JS-ctypes API makes it possible to call C-compatible foreign library functions without using XPCOM.
Add-ons Manager
The new Add-ons Manager provides information about installed add-ons, support for managing them, and provides ways to install and remove add-ons.
Loading code modules from chrome: URLs
You can now load JavaScript code modules using chrome: URLs, even inside JAR files.

DOM changes

{{ domxref("ChromeWorker") }}
A new type of worker for privileged code; this lets you use things like js-ctypes from workers in extensions and application code.

XUL

tabbrowser (gBrowser) changes

Several changes were made to the {{ XULElem("tabbrowser") }} element that impact extensions that interact with tabs.

Miscellaneous XUL changes

Storage

Miscellaneous storage API changes

XPCOM

XPCOM changes in Gecko 1.9.3
Details about changes to XPCOM that impact compatibility in Firefox 4.
Components.utils.getGlobalForObject()
This new method returns the global object with which an object is associated; this replaces a common use case of the now-removed __parent__.

Memory management

Infallible memory allocation
Mozilla now provides infallible memory allocators that are guaranteed not to return null. You should read this article to learn how they work and how to explicitly request fallible versus infallible memory allocation.

Other changes

Gopher support removed
The Gopher protocol is no longer supported natively. Continued support is available via the OverbiteFF extension.
Default plugin removed
The default plugin has been removed. The application plugins folder has also been removed by default, however support for installing plugins via this folder still exists. See bug 533891.
Extension Manager replaced with AddonManager
nsIExtensionManager has been replaced by AddonManager. Since there is apparently no way at present to obtain the install location from a given extension ID, the closest workaround is to use the directory service to find the profile directory and append "extensions" to it (though this approach will not catch extensions outside of the profile directory or those which are aliased to another location).

參考

{{ languages( { "en": "en/Firefox_4_for_developers", "de": "de/Firefox_4_fur_Entwickler", "ja": "ja/Firefox_4_for_developers"} ) }}