diff --git a/accessible/src/generic/FormControlAccessible.cpp b/accessible/src/generic/FormControlAccessible.cpp index 2915d964ee0a..ce1ff2cc2f3b 100644 --- a/accessible/src/generic/FormControlAccessible.cpp +++ b/accessible/src/generic/FormControlAccessible.cpp @@ -119,13 +119,13 @@ ProgressMeterAccessible::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) ? diff --git a/accessible/src/html/nsHTMLImageAccessible.cpp b/accessible/src/html/nsHTMLImageAccessible.cpp index 3325c49f3987..4057fb2732fc 100644 --- a/accessible/src/html/nsHTMLImageAccessible.cpp +++ b/accessible/src/html/nsHTMLImageAccessible.cpp @@ -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 = diff --git a/caps/src/nsScriptSecurityManager.cpp b/caps/src/nsScriptSecurityManager.cpp index 91ca5ac203dc..f7e10baeb9ea 100644 --- a/caps/src/nsScriptSecurityManager.cpp +++ b/caps/src/nsScriptSecurityManager.cpp @@ -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 */ diff --git a/content/base/public/Element.h b/content/base/public/Element.h index a24fae03e450..5d0f0e408c70 100644 --- a/content/base/public/Element.h +++ b/content/base/public/Element.h @@ -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 diff --git a/content/base/public/nsContentUtils.h b/content/base/public/nsContentUtils.h index e958223c28d1..142687c93caa 100644 --- a/content/base/public/nsContentUtils.h +++ b/content/base/public/nsContentUtils.h @@ -395,6 +395,9 @@ public: static PRUint32 CopyNewlineNormalizedUnicodeTo(nsReadingIterator& aSrcStart, const nsReadingIterator& aSrcEnd, nsAString& aDest); + static nsISupports * + GetClassInfoInstance(nsDOMClassInfoID aID); + static const nsDependentSubstring TrimCharsInSet(const char* aSet, const nsAString& aValue); diff --git a/content/base/public/nsIContent.h b/content/base/public/nsIContent.h index 4ab761748c6a..0900eb587501 100644 --- a/content/base/public/nsIContent.h +++ b/content/base/public/nsIContent.h @@ -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; diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index 88ec78c1ee73..ab779086d6d6 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -1623,7 +1623,8 @@ nsContentUtils::TraceSafeJSContext(JSTracer* aTrc) if (!sThreadJSContextStack) { return; } - JSContext* cx = sThreadJSContextStack->GetSafeJSContext(); + JSContext* cx = nsnull; + sThreadJSContextStack->GetSafeJSContext(&cx); if (!cx) { return; } diff --git a/content/base/src/nsDOMFileReader.h b/content/base/src/nsDOMFileReader.h index 23b97ea0fb28..78e29813e512 100644 --- a/content/base/src/nsDOMFileReader.h +++ b/content/base/src/nsDOMFileReader.h @@ -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 diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 5d5bf4f83f72..44fe870f8ef4 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -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 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 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 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 element = do_QueryInterface(aRadio); - NS_ASSERTION(element, "radio controls have to be content elements"); - if (element->HasAttr(kNameSpaceID_None, nsGkAtoms::required)) { - radioGroup->mRequiredRadioCount++; + nsCOMPtr 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 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 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; diff --git a/content/base/src/nsDocument.h b/content/base/src/nsDocument.h index 5a8fadf6baa2..1e252fc02ec1 100644 --- a/content/base/src/nsDocument.h +++ b/content/base/src/nsDocument.h @@ -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 diff --git a/content/base/src/nsFrameMessageManager.cpp b/content/base/src/nsFrameMessageManager.cpp index 8d42c627f0ed..1b7765849f4f 100644 --- a/content/base/src/nsFrameMessageManager.cpp +++ b/content/base/src/nsFrameMessageManager.cpp @@ -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 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"); diff --git a/content/base/src/nsGenericDOMDataNode.cpp b/content/base/src/nsGenericDOMDataNode.cpp index bdd9114c22df..8310fb50ca04 100644 --- a/content/base/src/nsGenericDOMDataNode.cpp +++ b/content/base/src/nsGenericDOMDataNode.cpp @@ -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 { diff --git a/content/base/src/nsGenericDOMDataNode.h b/content/base/src/nsGenericDOMDataNode.h index 1225277afc23..60be35625ed8 100644 --- a/content/base/src/nsGenericDOMDataNode.h +++ b/content/base/src/nsGenericDOMDataNode.h @@ -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; diff --git a/content/base/src/nsGenericElement.cpp b/content/base/src/nsGenericElement.cpp index 4a36c64d6d49..ec0820b718e6 100644 --- a/content/base/src/nsGenericElement.cpp +++ b/content/base/src/nsGenericElement.cpp @@ -3610,7 +3610,7 @@ nsGenericElement::GetInlineStyleRule() return nsnull; } -nsresult +NS_IMETHODIMP nsGenericElement::SetInlineStyleRule(css::StyleRule* aStyleRule, const nsAString* aSerialized, bool aNotify) diff --git a/content/base/src/nsGenericElement.h b/content/base/src/nsGenericElement.h index 9c43b44f4e4b..b8b3adcae136 100644 --- a/content/base/src/nsGenericElement.h +++ b/content/base/src/nsGenericElement.h @@ -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, diff --git a/content/base/src/nsStyledElement.cpp b/content/base/src/nsStyledElement.cpp index 655e88da419c..90850146c542 100644 --- a/content/base/src/nsStyledElement.cpp +++ b/content/base/src/nsStyledElement.cpp @@ -161,7 +161,7 @@ nsStyledElementNotElementCSSInlineStyle::AfterSetAttr(PRInt32 aNamespaceID, aNotify); } -nsresult +NS_IMETHODIMP nsStyledElementNotElementCSSInlineStyle::SetInlineStyleRule(css::StyleRule* aStyleRule, const nsAString* aSerialized, bool aNotify) diff --git a/content/base/src/nsStyledElement.h b/content/base/src/nsStyledElement.h index f65be3d9e65c..d4f4daeac135 100644 --- a/content/base/src/nsStyledElement.h +++ b/content/base/src/nsStyledElement.h @@ -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); diff --git a/content/events/src/nsEventListenerService.cpp b/content/events/src/nsEventListenerService.cpp index 672e0a2d5c38..cfc75bfd241f 100644 --- a/content/events/src/nsEventListenerService.cpp +++ b/content/events/src/nsEventListenerService.cpp @@ -134,7 +134,8 @@ nsEventListenerInfo::ToSource(nsAString& aResult) nsCOMPtr 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 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 diff --git a/content/html/document/src/nsHTMLDocument.h b/content/html/document/src/nsHTMLDocument.h index 4ceac9c8cbc2..732f384c8c10 100644 --- a/content/html/document/src/nsHTMLDocument.h +++ b/content/html/document/src/nsHTMLDocument.h @@ -124,7 +124,6 @@ public: NS_FORWARD_NSIDOMNODE(nsDocument::) // nsIDOMHTMLDocument interface - using nsDocument::GetPlugins; NS_DECL_NSIDOMHTMLDOCUMENT /** diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 29c52895443d..b8a0d43ec273 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -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 factory = + do_GetService(kDOMScriptObjectFactoryCID); + NS_ENSURE_TRUE(factory, NS_ERROR_FAILURE); + nsCOMPtr 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 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 win(do_QueryInterface(mScriptGlobal)); + win->SetDocShell(static_cast(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; } diff --git a/dom/Makefile.in b/dom/Makefile.in index cc8cdfd594d4..cbd083df86b8 100644 --- a/dom/Makefile.in +++ b/dom/Makefile.in @@ -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 diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index a50d782b1ce5..3472c751fa58 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -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); } diff --git a/dom/base/nsDOMScriptObjectFactory.cpp b/dom/base/nsDOMScriptObjectFactory.cpp index 61c03fe9d680..e48575a18dc9 100644 --- a/dom/base/nsDOMScriptObjectFactory.cpp +++ b/dom/base/nsDOMScriptObjectFactory.cpp @@ -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 observerService = mozilla::services::GetObserverService(); @@ -79,23 +80,26 @@ nsDOMScriptObjectFactory::nsDOMScriptObjectFactory() observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false); } - nsCOMPtr provider = new nsDOMExceptionProvider(); - nsCOMPtr xs = - do_GetService(NS_EXCEPTIONSERVICE_CONTRACTID); + nsCOMPtr provider(new nsDOMExceptionProvider()); + if (provider) { + nsCOMPtr 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 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 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 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 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 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 factory = \ + do_GetService(kDOMScriptObjectFactoryCID, &rv); + if (NS_FAILED(rv)) + return rv; + return factory->GetScriptRuntimeByID(aScriptTypeID, aLanguage); } - NS_IMPL_THREADSAFE_ISUPPORTS1(nsDOMExceptionProvider, nsIExceptionProvider) NS_IMETHODIMP diff --git a/dom/base/nsDOMScriptObjectFactory.h b/dom/base/nsDOMScriptObjectFactory.h index 5fb4033140d9..bc90aafb1809 100644 --- a/dom/base/nsDOMScriptObjectFactory.h +++ b/dom/base/nsDOMScriptObjectFactory.h @@ -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 mLanguageArray[NS_STID_ARRAY_UBOUND]; }; class nsDOMExceptionProvider : public nsIExceptionProvider diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index ec5224051516..971a569ef901 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -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 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; + 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 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 htmlDoc(do_QueryInterface(mDocument)); + + nsCOMPtr target; + + if (htmlDoc) { + nsCOMPtr 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(userArg); + + nsCOMPtr 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(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 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 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) { \ diff --git a/dom/base/nsGlobalWindow.h b/dom/base/nsGlobalWindow.h index 890c9bee72c9..24c975cd3333 100644 --- a/dom/base/nsGlobalWindow.h +++ b/dom/base/nsGlobalWindow.h @@ -939,6 +939,7 @@ protected: typedef nsCOMArray nsDOMStorageEventArray; nsDOMStorageEventArray mPendingStorageEvents; + nsAutoPtr< nsDataHashtable > mPendingStorageEventsObsolete; PRUint32 mTimeoutsSuspendDepth; @@ -1057,20 +1058,8 @@ protected: }; /* factory function */ -inline already_AddRefed -NS_NewScriptGlobalObject(bool aIsChrome, bool aIsModalContentWindow) -{ - nsRefPtr 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___ */ diff --git a/dom/base/nsIDOMScriptObjectFactory.h b/dom/base/nsIDOMScriptObjectFactory.h index bf375aa71ee6..d6b52f669f59 100644 --- a/dom/base/nsIDOMScriptObjectFactory.h +++ b/dom/base/nsIDOMScriptObjectFactory.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 mJSRuntime; }; NS_DEFINE_STATIC_IID_ACCESSOR(nsIDOMScriptObjectFactory, diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index ad58169c7385..eb5e68f68037 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -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" diff --git a/dom/indexedDB/IDBRequest.cpp b/dom/indexedDB/IDBRequest.cpp index b9fb46388fbc..c7a22468c7d0 100644 --- a/dom/indexedDB/IDBRequest.cpp +++ b/dom/indexedDB/IDBRequest.cpp @@ -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); diff --git a/dom/interfaces/storage/nsPIDOMStorage.h b/dom/interfaces/storage/nsPIDOMStorage.h index 280e9ec6da2d..64b3c0b38cda 100644 --- a/dom/interfaces/storage/nsPIDOMStorage.h +++ b/dom/interfaces/storage/nsPIDOMStorage.h @@ -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) diff --git a/dom/interfaces/xul/nsIDOMXULMultSelectCntrlEl.idl b/dom/interfaces/xul/nsIDOMXULMultSelectCntrlEl.idl index 9f53e06e23c3..43342921230e 100644 --- a/dom/interfaces/xul/nsIDOMXULMultSelectCntrlEl.idl +++ b/dom/interfaces/xul/nsIDOMXULMultSelectCntrlEl.idl @@ -42,10 +42,6 @@ [scriptable, uuid(E3CD8269-9502-4E70-910C-0D6D71B22253)] interface nsIDOMXULMultiSelectControlElement : nsIDOMXULSelectControlElement { -%{C++ - using nsIDOMXULSelectControlElement::GetSelectedItem; -%} - attribute DOMString selType; attribute nsIDOMXULSelectControlItemElement currentItem; diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 77b4fbc8628d..9cb6405a0e88 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -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 diff --git a/dom/ipc/CrashReporterParent.cpp b/dom/ipc/CrashReporterParent.cpp index d3cc3463ce6b..0530591bc978 100644 --- a/dom/ipc/CrashReporterParent.cpp +++ b/dom/ipc/CrashReporterParent.cpp @@ -152,7 +152,7 @@ CrashReporterParent::GenerateChildData(const AnnotationTable* processNotes) mNotes.Put(NS_LITERAL_CSTRING("ProcessType"), type); char startTime[32]; - sprintf(startTime, "%lld", static_cast(mStartTime)); + sprintf(startTime, "%lld", static_cast(mStartTime)); mNotes.Put(NS_LITERAL_CSTRING("StartupTime"), nsDependentCString(startTime)); if (!mAppNotes.IsEmpty()) diff --git a/dom/plugins/base/nsJSNPRuntime.cpp b/dom/plugins/base/nsJSNPRuntime.cpp index 309835e215a7..ed5404c69034 100644 --- a/dom/plugins/base/nsJSNPRuntime.cpp +++ b/dom/plugins/base/nsJSNPRuntime.cpp @@ -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!"); diff --git a/dom/plugins/base/nsNPAPIPlugin.cpp b/dom/plugins/base/nsNPAPIPlugin.cpp index 227d0952f3ba..8923e0b6dc90 100644 --- a/dom/plugins/base/nsNPAPIPlugin.cpp +++ b/dom/plugins/base/nsNPAPIPlugin.cpp @@ -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); diff --git a/dom/plugins/ipc/PluginIdentifierParent.cpp b/dom/plugins/ipc/PluginIdentifierParent.cpp index f459a6803061..f423dc15db8a 100644 --- a/dom/plugins/ipc/PluginIdentifierParent.cpp +++ b/dom/plugins/ipc/PluginIdentifierParent.cpp @@ -69,7 +69,8 @@ PluginIdentifierParent::RecvRetain() return false; } - JSContext* cx = stack->GetSafeJSContext(); + JSContext *cx = nsnull; + stack->GetSafeJSContext(&cx); if (!cx) { return false; } diff --git a/dom/plugins/ipc/PluginInstanceParent.h b/dom/plugins/ipc/PluginInstanceParent.h index bffba20ee326..c864fe89ceb5 100644 --- a/dom/plugins/ipc/PluginInstanceParent.h +++ b/dom/plugins/ipc/PluginInstanceParent.h @@ -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 diff --git a/dom/plugins/ipc/PluginModuleParent.cpp b/dom/plugins/ipc/PluginModuleParent.cpp index 7b4980359849..97da101ca040 100644 --- a/dom/plugins/ipc/PluginModuleParent.cpp +++ b/dom/plugins/ipc/PluginModuleParent.cpp @@ -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(); diff --git a/dom/src/storage/nsDOMStorage.cpp b/dom/src/storage/nsDOMStorage.cpp index 781bcbe1bac3..09de92348d11 100644 --- a/dom/src/storage/nsDOMStorage.cpp +++ b/dom/src/storage/nsDOMStorage.cpp @@ -1742,6 +1742,25 @@ nsDOMStorage::StorageType() return mStorageType; } +void +nsDOMStorage::BroadcastChangeNotification(const nsSubstring &aKey, + const nsSubstring &aOldValue, + const nsSubstring &aNewValue) +{ + nsCOMPtr 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 event = new nsDOMStorageEvent(); diff --git a/dom/src/storage/nsDOMStorage.h b/dom/src/storage/nsDOMStorage.h index 16e9907d0a64..4ac4736672f6 100644 --- a/dom/src/storage/nsDOMStorage.h +++ b/dom/src/storage/nsDOMStorage.h @@ -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 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); diff --git a/dom/system/gonk/SystemWorkerManager.cpp b/dom/system/gonk/SystemWorkerManager.cpp index bb71da3127ed..ad3d015c1a19 100644 --- a/dom/system/gonk/SystemWorkerManager.cpp +++ b/dom/system/gonk/SystemWorkerManager.cpp @@ -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); diff --git a/dom/tests/mochitest/Makefile.in b/dom/tests/mochitest/Makefile.in index 98db102b7b9c..3c299898baaa 100644 --- a/dom/tests/mochitest/Makefile.in +++ b/dom/tests/mochitest/Makefile.in @@ -58,6 +58,7 @@ DIRS += \ sessionstorage \ storageevent \ pointerlock \ + w3c \ browser-frame \ $(NULL) diff --git a/dom/imported-tests/Makefile.in b/dom/tests/mochitest/w3c/Makefile.in similarity index 83% rename from dom/imported-tests/Makefile.in rename to dom/tests/mochitest/w3c/Makefile.in index f0f7710e3b94..d07245841ef5 100644 --- a/dom/imported-tests/Makefile.in +++ b/dom/tests/mochitest/w3c/Makefile.in @@ -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) diff --git a/dom/imported-tests/README b/dom/tests/mochitest/w3c/README similarity index 100% rename from dom/imported-tests/README rename to dom/tests/mochitest/w3c/README diff --git a/dom/imported-tests/WebIDLParser.js b/dom/tests/mochitest/w3c/WebIDLParser.js similarity index 100% rename from dom/imported-tests/WebIDLParser.js rename to dom/tests/mochitest/w3c/WebIDLParser.js diff --git a/dom/imported-tests/failures.txt b/dom/tests/mochitest/w3c/failures.txt similarity index 100% rename from dom/imported-tests/failures.txt rename to dom/tests/mochitest/w3c/failures.txt diff --git a/dom/imported-tests/html.json b/dom/tests/mochitest/w3c/html.json similarity index 100% rename from dom/imported-tests/html.json rename to dom/tests/mochitest/w3c/html.json diff --git a/dom/imported-tests/html.mk b/dom/tests/mochitest/w3c/html.mk similarity index 100% rename from dom/imported-tests/html.mk rename to dom/tests/mochitest/w3c/html.mk diff --git a/dom/imported-tests/html.txt b/dom/tests/mochitest/w3c/html.txt similarity index 100% rename from dom/imported-tests/html.txt rename to dom/tests/mochitest/w3c/html.txt diff --git a/dom/imported-tests/html/tests/submission/Mozilla/Makefile.in b/dom/tests/mochitest/w3c/html/tests/submission/Mozilla/Makefile.in similarity index 79% rename from dom/imported-tests/html/tests/submission/Mozilla/Makefile.in rename to dom/tests/mochitest/w3c/html/tests/submission/Mozilla/Makefile.in index 8b4cd6cbbfa3..b8fd0a70b1d3 100644 --- a/dom/imported-tests/html/tests/submission/Mozilla/Makefile.in +++ b/dom/tests/mochitest/w3c/html/tests/submission/Mozilla/Makefile.in @@ -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) diff --git a/dom/imported-tests/html/tests/submission/Mozilla/nested-document-write-external.js b/dom/tests/mochitest/w3c/html/tests/submission/Mozilla/nested-document-write-external.js similarity index 100% rename from dom/imported-tests/html/tests/submission/Mozilla/nested-document-write-external.js rename to dom/tests/mochitest/w3c/html/tests/submission/Mozilla/nested-document-write-external.js diff --git a/dom/imported-tests/html/tests/submission/Mozilla/test_body-onload.html b/dom/tests/mochitest/w3c/html/tests/submission/Mozilla/test_body-onload.html similarity index 100% rename from dom/imported-tests/html/tests/submission/Mozilla/test_body-onload.html rename to dom/tests/mochitest/w3c/html/tests/submission/Mozilla/test_body-onload.html diff --git a/dom/imported-tests/html/tests/submission/Mozilla/test_pageload-image.html b/dom/tests/mochitest/w3c/html/tests/submission/Mozilla/test_pageload-image.html similarity index 100% rename from dom/imported-tests/html/tests/submission/Mozilla/test_pageload-image.html rename to dom/tests/mochitest/w3c/html/tests/submission/Mozilla/test_pageload-image.html diff --git a/dom/imported-tests/html/tests/submission/Mozilla/test_pageload-video.html b/dom/tests/mochitest/w3c/html/tests/submission/Mozilla/test_pageload-video.html similarity index 100% rename from dom/imported-tests/html/tests/submission/Mozilla/test_pageload-video.html rename to dom/tests/mochitest/w3c/html/tests/submission/Mozilla/test_pageload-video.html diff --git a/dom/imported-tests/html/tests/submission/Mozilla/test_script-for-onload.html b/dom/tests/mochitest/w3c/html/tests/submission/Mozilla/test_script-for-onload.html similarity index 100% rename from dom/imported-tests/html/tests/submission/Mozilla/test_script-for-onload.html rename to dom/tests/mochitest/w3c/html/tests/submission/Mozilla/test_script-for-onload.html diff --git a/dom/imported-tests/html/tests/submission/Mozilla/test_window-onerror-parse-error.html b/dom/tests/mochitest/w3c/html/tests/submission/Mozilla/test_window-onerror-parse-error.html similarity index 100% rename from dom/imported-tests/html/tests/submission/Mozilla/test_window-onerror-parse-error.html rename to dom/tests/mochitest/w3c/html/tests/submission/Mozilla/test_window-onerror-parse-error.html diff --git a/dom/imported-tests/html/tests/submission/Mozilla/test_window-onerror-runtime-error-throw.html b/dom/tests/mochitest/w3c/html/tests/submission/Mozilla/test_window-onerror-runtime-error-throw.html similarity index 100% rename from dom/imported-tests/html/tests/submission/Mozilla/test_window-onerror-runtime-error-throw.html rename to dom/tests/mochitest/w3c/html/tests/submission/Mozilla/test_window-onerror-runtime-error-throw.html diff --git a/dom/imported-tests/html/tests/submission/Mozilla/test_window-onerror-runtime-error.html b/dom/tests/mochitest/w3c/html/tests/submission/Mozilla/test_window-onerror-runtime-error.html similarity index 100% rename from dom/imported-tests/html/tests/submission/Mozilla/test_window-onerror-runtime-error.html rename to dom/tests/mochitest/w3c/html/tests/submission/Mozilla/test_window-onerror-runtime-error.html diff --git a/dom/imported-tests/idlharness.js b/dom/tests/mochitest/w3c/idlharness.js similarity index 100% rename from dom/imported-tests/idlharness.js rename to dom/tests/mochitest/w3c/idlharness.js diff --git a/dom/imported-tests/importTestsuite.py b/dom/tests/mochitest/w3c/importTestsuite.py similarity index 96% rename from dom/imported-tests/importTestsuite.py rename to dom/tests/mochitest/w3c/importTestsuite.py index 47fbbcd2d961..df4328d1b92d 100755 --- a/dom/imported-tests/importTestsuite.py +++ b/dom/tests/mochitest/w3c/importTestsuite.py @@ -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") diff --git a/dom/imported-tests/parseManifest.py b/dom/tests/mochitest/w3c/parseManifest.py similarity index 100% rename from dom/imported-tests/parseManifest.py rename to dom/tests/mochitest/w3c/parseManifest.py diff --git a/dom/imported-tests/testharness.css b/dom/tests/mochitest/w3c/testharness.css similarity index 100% rename from dom/imported-tests/testharness.css rename to dom/tests/mochitest/w3c/testharness.css diff --git a/dom/imported-tests/testharness.js b/dom/tests/mochitest/w3c/testharness.js similarity index 100% rename from dom/imported-tests/testharness.js rename to dom/tests/mochitest/w3c/testharness.js diff --git a/dom/imported-tests/testharnessreport.js.in b/dom/tests/mochitest/w3c/testharnessreport.js.in similarity index 97% rename from dom/imported-tests/testharnessreport.js.in rename to dom/tests/mochitest/w3c/testharnessreport.js.in index e13ad14db0e8..540adc5c58c5 100644 --- a/dom/imported-tests/testharnessreport.js.in +++ b/dom/tests/mochitest/w3c/testharnessreport.js.in @@ -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); }, /** diff --git a/dom/imported-tests/updateTestharness.py b/dom/tests/mochitest/w3c/updateTestharness.py similarity index 100% rename from dom/imported-tests/updateTestharness.py rename to dom/tests/mochitest/w3c/updateTestharness.py diff --git a/dom/imported-tests/webapps.json b/dom/tests/mochitest/w3c/webapps.json similarity index 100% rename from dom/imported-tests/webapps.json rename to dom/tests/mochitest/w3c/webapps.json diff --git a/dom/imported-tests/webapps.mk b/dom/tests/mochitest/w3c/webapps.mk similarity index 100% rename from dom/imported-tests/webapps.mk rename to dom/tests/mochitest/w3c/webapps.mk diff --git a/dom/imported-tests/webapps.txt b/dom/tests/mochitest/w3c/webapps.txt similarity index 100% rename from dom/imported-tests/webapps.txt rename to dom/tests/mochitest/w3c/webapps.txt diff --git a/dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/Makefile.in b/dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/Makefile.in similarity index 85% rename from dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/Makefile.in rename to dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/Makefile.in index 1c85dc41e7c5..78a765053c7f 100644 --- a/dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/Makefile.in +++ b/dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/Makefile.in @@ -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) diff --git a/dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-01.htm b/dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-01.htm similarity index 100% rename from dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-01.htm rename to dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-01.htm diff --git a/dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-02.htm b/dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-02.htm similarity index 100% rename from dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-02.htm rename to dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-02.htm diff --git a/dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-03.htm b/dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-03.htm similarity index 100% rename from dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-03.htm rename to dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-03.htm diff --git a/dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-04.htm b/dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-04.htm similarity index 100% rename from dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-04.htm rename to dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-04.htm diff --git a/dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-05.htm b/dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-05.htm similarity index 100% rename from dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-05.htm rename to dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-05.htm diff --git a/dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-06.htm b/dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-06.htm similarity index 100% rename from dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-06.htm rename to dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-06.htm diff --git a/dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-07.htm b/dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-07.htm similarity index 100% rename from dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-07.htm rename to dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-07.htm diff --git a/dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-08.htm b/dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-08.htm similarity index 100% rename from dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-08.htm rename to dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-08.htm diff --git a/dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-09.htm b/dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-09.htm similarity index 100% rename from dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-09.htm rename to dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-09.htm diff --git a/dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-10.xml b/dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-10.xml similarity index 100% rename from dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-10.xml rename to dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-10.xml diff --git a/dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-11.xml b/dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-11.xml similarity index 100% rename from dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-11.xml rename to dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-11.xml diff --git a/dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-12.htm b/dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-12.htm similarity index 100% rename from dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-12.htm rename to dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-12.htm diff --git a/dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-13.htm b/dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-13.htm similarity index 100% rename from dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-13.htm rename to dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-13.htm diff --git a/dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-14.htm b/dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-14.htm similarity index 100% rename from dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-14.htm rename to dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-14.htm diff --git a/dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-15.htm b/dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-15.htm similarity index 100% rename from dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-15.htm rename to dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-15.htm diff --git a/dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-16.htm b/dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-16.htm similarity index 100% rename from dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-16.htm rename to dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-16.htm diff --git a/dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-17.htm b/dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-17.htm similarity index 100% rename from dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-17.htm rename to dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-17.htm diff --git a/dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-18.htm b/dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-18.htm similarity index 100% rename from dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-18.htm rename to dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-18.htm diff --git a/dom/imported-tests/writeReporter.py b/dom/tests/mochitest/w3c/writeReporter.py similarity index 100% rename from dom/imported-tests/writeReporter.py rename to dom/tests/mochitest/w3c/writeReporter.py diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp index 0cda36864db5..07c154325af4 100644 --- a/dom/workers/RuntimeService.cpp +++ b/dom/workers/RuntimeService.cpp @@ -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; } diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp index 4b3ad503c68b..650ec2550caa 100644 --- a/dom/workers/WorkerPrivate.cpp +++ b/dom/workers/WorkerPrivate.cpp @@ -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 diff --git a/editor/composer/src/nsComposerCommands.cpp b/editor/composer/src/nsComposerCommands.cpp index 245cdc5c77dc..adc47d0caf65 100644 --- a/editor/composer/src/nsComposerCommands.cpp +++ b/editor/composer/src/nsComposerCommands.cpp @@ -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 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 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 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 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 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 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 diff --git a/editor/libeditor/html/nsHTMLEditRules.cpp b/editor/libeditor/html/nsHTMLEditRules.cpp index 679fd487da93..38d134f7d93a 100644 --- a/editor/libeditor/html/nsHTMLEditRules.cpp +++ b/editor/libeditor/html/nsHTMLEditRules.cpp @@ -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 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 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 diff --git a/editor/libeditor/html/nsHTMLEditor.cpp b/editor/libeditor/html/nsHTMLEditor.cpp index 26b75b06b72f..c448a483d7ba 100644 --- a/editor/libeditor/html/nsHTMLEditor.cpp +++ b/editor/libeditor/html/nsHTMLEditor.cpp @@ -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 *outNode) { - NS_ENSURE_TRUE(outNode, NS_ERROR_NULL_POINTER); - *outNode = NULL; - - nsCOMPtr 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 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 *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 *outNode) { - NS_ENSURE_TRUE(outNode, NS_ERROR_NULL_POINTER); - *outNode = NULL; - - nsCOMPtr 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 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 *outNode) { NS_ENSURE_TRUE(outNode, NS_ERROR_NULL_POINTER); + nsresult res = NS_OK; *outNode = nsnull; - - nsCOMPtr node = do_QueryInterface(inNode); - NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER); + nsCOMPtr 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 *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 *outNode) { - NS_ENSURE_TRUE(outNode, NS_ERROR_NULL_POINTER); - *outNode = NULL; - - nsCOMPtr 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 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); } diff --git a/editor/libeditor/html/nsHTMLEditor.h b/editor/libeditor/html/nsHTMLEditor.h index b98ceedb667d..d3672b74dcbd 100644 --- a/editor/libeditor/html/nsHTMLEditor.h +++ b/editor/libeditor/html/nsHTMLEditor.h @@ -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 *outNode); - nsINode* GetPriorHTMLSibling(nsINode* aParent, PRInt32 aOffset); nsresult GetPriorHTMLSibling(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr *outNode); - nsINode* GetNextHTMLSibling(nsINode* aNode); nsresult GetNextHTMLSibling(nsIDOMNode *inNode, nsCOMPtr *outNode); - nsINode* GetNextHTMLSibling(nsINode* aParent, PRInt32 aOffset); nsresult GetNextHTMLSibling(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr *outNode); nsresult GetPriorHTMLNode(nsIDOMNode *inNode, nsCOMPtr *outNode, bool bNoBlockCrossing = false); nsresult GetPriorHTMLNode(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr *outNode, bool bNoBlockCrossing = false); diff --git a/embedding/components/windowwatcher/src/nsWindowWatcher.cpp b/embedding/components/windowwatcher/src/nsWindowWatcher.cpp index 7c40315db34c..008e0992687d 100644 --- a/embedding/components/windowwatcher/src/nsWindowWatcher.cpp +++ b/embedding/components/windowwatcher/src/nsWindowWatcher.cpp @@ -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. diff --git a/gfx/src/X11Util.h b/gfx/src/X11Util.h index ae09ffef4199..e326d2af3253 100644 --- a/gfx/src/X11Util.h +++ b/gfx/src/X11Util.h @@ -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. diff --git a/js/src/jscntxt.h b/js/src/jscntxt.h index 3ebe886e016e..f4aef744eaa5 100644 --- a/js/src/jscntxt.h +++ b/js/src/jscntxt.h @@ -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 diff --git a/js/src/jscntxtinlines.h b/js/src/jscntxtinlines.h index 4b31c4ef7b64..68115fa706b2 100644 --- a/js/src/jscntxtinlines.h +++ b/js/src/jscntxtinlines.h @@ -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) diff --git a/js/src/jscompartment.h b/js/src/jscompartment.h index ab97881afdfc..ed2b89067bbb 100644 --- a/js/src/jscompartment.h +++ b/js/src/jscompartment.h @@ -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) diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp index 64690df55868..745411b5e08f 100644 --- a/js/src/jsobj.cpp +++ b/js/src/jsobj.cpp @@ -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()); diff --git a/js/src/jsscope.cpp b/js/src/jsscope.cpp index 6b1cd11c9250..0763e00b8e30 100644 --- a/js/src/jsscope.cpp +++ b/js/src/jsscope.cpp @@ -60,7 +60,6 @@ #include "js/MemoryMetrics.h" #include "jsatominlines.h" -#include "jscntxtinlines.h" #include "jsobjinlines.h" #include "jsscopeinlines.h" @@ -311,7 +310,7 @@ Shape::getChildBinding(JSContext *cx, const StackShape &child) { JS_ASSERT(!inDictionary()); - Shape *shape = cx->propertyTree().getChild(cx, this, numFixedSlots(), child); + Shape *shape = JS_PROPERTY_TREE(cx).getChild(cx, this, numFixedSlots(), child); if (shape) { //JS_ASSERT(shape->parent == this); // XXX 'this' is not rooted here @@ -364,7 +363,7 @@ Shape::replaceLastProperty(JSContext *cx, const StackBaseShape &base, JSObject * StackShape child(shape); child.base = nbase; - return cx->propertyTree().getChild(cx, shape->parent, shape->numFixedSlots(), child); + return JS_PROPERTY_TREE(cx).getChild(cx, shape->parent, shape->numFixedSlots(), child); } /* @@ -412,7 +411,7 @@ JSObject::getChildProperty(JSContext *cx, Shape *parent, StackShape &child) } shape->initDictionaryShape(child, self->numFixedSlots(), &self->shape_); } else { - shape = cx->propertyTree().getChild(cx, parent, self->numFixedSlots(), child); + shape = JS_PROPERTY_TREE(cx).getChild(cx, parent, self->numFixedSlots(), child); if (!shape) return NULL; //JS_ASSERT(shape->parent == parent); @@ -1333,7 +1332,7 @@ EmptyShape::getInitialShape(JSContext *cx, Class *clasp, JSObject *proto, JSObje if (!nbase) return NULL; - Shape *shape = cx->propertyTree().newShape(cx); + Shape *shape = JS_PROPERTY_TREE(cx).newShape(cx); if (!shape) return NULL; new (shape) EmptyShape(nbase, nfixed); diff --git a/js/xpconnect/idl/nsIJSContextStack.idl b/js/xpconnect/idl/nsIJSContextStack.idl index 00b1ffd004cf..dbb941b69518 100644 --- a/js/xpconnect/idl/nsIJSContextStack.idl +++ b/js/xpconnect/idl/nsIJSContextStack.idl @@ -77,9 +77,9 @@ interface nsIJSContextStackIterator : nsISupports JSContext prev(); }; -[uuid(3f8d6996-172d-4c0a-b591-50d6966cdb9a)] +[uuid(b7056a2a-a02d-43b1-abb9-47f81f8bf258)] interface nsIThreadJSContextStack : nsIJSContextStack { /* inherits methods of nsIJSContextStack */ - [notxpcom,nostdcall] JSContext getSafeJSContext(); + readonly attribute JSContext safeJSContext; }; diff --git a/js/xpconnect/idl/nsIXPConnect.idl b/js/xpconnect/idl/nsIXPConnect.idl index c5502959ed14..09e2d63cf36b 100644 --- a/js/xpconnect/idl/nsIXPConnect.idl +++ b/js/xpconnect/idl/nsIXPConnect.idl @@ -409,7 +409,7 @@ enum nsGCType { }; %} -[uuid(1239b432-b835-4d28-9dc0-53063cb7f60f)] +[uuid(08ad2253-3ed6-40ed-beec-6472f2d8dc7f)] interface nsIXPConnect : nsISupports { %{ C++ @@ -745,6 +745,30 @@ interface nsIXPConnect : nsISupports */ void NotifyDidPaint(); + /** + * Define quick stubs on the given object, @a proto. + * + * @param cx + * A context. Requires request. + * @param proto + * The (newly created) prototype object for a DOM class. The JS half + * of an XPCWrappedNativeProto. + * @param flags + * Property flags for the quick stub properties--should be either + * JSPROP_ENUMERATE or 0. + * @param interfaceCount + * The number of interfaces the class implements. + * @param interfaceArray + * The interfaces the class implements; interfaceArray and + * interfaceCount are like what nsIClassInfo.getInterfaces returns. + */ + [noscript,notxpcom] boolean defineDOMQuickStubs( + in JSContextPtr cx, + in JSObjectPtr proto, + in PRUint32 flags, + in PRUint32 interfaceCount, + [array, size_is(interfaceCount)] in nsIIDPtr interfaceArray); + %{C++ /** * Get the object principal for this wrapper. Note that this may well end diff --git a/js/xpconnect/src/XPCContext.cpp b/js/xpconnect/src/XPCContext.cpp index 92721f60d5ba..15c35521191d 100644 --- a/js/xpconnect/src/XPCContext.cpp +++ b/js/xpconnect/src/XPCContext.cpp @@ -77,9 +77,8 @@ XPCContext::~XPCContext() for (PRCList *scopeptr = PR_NEXT_LINK(&mScopes); scopeptr != &mScopes; scopeptr = PR_NEXT_LINK(scopeptr)) { - XPCWrappedNativeScope *scope = - static_cast(scopeptr); - scope->ClearContext(); + XPCWrappedNativeScope *scope = (XPCWrappedNativeScope *)scopeptr; + scope->SetContext(nsnull); } // we do not call JS_RemoveArgumentFormatter because we now only diff --git a/js/xpconnect/src/XPCJSRuntime.cpp b/js/xpconnect/src/XPCJSRuntime.cpp index f1831e20c154..55579b78de7f 100644 --- a/js/xpconnect/src/XPCJSRuntime.cpp +++ b/js/xpconnect/src/XPCJSRuntime.cpp @@ -68,6 +68,7 @@ #endif using namespace mozilla; +using namespace mozilla::xpconnect::memory; /***************************************************************************/ @@ -1376,7 +1377,9 @@ MakePath(const nsACString &pathPrefix, const JS::CompartmentStats &cStats, nsDependentCString(reporterName); } -namespace xpc { +namespace mozilla { +namespace xpconnect { +namespace memory { static nsresult ReportCompartmentStats(const JS::CompartmentStats &cStats, @@ -1638,7 +1641,9 @@ ReportJSRuntimeExplicitTreeStats(const JS::RuntimeStats &rtStats, return NS_OK; } -} // namespace xpc +} // namespace memory +} // namespace xpconnect +} // namespace mozilla NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(JsMallocSizeOf, "js") @@ -1757,8 +1762,7 @@ public: // "explicit" tree, then we report other stuff. nsresult rv = - xpc::ReportJSRuntimeExplicitTreeStats(rtStats, pathPrefix, cb, - closure); + ReportJSRuntimeExplicitTreeStats(rtStats, pathPrefix, cb, closure); NS_ENSURE_SUCCESS(rv, rv); REPORT_BYTES(pathPrefix + NS_LITERAL_CSTRING("xpconnect"), diff --git a/js/xpconnect/src/XPCQuickStubs.h b/js/xpconnect/src/XPCQuickStubs.h index f6079f7b6dda..23e1dd4b6fbf 100644 --- a/js/xpconnect/src/XPCQuickStubs.h +++ b/js/xpconnect/src/XPCQuickStubs.h @@ -653,6 +653,50 @@ xpc_qsVariantToJsval(XPCLazyCallContext &ccx, nsIVariant *p, jsval *rval); +/** + * Convert a jsval to PRInt64. Return true on success. + */ +inline JSBool +xpc_qsValueToInt64(JSContext *cx, + jsval v, + PRInt64 *result) +{ + if (JSVAL_IS_INT(v)) { + int32_t intval; + if (!JS_ValueToECMAInt32(cx, v, &intval)) + return false; + *result = static_cast(intval); + } else { + double doubleval; + if (!JS_ValueToNumber(cx, v, &doubleval)) + return false; + *result = static_cast(doubleval); + } + return true; +} + +/** + * Convert a jsval to PRUint64. Return true on success. + */ +inline JSBool +xpc_qsValueToUint64(JSContext *cx, + jsval v, + PRUint64 *result) +{ + if (JSVAL_IS_INT(v)) { + uint32_t intval; + if (!JS_ValueToECMAUint32(cx, v, &intval)) + return false; + *result = static_cast(intval); + } else { + double doubleval; + if (!JS_ValueToNumber(cx, v, &doubleval)) + return false; + *result = static_cast(doubleval); + } + return true; +} + #ifdef DEBUG void xpc_qsAssertContextOK(JSContext *cx); diff --git a/js/xpconnect/src/codegen.py b/js/xpconnect/src/codegen.py index c2797d1b41ad..ac0d97df4a50 100644 --- a/js/xpconnect/src/codegen.py +++ b/js/xpconnect/src/codegen.py @@ -127,13 +127,13 @@ argumentUnboxingTemplates = { " return JS_FALSE;\n", 'long long': - " int64_t ${name};\n" - " if (!xpc::ValueToInt64(cx, ${argVal}, &${name}))\n" + " PRInt64 ${name};\n" + " if (!xpc_qsValueToInt64(cx, ${argVal}, &${name}))\n" " return JS_FALSE;\n", 'unsigned long long': - " uint64_t ${name};\n" - " if (!xpc::ValueToUint64(cx, ${argVal}, &${name}))\n" + " PRUint64 ${name};\n" + " if (!xpc_qsValueToUint64(cx, ${argVal}, &${name}))\n" " return JS_FALSE;\n", 'float': diff --git a/js/xpconnect/src/nsXPConnect.cpp b/js/xpconnect/src/nsXPConnect.cpp index 6f94ddb27c18..c267b57dd66d 100644 --- a/js/xpconnect/src/nsXPConnect.cpp +++ b/js/xpconnect/src/nsXPConnect.cpp @@ -2373,6 +2373,18 @@ nsXPConnect::SetReportAllJSExceptions(bool newval) return NS_OK; } +/* [noscript, notxpcom] bool defineDOMQuickStubs (in JSContextPtr cx, in JSObjectPtr proto, in PRUint32 flags, in PRUint32 interfaceCount, [array, size_is (interfaceCount)] in nsIIDPtr interfaceArray); */ +NS_IMETHODIMP_(bool) +nsXPConnect::DefineDOMQuickStubs(JSContext * cx, + JSObject * proto, + PRUint32 flags, + PRUint32 interfaceCount, + const nsIID * *interfaceArray) +{ + return DOM_DefineQuickStubs(cx, proto, flags, + interfaceCount, interfaceArray); +} + /* attribute JSRuntime runtime; */ NS_IMETHODIMP nsXPConnect::GetRuntime(JSRuntime **runtime) @@ -2593,17 +2605,21 @@ nsXPConnect::Push(JSContext * cx) return data->GetJSContextStack()->Push(cx) ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } -/* virtual */ -JSContext* -nsXPConnect::GetSafeJSContext() +/* attribute JSContext SafeJSContext; */ +NS_IMETHODIMP +nsXPConnect::GetSafeJSContext(JSContext * *aSafeJSContext) { - XPCPerThreadData *data = XPCPerThreadData::GetData(NULL); + NS_ASSERTION(aSafeJSContext, "loser!"); + + XPCPerThreadData* data = XPCPerThreadData::GetData(nsnull); if (!data) { - return NULL; + *aSafeJSContext = nsnull; + return NS_ERROR_FAILURE; } - return data->GetJSContextStack()->GetSafeJSContext(); + *aSafeJSContext = data->GetJSContextStack()->GetSafeJSContext(); + return *aSafeJSContext ? NS_OK : NS_ERROR_FAILURE; } nsIPrincipal* diff --git a/js/xpconnect/src/qsgen.py b/js/xpconnect/src/qsgen.py index 07ce7fae2dc1..51ac3efedc43 100644 --- a/js/xpconnect/src/qsgen.py +++ b/js/xpconnect/src/qsgen.py @@ -456,13 +456,13 @@ argumentUnboxingTemplates = { " return JS_FALSE;\n", 'long long': - " int64_t ${name};\n" - " if (!xpc::ValueToInt64(cx, ${argVal}, &${name}))\n" + " PRInt64 ${name};\n" + " if (!xpc_qsValueToInt64(cx, ${argVal}, &${name}))\n" " return JS_FALSE;\n", 'unsigned long long': - " uint64_t ${name};\n" - " if (!xpc::ValueToUint64(cx, ${argVal}, &${name}))\n" + " PRUint64 ${name};\n" + " if (!xpc_qsValueToUint64(cx, ${argVal}, &${name}))\n" " return JS_FALSE;\n", 'float': @@ -1274,16 +1274,14 @@ def writeDefiner(f, conf, stringtable, interfaces): f.write("\n") # the definer function (entry point to this quick stubs file) - f.write("namespace xpc {\n") - f.write("bool %s_DefineQuickStubs(" % conf.name) + f.write("JSBool %s_DefineQuickStubs(" % conf.name) f.write("JSContext *cx, JSObject *proto, unsigned flags, PRUint32 count, " "const nsID **iids)\n" "{\n") - f.write(" return !!xpc_qsDefineQuickStubs(" + f.write(" return xpc_qsDefineQuickStubs(" "cx, proto, flags, count, iids, %d, tableData, %s, %s, %s);\n" % ( size, prop_array_name, func_array_name, table_name)) - f.write("}\n") - f.write("} // namespace xpc\n\n\n") + f.write("}\n\n\n") stubTopTemplate = '''\ diff --git a/js/xpconnect/src/xpcprivate.h b/js/xpconnect/src/xpcprivate.h index 586cb7e0338f..ea70c69cde2d 100644 --- a/js/xpconnect/src/xpcprivate.h +++ b/js/xpconnect/src/xpcprivate.h @@ -1606,7 +1606,7 @@ public: static void InitStatics() { gScopes = nsnull; gDyingScopes = nsnull; } XPCContext *GetContext() { return mContext; } - void ClearContext() { mContext = nsnull; } + void SetContext(XPCContext *xpcc) { mContext = nsnull; } nsDataHashtable& GetCachedDOMPrototypes() { diff --git a/js/xpconnect/src/xpcpublic.h b/js/xpconnect/src/xpcpublic.h index ff23f465bac8..4ef78ba644ef 100644 --- a/js/xpconnect/src/xpcpublic.h +++ b/js/xpconnect/src/xpcpublic.h @@ -209,8 +209,6 @@ xpc_UnmarkSkippableJSHolders(); NS_EXPORT_(void) xpc_ActivateDebugMode(); -class nsIMemoryMultiReporterCallback; - namespace xpc { // If these functions return false, then an exception will be set on cx. @@ -230,27 +228,13 @@ nsIPrincipal *GetCompartmentPrincipal(JSCompartment *compartment); #ifdef DEBUG void DumpJSHeap(FILE* file); #endif +} // namespace xpc -/** - * Define quick stubs on the given object, @a proto. - * - * @param cx - * A context. Requires request. - * @param proto - * The (newly created) prototype object for a DOM class. The JS half - * of an XPCWrappedNativeProto. - * @param flags - * Property flags for the quick stub properties--should be either - * JSPROP_ENUMERATE or 0. - * @param interfaceCount - * The number of interfaces the class implements. - * @param interfaceArray - * The interfaces the class implements; interfaceArray and - * interfaceCount are like what nsIClassInfo.getInterfaces returns. - */ -bool -DOM_DefineQuickStubs(JSContext *cx, JSObject *proto, PRUint32 flags, - PRUint32 interfaceCount, const nsIID **interfaceArray); +class nsIMemoryMultiReporterCallback; + +namespace mozilla { +namespace xpconnect { +namespace memory { // This reports all the stats in |rtStats| that belong in the "explicit" tree, // (which isn't all of them). @@ -260,49 +244,9 @@ ReportJSRuntimeExplicitTreeStats(const JS::RuntimeStats &rtStats, nsIMemoryMultiReporterCallback *cb, nsISupports *closure); -/** - * Convert a jsval to PRInt64. Return true on success. - */ -inline bool -ValueToInt64(JSContext *cx, JS::Value v, int64_t *result) -{ - if (JSVAL_IS_INT(v)) { - int32_t intval; - if (!JS_ValueToECMAInt32(cx, v, &intval)) - return false; - *result = static_cast(intval); - } else { - double doubleval; - if (!JS_ValueToNumber(cx, v, &doubleval)) - return false; - *result = static_cast(doubleval); - } - return true; -} +} // namespace memory +} // namespace xpconnect -/** - * Convert a jsval to uint64_t. Return true on success. - */ -inline bool -ValueToUint64(JSContext *cx, JS::Value v, uint64_t *result) -{ - if (JSVAL_IS_INT(v)) { - uint32_t intval; - if (!JS_ValueToECMAUint32(cx, v, &intval)) - return false; - *result = static_cast(intval); - } else { - double doubleval; - if (!JS_ValueToNumber(cx, v, &doubleval)) - return false; - *result = static_cast(doubleval); - } - return true; -} - -} // namespace xpc - -namespace mozilla { namespace dom { namespace binding { diff --git a/toolkit/components/alerts/mac/mozGrowlDelegate.mm b/toolkit/components/alerts/mac/mozGrowlDelegate.mm index c01d38433c86..4cf982c05d6e 100644 --- a/toolkit/components/alerts/mac/mozGrowlDelegate.mm +++ b/toolkit/components/alerts/mac/mozGrowlDelegate.mm @@ -74,8 +74,9 @@ GetWindowOfObserver(nsIObserver* aObserver) do_GetService("@mozilla.org/js/xpc/ContextStack;1", &rv); NS_ENSURE_SUCCESS(rv, nsnull); - JSContext* cx = stack->GetSafeJSContext(); - NS_ENSURE_TRUE(cx, nsnull); + JSContext* cx; + rv = stack->GetSafeJSContext(&cx); + NS_ENSURE_SUCCESS(rv, nsnull); JSAutoRequest ar(cx); JSAutoEnterCompartment ac; diff --git a/toolkit/xre/nsNativeAppSupportOS2.cpp b/toolkit/xre/nsNativeAppSupportOS2.cpp index 60fb25c2407a..72dbf99c4bb6 100644 --- a/toolkit/xre/nsNativeAppSupportOS2.cpp +++ b/toolkit/xre/nsNativeAppSupportOS2.cpp @@ -1678,9 +1678,11 @@ nsresult SafeJSContext::Push() { return NS_ERROR_FAILURE; mService = do_GetService(sJSStackContractID); - if (mService) { - JSContext* cx = mService->GetSafeJSContext(); - if (cx && NS_SUCCEEDED(mService->Push(cx))) { + if(mService) { + JSContext *cx; + if (NS_SUCCEEDED(mService->GetSafeJSContext(&cx)) && + cx && + NS_SUCCEEDED(mService->Push(cx))) { // Save cx in mContext to indicate need to pop. mContext = cx; } diff --git a/toolkit/xre/nsNativeAppSupportWin.cpp b/toolkit/xre/nsNativeAppSupportWin.cpp index c97105052c42..004fc1666db1 100644 --- a/toolkit/xre/nsNativeAppSupportWin.cpp +++ b/toolkit/xre/nsNativeAppSupportWin.cpp @@ -1501,9 +1501,11 @@ nsresult SafeJSContext::Push() { return NS_ERROR_FAILURE; mService = do_GetService(sJSStackContractID); - if (mService) { - JSContext* cx = mService->GetSafeJSContext(); - if (cx && NS_SUCCEEDED(mService->Push(cx))) { + if(mService) { + JSContext *cx; + if (NS_SUCCEEDED(mService->GetSafeJSContext(&cx)) && + cx && + NS_SUCCEEDED(mService->Push(cx))) { // Save cx in mContext to indicate need to pop. mContext = cx; } diff --git a/xpcom/base/nsError.h b/xpcom/base/nsError.h index 06ef1f1ca1b2..132449072403 100644 --- a/xpcom/base/nsError.h +++ b/xpcom/base/nsError.h @@ -98,6 +98,7 @@ #define NS_ERROR_MODULE_SCHEMA 31 #define NS_ERROR_MODULE_DOM_FILE 32 #define NS_ERROR_MODULE_DOM_INDEXEDDB 33 +#define NS_ERROR_MODULE_DOM_EVENTS 34 /* NS_ERROR_MODULE_GENERAL should be used by modules that do not * care if return code values overlap. Callers of methods that