This commit is contained in:
David Anderson 2011-09-06 13:54:08 -07:00
Родитель c4aeb23000 1e1b62fb5f
Коммит 91bcc54152
286 изменённых файлов: 4842 добавлений и 3437 удалений

Просмотреть файл

@ -56,7 +56,7 @@ interface nsIAccessibleRelation;
* Mozilla creates the implementations of nsIAccessible on demand.
* See http://www.mozilla.org/projects/ui/accessibility for more information.
*/
[scriptable, uuid(c7ac764a-b4c5-4479-9fb7-06e3c9f3db34)]
[scriptable, uuid(3126544c-826c-4694-a2ed-67bfe56a1f37)]
interface nsIAccessible : nsISupports
{
/**
@ -221,26 +221,6 @@ interface nsIAccessible : nsISupports
*/
nsIAccessible getChildAt(in long aChildIndex);
/**
* Accessible node geometrically to the right of this one
*/
nsIAccessible getAccessibleToRight();
/**
* Accessible node geometrically to the left of this one
*/
nsIAccessible getAccessibleToLeft();
/**
* Accessible node geometrically above this one
*/
nsIAccessible getAccessibleAbove();
/**
* Accessible node geometrically below this one
*/
nsIAccessible getAccessibleBelow();
/**
* Return accessible relation by the given relation type (see.
* constants defined in nsIAccessibleRelation).

Просмотреть файл

@ -1974,30 +1974,6 @@ NS_IMETHODIMP nsAccessible::GetHelp(nsAString& _retval)
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIAccessible getAccessibleToRight(); */
NS_IMETHODIMP nsAccessible::GetAccessibleToRight(nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIAccessible getAccessibleToLeft(); */
NS_IMETHODIMP nsAccessible::GetAccessibleToLeft(nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIAccessible getAccessibleAbove(); */
NS_IMETHODIMP nsAccessible::GetAccessibleAbove(nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIAccessible getAccessibleBelow(); */
NS_IMETHODIMP nsAccessible::GetAccessibleBelow(nsIAccessible **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
nsIContent*
nsAccessible::GetAtomicRegion() const
{

Просмотреть файл

@ -810,42 +810,35 @@ __try {
if (!pvarEndUpAt)
return E_INVALIDARG;
nsAccessible *xpAccessibleStart = GetXPAccessibleFor(varStart);
if (!xpAccessibleStart || IsDefunct())
nsAccessible* accessible = GetXPAccessibleFor(varStart);
if (!accessible || accessible->IsDefunct())
return E_FAIL;
VariantInit(pvarEndUpAt);
nsCOMPtr<nsIAccessible> xpAccessibleResult;
nsAccessible* navAccessible = nsnull;
PRUint32 xpRelation = 0;
switch(navDir) {
case NAVDIR_DOWN:
xpAccessibleStart->GetAccessibleBelow(getter_AddRefs(xpAccessibleResult));
break;
case NAVDIR_FIRSTCHILD:
if (!nsAccUtils::MustPrune(xpAccessibleStart))
xpAccessibleStart->GetFirstChild(getter_AddRefs(xpAccessibleResult));
if (!nsAccUtils::MustPrune(accessible))
navAccessible = accessible->FirstChild();
break;
case NAVDIR_LASTCHILD:
if (!nsAccUtils::MustPrune(xpAccessibleStart))
xpAccessibleStart->GetLastChild(getter_AddRefs(xpAccessibleResult));
break;
case NAVDIR_LEFT:
xpAccessibleStart->GetAccessibleToLeft(getter_AddRefs(xpAccessibleResult));
if (!nsAccUtils::MustPrune(accessible))
navAccessible = accessible->LastChild();
break;
case NAVDIR_NEXT:
xpAccessibleStart->GetNextSibling(getter_AddRefs(xpAccessibleResult));
navAccessible = accessible->NextSibling();
break;
case NAVDIR_PREVIOUS:
xpAccessibleStart->GetPreviousSibling(getter_AddRefs(xpAccessibleResult));
navAccessible = accessible->PrevSibling();
break;
case NAVDIR_DOWN:
case NAVDIR_LEFT:
case NAVDIR_RIGHT:
xpAccessibleStart->GetAccessibleToRight(getter_AddRefs(xpAccessibleResult));
break;
case NAVDIR_UP:
xpAccessibleStart->GetAccessibleAbove(getter_AddRefs(xpAccessibleResult));
break;
return E_NOTIMPL;
// MSAA relationship extensions to accNavigate
case NAVRELATION_CONTROLLED_BY:
@ -896,17 +889,20 @@ __try {
case NAVRELATION_DESCRIPTION_FOR:
xpRelation = nsIAccessibleRelation::RELATION_DESCRIPTION_FOR;
break;
default:
return E_INVALIDARG;
}
pvarEndUpAt->vt = VT_EMPTY;
if (xpRelation) {
Relation rel = RelationByType(xpRelation);
xpAccessibleResult = rel.Next();
navAccessible = rel.Next();
}
if (xpAccessibleResult) {
pvarEndUpAt->pdispVal = NativeAccessible(xpAccessibleResult);
if (navAccessible) {
pvarEndUpAt->pdispVal = NativeAccessible(navAccessible);
pvarEndUpAt->vt = VT_DISPATCH;
return S_OK;
}

1
aclocal.m4 поставляемый
Просмотреть файл

@ -16,6 +16,7 @@ builtin(include, build/autoconf/mozheader.m4)dnl
builtin(include, build/autoconf/acwinpaths.m4)dnl
builtin(include, build/autoconf/lto.m4)dnl
builtin(include, build/autoconf/gcc-pr49911.m4)dnl
builtin(include, build/autoconf/frameptr.m4)dnl
MOZ_PROG_CHECKMSYS()

Просмотреть файл

@ -486,6 +486,11 @@ SessionStoreService.prototype = {
this._forEachBrowserWindow(function(aWindow) {
this._collectWindowData(aWindow);
});
// we must cache this because _getMostRecentBrowserWindow will always
// return null by the time quit-application occurs
var activeWindow = this._getMostRecentBrowserWindow();
if (activeWindow)
this.activeWindowSSiCache = activeWindow.__SSi || "";
this._dirtyWindows = [];
break;
case "quit-application-granted":
@ -1512,6 +1517,13 @@ SessionStoreService.prototype = {
let lastWindow = this._getMostRecentBrowserWindow();
let canUseLastWindow = lastWindow &&
!lastWindow.__SS_lastSessionWindowID;
let lastSessionFocusedWindow = null;
this.windowToFocus = lastWindow;
// move the last focused window to the start of the array so that we
// minimize window movement (see bug 669272)
lastSessionState.windows.unshift(
lastSessionState.windows.splice(lastSessionState.selectedWindow - 1, 1)[0]);
// Restore into windows or open new ones as needed.
for (let i = 0; i < lastSessionState.windows.length; i++) {
@ -1549,9 +1561,18 @@ SessionStoreService.prototype = {
// weirdness but we will still merge other extData.
// Bug 588217 should make this go away by merging the group data.
this.restoreWindow(windowToUse, { windows: [winState] }, canOverwriteTabs, true);
if (i == 0)
lastSessionFocusedWindow = windowToUse;
// if we overwrote the tabs for our last focused window, we should
// give focus to the window that had it in the previous session
if (canOverwriteTabs && windowToUse == lastWindow)
this.windowToFocus = lastSessionFocusedWindow;
}
else {
this._openWindowWithState({ windows: [winState] });
let win = this._openWindowWithState({ windows: [winState] });
if (i == 0)
lastSessionFocusedWindow = win;
}
}
@ -2544,8 +2565,12 @@ SessionStoreService.prototype = {
this._closedWindows = root._closedWindows;
var winData;
if (!aState.selectedWindow) {
aState.selectedWindow = 0;
if (!root.selectedWindow) {
root.selectedWindow = 0;
} else {
// put the selected window at the beginning of the array to ensure that
// it gets restored first
root.windows.unshift(root.windows.splice(root.selectedWindow - 1, 1)[0]);
}
// open new windows for all further window entries of a multi-window session
// (unless they don't contain any tab data)
@ -2553,9 +2578,6 @@ SessionStoreService.prototype = {
winData = root.windows[w];
if (winData && winData.tabs && winData.tabs[0]) {
var window = this._openWindowWithState({ windows: [winData] });
if (w == aState.selectedWindow - 1) {
this.windowToFocus = window;
}
}
}
winData = root.windows[0];

Просмотреть файл

@ -55,7 +55,13 @@ var StyleInspector = {
return Services.prefs.getBoolPref("devtools.styleinspector.enabled");
},
createPanel: function SI_createPanel()
/**
* Factory method to create the actual style panel
* @param {Boolean} aPreserveOnHide Prevents destroy from being called
* onpopuphide. USE WITH CAUTION: When this value is set to true then you are
* responsible to manually call destroy from outside the style inspector.
*/
createPanel: function SI_createPanel(aPreserveOnHide)
{
let win = Services.wm.getMostRecentWindow("navigator:browser");
let popupSet = win.document.getElementById("mainPopupSet");
@ -98,7 +104,10 @@ var StyleInspector = {
hbox.appendChild(resizer);
popupSet.appendChild(panel);
panel.addEventListener("popupshown", function SI_popup_shown() {
/**
* Initialize the popup when it is first shown
*/
function SI_popupShown() {
if (!this.cssHtmlTree) {
this.cssLogic = new CssLogic();
this.cssHtmlTree = new CssHtmlTree(iframe, this.cssLogic, this);
@ -107,12 +116,23 @@ var StyleInspector = {
this.cssLogic.highlight(this.selectedNode);
this.cssHtmlTree.highlight(this.selectedNode);
Services.obs.notifyObservers(null, "StyleInspector-opened", null);
}, false);
}
/**
* Hide the popup and conditionally destroy it
*/
function SI_popupHidden() {
if (panel.preserveOnHide) {
Services.obs.notifyObservers(null, "StyleInspector-closed", null);
} else {
panel.destroy();
}
}
panel.addEventListener("popupshown", SI_popupShown);
panel.addEventListener("popuphidden", SI_popupHidden);
panel.preserveOnHide = !!aPreserveOnHide;
panel.addEventListener("popuphidden", function SI_popup_hidden() {
Services.obs.notifyObservers(null, "StyleInspector-closed", null);
}, false);
/**
* Check if the style inspector is open
*/
@ -138,6 +158,19 @@ var StyleInspector = {
}
};
/**
* Destroy the style panel, remove listeners etc.
*/
panel.destroy = function SI_destroy()
{
this.cssLogic = null;
this.cssHtmlTree = null;
this.removeEventListener("popupshown", SI_popupShown);
this.removeEventListener("popuphidden", SI_popupHidden);
this.parentNode.removeChild(this);
Services.obs.notifyObservers(null, "StyleInspector-closed", null);
};
/**
* Is the Style Inspector initialized?
* @returns {Boolean} true or false

Просмотреть файл

@ -1786,7 +1786,6 @@ HUD_SERVICE.prototype =
panels = popupset.querySelectorAll("panel[hudToolId=" + aHUDId + "]");
for (let i = 0; i < panels.length; i++) {
panels[i].hidePopup();
popupset.removeChild(panels[i]);
}
let id = ConsoleUtils.supString(aHUDId);

Просмотреть файл

@ -811,9 +811,22 @@ toolbar[mode="icons"] #zoom-in-button {
background-clip: padding-box;
}
#urlbar:-moz-window-inactive,
.searchbar-textbox:-moz-window-inactive {
border-color: @toolbarbuttonInactiveBorderColor@;
@media (-moz-mac-lion-theme) {
#urlbar,
.searchbar-textbox {
background-image: -moz-linear-gradient(hsl(0,0%,97%), hsl(0,0%,100%));
border-color: hsla(0,0%,0%,.35) hsla(0,0%,0%,.25) hsla(0,0%,0%,.15);
box-shadow: 0 1px 0 hsla(0,0%,100%,.2),
inset 0 0 1px hsla(0,0%,0%,.05),
inset 0 1px 2px hsla(0,0%,0%,.1);
}
}
@media not all and (-moz-mac-lion-theme) {
#urlbar:-moz-window-inactive,
.searchbar-textbox:-moz-window-inactive {
border-color: @toolbarbuttonInactiveBorderColor@;
}
}
#urlbar[focused="true"],

Просмотреть файл

@ -0,0 +1,25 @@
dnl Set MOZ_FRAMEPTR_FLAGS to the flags that should be used for enabling or
dnl disabling frame pointers in this architecture based on the configure
dnl options
AC_DEFUN([MOZ_SET_FRAMEPTR_FLAGS], [
if test "$GNU_CC"; then
MOZ_ENABLE_FRAME_PTR="-fno-omit-frame-pointer"
MOZ_DISABLE_FRAME_PTR="-fomit-frame-pointer"
else
case "$target" in
*-mingw*)
MOZ_ENABLE_FRAME_PTR="-Oy-"
MOZ_DISABLE_FRAME_PTR="-Oy"
;;
esac
fi
# if we are debugging or profiling, we want a frame pointer.
if test -z "$MOZ_OPTIMIZE" -o \
-n "$MOZ_PROFILING" -o -n "$MOZ_DEBUG"; then
MOZ_FRAMEPTR_FLAGS="$MOZ_ENABLE_FRAME_PTR"
else
MOZ_FRAMEPTR_FLAGS="$MOZ_DISABLE_FRAME_PTR"
fi
])

Просмотреть файл

@ -2423,7 +2423,7 @@ nsScriptSecurityManager::doGetObjectPrincipal(JSObject *aObj
// avoid wasting time checking properties of their classes etc in
// the loop.
if (jsClass == &js_FunctionClass) {
if (jsClass == &js::FunctionClass) {
aObj = aObj->getParent();
if (!aObj)
@ -2431,7 +2431,7 @@ nsScriptSecurityManager::doGetObjectPrincipal(JSObject *aObj
jsClass = aObj->getClass();
if (jsClass == &js_CallClass) {
if (jsClass == &js::CallClass) {
aObj = aObj->getParent();
if (!aObj)

Просмотреть файл

@ -303,6 +303,7 @@ ACDEFINES = @MOZ_DEFINES@
WARNINGS_AS_ERRORS = @WARNINGS_AS_ERRORS@
MOZ_OPTIMIZE = @MOZ_OPTIMIZE@
MOZ_FRAMEPTR_FLAGS = @MOZ_FRAMEPTR_FLAGS@
MOZ_OPTIMIZE_FLAGS = @MOZ_OPTIMIZE_FLAGS@
MOZ_PGO_OPTIMIZE_FLAGS = @MOZ_PGO_OPTIMIZE_FLAGS@
MOZ_OPTIMIZE_LDFLAGS = @MOZ_OPTIMIZE_LDFLAGS@

Просмотреть файл

@ -463,6 +463,9 @@ endif # MOZ_OPTIMIZE == 1
endif # MOZ_OPTIMIZE
endif # CROSS_COMPILE
CFLAGS += $(MOZ_FRAMEPTR_FLAGS)
CXXFLAGS += $(MOZ_FRAMEPTR_FLAGS)
# Check for FAIL_ON_WARNINGS & FAIL_ON_WARNINGS_DEBUG (Shorthand for Makefiles
# to request that we use the 'warnings as errors' compile flags)

Просмотреть файл

@ -2071,12 +2071,7 @@ case "$target" in
*-darwin*)
MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
# If we're building with --enable-profiling, we need a frame pointer.
if test -z "$MOZ_PROFILING"; then
MOZ_OPTIMIZE_FLAGS="-O3 -fomit-frame-pointer"
else
MOZ_OPTIMIZE_FLAGS="-O3 -fno-omit-frame-pointer"
fi
MOZ_OPTIMIZE_FLAGS="-O3"
_PEDANTIC=
CFLAGS="$CFLAGS -fno-common"
CXXFLAGS="$CXXFLAGS -fno-common"
@ -2188,12 +2183,7 @@ ia64*-hpux*)
TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
MOZ_GFX_OPTIMIZE_MOBILE=1
# If we're building with --enable-profiling, we need a frame pointer.
if test -z "$MOZ_PROFILING"; then
MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions -fomit-frame-pointer"
else
MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions -fno-omit-frame-pointer"
fi
MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions"
;;
*-*linux*)
@ -2211,14 +2201,8 @@ ia64*-hpux*)
# -Os is broken on gcc 4.1.x 4.2.x, 4.5.x we need to tweak it to get good results.
MOZ_OPTIMIZE_SIZE_TWEAK="-finline-limit=50"
esac
# If we're building with --enable-profiling, we need a frame pointer.
if test -z "$MOZ_PROFILING"; then
MOZ_FRAMEPTR_FLAGS="-fomit-frame-pointer"
else
MOZ_FRAMEPTR_FLAGS="-fno-omit-frame-pointer"
fi
MOZ_PGO_OPTIMIZE_FLAGS="-O3 $MOZ_FRAMEPTR_FLAGS"
MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks $MOZ_OPTIMIZE_SIZE_TWEAK $MOZ_FRAMEPTR_FLAGS"
MOZ_PGO_OPTIMIZE_FLAGS="-O3"
MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks $MOZ_OPTIMIZE_SIZE_TWEAK"
MOZ_DEBUG_FLAGS="-g"
fi
@ -2315,12 +2299,7 @@ ia64*-hpux*)
MOZ_DEBUG_FLAGS='-Zi'
MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
WARNINGS_AS_ERRORS='-WX'
# If we're building with --enable-profiling, we need -Oy-, which forces a frame pointer.
if test -z "$MOZ_PROFILING"; then
MOZ_OPTIMIZE_FLAGS='-O1'
else
MOZ_OPTIMIZE_FLAGS='-O1 -Oy-'
fi
MOZ_OPTIMIZE_FLAGS='-O1'
MOZ_FIX_LINK_PATHS=
DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
@ -6897,6 +6876,8 @@ else
MOZ_OPTIMIZE=
fi ], MOZ_OPTIMIZE=1)
MOZ_SET_FRAMEPTR_FLAGS
if test "$COMPILE_ENVIRONMENT"; then
if test -n "$MOZ_OPTIMIZE"; then
AC_MSG_CHECKING([for valid optimization flags])
@ -6915,6 +6896,7 @@ fi
fi # COMPILE_ENVIRONMENT
AC_SUBST(MOZ_OPTIMIZE)
AC_SUBST(MOZ_FRAMEPTR_FLAGS)
AC_SUBST(MOZ_OPTIMIZE_FLAGS)
AC_SUBST(MOZ_OPTIMIZE_LDFLAGS)
AC_SUBST(MOZ_OPTIMIZE_SIZE_TWEAK)

Просмотреть файл

@ -1700,6 +1700,26 @@ public:
*/
static PRBool IsFocusedContent(const nsIContent *aContent);
/**
* Returns PR_TRUE if the DOM full-screen API is enabled.
*/
static PRBool IsFullScreenApiEnabled();
/**
* Returns PR_TRUE if requests for full-screen are allowed in the current
* context. Requests are only allowed if the user initiated them (like with
* a mouse-click or key press), unless this check has been disabled by
* setting the pref "full-screen-api.allow-trusted-requests-only" to false.
*/
static PRBool IsRequestFullScreenAllowed();
/**
* Returns PR_TRUE if key input is restricted in DOM full-screen mode
* to non-alpha-numeric key codes only. This mirrors the
* "full-screen-api.key-input-restricted" pref.
*/
static PRBool IsFullScreenKeyInputRestricted();
static void GetShiftText(nsAString& text);
static void GetControlText(nsAString& text);
static void GetMetaText(nsAString& text);
@ -1864,6 +1884,9 @@ private:
static PRBool sIsHandlingKeyBoardEvent;
static PRBool sAllowXULXBL_for_file;
static PRBool sIsFullScreenApiEnabled;
static PRBool sTrustedFullScreenOnly;
static PRBool sFullScreenKeyInputRestricted;
static nsHtml5Parser* sHTMLFragmentParser;
static nsIParser* sXMLFragmentParser;

Просмотреть файл

@ -125,10 +125,9 @@ class Element;
} // namespace dom
} // namespace mozilla
#define NS_IDOCUMENT_IID \
{ 0x455e4d79, 0x756b, 0x4f73, \
{ 0x95, 0xea, 0x3f, 0xf6, 0x0c, 0x6a, 0x8c, 0xa6 } }
{ 0x170d5a75, 0xff0b, 0x4599, \
{ 0x9b, 0x68, 0x18, 0xb7, 0x42, 0xe0, 0xf9, 0xf7 } }
// Flag for AddStyleSheet().
#define NS_STYLESHEET_FROM_CATALOG (1 << 0)
@ -742,6 +741,43 @@ public:
virtual void AddToNameTable(Element* aElement, nsIAtom* aName) = 0;
virtual void RemoveFromNameTable(Element* aElement, nsIAtom* aName) = 0;
/**
* Resets the current full-screen element to nsnull.
*/
virtual void ResetFullScreenElement() = 0;
/**
* Returns the element which either is the full-screen element, or
* contains the full-screen element if a child of this document contains
* the fullscreen element.
*/
virtual Element* GetFullScreenElement() = 0;
/**
* Requests that the document make aElement the full-screen element,
* and move into full-screen mode.
*/
virtual void RequestFullScreen(Element* aElement) = 0;
/**
* Requests that the document, and all documents in its hierarchy exit
* from DOM full-screen mode.
*/
virtual void CancelFullScreen() = 0;
/**
* Updates the full-screen status on this document, setting the full-screen
* mode to aIsFullScreen. This doesn't affect the window's full-screen mode,
* this updates the document's internal state which determines whether the
* document reports as being in full-screen mode.
*/
virtual void UpdateFullScreenStatus(PRBool aIsFullScreen) = 0;
/**
* Returns PR_TRUE if this document is in full-screen mode.
*/
virtual PRBool IsFullScreenDoc() = 0;
//----------------------------------------------------------------------
// Document notification API's

Просмотреть файл

@ -282,8 +282,8 @@ private:
// IID for the nsINode interface
#define NS_INODE_IID \
{ 0x5572c8a9, 0xbda9, 0x4b78, \
{ 0xb4, 0x1a, 0xdb, 0x1a, 0x83, 0xef, 0x53, 0x7e } }
{ 0xb59269fe, 0x7f60, 0x4672, \
{ 0x8e, 0x56, 0x01, 0x84, 0xb2, 0x58, 0x14, 0xb0 } }
/**
* An internal interface that abstracts some DOMNode-related parts that both
@ -1085,6 +1085,14 @@ public:
return GetNextNodeImpl(aRoot, PR_TRUE);
}
/**
* Returns true if 'this' is either document or element or
* document fragment and aOther is a descendant in the same
* anonymous tree.
*/
PRBool Contains(const nsINode* aOther) const;
nsresult Contains(nsIDOMNode* aOther, PRBool* aReturn);
private:
nsIContent* GetNextNodeImpl(const nsINode* aRoot,

Просмотреть файл

@ -176,6 +176,7 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID);
#include "nsIPluginHost.h"
#include "nsICategoryManager.h"
#include "nsIViewManager.h"
#include "nsEventStateManager.h"
#ifdef IBMBIDI
#include "nsIBidiKeyboard.h"
@ -261,6 +262,9 @@ nsString* nsContentUtils::sAltText = nsnull;
nsString* nsContentUtils::sModifierSeparator = nsnull;
PRBool nsContentUtils::sInitialized = PR_FALSE;
PRBool nsContentUtils::sIsFullScreenApiEnabled = PR_FALSE;
PRBool nsContentUtils::sTrustedFullScreenOnly = PR_TRUE;
PRBool nsContentUtils::sFullScreenKeyInputRestricted = PR_TRUE;
nsHtml5Parser* nsContentUtils::sHTMLFragmentParser = nsnull;
nsIParser* nsContentUtils::sXMLFragmentParser = nsnull;
@ -384,6 +388,15 @@ nsContentUtils::Init()
Preferences::AddBoolVarCache(&sAllowXULXBL_for_file,
"dom.allow_XUL_XBL_for_file");
Preferences::AddBoolVarCache(&sIsFullScreenApiEnabled,
"full-screen-api.enabled");
Preferences::AddBoolVarCache(&sTrustedFullScreenOnly,
"full-screen-api.allow-trusted-requests-only");
Preferences::AddBoolVarCache(&sFullScreenKeyInputRestricted,
"full-screen-api.key-input-restricted");
sInitialized = PR_TRUE;
return NS_OK;
@ -5696,3 +5709,20 @@ nsContentUtils::IsPatternMatching(nsAString& aValue, nsAString& aPattern,
return res == JS_FALSE || rval != JSVAL_NULL;
}
PRBool
nsContentUtils::IsFullScreenApiEnabled()
{
return sIsFullScreenApiEnabled;
}
PRBool nsContentUtils::IsRequestFullScreenAllowed()
{
return !sTrustedFullScreenOnly || nsEventStateManager::IsHandlingUserInput();
}
PRBool
nsContentUtils::IsFullScreenKeyInputRestricted()
{
return sFullScreenKeyInputRestricted;
}

Просмотреть файл

@ -657,6 +657,12 @@ nsDOMAttribute::IsSameNode(nsIDOMNode *other, PRBool *aResult)
return NS_OK;
}
NS_IMETHODIMP
nsDOMAttribute::Contains(nsIDOMNode* aOther, PRBool* aReturn)
{
return nsINode::Contains(aOther, aReturn);
}
NS_IMETHODIMP
nsDOMAttribute::LookupPrefix(const nsAString & namespaceURI,
nsAString & aResult)

Просмотреть файл

@ -181,6 +181,7 @@
#include "nsGlobalWindow.h"
#include "mozilla/dom/indexedDB/IndexedDatabaseManager.h"
#include "nsDOMNavigationTiming.h"
#include "nsEventStateManager.h"
#ifdef MOZ_SMIL
#include "nsSMILAnimationController.h"
@ -1544,6 +1545,7 @@ nsDOMImplementation::CreateHTMLDocument(const nsAString& aTitle,
nsDocument::nsDocument(const char* aContentType)
: nsIDocument()
, mAnimatingImages(PR_TRUE)
, mIsFullScreen(PR_FALSE)
{
SetContentTypeInternal(nsDependentCString(aContentType));
@ -1871,6 +1873,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsDocument)
nsIDOMNodeList)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOriginalDocument)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mCachedEncoder)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mFullScreenElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mStateObjectCached)
// Traverse all our nsCOMArrays.
@ -1927,6 +1930,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDocument)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mImageMaps)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOriginalDocument)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mCachedEncoder)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mFullScreenElement)
tmp->mParentDocument = nsnull;
@ -5874,6 +5878,12 @@ nsDocument::GetUserData(const nsAString & key,
return nsINode::GetUserData(key, aResult);
}
NS_IMETHODIMP
nsDocument::Contains(nsIDOMNode* aOther, PRBool* aReturn)
{
return nsINode::Contains(aOther, aReturn);
}
NS_IMETHODIMP
nsDocument::GetInputEncoding(nsAString& aInputEncoding)
{
@ -8459,6 +8469,221 @@ nsIDocument::SizeOf() const
return size;
}
// Returns the root document in a document hierarchy.
static nsIDocument*
GetRootDocument(nsIDocument* aDoc)
{
if (!aDoc) {
return nsnull;
}
nsCOMPtr<nsIPresShell> shell = aDoc->GetShell();
if (!shell) {
return nsnull;
}
nsPresContext* ctx = shell->GetPresContext();
if (!ctx) {
return nsnull;
}
nsRootPresContext* rpc = ctx->GetRootPresContext();
if (!rpc) {
return nsnull;
}
return rpc->Document();
}
class nsDispatchFullScreenChange : public nsRunnable
{
public:
nsDispatchFullScreenChange(nsIDocument *aDoc)
: mDoc(aDoc)
{
mTarget = aDoc->GetFullScreenElement();
if (!mTarget) {
mTarget = aDoc;
}
}
NS_IMETHOD Run()
{
nsContentUtils::DispatchTrustedEvent(mDoc,
mTarget,
NS_LITERAL_STRING("mozfullscreenchange"),
PR_TRUE,
PR_FALSE);
return NS_OK;
}
nsCOMPtr<nsIDocument> mDoc;
nsCOMPtr<nsISupports> mTarget;
};
void
nsDocument::UpdateFullScreenStatus(PRBool aIsFullScreen)
{
if (mIsFullScreen != aIsFullScreen) {
nsCOMPtr<nsIRunnable> event(new nsDispatchFullScreenChange(this));
NS_DispatchToCurrentThread(event);
}
mIsFullScreen = aIsFullScreen;
if (!mIsFullScreen) {
// Full-screen is being turned off. Reset the full-screen element, to
// save us from having to traverse the document hierarchy again in
// MozCancelFullScreen().
ResetFullScreenElement();
}
}
static PRBool
UpdateFullScreenStatus(nsIDocument* aDocument, void* aData)
{
aDocument->UpdateFullScreenStatus(*static_cast<PRBool*>(aData));
aDocument->EnumerateSubDocuments(UpdateFullScreenStatus, aData);
return PR_TRUE;
}
static void
UpdateFullScreenStatusInDocTree(nsIDocument* aDoc, PRBool aIsFullScreen)
{
nsIDocument* root = GetRootDocument(aDoc);
if (root) {
UpdateFullScreenStatus(root, static_cast<void*>(&aIsFullScreen));
}
}
void
nsDocument::ResetFullScreenElement()
{
if (mFullScreenElement) {
nsEventStateManager::SetFullScreenState(mFullScreenElement, PR_FALSE);
}
mFullScreenElement = nsnull;
}
static PRBool
ResetFullScreenElement(nsIDocument* aDocument, void* aData)
{
aDocument->ResetFullScreenElement();
aDocument->EnumerateSubDocuments(ResetFullScreenElement, aData);
return PR_TRUE;
}
static void
ResetFullScreenElementInDocTree(nsIDocument* aDoc)
{
nsIDocument* root = GetRootDocument(aDoc);
if (root) {
ResetFullScreenElement(root, nsnull);
}
}
NS_IMETHODIMP
nsDocument::MozCancelFullScreen()
{
if (!nsContentUtils::IsRequestFullScreenAllowed()) {
return NS_OK;
}
CancelFullScreen();
return NS_OK;
}
void
nsDocument::CancelFullScreen()
{
if (!nsContentUtils::IsFullScreenApiEnabled() ||
!IsFullScreenDoc() ||
!GetWindow()) {
return;
}
// Disable full-screen mode in all documents in this hierarchy.
UpdateFullScreenStatusInDocTree(this, PR_FALSE);
// Move the window out of full-screen mode.
GetWindow()->SetFullScreen(PR_FALSE);
return;
}
PRBool
nsDocument::IsFullScreenDoc()
{
return nsContentUtils::IsFullScreenApiEnabled() && mIsFullScreen;
}
void
nsDocument::RequestFullScreen(Element* aElement)
{
if (!aElement || !nsContentUtils::IsFullScreenApiEnabled() || !GetWindow()) {
return;
}
// Reset the full-screen elements of every document in this document
// hierarchy.
ResetFullScreenElementInDocTree(this);
if (aElement->IsInDoc()) {
// Propagate up the document hierarchy, setting the full-screen element as
// the element's container in ancestor documents. Note we don't propagate
// down the document hierarchy, the full-screen element (or its container)
// is not visible there.
mFullScreenElement = aElement;
// Set the full-screen state on the element, so the css-pseudo class
// applies to the element.
nsEventStateManager::SetFullScreenState(mFullScreenElement, PR_TRUE);
nsIDocument* child = this;
nsIDocument* parent;
while (parent = child->GetParentDocument()) {
nsIContent* content = parent->FindContentForSubDocument(child);
nsCOMPtr<Element> element(do_QueryInterface(content));
// Containing frames also need the css-pseudo class applied.
nsEventStateManager::SetFullScreenState(element, PR_TRUE);
static_cast<nsDocument*>(parent)->mFullScreenElement = element;
child = parent;
}
}
// Set all documents in hierarchy to full-screen mode.
UpdateFullScreenStatusInDocTree(this, PR_TRUE);
// Make the window full-screen. Note we must make the state changes above
// before making the window full-screen, as then the document reports as
// being in full-screen mode when the Chrome "fullscreen" event fires,
// enabling browser.js to distinguish between browser and dom full-screen
// modes.
GetWindow()->SetFullScreen(PR_TRUE);
}
NS_IMETHODIMP
nsDocument::GetMozFullScreenElement(nsIDOMHTMLElement **aFullScreenElement)
{
NS_ENSURE_ARG_POINTER(aFullScreenElement);
if (!nsContentUtils::IsFullScreenApiEnabled() || !IsFullScreenDoc()) {
*aFullScreenElement = nsnull;
return NS_OK;
}
nsCOMPtr<nsIDOMHTMLElement> e(do_QueryInterface(GetFullScreenElement()));
NS_IF_ADDREF(*aFullScreenElement = e);
return NS_OK;
}
Element*
nsDocument::GetFullScreenElement()
{
if (!nsContentUtils::IsFullScreenApiEnabled() ||
(mFullScreenElement && !mFullScreenElement->IsInDoc())) {
return nsnull;
}
return mFullScreenElement;
}
NS_IMETHODIMP
nsDocument::GetMozFullScreen(PRBool *aFullScreen)
{
NS_ENSURE_ARG_POINTER(aFullScreen);
*aFullScreen = nsContentUtils::IsFullScreenApiEnabled() && IsFullScreenDoc();
return NS_OK;
}
PRInt64
nsDocument::SizeOf() const
{

Просмотреть файл

@ -941,6 +941,13 @@ public:
virtual Element* FindImageMap(const nsAString& aNormalizedMapName);
virtual void ResetFullScreenElement();
virtual Element* GetFullScreenElement();
virtual void RequestFullScreen(Element* aElement);
virtual void CancelFullScreen();
virtual void UpdateFullScreenStatus(PRBool aIsFullScreen);
virtual PRBool IsFullScreenDoc();
protected:
friend class nsNodeUtils;
@ -1078,6 +1085,9 @@ protected:
// Recorded time of change to 'loading' state.
mozilla::TimeStamp mLoadingTimeStamp;
// The current full-screen element of this document.
nsCOMPtr<Element> mFullScreenElement;
// True if the document has been detached from its content viewer.
PRPackedBool mIsGoingAway:1;
// True if the document is being destroyed.
@ -1110,6 +1120,9 @@ protected:
// Whether we currently require our images to animate
PRPackedBool mAnimatingImages:1;
// Whether we are currently in full-screen mode, as per the DOM API.
PRPackedBool mIsFullScreen:1;
PRUint8 mXMLDeclarationBits;
PRUint8 mDefaultElementType;

Просмотреть файл

@ -5530,3 +5530,44 @@ nsGenericElement::SizeOf() const
#include "nsEventNameList.h"
#undef TOUCH_EVENT
#undef EVENT
PRBool
nsINode::Contains(const nsINode* aOther) const
{
if (!aOther ||
aOther == this ||
GetOwnerDoc() != aOther->GetOwnerDoc() ||
IsInDoc() != aOther->IsInDoc() ||
!(aOther->IsElement() ||
aOther->IsNodeOfType(nsINode::eCONTENT)) ||
!GetFirstChild()) {
return PR_FALSE;
}
const nsIContent* other = static_cast<const nsIContent*>(aOther);
if (this == GetOwnerDoc()) {
// document.contains(aOther) returns true if aOther is in the document,
// but is not in any anonymous subtree.
// IsInDoc() check is done already before this.
return !other->IsInAnonymousSubtree();
}
if (!IsElement() && !IsNodeOfType(nsINode::eDOCUMENT_FRAGMENT)) {
return PR_FALSE;
}
const nsIContent* thisContent = static_cast<const nsIContent*>(this);
if (thisContent->GetBindingParent() != other->GetBindingParent()) {
return PR_FALSE;
}
return nsContentUtils::ContentIsDescendantOf(other, this);
}
nsresult
nsINode::Contains(nsIDOMNode* aOther, PRBool* aReturn)
{
nsCOMPtr<nsINode> node = do_QueryInterface(aOther);
*aReturn = Contains(node);
return NS_OK;
}

Просмотреть файл

@ -63,6 +63,7 @@
GK_ATOM(_empty, "")
GK_ATOM(moz, "_moz")
GK_ATOM(mozallowfullscreen, "mozallowfullscreen")
GK_ATOM(moztype, "_moz-type")
GK_ATOM(mozdirty, "_moz_dirty")
GK_ATOM(mozdonotsend, "moz-do-not-send")
@ -583,6 +584,7 @@ GK_ATOM(mouseout, "mouseout")
GK_ATOM(mouseover, "mouseover")
GK_ATOM(mousethrough, "mousethrough")
GK_ATOM(mouseup, "mouseup")
GK_ATOM(mozfullscreenchange, "mozfullscreenchange")
GK_ATOM(moz_opaque, "moz-opaque")
GK_ATOM(moz_action_hint, "mozactionhint")
GK_ATOM(x_moz_errormessage, "x-moz-errormessage")
@ -695,6 +697,7 @@ GK_ATOM(onMozMouseHittest, "onMozMouseHittest")
GK_ATOM(onmouseup, "onmouseup")
GK_ATOM(onMozAfterPaint, "onMozAfterPaint")
GK_ATOM(onMozBeforePaint, "onMozBeforePaint")
GK_ATOM(onmozfullscreenchange, "onmozfullscreenchange")
GK_ATOM(onMozMousePixelScroll, "onMozMousePixelScroll")
GK_ATOM(onMozScrolledAreaChanged, "onMozScrolledAreaChanged")
GK_ATOM(ononline, "ononline")

Просмотреть файл

@ -69,6 +69,7 @@ _CHROME_FILES = \
test_bug357450.xul \
test_bug571390.xul \
test_bug574596.html \
test_bug683852.xul \
$(NULL)
libs:: $(_TEST_FILES)

Просмотреть файл

@ -0,0 +1,67 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=683852
-->
<window title="Mozilla Bug 683852"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<button value="testbutton" id="testbutton"/>
<!-- test results are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml">
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=683852"
target="_blank" id="link">Mozilla Bug 683852</a>
</body>
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
/** Test for Bug 683852 **/
SimpleTest.waitForExplicitFinish();
function startTest() {
is(document.contains(document), false, "Document should not contain itself!");
var tb = document.getElementById("testbutton");
is(document.contains(tb), true, "Document should contain element in it!");
var anon = document.getAnonymousElementByAttribute(tb, "anonid", "button-box");
is(document.contains(anon), false, "Document should not contain anonymous element in it!");
is(tb.contains(anon), false, "Element should not contain anonymous element in it!");
is(document.documentElement.contains(tb), true, "Element should contain element in it!");
is(document.contains(document.createElement("foo")), false, "Document shouldn't contain element which is't in the document");
is(document.contains(document.createTextNode("foo")), false, "Document shouldn't contain text node which is't in the document");
var link = document.getElementById("link");
is(document.contains(link.firstChild), true,
"Document should contain a text node in it.");
is(link.contains(link.firstChild), true,
"Element should contain a text node in it.");
is(link.firstChild.contains(link), false, "text node shouldn't contain its parent.");
is(document.contains(null), false, "Document shouldn't contain null.");
var pi = document.createProcessingInstruction("adf", "asd");
is(pi.contains(document), false, "Processing instruction shouldn't contain document");
document.documentElement.appendChild(pi);
document.contains(pi, true, "Document should contain processing instruction");
var df = document.createRange().createContextualFragment("<div>foo</div>");
is(df.contains(df.firstChild), true, "Document fragment should contain its child");
is(df.contains(df.firstChild.firstChild), true,
"Document fragment should contain its descendant");
is(df.contains(df), false, "Document fragment shouldn't contain itself.");
var d = document.implementation.createHTMLDocument("");
is(document.contains(d), false,
"Document shouldn't contain another document.");
is(document.contains(d.createElement("div")), false,
"Document shouldn't contain an element from another document.");
SimpleTest.finish();
}
addLoadEvent(startTest);
]]>
</script>
</window>

Просмотреть файл

@ -38,51 +38,6 @@ function testCancelInPhase4() {
xhr2.addEventListener("load", function() {
is(xhr2.responseText, "0", "Received fresh value for second request");
testCancelBeforePhase4();
}, false);
xhr2.open("GET", url);
xhr2.setRequestHeader("X-Request", "1", false);
try { xhr2.send(); }
catch(e) {
is(xhr2.status, "200", "Exception!");
}
}, 0);
}, false);
xhr.abort();
}
}, false);
xhr.open("GET", url, true);
xhr.setRequestHeader("X-Request", "0", false);
try { xhr.send(); }
catch(e) {
is("Nothing", "Exception", "Boom: " + e);
}
}
// Tests that response is NOT cached if the request is cancelled
// before it has reached state 4
function testCancelBeforePhase4() {
clearCache();
// First request - should be loaded from server
var xhr = new XMLHttpRequest();
xhr.addEventListener("readystatechange", function(e) {
if (xhr.readyState == 3) {
xhr.addEventListener("abort", function() {
setTimeout(function() {
// This request was cancelled, so the responseText should be empty string
is(xhr.responseText, "", "Expected empty response to cancelled request");
// Second request - should be found in cache
var xhr2 = new XMLHttpRequest();
xhr2.addEventListener("load", function() {
is(xhr2.responseText, "1", "Received cached value for second request");
SimpleTest.finish();
}, false);

Просмотреть файл

@ -502,9 +502,7 @@ protected:
PRBool ValidateAttribIndex(WebGLuint index, const char *info);
PRBool ValidateStencilParamsForDrawCall();
bool ValidateGLSLVariableName(const nsAString& name, const char *info);
bool ValidateGLSLCharacter(PRUnichar c);
bool ValidateGLSLString(const nsAString& string, const char *info);
bool ValidateGLSLIdentifier(const nsAString& name, const char *info);
static PRUint32 GetTexelSize(WebGLenum format, WebGLenum type);

Просмотреть файл

@ -62,7 +62,6 @@
#endif
#include "WebGLTexelConversions.h"
#include "WebGLValidateStrings.h"
using namespace mozilla;
@ -183,8 +182,8 @@ WebGLContext::BindAttribLocation(nsIWebGLProgram *pobj, WebGLuint location, cons
if (!GetGLName<WebGLProgram>("bindAttribLocation: program", pobj, &progname))
return NS_OK;
if (!ValidateGLSLVariableName(name, "bindAttribLocation"))
return NS_OK;
if (name.IsEmpty())
return ErrorInvalidValue("BindAttribLocation: name can't be null or empty");
if (!ValidateAttribIndex(location, "bindAttribLocation"))
return NS_OK;
@ -1857,7 +1856,7 @@ WebGLContext::GetAttribLocation(nsIWebGLProgram *pobj,
if (!GetGLName<WebGLProgram>("getAttribLocation: program", pobj, &progname))
return NS_OK;
if (!ValidateGLSLVariableName(name, "getAttribLocation"))
if (!ValidateGLSLIdentifier(name, "getAttribLocation"))
return NS_OK;
MakeContextCurrent();
@ -2672,7 +2671,7 @@ WebGLContext::GetUniformLocation(nsIWebGLProgram *pobj, const nsAString& name, n
if (!GetConcreteObjectAndGLName("getUniformLocation: program", pobj, &prog, &progname))
return NS_OK;
if (!ValidateGLSLVariableName(name, "getUniformLocation"))
if (!ValidateGLSLIdentifier(name, "getUniformLocation"))
return NS_OK;
MakeContextCurrent();
@ -4138,10 +4137,7 @@ WebGLContext::ShaderSource(nsIWebGLShader *sobj, const nsAString& source)
WebGLuint shadername;
if (!GetConcreteObjectAndGLName("shaderSource: shader", sobj, &shader, &shadername))
return NS_OK;
if (!ValidateGLSLString(source, "shaderSource"))
return NS_OK;
const nsPromiseFlatString& flatSource = PromiseFlatString(source);
if (!NS_IsAscii(flatSource.get()))

Просмотреть файл

@ -328,31 +328,14 @@ PRBool WebGLContext::ValidateDrawModeEnum(WebGLenum mode, const char *info)
}
}
bool WebGLContext::ValidateGLSLVariableName(const nsAString& name, const char *info)
bool WebGLContext::ValidateGLSLIdentifier(const nsAString& name, const char *info)
{
const PRUint32 maxSize = 255;
const PRUint32 maxSize = 4095;
if (name.Length() > maxSize) {
ErrorInvalidValue("%s: identifier is %d characters long, exceeds the maximum allowed length of %d characters",
info, name.Length(), maxSize);
return false;
}
if (!ValidateGLSLString(name, info)) {
return false;
}
return true;
}
bool WebGLContext::ValidateGLSLString(const nsAString& string, const char *info)
{
for (PRUint32 i = 0; i < string.Length(); ++i) {
if (!ValidateGLSLCharacter(string.CharAt(i))) {
ErrorInvalidValue("%s: string contains the illegal character '%d'", info, string.CharAt(i));
return false;
}
}
return true;
}

Просмотреть файл

@ -1,58 +0,0 @@
/*
* Copyright (C) 2011 Apple Inc. All rights reserved.
* Copyright (C) 2011 Mozilla Corporation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef WEBGLVALIDATESTRINGS_H_
#define WEBGLVALIDATESTRINGS_H_
#include "WebGLContext.h"
namespace mozilla {
// The following function was taken from the WebKit WebGL implementation,
// which can be found here:
// http://trac.webkit.org/browser/trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp#L123
/****** BEGIN CODE TAKEN FROM WEBKIT ******/
bool WebGLContext::ValidateGLSLCharacter(PRUnichar c)
{
// Printing characters are valid except " $ ` @ \ ' DEL.
if (c >= 32 && c <= 126 &&
c != '"' && c != '$' && c != '`' && c != '@' && c != '\\' && c != '\'')
{
return true;
}
// Horizontal tab, line feed, vertical tab, form feed, carriage return are also valid.
if (c >= 9 && c <= 13) {
return true;
}
return false;
}
/****** END CODE TAKEN FROM WEBKIT ******/
} // end namespace mozilla
#endif // WEBGLVALIDATESTRINGS_H_

Просмотреть файл

@ -12,6 +12,7 @@ conformance/gl-getshadersource.html
conformance/gl-uniform-bool.html
conformance/glsl-conformance.html
conformance/glsl-long-variable-names.html
conformance/invalid-passed-params.html
conformance/premultiplyalpha-test.html
conformance/read-pixels-test.html
conformance/uninitialized-test.html

Просмотреть файл

@ -6,6 +6,7 @@ conformance/gl-getshadersource.html
conformance/gl-object-get-calls.html
conformance/glsl-conformance.html
conformance/glsl-long-variable-names.html
conformance/invalid-passed-params.html
conformance/premultiplyalpha-test.html
conformance/program-test.html
conformance/read-pixels-test.html

Просмотреть файл

@ -4,6 +4,7 @@ conformance/framebuffer-object-attachment.html
conformance/gl-getshadersource.html
conformance/glsl-conformance.html
conformance/glsl-long-variable-names.html
conformance/invalid-passed-params.html
conformance/premultiplyalpha-test.html
conformance/read-pixels-test.html
conformance/more/conformance/quickCheckAPI.html

Просмотреть файл

@ -243,6 +243,10 @@ EVENT(mouseup,
NS_MOUSE_BUTTON_UP,
EventNameType_All,
NS_MOUSE_EVENT)
EVENT(mozfullscreenchange,
NS_FULLSCREENCHANGE,
EventNameType_HTML,
NS_EVENT_NULL)
// Not supported yet; probably never because "wheel" is a better idea.
// EVENT(mousewheel)
EVENT(pause,

Просмотреть файл

@ -261,6 +261,9 @@ private:
#define NS_EVENT_STATE_MOZ_UI_INVALID NS_DEFINE_EVENT_STATE_MACRO(32)
// UI friendly version of :valid pseudo-class.
#define NS_EVENT_STATE_MOZ_UI_VALID NS_DEFINE_EVENT_STATE_MACRO(33)
// Content is the full screen element, or a frame containing the
// current full-screen element.
#define NS_EVENT_STATE_FULL_SCREEN NS_DEFINE_EVENT_STATE_MACRO(34)
/**
* NOTE: do not go over 63 without updating nsEventStates::InternalType!
@ -268,7 +271,8 @@ private:
#define ESM_MANAGED_STATES (NS_EVENT_STATE_ACTIVE | NS_EVENT_STATE_FOCUS | \
NS_EVENT_STATE_HOVER | NS_EVENT_STATE_DRAGOVER | \
NS_EVENT_STATE_URLTARGET | NS_EVENT_STATE_FOCUSRING)
NS_EVENT_STATE_URLTARGET | NS_EVENT_STATE_FOCUSRING | \
NS_EVENT_STATE_FULL_SCREEN)
#define INTRINSIC_STATES (~ESM_MANAGED_STATES)

Просмотреть файл

@ -92,6 +92,7 @@ static const char* const sEventNames[] = {
"MozAfterPaint",
"MozBeforePaint",
"MozBeforeResize",
"mozfullscreenchange",
"MozSwipeGesture",
"MozMagnifyGestureStart",
"MozMagnifyGestureUpdate",
@ -1366,6 +1367,8 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType)
return sEventNames[eDOMEvents_devicemotion];
case NS_DEVICE_ORIENTATION:
return sEventNames[eDOMEvents_deviceorientation];
case NS_FULLSCREENCHANGE:
return sEventNames[eDOMEvents_mozfullscreenchange];
default:
break;
}

Просмотреть файл

@ -177,6 +177,7 @@ public:
eDOMEvents_afterpaint,
eDOMEvents_beforepaint,
eDOMEvents_beforeresize,
eDOMEvents_mozfullscreenchange,
eDOMEvents_MozSwipeGesture,
eDOMEvents_MozMagnifyGestureStart,
eDOMEvents_MozMagnifyGestureUpdate,

Просмотреть файл

@ -4384,6 +4384,14 @@ static nsIContent* FindCommonAncestor(nsIContent *aNode1, nsIContent *aNode2)
return nsnull;
}
/* static */
void
nsEventStateManager::SetFullScreenState(Element* aElement,
PRBool aIsFullScreen)
{
DoStateChange(aElement, NS_EVENT_STATE_FULL_SCREEN, aIsFullScreen);
}
/* static */
inline void
nsEventStateManager::DoStateChange(Element* aElement, nsEventStates aState,

Просмотреть файл

@ -203,6 +203,10 @@ public:
// if aContent is non-null, marks the object as active.
static void SetActiveManager(nsEventStateManager* aNewESM,
nsIContent* aContent);
// Sets the full-screen event state on aElement to aIsFullScreen.
static void SetFullScreenState(mozilla::dom::Element* aElement, PRBool aIsFullScreen);
protected:
void UpdateCursor(nsPresContext* aPresContext, nsEvent* aEvent, nsIFrame* aTargetFrame, nsEventStatus* aStatus);
/**

Просмотреть файл

@ -3379,6 +3379,50 @@ nsGenericHTMLElement::Focus()
return fm ? fm->SetFocus(elem, 0) : NS_OK;
}
nsresult nsGenericHTMLElement::MozRequestFullScreen()
{
// Only grant full-screen requests if this is called from inside a trusted
// event handler (i.e. inside an event handler for a user initiated event).
// This stops the full-screen from being abused similar to the popups of old,
// and it also makes it harder for bad guys' script to go full-screen and
// spoof the browser chrome/window and phish logins etc.
if (!nsContentUtils::IsFullScreenApiEnabled() ||
!nsContentUtils::IsRequestFullScreenAllowed()) {
return NS_OK;
}
// Ensure that all ancestor <iframe> elements have the mozallowfullscreen
// boolean attribute set.
nsINode* node = static_cast<nsINode*>(this);
do {
nsIContent* content = static_cast<nsIContent*>(node);
if (content->IsHTML(nsGkAtoms::iframe) &&
!content->HasAttr(kNameSpaceID_None, nsGkAtoms::mozallowfullscreen)) {
// The node requesting fullscreen, or one of its crossdoc ancestors,
// is an iframe which doesn't have the "mozalllowfullscreen" attribute.
// This request is not authorized by the parent document.
return NS_OK;
}
node = nsContentUtils::GetCrossDocParentNode(node);
} while (node);
nsIDocument* doc = GetOwnerDoc();
NS_ENSURE_STATE(doc);
doc->RequestFullScreen(this);
#ifdef DEBUG
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(doc->GetWindow());
NS_ENSURE_STATE(window);
PRBool fullscreen;
window->GetFullScreen(&fullscreen);
NS_ASSERTION(fullscreen, "Windows should report fullscreen");
nsCOMPtr<nsIDOMDocument> domDocument(do_QueryInterface(doc));
domDocument->GetMozFullScreen(&fullscreen);
NS_ASSERTION(fullscreen, "Document should report fullscreen");
NS_ASSERTION(doc->IsFullScreenDoc(), "Should be in full screen state!");
#endif
return NS_OK;
}
nsresult nsGenericHTMLElement::Click()
{
if (HasFlag(NODE_HANDLING_CLICK))

Просмотреть файл

@ -139,6 +139,7 @@ public:
virtual nsresult InsertAdjacentHTML(const nsAString& aPosition,
const nsAString& aText);
nsresult ScrollIntoView(PRBool aTop, PRUint8 optional_argc);
nsresult MozRequestFullScreen();
// Declare Focus(), Blur(), GetTabIndex(), SetTabIndex(), GetHidden(),
// SetHidden(), GetSpellcheck(), SetSpellcheck(), and GetDraggable() such that
// classes that inherit interfaces with those methods properly override them.

Просмотреть файл

@ -131,6 +131,7 @@ NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Name, name)
NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Scrolling, scrolling)
NS_IMPL_URI_ATTR(nsHTMLIFrameElement, Src, src)
NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Width, width)
NS_IMPL_BOOL_ATTR(nsHTMLIFrameElement, MozAllowFullScreen, mozallowfullscreen)
NS_IMETHODIMP
nsHTMLIFrameElement::GetContentDocument(nsIDOMDocument** aContentDocument)

Просмотреть файл

@ -277,6 +277,9 @@ _TEST_FILES = \
test_checked.html \
test_bug677658.html \
test_bug677463.html \
file_fullscreen-api.html \
file_fullscreen-api-keys.html \
test_fullscreen-api.html \
$(NULL)
libs:: $(_TEST_FILES)

Просмотреть файл

@ -0,0 +1,250 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=545812
Test that restricted key pressed drop documents out of DOM full-screen mode.
-->
<head>
<title>Test for Bug 545812</title>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
</head>
<body onload="document.body.mozRequestFullScreen();">
<script type="application/javascript">
/** Test for Bug 545812 **/
// List of key codes, and whether they're restricted in full-screen mode.
var keyList = [
// Allowed: DOM_VK_CANCEL to DOM_VK_CAPS_LOCK, inclusive
{ code: "VK_CANCEL", allowed: true},
{ code: "VK_HELP", allowed: true},
{ code: "VK_BACK_SPACE", allowed: true},
{ code: "VK_TAB", allowed: true},
{ code: "VK_CLEAR", allowed: true},
{ code: "VK_RETURN", allowed: true},
{ code: "VK_ENTER", allowed: true},
{ code: "VK_SHIFT", allowed: true},
{ code: "VK_CONTROL", allowed: true},
{ code: "VK_ALT", allowed: true},
{ code: "VK_PAUSE", allowed: true},
{ code: "VK_CAPS_LOCK", allowed: true},
{ code: "VK_KANA", allowed: false},
{ code: "VK_HANGUL", allowed: false},
{ code: "VK_JUNJA", allowed: false},
{ code: "VK_FINAL", allowed: false},
{ code: "VK_HANJA", allowed: false},
{ code: "VK_KANJI", allowed: false},
{ code: "VK_ESCAPE", allowed: false},
{ code: "VK_CONVERT", allowed: false},
{ code: "VK_NONCONVERT", allowed: false},
{ code: "VK_ACCEPT", allowed: false},
{ code: "VK_MODECHANGE", allowed: false},
// Allowed: DOM_VK_SPACE to DOM_VK_DELETE, inclusive
{ code: "VK_SPACE", allowed: true},
{ code: "VK_PAGE_UP", allowed: true},
{ code: "VK_PAGE_DOWN", allowed: true},
{ code: "VK_END", allowed: true},
{ code: "VK_HOME", allowed: true},
{ code: "VK_LEFT", allowed: true},
{ code: "VK_UP", allowed: true},
{ code: "VK_RIGHT", allowed: true},
{ code: "VK_DOWN", allowed: true},
{ code: "VK_SELECT", allowed: true},
{ code: "VK_PRINT", allowed: true},
{ code: "VK_EXECUTE", allowed: true},
{ code: "VK_PRINTSCREEN", allowed: true},
{ code: "VK_INSERT", allowed: true},
{ code: "VK_DELETE", allowed: true},
{ code: "VK_0", allowed: false},
{ code: "VK_1", allowed: false},
{ code: "VK_2", allowed: false},
{ code: "VK_3", allowed: false},
{ code: "VK_4", allowed: false},
{ code: "VK_5", allowed: false},
{ code: "VK_6", allowed: false},
{ code: "VK_7", allowed: false},
{ code: "VK_8", allowed: false},
{ code: "VK_9", allowed: false},
// Allowed: DOM_VK_SPACE to DOM_VK_DELETE, inclusive
{ code: "VK_SEMICOLON", allowed: true},
{ code: "VK_EQUALS", allowed: true},
{ code: "VK_A", allowed: false},
{ code: "VK_B", allowed: false},
{ code: "VK_C", allowed: false},
{ code: "VK_D", allowed: false},
{ code: "VK_E", allowed: false},
{ code: "VK_F", allowed: false},
{ code: "VK_G", allowed: false},
{ code: "VK_H", allowed: false},
{ code: "VK_I", allowed: false},
{ code: "VK_J", allowed: false},
{ code: "VK_K", allowed: false},
{ code: "VK_L", allowed: false},
{ code: "VK_M", allowed: false},
{ code: "VK_N", allowed: false},
{ code: "VK_O", allowed: false},
{ code: "VK_P", allowed: false},
{ code: "VK_Q", allowed: false},
{ code: "VK_R", allowed: false},
{ code: "VK_S", allowed: false},
{ code: "VK_T", allowed: false},
{ code: "VK_U", allowed: false},
{ code: "VK_V", allowed: false},
{ code: "VK_W", allowed: false},
{ code: "VK_X", allowed: false},
{ code: "VK_Y", allowed: false},
{ code: "VK_Z", allowed: false},
{ code: "VK_CONTEXT_MENU", allowed: false},
{ code: "VK_SLEEP", allowed: false},
{ code: "VK_NUMPAD0", allowed: false},
{ code: "VK_NUMPAD1", allowed: false},
{ code: "VK_NUMPAD2", allowed: false},
{ code: "VK_NUMPAD3", allowed: false},
{ code: "VK_NUMPAD4", allowed: false},
{ code: "VK_NUMPAD5", allowed: false},
{ code: "VK_NUMPAD6", allowed: false},
{ code: "VK_NUMPAD7", allowed: false},
{ code: "VK_NUMPAD8", allowed: false},
{ code: "VK_NUMPAD9", allowed: false},
// Allowed: DOM_VK_MULTIPLY to DOM_VK_META, inclusive
{ code: "VK_MULTIPLY", allowed: true},
{ code: "VK_ADD", allowed: true},
{ code: "VK_SEPARATOR", allowed: true},
{ code: "VK_SUBTRACT", allowed: true},
{ code: "VK_DECIMAL", allowed: true},
{ code: "VK_DIVIDE", allowed: true},
{ code: "VK_F1", allowed: true},
{ code: "VK_F2", allowed: true},
{ code: "VK_F3", allowed: true},
{ code: "VK_F4", allowed: true},
{ code: "VK_F5", allowed: true},
{ code: "VK_F6", allowed: true},
{ code: "VK_F7", allowed: true},
{ code: "VK_F8", allowed: true},
{ code: "VK_F9", allowed: true},
{ code: "VK_F10", allowed: true},
{ code: "VK_F11", allowed: true},
{ code: "VK_F12", allowed: true},
{ code: "VK_F13", allowed: true},
{ code: "VK_F14", allowed: true},
{ code: "VK_F15", allowed: true},
{ code: "VK_F16", allowed: true},
{ code: "VK_F17", allowed: true},
{ code: "VK_F18", allowed: true},
{ code: "VK_F19", allowed: true},
{ code: "VK_F20", allowed: true},
{ code: "VK_F21", allowed: true},
{ code: "VK_F22", allowed: true},
{ code: "VK_F23", allowed: true},
{ code: "VK_F24", allowed: true},
{ code: "VK_NUM_LOCK", allowed: true},
{ code: "VK_SCROLL_LOCK", allowed: true},
{ code: "VK_COMMA", allowed: true},
{ code: "VK_PERIOD", allowed: true},
{ code: "VK_SLASH", allowed: true},
{ code: "VK_BACK_QUOTE", allowed: true},
{ code: "VK_OPEN_BRACKET", allowed: true},
{ code: "VK_BACK_SLASH", allowed: true},
{ code: "VK_CLOSE_BRACKET", allowed: true},
{ code: "VK_QUOTE", allowed: true},
{ code: "VK_META", allowed: true},
];
function ok(condition, msg) {
opener.ok(condition, msg);
}
function is(a, b, msg) {
opener.is(a, b, msg);
}
var gKeyTestIndex = 0;
var gKeyName;
var gKeyCode;
var gKeyAllowed;
var gKeyReceived = false;
function keyHandler(event) {
event.preventDefault()
gKeyReceived = true;
}
function checkKeyEffect() {
is(document.mozFullScreen, gKeyAllowed,
(gKeyAllowed ? ("Should remain in full-screen mode for allowed key press " + gKeyName)
: ("Should drop out of full-screen mode for restricted key press " + gKeyName)));
if (gKeyTestIndex < keyList.length) {
setTimeout(testNextKey, 0);
} else {
opener.keysTestFinished();
}
}
function testTrustedKeyEvents() {
document.body.focus();
gKeyReceived = false;
synthesizeKey(gKeyName, {});
setTimeout(checkKeyEffect, 0);
}
function testScriptInitiatedKeyEvents() {
// Script initiated untrusted key events should not be blocked.
document.body.focus();
gKeyReceived = false;
var evt = document.createEvent("KeyEvents");
evt.initKeyEvent("keydown", true, true, window,
false, false, false, false,
gKeyCode, 0);
document.body.dispatchEvent(evt);
evt = document.createEvent("KeyEvents");
evt.initKeyEvent("keypress", true, true, window,
false, false, false, false,
gKeyCode, 0);
document.body.dispatchEvent(evt);
evt = document.createEvent("KeyEvents");
evt.initKeyEvent("keyup", true, true, window,
false, false, false, false,
gKeyCode, 0);
document.body.dispatchEvent(evt);
ok(gKeyReceived, "dispatchEvent should dispatch events synchronously");
ok(document.mozFullScreen,
"Should remain in full-screen mode for script initiated key events for " + gKeyName);
}
function testNextKey() {
if (!document.mozFullScreen) {
document.body.mozRequestFullScreen();
}
ok(document.mozFullScreen, "Must be in full-screen mode");
gKeyName = keyList[gKeyTestIndex].code;
gKeyCode = KeyEvent["DOM_" + gKeyName];
gKeyAllowed = keyList[gKeyTestIndex].allowed;
gKeyTestIndex++;
testScriptInitiatedKeyEvents();
testTrustedKeyEvents();
}
window.addEventListener("keydown", keyHandler, true);
window.addEventListener("keyup", keyHandler, true);
window.addEventListener("keypress", keyHandler, true);
setTimeout(testNextKey, 0);
</script>
</pre>
</body>
</html>

Просмотреть файл

@ -0,0 +1,161 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=545812
Test DOM full-screen API.
-->
<head>
<title>Test for Bug 545812</title>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<style>
body:-moz-full-screen, div:-moz-full-screen {
background-color: red;
}
</style>
</head>
<body onload="document.body.mozRequestFullScreen();">
<script type="application/javascript">
/** Test for Bug 545812 **/
function ok(condition, msg) {
opener.ok(condition, msg);
}
function is(a, b, msg) {
opener.is(a, b, msg);
}
/*
<html>
<body onload='document.body.mozRequestFullScreen();'>
</body>
</html>
*/
var iframeContents = "data:text/html;charset=utf-8,<html>%0D%0A <body onload%3D'document.body.mozRequestFullScreen()%3B'>%0D%0A <%2Fbody>%0D%0A<%2Fhtml>";
var iframe = null;
var outOfDocElement = null;
var inDocElement = null;
var button = null;
var fullScreenChangeCount = 0;
function sendMouseClick(element) {
synthesizeMouseAtCenter(element, {});
}
function setRequireTrustedContext(value) {
opener.SpecialPowers.setBoolPref("full-screen-api.allow-trusted-requests-only", value);
}
function fullScreenChange(event) {
switch (fullScreenChangeCount) {
case 0: {
ok(document.mozFullScreen, "Should be in full-screen mode (first time)");
is(event.target, document.body, "Event target should be full-screen element");
is(document.mozFullScreenElement, document.body,
"Full-screen element should be body element.");
document.mozCancelFullScreen();
break;
}
case 1: {
ok(!document.mozFullScreen, "Should have left full-screen mode (first time)");
is(event.target, document.body, "Event target should be full-screen element");
is(document.mozFullScreenElement, null, "Full-screen element should be null.");
iframe = document.createElement("iframe");
iframe.mozAllowFullScreen = true;
document.body.appendChild(iframe);
iframe.src = iframeContents;
break;
}
case 2: {
ok(document.mozFullScreen, "Should be back in full-screen mode (second time)");
is(event.target, iframe,
"Event target should be full-screen element container");
is(document.mozFullScreenElement, iframe,
"Full-screen element should be iframe element.");
document.mozCancelFullScreen();
break;
}
case 3: {
ok(!document.mozFullScreen, "Should be back in non-full-screen mode (second time)");
is(event.target, iframe,
"Event target should be full-screen element container");
is(document.mozFullScreenElement, null, "Full-screen element should be null.");
document.body.removeChild(iframe);
iframe = null;
outOfDocElement = document.createElement("div");
outOfDocElement.mozRequestFullScreen();
break;
}
case 4: {
ok(document.mozFullScreen, "Should be back in full-screen mode (third time)");
is(event.target, document, "Event target should be document");
is(document.mozFullScreenElement, null,
"Should not have a full-screen element when element not in document requests full-screen.");
// Set another element to be the full-screen element. It should immediately
// become the current full-screen element.
inDocElement = document.createElement("div");
document.body.appendChild(inDocElement);
inDocElement.mozRequestFullScreen();
ok(document.mozFullScreen, "Should remain in full-screen mode (third and a half time)");
is(document.mozFullScreenElement, inDocElement,
"Full-screen element should be in doc again.");
// Remove full-screen element from document before exiting full screen.
document.body.removeChild(inDocElement);
ok(document.mozFullScreen,
"Should remain in full-screen mode after removing full-screen element from document");
is(document.mozFullScreenElement, null,
"Should not have a full-screen element again.");
document.mozCancelFullScreen();
break;
}
case 5: {
ok(!document.mozFullScreen, "Should be back in non-full-screen mode (third time)");
setRequireTrustedContext(true);
document.body.mozRequestFullScreen();
ok(!document.mozFullScreen, "Should still be in normal mode, because calling context isn't trusted.");
button = document.createElement("button");
button.onclick = function(){document.body.mozRequestFullScreen();}
document.body.appendChild(button);
sendMouseClick(button);
break;
}
case 6: {
ok(document.mozFullScreen, "Moved to full-screen after mouse click");
document.mozCancelFullScreen();
ok(document.mozFullScreen, "Should still be in full-screen mode, because calling context isn't trusted.");
setRequireTrustedContext(false);
document.mozCancelFullScreen();
ok(!document.mozFullScreen, "Should have left full-screen mode.");
break;
}
case 7: {
ok(!document.mozFullScreen, "Should have left full-screen mode (last time).");
// Set timeout for calling finish(), so that any pending "mozfullscreenchange" events
// would have a chance to fire.
setTimeout(function(){opener.apiTestFinished();}, 0);
break;
}
default: {
ok(false, "Should not receive any more fullscreenchange events!");
}
}
fullScreenChangeCount++;
}
document.addEventListener("mozfullscreenchange", fullScreenChange, false);
</script>
</pre>
</body>
</html>

Просмотреть файл

@ -40,7 +40,6 @@ function test() {
SimpleTest.waitForExplicitFinish();
addLoadEvent(test);
addLoadEvent(SimpleTest.finish);
</script>
</pre>

Просмотреть файл

@ -0,0 +1,83 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for Bug 545812</title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=545812">Mozilla Bug 545812</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 545812 **/
var testWindow = null;
/*
<html>
<body onload='document.body.mozRequestFullScreen();'>
</body>
</html>
*/
var requestFullScreenContents = "data:text/html;charset=utf-8,<html>%0D%0A <body onload%3D'document.body.mozRequestFullScreen()%3B'>%0D%0A <%2Fbody>%0D%0A<%2Fhtml>";
var prevTrusted = false;
var prevEnabled = false;
function run() {
document.addEventListener("mozfullscreenchange",
function(){ok(false, "Should never receive a mozfullscreenchange event in the main window.");},
false);
// Ensure the full-screen api is enabled, and will be disabled on test exit.
prevEnabled = SpecialPowers.getBoolPref("full-screen-api.enabled");
SpecialPowers.setBoolPref("full-screen-api.enabled", true);
prevTrusted = SpecialPowers.getBoolPref("full-screen-api.allow-trusted-requests-only");
// Request full-screen from a non trusted context (this script isn't a user
// generated event!). We should not receive a "mozfullscreenchange" event.
SpecialPowers.setBoolPref("full-screen-api.allow-trusted-requests-only", true);
document.body.mozRequestFullScreen();
// Disable the requirement for trusted contexts only, so the tests are easier
// to write.
SpecialPowers.setBoolPref("full-screen-api.allow-trusted-requests-only", false);
// Load an iframe whose contents requests full-screen. This request should
// fail, and we should never receive a "mozfullscreenchange" event, because the
// iframe doesn't have a mozallowfullscreen attribute.
var iframe = document.createElement("iframe");
iframe.src = requestFullScreenContents;
document.body.appendChild(iframe);
// Run the tests which go full-screen in a new window, as mochitests normally
// run in an iframe, which by default will not have the mozallowfullscreen
// attribute set, so full-screen won't work.
testWindow = window.open("file_fullscreen-api.html", "", "width=500,height=500");
}
function apiTestFinished() {
testWindow.close();
testWindow = window.open("file_fullscreen-api-keys.html", "", "width=500,height=500");
}
function keysTestFinished() {
testWindow.close();
SpecialPowers.setBoolPref("full-screen-api.enabled", prevEnabled);
SpecialPowers.setBoolPref("full-screen-api.allow-trusted-requests-only", prevTrusted);
SimpleTest.finish();
}
addLoadEvent(run);
SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>
</html>

Просмотреть файл

@ -60,6 +60,7 @@ _TEST_FILES = \
test_animLengthUnits.xhtml \
test_bbox.xhtml \
test_bbox-with-invalid-viewBox.xhtml \
test_bounds.html \
bbox-helper.svg \
bounds-helper.svg \
test_dataTypes.html \

Просмотреть файл

@ -7,24 +7,23 @@ text { font: 20px monospace; }
<g id="g">
<text id="text1" x="25" y="25">abc</text>
<text id="text1a" x="85" y="25" stroke="black" stroke-width="4">abc</text>
<rect id="rect1" x="50" y="50" width="50" height="50" fill="green"/>
<rect id="rect1a" x="50" y="50" width="50" height="50" fill="none" stroke-width="2" stroke="yellow"/>
<rect id="rect1a" x="50" y="50" width="50" height="50" fill="none" stroke-width="4" stroke="yellow"/>
<text id="text2" x="125" y="25">abc</text>
<text id="text2a" x="185" y="25" stroke="black" stroke-width="10">abc</text>
<g transform="rotate(45 175 75)">
<rect id="rect2" x="150" y="50" width="50" height="50" fill="yellow"/>
<rect id="rect2a" x="150" y="50" width="50" height="50" fill="none" stroke-width="2" stroke="blue"/>
<rect id="rect2a" x="150" y="50" width="50" height="50" fill="none" stroke-width="4" stroke="blue"/>
<text id="text3" x="150" y="50" text-anchor="middle">abc</text>
</g>
<g transform="scale(2)">
<rect id="rect3" x="25" y="80" width="50" height="50" fill="green"/>
<rect id="rect3a" x="25" y="80" width="50" height="50" fill="none" stroke-width="2" stroke="blue"/>
<rect id="rect3a" x="25" y="80" width="50" height="50" fill="none" stroke-width="4" stroke="blue"/>
</g>
<g transform="scale(2) rotate(45 175 75)">
<rect id="rect4" x="150" y="50" width="50" height="50" fill="yellow"/>
<rect id="rect4a" x="150" y="50" width="50" height="50" fill="none" stroke-width="2" stroke="blue"/>
<text id="text4" x="125" y="125">abc</text>
<rect id="rect4a" x="150" y="50" width="50" height="50" fill="none" stroke-width="4" stroke="blue"/>
</g>
<text id="text1a" x="85" y="25" stroke="black" stroke-width="1">M</text>
<text id="text2a" x="185" y="25" stroke="black" stroke-width="10">M</text>
</g>
</svg>

До

Ширина:  |  Высота:  |  Размер: 1.4 KiB

После

Ширина:  |  Высота:  |  Размер: 1.4 KiB

Просмотреть файл

@ -19,101 +19,120 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=463934
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
function Rect(left, top, width, height)
{
this.left = left;
this.top = top;
this.width = width;
this.height = height;
}
Rect.prototype.roundOut = function()
{
this.width = Math.ceil(this.left + this.width) - Math.floor(this.left);
this.height = Math.ceil(this.top + this.height) - Math.floor(this.top);
this.left = Math.floor(this.left);
this.top = Math.floor(this.top);
}
var delta = 1;
function isApproximately(a, b, message)
{
ok(delta >= Math.abs(a - b), message + " - got " + a + ", expected " + b + " ± " + delta);
}
function runTest()
{
function isRounded(a, b, message) {
is (Math.round(a), Math.round(b), message);
}
var doc = $("svg").contentWindow.document;
var text1 = doc.getElementById("text1");
var len = text1.getComputedTextLength();
var text1Bounds = text1.getBoundingClientRect();
var text2Bounds = doc.getElementById("text2").getBoundingClientRect();
var text3Bounds = doc.getElementById("text3").getBoundingClientRect();
var text4Bounds = doc.getElementById("text4").getBoundingClientRect();
var sin45 = Math.sin(Math.PI / 4);
isRounded(text1Bounds.left, 25, "text1.getBoundingClientRect().left");
isRounded(text1Bounds.width, len, "text1.getBoundingClientRect().width");
isApproximately(text1Bounds.left, 24, "text1.getBoundingClientRect().left");
isRounded(text2Bounds.left, text1Bounds.left + 100, "text2.getBoundingClientRect().left");
isRounded(text2Bounds.top, text1Bounds.top, "text2.getBoundingClientRect().top");
isRounded(text2Bounds.width, text1Bounds.width, "text2.getBoundingClientRect().width");
isRounded(text2Bounds.height, text1Bounds.height, "text2.getBoundingClientRect().height");
is(text2Bounds.left, text1Bounds.left + 100, "text2.getBoundingClientRect().left");
is(text2Bounds.top, text1Bounds.top, "text2.getBoundingClientRect().top");
is(text2Bounds.width, text1Bounds.width, "text2.getBoundingClientRect().width");
is(text2Bounds.height, text1Bounds.height, "text2.getBoundingClientRect().height");
isRounded(text3Bounds.width, (text1Bounds.width + text1Bounds.height) * sin45 + .5, "text3.getBoundingClientRect().width");
isRounded(text3Bounds.height, (text1Bounds.height + text1Bounds.width) * sin45 + .5, "text3.getBoundingClientRect().height");
isRounded(text4Bounds.width, 2 * (text1Bounds.width + text1Bounds.height) * sin45, "text4.getBoundingClientRect().width");
isRounded(text4Bounds.height, 2 * ((text1Bounds.height + text1Bounds.width) * sin45 - .5), "text4.getBoundingClientRect().height");
var r = (text1Bounds.width + text1Bounds.height) * sin45;
isApproximately(text3Bounds.width, Math.ceil(r), "text3.getBoundingClientRect().width");
isApproximately(text3Bounds.height, Math.ceil(r), "text3.getBoundingClientRect().height");
var rect1Bounds = doc.getElementById("rect1").getBoundingClientRect();
var rect2Bounds = doc.getElementById("rect2").getBoundingClientRect();
var rect3Bounds = doc.getElementById("rect3").getBoundingClientRect();
var rect4Bounds = doc.getElementById("rect4").getBoundingClientRect();
isRounded(rect1Bounds.left, 50, "rect1.getBoundingClientRect().left");
isRounded(rect1Bounds.top, 50, "rect1.getBoundingClientRect().top");
isRounded(rect1Bounds.width, 50, "rect1.getBoundingClientRect().width");
isRounded(rect1Bounds.height, 50, "rect1.getBoundingClientRect().height");
isRounded(rect2Bounds.left, 175 - 50 * sin45 - .5, "rect2.getBoundingClientRect().left");
isRounded(rect2Bounds.top, 75 - 50 * sin45 - .5, "rect2.getBoundingClientRect().top");
isRounded(rect2Bounds.width, (50 * sin45 + .5) * 2, "rect2.getBoundingClientRect().width");
isRounded(rect2Bounds.height, (50 * sin45 + .5) * 2, "rect2.getBoundingClientRect().height");
is(rect1Bounds.left, 50, "rect1.getBoundingClientRect().left");
is(rect1Bounds.top, 50, "rect1.getBoundingClientRect().top");
is(rect1Bounds.width, 50, "rect1.getBoundingClientRect().width");
is(rect1Bounds.height, 50, "rect1.getBoundingClientRect().height");
isRounded(rect3Bounds.left, 50, "rect3.getBoundingClientRect().left");
isRounded(rect3Bounds.top, 160, "rect3.getBoundingClientRect().top");
isRounded(rect3Bounds.width, 100, "rect3.getBoundingClientRect().width");
isRounded(rect3Bounds.height, 100, "rect3.getBoundingClientRect().height");
rect = new Rect(175 - 50 * sin45, 75 - 50 * sin45, 50 * sin45 * 2, 50 * sin45 * 2);
rect.roundOut();
is(rect2Bounds.left, rect.left, "rect2.getBoundingClientRect().left");
is(rect2Bounds.top, rect.top, "rect2.getBoundingClientRect().top");
is(rect2Bounds.width, rect.width, "rect2.getBoundingClientRect().width");
is(rect2Bounds.height, rect.height, "rect2.getBoundingClientRect().height");
isRounded(rect4Bounds.left, 350 - 100 * sin45 - .5, "rect4.getBoundingClientRect().left");
isRounded(rect4Bounds.top, 150 - 100 * sin45 - .5, "rect4.getBoundingClientRect().top");
isRounded(rect4Bounds.width, (100 * sin45 + .5) * 2, "rect4.getBoundingClientRect().width");
isRounded(rect4Bounds.height, (100 * sin45 + .5) * 2, "rect4.getBoundingClientRect().height");
is(rect3Bounds.left, 50, "rect3.getBoundingClientRect().left");
is(rect3Bounds.top, 160, "rect3.getBoundingClientRect().top");
is(rect3Bounds.width, 100, "rect3.getBoundingClientRect().width");
is(rect3Bounds.height, 100, "rect3.getBoundingClientRect().height");
rect = new Rect(350 - 100 * sin45, 150 - 100 * sin45, 100 * sin45 * 2, 100 * sin45 * 2);
rect.roundOut();
is(rect4Bounds.left, rect.left, "rect4.getBoundingClientRect().left");
is(rect4Bounds.top, rect.top, "rect4.getBoundingClientRect().top");
is(rect4Bounds.width, rect.width, "rect4.getBoundingClientRect().width");
is(rect4Bounds.height, rect.height, "rect4.getBoundingClientRect().height");
var rect1aBounds = doc.getElementById("rect1a").getBoundingClientRect();
var rect2aBounds = doc.getElementById("rect2a").getBoundingClientRect();
var rect3aBounds = doc.getElementById("rect3a").getBoundingClientRect();
var rect4aBounds = doc.getElementById("rect4a").getBoundingClientRect();
isRounded(rect1aBounds.left, 49, "rect1a.getBoundingClientRect().left");
isRounded(rect1aBounds.top, 49, "rect1a.getBoundingClientRect().top");
isRounded(rect1aBounds.width, 52, "rect1a.getBoundingClientRect().width");
isRounded(rect1aBounds.height, 52, "rect1a.getBoundingClientRect().height");
isRounded(rect2aBounds.left, 175 - 52 * sin45 - .5, "rect2a.getBoundingClientRect().left");
isRounded(rect2aBounds.top, 75 - 52 * sin45 - .5, "rect2a.getBoundingClientRect().top");
isRounded(rect2aBounds.width, 52 * sin45 * 2, "rect2a.getBoundingClientRect().width");
isRounded(rect2aBounds.height, 52 * sin45 * 2, "rect2a.getBoundingClientRect().height");
is(rect1aBounds.left, 48, "rect1a.getBoundingClientRect().left");
is(rect1aBounds.top, 48, "rect1a.getBoundingClientRect().top");
is(rect1aBounds.width, 54, "rect1a.getBoundingClientRect().width");
is(rect1aBounds.height, 54, "rect1a.getBoundingClientRect().height");
isRounded(rect3aBounds.left, 48, "rect3a.getBoundingClientRect().left");
isRounded(rect3aBounds.top, 158, "rect3a.getBoundingClientRect().top");
isRounded(rect3aBounds.width, 104, "rect3a.getBoundingClientRect().width");
isRounded(rect3aBounds.height, 104, "rect3a.getBoundingClientRect().height");
rect = new Rect(175 - 54 * sin45, 75 - 54 * sin45, 54 * sin45 * 2, 54 * sin45 * 2);
rect.roundOut();
is(rect2aBounds.left, rect.left, "rect2a.getBoundingClientRect().left");
is(rect2aBounds.top, rect.top, "rect2a.getBoundingClientRect().top");
is(rect2aBounds.width, rect.width, "rect2a.getBoundingClientRect().width");
is(rect2aBounds.height, rect.height, "rect2a.getBoundingClientRect().height");
isRounded(rect4aBounds.left, 350 - 104 * sin45 - .5, "rect4a.getBoundingClientRect().left");
isRounded(rect4aBounds.top, 150 - 104 * sin45 - .5, "rect4a.getBoundingClientRect().top");
isRounded(rect4aBounds.width, (104 * sin45 + .5) * 2, "rect4a.getBoundingClientRect().width");
isRounded(rect4aBounds.height, (104 * sin45 + .5) * 2, "rect4a.getBoundingClientRect().height");
is(rect3aBounds.left, 46, "rect3a.getBoundingClientRect().left");
is(rect3aBounds.top, 156, "rect3a.getBoundingClientRect().top");
is(rect3aBounds.width, 108, "rect3a.getBoundingClientRect().width");
is(rect3aBounds.height, 108, "rect3a.getBoundingClientRect().height");
rect = new Rect(350 - 108 * sin45, 150 - 108 * sin45, 108 * sin45 * 2, 108 * sin45 * 2);
rect.roundOut();
is(rect4aBounds.left, rect.left, "rect4a.getBoundingClientRect().left");
is(rect4aBounds.top, rect.top, "rect4a.getBoundingClientRect().top");
is(rect4aBounds.width, rect.width, "rect4a.getBoundingClientRect().width");
is(rect4aBounds.height, rect.height, "rect4a.getBoundingClientRect().height");
var text1a = doc.getElementById("text1a");
var text1aBounds = text1a.getBoundingClientRect();
var text2aBounds = doc.getElementById("text2a").getBoundingClientRect();
var len = text1a.getComputedTextLength();
isApproximately(text1aBounds.left, 82, "text1a.getBoundingClientRect().left");
is(text1aBounds.width, text1Bounds.width + 4, "text1a.getBoundingClientRect().width");
isRounded(text1aBounds.left, 85 - 1, "text1a.getBoundingClientRect().left");
isRounded(text1aBounds.width, len + 1, "text1a.getBoundingClientRect().width");
isRounded(text2aBounds.left, text1aBounds.left + 100 - 4, "text2a.getBoundingClientRect().left");
isRounded(text2aBounds.width, text1aBounds.width + 9, "text2a.getBoundingClientRect().width");
is(text2aBounds.left, text1aBounds.left + 100 - 3, "text2a.getBoundingClientRect().left");
is(text2aBounds.width, text1aBounds.width + 6, "text2a.getBoundingClientRect().width");
SimpleTest.finish();
}

Просмотреть файл

@ -86,7 +86,9 @@ txLoadedDocumentsHash::~txLoadedDocumentsHash()
txExecutionState::txExecutionState(txStylesheet* aStylesheet,
PRBool aDisableLoads)
: mStylesheet(aStylesheet),
: mOutputHandler(nsnull),
mResultHandler(nsnull),
mStylesheet(aStylesheet),
mNextInstruction(nsnull),
mLocalVariables(nsnull),
mRecursionDepth(0),
@ -199,6 +201,9 @@ txExecutionState::end(nsresult aResult)
if (NS_SUCCEEDED(aResult)) {
popTemplateRule();
}
else if (!mOutputHandler) {
return NS_OK;
}
return mOutputHandler->endDocument(aResult);
}

Просмотреть файл

@ -48,6 +48,7 @@
#include "AccessCheck.h"
#include "xpcprivate.h"
#include "XPCWrapper.h"
#include "nscore.h"
#include "nsDOMClassInfo.h"
@ -516,7 +517,6 @@ static const char kDOMStringBundleURL[] =
#define WINDOW_SCRIPTABLE_FLAGS \
(nsIXPCScriptable::WANT_GETPROPERTY | \
nsIXPCScriptable::WANT_SETPROPERTY | \
nsIXPCScriptable::WANT_PRECREATE | \
nsIXPCScriptable::WANT_FINALIZE | \
nsIXPCScriptable::WANT_EQUALITY | \
@ -5269,39 +5269,6 @@ nsWindowSH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
return NS_OK;
}
NS_IMETHODIMP
nsWindowSH::SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsid id, jsval *vp, PRBool *_retval)
{
if (id == sLocation_id) {
JSAutoRequest ar(cx);
JSString *val = ::JS_ValueToString(cx, *vp);
NS_ENSURE_TRUE(val, NS_ERROR_UNEXPECTED);
nsCOMPtr<nsIDOMWindow> window = do_QueryWrappedNative(wrapper);
NS_ENSURE_TRUE(window, NS_ERROR_UNEXPECTED);
nsCOMPtr<nsIDOMLocation> location;
nsresult rv = window->GetLocation(getter_AddRefs(location));
NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && location, rv);
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
rv = WrapNative(cx, obj, location, &NS_GET_IID(nsIDOMLocation), PR_TRUE,
vp, getter_AddRefs(holder));
NS_ENSURE_SUCCESS(rv, rv);
nsDependentJSString depStr;
NS_ENSURE_TRUE(depStr.init(cx, val), NS_ERROR_UNEXPECTED);
rv = location->SetHref(depStr);
return NS_FAILED(rv) ? rv : NS_SUCCESS_I_DID_SOMETHING;
}
return NS_OK;
}
NS_IMETHODIMP
nsWindowSH::Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, PRBool *_retval)
@ -6392,6 +6359,68 @@ static JSNewResolveOp sOtherResolveFuncs[] = {
mozilla::dom::workers::ResolveWorkerClasses
};
template<class Interface>
static nsresult
LocationSetterGuts(JSContext *cx, JSObject *obj, jsval *vp)
{
// This function duplicates some of the logic in XPC_WN_HelperSetProperty
XPCWrappedNative *wrapper =
XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj);
// The error checks duplicate code in THROW_AND_RETURN_IF_BAD_WRAPPER
NS_ENSURE_TRUE(wrapper, NS_ERROR_XPC_BAD_OP_ON_WN_PROTO);
NS_ENSURE_TRUE(wrapper->IsValid(), NS_ERROR_XPC_HAS_BEEN_SHUTDOWN);
nsCOMPtr<Interface> xpcomObj = do_QueryWrappedNative(wrapper);
NS_ENSURE_TRUE(xpcomObj, NS_ERROR_UNEXPECTED);
nsCOMPtr<nsIDOMLocation> location;
nsresult rv = xpcomObj->GetLocation(getter_AddRefs(location));
NS_ENSURE_SUCCESS(rv, rv);
JSString *val = ::JS_ValueToString(cx, *vp);
NS_ENSURE_TRUE(val, NS_ERROR_UNEXPECTED);
nsDependentJSString depStr;
NS_ENSURE_TRUE(depStr.init(cx, val), NS_ERROR_UNEXPECTED);
rv = location->SetHref(depStr);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
return WrapNative(cx, JS_GetGlobalForScopeChain(cx), location,
&NS_GET_IID(nsIDOMLocation), PR_TRUE, vp,
getter_AddRefs(holder));
}
template<class Interface>
static JSBool
LocationSetter(JSContext *cx, JSObject *obj, jsid id, JSBool strict,
jsval *vp)
{
nsresult rv = LocationSetterGuts<Interface>(cx, obj, vp);
if (NS_FAILED(rv)) {
if (!::JS_IsExceptionPending(cx)) {
nsDOMClassInfo::ThrowJSException(cx, rv);
}
return JS_FALSE;
}
return JS_TRUE;
}
static JSBool
LocationSetterUnwrapper(JSContext *cx, JSObject *obj, jsid id, JSBool strict,
jsval *vp)
{
JSObject *wrapped = XPCWrapper::UnsafeUnwrapSecurityWrapper(obj);
if (wrapped) {
obj = wrapped;
}
return LocationSetter<nsIDOMWindow>(cx, obj, id, strict, vp);
}
NS_IMETHODIMP
nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsid id, PRUint32 flags,
@ -6544,7 +6573,8 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
NS_ENSURE_SUCCESS(rv, rv);
JSBool ok = JS_WrapValue(cx, &v) &&
JS_DefinePropertyById(cx, obj, id, v, nsnull, nsnull,
JS_DefinePropertyById(cx, obj, id, v, nsnull,
LocationSetterUnwrapper,
JSPROP_PERMANENT | JSPROP_ENUMERATE);
if (!ok) {
@ -8177,7 +8207,8 @@ nsDocumentSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSAutoRequest ar(cx);
JSBool ok = ::JS_DefinePropertyById(cx, obj, id, v, nsnull, nsnull,
JSBool ok = ::JS_DefinePropertyById(cx, obj, id, v, nsnull,
LocationSetter<nsIDOMDocument>,
JSPROP_PERMANENT | JSPROP_ENUMERATE);
if (!ok) {
@ -8222,34 +8253,6 @@ NS_IMETHODIMP
nsDocumentSH::SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsid id, jsval *vp, PRBool *_retval)
{
if (id == sLocation_id) {
nsCOMPtr<nsIDOMDocument> doc = do_QueryWrappedNative(wrapper);
NS_ENSURE_TRUE(doc, NS_ERROR_UNEXPECTED);
nsCOMPtr<nsIDOMLocation> location;
nsresult rv = doc->GetLocation(getter_AddRefs(location));
NS_ENSURE_SUCCESS(rv, rv);
if (location) {
JSAutoRequest ar(cx);
JSString *val = ::JS_ValueToString(cx, *vp);
NS_ENSURE_TRUE(val, NS_ERROR_UNEXPECTED);
nsDependentJSString depStr;
NS_ENSURE_TRUE(depStr.init(cx, val), NS_ERROR_UNEXPECTED);
rv = location->SetHref(depStr);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), location,
&NS_GET_IID(nsIDOMLocation), PR_TRUE, vp,
getter_AddRefs(holder));
return NS_FAILED(rv) ? rv : NS_SUCCESS_I_DID_SOMETHING;
}
}
if (id == sDocumentURIObject_id && IsPrivilegedScript()) {
// We don't want privileged script that can read this property to set it,
// but _do_ want to allow everyone else to set a value they can then read.

Просмотреть файл

@ -407,8 +407,6 @@ public:
#endif
NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
NS_IMETHOD SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
NS_IMETHOD Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, PRBool *_retval);
NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,

Просмотреть файл

@ -4408,9 +4408,11 @@ nsGlobalWindow::SetFullScreen(PRBool aFullScreen)
PRBool rootWinFullScreen;
GetFullScreen(&rootWinFullScreen);
// Only chrome can change our fullScreen mode.
if (aFullScreen == rootWinFullScreen ||
!nsContentUtils::IsCallerTrustedForWrite()) {
// Only chrome can change our fullScreen mode, unless the DOM full-screen
// API is enabled.
if ((aFullScreen == rootWinFullScreen ||
!nsContentUtils::IsCallerTrustedForWrite()) &&
!nsContentUtils::IsFullScreenApiEnabled()) {
return NS_OK;
}
@ -4460,6 +4462,14 @@ nsGlobalWindow::SetFullScreen(PRBool aFullScreen)
if (widget)
widget->MakeFullScreen(aFullScreen);
if (!mFullScreen && mDocument) {
// Notify the document that we've left full-screen mode. This is so that
// if we're in full-screen mode and the user exits full-screen mode with
// the browser full-screen mode toggle keyboard-shortcut, we detect that
// and leave DOM API full-screen mode too.
mDocument->MozCancelFullScreen();
}
return NS_OK;
}

Просмотреть файл

@ -542,6 +542,10 @@ public:
}
static nsGlobalWindow* GetInnerWindowWithId(PRUint64 aInnerWindowID) {
if (!sWindowsById) {
return nsnull;
}
nsGlobalWindow* innerWindow = sWindowsById->Get(aInnerWindowID);
return innerWindow && innerWindow->IsInnerWindow() ? innerWindow : nsnull;
}

Просмотреть файл

@ -2259,14 +2259,8 @@ nsJSContext::CreateOuterObject(nsIScriptGlobalObject *aGlobalObject,
mGlobalObjectRef = aGlobalObject;
nsCOMPtr<nsIDOMChromeWindow> chromeWindow(do_QueryInterface(aGlobalObject));
PRUint32 flags = 0;
if (chromeWindow) {
// Flag this window's global object and objects under it as "system",
// for optional automated XPCNativeWrapper construction when chrome JS
// views a content DOM.
flags = nsIXPConnect::FLAG_SYSTEM_GLOBAL_OBJECT;
// Always enable E4X for XUL and other chrome content -- there is no
// need to preserve the <!-- script hiding hack from JS-in-HTML daze
// (introduced in 1995 for graceful script degradation in Netscape 1,

Просмотреть файл

@ -63,7 +63,7 @@ interface nsIDOMCaretPosition;
* http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
*/
[scriptable, uuid(d19897dc-948a-42e7-8ac6-d8a0bd141b85)]
[scriptable, uuid(903493d3-72b6-4416-b930-fbfc17ef1d87)]
interface nsIDOMDocument : nsIDOMNode
{
readonly attribute nsIDOMDocumentType doctype;
@ -371,4 +371,28 @@ interface nsIDOMDocument : nsIDOMNode
in nsIDOMElement aImageElement);
nsIDOMCaretPosition caretPositionFromPoint(in float x, in float y);
/**
* Element which is currently the full-screen element as per the DOM
* full-screen api.
*
* @see <https://wiki.mozilla.org/index.php?title=Gecko:FullScreenAPI>
*/
readonly attribute nsIDOMHTMLElement mozFullScreenElement;
/**
* Causes the document to leave DOM full-screen mode, if it's in
* full-screen mode, as per the DOM full-screen api.
*
* @see <https://wiki.mozilla.org/index.php?title=Gecko:FullScreenAPI>
*/
void mozCancelFullScreen();
/**
* Denotes whether this document is in DOM full-screen mode, as per the DOM
* full-screen api.
*
* @see <https://wiki.mozilla.org/index.php?title=Gecko:FullScreenAPI>
*/
readonly attribute boolean mozFullScreen;
};

Просмотреть файл

@ -52,7 +52,7 @@ interface nsIDOMUserDataHandler;
* http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
*/
[scriptable, uuid(29a95243-c73e-454c-a996-272f6727b03c)]
[scriptable, uuid(af9b19f7-7c88-4d16-9a3a-97390f824c58)]
interface nsIDOMNode : nsISupports
{
const unsigned short ELEMENT_NODE = 1;
@ -146,4 +146,6 @@ interface nsIDOMNode : nsISupports
in nsIDOMUserDataHandler handler);
// Introduced in DOM Level 3:
nsIVariant getUserData(in DOMString key);
boolean contains(in nsIDOMNode aOther);
};

Просмотреть файл

@ -80,6 +80,7 @@ interface nsIInlineEventHandlers : nsISupports
[implicit_jscontext] attribute jsval onmouseup;
// Not supported yet
// [implicit_jscontext] attribute jsval onmousewheel;
[implicit_jscontext] attribute jsval onmozfullscreenchange;
[implicit_jscontext] attribute jsval onpause;
[implicit_jscontext] attribute jsval onplay;
[implicit_jscontext] attribute jsval onplaying;

Просмотреть файл

@ -50,7 +50,7 @@
* http://www.whatwg.org/specs/web-apps/current-work/
*/
[scriptable, uuid(33dfbcdc-4edf-4e6a-acf4-c6b5bbb61caf)]
[scriptable, uuid(31969911-36fb-42ee-9a00-018c3ff78cfb)]
interface nsIDOMHTMLIFrameElement : nsIDOMHTMLElement
{
attribute DOMString align;
@ -65,4 +65,9 @@ interface nsIDOMHTMLIFrameElement : nsIDOMHTMLElement
attribute DOMString width;
// Introduced in DOM Level 2:
readonly attribute nsIDOMDocument contentDocument;
// iframe elements require the mozAllowFullScreen attribute to be present
// if they're to allow content in the sub document to go into DOM full-screen
// mode. See https://wiki.mozilla.org/index.php?title=Gecko:FullScreenAPI
attribute boolean mozAllowFullScreen;
};

Просмотреть файл

@ -41,7 +41,7 @@
interface nsIDOMDOMStringMap;
interface nsIDOMHTMLMenuElement;
[scriptable, uuid(0c3b4b63-30b2-4c93-906d-f983ee9af584)]
[scriptable, uuid(38305156-007a-4b68-8592-b1c3625c6f6c)]
interface nsIDOMNSHTMLElement : nsISupports
{
readonly attribute long offsetTop;
@ -76,4 +76,12 @@ interface nsIDOMNSHTMLElement : nsISupports
attribute boolean spellcheck;
readonly attribute nsIDOMDOMStringMap dataset;
/**
* Requests that this element be made the full-screen element, as per the DOM
* full-screen api.
*
* @see <https://wiki.mozilla.org/index.php?title=Gecko:FullScreenAPI>
*/
void mozRequestFullScreen();
};

Просмотреть файл

@ -55,7 +55,7 @@
typedef unsigned int uint32_t;
typedef long long int64_t;
typedef unsigned long long uint64_t;
#elif defined(_AIX) || defined(__sun) || defined(__osf__) || defined(IRIX) || defined(HPUX)
#elif defined(_AIX) || defined(__sun) || defined(__osf__) || defined(HPUX)
/*
* AIX and SunOS ship a inttypes.h header that defines [u]int32_t,
* but not bool for C.

Просмотреть файл

@ -236,7 +236,9 @@ nsDeviceMotion::DeviceMotionChanged(PRUint32 type, double x, double y, double z)
// check to see if this window is in the background. if
// it is, don't send any device motion to it.
nsCOMPtr<nsPIDOMWindow> pwindow = do_QueryInterface(mWindowListeners[i]);
if (!pwindow || pwindow->GetOuterWindow()->IsBackground())
if (!pwindow ||
!pwindow->GetOuterWindow() ||
pwindow->GetOuterWindow()->IsBackground())
continue;
nsCOMPtr<nsIDOMDocument> domdoc;

Просмотреть файл

@ -69,6 +69,7 @@ _TEST_FILES = \
test_cyclecollector.xul \
test_resize_move_windows.xul \
test_popup_blocker_chrome.xul \
test_moving_xhr.xul \
$(NULL)
ifeq (WINNT,$(OS_ARCH))

Просмотреть файл

@ -0,0 +1,41 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=654370
-->
<window title="Mozilla Bug 654370"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<!-- test results are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml">
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=654370"
target="_blank">Mozilla Bug 654370</a>
</body>
<!-- test code goes here -->
<script type="application/javascript"><![CDATA[
SimpleTest.waitForExplicitFinish();
var firstWindow, secondWindow;
function iframe_loaded() {
if (!firstWindow || !secondWindow)
return;
var xhr = firstWindow.wrappedJSObject.createXHR();
ok(!("expando" in xhr), "shouldn't be able to see expandos on the XHR");
is(xhr.readyState, XMLHttpRequest.UNSENT, "can access readyState in chrome");
secondWindow.wrappedJSObject.tryToUseXHR(xhr, ok);
secondWindow.wrappedJSObject.tryToUseXHR(new XMLHttpRequest(), ok);
SimpleTest.finish();
}
]]></script>
<iframe id="one" src="http://mochi.test:8888/tests/dom/tests/mochitest/general/file_moving_xhr.html"
onload="firstWindow = this.contentWindow; iframe_loaded()" />
<iframe id="two" src="http://example.org/tests/dom/tests/mochitest/general/file_moving_xhr.html"
onload="secondWindow = this.contentWindow; iframe_loaded()" />
</window>

Просмотреть файл

@ -55,6 +55,7 @@ _TEST_FILES = \
test_location.html \
test_innerWidthHeight_script.html \
innerWidthHeight_script.html \
test_location_setters.html \
$(NULL)
libs:: $(_TEST_FILES)

Просмотреть файл

@ -0,0 +1,78 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=639720
-->
<head>
<title>Test for Bug 639720</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=639720">Mozilla Bug 639720</a>
<p id="display">
<iframe id="f"></iframe>
</p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 639720 **/
SimpleTest.waitForExplicitFinish();
var tests = [
{ url: "data:text/plain,1" },
{ url: "data:text/plain,2",
useDocument: true },
{ prepURL: "http://www.example.com",
url: "data:text/plain,3" }
];
var currentTest = 0;
function checkTest() {
is($("f").contentWindow.location.href, tests[currentTest].url,
"href of content window's location should match url of current test");
++currentTest;
runNextTest();
}
function runCurrentTest() {
var test = tests[currentTest];
$("f").onload = checkTest;
if (test.useDocument) {
$("f").contentDocument.location = test.url;
} else {
$("f").contentWindow.location = test.url;
}
is(typeof($("f").contentWindow.location), "object",
"Location should not have become string");
}
function prepComplete() {
runCurrentTest();
}
function runNextTest() {
if (currentTest == tests.length) {
SimpleTest.finish();
return;
}
var test = tests[currentTest];
if ("prepURL" in test) {
$("f").onload = prepComplete;
$("f").src = test.prepURL;
return;
}
runCurrentTest();
}
addLoadEvent(runNextTest);
</script>
</pre>
</body>
</html>

Просмотреть файл

@ -68,6 +68,7 @@ _TEST_FILES = \
test_framedhistoryframes.html \
test_windowedhistoryframes.html \
test_focusrings.xul \
file_moving_xhr.html \
$(NULL)
_CHROME_FILES = \

Просмотреть файл

@ -0,0 +1,26 @@
<html>
<head>
<script>
function createXHR() {
return new XMLHttpRequest();
}
function tryToUseXHR(xhr, ok) {
function expectException(op, reason) {
try {
var result = op();
ok(false, "should have thrown an exception, got: " + result);
} catch (e) {
ok(/Permission denied/.test(e.toString()), reason);
}
}
expectException(function() { xhr.open(); }, "should not have access to any functions");
expectException(function() { xhr.foo = "foo"; }, "should not be able to add expandos");
expectException(function() { xhr.withCredentials = true; }, "should not be able to set attributes");
}
</script>
</head>
<body>
</body>
</html>

Просмотреть файл

@ -729,8 +729,9 @@ nsEditorSpellCheck::UpdateCurrentDictionary()
}
// otherwise, get language from preferences
nsAutoString preferedDict(Preferences::GetLocalizedString("spellchecker.dictionary"));
if (dictName.IsEmpty()) {
dictName.Assign(Preferences::GetLocalizedString("spellchecker.dictionary"));
dictName.Assign(preferedDict);
}
if (dictName.IsEmpty())
@ -755,27 +756,50 @@ nsEditorSpellCheck::UpdateCurrentDictionary()
rv = SetCurrentDictionary(dictName);
if (NS_FAILED(rv)) {
// required dictionary was not available. Try to get a dictionary
// matching at least language part of dictName: If required dictionary is
// "aa-bb", we try "aa", then we try any available dictionary aa-XX
// matching at least language part of dictName:
nsAutoString langCode;
PRInt32 dashIdx = dictName.FindChar('-');
if (dashIdx != -1) {
langCode.Assign(Substring(dictName, 0, dashIdx));
// try to use langCode
rv = SetCurrentDictionary(langCode);
} else {
langCode.Assign(dictName);
}
nsDefaultStringComparator comparator;
// try dictionary.spellchecker preference if it starts with langCode (and
// if we haven't tried it already)
if (!preferedDict.IsEmpty() && !dictName.Equals(preferedDict) &&
nsStyleUtil::DashMatchCompare(preferedDict, langCode, comparator)) {
rv = SetCurrentDictionary(preferedDict);
}
// Otherwise, try langCode (if we haven't tried it already)
if (NS_FAILED(rv)) {
if (!dictName.Equals(langCode) && !preferedDict.Equals(langCode)) {
rv = SetCurrentDictionary(langCode);
}
}
// Otherwise, try any available dictionary aa-XX
if (NS_FAILED(rv)) {
// loop over avaible dictionaries; if we find one with required
// language, use it
nsTArray<nsString> dictList;
rv = mSpellChecker->GetDictionaryList(&dictList);
NS_ENSURE_SUCCESS(rv, rv);
nsDefaultStringComparator comparator;
PRInt32 i, count = dictList.Length();
for (i = 0; i < count; i++) {
nsAutoString dictStr(dictList.ElementAt(i));
if (dictStr.Equals(dictName) ||
dictStr.Equals(preferedDict) ||
dictStr.Equals(langCode)) {
// We have already tried it
continue;
}
if (nsStyleUtil::DashMatchCompare(dictStr, langCode, comparator) &&
NS_SUCCEEDED(SetCurrentDictionary(dictStr))) {
break;

Просмотреть файл

@ -65,6 +65,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=434998
threw = true;
}
ok(!threw, "The execCommand API should work on <xul:editor>");
progress.removeProgressListener(progressListener, Components.interfaces.nsIWebProgress.NOTIFY_ALL);
SimpleTest.finish();
}
}

Просмотреть файл

@ -4047,11 +4047,26 @@ nsHTMLEditRules::WillOutdent(nsISelection *aSelection, PRBool *aCancel, PRBool *
NS_ENSURE_SUCCESS(res, res);
continue;
}
// is it a block with a 'margin' property?
if (useCSS && IsBlockNode(curNode))
{
nsIAtom* marginProperty = MarginPropertyAtomForIndent(mHTMLEditor->mHTMLCSSUtils, curNode);
nsAutoString value;
mHTMLEditor->mHTMLCSSUtils->GetSpecifiedProperty(curNode, marginProperty, value);
float f;
nsCOMPtr<nsIAtom> unit;
mHTMLEditor->mHTMLCSSUtils->ParseLength(value, &f, getter_AddRefs(unit));
if (f > 0)
{
RelativeChangeIndentationOfElementNode(curNode, -1);
continue;
}
}
// is it a list item?
if (nsHTMLEditUtils::IsListItem(curNode))
{
// if it is a list item, that means we are not outdenting whole list.
// So we need to finish up dealng with any curBlockQuote, and then
// So we need to finish up dealing with any curBlockQuote, and then
// pop this list item.
if (curBlockQuote)
{
@ -4123,7 +4138,7 @@ nsHTMLEditRules::WillOutdent(nsISelection *aSelection, PRBool *aCancel, PRBool *
float f;
nsCOMPtr<nsIAtom> unit;
mHTMLEditor->mHTMLCSSUtils->ParseLength(value, &f, getter_AddRefs(unit));
if (f > 0)
if (f > 0 && !(nsHTMLEditUtils::IsList(curParent) && nsHTMLEditUtils::IsList(curNode)))
{
curBlockQuote = n;
firstBQChild = curNode;

Просмотреть файл

@ -40,7 +40,7 @@ addLoadEvent(function() {
var twoindent = '<p></p><ul style="margin-left: 80px;"><li>Item 1</li><li>Item 2</li></ul><p></p>';
is(editor.innerHTML, twoindent, "a twice indented bulleted list");
document.execCommand("outdent", false, false);
todo_is(editor.innerHTML, oneindent, "outdenting a twice indented bulleted list");
is(editor.innerHTML, oneindent, "outdenting a twice indented bulleted list");
// done
SimpleTest.finish();

Просмотреть файл

@ -38,7 +38,7 @@ addLoadEvent(function() {
var expected = '<ul style="margin-left: 40px;"><li>Item 1</li><ul><li>Item 2</li><li>Item 3</li></ul><li>Item 4</li></ul>';
is(editor.innerHTML, expected, "indenting part of an already indented bulleted list");
document.execCommand("outdent", false, false);
todo_is(editor.innerHTML, original, "outdenting the partially indented part of an already indented bulleted list");
is(editor.innerHTML, original, "outdenting the partially indented part of an already indented bulleted list");
// done
SimpleTest.finish();

Просмотреть файл

@ -467,9 +467,15 @@ abstract public class GeckoApp
componentsDir.mkdir();
componentsDir.setLastModified(applicationPackage.lastModified());
surfaceView.mSplashStatusMsg =
getResources().getString(R.string.splash_firstrun);
surfaceView.drawSplashScreen();
GeckoAppShell.killAnyZombies();
ZipFile zip = new ZipFile(applicationPackage);
byte[] buf = new byte[8192];
byte[] buf = new byte[32768];
try {
if (unpackFile(zip, buf, null, "removed-files"))
removeFiles();
@ -520,8 +526,6 @@ abstract public class GeckoApp
}
boolean haveKilledZombies = false;
private boolean unpackFile(ZipFile zip, byte[] buf, ZipEntry fileEntry,
String name)
throws IOException, FileNotFoundException
@ -533,22 +537,12 @@ abstract public class GeckoApp
zip.getName());
File outFile = new File(sGREDir, name);
if (outFile.exists() &&
outFile.lastModified() == fileEntry.getTime() &&
if (outFile.lastModified() == fileEntry.getTime() &&
outFile.length() == fileEntry.getSize())
return false;
surfaceView.mSplashStatusMsg =
getResources().getString(R.string.splash_firstrun);
surfaceView.drawSplashScreen();
if (!haveKilledZombies) {
haveKilledZombies = true;
GeckoAppShell.killAnyZombies();
}
File dir = outFile.getParentFile();
if (!outFile.exists())
if (!dir.exists())
dir.mkdirs();
InputStream fileStream;

Просмотреть файл

@ -597,9 +597,9 @@ class GeckoSurfaceView
switch (event.getAction()) {
case KeyEvent.ACTION_DOWN:
return onKeyDown(keyCode, event);
return processKeyDown(keyCode, event, true);
case KeyEvent.ACTION_UP:
return onKeyUp(keyCode, event);
return processKeyUp(keyCode, event, true);
case KeyEvent.ACTION_MULTIPLE:
return onKeyMultiple(keyCode, event.getRepeatCount(), event);
}
@ -608,6 +608,10 @@ class GeckoSurfaceView
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
return processKeyDown(keyCode, event, false);
}
private boolean processKeyDown(int keyCode, KeyEvent event, boolean isPreIme) {
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
if (event.getRepeatCount() == 0) {
@ -644,6 +648,11 @@ class GeckoSurfaceView
default:
break;
}
if (isPreIme && mIMEState != IME_STATE_DISABLED)
// Let active IME process pre-IME key events
return false;
// KeyListener returns true if it handled the event for us.
if (mIMEState == IME_STATE_DISABLED ||
keyCode == KeyEvent.KEYCODE_ENTER ||
@ -656,6 +665,10 @@ class GeckoSurfaceView
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
return processKeyUp(keyCode, event, false);
}
private boolean processKeyUp(int keyCode, KeyEvent event, boolean isPreIme) {
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
if (!event.isTracking() || event.isCanceled())
@ -664,6 +677,11 @@ class GeckoSurfaceView
default:
break;
}
if (isPreIme && mIMEState != IME_STATE_DISABLED)
// Let active IME process pre-IME key events
return false;
if (mIMEState == IME_STATE_DISABLED ||
keyCode == KeyEvent.KEYCODE_ENTER ||
keyCode == KeyEvent.KEYCODE_DEL ||

Просмотреть файл

@ -110,13 +110,14 @@ SFX B e able [^aeiou]e
SFX L Y 1
SFX L 0 ment .
REP 88
REP 89
REP a ei
REP ei a
REP a ey
REP ey a
REP ai ie
REP ie ai
REP alot a_lot
REP are air
REP are ear
REP are eir

Просмотреть файл

@ -697,10 +697,11 @@ gfxFT2Font::InitTextRun(gfxContext *aContext,
}
if (!ok) {
aTextRun->AdjustAdvancesForSyntheticBold(aRunStart, aRunLength);
AddRange(aTextRun, aString, aRunStart, aRunLength);
}
aTextRun->AdjustAdvancesForSyntheticBold(aContext, aRunStart, aRunLength);
return PR_TRUE;
}
@ -809,9 +810,7 @@ gfxFT2Font::gfxFT2Font(cairo_scaled_font_t *aCairoFont,
: gfxFT2FontBase(aCairoFont, aFontEntry, aFontStyle)
{
NS_ASSERTION(mFontEntry, "Unable to find font entry for font. Something is whack.");
if (aNeedsBold) {
mSyntheticBoldOffset = 1.0;
}
mApplySyntheticBold = aNeedsBold;
mCharGlyphCache.Init(64);
}

Просмотреть файл

@ -581,12 +581,28 @@ StyleDistance(gfxFontEntry *aFontEntry,
// and the given fontEntry,
// considering italicness and font-stretch but not weight.
// TODO (refine CSS spec...): discuss priority of italic vs stretch;
// whether penalty for stretch mismatch should depend on actual difference in values;
// whether a sign mismatch in stretch should increase the effective distance
return (aFontEntry->IsItalic() != anItalic ? 1 : 0) +
(aFontEntry->mStretch != aStretch ? 10 : 0);
PRInt32 distance = 0;
if (aStretch != aFontEntry->mStretch) {
// stretch values are in the range -4 .. +4
// if aStretch is positive, we prefer more-positive values;
// if zero or negative, prefer more-negative
if (aStretch > 0) {
distance = (aFontEntry->mStretch - aStretch) * 2;
} else {
distance = (aStretch - aFontEntry->mStretch) * 2;
}
// if the computed "distance" here is negative, it means that
// aFontEntry lies in the "non-preferred" direction from aStretch,
// so we treat that as larger than any preferred-direction distance
// (max possible is 8) by adding an extra 10 to the absolute value
if (distance < 0) {
distance = -distance + 10;
}
}
if (aFontEntry->IsItalic() != anItalic) {
distance += 1;
}
return PRUint32(distance);
}
PRBool
@ -609,9 +625,11 @@ gfxFontFamily::FindWeightsForStyle(gfxFontEntry* aFontsForWeights[],
aFontsForWeights[wt] = fe;
++foundWeights;
} else {
PRUint32 prevDistance = StyleDistance(aFontsForWeights[wt], anItalic, aStretch);
PRUint32 prevDistance =
StyleDistance(aFontsForWeights[wt], anItalic, aStretch);
if (prevDistance >= distance) {
// replacing a weight we already found, so don't increment foundWeights
// replacing a weight we already found,
// so don't increment foundWeights
aFontsForWeights[wt] = fe;
}
}
@ -1035,10 +1053,10 @@ gfxFont::RunMetrics::CombineWith(const RunMetrics& aOther, PRBool aOtherIsOnLeft
gfxFont::gfxFont(gfxFontEntry *aFontEntry, const gfxFontStyle *aFontStyle,
AntialiasOption anAAOption) :
mFontEntry(aFontEntry), mIsValid(PR_TRUE),
mApplySyntheticBold(PR_FALSE),
mStyle(*aFontStyle),
mAdjustedSize(0.0),
mFUnitsConvFactor(0.0f),
mSyntheticBoldOffset(0),
mAntialiasOption(anAAOption),
mPlatformShaper(nsnull),
mHarfBuzzShaper(nsnull)
@ -1115,6 +1133,33 @@ struct GlyphBuffer {
#undef GLYPH_BUFFER_SIZE
};
// Bug 674909. When synthetic bolding text by drawing twice, need to
// render using a pixel offset in device pixels, otherwise text
// doesn't appear bolded, it appears as if a bad text shadow exists
// when a non-identity transform exists. Use an offset factor so that
// the second draw occurs at a constant offset in device pixels.
static double
CalcXScale(gfxContext *aContext)
{
// determine magnitude of a 1px x offset in device space
gfxSize t = aContext->UserToDevice(gfxSize(1.0, 0.0));
if (t.width == 1.0 && t.height == 0.0) {
// short-circuit the most common case to avoid sqrt() and division
return 1.0;
}
double m = sqrt(t.width * t.width + t.height * t.height);
NS_ASSERTION(m != 0.0, "degenerate transform while synthetic bolding");
if (m == 0.0) {
return 0.0; // effectively disables offset
}
// scale factor so that offsets are 1px in device pixels
return 1.0 / m;
}
void
gfxFont::Draw(gfxTextRun *aTextRun, PRUint32 aStart, PRUint32 aEnd,
gfxContext *aContext, PRBool aDrawToPath, gfxPoint *aPt,
@ -1128,9 +1173,18 @@ gfxFont::Draw(gfxTextRun *aTextRun, PRUint32 aStart, PRUint32 aEnd,
const double devUnitsPerAppUnit = 1.0/double(appUnitsPerDevUnit);
PRBool isRTL = aTextRun->IsRightToLeft();
double direction = aTextRun->GetDirection();
// double-strike in direction of run
double synBoldDevUnitOffsetAppUnits =
direction * (double) mSyntheticBoldOffset * appUnitsPerDevUnit;
// synthetic-bold strikes are each offset one device pixel in run direction
// (these values are only needed if IsSyntheticBold() is true)
double synBoldOnePixelOffset;
PRInt32 strikes;
if (IsSyntheticBold()) {
double xscale = CalcXScale(aContext);
synBoldOnePixelOffset = direction * xscale;
// use as many strikes as needed for the the increased advance
strikes = NS_lroundf(GetSyntheticBoldOffset() / xscale);
}
PRUint32 i;
// Current position in appunits
double x = aPt->x;
@ -1169,15 +1223,21 @@ gfxFont::Draw(gfxTextRun *aTextRun, PRUint32 aStart, PRUint32 aEnd,
glyph->x = ToDeviceUnits(glyphX, devUnitsPerAppUnit);
glyph->y = ToDeviceUnits(y, devUnitsPerAppUnit);
// synthetic bolding by drawing with a one-pixel offset
if (mSyntheticBoldOffset) {
cairo_glyph_t *doubleglyph;
doubleglyph = glyphs.AppendGlyph();
doubleglyph->index = glyph->index;
doubleglyph->x =
ToDeviceUnits(glyphX + synBoldDevUnitOffsetAppUnits,
devUnitsPerAppUnit);
doubleglyph->y = glyph->y;
// synthetic bolding by multi-striking with 1-pixel offsets
// at least once, more if there's room (large font sizes)
if (IsSyntheticBold()) {
double strikeOffset = synBoldOnePixelOffset;
PRInt32 strikeCount = strikes;
do {
cairo_glyph_t *doubleglyph;
doubleglyph = glyphs.AppendGlyph();
doubleglyph->index = glyph->index;
doubleglyph->x =
ToDeviceUnits(glyphX + strikeOffset * appUnitsPerDevUnit,
devUnitsPerAppUnit);
doubleglyph->y = glyph->y;
strikeOffset += synBoldOnePixelOffset;
} while (--strikeCount > 0);
}
glyphs.Flush(cr, aDrawToPath, isRTL);
@ -1216,15 +1276,20 @@ gfxFont::Draw(gfxTextRun *aTextRun, PRUint32 aStart, PRUint32 aEnd,
glyph->x = ToDeviceUnits(glyphX, devUnitsPerAppUnit);
glyph->y = ToDeviceUnits(y + details->mYOffset, devUnitsPerAppUnit);
// synthetic bolding by drawing with a one-pixel offset
if (mSyntheticBoldOffset) {
cairo_glyph_t *doubleglyph;
doubleglyph = glyphs.AppendGlyph();
doubleglyph->index = glyph->index;
doubleglyph->x =
ToDeviceUnits(glyphX + synBoldDevUnitOffsetAppUnits,
devUnitsPerAppUnit);
doubleglyph->y = glyph->y;
if (IsSyntheticBold()) {
double strikeOffset = synBoldOnePixelOffset;
PRInt32 strikeCount = strikes;
do {
cairo_glyph_t *doubleglyph;
doubleglyph = glyphs.AppendGlyph();
doubleglyph->index = glyph->index;
doubleglyph->x =
ToDeviceUnits(glyphX + strikeOffset *
appUnitsPerDevUnit,
devUnitsPerAppUnit);
doubleglyph->y = glyph->y;
strikeOffset += synBoldOnePixelOffset;
} while (--strikeCount > 0);
}
glyphs.Flush(cr, aDrawToPath, isRTL);
@ -3492,7 +3557,9 @@ struct BufferAlphaColor {
};
void
gfxTextRun::AdjustAdvancesForSyntheticBold(PRUint32 aStart, PRUint32 aLength)
gfxTextRun::AdjustAdvancesForSyntheticBold(gfxContext *aContext,
PRUint32 aStart,
PRUint32 aLength)
{
const PRUint32 appUnitsPerDevUnit = GetAppUnitsPerDevUnit();
PRBool isRTL = IsRightToLeft();
@ -3501,7 +3568,9 @@ gfxTextRun::AdjustAdvancesForSyntheticBold(PRUint32 aStart, PRUint32 aLength)
while (iter.NextRun()) {
gfxFont *font = iter.GetGlyphRun()->mFont;
if (font->IsSyntheticBold()) {
PRUint32 synAppUnitOffset = font->GetSyntheticBoldOffset() * appUnitsPerDevUnit;
PRUint32 synAppUnitOffset =
font->GetSyntheticBoldOffset() *
appUnitsPerDevUnit * CalcXScale(aContext);
PRUint32 start = iter.GetStringStart();
PRUint32 end = iter.GetStringEnd();
PRUint32 i;

Просмотреть файл

@ -1193,8 +1193,12 @@ public:
// This is called by the default Draw() implementation above.
virtual PRBool SetupCairoFont(gfxContext *aContext) = 0;
PRBool IsSyntheticBold() { return mSyntheticBoldOffset != 0; }
PRUint32 GetSyntheticBoldOffset() { return mSyntheticBoldOffset; }
PRBool IsSyntheticBold() { return mApplySyntheticBold; }
// Amount by which synthetic bold "fattens" the glyphs: 1/16 of the em-size
gfxFloat GetSyntheticBoldOffset() {
return GetAdjustedSize() * (1.0 / 16.0);
}
gfxFontEntry *GetFontEntry() { return mFontEntry.get(); }
PRBool HasCharacter(PRUint32 ch) {
@ -1224,6 +1228,11 @@ protected:
nsRefPtr<gfxFontEntry> mFontEntry;
PRPackedBool mIsValid;
// use synthetic bolding for environments where this is not supported
// by the platform
PRPackedBool mApplySyntheticBold;
nsExpirationState mExpirationState;
gfxFontStyle mStyle;
nsAutoTArray<gfxGlyphExtents*,1> mGlyphExtentsArray;
@ -1232,9 +1241,6 @@ protected:
float mFUnitsConvFactor; // conversion factor from font units to dev units
// synthetic bolding for environments where this is not supported by the platform
PRUint32 mSyntheticBoldOffset; // number of devunit pixels to offset double-strike, 0 ==> no bolding
// the AA setting requested for this font - may affect glyph bounds
AntialiasOption mAntialiasOption;
@ -2043,7 +2049,9 @@ public:
#endif
// post-process glyph advances to deal with synthetic bolding
void AdjustAdvancesForSyntheticBold(PRUint32 aStart, PRUint32 aLength);
void AdjustAdvancesForSyntheticBold(gfxContext *aContext,
PRUint32 aStart,
PRUint32 aLength);
protected:
/**

Просмотреть файл

@ -177,6 +177,66 @@ gfxFontconfigUtils::FcWeightForBaseWeight(PRInt8 aBaseWeight)
return aBaseWeight < 2 ? FC_WEIGHT_THIN : FC_WEIGHT_EXTRABLACK;
}
/* static */ PRInt16
gfxFontconfigUtils::GetThebesStretch(FcPattern *aPattern)
{
int width;
if (FcPatternGetInteger(aPattern, FC_WIDTH, 0, &width) != FcResultMatch) {
return NS_FONT_STRETCH_NORMAL;
}
if (width <= (FC_WIDTH_ULTRACONDENSED + FC_WIDTH_EXTRACONDENSED) / 2) {
return NS_FONT_STRETCH_ULTRA_CONDENSED;
}
if (width <= (FC_WIDTH_EXTRACONDENSED + FC_WIDTH_CONDENSED) / 2) {
return NS_FONT_STRETCH_EXTRA_CONDENSED;
}
if (width <= (FC_WIDTH_CONDENSED + FC_WIDTH_SEMICONDENSED) / 2) {
return NS_FONT_STRETCH_CONDENSED;
}
if (width <= (FC_WIDTH_SEMICONDENSED + FC_WIDTH_NORMAL) / 2) {
return NS_FONT_STRETCH_SEMI_CONDENSED;
}
if (width <= (FC_WIDTH_NORMAL + FC_WIDTH_SEMIEXPANDED) / 2) {
return NS_FONT_STRETCH_NORMAL;
}
if (width <= (FC_WIDTH_SEMIEXPANDED + FC_WIDTH_EXPANDED) / 2) {
return NS_FONT_STRETCH_SEMI_EXPANDED;
}
if (width <= (FC_WIDTH_EXPANDED + FC_WIDTH_EXTRAEXPANDED) / 2) {
return NS_FONT_STRETCH_EXPANDED;
}
if (width <= (FC_WIDTH_EXTRAEXPANDED + FC_WIDTH_ULTRAEXPANDED) / 2) {
return NS_FONT_STRETCH_EXTRA_EXPANDED;
}
return NS_FONT_STRETCH_ULTRA_EXPANDED;
}
/* static */ int
gfxFontconfigUtils::FcWidthForThebesStretch(PRInt16 aStretch)
{
switch (aStretch) {
default: // this will catch "normal" (0) as well as out-of-range values
return FC_WIDTH_NORMAL;
case NS_FONT_STRETCH_ULTRA_CONDENSED:
return FC_WIDTH_ULTRACONDENSED;
case NS_FONT_STRETCH_EXTRA_CONDENSED:
return FC_WIDTH_EXTRACONDENSED;
case NS_FONT_STRETCH_CONDENSED:
return FC_WIDTH_CONDENSED;
case NS_FONT_STRETCH_SEMI_CONDENSED:
return FC_WIDTH_SEMICONDENSED;
case NS_FONT_STRETCH_SEMI_EXPANDED:
return FC_WIDTH_SEMIEXPANDED;
case NS_FONT_STRETCH_EXPANDED:
return FC_WIDTH_EXPANDED;
case NS_FONT_STRETCH_EXTRA_EXPANDED:
return FC_WIDTH_EXTRAEXPANDED;
case NS_FONT_STRETCH_ULTRA_EXPANDED:
return FC_WIDTH_ULTRAEXPANDED;
}
}
// This makes a guess at an FC_WEIGHT corresponding to a base weight and
// offset (without any knowledge of which weights are available).
@ -244,6 +304,7 @@ gfxFontconfigUtils::NewPattern(const nsTArray<nsString>& aFamilies,
FcPatternAddDouble(pattern, FC_PIXEL_SIZE, aFontStyle.size);
FcPatternAddInteger(pattern, FC_SLANT, GetFcSlant(aFontStyle));
FcPatternAddInteger(pattern, FC_WEIGHT, GuessFcWeight(aFontStyle));
FcPatternAddInteger(pattern, FC_WIDTH, FcWidthForThebesStretch(aFontStyle.stretch));
if (aLang) {
AddString(pattern, FC_LANG, aLang);

Просмотреть файл

@ -149,12 +149,15 @@ public:
static PRUint8 FcSlantToThebesStyle(int aFcSlant);
static PRUint8 GetThebesStyle(FcPattern *aPattern); // slant
static PRUint16 GetThebesWeight(FcPattern *aPattern);
static PRInt16 GetThebesStretch(FcPattern *aPattern);
static int GetFcSlant(const gfxFontStyle& aFontStyle);
// Returns a precise FC_WEIGHT from |aBaseWeight|,
// which is a CSS absolute weight / 100.
static int FcWeightForBaseWeight(PRInt8 aBaseWeight);
static int FcWidthForThebesStretch(PRInt16 aStretch);
static PRBool GetFullnameFromFamilyAndStyle(FcPattern *aFont,
nsACString *aFullname);

Просмотреть файл

@ -213,17 +213,20 @@ FontTypeToOutPrecision(PRUint8 fontType)
*
*/
GDIFontEntry::GDIFontEntry(const nsAString& aFaceName, gfxWindowsFontType aFontType,
PRBool aItalic, PRUint16 aWeight, gfxUserFontData *aUserFontData) :
gfxFontEntry(aFaceName),
mWindowsFamily(0), mWindowsPitch(0),
mFontType(aFontType),
mForceGDI(PR_FALSE), mUnknownCMAP(PR_FALSE),
mCharset(), mUnicodeRanges()
GDIFontEntry::GDIFontEntry(const nsAString& aFaceName,
gfxWindowsFontType aFontType,
PRBool aItalic, PRUint16 aWeight, PRInt16 aStretch,
gfxUserFontData *aUserFontData)
: gfxFontEntry(aFaceName),
mWindowsFamily(0), mWindowsPitch(0),
mFontType(aFontType),
mForceGDI(PR_FALSE), mUnknownCMAP(PR_FALSE),
mCharset(), mUnicodeRanges()
{
mUserFontData = aUserFontData;
mItalic = aItalic;
mWeight = aWeight;
mStretch = aStretch;
if (IsType1())
mForceGDI = PR_TRUE;
mIsUserFont = aUserFontData != nsnull;
@ -318,8 +321,8 @@ GDIFontEntry::GetFontTable(PRUint32 aTableTag,
void
GDIFontEntry::FillLogFont(LOGFONTW *aLogFont, PRBool aItalic,
PRUint16 aWeight, gfxFloat aSize,
PRBool aUseCleartype)
PRUint16 aWeight, gfxFloat aSize,
PRBool aUseCleartype)
{
memcpy(aLogFont, &mLogFont, sizeof(LOGFONTW));
@ -414,7 +417,7 @@ GDIFontEntry::TestCharacterMap(PRUint32 aCh)
void
GDIFontEntry::InitLogFont(const nsAString& aName,
gfxWindowsFontType aFontType)
gfxWindowsFontType aFontType)
{
#define CLIP_TURNOFF_FONTASSOCIATION 0x40
@ -444,14 +447,15 @@ GDIFontEntry::InitLogFont(const nsAString& aName,
}
GDIFontEntry*
GDIFontEntry::CreateFontEntry(const nsAString& aName, gfxWindowsFontType aFontType,
PRBool aItalic, PRUint16 aWeight,
gfxUserFontData* aUserFontData)
GDIFontEntry::CreateFontEntry(const nsAString& aName,
gfxWindowsFontType aFontType, PRBool aItalic,
PRUint16 aWeight, PRInt16 aStretch,
gfxUserFontData* aUserFontData)
{
// jtdfix - need to set charset, unicode ranges, pitch/family
GDIFontEntry *fe = new GDIFontEntry(aName, aFontType, aItalic, aWeight,
aUserFontData);
GDIFontEntry *fe = new GDIFontEntry(aName, aFontType, aItalic,
aWeight, aStretch, aUserFontData);
return fe;
}
@ -500,8 +504,10 @@ GDIFontFamily::FamilyAddStylesProc(const ENUMLOGFONTEXW *lpelfe,
}
}
fe = GDIFontEntry::CreateFontEntry(nsDependentString(lpelfe->elfFullName), feType, (logFont.lfItalic == 0xFF),
(PRUint16) (logFont.lfWeight), nsnull);
fe = GDIFontEntry::CreateFontEntry(nsDependentString(lpelfe->elfFullName),
feType, (logFont.lfItalic == 0xFF),
(PRUint16) (logFont.lfWeight), 0,
nsnull);
if (!fe)
return 1;
@ -747,7 +753,7 @@ gfxGDIFontList::LookupLocalFont(const gfxProxyFontEntry *aProxyEntry,
gfxFontEntry *fe = GDIFontEntry::CreateFontEntry(lookup->Name(),
gfxWindowsFontType(isCFF ? GFX_FONT_TYPE_PS_OPENTYPE : GFX_FONT_TYPE_TRUETYPE) /*type*/,
PRUint32(aProxyEntry->mItalic ? FONT_STYLE_ITALIC : FONT_STYLE_NORMAL),
w, nsnull);
w, aProxyEntry->mStretch, nsnull);
if (!fe)
return nsnull;
@ -966,7 +972,7 @@ gfxGDIFontList::MakePlatformFont(const gfxProxyFontEntry *aProxyEntry,
GDIFontEntry *fe = GDIFontEntry::CreateFontEntry(uniqueName,
gfxWindowsFontType(isCFF ? GFX_FONT_TYPE_PS_OPENTYPE : GFX_FONT_TYPE_TRUETYPE) /*type*/,
PRUint32(aProxyEntry->mItalic ? FONT_STYLE_ITALIC : FONT_STYLE_NORMAL),
w, winUserFontData);
w, aProxyEntry->mStretch, winUserFontData);
if (!fe)
return fe;

Просмотреть файл

@ -275,14 +275,15 @@ public:
virtual PRBool TestCharacterMap(PRUint32 aCh);
// create a font entry for a font with a given name
static GDIFontEntry* CreateFontEntry(const nsAString& aName,
gfxWindowsFontType aFontType,
PRBool aItalic, PRUint16 aWeight,
gfxUserFontData* aUserFontData);
static GDIFontEntry* CreateFontEntry(const nsAString& aName,
gfxWindowsFontType aFontType,
PRBool aItalic,
PRUint16 aWeight, PRInt16 aStretch,
gfxUserFontData* aUserFontData);
// create a font entry for a font referenced by its fullname
static GDIFontEntry* LoadLocalFont(const gfxProxyFontEntry &aProxyEntry,
const nsAString& aFullname);
const nsAString& aFullname);
PRUint8 mWindowsFamily;
PRUint8 mWindowsPitch;
@ -298,7 +299,8 @@ protected:
friend class gfxWindowsFont;
GDIFontEntry(const nsAString& aFaceName, gfxWindowsFontType aFontType,
PRBool aItalic, PRUint16 aWeight, gfxUserFontData *aUserFontData);
PRBool aItalic, PRUint16 aWeight, PRInt16 aStretch,
gfxUserFontData *aUserFontData);
void InitLogFont(const nsAString& aName, gfxWindowsFontType aFontType);

Просмотреть файл

@ -57,9 +57,7 @@ gfxMacFont::gfxMacFont(MacOSFontEntry *aFontEntry, const gfxFontStyle *aFontStyl
mFontFace(nsnull),
mScaledFont(nsnull)
{
if (aNeedsBold) {
mSyntheticBoldOffset = 1; // devunit offset when double-striking text to fake boldness
}
mApplySyntheticBold = aNeedsBold;
mCGFont = aFontEntry->GetFontRef();
if (!mCGFont) {
@ -167,7 +165,7 @@ gfxMacFont::InitTextRun(gfxContext *aContext,
aRunStart, aRunLength, aRunScript,
static_cast<MacOSFontEntry*>(GetFontEntry())->RequiresAATLayout());
aTextRun->AdjustAdvancesForSyntheticBold(aRunStart, aRunLength);
aTextRun->AdjustAdvancesForSyntheticBold(aContext, aRunStart, aRunLength);
return ok;
}
@ -320,8 +318,10 @@ gfxMacFont::InitMetrics()
mMetrics.aveCharWidth = mMetrics.maxAdvance;
}
}
mMetrics.aveCharWidth += mSyntheticBoldOffset;
mMetrics.maxAdvance += mSyntheticBoldOffset;
if (IsSyntheticBold()) {
mMetrics.aveCharWidth += GetSyntheticBoldOffset();
mMetrics.maxAdvance += GetSyntheticBoldOffset();
}
mMetrics.spaceWidth = GetCharWidth(cmap, ' ', &glyphID, cgConvFactor);
if (glyphID == 0) {

Просмотреть файл

@ -449,6 +449,14 @@ gfxUserFcFontEntry::AdjustPatternToCSS(FcPattern *aPattern)
IsItalic() ? FC_SLANT_OBLIQUE : FC_SLANT_ROMAN);
}
int fontWidth = -1;
FcPatternGetInteger(aPattern, FC_WIDTH, 0, &fontWidth);
int cssWidth = gfxFontconfigUtils::FcWidthForThebesStretch(mStretch);
if (cssWidth != fontWidth) {
FcPatternDel(aPattern, FC_WIDTH);
FcPatternAddInteger(aPattern, FC_WIDTH, cssWidth);
}
// Ensure that there is a fullname property (if there is a family
// property) so that fontconfig rules can identify the real name of the
// font, because the family property will be replaced.
@ -1250,8 +1258,9 @@ private:
// and style |aStyle| properties.
static const nsTArray< nsCountedRef<FcPattern> >*
FindFontPatterns(gfxUserFontSet *mUserFontSet,
const nsACString &aFamily, PRUint8 aStyle, PRUint16 aWeight,
PRBool& aFoundFamily, PRBool& aWaitForUserFont)
const nsACString &aFamily, PRUint8 aStyle,
PRUint16 aWeight, PRInt16 aStretch,
PRBool& aFoundFamily, PRBool& aWaitForUserFont)
{
// Convert to UTF16
NS_ConvertUTF8toUTF16 utf16Family(aFamily);
@ -1264,6 +1273,7 @@ FindFontPatterns(gfxUserFontSet *mUserFontSet,
gfxFontStyle style;
style.style = aStyle;
style.weight = aWeight;
style.stretch = aStretch;
gfxUserFcFontEntry *fontEntry = static_cast<gfxUserFcFontEntry*>
(mUserFontSet->FindFontEntry(utf16Family, style, aFoundFamily,
@ -1431,10 +1441,13 @@ gfxFcFontSet::SortPreferredFonts(PRBool &aWaitForUserFont)
gfxFontconfigUtils::FcSlantToThebesStyle(requestedSlant);
PRUint16 thebesWeight =
gfxFontconfigUtils::GetThebesWeight(mSortPattern);
PRInt16 thebesStretch =
gfxFontconfigUtils::GetThebesStretch(mSortPattern);
PRBool foundFamily, waitForUserFont;
familyFonts = FindFontPatterns(mUserFontSet, cssFamily,
thebesStyle, thebesWeight,
thebesStyle,
thebesWeight, thebesStretch,
foundFamily, waitForUserFont);
if (waitForUserFont) {
aWaitForUserFont = PR_TRUE;

Просмотреть файл

@ -76,7 +76,7 @@ ToUTF8(const nsACString &aString, const char *aCharset, nsACString &aResult)
rv = unicodeDecoder->Convert(inStr.get(), &srcLen, ustr, &dstLen);
if (NS_SUCCEEDED(rv)){
// Tru64 Cxx and IRIX MIPSpro 7.3 need an explicit get()
// Tru64 Cxx needs an explicit get()
CopyUTF16toUTF8(Substring(ustr.get(), ustr + dstLen), aResult);
}
return rv;

1
js/src/aclocal.m4 поставляемый
Просмотреть файл

@ -11,5 +11,6 @@ builtin(include, build/autoconf/mozprog.m4)dnl
builtin(include, build/autoconf/acwinpaths.m4)dnl
builtin(include, build/autoconf/lto.m4)dnl
builtin(include, build/autoconf/gcc-pr49911.m4)dnl
builtin(include, build/autoconf/frameptr.m4)dnl
MOZ_PROG_CHECKMSYS()

Просмотреть файл

@ -192,7 +192,11 @@ namespace JSC {
void grow(int extraCapacity = 0)
{
int newCapacity = m_capacity + m_capacity / 2 + extraCapacity;
/*
* If |extraCapacity| is zero (as it almost always is) this is an
* allocator-friendly doubling growth strategy.
*/
int newCapacity = m_capacity + m_capacity + extraCapacity;
char* newBuffer;
// Do not allow offsets to grow beyond INT_MAX / 2. This mirrors

Просмотреть файл

@ -0,0 +1,25 @@
dnl Set MOZ_FRAMEPTR_FLAGS to the flags that should be used for enabling or
dnl disabling frame pointers in this architecture based on the configure
dnl options
AC_DEFUN([MOZ_SET_FRAMEPTR_FLAGS], [
if test "$GNU_CC"; then
MOZ_ENABLE_FRAME_PTR="-fno-omit-frame-pointer"
MOZ_DISABLE_FRAME_PTR="-fomit-frame-pointer"
else
case "$target" in
*-mingw*)
MOZ_ENABLE_FRAME_PTR="-Oy-"
MOZ_DISABLE_FRAME_PTR="-Oy"
;;
esac
fi
# if we are debugging or profiling, we want a frame pointer.
if test -z "$MOZ_OPTIMIZE" -o \
-n "$MOZ_PROFILING" -o -n "$MOZ_DEBUG"; then
MOZ_FRAMEPTR_FLAGS="$MOZ_ENABLE_FRAME_PTR"
else
MOZ_FRAMEPTR_FLAGS="$MOZ_DISABLE_FRAME_PTR"
fi
])

Просмотреть файл

@ -143,6 +143,7 @@ WARNINGS_AS_ERRORS = @WARNINGS_AS_ERRORS@
FAIL_ON_WARNINGS = @FAIL_ON_WARNINGS@
MOZ_OPTIMIZE = @MOZ_OPTIMIZE@
MOZ_FRAMEPTR_FLAGS = @MOZ_FRAMEPTR_FLAGS@
MOZ_OPTIMIZE_FLAGS = @MOZ_OPTIMIZE_FLAGS@
MOZ_PGO_OPTIMIZE_FLAGS = @MOZ_PGO_OPTIMIZE_FLAGS@
MOZ_OPTIMIZE_LDFLAGS = @MOZ_OPTIMIZE_LDFLAGS@

Просмотреть файл

@ -463,6 +463,9 @@ endif # MOZ_OPTIMIZE == 1
endif # MOZ_OPTIMIZE
endif # CROSS_COMPILE
CFLAGS += $(MOZ_FRAMEPTR_FLAGS)
CXXFLAGS += $(MOZ_FRAMEPTR_FLAGS)
# Check for FAIL_ON_WARNINGS & FAIL_ON_WARNINGS_DEBUG (Shorthand for Makefiles
# to request that we use the 'warnings as errors' compile flags)

Просмотреть файл

@ -1972,13 +1972,7 @@ case "$target" in
*-darwin*)
MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
# If we're building with --enable-profiling, we need a frame pointer.
if test -z "$MOZ_PROFILING"; then
MOZ_FRAMEPTR_FLAGS="-fomit-frame-pointer"
else
MOZ_FRAMEPTR_FLAGS="-fno-omit-frame-pointer"
fi
MOZ_OPTIMIZE_FLAGS="-O3 $MOZ_FRAMEPTR_FLAGS -fno-stack-protector"
MOZ_OPTIMIZE_FLAGS="-O3 -fno-stack-protector"
_PEDANTIC=
CFLAGS="$CFLAGS -fpascal-strings -fno-common"
CXXFLAGS="$CXXFLAGS -fpascal-strings -fno-common"
@ -2083,13 +2077,7 @@ ia64*-hpux*)
TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
MOZ_GFX_OPTIMIZE_MOBILE=1
# If we're building with --enable-profiling, we need a frame pointer.
if test -z "$MOZ_PROFILING"; then
MOZ_FRAMEPTR_FLAGS="-fomit-frame-pointer"
else
MOZ_FRAMEPTR_FLAGS="-fno-omit-frame-pointer"
fi
MOZ_OPTIMIZE_FLAGS="-O3 -freorder-blocks -fno-reorder-functions $MOZ_FRAMEPTR_FLAGS"
MOZ_OPTIMIZE_FLAGS="-O3 -freorder-blocks -fno-reorder-functions"
# The Maemo builders don't know about this flag
MOZ_ARM_VFP_FLAGS="-mfpu=vfp"
;;
@ -2109,14 +2097,8 @@ ia64*-hpux*)
# -Os is broken on gcc 4.1.x 4.2.x, 4.5.x we need to tweak it to get good results.
MOZ_OPTIMIZE_SIZE_TWEAK="-finline-limit=50"
esac
# If we're building with --enable-profiling, we need a frame pointer.
if test -z "$MOZ_PROFILING"; then
MOZ_FRAMEPTR_FLAGS="-fomit-frame-pointer"
else
MOZ_FRAMEPTR_FLAGS="-fno-omit-frame-pointer"
fi
MOZ_PGO_OPTIMIZE_FLAGS="-O3 $MOZ_FRAMEPTR_FLAGS"
MOZ_OPTIMIZE_FLAGS="-O3 -freorder-blocks $MOZ_OPTIMIZE_SIZE_TWEAK $MOZ_FRAMEPTR_FLAGS"
MOZ_PGO_OPTIMIZE_FLAGS="-O3"
MOZ_OPTIMIZE_FLAGS="-O3 -freorder-blocks $MOZ_OPTIMIZE_SIZE_TWEAK"
MOZ_DEBUG_FLAGS="-g"
fi
@ -2236,13 +2218,7 @@ ia64*-hpux*)
MOZ_DEBUG_FLAGS='-Zi'
MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
WARNINGS_AS_ERRORS='-WX'
# If we're building with --enable-profiling, we need -Oy-, which forces a frame pointer.
if test -z "$MOZ_PROFILING"; then
MOZ_FRAMEPTR_FLAGS=
else
MOZ_FRAMEPTR_FLAGS='-Oy-'
fi
MOZ_OPTIMIZE_FLAGS="-O2 $MOZ_FRAMEPTR_FLAGS"
MOZ_OPTIMIZE_FLAGS="-O2"
MOZ_JS_LIBS='$(libdir)/mozjs.lib'
MOZ_FIX_LINK_PATHS=
DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
@ -4414,6 +4390,8 @@ else
MOZ_OPTIMIZE=
fi ], MOZ_OPTIMIZE=1)
MOZ_SET_FRAMEPTR_FLAGS
if test "$COMPILE_ENVIRONMENT"; then
if test -n "$MOZ_OPTIMIZE"; then
AC_MSG_CHECKING([for valid optimization flags])
@ -4432,6 +4410,7 @@ fi
fi # COMPILE_ENVIRONMENT
AC_SUBST(MOZ_OPTIMIZE)
AC_SUBST(MOZ_FRAMEPTR_FLAGS)
AC_SUBST(MOZ_OPTIMIZE_FLAGS)
AC_SUBST(MOZ_OPTIMIZE_LDFLAGS)
AC_SUBST(MOZ_OPTIMIZE_SIZE_TWEAK)

Просмотреть файл

@ -905,9 +905,7 @@ ScriptAnalysis::analyzeLifetimes(JSContext *cx)
ensureVariable(lifetimes[i], startOffset - 1);
}
#ifdef DEBUG
found = true;
#endif
break;
}
}

Просмотреть файл

@ -49,7 +49,7 @@ bool checkObjectFields(JSObject *savedCopy, JSObject *obj)
{
/* Ignore fields which are unstable across GCs. */
CHECK(savedCopy->lastProp == obj->lastProp);
CHECK(savedCopy->clasp == obj->clasp);
CHECK(savedCopy->getClass() == obj->getClass());
CHECK(savedCopy->flags == obj->flags);
CHECK(savedCopy->newType == obj->newType);
CHECK(savedCopy->getProto() == obj->getProto());

Просмотреть файл

@ -1552,7 +1552,7 @@ JS_InitStandardClasses(JSContext *cx, JSObject *obj)
return obj->asGlobal()->initStandardClasses(cx);
}
#define CLASP(name) (&js_##name##Class)
#define CLASP(name) (&name##Class)
#define TYPED_ARRAY_CLASP(type) (&TypedArray::fastClasses[TypedArray::type])
#define EAGER_ATOM(name) ATOM_OFFSET(name), NULL
#define EAGER_CLASS_ATOM(name) CLASS_ATOM_OFFSET(name), NULL
@ -1662,7 +1662,7 @@ static JSStdName standard_class_names[] = {
#endif
/* Typed Arrays */
{js_InitTypedArrayClasses, EAGER_CLASS_ATOM(ArrayBuffer), &js_ArrayBufferClass},
{js_InitTypedArrayClasses, EAGER_CLASS_ATOM(ArrayBuffer), &ArrayBufferClass},
{js_InitTypedArrayClasses, EAGER_CLASS_ATOM(Int8Array), TYPED_ARRAY_CLASP(TYPE_INT8)},
{js_InitTypedArrayClasses, EAGER_CLASS_ATOM(Uint8Array), TYPED_ARRAY_CLASP(TYPE_UINT8)},
{js_InitTypedArrayClasses, EAGER_CLASS_ATOM(Int16Array), TYPED_ARRAY_CLASP(TYPE_INT16)},
@ -2288,7 +2288,7 @@ JS_PrintTraceThingInfo(char *buf, size_t bufsize, JSTracer *trc, void *thing,
{
JSObject *obj = (JSObject *)thing;
Class *clasp = obj->getClass();
if (clasp == &js_FunctionClass) {
if (clasp == &FunctionClass) {
JSFunction *fun = obj->getFunctionPrivate();
if (!fun) {
JS_snprintf(buf, bufsize, "<newborn>");
@ -3078,9 +3078,9 @@ JS_NewObject(JSContext *cx, JSClass *jsclasp, JSObject *proto, JSObject *parent)
Class *clasp = Valueify(jsclasp);
if (!clasp)
clasp = &js_ObjectClass; /* default class is Object */
clasp = &ObjectClass; /* default class is Object */
JS_ASSERT(clasp != &js_FunctionClass);
JS_ASSERT(clasp != &FunctionClass);
JS_ASSERT(!(clasp->flags & JSCLASS_IS_GLOBAL));
if (proto)
@ -3107,9 +3107,9 @@ JS_NewObjectWithGivenProto(JSContext *cx, JSClass *jsclasp, JSObject *proto, JSO
Class *clasp = Valueify(jsclasp);
if (!clasp)
clasp = &js_ObjectClass; /* default class is Object */
clasp = &ObjectClass; /* default class is Object */
JS_ASSERT(clasp != &js_FunctionClass);
JS_ASSERT(clasp != &FunctionClass);
JS_ASSERT(!(clasp->flags & JSCLASS_IS_GLOBAL));
JSObject *obj = NewNonFunction<WithProto::Given>(cx, clasp, proto, parent);
@ -3182,7 +3182,7 @@ JS_ConstructObject(JSContext *cx, JSClass *jsclasp, JSObject *proto, JSObject *p
assertSameCompartment(cx, proto, parent);
Class *clasp = Valueify(jsclasp);
if (!clasp)
clasp = &js_ObjectClass; /* default class is Object */
clasp = &ObjectClass; /* default class is Object */
return js_ConstructObject(cx, clasp, proto, parent, 0, NULL);
}
@ -3194,7 +3194,7 @@ JS_ConstructObjectWithArguments(JSContext *cx, JSClass *jsclasp, JSObject *proto
assertSameCompartment(cx, proto, parent, JSValueArray(argv, argc));
Class *clasp = Valueify(jsclasp);
if (!clasp)
clasp = &js_ObjectClass; /* default class is Object */
clasp = &ObjectClass; /* default class is Object */
return js_ConstructObject(cx, clasp, proto, parent, argc, Valueify(argv));
}
@ -3534,7 +3534,7 @@ JS_DefineObject(JSContext *cx, JSObject *obj, const char *name, JSClass *jsclasp
Class *clasp = Valueify(jsclasp);
if (!clasp)
clasp = &js_ObjectClass; /* default class is Object */
clasp = &ObjectClass; /* default class is Object */
JSObject *nobj = NewObject<WithProto::Class>(cx, clasp, proto, obj);
if (!nobj)
@ -4229,7 +4229,7 @@ JS_CloneFunctionObject(JSContext *cx, JSObject *funobj, JSObject *parent)
JS_ASSERT(parent);
}
if (funobj->getClass() != &js_FunctionClass) {
if (!funobj->isFunction()) {
/*
* We cannot clone this object, so fail (we used to return funobj, bad
* idea, but we changed incompatibly to teach any abusers a lesson!).
@ -4320,7 +4320,7 @@ JS_GetFunctionArity(JSFunction *fun)
JS_PUBLIC_API(JSBool)
JS_ObjectIsFunction(JSContext *cx, JSObject *obj)
{
return obj->getClass() == &js_FunctionClass;
return obj->isFunction();
}
JS_PUBLIC_API(JSBool)

Просмотреть файл

@ -44,7 +44,7 @@
* Array objects begin as "dense" arrays, optimized for index-only property
* access over a vector of slots with high load factor. Array methods
* optimize for denseness by testing that the object's class is
* &js_ArrayClass, and can then directly manipulate the slots for efficiency.
* &ArrayClass, and can then directly manipulate the slots for efficiency.
*
* We track these pieces of metadata for arrays in dense mode:
* - The array's length property as a uint32, accessible with
@ -81,7 +81,7 @@
* known to have no hole values below its initialized length, then it is a
* "packed" array and can be accessed much faster by JIT code.
*
* Arrays are converted to use js_SlowArrayClass when any of these conditions
* Arrays are converted to use SlowArrayClass when any of these conditions
* are met:
* - there are more than MIN_SPARSE_INDEX slots total and the load factor
* (COUNT / capacity) is less than 0.25
@ -93,7 +93,7 @@
* properties in the order they were created. We could instead maintain the
* scope to track property enumeration order, but still use the fast slot
* access. That would have the same memory cost as just using a
* js_SlowArrayClass, but have the same performance characteristics as a dense
* SlowArrayClass, but have the same performance characteristics as a dense
* array for slot accesses, at some cost in code complexity.
*/
#include <stdlib.h>
@ -146,13 +146,6 @@ using namespace js;
using namespace js::gc;
using namespace js::types;
static inline bool
ENSURE_SLOW_ARRAY(JSContext *cx, JSObject *obj)
{
return obj->getClass() == &js_SlowArrayClass ||
obj->makeDenseArraySlow(cx);
}
JSBool
js_GetLengthProperty(JSContext *cx, JSObject *obj, jsuint *lengthp)
{
@ -246,14 +239,11 @@ static JSBool
BigIndexToId(JSContext *cx, JSObject *obj, jsuint index, JSBool createAtom,
jsid *idp)
{
jschar buf[10], *start;
Class *clasp;
JSAtom *atom;
JS_STATIC_ASSERT((jsuint)-1 == 4294967295U);
JS_ASSERT(index > JSID_INT_MAX);
start = JS_ARRAY_END(buf);
jschar buf[10];
jschar *start = JS_ARRAY_END(buf);
do {
--start;
*start = (jschar)('0' + index % 10);
@ -264,14 +254,11 @@ BigIndexToId(JSContext *cx, JSObject *obj, jsuint index, JSBool createAtom,
* Skip the atomization if the class is known to store atoms corresponding
* to big indexes together with elements. In such case we know that the
* array does not have an element at the given index if its atom does not
* exist. Fast arrays (clasp == &js_ArrayClass) don't use atoms for
* any indexes, though it would be rare to see them have a big index
* in any case.
* exist. Dense arrays don't use atoms for any indexes, though it would be
* rare to see them have a big index in any case.
*/
if (!createAtom &&
((clasp = obj->getClass()) == &js_SlowArrayClass ||
obj->isArguments() ||
clasp == &js_ObjectClass)) {
JSAtom *atom;
if (!createAtom && (obj->isSlowArray() || obj->isArguments() || obj->isObject())) {
atom = js_GetExistingStringAtom(cx, start, JS_ARRAY_END(buf) - start);
if (!atom) {
*idp = JSID_VOID;
@ -501,13 +488,13 @@ JSBool JS_FASTCALL
js_EnsureDenseArrayCapacity(JSContext *cx, JSObject *obj, jsint i)
{
#ifdef DEBUG
Class *origObjClasp = obj->clasp;
Class *origObjClasp = obj->getClass();
#endif
jsuint u = jsuint(i);
JSBool ret = (obj->ensureDenseArrayElements(cx, u, 1) == JSObject::ED_OK);
/* Partially check the CallInfo's storeAccSet is correct. */
JS_ASSERT(obj->clasp == origObjClasp);
JS_ASSERT(obj->getClass() == origObjClasp);
return ret;
}
/* This function and its callees do not touch any object's .clasp field. */
@ -989,7 +976,7 @@ array_fix(JSContext *cx, JSObject *obj, bool *success, AutoIdVector *props)
return true;
}
Class js_ArrayClass = {
Class js::ArrayClass = {
"Array",
Class::NON_NATIVE | JSCLASS_HAS_PRIVATE | JSCLASS_HAS_CACHED_PROTO(JSProto_Array),
PropertyStub, /* addProperty */
@ -1024,7 +1011,7 @@ Class js_ArrayClass = {
}
};
Class js_SlowArrayClass = {
Class js::SlowArrayClass = {
"Array",
JSCLASS_HAS_PRIVATE |
JSCLASS_HAS_CACHED_PROTO(JSProto_Array),
@ -1068,8 +1055,8 @@ JSObject::makeDenseArraySlow(JSContext *cx)
js::Shape *oldMap = lastProp;
/* Create a native scope. */
js::gc::FinalizeKind kind = js::gc::FinalizeKind(arenaHeader()->getThingKind());
if (!InitScopeForObject(cx, this, &js_SlowArrayClass, getProto()->getNewType(cx), kind))
gc::AllocKind kind = getAllocKind();
if (!InitScopeForObject(cx, this, &SlowArrayClass, getProto()->getNewType(cx), kind))
return false;
backfillDenseArrayHoles(cx);
@ -1090,7 +1077,7 @@ JSObject::makeDenseArraySlow(JSContext *cx)
JS_ASSERT(!denseArrayHasInlineSlots());
}
capacity = numFixedSlots() + arrayCapacity;
clasp = &js_SlowArrayClass;
clasp = &SlowArrayClass;
/*
* Root all values in the array during conversion, as SlowArrayClass only
@ -1110,7 +1097,7 @@ JSObject::makeDenseArraySlow(JSContext *cx)
setMap(oldMap);
capacity = arrayCapacity;
initializedLength = arrayInitialized;
clasp = &js_ArrayClass;
clasp = &ArrayClass;
return false;
}
@ -1133,7 +1120,7 @@ JSObject::makeDenseArraySlow(JSContext *cx)
setMap(oldMap);
capacity = arrayCapacity;
initializedLength = arrayInitialized;
clasp = &js_ArrayClass;
clasp = &ArrayClass;
return false;
}
@ -1144,7 +1131,7 @@ JSObject::makeDenseArraySlow(JSContext *cx)
/*
* Finally, update class. If |this| is Array.prototype, then js_InitClass
* will create an emptyShape whose class is &js_SlowArrayClass, to ensure
* will create an emptyShape whose class is &SlowArrayClass, to ensure
* that delegating instances can share shapes in the tree rooted at the
* proto's empty shape.
*/
@ -1211,7 +1198,7 @@ array_toSource(JSContext *cx, uintN argc, Value *vp)
if (!obj)
return false;
if (!obj->isArray()) {
ReportIncompatibleMethod(cx, vp, &js_ArrayClass);
ReportIncompatibleMethod(cx, vp, &ArrayClass);
return false;
}
@ -1540,7 +1527,7 @@ InitArrayElements(JSContext *cx, JSObject *obj, jsuint start, jsuint count, Valu
return JS_TRUE;
/* Finish out any remaining elements past the max array index. */
if (obj->isDenseArray() && !ENSURE_SLOW_ARRAY(cx, obj))
if (obj->isDenseArray() && !obj->makeDenseArraySlow(cx))
return JS_FALSE;
JS_ASSERT(start == MAX_ARRAY_INDEX + 1);
@ -3217,12 +3204,12 @@ js_InitArrayClass(JSContext *cx, JSObject *obj)
GlobalObject *global = obj->asGlobal();
JSObject *arrayProto = global->createBlankPrototype(cx, &js_SlowArrayClass);
JSObject *arrayProto = global->createBlankPrototype(cx, &SlowArrayClass);
if (!arrayProto || !AddLengthProperty(cx, arrayProto))
return NULL;
arrayProto->setArrayLength(cx, 0);
JSFunction *ctor = global->createConstructor(cx, js_Array, &js_ArrayClass,
JSFunction *ctor = global->createConstructor(cx, js_Array, &ArrayClass,
CLASS_ATOM(cx, Array), 1);
if (!ctor)
return NULL;
@ -3256,8 +3243,8 @@ NewArray(JSContext *cx, jsuint length, JSObject *proto)
{
JS_ASSERT_IF(proto, proto->isArray());
gc::FinalizeKind kind = GuessObjectGCKind(length, true);
JSObject *obj = detail::NewObject<WithProto::Class, false>(cx, &js_ArrayClass, proto, NULL, kind);
gc::AllocKind kind = GuessObjectGCKind(length, true);
JSObject *obj = detail::NewObject<WithProto::Class, false>(cx, &ArrayClass, proto, NULL, kind);
if (!obj)
return NULL;
@ -3346,7 +3333,7 @@ JS_DEFINE_CALLINFO_3(extern, OBJECT, NewDenseUnallocatedArray, CONTEXT, UINT32,
JSObject *
NewSlowEmptyArray(JSContext *cx)
{
JSObject *obj = NewNonFunction<WithProto::Class>(cx, &js_SlowArrayClass, NULL, NULL);
JSObject *obj = NewNonFunction<WithProto::Class>(cx, &SlowArrayClass, NULL, NULL);
if (!obj || !AddLengthProperty(cx, obj))
return NULL;

Просмотреть файл

@ -63,7 +63,7 @@
using namespace js;
using namespace js::types;
Class js_BooleanClass = {
Class js::BooleanClass = {
"Boolean",
JSCLASS_HAS_RESERVED_SLOTS(1) |
JSCLASS_HAS_CACHED_PROTO(JSProto_Boolean),
@ -138,7 +138,7 @@ Boolean(JSContext *cx, uintN argc, Value *vp)
bool b = argc != 0 ? js_ValueToBoolean(argv[0]) : false;
if (IsConstructing(vp)) {
JSObject *obj = NewBuiltinClassInstance(cx, &js_BooleanClass);
JSObject *obj = NewBuiltinClassInstance(cx, &BooleanClass);
if (!obj)
return false;
obj->setPrimitiveThis(BooleanValue(b));
@ -152,7 +152,7 @@ Boolean(JSContext *cx, uintN argc, Value *vp)
JSObject *
js_InitBooleanClass(JSContext *cx, JSObject *obj)
{
JSObject *proto = js_InitClass(cx, obj, NULL, &js_BooleanClass, Boolean, 1,
JSObject *proto = js_InitClass(cx, obj, NULL, &BooleanClass, Boolean, 1,
NULL, boolean_methods, NULL, NULL);
if (!proto)
return NULL;

Просмотреть файл

@ -46,14 +46,6 @@
#include "jsapi.h"
#include "jsobj.h"
extern js::Class js_BooleanClass;
inline bool
JSObject::isBoolean() const
{
return getClass() == &js_BooleanClass;
}
extern JSObject *
js_InitBooleanClass(JSContext *cx, JSObject *obj);

Просмотреть файл

@ -251,7 +251,7 @@ HasProperty(JSContext* cx, JSObject* obj, jsid id)
if (pobj->getOps()->lookupProperty)
return JS_NEITHER;
Class* clasp = pobj->getClass();
if (clasp->resolve != JS_ResolveStub && clasp != &js_StringClass)
if (clasp->resolve != JS_ResolveStub && clasp != &StringClass)
return JS_NEITHER;
}
@ -320,7 +320,7 @@ js_NewNullClosure(JSContext* cx, JSObject* funobj, JSObject* proto, JSObject* pa
if (!closure)
return NULL;
if (!closure->initSharingEmptyShape(cx, &js_FunctionClass, type, parent,
if (!closure->initSharingEmptyShape(cx, &FunctionClass, type, parent,
fun, gc::FINALIZE_OBJECT2)) {
return NULL;
}

Просмотреть файл

@ -84,8 +84,8 @@ enum {
* 'i': an integer argument
* 's': a JSString* argument
* 'o': a JSObject* argument
* 'r': a JSObject* argument that is of class js_RegExpClass
* 'f': a JSObject* argument that is of class js_FunctionClass
* 'r': a JSObject* argument that is of class RegExpClass
* 'f': a JSObject* argument that is of class FunctionClass
* 'v': a value argument: on 32-bit, a Value*, on 64-bit, a jsval
*/
struct JSSpecializedNative {

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше