Backing out bf0a78471e5e:dc7022e2d807 for inexplicable windows crashes.

This commit is contained in:
Ms2ger 2012-04-14 17:52:34 +02:00
Родитель 69966a9faf
Коммит 77ca860259
115 изменённых файлов: 1001 добавлений и 595 удалений

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

@ -119,13 +119,13 @@ ProgressMeterAccessible<Max>::Value(nsString& aValue)
double maxValue = 0;
nsresult rv = GetMaximumValue(&maxValue);
if (NS_FAILED(rv) || maxValue == 0)
NS_ENSURE_SUCCESS(rv, );
if (maxValue == 0)
return;
double curValue = 0;
GetCurrentValue(&curValue);
if (NS_FAILED(rv))
return;
NS_ENSURE_SUCCESS(rv, );
// Treat the current value bigger than maximum as 100%.
double percentValue = (curValue < maxValue) ?

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

@ -243,7 +243,8 @@ nsHTMLImageAccessible::GetLongDescURI() const
nsDocAccessible* document = Document();
if (document) {
IDRefsIterator iter(document, mContent, nsGkAtoms::aria_describedby);
while (nsIContent* target = iter.NextElem()) {
nsIContent* target = nsnull;
while (target = iter.NextElem()) {
if ((target->IsHTML(nsGkAtoms::a) || target->IsHTML(nsGkAtoms::area)) &&
target->HasAttr(kNameSpaceID_None, nsGkAtoms::href)) {
nsGenericHTMLElement* element =

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

@ -363,7 +363,10 @@ JSContext *
nsScriptSecurityManager::GetSafeJSContext()
{
// Get JSContext from stack.
return sJSContextStack->GetSafeJSContext();
JSContext *cx;
if (NS_FAILED(sJSContextStack->GetSafeJSContext(&cx)))
return nsnull;
return cx;
}
/* static */

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

@ -88,9 +88,9 @@ namespace dom {
class Link;
// IID for the dom::Element interface
#define NS_ELEMENT_IID \
{ 0xab6554b0, 0xb675, 0x45a7, \
{ 0xac, 0x23, 0x44, 0x1c, 0x94, 0x5f, 0x3b, 0xee } }
#define NS_ELEMENT_IID \
{ 0xa1588efb, 0x5a84, 0x49cd, \
{ 0x99, 0x1a, 0xac, 0x84, 0x9d, 0x92, 0x05, 0x0f } }
class Element : public nsIContent
{
@ -171,53 +171,6 @@ public:
*/
void ClearStyleStateLocks();
/**
* Get the inline style rule, if any, for this element.
*/
virtual css::StyleRule* GetInlineStyleRule() = 0;
/**
* Set the inline style rule for this element. This will send an appropriate
* AttributeChanged notification if aNotify is true.
*/
virtual nsresult SetInlineStyleRule(css::StyleRule* aStyleRule,
const nsAString* aSerialized,
bool aNotify) = 0;
/**
* Get the SMIL override style rule for this element. If the rule hasn't been
* created, this method simply returns null.
*/
virtual css::StyleRule* GetSMILOverrideStyleRule() = 0;
/**
* Set the SMIL override style rule for this element. If aNotify is true, this
* method will notify the document's pres context, so that the style changes
* will be noticed.
*/
virtual nsresult SetSMILOverrideStyleRule(css::StyleRule* aStyleRule,
bool aNotify) = 0;
/**
* Returns a new nsISMILAttr that allows the caller to animate the given
* attribute on this element.
*
* The CALLER OWNS the result and is responsible for deleting it.
*/
virtual nsISMILAttr* GetAnimatedAttr(PRInt32 aNamespaceID, nsIAtom* aName) = 0;
/**
* Get the SMIL override style for this element. This is a style declaration
* that is applied *after* the inline style, and it can be used e.g. to store
* animated style values.
*
* Note: This method is analogous to the 'GetStyle' method in
* nsGenericHTMLElement and nsStyledElement.
*
* TODO: Bug 744157 - All callers QI to nsICSSDeclaration.
*/
virtual nsIDOMCSSStyleDeclaration* GetSMILOverrideStyle() = 0;
protected:
/**
* Method to get the _intrinsic_ content state of this element. This is the

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

@ -395,6 +395,9 @@ public:
static PRUint32 CopyNewlineNormalizedUnicodeTo(nsReadingIterator<PRUnichar>& aSrcStart, const nsReadingIterator<PRUnichar>& aSrcEnd, nsAString& aDest);
static nsISupports *
GetClassInfoInstance(nsDOMClassInfoID aID);
static const nsDependentSubstring TrimCharsInSet(const char* aSet,
const nsAString& aValue);

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

@ -77,8 +77,8 @@ enum nsLinkState {
// IID for the nsIContent interface
#define NS_ICONTENT_IID \
{ 0xa887c108, 0xc25e, 0x42ab, \
{ 0x87, 0xef, 0xad, 0x4b, 0xee, 0x50, 0x28, 0x28 } }
{ 0x94671671, 0x9e1b, 0x447a, \
{ 0xad, 0xb7, 0xc3, 0x2e, 0x05, 0x6a, 0x96, 0xc9 } }
/**
* A node of content in a document's content model. This interface
@ -793,6 +793,22 @@ public:
*/
NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker) = 0;
/**
* Get the inline style rule, if any, for this content node
*/
virtual mozilla::css::StyleRule* GetInlineStyleRule() = 0;
/**
* Set the inline style rule for this node. This will send an
* appropriate AttributeChanged notification if aNotify is true. If
* a serialized form of aStyleRule is available, a pointer to it
* should be passed in aSerialized. Otherwise, aSerialized should
* be null.
*/
NS_IMETHOD SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule,
const nsAString* aSerialized,
bool aNotify) = 0;
/**
* Is the attribute named stored in the mapped attributes?
*
@ -859,6 +875,39 @@ public:
mPrimaryFrame = aFrame;
}
/*
* Returns a new nsISMILAttr that allows the caller to animate the given
* attribute on this element.
*
* The CALLER OWNS the result and is responsible for deleting it.
*/
virtual nsISMILAttr* GetAnimatedAttr(PRInt32 aNamespaceID, nsIAtom* aName) = 0;
/**
* Get the SMIL override style for this content node. This is a style
* declaration that is applied *after* the inline style, and it can be used
* e.g. to store animated style values.
*
* Note: This method is analogous to the 'GetStyle' method in
* nsGenericHTMLElement and nsStyledElement.
*/
virtual nsIDOMCSSStyleDeclaration* GetSMILOverrideStyle() = 0;
/**
* Get the SMIL override style rule for this content node. If the rule
* hasn't been created (or if this nsIContent object doesn't support SMIL
* override style), this method simply returns null.
*/
virtual mozilla::css::StyleRule* GetSMILOverrideStyleRule() = 0;
/**
* Set the SMIL override style rule for this node. If aNotify is true, this
* method will notify the document's pres context, so that the style changes
* will be noticed.
*/
virtual nsresult SetSMILOverrideStyleRule(mozilla::css::StyleRule* aStyleRule,
bool aNotify) = 0;
nsresult LookupNamespaceURIInternal(const nsAString& aNamespacePrefix,
nsAString& aNamespaceURI) const;

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

@ -1623,7 +1623,8 @@ nsContentUtils::TraceSafeJSContext(JSTracer* aTrc)
if (!sThreadJSContextStack) {
return;
}
JSContext* cx = sThreadJSContextStack->GetSafeJSContext();
JSContext* cx = nsnull;
sThreadJSContextStack->GetSafeJSContext(&cx);
if (!cx) {
return;
}

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

@ -91,7 +91,6 @@ public:
PRUint32 argc, jsval* argv);
// nsICharsetDetectionObserver
using mozilla::dom::FileIOObject::Notify;
NS_IMETHOD Notify(const char *aCharset, nsDetectionConfident aConf);
// FileIOObject overrides

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

@ -3845,7 +3845,7 @@ nsDocument::SetScriptGlobalObject(nsIScriptGlobalObject *aScriptGlobalObject)
if (!cx) {
nsContentUtils::ThreadJSContextStack()->Peek(&cx);
if (!cx) {
cx = nsContentUtils::ThreadJSContextStack()->GetSafeJSContext();
nsContentUtils::ThreadJSContextStack()->GetSafeJSContext(&cx);
NS_ASSERTION(cx, "Uhoh, no context, this is bad!");
}
}
@ -6054,7 +6054,7 @@ GetContextAndScope(nsIDocument* aOldDocument, nsIDocument* aNewDocument,
stack->Peek(&cx);
if (!cx) {
cx = stack->GetSafeJSContext();
stack->GetSafeJSContext(&cx);
if (!cx) {
// No safe context reachable, bail.
@ -6469,33 +6469,36 @@ nsDocument::IsScriptEnabled()
return enabled;
}
nsRadioGroupStruct*
nsDocument::GetRadioGroup(const nsAString& aName)
nsresult
nsDocument::GetRadioGroup(const nsAString& aName,
nsRadioGroupStruct **aRadioGroup)
{
nsAutoString tmKey(aName);
if (IsHTML()) {
ToLowerCase(tmKey); //should case-insensitive.
}
if(IsHTML())
ToLowerCase(tmKey); //should case-insensitive.
if (mRadioGroups.Get(tmKey, aRadioGroup))
return NS_OK;
nsRadioGroupStruct* radioGroup;
if (mRadioGroups.Get(tmKey, &radioGroup)) {
return radioGroup;
}
nsAutoPtr<nsRadioGroupStruct> radioGroup(new nsRadioGroupStruct());
NS_ENSURE_TRUE(radioGroup, NS_ERROR_OUT_OF_MEMORY);
NS_ENSURE_TRUE(mRadioGroups.Put(tmKey, radioGroup), NS_ERROR_OUT_OF_MEMORY);
nsAutoPtr<nsRadioGroupStruct> newRadioGroup(new nsRadioGroupStruct());
NS_ENSURE_TRUE(mRadioGroups.Put(tmKey, newRadioGroup), nsnull);
*aRadioGroup = radioGroup;
radioGroup.forget();
return newRadioGroup.forget();
return NS_OK;
}
NS_IMETHODIMP
nsDocument::SetCurrentRadioButton(const nsAString& aName,
nsIDOMHTMLInputElement* aRadio)
{
nsRadioGroupStruct* radioGroup = GetRadioGroup(aName);
NS_ENSURE_TRUE(radioGroup, NS_OK);
nsRadioGroupStruct* radioGroup = nsnull;
GetRadioGroup(aName, &radioGroup);
if (radioGroup) {
radioGroup->mSelectedRadioButton = aRadio;
}
radioGroup->mSelectedRadioButton = aRadio;
return NS_OK;
}
@ -6503,11 +6506,13 @@ NS_IMETHODIMP
nsDocument::GetCurrentRadioButton(const nsAString& aName,
nsIDOMHTMLInputElement** aRadio)
{
nsRadioGroupStruct* radioGroup = GetRadioGroup(aName);
NS_ENSURE_TRUE(radioGroup, NS_OK);
nsRadioGroupStruct* radioGroup = nsnull;
GetRadioGroup(aName, &radioGroup);
if (radioGroup) {
*aRadio = radioGroup->mSelectedRadioButton;
NS_IF_ADDREF(*aRadio);
}
*aRadio = radioGroup->mSelectedRadioButton;
NS_IF_ADDREF(*aRadio);
return NS_OK;
}
@ -6524,8 +6529,9 @@ nsDocument::GetPositionInGroup(nsIDOMHTMLInputElement *aRadio,
return NS_OK;
}
nsRadioGroupStruct* radioGroup = GetRadioGroup(name);
NS_ENSURE_TRUE(radioGroup, NS_ERROR_OUT_OF_MEMORY);
nsRadioGroupStruct* radioGroup = nsnull;
nsresult rv = GetRadioGroup(name, &radioGroup);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIFormControl> radioControl(do_QueryInterface(aRadio));
NS_ASSERTION(radioControl, "Radio button should implement nsIFormControl");
@ -6548,8 +6554,11 @@ nsDocument::GetNextRadioButton(const nsAString& aName,
// opposed to nsHTMLDocument?
*aRadioOut = nsnull;
nsRadioGroupStruct* radioGroup = GetRadioGroup(aName);
NS_ENSURE_TRUE(radioGroup, NS_ERROR_FAILURE);
nsRadioGroupStruct* radioGroup = nsnull;
GetRadioGroup(aName, &radioGroup);
if (!radioGroup) {
return NS_ERROR_FAILURE;
}
// Return the radio button relative to the focused radio button.
// If no radio is focused, get the radio relative to the selected one.
@ -6594,16 +6603,18 @@ NS_IMETHODIMP
nsDocument::AddToRadioGroup(const nsAString& aName,
nsIFormControl* aRadio)
{
nsRadioGroupStruct* radioGroup = GetRadioGroup(aName);
NS_ENSURE_TRUE(radioGroup, NS_OK);
nsRadioGroupStruct* radioGroup = nsnull;
GetRadioGroup(aName, &radioGroup);
if (radioGroup) {
radioGroup->mRadioButtons.AppendObject(aRadio);
radioGroup->mRadioButtons.AppendObject(aRadio);
nsCOMPtr<nsIContent> element = do_QueryInterface(aRadio);
NS_ASSERTION(element, "radio controls have to be content elements");
if (element->HasAttr(kNameSpaceID_None, nsGkAtoms::required)) {
radioGroup->mRequiredRadioCount++;
nsCOMPtr<nsIContent> element = do_QueryInterface(aRadio);
NS_ASSERTION(element, "radio controls have to be content elements");
if (element->HasAttr(kNameSpaceID_None, nsGkAtoms::required)) {
radioGroup->mRequiredRadioCount++;
}
}
return NS_OK;
}
@ -6611,18 +6622,20 @@ NS_IMETHODIMP
nsDocument::RemoveFromRadioGroup(const nsAString& aName,
nsIFormControl* aRadio)
{
nsRadioGroupStruct* radioGroup = GetRadioGroup(aName);
NS_ENSURE_TRUE(radioGroup, NS_OK);
nsRadioGroupStruct* radioGroup = nsnull;
GetRadioGroup(aName, &radioGroup);
if (radioGroup) {
radioGroup->mRadioButtons.RemoveObject(aRadio);
radioGroup->mRadioButtons.RemoveObject(aRadio);
nsCOMPtr<nsIContent> element = do_QueryInterface(aRadio);
NS_ASSERTION(element, "radio controls have to be content elements");
if (element->HasAttr(kNameSpaceID_None, nsGkAtoms::required)) {
radioGroup->mRequiredRadioCount--;
NS_ASSERTION(radioGroup->mRequiredRadioCount >= 0,
"mRequiredRadioCount shouldn't be negative!");
nsCOMPtr<nsIContent> element = do_QueryInterface(aRadio);
NS_ASSERTION(element, "radio controls have to be content elements");
if (element->HasAttr(kNameSpaceID_None, nsGkAtoms::required)) {
radioGroup->mRequiredRadioCount--;
NS_ASSERTION(radioGroup->mRequiredRadioCount >= 0,
"mRequiredRadioCount shouldn't be negative!");
}
}
return NS_OK;
}
@ -6631,8 +6644,11 @@ nsDocument::WalkRadioGroup(const nsAString& aName,
nsIRadioVisitor* aVisitor,
bool aFlushContent)
{
nsRadioGroupStruct* radioGroup = GetRadioGroup(aName);
NS_ENSURE_TRUE(radioGroup, NS_OK);
nsRadioGroupStruct* radioGroup = nsnull;
GetRadioGroup(aName, &radioGroup);
if (!radioGroup) {
return NS_OK;
}
for (int i = 0; i < radioGroup->mRadioButtons.Count(); i++) {
if (!aVisitor->Visit(radioGroup->mRadioButtons[i])) {
@ -6661,7 +6677,8 @@ nsDocument::GetRequiredRadioCount(const nsAString& aName) const
void
nsDocument::RadioRequiredChanged(const nsAString& aName, nsIFormControl* aRadio)
{
nsRadioGroupStruct* radioGroup = GetRadioGroup(aName);
nsRadioGroupStruct* radioGroup = nsnull;
GetRadioGroup(aName, &radioGroup);
if (!radioGroup) {
return;
@ -6696,7 +6713,8 @@ nsDocument::GetValueMissingState(const nsAString& aName) const
void
nsDocument::SetValueMissingState(const nsAString& aName, bool aValue)
{
nsRadioGroupStruct* radioGroup = GetRadioGroup(aName);
nsRadioGroupStruct* radioGroup = nsnull;
GetRadioGroup(aName, &radioGroup);
if (!radioGroup) {
return;

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

@ -754,7 +754,8 @@ public:
virtual void SetValueMissingState(const nsAString& aName, bool aValue);
// for radio group
nsRadioGroupStruct* GetRadioGroup(const nsAString& aName);
nsresult GetRadioGroup(const nsAString& aName,
nsRadioGroupStruct **aRadioGroup);
// nsIDOMNode
NS_DECL_NSIDOMNODE

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

@ -379,7 +379,7 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
{
JSContext* ctx = mContext ? mContext : aContext;
if (!ctx) {
ctx = nsContentUtils::ThreadJSContextStack()->GetSafeJSContext();
nsContentUtils::ThreadJSContextStack()->GetSafeJSContext(&ctx);
}
if (mListeners.Length()) {
nsCOMPtr<nsIAtom> name = do_GetAtom(aMessage);
@ -723,7 +723,8 @@ void
nsFrameScriptExecutor::Shutdown()
{
if (sCachedScripts) {
JSContext* cx = nsContentUtils::ThreadJSContextStack()->GetSafeJSContext();
JSContext* cx = nsnull;
nsContentUtils::ThreadJSContextStack()->GetSafeJSContext(&cx);
if (cx) {
#ifdef DEBUG_smaug
printf("Will clear cached frame manager scripts!\n");

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

@ -949,6 +949,41 @@ nsGenericDOMDataNode::WalkContentStyleRules(nsRuleWalker* aRuleWalker)
return NS_OK;
}
nsIDOMCSSStyleDeclaration*
nsGenericDOMDataNode::GetSMILOverrideStyle()
{
return nsnull;
}
css::StyleRule*
nsGenericDOMDataNode::GetSMILOverrideStyleRule()
{
return nsnull;
}
nsresult
nsGenericDOMDataNode::SetSMILOverrideStyleRule(css::StyleRule* aStyleRule,
bool aNotify)
{
NS_NOTREACHED("How come we're setting SMILOverrideStyle on a non-element?");
return NS_ERROR_UNEXPECTED;
}
css::StyleRule*
nsGenericDOMDataNode::GetInlineStyleRule()
{
return nsnull;
}
NS_IMETHODIMP
nsGenericDOMDataNode::SetInlineStyleRule(css::StyleRule* aStyleRule,
const nsAString* aSerialized,
bool aNotify)
{
NS_NOTREACHED("How come we're setting inline style on a non-element?");
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP_(bool)
nsGenericDOMDataNode::IsAttributeMapped(const nsIAtom* aAttribute) const
{

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

@ -226,6 +226,15 @@ public:
virtual void DestroyContent();
virtual void SaveSubtreeState();
virtual nsISMILAttr* GetAnimatedAttr(PRInt32 /*aNamespaceID*/, nsIAtom* /*aName*/)
{
return nsnull;
}
virtual nsIDOMCSSStyleDeclaration* GetSMILOverrideStyle();
virtual mozilla::css::StyleRule* GetSMILOverrideStyleRule();
virtual nsresult SetSMILOverrideStyleRule(mozilla::css::StyleRule* aStyleRule,
bool aNotify);
#ifdef DEBUG
virtual void List(FILE* out, PRInt32 aIndent) const;
virtual void DumpContent(FILE* out, PRInt32 aIndent, bool aDumpAll) const;
@ -238,6 +247,9 @@ public:
virtual nsIAtom* DoGetID() const;
virtual const nsAttrValue* DoGetClasses() const;
NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker);
virtual mozilla::css::StyleRule* GetInlineStyleRule();
NS_IMETHOD SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule,
const nsAString* aSerialized, bool aNotify);
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
PRInt32 aModType) const;

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

@ -3610,7 +3610,7 @@ nsGenericElement::GetInlineStyleRule()
return nsnull;
}
nsresult
NS_IMETHODIMP
nsGenericElement::SetInlineStyleRule(css::StyleRule* aStyleRule,
const nsAString* aSerialized,
bool aNotify)

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

@ -368,9 +368,9 @@ public:
virtual const nsAttrValue* DoGetClasses() const;
NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker);
virtual mozilla::css::StyleRule* GetInlineStyleRule();
virtual nsresult SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule,
const nsAString* aSerialized,
bool aNotify);
NS_IMETHOD SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule,
const nsAString* aSerialized,
bool aNotify);
NS_IMETHOD_(bool)
IsAttributeMapped(const nsIAtom* aAttribute) const;
virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,

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

@ -161,7 +161,7 @@ nsStyledElementNotElementCSSInlineStyle::AfterSetAttr(PRInt32 aNamespaceID,
aNotify);
}
nsresult
NS_IMETHODIMP
nsStyledElementNotElementCSSInlineStyle::SetInlineStyleRule(css::StyleRule* aStyleRule,
const nsAString* aSerialized,
bool aNotify)

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

@ -74,9 +74,9 @@ public:
virtual const nsAttrValue* DoGetClasses() const;
virtual mozilla::css::StyleRule* GetInlineStyleRule();
virtual nsresult SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule,
const nsAString* aSerialized,
bool aNotify);
NS_IMETHOD SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule,
const nsAString* aSerialized,
bool aNotify);
virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
bool aNotify);

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

@ -134,7 +134,8 @@ nsEventListenerInfo::ToSource(nsAString& aResult)
nsCOMPtr<nsIThreadJSContextStack> stack =
nsContentUtils::ThreadJSContextStack();
if (stack) {
JSContext* cx = stack->GetSafeJSContext();
JSContext* cx = nsnull;
stack->GetSafeJSContext(&cx);
if (cx && NS_SUCCEEDED(stack->Push(cx))) {
{
// Extra block to finish the auto request before calling pop
@ -176,7 +177,8 @@ nsEventListenerInfo::GetDebugObject(nsISupports** aRetVal)
nsCOMPtr<nsIThreadJSContextStack> stack =
nsContentUtils::ThreadJSContextStack();
if (stack) {
JSContext* cx = stack->GetSafeJSContext();
JSContext* cx = nsnull;
stack->GetSafeJSContext(&cx);
if (cx && NS_SUCCEEDED(stack->Push(cx))) {
{
// Extra block to finish the auto request before calling pop

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

@ -124,7 +124,6 @@ public:
NS_FORWARD_NSIDOMNODE(nsDocument::)
// nsIDOMHTMLDocument interface
using nsDocument::GetPlugins;
NS_DECL_NSIDOMHTMLDOCUMENT
/**

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

@ -169,7 +169,6 @@
#include "nsIEditingSession.h"
#include "nsPIDOMWindow.h"
#include "nsGlobalWindow.h"
#include "nsPIWindowRoot.h"
#include "nsIDOMDocument.h"
#include "nsICachingChannel.h"
@ -10856,6 +10855,10 @@ nsDocShell::EnsureScriptEnvironment()
mInEnsureScriptEnv = true;
#endif
nsCOMPtr<nsIDOMScriptObjectFactory> factory =
do_GetService(kDOMScriptObjectFactoryCID);
NS_ENSURE_TRUE(factory, NS_ERROR_FAILURE);
nsCOMPtr<nsIWebBrowserChrome> browserChrome(do_GetInterface(mTreeOwner));
NS_ENSURE_TRUE(browserChrome, NS_ERROR_NOT_AVAILABLE);
@ -10868,15 +10871,20 @@ nsDocShell::EnsureScriptEnvironment()
// If our window is modal and we're not opened as chrome, make
// this window a modal content window.
nsRefPtr<nsGlobalWindow> window =
NS_NewScriptGlobalObject(mItemType == typeChrome, isModalContentWindow);
MOZ_ASSERT(window);
mScriptGlobal = window;
factory->NewScriptGlobalObject(mItemType == typeChrome,
isModalContentWindow,
getter_AddRefs(mScriptGlobal));
NS_ENSURE_TRUE(mScriptGlobal, NS_ERROR_FAILURE);
window->SetDocShell(this);
nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(mScriptGlobal));
win->SetDocShell(static_cast<nsIDocShell *>(this));
// Ensure the script object is set up to run script.
return mScriptGlobal->EnsureScriptEnvironment();
nsresult rv;
rv = mScriptGlobal->EnsureScriptEnvironment();
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}

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

@ -105,12 +105,7 @@ DIRS += \
bluetooth \
$(NULL)
endif
TEST_DIRS += \
tests \
imported-tests \
$(NULL)
TEST_DIRS += tests
ifneq (,$(filter gtk2 cocoa windows android qt os2,$(MOZ_WIDGET_TOOLKIT)))
TEST_DIRS += plugins/test
endif

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

@ -53,9 +53,7 @@
#include "jsdbgapi.h"
#include "WrapperFactory.h"
#include "AccessCheck.h"
#include "XrayWrapper.h"
#include "xpcpublic.h"
#include "xpcprivate.h"
#include "XPCWrapper.h"
@ -86,6 +84,8 @@
#include "nsIRunnable.h"
#include "nsThreadUtils.h"
#include "nsDOMEventTargetHelper.h"
#include "xpcprivate.h"
#include "XrayWrapper.h"
// General helper includes
#include "nsGlobalWindow.h"
@ -2418,8 +2418,10 @@ nsDOMClassInfo::Init()
do_GetService("@mozilla.org/js/xpc/ContextStack;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
JSContext* cx = stack->GetSafeJSContext();
NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);
JSContext *cx = nsnull;
rv = stack->GetSafeJSContext(&cx);
NS_ENSURE_SUCCESS(rv, rv);
DOM_CLASSINFO_MAP_BEGIN(Window, nsIDOMWindow)
DOM_CLASSINFO_WINDOW_MAP_ENTRIES(nsGlobalWindow::HasIndexedDBSupport())
@ -4922,7 +4924,8 @@ nsDOMClassInfo::PostCreatePrototype(JSContext * cx, JSObject * proto)
count++;
}
if (!xpc::DOM_DefineQuickStubs(cx, proto, flags, count, mData->mInterfaces)) {
if (!sXPConnect->DefineDOMQuickStubs(cx, proto, flags,
count, mData->mInterfaces)) {
JS_ClearPendingException(cx);
}
@ -5823,10 +5826,11 @@ DefineIDBInterfaceConstants(JSContext *cx, JSObject *obj, const nsIID *aIID)
const char* interface;
if (aIID->Equals(NS_GET_IID(nsIIDBCursor))) {
interface = IDBConstant::IDBCursor;
} else if (aIID->Equals(NS_GET_IID(nsIIDBRequest))) {
}
else if (aIID->Equals(NS_GET_IID(nsIIDBRequest))) {
interface = IDBConstant::IDBRequest;
} else {
MOZ_ASSERT(aIID->Equals(NS_GET_IID(nsIIDBTransaction)));
}
else if (aIID->Equals(NS_GET_IID(nsIIDBTransaction))) {
interface = IDBConstant::IDBTransaction;
}
@ -8775,9 +8779,9 @@ nsHTMLDocumentSH::DocumentAllGetProperty(JSContext *cx, JSObject *obj,
}
}
nsHTMLDocument* doc = GetDocument(obj);
nsISupports* result = nsnull;
nsWrapperCache* cache = nsnull;
nsHTMLDocument *doc = GetDocument(obj);
nsISupports *result;
nsWrapperCache *cache;
nsresult rv = NS_OK;
if (JSID_IS_STRING(id)) {
@ -9586,7 +9590,7 @@ public:
do_GetService("@mozilla.org/js/xpc/ContextStack;1");
NS_ENSURE_TRUE(stack, NS_OK);
cx = stack->GetSafeJSContext();
stack->GetSafeJSContext(&cx);
NS_ENSURE_TRUE(cx, NS_OK);
}

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

@ -71,7 +71,8 @@ static NS_DEFINE_CID(kDOMScriptObjectFactoryCID, NS_DOM_SCRIPT_OBJECT_FACTORY_CI
nsIExceptionProvider* gExceptionProvider = nsnull;
nsDOMScriptObjectFactory::nsDOMScriptObjectFactory()
nsDOMScriptObjectFactory::nsDOMScriptObjectFactory() :
mLoadedAllLanguages(false)
{
nsCOMPtr<nsIObserverService> observerService =
mozilla::services::GetObserverService();
@ -79,23 +80,26 @@ nsDOMScriptObjectFactory::nsDOMScriptObjectFactory()
observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
}
nsCOMPtr<nsIExceptionProvider> provider = new nsDOMExceptionProvider();
nsCOMPtr<nsIExceptionService> xs =
do_GetService(NS_EXCEPTIONSERVICE_CONTRACTID);
nsCOMPtr<nsIExceptionProvider> provider(new nsDOMExceptionProvider());
if (provider) {
nsCOMPtr<nsIExceptionService> xs =
do_GetService(NS_EXCEPTIONSERVICE_CONTRACTID);
if (xs) {
xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_DOM);
xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_SVG);
xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_DOM_XPATH);
xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_DOM_INDEXEDDB);
xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_XPCONNECT);
if (xs) {
xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_DOM);
xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_SVG);
xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_DOM_XPATH);
xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_DOM_INDEXEDDB);
xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_XPCONNECT);
xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_DOM_EVENTS);
}
NS_ASSERTION(!gExceptionProvider, "Registered twice?!");
provider.swap(gExceptionProvider);
}
NS_ASSERTION(!gExceptionProvider, "Registered twice?!");
provider.swap(gExceptionProvider);
// And pre-create the javascript language.
NS_CreateJSRuntime(getter_AddRefs(mJSRuntime));
NS_CreateJSRuntime(getter_AddRefs(mLanguageArray[NS_STID_INDEX(nsIProgrammingLanguage::JAVASCRIPT)]));
}
NS_INTERFACE_MAP_BEGIN(nsDOMScriptObjectFactory)
@ -108,6 +112,119 @@ NS_INTERFACE_MAP_END
NS_IMPL_ADDREF(nsDOMScriptObjectFactory)
NS_IMPL_RELEASE(nsDOMScriptObjectFactory)
/**
* Notes about language registration (for language other than js):
* - All language are expected to register (at least) 2 contract IDs
* @mozilla.org/script-language;1?id=%d
* using the language ID as defined in nsIProgrammingLanguage, and
* @mozilla.org/script-language;1?script-type=%s
* using the "mime-type" of the script language
*
* Theoretically, a language could register multiple script-type
* names, although this is discouraged - each language should have one,
* canonical name.
*
* The most common case is that languages are looked up by ID. For this
* reason, we keep an array of languages indexed by this ID - the registry
* is only looked the first request for a language ID.
*
* The registry is looked up and getService called for each query by name.
* (As services are cached by CID, multiple contractIDs will still work
* correctly)
**/
NS_IMETHODIMP
nsDOMScriptObjectFactory::GetScriptRuntime(const nsAString &aLanguageName,
nsIScriptRuntime **aLanguage)
{
// Note that many callers have optimized detection for JS (along with
// supporting various alternate names for JS), so don't call this.
// One exception is for the new "script-type" attribute on a node - and
// there is no need to support backwards compatible names.
// As JS is the default language, this is still rarely called for JS -
// only when a node explicitly sets JS - so that is done last.
nsCAutoString contractid(NS_LITERAL_CSTRING(
"@mozilla.org/script-language;1?script-type="));
// Arbitrarily use utf8 encoding should the name have extended chars
AppendUTF16toUTF8(aLanguageName, contractid);
nsresult rv;
nsCOMPtr<nsIScriptRuntime> lang =
do_GetService(contractid.get(), &rv);
if (NS_FAILED(rv)) {
if (aLanguageName.Equals(NS_LITERAL_STRING("application/javascript")))
return GetScriptRuntimeByID(nsIProgrammingLanguage::JAVASCRIPT, aLanguage);
// Not JS and nothing else we know about.
NS_WARNING("No script language registered for this mime-type");
return NS_ERROR_FACTORY_NOT_REGISTERED;
}
// And stash it away in our array for fast lookup by ID.
PRUint32 lang_ndx = NS_STID_INDEX(nsIProgrammingLanguage::JAVASCRIPT);
if (mLanguageArray[lang_ndx] == nsnull) {
mLanguageArray[lang_ndx] = lang;
} else {
// All languages are services - we should have an identical object!
NS_ASSERTION(mLanguageArray[lang_ndx] == lang,
"Got a different language for this ID???");
}
*aLanguage = lang;
NS_IF_ADDREF(*aLanguage);
return NS_OK;
}
NS_IMETHODIMP
nsDOMScriptObjectFactory::GetScriptRuntimeByID(PRUint32 aLanguageID,
nsIScriptRuntime **aLanguage)
{
if (!NS_STID_VALID(aLanguageID)) {
NS_WARNING("Unknown script language");
return NS_ERROR_UNEXPECTED;
}
*aLanguage = mLanguageArray[NS_STID_INDEX(aLanguageID)];
if (!*aLanguage) {
nsCAutoString contractid(NS_LITERAL_CSTRING(
"@mozilla.org/script-language;1?id="));
char langIdStr[25]; // space for an int.
sprintf(langIdStr, "%d", aLanguageID);
contractid += langIdStr;
nsresult rv;
nsCOMPtr<nsIScriptRuntime> lang = do_GetService(contractid.get(), &rv);
if (NS_FAILED(rv)) {
NS_ERROR("Failed to get the script language");
return rv;
}
// Stash it away in our array for fast lookup by ID.
mLanguageArray[NS_STID_INDEX(aLanguageID)] = lang;
*aLanguage = lang;
}
NS_IF_ADDREF(*aLanguage);
return NS_OK;
}
NS_IMETHODIMP
nsDOMScriptObjectFactory::GetIDForScriptType(const nsAString &aLanguageName,
PRUint32 *aScriptTypeID)
{
nsCOMPtr<nsIScriptRuntime> languageRuntime;
nsresult rv;
rv = GetScriptRuntime(aLanguageName, getter_AddRefs(languageRuntime));
if (NS_FAILED(rv))
return rv;
*aScriptTypeID = nsIProgrammingLanguage::JAVASCRIPT;
return NS_OK;
}
NS_IMETHODIMP
nsDOMScriptObjectFactory::NewScriptGlobalObject(bool aIsChrome,
bool aIsModalContentWindow,
nsIScriptGlobalObject **aGlobal)
{
return NS_NewScriptGlobalObject(aIsChrome, aIsModalContentWindow, aGlobal);
}
NS_IMETHODIMP_(nsISupports *)
nsDOMScriptObjectFactory::GetClassInfoInstance(nsDOMClassInfoID aID)
{
@ -174,6 +291,8 @@ nsDOMScriptObjectFactory::Observe(nsISupports *aSubject,
NS_ERROR_MODULE_DOM_XPATH);
xs->UnregisterExceptionProvider(gExceptionProvider,
NS_ERROR_MODULE_XPCONNECT);
xs->UnregisterExceptionProvider(gExceptionProvider,
NS_ERROR_MODULE_DOM_EVENTS);
}
NS_RELEASE(gExceptionProvider);
@ -200,7 +319,7 @@ CreateXPConnectException(nsresult aResult, nsIException *aDefaultException,
NS_ENSURE_SUCCESS(rv, rv);
}
exception.forget(_retval);
NS_ADDREF(*_retval = exception);
return NS_OK;
}
@ -225,42 +344,31 @@ nsDOMScriptObjectFactory::RegisterDOMClassInfo(const char *aName,
aConstructorCID);
}
// Factories
static nsresult
GetJSRuntime(nsIScriptRuntime** aLanguage)
{
nsCOMPtr<nsIDOMScriptObjectFactory> factory =
do_GetService(kDOMScriptObjectFactoryCID);
NS_ENSURE_TRUE(factory, NS_ERROR_FAILURE);
NS_IF_ADDREF(*aLanguage = factory->GetJSRuntime());
return NS_OK;
}
nsresult NS_GetScriptRuntime(const nsAString &aLanguageName,
nsIScriptRuntime **aLanguage)
{
*aLanguage = NULL;
NS_ENSURE_TRUE(aLanguageName.EqualsLiteral("application/javascript"),
NS_ERROR_FAILURE);
return GetJSRuntime(aLanguage);
nsresult rv;
*aLanguage = nsnull;
nsCOMPtr<nsIDOMScriptObjectFactory> factory = \
do_GetService(kDOMScriptObjectFactoryCID, &rv);
if (NS_FAILED(rv))
return rv;
return factory->GetScriptRuntime(aLanguageName, aLanguage);
}
nsresult NS_GetScriptRuntimeByID(PRUint32 aScriptTypeID,
nsIScriptRuntime **aLanguage)
{
*aLanguage = NULL;
NS_ENSURE_TRUE(aScriptTypeID == nsIProgrammingLanguage::JAVASCRIPT,
NS_ERROR_FAILURE);
return GetJSRuntime(aLanguage);
nsresult rv;
*aLanguage = nsnull;
nsCOMPtr<nsIDOMScriptObjectFactory> factory = \
do_GetService(kDOMScriptObjectFactoryCID, &rv);
if (NS_FAILED(rv))
return rv;
return factory->GetScriptRuntimeByID(aScriptTypeID, aLanguage);
}
NS_IMPL_THREADSAFE_ISUPPORTS1(nsDOMExceptionProvider, nsIExceptionProvider)
NS_IMETHODIMP

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

@ -68,6 +68,19 @@ public:
NS_DECL_NSIOBSERVER
// nsIDOMScriptObjectFactory
NS_IMETHOD GetScriptRuntime(const nsAString &aLanguageName,
nsIScriptRuntime **aLanguage);
NS_IMETHOD GetScriptRuntimeByID(PRUint32 aLanguageID,
nsIScriptRuntime **aLanguage);
NS_IMETHOD GetIDForScriptType(const nsAString &aLanguageName,
PRUint32 *aLanguageID);
NS_IMETHOD NewScriptGlobalObject(bool aIsChrome,
bool aIsModalContentWindow,
nsIScriptGlobalObject **aGlobal);
NS_IMETHOD_(nsISupports *) GetClassInfoInstance(nsDOMClassInfoID aID);
NS_IMETHOD_(nsISupports *) GetExternalClassInfoInstance(const nsAString& aName);
@ -78,6 +91,10 @@ public:
PRUint32 aScriptableFlags,
bool aHasClassInterface,
const nsCID *aConstructorCID);
protected:
bool mLoadedAllLanguages;
nsCOMPtr<nsIScriptRuntime> mLanguageArray[NS_STID_ARRAY_UBOUND];
};
class nsDOMExceptionProvider : public nsIExceptionProvider

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

@ -886,6 +886,7 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalWindow *aOuterWindow)
mTimeoutPublicIdCounter(1),
mTimeoutFiringDepth(0),
mJSObject(nsnull),
mPendingStorageEventsObsolete(nsnull),
mTimeoutsSuspendDepth(0),
mFocusMethod(0),
mSerial(0),
@ -920,9 +921,10 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalWindow *aOuterWindow)
os->AddObserver(mObserver, NS_IOSERVICE_OFFLINE_STATUS_TOPIC,
false);
// Watch for dom-storage2-changed so we can fire storage
// Watch for dom-storage-changed so we can fire storage
// events. Use a strong reference.
os->AddObserver(mObserver, "dom-storage2-changed", false);
os->AddObserver(mObserver, "dom-storage-changed", false);
}
}
} else {
@ -1201,6 +1203,7 @@ nsGlobalWindow::CleanUp(bool aIgnoreModalDialog)
if (os) {
os->RemoveObserver(mObserver, NS_IOSERVICE_OFFLINE_STATUS_TOPIC);
os->RemoveObserver(mObserver, "dom-storage2-changed");
os->RemoveObserver(mObserver, "dom-storage-changed");
}
// Drop its reference to this dying window, in case for some bogus reason
@ -1223,6 +1226,7 @@ nsGlobalWindow::CleanUp(bool aIgnoreModalDialog)
mWindowUtils = nsnull;
mApplicationCache = nsnull;
mIndexedDB = nsnull;
mPendingStorageEventsObsolete = nsnull;
mPerformance = nsnull;
@ -6195,7 +6199,7 @@ PostMessageEvent::Run()
// we need to find a JSContext.
nsIThreadJSContextStack* cxStack = nsContentUtils::ThreadJSContextStack();
if (cxStack) {
cx = cxStack->GetSafeJSContext();
cxStack->GetSafeJSContext(&cx);
}
if (!cx) {
@ -8471,6 +8475,76 @@ nsGlobalWindow::Observe(nsISupports* aSubject, const char* aTopic,
return NS_OK;
}
if (IsInnerWindow() && !nsCRT::strcmp(aTopic, "dom-storage-changed")) {
nsIPrincipal *principal;
nsresult rv;
principal = GetPrincipal();
if (principal) {
// A global storage object changed, check to see if it's one
// this window can access.
nsCOMPtr<nsIURI> codebase;
principal->GetURI(getter_AddRefs(codebase));
if (!codebase) {
return NS_OK;
}
nsCAutoString currentDomain;
rv = codebase->GetAsciiHost(currentDomain);
if (NS_FAILED(rv)) {
return NS_OK;
}
}
nsAutoString domain(aData);
if (IsFrozen()) {
// This window is frozen, rather than firing the events here,
// store the domain in which the change happened and fire the
// events if we're ever thawed.
if (!mPendingStorageEventsObsolete) {
mPendingStorageEventsObsolete = new nsDataHashtable<nsStringHashKey, bool>;
NS_ENSURE_TRUE(mPendingStorageEventsObsolete, NS_ERROR_OUT_OF_MEMORY);
rv = mPendingStorageEventsObsolete->Init();
NS_ENSURE_SUCCESS(rv, rv);
}
mPendingStorageEventsObsolete->Put(domain, true);
return NS_OK;
}
nsRefPtr<nsDOMStorageEventObsolete> event = new nsDOMStorageEventObsolete();
NS_ENSURE_TRUE(event, NS_ERROR_OUT_OF_MEMORY);
rv = event->InitStorageEvent(NS_LITERAL_STRING("storage"), false, false, domain);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc(do_QueryInterface(mDocument));
nsCOMPtr<nsIDOMEventTarget> target;
if (htmlDoc) {
nsCOMPtr<nsIDOMHTMLElement> body;
htmlDoc->GetBody(getter_AddRefs(body));
target = do_QueryInterface(body);
}
if (!target) {
target = this;
}
bool defaultActionEnabled;
target->DispatchEvent((nsIDOMStorageEventObsolete *)event, &defaultActionEnabled);
return NS_OK;
}
if (IsInnerWindow() && !nsCRT::strcmp(aTopic, "dom-storage2-changed")) {
nsIPrincipal *principal;
nsresult rv;
@ -8624,6 +8698,22 @@ nsGlobalWindow::CloneStorageEvent(const nsAString& aType,
url, storageArea);
}
static PLDHashOperator
FirePendingStorageEvents(const nsAString& aKey, bool aData, void *userArg)
{
nsGlobalWindow *win = static_cast<nsGlobalWindow *>(userArg);
nsCOMPtr<nsIDOMStorage> storage;
win->GetSessionStorage(getter_AddRefs(storage));
if (storage) {
win->Observe(storage, "dom-storage-changed",
aKey.IsEmpty() ? nsnull : PromiseFlatString(aKey).get());
}
return PL_DHASH_NEXT;
}
nsresult
nsGlobalWindow::FireDelayedDOMEvents()
{
@ -8633,6 +8723,12 @@ nsGlobalWindow::FireDelayedDOMEvents()
Observe(mPendingStorageEvents[i], "dom-storage2-changed", nsnull);
}
if (mPendingStorageEventsObsolete) {
// Fire pending storage events.
mPendingStorageEventsObsolete->EnumerateRead(FirePendingStorageEvents, this);
mPendingStorageEventsObsolete = nsnull;
}
if (mApplicationCache) {
static_cast<nsDOMOfflineResourceList*>(mApplicationCache.get())->FirePendingEvents();
}
@ -9251,7 +9347,7 @@ nsGlobalWindow::RunTimeout(nsTimeout *aTimeout)
++mTimeoutFiringDepth;
bool trackNestingLevel = !timeout->mIsInterval;
PRUint32 nestingLevel = 0;
PRUint32 nestingLevel;
if (trackNestingLevel) {
nestingLevel = sNestingLevel;
sNestingLevel = timeout->mNestingLevel;
@ -9969,9 +10065,8 @@ nsGlobalWindow::SuspendTimeouts(PRUint32 aIncrease,
if (!suspended) {
nsCOMPtr<nsIDeviceSensors> ac = do_GetService(NS_DEVICE_SENSORS_CONTRACTID);
if (ac) {
for (PRUint32 i = 0; i < mEnabledSensors.Length(); i++) {
for (int i = 0; i < mEnabledSensors.Length(); i++)
ac->RemoveWindowListener(mEnabledSensors[i], this);
}
}
// Suspend all of the workers for this window.
@ -10050,9 +10145,8 @@ nsGlobalWindow::ResumeTimeouts(bool aThawChildren)
if (shouldResume) {
nsCOMPtr<nsIDeviceSensors> ac = do_GetService(NS_DEVICE_SENSORS_CONTRACTID);
if (ac) {
for (PRUint32 i = 0; i < mEnabledSensors.Length(); i++) {
for (int i = 0; i < mEnabledSensors.Length(); i++)
ac->AddWindowListener(mEnabledSensors[i], this);
}
}
// Resume all of the workers for this window.
@ -10159,7 +10253,7 @@ void
nsGlobalWindow::EnableDeviceSensor(PRUint32 aType)
{
bool alreadyEnabled = false;
for (PRUint32 i = 0; i < mEnabledSensors.Length(); i++) {
for (int i = 0; i < mEnabledSensors.Length(); i++) {
if (mEnabledSensors[i] == aType) {
alreadyEnabled = true;
break;
@ -10179,8 +10273,8 @@ nsGlobalWindow::EnableDeviceSensor(PRUint32 aType)
void
nsGlobalWindow::DisableDeviceSensor(PRUint32 aType)
{
PRInt32 doomedElement = -1;
for (PRUint32 i = 0; i < mEnabledSensors.Length(); i++) {
PRUint32 doomedElement = -1;
for (int i = 0; i < mEnabledSensors.Length(); i++) {
if (mEnabledSensors[i] == aType) {
doomedElement = i;
break;
@ -10646,6 +10740,33 @@ nsGlobalWindow::SetHasAudioAvailableEventListeners()
}
}
//*****************************************************************************
// nsGlobalWindow: Creator Function (This should go away)
//*****************************************************************************
nsresult
NS_NewScriptGlobalObject(bool aIsChrome, bool aIsModalContentWindow,
nsIScriptGlobalObject **aResult)
{
*aResult = nsnull;
nsGlobalWindow *global;
if (aIsChrome) {
global = new nsGlobalChromeWindow(nsnull);
} else if (aIsModalContentWindow) {
global = new nsGlobalModalWindow(nsnull);
} else {
global = new nsGlobalWindow(nsnull);
}
NS_ENSURE_TRUE(global, NS_ERROR_OUT_OF_MEMORY);
NS_ADDREF(*aResult = global);
return NS_OK;
}
#define EVENT(name_, id_, type_, struct_) \
NS_IMETHODIMP nsGlobalWindow::GetOn##name_(JSContext *cx, \
jsval *vp) { \

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

@ -939,6 +939,7 @@ protected:
typedef nsCOMArray<nsIDOMStorageEvent> nsDOMStorageEventArray;
nsDOMStorageEventArray mPendingStorageEvents;
nsAutoPtr< nsDataHashtable<nsStringHashKey, bool> > mPendingStorageEventsObsolete;
PRUint32 mTimeoutsSuspendDepth;
@ -1057,20 +1058,8 @@ protected:
};
/* factory function */
inline already_AddRefed<nsGlobalWindow>
NS_NewScriptGlobalObject(bool aIsChrome, bool aIsModalContentWindow)
{
nsRefPtr<nsGlobalWindow> global;
if (aIsChrome) {
global = new nsGlobalChromeWindow(nsnull);
} else if (aIsModalContentWindow) {
global = new nsGlobalModalWindow(nsnull);
} else {
global = new nsGlobalWindow(nsnull);
}
return global.forget();
}
nsresult
NS_NewScriptGlobalObject(bool aIsChrome, bool aIsModalContentWindow,
nsIScriptGlobalObject **aResult);
#endif /* nsGlobalWindow_h___ */

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

@ -41,14 +41,14 @@
#include "nsISupports.h"
#include "nsIDOMClassInfo.h"
#include "nsStringGlue.h"
#include "nsIScriptRuntime.h"
#define NS_IDOM_SCRIPT_OBJECT_FACTORY_IID \
{ 0x2a50e17c, 0x46ff, 0x4150, \
{ 0xbb, 0x46, 0xd8, 0x07, 0xb3, 0x36, 0xde, 0xab } }
#define NS_IDOM_SCRIPT_OBJECT_FACTORY_IID \
{ 0x8c0eb687, 0xa859, 0x4a62, \
{ 0x99, 0x82, 0xea, 0xbf, 0x9e, 0xf5, 0x59, 0x5f } }
class nsIScriptContext;
class nsIScriptGlobalObject;
class nsIScriptRuntime;
class nsIDOMEventListener;
typedef nsXPCClassInfo* (*nsDOMClassInfoExternalConstructorFnc)
@ -58,6 +58,27 @@ class nsIDOMScriptObjectFactory : public nsISupports {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOM_SCRIPT_OBJECT_FACTORY_IID)
// Get a script language given its "name" (ie, the mime-type)
// Note that to fetch javascript from this function, you must currently
// use the name "application/javascript" (but also note that all existing
// callers of this function optimize the detection of JS, so do not
// ask this function for JS)
NS_IMETHOD GetScriptRuntime(const nsAString &aLanguageName,
nsIScriptRuntime **aLanguage) = 0;
// Get a script language given its nsIProgrammingLanguage ID.
NS_IMETHOD GetScriptRuntimeByID(PRUint32 aScriptTypeID,
nsIScriptRuntime **aLanguage) = 0;
// Get the ID for a language given its name - but like GetScriptRuntime,
// only "application/javascript" is currently supported for JS.
NS_IMETHOD GetIDForScriptType(const nsAString &aLanguageName,
PRUint32 *aScriptTypeID) = 0;
NS_IMETHOD NewScriptGlobalObject(bool aIsChrome,
bool aIsModalContentWindow,
nsIScriptGlobalObject **aGlobal) = 0;
NS_IMETHOD_(nsISupports *) GetClassInfoInstance(nsDOMClassInfoID aID) = 0;
NS_IMETHOD_(nsISupports *) GetExternalClassInfoInstance(const nsAString& aName) = 0;
@ -73,14 +94,6 @@ public:
PRUint32 aScriptableFlags,
bool aHasClassInterface,
const nsCID *aConstructorCID) = 0;
nsIScriptRuntime* GetJSRuntime()
{
return mJSRuntime;
}
protected:
nsCOMPtr<nsIScriptRuntime> mJSRuntime;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIDOMScriptObjectFactory,

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

@ -1324,13 +1324,13 @@ def getArgumentConversionTemplate(type, descriptor):
elif tag is IDLType.Tags.int64:
# XXXbz this may not match what WebIDL says to do in terms of reducing
# mod 2^64. Should we check?
replacements["jstype"] = "int64_t"
replacements["converter"] = "xpc::ValueToInt64"
replacements["jstype"] = "PRInt64"
replacements["converter"] = "xpc_qsValueToInt64"
elif tag is IDLType.Tags.uint64:
# XXXbz this may not match what WebIDL says to do in terms of reducing
# mod 2^64. Should we check?
replacements["jstype"] = "uint64_t"
replacements["converter"] = "xpc::ValueToUint64"
replacements["jstype"] = "PRUint64"
replacements["converter"] = "xpc_qsValueToUint64"
elif tag in [IDLType.Tags.float, IDLType.Tags.double]:
replacements["jstype"] = "double"
replacements["converter"] = "JS::ToNumber"

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

@ -134,8 +134,7 @@ IDBRequest::NotifyHelperCompleted(HelperBase* aHelper)
nsIThreadJSContextStack* cxStack = nsContentUtils::ThreadJSContextStack();
NS_ASSERTION(cxStack, "Failed to get thread context stack!");
cx = cxStack->GetSafeJSContext();
if (!cx) {
if (NS_FAILED(cxStack->GetSafeJSContext(&cx))) {
NS_WARNING("Failed to get safe JSContext!");
rv = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
mError = DOMError::CreateForNSResult(rv);

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

@ -47,9 +47,10 @@ class nsIDOMStorageObsolete;
class nsIURI;
class nsIPrincipal;
#define NS_PIDOMSTORAGE_IID \
{ 0x86dfe3c4, 0x4286, 0x4648, \
{ 0xb2, 0x09, 0x55, 0x27, 0x50, 0x59, 0x26, 0xac } }
// {BAFFCEB1-FD40-4ea9-8378-3509DD79204A}
#define NS_PIDOMSTORAGE_IID \
{ 0xbaffceb1, 0xfd40, 0x4ea9, \
{ 0x83, 0x78, 0x35, 0x9, 0xdd, 0x79, 0x20, 0x4a } }
class nsPIDOMStorage : public nsISupports
{
@ -75,6 +76,10 @@ public:
virtual bool CanAccess(nsIPrincipal *aPrincipal) = 0;
virtual nsDOMStorageType StorageType() = 0;
virtual void BroadcastChangeNotification(const nsSubstring &aKey,
const nsSubstring &aOldValue,
const nsSubstring &aNewValue) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsPIDOMStorage, NS_PIDOMSTORAGE_IID)

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

@ -42,10 +42,6 @@
[scriptable, uuid(E3CD8269-9502-4E70-910C-0D6D71B22253)]
interface nsIDOMXULMultiSelectControlElement : nsIDOMXULSelectControlElement
{
%{C++
using nsIDOMXULSelectControlElement::GetSelectedItem;
%}
attribute DOMString selType;
attribute nsIDOMXULSelectControlItemElement currentItem;

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

@ -432,7 +432,7 @@ ContentParent::ContentParent()
nsCString buildID(gAppData->buildID);
//Sending all information to content process
unused << SendAppInfo(version, buildID);
SendAppInfo(version, buildID);
}
}
@ -718,10 +718,10 @@ ContentParent::Observe(nsISupports* aSubject,
unused << SendPMemoryReportRequestConstructor();
}
else if (!strcmp(aTopic, "child-gc-request")){
unused << SendGarbageCollect();
SendGarbageCollect();
}
else if (!strcmp(aTopic, "child-cc-request")){
unused << SendCycleCollect();
SendCycleCollect();
}
#ifdef ACCESSIBILITY
// Make sure accessibility is running in content process when accessibility

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

@ -152,7 +152,7 @@ CrashReporterParent::GenerateChildData(const AnnotationTable* processNotes)
mNotes.Put(NS_LITERAL_CSTRING("ProcessType"), type);
char startTime[32];
sprintf(startTime, "%lld", static_cast<long long>(mStartTime));
sprintf(startTime, "%lld", static_cast<PRInt64>(mStartTime));
mNotes.Put(NS_LITERAL_CSTRING("StartupTime"), nsDependentCString(startTime));
if (!mAppNotes.IsEmpty())

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

@ -1985,7 +1985,8 @@ nsJSNPRuntime::OnPluginDestroy(NPP npp)
return;
}
JSContext* cx = stack->GetSafeJSContext();
JSContext *cx;
stack->GetSafeJSContext(&cx);
if (!cx) {
NS_ERROR("No safe JS context available!");

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

@ -1348,10 +1348,10 @@ _getstringidentifier(const NPUTF8* name)
if (!stack)
return NULL;
JSContext* cx = stack->GetSafeJSContext();
if (!cx) {
JSContext *cx = nsnull;
stack->GetSafeJSContext(&cx);
if (!cx)
return NULL;
}
JSAutoRequest ar(cx);
return doGetIdentifier(cx, name);
@ -1369,10 +1369,10 @@ _getstringidentifiers(const NPUTF8** names, int32_t nameCount,
if (!stack)
return;
JSContext* cx = stack->GetSafeJSContext();
if (!cx) {
JSContext *cx = nsnull;
stack->GetSafeJSContext(&cx);
if (!cx)
return;
}
JSAutoRequest ar(cx);

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

@ -69,7 +69,8 @@ PluginIdentifierParent::RecvRetain()
return false;
}
JSContext* cx = stack->GetSafeJSContext();
JSContext *cx = nsnull;
stack->GetSafeJSContext(&cx);
if (!cx) {
return false;
}

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

@ -41,7 +41,6 @@
#include "mozilla/plugins/PPluginInstanceParent.h"
#include "mozilla/plugins/PluginScriptableObjectParent.h"
#include "mozilla/unused.h"
#if defined(OS_WIN)
#include "mozilla/gfx/SharedDIBWin.h"
#elif defined(MOZ_WIDGET_COCOA)
@ -306,10 +305,7 @@ public:
nsresult HandleGUIEvent(const nsGUIEvent& anEvent, bool* handled);
#endif
void DidComposite()
{
unused << SendNPP_DidComposite();
}
void DidComposite() { SendNPP_DidComposite(); }
private:
// Create an appropriate platform surface for a background of size

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

@ -588,7 +588,7 @@ PluginModuleParent::AnswerNPN_UserAgent(nsCString* userAgent)
PluginIdentifierParent*
PluginModuleParent::GetIdentifierForNPIdentifier(NPP npp, NPIdentifier aIdentifier)
{
PluginIdentifierParent* ident = nsnull;
PluginIdentifierParent* ident;
if (mIdentifiers.Get(aIdentifier, &ident)) {
if (ident->IsTemporary()) {
ident->AddTemporaryRef();

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

@ -1742,6 +1742,25 @@ nsDOMStorage::StorageType()
return mStorageType;
}
void
nsDOMStorage::BroadcastChangeNotification(const nsSubstring &aKey,
const nsSubstring &aOldValue,
const nsSubstring &aNewValue)
{
nsCOMPtr<nsIObserverService> observerService =
mozilla::services::GetObserverService();
if (!observerService) {
return;
}
// Fire off a notification that a storage object changed. If the
// storage object is a session storage object, we don't pass a
// domain, but if it's a global storage object we do.
observerService->NotifyObservers((nsIDOMStorageObsolete *)this,
"dom-storage-changed",
NS_ConvertUTF8toUTF16(mStorageImpl->mDomain).get());
}
//
// nsDOMStorage2
//
@ -1906,8 +1925,8 @@ StorageNotifierRunnable::Run()
void
nsDOMStorage2::BroadcastChangeNotification(const nsSubstring &aKey,
const nsSubstring &aOldValue,
const nsSubstring &aNewValue)
const nsSubstring &aOldValue,
const nsSubstring &aNewValue)
{
nsresult rv;
nsCOMPtr<nsIDOMStorageEvent> event = new nsDOMStorageEvent();

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

@ -339,8 +339,6 @@ private:
nsDOMStorage* mOwner;
};
class nsDOMStorage2;
class nsDOMStorage : public nsIDOMStorageObsolete,
public nsPIDOMStorage
{
@ -368,6 +366,9 @@ public:
virtual nsIPrincipal* Principal();
virtual bool CanAccess(nsIPrincipal *aPrincipal);
virtual nsDOMStorageType StorageType();
virtual void BroadcastChangeNotification(const nsSubstring &aKey,
const nsSubstring &aOldValue,
const nsSubstring &aNewValue);
// Check whether storage may be used by the caller, and whether it
// is session only. Returns true if storage may be used.
@ -418,7 +419,7 @@ public:
friend class nsIDOMStorage2;
nsCOMPtr<nsIPrincipal> mPrincipal;
nsDOMStorage2* mEventBroadcaster;
nsPIDOMStorage* mEventBroadcaster;
};
class nsDOMStorage2 : public nsIDOMStorage,
@ -444,10 +445,10 @@ public:
virtual nsIPrincipal* Principal();
virtual bool CanAccess(nsIPrincipal *aPrincipal);
virtual nsDOMStorageType StorageType();
virtual void BroadcastChangeNotification(const nsSubstring &aKey,
const nsSubstring &aOldValue,
const nsSubstring &aNewValue);
void BroadcastChangeNotification(const nsSubstring &aKey,
const nsSubstring &aOldValue,
const nsSubstring &aNewValue);
nsresult InitAsSessionStorageFork(nsIPrincipal *aPrincipal,
const nsSubstring &aDocumentURI,
nsIDOMStorageObsolete* aStorage);

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

@ -216,15 +216,16 @@ SystemWorkerManager::Init()
NS_ASSERTION(NS_IsMainThread(), "We can only initialize on the main thread");
NS_ASSERTION(!mShutdown, "Already shutdown!");
JSContext* cx = nsContentUtils::ThreadJSContextStack()->GetSafeJSContext();
NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);
JSContext *cx;
nsresult rv = nsContentUtils::ThreadJSContextStack()->GetSafeJSContext(&cx);
NS_ENSURE_SUCCESS(rv, rv);
nsCxPusher pusher;
if (!pusher.Push(cx, false)) {
if (!cx || !pusher.Push(cx, false)) {
return NS_ERROR_FAILURE;
}
nsresult rv = InitRIL(cx);
rv = InitRIL(cx);
NS_ENSURE_SUCCESS(rv, rv);
rv = InitWifi(cx);

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

@ -58,6 +58,7 @@ DIRS += \
sessionstorage \
storageevent \
pointerlock \
w3c \
browser-frame \
$(NULL)

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

@ -2,11 +2,11 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
DEPTH = ../..
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = dom/imported-tests
relativesrcdir = dom/tests/mochitest/w3c
DIRS = \
$(NULL)
@ -24,7 +24,7 @@ _SUPPORT_FILES = \
WebIDLParser.js \
$(NULL)
testharnessreport.js: testharnessreport.js.in writeReporter.py html.json webapps.json
testharnessreport.js: testharnessreport.js.in writeReporter.py
$(PYTHON_PATH) $(srcdir)/writeReporter.py $<
libs:: $(_SUPPORT_FILES)

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

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

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

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

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

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

@ -1,11 +1,11 @@
# THIS FILE IS AUTOGENERATED BY importTestsuite.py - DO NOT EDIT
# THIS FILE IS AUTOGENERATED - DO NOT EDIT
DEPTH = ../../../../../..
DEPTH = ../../../../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = dom/imported-tests/html/tests/submission/Mozilla
relativesrcdir = dom/tests/mochitest/w3c/html/tests/submission/Mozilla
DIRS = \
$(NULL)

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

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

@ -53,12 +53,11 @@ def copy(thissrcdir, dest, directories):
print "Copying %s..." % (directories, )
for d in directories:
dirtocreate = dest
os.makedirs(d)
subdirs, mochitests, supportfiles = parseManifestFile(dest, d)
sourcedir = "hg-%s/%s" % (dest, d)
destdir = "%s/%s" % (dest, d)
os.makedirs(destdir)
for mochitest in mochitests:
shutil.copy("%s/%s" % (sourcedir, mochitest), "%s/test_%s" % (destdir, mochitest))
for support in supportfiles:
@ -140,9 +139,9 @@ def printMakefiles(thissrcdir, dest, directories):
def hgadd(dest, directories):
"""Inform hg of the files in |directories|."""
print "hg addremoving..."
print "hg adding..."
for d in directories:
subprocess.check_call(["hg", "addremove", "%s/%s" % (dest, d)])
subprocess.check_call(["hg", "add", "%s/%s" % (dest, d)])
def importDirs(thissrcdir, dest, directories):
copy(thissrcdir, dest, directories)
@ -171,7 +170,7 @@ def importRepo(confFile, thissrcdir):
print "Done"
if __name__ == "__main__":
if len(sys.argv) != 2:
if len(sys.argv) == 2:
print "Need one argument."
else:
importRepo(sys.argv[1], "dom/imported-tests")
importRepo(sys.argv[1], "dom/tests/mochitest/w3c")

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

@ -38,7 +38,7 @@ var W3CTest = {
* directory. Used as a key into the expectedFailures dictionary.
*/
"getURL": function() {
return this.runner.currentTestURL.substring("/tests/dom/imported-tests/".length);
return this.runner.currentTestURL.substring("/tests/dom/tests/mochitest/w3c/".length);
},
/**

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

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

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

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

@ -1,11 +1,11 @@
# THIS FILE IS AUTOGENERATED BY importTestsuite.py - DO NOT EDIT
# THIS FILE IS AUTOGENERATED - DO NOT EDIT
DEPTH = ../../../../../../..
DEPTH = ../../../../../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = dom/imported-tests/webapps/DOMCore/tests/submissions/Opera
relativesrcdir = dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera
DIRS = \
$(NULL)

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

@ -77,6 +77,7 @@ USING_WORKERS_NAMESPACE
using mozilla::MutexAutoLock;
using mozilla::MutexAutoUnlock;
using mozilla::Preferences;
using namespace mozilla::xpconnect::memory;
// The size of the worker runtime heaps in bytes. May be changed via pref.
#define WORKER_DEFAULT_RUNTIME_HEAPSIZE 32 * 1024 * 1024
@ -1336,8 +1337,8 @@ RuntimeService::AutoSafeJSContext::GetSafeContext()
nsIThreadJSContextStack* stack = nsContentUtils::ThreadJSContextStack();
NS_ASSERTION(stack, "This should never be null!");
JSContext* cx = stack->GetSafeJSContext();
if (!cx) {
JSContext* cx;
if (NS_FAILED(stack->GetSafeJSContext(&cx))) {
NS_ERROR("Couldn't get safe JSContext!");
return nsnull;
}

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

@ -100,6 +100,7 @@ using mozilla::MutexAutoLock;
using mozilla::TimeDuration;
using mozilla::TimeStamp;
using mozilla::dom::workers::exceptions::ThrowDOMExceptionForCode;
using mozilla::xpconnect::memory::ReportJSRuntimeExplicitTreeStats;
USING_WORKERS_NAMESPACE
using namespace mozilla::dom::workers::events;
@ -262,8 +263,12 @@ public:
// Always report, even if we're disabled, so that we at least get an entry
// in about::memory.
return xpc::ReportJSRuntimeExplicitTreeStats(rtStats, mPathPrefix,
aCallback, aClosure);
rv = ReportJSRuntimeExplicitTreeStats(rtStats, mPathPrefix, aCallback, aClosure);
if (NS_FAILED(rv)) {
return rv;
}
return NS_OK;
}
NS_IMETHOD

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

@ -59,10 +59,11 @@
#include "nsCRT.h"
//prototype
nsresult GetListState(nsIHTMLEditor* aEditor, bool* aMixed,
nsAString& aLocalName);
nsresult RemoveOneProperty(nsIHTMLEditor* aEditor, const nsAString& aProp);
nsresult RemoveTextProperty(nsIHTMLEditor* aEditor, const nsAString& aProp);
nsresult GetListState(nsIEditor *aEditor, bool *aMixed, PRUnichar **tagStr);
nsresult RemoveOneProperty(nsIHTMLEditor *aEditor,const nsString& aProp,
const nsString &aAttr);
nsresult RemoveTextProperty(nsIEditor *aEditor, const PRUnichar *prop,
const PRUnichar *attr);
nsresult SetTextProperty(nsIEditor *aEditor, const PRUnichar *prop,
const PRUnichar *attr, const PRUnichar *value);
@ -263,26 +264,34 @@ nsStyleUpdatingCommand::ToggleState(nsIEditor *aEditor, const char* aTagName)
if (doTagRemoval) {
// Also remove equivalent properties (bug 317093)
if (tagName.EqualsLiteral("b")) {
rv = RemoveTextProperty(htmlEditor, NS_LITERAL_STRING("strong"));
rv = RemoveTextProperty(aEditor, NS_LITERAL_STRING("strong").get(), nsnull);
NS_ENSURE_SUCCESS(rv, rv);
} else if (tagName.EqualsLiteral("i")) {
rv = RemoveTextProperty(htmlEditor, NS_LITERAL_STRING("em"));
rv = RemoveTextProperty(aEditor, NS_LITERAL_STRING("em").get(), nsnull);
NS_ENSURE_SUCCESS(rv, rv);
} else if (tagName.EqualsLiteral("strike")) {
rv = RemoveTextProperty(htmlEditor, NS_LITERAL_STRING("s"));
rv = RemoveTextProperty(aEditor, NS_LITERAL_STRING("s").get(), nsnull);
NS_ENSURE_SUCCESS(rv, rv);
}
rv = RemoveTextProperty(htmlEditor, tagName);
rv = RemoveTextProperty(aEditor, tagName.get(), nsnull);
} else {
// Superscript and Subscript styles are mutually exclusive
nsAutoString removeName;
aEditor->BeginTransaction();
if (tagName.EqualsLiteral("sub") || tagName.EqualsLiteral("sup")) {
rv = RemoveTextProperty(htmlEditor, tagName);
if (tagName.EqualsLiteral("sub"))
{
removeName.AssignLiteral("sup");
rv = RemoveTextProperty(aEditor,tagName.get(), nsnull);
}
else if (tagName.EqualsLiteral("sup"))
{
removeName.AssignLiteral("sub");
rv = RemoveTextProperty(aEditor, tagName.get(), nsnull);
}
if (NS_SUCCEEDED(rv))
rv = SetTextProperty(aEditor, tagName.get(), nsnull, nsnull);
rv = SetTextProperty(aEditor,tagName.get(), nsnull, nsnull);
aEditor->EndTransaction();
}
@ -300,19 +309,19 @@ nsListCommand::GetCurrentState(nsIEditor *aEditor, const char* aTagName,
nsICommandParams *aParams)
{
NS_ASSERTION(aEditor, "Need editor here");
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);
NS_ENSURE_TRUE(htmlEditor, NS_ERROR_NO_INTERFACE);
bool bMixed;
nsAutoString localName;
nsresult rv = GetListState(htmlEditor, &bMixed, localName);
PRUnichar *tagStr;
nsresult rv = GetListState(aEditor,&bMixed, &tagStr);
NS_ENSURE_SUCCESS(rv, rv);
// Need to use mTagName????
bool inList = localName.EqualsASCII(mTagName);
bool inList = (0 == nsCRT::strcmp(tagStr,
NS_ConvertASCIItoUTF16(mTagName).get()));
aParams->SetBooleanValue(STATE_ALL, !bMixed && inList);
aParams->SetBooleanValue(STATE_MIXED, bMixed);
aParams->SetBooleanValue(STATE_ENABLED, true);
if (tagStr) NS_Free(tagStr);
return NS_OK;
}
@ -395,24 +404,33 @@ nsListItemCommand::ToggleState(nsIEditor *aEditor, const char* aTagName)
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_SUCCESS(rv, rv);
if (inList) {
if (inList)
{
// To remove a list, first get what kind of list we're in
bool bMixed;
nsAutoString localName;
rv = GetListState(htmlEditor, &bMixed, localName);
PRUnichar *tagStr;
rv = GetListState(aEditor,&bMixed, &tagStr);
NS_ENSURE_SUCCESS(rv, rv);
if (localName.IsEmpty() || bMixed) {
return rv;
if (tagStr)
{
if (!bMixed)
{
rv = htmlEditor->RemoveList(nsDependentString(tagStr));
}
NS_Free(tagStr);
}
return htmlEditor->RemoveList(localName);
}
nsAutoString itemType; itemType.AssignWithConversion(mTagName);
// Set to the requested paragraph type
//XXX Note: This actually doesn't work for "LI",
// but we currently don't use this for non DL lists anyway.
// Problem: won't this replace any current block paragraph style?
return htmlEditor->SetParagraphFormat(itemType);
else
{
nsAutoString itemType; itemType.AssignWithConversion(mTagName);
// Set to the requested paragraph type
//XXX Note: This actually doesn't work for "LI",
// but we currently don't use this for non DL lists anyway.
// Problem: won't this replace any current block paragraph style?
rv = htmlEditor->SetParagraphFormat(itemType);
}
return rv;
}
NS_IMETHODIMP
@ -420,27 +438,28 @@ nsRemoveListCommand::IsCommandEnabled(const char * aCommandName,
nsISupports *refCon,
bool *outCmdEnabled)
{
*outCmdEnabled = false;
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
NS_ENSURE_TRUE(editor, NS_OK);
if (editor)
{
bool isEditable = false;
nsresult rv = editor->GetIsSelectionEditable(&isEditable);
NS_ENSURE_SUCCESS(rv, rv);
if (isEditable)
{
// It is enabled if we are in any list type
bool bMixed;
PRUnichar *tagStr;
nsresult rv = GetListState(editor, &bMixed, &tagStr);
NS_ENSURE_SUCCESS(rv, rv);
bool isEditable = false;
nsresult rv = editor->GetIsSelectionEditable(&isEditable);
NS_ENSURE_SUCCESS(rv, rv);
if (!isEditable) {
return NS_OK;
*outCmdEnabled = bMixed ? true : (tagStr && *tagStr);
if (tagStr) NS_Free(tagStr);
return NS_OK;
}
}
// It is enabled if we are in any list type
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(refCon);
NS_ENSURE_TRUE(htmlEditor, NS_ERROR_NO_INTERFACE);
bool bMixed;
nsAutoString localName;
rv = GetListState(htmlEditor, &bMixed, localName);
NS_ENSURE_SUCCESS(rv, rv);
*outCmdEnabled = bMixed || !localName.IsEmpty();
*outCmdEnabled = false;
return NS_OK;
}
@ -1533,57 +1552,79 @@ nsInsertTagCommand::GetCommandStateParams(const char *aCommandName,
/****************************/
nsresult
GetListState(nsIHTMLEditor* aEditor, bool* aMixed, nsAString& aLocalName)
GetListState(nsIEditor *aEditor, bool *aMixed, PRUnichar **_retval)
{
MOZ_ASSERT(aEditor);
MOZ_ASSERT(aMixed);
NS_ENSURE_TRUE(aMixed && _retval && aEditor, NS_ERROR_NULL_POINTER);
*_retval = nsnull;
*aMixed = false;
aLocalName.Truncate();
bool bOL, bUL, bDL;
nsresult rv = aEditor->GetListState(aMixed, &bOL, &bUL, &bDL);
NS_ENSURE_SUCCESS(rv, rv);
if (*aMixed) {
return NS_OK;
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);
nsresult err = NS_ERROR_NO_INTERFACE;
if (htmlEditor)
{
bool bOL, bUL, bDL;
err = htmlEditor->GetListState(aMixed, &bOL, &bUL, &bDL);
if (NS_SUCCEEDED(err))
{
if (!*aMixed)
{
nsAutoString tagStr;
if (bOL)
tagStr.AssignLiteral("ol");
else if (bUL)
tagStr.AssignLiteral("ul");
else if (bDL)
tagStr.AssignLiteral("dl");
*_retval = ToNewUnicode(tagStr);
}
}
}
if (bOL) {
aLocalName.AssignLiteral("ol");
} else if (bUL) {
aLocalName.AssignLiteral("ul");
} else if (bDL) {
aLocalName.AssignLiteral("dl");
}
return NS_OK;
return err;
}
nsresult
RemoveOneProperty(nsIHTMLEditor* aEditor, const nsAString& aProp)
RemoveOneProperty(nsIHTMLEditor *aEditor,const nsString& aProp,
const nsString &aAttr)
{
MOZ_ASSERT(aEditor);
NS_ENSURE_TRUE(aEditor, NS_ERROR_NOT_INITIALIZED);
/// XXX Hack alert! Look in nsIEditProperty.h for this
nsCOMPtr<nsIAtom> styleAtom = do_GetAtom(aProp);
NS_ENSURE_TRUE(styleAtom, NS_ERROR_OUT_OF_MEMORY);
NS_ENSURE_TRUE( styleAtom, NS_ERROR_OUT_OF_MEMORY);
return aEditor->RemoveInlineProperty(styleAtom, EmptyString());
return aEditor->RemoveInlineProperty(styleAtom, aAttr);
}
// the name of the attribute here should be the contents of the appropriate
// tag, e.g. 'b' for bold, 'i' for italics.
nsresult
RemoveTextProperty(nsIHTMLEditor* aEditor, const nsAString& aProp)
RemoveTextProperty(nsIEditor *aEditor, const PRUnichar *prop,
const PRUnichar *attr)
{
MOZ_ASSERT(aEditor);
NS_ENSURE_TRUE(aEditor, NS_ERROR_NOT_INITIALIZED);
nsCOMPtr<nsIHTMLEditor> editor = do_QueryInterface(aEditor);
NS_ENSURE_TRUE(editor, NS_ERROR_INVALID_ARG);
// OK, I'm really hacking now. This is just so that
// we can accept 'all' as input.
nsAutoString allStr(prop);
ToLowerCase(allStr);
bool doingAll = (allStr.EqualsLiteral("all"));
nsresult err = NS_OK;
if (aProp.LowerCaseEqualsLiteral("all")) {
return aEditor->RemoveAllInlineProperties();
if (doingAll)
{
err = editor->RemoveAllInlineProperties();
}
else
{
nsAutoString aProp(prop);
nsAutoString aAttr(attr);
err = RemoveOneProperty(editor,aProp, aAttr);
}
return RemoveOneProperty(aEditor, aProp);
return err;
}
// the name of the attribute here should be the contents of the appropriate

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

@ -685,41 +685,41 @@ nsHTMLEditRules::GetListState(bool *aMixed, bool *aOL, bool *aUL, bool *aDL)
nsresult res = GetListActionNodes(arrayOfNodes, false, true);
NS_ENSURE_SUCCESS(res, res);
// Examine list type for nodes in selection.
// examine list type for nodes in selection
PRInt32 listCount = arrayOfNodes.Count();
for (PRInt32 i = listCount - 1; i >= 0; --i) {
nsIDOMNode* curDOMNode = arrayOfNodes[i];
nsCOMPtr<dom::Element> curElement = do_QueryInterface(curDOMNode);
if (!curElement) {
bNonList = true;
} else if (curElement->IsHTML(nsGkAtoms::ul)) {
PRInt32 i;
for (i=listCount-1; i>=0; i--)
{
nsIDOMNode* curNode = arrayOfNodes[i];
if (nsHTMLEditUtils::IsUnorderedList(curNode))
*aUL = true;
} else if (curElement->IsHTML(nsGkAtoms::ol)) {
else if (nsHTMLEditUtils::IsOrderedList(curNode))
*aOL = true;
} else if (curElement->IsHTML(nsGkAtoms::li)) {
if (nsINode* parent = curElement->GetElementParent()) {
if (parent->AsElement()->IsHTML(nsGkAtoms::ul)) {
*aUL = true;
} else if (parent->AsElement()->IsHTML(nsGkAtoms::ol)) {
*aOL = true;
}
}
} else if (curElement->IsHTML(nsGkAtoms::dl) ||
curElement->IsHTML(nsGkAtoms::dt) ||
curElement->IsHTML(nsGkAtoms::dd)) {
*aDL = true;
} else {
bNonList = true;
else if (nsEditor::NodeIsType(curNode, nsEditProperty::li))
{
nsCOMPtr<nsIDOMNode> parent;
PRInt32 offset;
res = nsEditor::GetNodeLocation(curNode, address_of(parent), &offset);
NS_ENSURE_SUCCESS(res, res);
if (nsHTMLEditUtils::IsUnorderedList(parent))
*aUL = true;
else if (nsHTMLEditUtils::IsOrderedList(parent))
*aOL = true;
}
else if (nsEditor::NodeIsType(curNode, nsEditProperty::dl) ||
nsEditor::NodeIsType(curNode, nsEditProperty::dt) ||
nsEditor::NodeIsType(curNode, nsEditProperty::dd) )
{
*aDL = true;
}
else bNonList = true;
}
// hokey arithmetic with booleans
if ((*aUL + *aOL + *aDL + bNonList) > 1) {
*aMixed = true;
}
return NS_OK;
if ( (*aUL + *aOL + *aDL + bNonList) > 1) *aMixed = true;
return res;
}
nsresult

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

@ -4209,30 +4209,29 @@ nsHTMLEditor::RemoveBlockContainer(nsIDOMNode *inNode)
// GetPriorHTMLSibling: returns the previous editable sibling, if there is
// one within the parent
//
nsINode*
nsHTMLEditor::GetPriorHTMLSibling(nsINode* aNode)
{
MOZ_ASSERT(aNode);
nsIContent* node = aNode->GetPreviousSibling();
while (node && !IsEditable(node)) {
node = node->GetPreviousSibling();
}
return node;
}
nsresult
nsHTMLEditor::GetPriorHTMLSibling(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode)
{
NS_ENSURE_TRUE(outNode, NS_ERROR_NULL_POINTER);
*outNode = NULL;
nsCOMPtr<nsINode> node = do_QueryInterface(inNode);
NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
*outNode = do_QueryInterface(GetPriorHTMLSibling(node));
return NS_OK;
NS_ENSURE_TRUE(outNode && inNode, NS_ERROR_NULL_POINTER);
nsresult res = NS_OK;
*outNode = nsnull;
nsCOMPtr<nsIDOMNode> temp, node = do_QueryInterface(inNode);
while (1)
{
res = node->GetPreviousSibling(getter_AddRefs(temp));
NS_ENSURE_SUCCESS(res, res);
if (!temp) {
// return null sibling
return NS_OK;
}
// if it's editable, we're done
if (IsEditable(temp)) break;
// otherwise try again
node = temp;
}
*outNode = temp;
return res;
}
@ -4242,30 +4241,23 @@ nsHTMLEditor::GetPriorHTMLSibling(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outN
// one within the parent. just like above routine but
// takes a parent/offset instead of a node.
//
nsINode*
nsHTMLEditor::GetPriorHTMLSibling(nsINode* aParent, PRInt32 aOffset)
{
MOZ_ASSERT(aParent);
nsIContent* node = aParent->GetChildAt(aOffset - 1);
if (!node || IsEditable(node)) {
return node;
}
return GetPriorHTMLSibling(node);
}
nsresult
nsHTMLEditor::GetPriorHTMLSibling(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outNode)
{
NS_ENSURE_TRUE(outNode, NS_ERROR_NULL_POINTER);
*outNode = NULL;
nsCOMPtr<nsINode> parent = do_QueryInterface(inParent);
NS_ENSURE_TRUE(parent, NS_ERROR_NULL_POINTER);
*outNode = do_QueryInterface(GetPriorHTMLSibling(parent, inOffset));
return NS_OK;
NS_ENSURE_TRUE(outNode && inParent, NS_ERROR_NULL_POINTER);
nsresult res = NS_OK;
*outNode = nsnull;
if (inOffset <= 0) {
// return null sibling if at offset zero
return NS_OK;
}
nsCOMPtr<nsIDOMNode> node = nsEditor::GetChildAt(inParent,inOffset-1);
if (node && IsEditable(node)) {
*outNode = node;
return res;
}
// else
return GetPriorHTMLSibling(node, outNode);
}
@ -4274,30 +4266,29 @@ nsHTMLEditor::GetPriorHTMLSibling(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMP
// GetNextHTMLSibling: returns the next editable sibling, if there is
// one within the parent
//
nsINode*
nsHTMLEditor::GetNextHTMLSibling(nsINode* aNode)
{
MOZ_ASSERT(aNode);
nsIContent* node = aNode->GetNextSibling();
while (node && !IsEditable(node)) {
node = node->GetNextSibling();
}
return node;
}
nsresult
nsHTMLEditor::GetNextHTMLSibling(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode)
{
NS_ENSURE_TRUE(outNode, NS_ERROR_NULL_POINTER);
nsresult res = NS_OK;
*outNode = nsnull;
nsCOMPtr<nsINode> node = do_QueryInterface(inNode);
NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMNode> temp, node = do_QueryInterface(inNode);
*outNode = do_QueryInterface(GetNextHTMLSibling(node));
return NS_OK;
while (1)
{
res = node->GetNextSibling(getter_AddRefs(temp));
NS_ENSURE_SUCCESS(res, res);
if (!temp) {
// return null sibling
return NS_OK;
}
// if it's editable, we're done
if (IsEditable(temp)) break;
// otherwise try again
node = temp;
}
*outNode = temp;
return res;
}
@ -4306,30 +4297,24 @@ nsHTMLEditor::GetNextHTMLSibling(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNo
// GetNextHTMLSibling: returns the next editable sibling, if there is
// one within the parent. just like above routine but
// takes a parent/offset instead of a node.
nsINode*
nsHTMLEditor::GetNextHTMLSibling(nsINode* aParent, PRInt32 aOffset)
{
MOZ_ASSERT(aParent);
nsIContent* node = aParent->GetChildAt(aOffset + 1);
if (!node || IsEditable(node)) {
return node;
}
return GetNextHTMLSibling(node);
}
//
nsresult
nsHTMLEditor::GetNextHTMLSibling(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outNode)
{
NS_ENSURE_TRUE(outNode, NS_ERROR_NULL_POINTER);
*outNode = NULL;
nsCOMPtr<nsINode> parent = do_QueryInterface(inParent);
NS_ENSURE_TRUE(parent, NS_ERROR_NULL_POINTER);
*outNode = do_QueryInterface(GetNextHTMLSibling(parent, inOffset));
return NS_OK;
NS_ENSURE_TRUE(outNode && inParent, NS_ERROR_NULL_POINTER);
nsresult res = NS_OK;
*outNode = nsnull;
nsCOMPtr<nsIDOMNode> node = nsEditor::GetChildAt(inParent, inOffset + 1);
if (!node) {
// return null sibling if no sibling
return NS_OK;
}
if (node && IsEditable(node)) {
*outNode = node;
return res;
}
// else
return GetNextHTMLSibling(node, outNode);
}

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

@ -720,13 +720,9 @@ protected:
bool IsOnlyAttribute(nsIDOMNode *aElement, const nsAString *aAttribute);
nsresult RemoveBlockContainer(nsIDOMNode *inNode);
nsINode* GetPriorHTMLSibling(nsINode* aNode);
nsresult GetPriorHTMLSibling(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode);
nsINode* GetPriorHTMLSibling(nsINode* aParent, PRInt32 aOffset);
nsresult GetPriorHTMLSibling(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outNode);
nsINode* GetNextHTMLSibling(nsINode* aNode);
nsresult GetNextHTMLSibling(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode);
nsINode* GetNextHTMLSibling(nsINode* aParent, PRInt32 aOffset);
nsresult GetNextHTMLSibling(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outNode);
nsresult GetPriorHTMLNode(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode, bool bNoBlockCrossing = false);
nsresult GetPriorHTMLNode(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outNode, bool bNoBlockCrossing = false);

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

@ -306,10 +306,10 @@ nsresult JSContextAutoPopper::Push(JSContext *cx)
return NS_ERROR_FAILURE;
mService = do_GetService(sJSStackContractID);
if (mService) {
if(mService) {
// Get the safe context if we're not provided one.
if (!cx) {
cx = mService->GetSafeJSContext();
if (!cx && NS_FAILED(mService->GetSafeJSContext(&cx))) {
cx = nsnull;
}
// Save cx in mContext to indicate need to pop.

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

@ -94,7 +94,7 @@ struct ScopedXFreePtrTraits
static T *empty() { return NULL; }
static void release(T *ptr) { if (ptr!=NULL) XFree(ptr); }
};
SCOPED_TEMPLATE(ScopedXFree, ScopedXFreePtrTraits)
SCOPED_TEMPLATE(ScopedXFree, ScopedXFreePtrTraits);
/**
* On construction, set a graceful X error handler that doesn't crash the application and records X errors.

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

@ -1015,8 +1015,6 @@ struct JSContext : js::ContextFriendFields
js::LifoAlloc &tempLifoAlloc() { return runtime->tempLifoAlloc; }
inline js::LifoAlloc &typeLifoAlloc();
inline js::PropertyTree &propertyTree();
#ifdef JS_THREADSAFE
unsigned outstandingRequests;/* number of JS_BeginRequest calls
without the corresponding

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

@ -505,12 +505,6 @@ JSContext::ensureParseMapPool()
return parseMapPool_;
}
inline js::PropertyTree&
JSContext::propertyTree()
{
return compartment->propertyTree;
}
/* Get the current frame, first lazily instantiating stack frames if needed. */
static inline js::StackFrame *
js_GetTopStackFrame(JSContext *cx, FrameExpandKind expand)

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

@ -471,6 +471,8 @@ struct JSCompartment
js::DebugScriptMap *debugScriptMap;
};
#define JS_PROPERTY_TREE(cx) ((cx)->compartment->propertyTree)
namespace js {
static inline MathCache *
GetMathCache(JSContext *cx)

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

@ -87,7 +87,6 @@
#include "jsarrayinlines.h"
#include "jsatominlines.h"
#include "jscntxtinlines.h"
#include "jsinterpinlines.h"
#include "jsobjinlines.h"
#include "jsscopeinlines.h"
@ -2546,9 +2545,9 @@ JSObject::sealOrFreeze(JSContext *cx, ImmutabilityType it)
if (!JSID_IS_EMPTY(child.propid))
MarkTypePropertyConfigured(cx, self, child.propid);
last = cx->propertyTree().getChild(cx, last, self->numFixedSlots(), child);
last = JS_PROPERTY_TREE(cx).getChild(cx, last, self->numFixedSlots(), child);
if (!last)
return false;
return NULL;
}
JS_ASSERT(self->lastProperty()->slotSpan() == last->slotSpan());

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