diff --git a/.hgtags b/.hgtags index 614c3e6a4db..3ee11aa0273 100644 --- a/.hgtags +++ b/.hgtags @@ -63,3 +63,6 @@ a71bd564ebf5bf4f93d13e84114f759c263130b0 MOBILE_MERGE_DONE a71bd564ebf5bf4f93d13e84114f759c263130b0 MOBILE_MERGE_DONE_20110406 a95d426422816513477e5863add1b00ac7041dcb AURORA_BASE_20110412 138f593553b66c9f815e8f57870c19d6347f7702 UPDATE_PACKAGING_R14 +9eae975b3d6fb7748fe5a3c0113d449b1c7cc0b2 AURORA_BASE_20110524 +138f593553b66c9f815e8f57870c19d6347f7702 UPDATE_PACKAGING_R14 +462c726144bc1fb45b61e774f64ac5d61b4e047c UPDATE_PACKAGING_R14 diff --git a/accessible/src/base/nsAccessNode.cpp b/accessible/src/base/nsAccessNode.cpp index aadbe4399da..8fb9eb37ffb 100644 --- a/accessible/src/base/nsAccessNode.cpp +++ b/accessible/src/base/nsAccessNode.cpp @@ -55,9 +55,6 @@ #include "nsIDOMCSSPrimitiveValue.h" #include "nsIDOMDocument.h" #include "nsIDOMElement.h" -#include "nsIDOMHTMLDocument.h" -#include "nsIDOMHTMLElement.h" -#include "nsIDOMNSDocument.h" #include "nsIDOMNSHTMLElement.h" #include "nsIDOMWindow.h" #include "nsPIDOMWindow.h" @@ -135,6 +132,12 @@ void nsAccessNode::LastRelease() //////////////////////////////////////////////////////////////////////////////// // nsAccessNode public +bool +nsAccessNode::IsDefunct() const +{ + return !mContent; +} + PRBool nsAccessNode::Init() { diff --git a/accessible/src/base/nsAccessNode.h b/accessible/src/base/nsAccessNode.h index 0f902f3db47..0b851b78ee4 100644 --- a/accessible/src/base/nsAccessNode.h +++ b/accessible/src/base/nsAccessNode.h @@ -120,11 +120,6 @@ public: */ already_AddRefed GetCurrentFocus(); - /** - * Returns true when the accessible is defunct. - */ - virtual PRBool IsDefunct() { return !mContent; } - /** * Initialize the access node object, add it to the cache. */ @@ -135,6 +130,11 @@ public: */ virtual void Shutdown(); + /** + * Returns true when the accessible is defunct. + */ + virtual bool IsDefunct() const; + /** * Return frame for the given access node object. */ diff --git a/accessible/src/base/nsAccessibilityService.cpp b/accessible/src/base/nsAccessibilityService.cpp index 92d9083a638..6827529f6f6 100644 --- a/accessible/src/base/nsAccessibilityService.cpp +++ b/accessible/src/base/nsAccessibilityService.cpp @@ -107,7 +107,6 @@ #include "mozilla/FunctionTimer.h" #include "mozilla/dom/Element.h" -#include "nsImageMapUtils.h" //////////////////////////////////////////////////////////////////////////////// // nsAccessibilityService @@ -275,8 +274,10 @@ nsAccessibilityService::CreateHTMLImageAccessible(nsIContent* aContent, aContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::usemap, mapElmName); - nsCOMPtr mapElm = - nsImageMapUtils::FindImageMap(aContent->GetCurrentDoc(), mapElmName); + nsCOMPtr mapElm; + if (nsIDocument* document = aContent->GetCurrentDoc()) { + mapElm = do_QueryInterface(document->FindImageMap(mapElmName)); + } nsCOMPtr weakShell(do_GetWeakReference(aPresShell)); nsAccessible* accessible = mapElm ? diff --git a/accessible/src/base/nsApplicationAccessible.cpp b/accessible/src/base/nsApplicationAccessible.cpp index 4ada51e9feb..927ef2363e1 100644 --- a/accessible/src/base/nsApplicationAccessible.cpp +++ b/accessible/src/base/nsApplicationAccessible.cpp @@ -332,8 +332,8 @@ nsApplicationAccessible::GetPlatformVersion(nsAString& aVersion) //////////////////////////////////////////////////////////////////////////////// // nsAccessNode public methods -PRBool -nsApplicationAccessible::IsDefunct() +bool +nsApplicationAccessible::IsDefunct() const { return nsAccessibilityService::IsShutdown(); } diff --git a/accessible/src/base/nsApplicationAccessible.h b/accessible/src/base/nsApplicationAccessible.h index e9d094d6793..9adf0263c74 100644 --- a/accessible/src/base/nsApplicationAccessible.h +++ b/accessible/src/base/nsApplicationAccessible.h @@ -115,7 +115,7 @@ public: NS_DECL_NSIACCESSIBLEAPPLICATION // nsAccessNode - virtual PRBool IsDefunct(); + virtual bool IsDefunct() const; virtual PRBool Init(); virtual void Shutdown(); virtual bool IsPrimaryForNode() const; diff --git a/accessible/src/base/nsBaseWidgetAccessible.cpp b/accessible/src/base/nsBaseWidgetAccessible.cpp index b4b9ba8867d..49cea016674 100644 --- a/accessible/src/base/nsBaseWidgetAccessible.cpp +++ b/accessible/src/base/nsBaseWidgetAccessible.cpp @@ -141,7 +141,7 @@ nsLinkableAccessible::GetNumActions(PRUint8 *aNumActions) { NS_ENSURE_ARG_POINTER(aNumActions); - *aNumActions = mActionAcc ? 1 : 0; + *aNumActions = (mIsOnclick || mIsLink) ? 1 : 0; return NS_OK; } @@ -228,7 +228,6 @@ nsLinkableAccessible::BindToParent(nsAccessible* aParent, mIsOnclick = PR_FALSE; if (nsCoreUtils::HasClickListener(mContent)) { - mActionAcc = this; mIsOnclick = PR_TRUE; return; } diff --git a/accessible/src/base/nsDocAccessible.cpp b/accessible/src/base/nsDocAccessible.cpp index 262d63b1d7a..febee5a1caa 100644 --- a/accessible/src/base/nsDocAccessible.cpp +++ b/accessible/src/base/nsDocAccessible.cpp @@ -54,8 +54,6 @@ #include "nsIDOMCharacterData.h" #include "nsIDOMDocument.h" #include "nsIDOMDocumentType.h" -#include "nsIDOMNSDocument.h" -#include "nsIDOMNSHTMLDocument.h" #include "nsIDOMXULDocument.h" #include "nsIDOMMutationEvent.h" #include "nsPIDOMWindow.h" @@ -411,22 +409,24 @@ NS_IMETHODIMP nsDocAccessible::GetURL(nsAString& aURL) return NS_OK; } -NS_IMETHODIMP nsDocAccessible::GetTitle(nsAString& aTitle) +NS_IMETHODIMP +nsDocAccessible::GetTitle(nsAString& aTitle) { - nsCOMPtr domnsDocument(do_QueryInterface(mDocument)); - if (domnsDocument) { - return domnsDocument->GetTitle(aTitle); + nsCOMPtr domDocument = do_QueryInterface(mDocument); + if (!domDocument) { + return NS_ERROR_FAILURE; } - return NS_ERROR_FAILURE; + return domDocument->GetTitle(aTitle); } -NS_IMETHODIMP nsDocAccessible::GetMimeType(nsAString& aMimeType) +NS_IMETHODIMP +nsDocAccessible::GetMimeType(nsAString& aMimeType) { - nsCOMPtr domnsDocument(do_QueryInterface(mDocument)); - if (domnsDocument) { - return domnsDocument->GetContentType(aMimeType); + nsCOMPtr domDocument = do_QueryInterface(mDocument); + if (!domDocument) { + return NS_ERROR_FAILURE; } - return NS_ERROR_FAILURE; + return domDocument->GetContentType(aMimeType); } NS_IMETHODIMP nsDocAccessible::GetDocType(nsAString& aDocType) @@ -607,6 +607,12 @@ nsDocAccessible::Init() if (!mNotificationController) return PR_FALSE; + // Mark the document accessible as loaded if its DOM document was loaded at + // this point (this can happen because a11y is started late or DOM document + // having no container was loaded. + if (mDocument->GetReadyStateEnum() == nsIDocument::READYSTATE_COMPLETE) + mIsLoaded = PR_TRUE; + AddEventListeners(); return PR_TRUE; } @@ -670,8 +676,8 @@ nsDocAccessible::GetFrame() const return root; } -PRBool -nsDocAccessible::IsDefunct() +bool +nsDocAccessible::IsDefunct() const { return nsHyperTextAccessibleWrap::IsDefunct() || !mDocument; } diff --git a/accessible/src/base/nsDocAccessible.h b/accessible/src/base/nsDocAccessible.h index 55d8f753cef..2b966245230 100644 --- a/accessible/src/base/nsDocAccessible.h +++ b/accessible/src/base/nsDocAccessible.h @@ -108,7 +108,7 @@ public: virtual PRBool Init(); virtual void Shutdown(); virtual nsIFrame* GetFrame() const; - virtual PRBool IsDefunct(); + virtual bool IsDefunct() const; virtual nsINode* GetNode() const { return mDocument; } virtual nsIDocument* GetDocumentNode() const { return mDocument; } diff --git a/accessible/src/base/nsRootAccessible.cpp b/accessible/src/base/nsRootAccessible.cpp index 902b9c0ff6b..6fa4fca298d 100644 --- a/accessible/src/base/nsRootAccessible.cpp +++ b/accessible/src/base/nsRootAccessible.cpp @@ -59,7 +59,6 @@ #include "nsIDOMHTMLInputElement.h" #include "nsIDOMHTMLSelectElement.h" #include "nsIDOMDataContainerEvent.h" -#include "nsIDOMNSDocument.h" #include "nsIDOMNSEvent.h" #include "nsIDOMXULMenuListElement.h" #include "nsIDOMXULMultSelectCntrlEl.h" @@ -139,7 +138,7 @@ nsRootAccessible::GetName(nsAString& aName) } } - nsCOMPtr document(do_QueryInterface(mDocument)); + nsCOMPtr document = do_QueryInterface(mDocument); return document->GetTitle(aName); } diff --git a/accessible/src/xul/nsXULTreeAccessible.cpp b/accessible/src/xul/nsXULTreeAccessible.cpp index 6a392d999d8..524d1e43ea0 100644 --- a/accessible/src/xul/nsXULTreeAccessible.cpp +++ b/accessible/src/xul/nsXULTreeAccessible.cpp @@ -156,8 +156,8 @@ nsXULTreeAccessible::GetValue(nsAString& aValue) //////////////////////////////////////////////////////////////////////////////// // nsXULTreeAccessible: nsAccessNode implementation -PRBool -nsXULTreeAccessible::IsDefunct() +bool +nsXULTreeAccessible::IsDefunct() const { return nsAccessibleWrap::IsDefunct() || !mTree || !mTreeView; } @@ -834,8 +834,8 @@ nsXULTreeItemAccessibleBase::DoAction(PRUint8 aIndex) //////////////////////////////////////////////////////////////////////////////// // nsXULTreeItemAccessibleBase: nsAccessNode implementation -PRBool -nsXULTreeItemAccessibleBase::IsDefunct() +bool +nsXULTreeItemAccessibleBase::IsDefunct() const { if (nsAccessibleWrap::IsDefunct() || !mTree || !mTreeView || mRow < 0) return PR_TRUE; @@ -1091,8 +1091,8 @@ nsXULTreeItemAccessible::GetName(nsAString& aName) //////////////////////////////////////////////////////////////////////////////// // nsXULTreeItemAccessible: nsAccessNode implementation -PRBool -nsXULTreeItemAccessible::IsDefunct() +bool +nsXULTreeItemAccessible::IsDefunct() const { return nsXULTreeItemAccessibleBase::IsDefunct() || !mColumn; } diff --git a/accessible/src/xul/nsXULTreeAccessible.h b/accessible/src/xul/nsXULTreeAccessible.h index de3f42b3166..7596124f498 100644 --- a/accessible/src/xul/nsXULTreeAccessible.h +++ b/accessible/src/xul/nsXULTreeAccessible.h @@ -80,7 +80,7 @@ public: NS_IMETHOD GetFocusedChild(nsIAccessible **aFocusedChild); // nsAccessNode - virtual PRBool IsDefunct(); + virtual bool IsDefunct() const; virtual void Shutdown(); // nsAccessible @@ -201,7 +201,7 @@ public: NS_IMETHOD DoAction(PRUint8 aIndex); // nsAccessNode - virtual PRBool IsDefunct(); + virtual bool IsDefunct() const; virtual void Shutdown(); virtual bool IsPrimaryForNode() const; @@ -266,7 +266,7 @@ public: NS_IMETHOD GetName(nsAString& aName); // nsAccessNode - virtual PRBool IsDefunct(); + virtual bool IsDefunct() const; virtual PRBool Init(); virtual void Shutdown(); diff --git a/accessible/src/xul/nsXULTreeGridAccessible.cpp b/accessible/src/xul/nsXULTreeGridAccessible.cpp index 5c7f1316735..cf71759d90a 100644 --- a/accessible/src/xul/nsXULTreeGridAccessible.cpp +++ b/accessible/src/xul/nsXULTreeGridAccessible.cpp @@ -1087,8 +1087,8 @@ nsXULTreeGridCellAccessible::IsSelected(PRBool *aIsSelected) //////////////////////////////////////////////////////////////////////////////// // nsXULTreeGridCellAccessible: nsAccessNode implementation -PRBool -nsXULTreeGridCellAccessible::IsDefunct() +bool +nsXULTreeGridCellAccessible::IsDefunct() const { return nsLeafAccessible::IsDefunct() || !mParent || !mTree || !mTreeView || !mColumn; diff --git a/accessible/src/xul/nsXULTreeGridAccessible.h b/accessible/src/xul/nsXULTreeGridAccessible.h index 678d43cdd52..897b1c8d762 100644 --- a/accessible/src/xul/nsXULTreeGridAccessible.h +++ b/accessible/src/xul/nsXULTreeGridAccessible.h @@ -155,7 +155,7 @@ public: NS_DECL_NSIACCESSIBLETABLECELL // nsAccessNode - virtual PRBool IsDefunct(); + virtual bool IsDefunct() const; virtual PRBool Init(); virtual bool IsPrimaryForNode() const; diff --git a/accessible/tests/mochitest/Makefile.in b/accessible/tests/mochitest/Makefile.in index 9dfa858c1f8..16d56c4a61a 100644 --- a/accessible/tests/mochitest/Makefile.in +++ b/accessible/tests/mochitest/Makefile.in @@ -90,16 +90,14 @@ _TEST_FILES =\ test_aria_roles.xul \ test_aria_token_attrs.html \ test_bug420863.html \ - $(warning test_childAtPoint.html temporarily disabled) \ - $(warning test_childAtPoint.xul temporarily disabled) \ + test_childAtPoint.html \ + test_childAtPoint.xul \ test_descr.html \ test_elm_landmarks.html \ test_elm_listbox.xul \ - $(warning test_elm_media.html temporarily disabled) \ test_elm_nsApplicationAcc.html \ test_elm_plugin.html \ test_keys.html \ - $(warning test_nsIAccessible_comboboxes.xul temporarily disabled) \ test_nsIAccessible_selects.html \ test_nsIAccessibleDocument.html \ test_nsIAccessibleImage.html \ diff --git a/accessible/tests/mochitest/actions/Makefile.in b/accessible/tests/mochitest/actions/Makefile.in index e8ab174e43f..3b6885977c1 100644 --- a/accessible/tests/mochitest/actions/Makefile.in +++ b/accessible/tests/mochitest/actions/Makefile.in @@ -52,6 +52,7 @@ _TEST_FILES =\ test_general.xul \ test_inputs.html \ test_link.html \ + test_media.html \ test_tree.xul \ test_treegrid.xul \ $(NULL) diff --git a/accessible/tests/mochitest/actions/test_general.html b/accessible/tests/mochitest/actions/test_general.html index a51118d648b..0133c9c607c 100644 --- a/accessible/tests/mochitest/actions/test_general.html +++ b/accessible/tests/mochitest/actions/test_general.html @@ -36,9 +36,19 @@ ID: "li_clickable3", actionName: "click", events: CLICK_EVENTS + }, + { + ID: "onclick_img", + actionName: "click", + events: CLICK_EVENTS } ]; + testActions(actionsArray); + + getAccessible("onclick_img").takeFocus(); +is(getAccessible("link1").numActions, 1, "links should have one action"); +is(getAccessible("link2").numActions, 1, "link with onclick handler should have 1 action"); } SimpleTest.waitForExplicitFinish(); @@ -58,6 +68,11 @@ title="Expose click action if mouseup and mousedown are registered"> Mozilla Bug 423409 + + Mozilla Bug 659620 +

@@ -68,5 +83,11 @@
     
  • Clickable list item
  • Clickable list item
  • + + + + + linkable textleaf accessible +
    linkable textleaf accessible
    diff --git a/accessible/tests/mochitest/test_elm_media.html b/accessible/tests/mochitest/actions/test_media.html similarity index 64% rename from accessible/tests/mochitest/test_elm_media.html rename to accessible/tests/mochitest/actions/test_media.html index 0b17ab3f42a..a5ceba62e19 100644 --- a/accessible/tests/mochitest/test_elm_media.html +++ b/accessible/tests/mochitest/actions/test_media.html @@ -13,15 +13,15 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=483573 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"> + src="../common.js"> + src="../events.js"> + src="../actions.js"> + src="../role.js"> + src="../states.js"> @@ -268,6 +305,11 @@ title="Shutdown document accessible when presshell goes away"> Mozilla Bug 571459 + + Mozilla Bug 658185 +

    @@ -275,6 +317,7 @@
    +
    diff --git a/accessible/tests/mochitest/states/Makefile.in b/accessible/tests/mochitest/states/Makefile.in index 3905fb981e2..8314fd9460b 100644 --- a/accessible/tests/mochitest/states/Makefile.in +++ b/accessible/tests/mochitest/states/Makefile.in @@ -49,6 +49,7 @@ _TEST_FILES =\ test_aria.html \ test_aria_imgmap.html \ test_aria_tabs.html \ + test_comboboxes.xul \ test_doc.html \ test_docarticle.html \ test_editablebody.html \ diff --git a/accessible/tests/mochitest/test_nsIAccessible_comboboxes.xul b/accessible/tests/mochitest/states/test_comboboxes.xul similarity index 96% rename from accessible/tests/mochitest/test_nsIAccessible_comboboxes.xul rename to accessible/tests/mochitest/states/test_comboboxes.xul index 6dfe7aca245..7edbcb52d1f 100644 --- a/accessible/tests/mochitest/test_nsIAccessible_comboboxes.xul +++ b/accessible/tests/mochitest/states/test_comboboxes.xul @@ -16,9 +16,9 @@ src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js" /> diff --git a/content/base/public/nsContentCID.h b/content/base/public/nsContentCID.h index 77074af5103..4b032d8cd19 100644 --- a/content/base/public/nsContentCID.h +++ b/content/base/public/nsContentCID.h @@ -214,15 +214,11 @@ #define NS_RANGEUTILS_CID \ { 0xa6cf9126, 0x15b3, 0x11d2, {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } } -#ifdef MOZ_SVG - #define NS_SVGDOCUMENT_CID \ { /* b7f44954-1dd1-11b2-8c2e-c2feab4186bc */ \ 0xb7f44954, 0x11d1, 0x11b2, \ {0x8c, 0x2e, 0xc2, 0xfe, 0xab, 0x41, 0x86, 0xbc}} -#endif // MOZ_SVG - #ifdef MOZ_MEDIA // {d899a152-9412-46b2-b651-2e71c5c2f05f} diff --git a/content/base/public/nsContentCreatorFunctions.h b/content/base/public/nsContentCreatorFunctions.h index bd56f71372f..e55273e6fdd 100644 --- a/content/base/public/nsContentCreatorFunctions.h +++ b/content/base/public/nsContentCreatorFunctions.h @@ -125,11 +125,9 @@ void NS_TrustedNewXULElement(nsIContent** aResult, already_AddRefed aNodeInfo); #endif -#ifdef MOZ_SVG nsresult NS_NewSVGElement(nsIContent** aResult, already_AddRefed aNodeInfo, mozilla::dom::FromParser aFromParser); -#endif nsresult NS_NewGenConImageContent(nsIContent** aResult, diff --git a/content/base/public/nsContentUtils.h b/content/base/public/nsContentUtils.h index e9700fadc3d..4ec4428b4ff 100644 --- a/content/base/public/nsContentUtils.h +++ b/content/base/public/nsContentUtils.h @@ -51,6 +51,17 @@ #include #endif +//A trick to handle IEEE floating point exceptions on FreeBSD - E.D. +#ifdef __FreeBSD__ +#include +#ifdef __alpha__ +static fp_except_t allmask = FP_X_INV|FP_X_OFL|FP_X_UFL|FP_X_DZ|FP_X_IMP; +#else +static fp_except_t allmask = FP_X_INV|FP_X_OFL|FP_X_UFL|FP_X_DZ|FP_X_IMP|FP_X_DNML; +#endif +static fp_except_t oldmask = fpsetmask(~allmask); +#endif + #include "nsAString.h" #include "nsIStatefulFrame.h" #include "nsINodeInfo.h" @@ -66,7 +77,6 @@ #include "nsTArray.h" #include "nsTextFragment.h" #include "nsReadableUtils.h" -#include "nsIPrefBranch2.h" #include "mozilla/AutoRestore.h" #include "nsINode.h" #include "nsHashtable.h" @@ -93,7 +103,6 @@ class imgIDecoderObserver; class imgIRequest; class imgILoader; class imgICache; -class nsIPrefBranch2; class nsIImageLoadingContent; class nsIDOMHTMLFormElement; class nsIDOMDocument; @@ -118,8 +127,6 @@ class nsPIDOMWindow; class nsPIDOMEventTarget; class nsIPresShell; class nsIXPConnectJSObjectHolder; -class nsPrefOldCallback; -class nsPrefObserverHashKey; #ifdef MOZ_XTF class nsIXTFService; #endif @@ -135,11 +142,6 @@ struct nsIntMargin; class nsPIDOMWindow; class nsIDocumentLoaderFactory; -#ifndef have_PrefChangedFunc_typedef -typedef int (*PR_CALLBACK PrefChangedFunc)(const char *, void *); -#define have_PrefChangedFunc_typedef -#endif - namespace mozilla { namespace layers { @@ -214,7 +216,8 @@ public: * When a document's scope changes (e.g., from document.open(), call this * function to move all content wrappers from the old scope to the new one. */ - static nsresult ReparentContentWrappersInScope(nsIScriptGlobalObject *aOldScope, + static nsresult ReparentContentWrappersInScope(JSContext *cx, + nsIScriptGlobalObject *aOldScope, nsIScriptGlobalObject *aNewScope); static PRBool IsCallerChrome(); @@ -550,27 +553,6 @@ public: static void SplitExpatName(const PRUnichar *aExpatName, nsIAtom **aPrefix, nsIAtom **aTagName, PRInt32 *aNameSpaceID); - static nsAdoptingCString GetCharPref(const char *aPref); - static PRPackedBool GetBoolPref(const char *aPref, - PRBool aDefault = PR_FALSE); - static PRInt32 GetIntPref(const char *aPref, PRInt32 aDefault = 0); - static nsAdoptingString GetLocalizedStringPref(const char *aPref); - static nsAdoptingString GetStringPref(const char *aPref); - static void RegisterPrefCallback(const char *aPref, - PrefChangedFunc aCallback, - void * aClosure); - static void UnregisterPrefCallback(const char *aPref, - PrefChangedFunc aCallback, - void * aClosure); - static void AddBoolPrefVarCache(const char* aPref, PRBool* aVariable, - PRBool aDefault = PR_FALSE); - static void AddIntPrefVarCache(const char* aPref, PRInt32* aVariable, - PRInt32 aDefault = 0); - static nsIPrefBranch2 *GetPrefBranch() - { - return sPrefBranch; - } - // Get a permission-manager setting for the given uri and type. // If the pref doesn't exist or if it isn't ALLOW_ACTION, PR_FALSE is // returned, otherwise PR_TRUE is returned. @@ -770,9 +752,7 @@ public: eFORMS_PROPERTIES, ePRINTING_PROPERTIES, eDOM_PROPERTIES, -#ifdef MOZ_SVG eSVG_PROPERTIES, -#endif eBRAND_PROPERTIES, eCOMMON_DIALOG_PROPERTIES, PropertiesFile_COUNT @@ -865,16 +845,6 @@ public: */ static PRBool IsInChromeDocshell(nsIDocument *aDocument); - /** - * Release *aSupportsPtr when the shutdown notification is received - */ - static nsresult ReleasePtrOnShutdown(nsISupports** aSupportsPtr) { - NS_ASSERTION(aSupportsPtr, "Expect to crash!"); - NS_ASSERTION(*aSupportsPtr, "Expect to crash!"); - return sPtrsToPtrsToRelease->AppendElement(aSupportsPtr) != nsnull ? NS_OK : - NS_ERROR_OUT_OF_MEMORY; - } - /** * Return the content policy service */ @@ -1491,29 +1461,6 @@ public: return sScriptBlockerCount == 0; } - /** - * Get/Set the current number of removable updates. Currently only - * UPDATE_CONTENT_MODEL updates are removable, and only when firing mutation - * events. These functions should only be called by mozAutoDocUpdateRemover. - * The count is also adjusted by the normal calls to BeginUpdate/EndUpdate. - */ - static void AddRemovableScriptBlocker() - { - AddScriptBlocker(); - ++sRemovableScriptBlockerCount; - } - static void RemoveRemovableScriptBlocker() - { - NS_ASSERTION(sRemovableScriptBlockerCount != 0, - "Number of removable blockers should never go below zero"); - --sRemovableScriptBlockerCount; - RemoveScriptBlocker(); - } - static PRUint32 GetRemovableScriptBlockerLevel() - { - return sRemovableScriptBlockerCount; - } - /* Process viewport META data. This gives us information for the scale * and zoom of a page on mobile devices. We stick the information in * the document header and use it later on after rendering. @@ -1823,11 +1770,6 @@ private: static nsIXTFService *sXTFService; #endif - static nsIPrefBranch2 *sPrefBranch; - // For old compatibility of RegisterPrefCallback - static nsRefPtrHashtable - *sPrefCallbackTable; - static bool sImgLoaderInitialized; static void InitImgLoader(); @@ -1851,9 +1793,6 @@ private: static nsIWordBreaker* sWordBreaker; static nsIUGenCategory* sGenCat; - // Holds pointers to nsISupports* that should be released at shutdown - static nsTArray* sPtrsToPtrsToRelease; - static nsIScriptRuntime* sScriptRuntimes[NS_STID_ARRAY_UBOUND]; static PRInt32 sScriptRootCount[NS_STID_ARRAY_UBOUND]; static PRUint32 sJSGCThingRootCount; @@ -1864,7 +1803,6 @@ private: static PRBool sInitialized; static PRUint32 sScriptBlockerCount; - static PRUint32 sRemovableScriptBlockerCount; #ifdef DEBUG static PRUint32 sDOMNodeRemovedSuppressCount; #endif @@ -1932,33 +1870,6 @@ private: MOZILLA_DECL_USE_GUARD_OBJECT_NOTIFIER }; -class NS_STACK_CLASS nsAutoRemovableScriptBlocker { -public: - nsAutoRemovableScriptBlocker(MOZILLA_GUARD_OBJECT_NOTIFIER_ONLY_PARAM) { - MOZILLA_GUARD_OBJECT_NOTIFIER_INIT; - nsContentUtils::AddRemovableScriptBlocker(); - } - ~nsAutoRemovableScriptBlocker() { - nsContentUtils::RemoveRemovableScriptBlocker(); - } -private: - MOZILLA_DECL_USE_GUARD_OBJECT_NOTIFIER -}; - -class NS_STACK_CLASS mozAutoRemovableBlockerRemover -{ -public: - mozAutoRemovableBlockerRemover(nsIDocument* aDocument - MOZILLA_GUARD_OBJECT_NOTIFIER_PARAM); - ~mozAutoRemovableBlockerRemover(); - -private: - PRUint32 mNestingLevel; - nsCOMPtr mDocument; - nsCOMPtr mObserver; - MOZILLA_DECL_USE_GUARD_OBJECT_NOTIFIER -}; - class NS_STACK_CLASS nsAutoScriptBlockerSuppressNodeRemoved : public nsAutoScriptBlocker { public: @@ -1983,6 +1894,88 @@ public: } \ } else +/** + * Macros to workaround math-bugs bugs in various platforms + */ + +/** + * Stefan Hanske reports: + * ARM is a little endian architecture but 64 bit double words are stored + * differently: the 32 bit words are in little endian byte order, the two words + * are stored in big endian`s way. + */ + +#if defined(__arm) || defined(__arm32__) || defined(__arm26__) || defined(__arm__) +#if !defined(__VFP_FP__) +#define FPU_IS_ARM_FPA +#endif +#endif + +typedef union dpun { + struct { +#if defined(IS_LITTLE_ENDIAN) && !defined(FPU_IS_ARM_FPA) + PRUint32 lo, hi; +#else + PRUint32 hi, lo; +#endif + } s; + PRFloat64 d; +public: + operator double() const { + return d; + } +} dpun; + +/** + * Utility class for doubles + */ +#if (__GNUC__ == 2 && __GNUC_MINOR__ > 95) || __GNUC__ > 2 +/** + * This version of the macros is safe for the alias optimizations + * that gcc does, but uses gcc-specific extensions. + */ +#define DOUBLE_HI32(x) (__extension__ ({ dpun u; u.d = (x); u.s.hi; })) +#define DOUBLE_LO32(x) (__extension__ ({ dpun u; u.d = (x); u.s.lo; })) + +#else // __GNUC__ + +/* We don't know of any non-gcc compilers that perform alias optimization, + * so this code should work. + */ + +#if defined(IS_LITTLE_ENDIAN) && !defined(FPU_IS_ARM_FPA) +#define DOUBLE_HI32(x) (((PRUint32 *)&(x))[1]) +#define DOUBLE_LO32(x) (((PRUint32 *)&(x))[0]) +#else +#define DOUBLE_HI32(x) (((PRUint32 *)&(x))[0]) +#define DOUBLE_LO32(x) (((PRUint32 *)&(x))[1]) +#endif + +#endif // __GNUC__ + +#define DOUBLE_HI32_SIGNBIT 0x80000000 +#define DOUBLE_HI32_EXPMASK 0x7ff00000 +#define DOUBLE_HI32_MANTMASK 0x000fffff + +#define DOUBLE_IS_NaN(x) \ +((DOUBLE_HI32(x) & DOUBLE_HI32_EXPMASK) == DOUBLE_HI32_EXPMASK && \ + (DOUBLE_LO32(x) || (DOUBLE_HI32(x) & DOUBLE_HI32_MANTMASK))) + +#ifdef IS_BIG_ENDIAN +#define DOUBLE_NaN {{DOUBLE_HI32_EXPMASK | DOUBLE_HI32_MANTMASK, \ + 0xffffffff}} +#else +#define DOUBLE_NaN {{0xffffffff, \ + DOUBLE_HI32_EXPMASK | DOUBLE_HI32_MANTMASK}} +#endif + +#if defined(XP_WIN) +#define DOUBLE_COMPARE(LVAL, OP, RVAL) \ + (!DOUBLE_IS_NaN(LVAL) && !DOUBLE_IS_NaN(RVAL) && (LVAL) OP (RVAL)) +#else +#define DOUBLE_COMPARE(LVAL, OP, RVAL) ((LVAL) OP (RVAL)) +#endif + /* * Check whether a floating point number is finite (not +/-infinity and not a * NaN value). diff --git a/content/base/public/nsIDOMFile.idl b/content/base/public/nsIDOMFile.idl index f317562ae75..f0048d10f9b 100644 --- a/content/base/public/nsIDOMFile.idl +++ b/content/base/public/nsIDOMFile.idl @@ -82,7 +82,7 @@ interface nsIDOMFile : nsIDOMBlob }; [scriptable, uuid(c4a77171-039b-4f84-97f9-820fb51626af)] -interface nsIDOMBlobBuilder : nsISupports +interface nsIDOMMozBlobBuilder : nsISupports { nsIDOMBlob getBlob([optional] in DOMString contentType); [implicit_jscontext] void append(in jsval data); diff --git a/content/base/public/nsIDocument.h b/content/base/public/nsIDocument.h index 2c705faf867..aff5432e9c9 100644 --- a/content/base/public/nsIDocument.h +++ b/content/base/public/nsIDocument.h @@ -124,8 +124,8 @@ class Element; #define NS_IDOCUMENT_IID \ -{ 0x26ef6218, 0xcd5e, 0x4953, \ - { 0xbb, 0x57, 0xb8, 0x50, 0x29, 0xa1, 0xae, 0x40 } } +{ 0x2ec7872f, 0x97c3, 0x43de, \ + { 0x81, 0x0a, 0x8f, 0x18, 0xa0, 0xa0, 0xdf, 0x30 } } // Flag for AddStyleSheet(). #define NS_STYLESHEET_FROM_CATALOG (1 << 0) @@ -361,7 +361,7 @@ public: /** * Get the Content-Type of this document. * (This will always return NS_OK, but has this signature to be compatible - * with nsIDOMNSDocument::GetContentType()) + * with nsIDOMDocument::GetContentType()) */ NS_IMETHOD GetContentType(nsAString& aContentType) = 0; @@ -479,8 +479,6 @@ public: void SetBFCacheEntry(nsISHEntry* aSHEntry) { mSHEntry = aSHEntry; - // Doing this just to keep binary compat for the gecko 2.0 release - mShellIsHidden = !!aSHEntry; } nsISHEntry* GetBFCacheEntry() const { return mSHEntry; } @@ -1079,7 +1077,7 @@ public: nsIDOMNodeList** aResult) = 0; /** - * Helper for nsIDOMNSDocument::elementFromPoint implementation that allows + * Helper for nsIDOMDocument::elementFromPoint implementation that allows * ignoring the scroll frame and/or avoiding layout flushes. * * @see nsIDOMWindowUtils::elementFromPoint @@ -1519,6 +1517,8 @@ public: virtual nsresult GetStateObject(nsIVariant** aResult) = 0; + virtual Element* FindImageMap(const nsAString& aNormalizedMapName) = 0; + protected: ~nsIDocument() { @@ -1621,10 +1621,6 @@ protected: // document in it. PRPackedBool mIsInitialDocumentInWindow; - // True if we're currently bfcached. This is only here for binary compat. - // Remove once the gecko 2.0 has branched and just use mSHEntry instead. - PRPackedBool mShellIsHidden; - PRPackedBool mIsRegularHTML; PRPackedBool mIsXUL; @@ -1796,10 +1792,8 @@ NS_NewHTMLDocument(nsIDocument** aInstancePtrResult); nsresult NS_NewXMLDocument(nsIDocument** aInstancePtrResult); -#ifdef MOZ_SVG nsresult NS_NewSVGDocument(nsIDocument** aInstancePtrResult); -#endif nsresult NS_NewImageDocument(nsIDocument** aInstancePtrResult); diff --git a/content/base/public/nsINode.h b/content/base/public/nsINode.h index 33197f89b30..cafde14d1d4 100644 --- a/content/base/public/nsINode.h +++ b/content/base/public/nsINode.h @@ -514,8 +514,7 @@ public: * Note: If there is no child at aIndex, this method will simply do nothing. */ virtual nsresult RemoveChildAt(PRUint32 aIndex, - PRBool aNotify, - PRBool aMutationEvent = PR_TRUE) = 0; + PRBool aNotify) = 0; /** * Get a property associated with this node. @@ -1295,8 +1294,7 @@ protected: * @param aMutationEvent whether to fire a mutation event for this removal. */ nsresult doRemoveChildAt(PRUint32 aIndex, PRBool aNotify, nsIContent* aKid, - nsAttrAndChildArray& aChildArray, - PRBool aMutationEvent); + nsAttrAndChildArray& aChildArray); /** * Most of the implementation of the nsINode InsertChildAt method. diff --git a/content/base/src/mozAutoDocUpdate.h b/content/base/src/mozAutoDocUpdate.h index 58a6a3ae55b..a4949af79c9 100644 --- a/content/base/src/mozAutoDocUpdate.h +++ b/content/base/src/mozAutoDocUpdate.h @@ -52,9 +52,6 @@ public: if (mDocument) { mDocument->BeginUpdate(mUpdateType); } - else if (aUpdateType == UPDATE_CONTENT_MODEL) { - nsContentUtils::AddRemovableScriptBlocker(); - } else { nsContentUtils::AddScriptBlocker(); } @@ -65,9 +62,6 @@ public: if (mDocument) { mDocument->EndUpdate(mUpdateType); } - else if (mUpdateType == UPDATE_CONTENT_MODEL) { - nsContentUtils::RemoveRemovableScriptBlocker(); - } else { nsContentUtils::RemoveScriptBlocker(); } diff --git a/content/base/src/nsAttrValue.cpp b/content/base/src/nsAttrValue.cpp index f622bc7eee1..bfef46f3fa4 100644 --- a/content/base/src/nsAttrValue.cpp +++ b/content/base/src/nsAttrValue.cpp @@ -52,9 +52,7 @@ #include "nsContentUtils.h" #include "nsReadableUtils.h" #include "prprf.h" -#ifdef MOZ_SVG #include "nsISVGValue.h" -#endif namespace css = mozilla::css; @@ -86,13 +84,11 @@ nsAttrValue::nsAttrValue(css::StyleRule* aValue, const nsAString* aSerialized) SetTo(aValue, aSerialized); } -#ifdef MOZ_SVG nsAttrValue::nsAttrValue(nsISVGValue* aValue) : mBits(0) { SetTo(aValue); } -#endif nsAttrValue::nsAttrValue(const nsIntMargin& aValue) : mBits(0) @@ -255,13 +251,11 @@ nsAttrValue::SetTo(const nsAttrValue& aOther) } break; } -#ifdef MOZ_SVG case eSVGValue: { NS_ADDREF(cont->mSVGValue = otherCont->mSVGValue); break; } -#endif case eDoubleValue: { cont->mDoubleValue = otherCont->mDoubleValue; @@ -323,7 +317,6 @@ nsAttrValue::SetTo(css::StyleRule* aValue, const nsAString* aSerialized) } } -#ifdef MOZ_SVG void nsAttrValue::SetTo(nsISVGValue* aValue) { @@ -333,7 +326,6 @@ nsAttrValue::SetTo(nsISVGValue* aValue) cont->mType = eSVGValue; } } -#endif void nsAttrValue::SetTo(const nsIntMargin& aValue) @@ -436,13 +428,11 @@ nsAttrValue::ToString(nsAString& aResult) const break; } -#ifdef MOZ_SVG case eSVGValue: { GetMiscContainer()->mSVGValue->GetValueString(aResult); break; } -#endif case eDoubleValue: { aResult.Truncate(); @@ -601,12 +591,10 @@ nsAttrValue::HashValue() const } return retval; } -#ifdef MOZ_SVG case eSVGValue: { return NS_PTR_TO_INT32(cont->mSVGValue); } -#endif case eDoubleValue: { // XXX this is crappy, but oh well @@ -700,12 +688,10 @@ nsAttrValue::Equals(const nsAttrValue& aOther) const needsStringComparison = PR_TRUE; break; } -#ifdef MOZ_SVG case eSVGValue: { return thisCont->mSVGValue == otherCont->mSVGValue; } -#endif case eDoubleValue: { return thisCont->mDoubleValue == otherCont->mDoubleValue; @@ -1309,13 +1295,11 @@ nsAttrValue::EnsureEmptyMiscContainer() delete cont->mAtomArray; break; } -#ifdef MOZ_SVG case eSVGValue: { NS_RELEASE(cont->mSVGValue); break; } -#endif case eIntMarginValue: { delete cont->mIntMargin; diff --git a/content/base/src/nsAttrValue.h b/content/base/src/nsAttrValue.h index 8d2f0e93f3e..566802cf12a 100644 --- a/content/base/src/nsAttrValue.h +++ b/content/base/src/nsAttrValue.h @@ -105,9 +105,7 @@ public: nsAttrValue(const nsAttrValue& aOther); explicit nsAttrValue(const nsAString& aValue); nsAttrValue(mozilla::css::StyleRule* aValue, const nsAString* aSerialized); -#ifdef MOZ_SVG explicit nsAttrValue(nsISVGValue* aValue); -#endif explicit nsAttrValue(const nsIntMargin& aValue); ~nsAttrValue(); @@ -127,9 +125,7 @@ public: // struct. eCSSStyleRule = 0x10, eAtomArray = 0x11 -#ifdef MOZ_SVG ,eSVGValue = 0x12 -#endif ,eDoubleValue = 0x13 ,eIntMarginValue = 0x14 }; @@ -142,9 +138,7 @@ public: void SetTo(const nsAString& aValue); void SetTo(PRInt16 aInt); void SetTo(mozilla::css::StyleRule* aValue, const nsAString* aSerialized); -#ifdef MOZ_SVG void SetTo(nsISVGValue* aValue); -#endif void SetTo(const nsIntMargin& aValue); void SwapValueWith(nsAttrValue& aOther); @@ -162,9 +156,7 @@ public: inline float GetPercentValue() const; inline AtomArray* GetAtomArrayValue() const; inline mozilla::css::StyleRule* GetCSSStyleRuleValue() const; -#ifdef MOZ_SVG inline nsISVGValue* GetSVGValue() const; -#endif inline double GetDoubleValue() const; PRBool GetIntMarginValue(nsIntMargin& aMargin) const; @@ -343,9 +335,7 @@ private: PRInt32 mPercent; mozilla::css::StyleRule* mCSSStyleRule; AtomArray* mAtomArray; -#ifdef MOZ_SVG nsISVGValue* mSVGValue; -#endif double mDoubleValue; nsIntMargin* mIntMargin; }; @@ -449,14 +439,12 @@ nsAttrValue::GetCSSStyleRuleValue() const return GetMiscContainer()->mCSSStyleRule; } -#ifdef MOZ_SVG inline nsISVGValue* nsAttrValue::GetSVGValue() const { NS_PRECONDITION(Type() == eSVGValue, "wrong type"); return GetMiscContainer()->mSVGValue; } -#endif inline double nsAttrValue::GetDoubleValue() const diff --git a/content/base/src/nsCSPService.cpp b/content/base/src/nsCSPService.cpp index ff825fe3ac2..c6f89beb2fc 100644 --- a/content/base/src/nsCSPService.cpp +++ b/content/base/src/nsCSPService.cpp @@ -44,7 +44,6 @@ #include "nsIObserver.h" #include "nsIDocument.h" #include "nsIContent.h" -#include "nsContentUtils.h" #include "nsCSPService.h" #include "nsIContentSecurityPolicy.h" #include "nsIChannelPolicy.h" @@ -55,6 +54,9 @@ #include "nsChannelProperties.h" #include "nsIAsyncVerifyRedirectCallback.h" #include "nsAsyncRedirectVerifyHelper.h" +#include "mozilla/Preferences.h" + +using namespace mozilla; /* Keeps track of whether or not CSP is enabled */ PRBool CSPService::sCSPEnabled = PR_TRUE; @@ -65,7 +67,7 @@ static PRLogModuleInfo* gCspPRLog; CSPService::CSPService() { - nsContentUtils::AddBoolPrefVarCache("security.csp.enable", &sCSPEnabled); + Preferences::AddBoolVarCache(&sCSPEnabled, "security.csp.enable"); #ifdef PR_LOGGING if (!gCspPRLog) diff --git a/content/base/src/nsContentSink.cpp b/content/base/src/nsContentSink.cpp index 32887e760f5..00c17bf3dff 100644 --- a/content/base/src/nsContentSink.cpp +++ b/content/base/src/nsContentSink.cpp @@ -89,7 +89,6 @@ #include "nsIAppShell.h" #include "nsIWidget.h" #include "nsWidgetsCID.h" -#include "nsIDOMNSDocument.h" #include "nsIRequest.h" #include "nsNodeUtils.h" #include "nsIDOMNode.h" @@ -103,6 +102,9 @@ #include "nsGenericHTMLElement.h" #include "nsHTMLDNSPrefetch.h" #include "nsISupportsPrimitives.h" +#include "mozilla/Preferences.h" + +using namespace mozilla; PRLogModuleInfo* gContentSinkLogModuleInfo; @@ -233,11 +235,11 @@ PRBool nsContentSink::sCanInterruptParser; void nsContentSink::InitializeStatics() { - nsContentUtils::AddBoolPrefVarCache("content.notify.ontimer", - &sNotifyOnTimer, PR_TRUE); + Preferences::AddBoolVarCache(&sNotifyOnTimer, + "content.notify.ontimer", PR_TRUE); // -1 means never. - nsContentUtils::AddIntPrefVarCache("content.notify.backoffcount", - &sBackoffCount, -1); + Preferences::AddIntVarCache(&sBackoffCount, + "content.notify.backoffcount", -1); // The gNotificationInterval has a dramatic effect on how long it // takes to initially display content for slow connections. // The current value provides good @@ -245,29 +247,28 @@ nsContentSink::InitializeStatics() // in page load time. If this value is set below 1/10 of second // it starts to impact page load performance. // see bugzilla bug 72138 for more info. - nsContentUtils::AddIntPrefVarCache("content.notify.interval", - &sNotificationInterval, - 120000); - nsContentUtils::AddIntPrefVarCache("content.sink.interactive_deflect_count", - &sInteractiveDeflectCount, 0); - nsContentUtils::AddIntPrefVarCache("content.sink.perf_deflect_count", - &sPerfDeflectCount, 200); - nsContentUtils::AddIntPrefVarCache("content.sink.pending_event_mode", - &sPendingEventMode, 1); - nsContentUtils::AddIntPrefVarCache("content.sink.event_probe_rate", - &sEventProbeRate, 1); - nsContentUtils::AddIntPrefVarCache("content.sink.interactive_parse_time", - &sInteractiveParseTime, 3000); - nsContentUtils::AddIntPrefVarCache("content.sink.perf_parse_time", - &sPerfParseTime, 360000); - nsContentUtils::AddIntPrefVarCache("content.sink.interactive_time", - &sInteractiveTime, 750000); - nsContentUtils::AddIntPrefVarCache("content.sink.initial_perf_time", - &sInitialPerfTime, 2000000); - nsContentUtils::AddIntPrefVarCache("content.sink.enable_perf_mode", - &sEnablePerfMode, 0); - nsContentUtils::AddBoolPrefVarCache("content.interrupt.parsing", - &sCanInterruptParser, PR_TRUE); + Preferences::AddIntVarCache(&sNotificationInterval, + "content.notify.interval", 120000); + Preferences::AddIntVarCache(&sInteractiveDeflectCount, + "content.sink.interactive_deflect_count", 0); + Preferences::AddIntVarCache(&sPerfDeflectCount, + "content.sink.perf_deflect_count", 200); + Preferences::AddIntVarCache(&sPendingEventMode, + "content.sink.pending_event_mode", 1); + Preferences::AddIntVarCache(&sEventProbeRate, + "content.sink.event_probe_rate", 1); + Preferences::AddIntVarCache(&sInteractiveParseTime, + "content.sink.interactive_parse_time", 3000); + Preferences::AddIntVarCache(&sPerfParseTime, + "content.sink.perf_parse_time", 360000); + Preferences::AddIntVarCache(&sInteractiveTime, + "content.sink.interactive_time", 750000); + Preferences::AddIntVarCache(&sInitialPerfTime, + "content.sink.initial_perf_time", 2000000); + Preferences::AddIntVarCache(&sEnablePerfMode, + "content.sink.enable_perf_mode", 0); + Preferences::AddBoolVarCache(&sCanInterruptParser, + "content.interrupt.parsing", PR_TRUE); } nsresult diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index 3c264ce3b4a..77d7b103395 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -49,9 +49,6 @@ #include "nsAString.h" #include "nsPrintfCString.h" #include "nsUnicharUtils.h" -#include "nsIPrefService.h" -#include "nsIPrefBranch2.h" -#include "nsIPrefLocalizedString.h" #include "nsServiceManagerUtils.h" #include "nsIScriptGlobalObject.h" #include "nsIScriptContext.h" @@ -211,8 +208,11 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID); #endif #include "nsDOMTouchEvent.h" +#include "mozilla/Preferences.h" + using namespace mozilla::dom; using namespace mozilla::layers; +using namespace mozilla; const char kLoadAsData[] = "loadAsData"; @@ -230,7 +230,6 @@ nsIIOService *nsContentUtils::sIOService; #ifdef MOZ_XTF nsIXTFService *nsContentUtils::sXTFService = nsnull; #endif -nsIPrefBranch2 *nsContentUtils::sPrefBranch = nsnull; imgILoader *nsContentUtils::sImgLoader; imgICache *nsContentUtils::sImgCache; nsIConsoleService *nsContentUtils::sConsoleService; @@ -244,7 +243,6 @@ PRBool nsContentUtils::sTriedToGetContentPolicy = PR_FALSE; nsILineBreaker *nsContentUtils::sLineBreaker; nsIWordBreaker *nsContentUtils::sWordBreaker; nsIUGenCategory *nsContentUtils::sGenCat; -nsTArray *nsContentUtils::sPtrsToPtrsToRelease; nsIScriptRuntime *nsContentUtils::sScriptRuntimes[NS_STID_ARRAY_UBOUND]; PRInt32 nsContentUtils::sScriptRootCount[NS_STID_ARRAY_UBOUND]; PRUint32 nsContentUtils::sJSGCThingRootCount; @@ -252,7 +250,6 @@ PRUint32 nsContentUtils::sJSGCThingRootCount; nsIBidiKeyboard *nsContentUtils::sBidiKeyboard = nsnull; #endif PRUint32 nsContentUtils::sScriptBlockerCount = 0; -PRUint32 nsContentUtils::sRemovableScriptBlockerCount = 0; #ifdef DEBUG PRUint32 nsContentUtils::sDOMNodeRemovedSuppressCount = 0; #endif @@ -266,9 +263,6 @@ PRBool nsContentUtils::sAllowXULXBL_for_file = PR_FALSE; PRBool nsContentUtils::sInitialized = PR_FALSE; -nsRefPtrHashtable - *nsContentUtils::sPrefCallbackTable = nsnull; - static PLDHashTable sEventListenerManagersHash; class EventListenerManagerMapEntry : public PLDHashEntryHdr @@ -318,110 +312,6 @@ class nsSameOriginChecker : public nsIChannelEventSink, NS_DECL_NSIINTERFACEREQUESTOR }; -class nsPrefObserverHashKey : public PLDHashEntryHdr { -public: - typedef nsPrefObserverHashKey* KeyType; - typedef const nsPrefObserverHashKey* KeyTypePointer; - - static const nsPrefObserverHashKey* KeyToPointer(nsPrefObserverHashKey *aKey) - { - return aKey; - } - - static PLDHashNumber HashKey(const nsPrefObserverHashKey *aKey) - { - PRUint32 strHash = nsCRT::HashCode(aKey->mPref.BeginReading(), - aKey->mPref.Length()); - return PR_ROTATE_LEFT32(strHash, 4) ^ - NS_PTR_TO_UINT32(aKey->mCallback); - } - - nsPrefObserverHashKey(const char *aPref, PrefChangedFunc aCallback) : - mPref(aPref), mCallback(aCallback) { } - - nsPrefObserverHashKey(const nsPrefObserverHashKey *aOther) : - mPref(aOther->mPref), mCallback(aOther->mCallback) - { } - - PRBool KeyEquals(const nsPrefObserverHashKey *aOther) const - { - return mCallback == aOther->mCallback && - mPref.Equals(aOther->mPref); - } - - nsPrefObserverHashKey *GetKey() const - { - return const_cast(this); - } - - enum { ALLOW_MEMMOVE = PR_TRUE }; - -public: - nsCString mPref; - PrefChangedFunc mCallback; -}; - -// For nsContentUtils::RegisterPrefCallback/UnregisterPrefCallback -class nsPrefOldCallback : public nsIObserver, - public nsPrefObserverHashKey -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIOBSERVER - -public: - nsPrefOldCallback(const char *aPref, PrefChangedFunc aCallback) - : nsPrefObserverHashKey(aPref, aCallback) { } - - ~nsPrefOldCallback() { - nsIPrefBranch2 *prefBranch = nsContentUtils::GetPrefBranch(); - if(prefBranch) - prefBranch->RemoveObserver(mPref.get(), this); - } - - void AppendClosure(void *aClosure) { - mClosures.AppendElement(aClosure); - } - - void RemoveClosure(void *aClosure) { - mClosures.RemoveElement(aClosure); - } - - PRBool HasNoClosures() { - return mClosures.Length() == 0; - } - -public: - nsTArray mClosures; -}; - -NS_IMPL_ISUPPORTS1(nsPrefOldCallback, nsIObserver) - -NS_IMETHODIMP -nsPrefOldCallback::Observe(nsISupports *aSubject, - const char *aTopic, - const PRUnichar *aData) -{ - NS_ASSERTION(!strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID), - "invalid topic"); - NS_LossyConvertUTF16toASCII data(aData); - for (PRUint32 i = 0; i < mClosures.Length(); i++) { - mCallback(data.get(), mClosures.ElementAt(i)); - } - - return NS_OK; -} - -struct PrefCacheData { - void* cacheLocation; - union { - PRBool defaultValueBool; - PRInt32 defaultValueInt; - }; -}; - -nsTArray >* sPrefCacheData = nsnull; - // static nsresult nsContentUtils::Init() @@ -432,11 +322,6 @@ nsContentUtils::Init() return NS_OK; } - sPrefCacheData = new nsTArray >(); - - // It's ok to not have a pref service. - CallGetService(NS_PREFSERVICE_CONTRACTID, &sPrefBranch); - nsresult rv = NS_GetNameSpaceManager(&sNameSpaceManager); NS_ENSURE_SUCCESS(rv, rv); @@ -467,11 +352,6 @@ nsContentUtils::Init() rv = CallGetService(NS_UNICHARCATEGORY_CONTRACTID, &sGenCat); NS_ENSURE_SUCCESS(rv, rv); - sPtrsToPtrsToRelease = new nsTArray(); - if (!sPtrsToPtrsToRelease) { - return NS_ERROR_OUT_OF_MEMORY; - } - if (!InitializeEventTable()) return NS_ERROR_FAILURE; @@ -499,8 +379,8 @@ nsContentUtils::Init() sBlockedScriptRunners = new nsCOMArray; NS_ENSURE_TRUE(sBlockedScriptRunners, NS_ERROR_OUT_OF_MEMORY); - nsContentUtils::AddBoolPrefVarCache("dom.allow_XUL_XBL_for_file", - &sAllowXULXBL_for_file); + Preferences::AddBoolVarCache(&sAllowXULXBL_for_file, + "dom.allow_XUL_XBL_for_file"); sInitialized = PR_TRUE; @@ -627,7 +507,6 @@ nsContentUtils::InitializeEventTable() { { nsGkAtoms::onoverflow, NS_SCROLLPORT_OVERFLOW, EventNameType_XUL, NS_EVENT_NULL}, { nsGkAtoms::onunderflow, NS_SCROLLPORT_UNDERFLOW, EventNameType_XUL, NS_EVENT_NULL}, -#ifdef MOZ_SVG { nsGkAtoms::onSVGLoad, NS_SVG_LOAD, EventNameType_None, NS_SVG_EVENT }, { nsGkAtoms::onSVGUnload, NS_SVG_UNLOAD, EventNameType_None, NS_SVG_EVENT }, { nsGkAtoms::onSVGAbort, NS_SVG_ABORT, EventNameType_None, NS_SVG_EVENT }, @@ -639,7 +518,6 @@ nsContentUtils::InitializeEventTable() { // This is a bit hackish, but SVG's event names are weird. { nsGkAtoms::onzoom, NS_SVG_ZOOM, EventNameType_SVGSVG, NS_EVENT_NULL }, -#endif // MOZ_SVG #ifdef MOZ_SMIL { nsGkAtoms::onbegin, NS_SMIL_BEGIN, EventNameType_SMIL, NS_EVENT_NULL }, { nsGkAtoms::onbeginEvent, NS_SMIL_BEGIN, EventNameType_None, NS_SMIL_TIME_EVENT }, @@ -1129,9 +1007,10 @@ nsContentUtils::OfflineAppAllowed(nsIURI *aURI) } PRBool allowed; - nsresult rv = updateService->OfflineAppAllowedForURI(aURI, - sPrefBranch, - &allowed); + nsresult rv = + updateService->OfflineAppAllowedForURI(aURI, + Preferences::GetRootBranch(), + &allowed); return NS_SUCCEEDED(rv) && allowed; } @@ -1147,7 +1026,7 @@ nsContentUtils::OfflineAppAllowed(nsIPrincipal *aPrincipal) PRBool allowed; nsresult rv = updateService->OfflineAppAllowed(aPrincipal, - sPrefBranch, + Preferences::GetRootBranch(), &allowed); return NS_SUCCEEDED(rv) && allowed; } @@ -1167,15 +1046,6 @@ nsContentUtils::Shutdown() for (i = 0; i < PropertiesFile_COUNT; ++i) NS_IF_RELEASE(sStringBundles[i]); - // Clean up c-style's observer - if (sPrefCallbackTable) { - delete sPrefCallbackTable; - sPrefCallbackTable = nsnull; - } - - delete sPrefCacheData; - sPrefCacheData = nsnull; - NS_IF_RELEASE(sStringBundleService); NS_IF_RELEASE(sConsoleService); NS_IF_RELEASE(sDOMScriptObjectFactory); @@ -1193,7 +1063,6 @@ nsContentUtils::Shutdown() #endif NS_IF_RELEASE(sImgLoader); NS_IF_RELEASE(sImgCache); - NS_IF_RELEASE(sPrefBranch); #ifdef IBMBIDI NS_IF_RELEASE(sBidiKeyboard); #endif @@ -1205,15 +1074,6 @@ nsContentUtils::Shutdown() delete sUserDefinedEvents; sUserDefinedEvents = nsnull; - if (sPtrsToPtrsToRelease) { - for (i = 0; i < sPtrsToPtrsToRelease->Length(); ++i) { - nsISupports** ptrToPtr = sPtrsToPtrsToRelease->ElementAt(i); - NS_RELEASE(*ptrToPtr); - } - delete sPtrsToPtrsToRelease; - sPtrsToPtrsToRelease = nsnull; - } - if (sEventListenerManagersHash.ops) { NS_ASSERTION(sEventListenerManagersHash.entryCount == 0, "Event listener manager hash not empty at shutdown!"); @@ -1476,42 +1336,10 @@ nsContentUtils::GetContextAndScope(nsIDocument *aOldDocument, } nsresult -nsContentUtils::ReparentContentWrappersInScope(nsIScriptGlobalObject *aOldScope, +nsContentUtils::ReparentContentWrappersInScope(JSContext *cx, + nsIScriptGlobalObject *aOldScope, nsIScriptGlobalObject *aNewScope) { - JSContext *cx = nsnull; - - // Try really hard to find a context to work on. - nsIScriptContext *context = aOldScope->GetContext(); - if (context) { - cx = static_cast(context->GetNativeContext()); - } - - if (!cx) { - context = aNewScope->GetContext(); - if (context) { - cx = static_cast(context->GetNativeContext()); - } - - if (!cx) { - sThreadJSContextStack->Peek(&cx); - - if (!cx) { - sThreadJSContextStack->GetSafeJSContext(&cx); - - if (!cx) { - // Wow, this is really bad! - NS_WARNING("No context reachable in ReparentContentWrappers()!"); - - return NS_ERROR_NOT_AVAILABLE; - } - } - } - } - - // Now that we have a context, let's get the global objects from the two - // scopes and ask XPConnect to do the rest of the work. - JSObject *oldScopeObj = aOldScope->GetGlobalJSObject(); JSObject *newScopeObj = aNewScope->GetGlobalJSObject(); @@ -2595,186 +2423,6 @@ nsContentUtils::IsDraggableLink(const nsIContent* aContent) { return aContent->IsLink(getter_AddRefs(absURI)); } -// static -nsAdoptingCString -nsContentUtils::GetCharPref(const char *aPref) -{ - nsAdoptingCString result; - - if (sPrefBranch) { - sPrefBranch->GetCharPref(aPref, getter_Copies(result)); - } - - return result; -} - -// static -PRPackedBool -nsContentUtils::GetBoolPref(const char *aPref, PRBool aDefault) -{ - PRBool result; - - if (!sPrefBranch || - NS_FAILED(sPrefBranch->GetBoolPref(aPref, &result))) { - result = aDefault; - } - - return (PRPackedBool)result; -} - -// static -PRInt32 -nsContentUtils::GetIntPref(const char *aPref, PRInt32 aDefault) -{ - PRInt32 result; - - if (!sPrefBranch || - NS_FAILED(sPrefBranch->GetIntPref(aPref, &result))) { - result = aDefault; - } - - return result; -} - -// static -nsAdoptingString -nsContentUtils::GetLocalizedStringPref(const char *aPref) -{ - nsAdoptingString result; - - if (sPrefBranch) { - nsCOMPtr prefLocalString; - sPrefBranch->GetComplexValue(aPref, NS_GET_IID(nsIPrefLocalizedString), - getter_AddRefs(prefLocalString)); - if (prefLocalString) { - prefLocalString->GetData(getter_Copies(result)); - } - } - - return result; -} - -// static -nsAdoptingString -nsContentUtils::GetStringPref(const char *aPref) -{ - nsAdoptingString result; - - if (sPrefBranch) { - nsCOMPtr theString; - sPrefBranch->GetComplexValue(aPref, NS_GET_IID(nsISupportsString), - getter_AddRefs(theString)); - if (theString) { - theString->ToString(getter_Copies(result)); - } - } - - return result; -} - -// RegisterPrefCallback/UnregisterPrefCallback are for backward compatiblity -// with c-style observers. - -// static -void -nsContentUtils::RegisterPrefCallback(const char *aPref, - PrefChangedFunc aCallback, - void * aClosure) -{ - if (sPrefBranch) { - if (!sPrefCallbackTable) { - sPrefCallbackTable = - new nsRefPtrHashtable(); - sPrefCallbackTable->Init(); - } - - nsPrefObserverHashKey hashKey(aPref, aCallback); - nsRefPtr callback; - sPrefCallbackTable->Get(&hashKey, getter_AddRefs(callback)); - if (callback) { - callback->AppendClosure(aClosure); - return; - } - - callback = new nsPrefOldCallback(aPref, aCallback); - callback->AppendClosure(aClosure); - if (NS_SUCCEEDED(sPrefBranch->AddObserver(aPref, callback, PR_FALSE))) { - sPrefCallbackTable->Put(callback, callback); - } - } -} - -// static -void -nsContentUtils::UnregisterPrefCallback(const char *aPref, - PrefChangedFunc aCallback, - void * aClosure) -{ - if (sPrefBranch) { - if (!sPrefCallbackTable) { - return; - } - - nsPrefObserverHashKey hashKey(aPref, aCallback); - nsRefPtr callback; - sPrefCallbackTable->Get(&hashKey, getter_AddRefs(callback)); - - if (callback) { - callback->RemoveClosure(aClosure); - if (callback->HasNoClosures()) { - // Delete the callback since its list of closures is empty. - sPrefCallbackTable->Remove(callback); - } - } - } -} - -static int -BoolVarChanged(const char *aPref, void *aClosure) -{ - PrefCacheData* cache = static_cast(aClosure); - *((PRBool*)cache->cacheLocation) = - nsContentUtils::GetBoolPref(aPref, cache->defaultValueBool); - - return 0; -} - -void -nsContentUtils::AddBoolPrefVarCache(const char *aPref, - PRBool* aCache, - PRBool aDefault) -{ - *aCache = GetBoolPref(aPref, aDefault); - PrefCacheData* data = new PrefCacheData; - data->cacheLocation = aCache; - data->defaultValueBool = aDefault; - sPrefCacheData->AppendElement(data); - RegisterPrefCallback(aPref, BoolVarChanged, data); -} - -static int -IntVarChanged(const char *aPref, void *aClosure) -{ - PrefCacheData* cache = static_cast(aClosure); - *((PRInt32*)cache->cacheLocation) = - nsContentUtils::GetIntPref(aPref, cache->defaultValueInt); - - return 0; -} - -void -nsContentUtils::AddIntPrefVarCache(const char *aPref, - PRInt32* aCache, - PRInt32 aDefault) -{ - *aCache = GetIntPref(aPref, aDefault); - PrefCacheData* data = new PrefCacheData; - data->cacheLocation = aCache; - data->defaultValueInt = aDefault; - sPrefCacheData->AppendElement(data); - RegisterPrefCallback(aPref, IntVarChanged, data); -} - PRBool nsContentUtils::IsSitePermAllow(nsIURI* aURI, const char* aType) { @@ -3031,9 +2679,7 @@ static const char gPropertiesFiles[nsContentUtils::PropertiesFile_COUNT][56] = { "chrome://global/locale/layout/HtmlForm.properties", "chrome://global/locale/printing.properties", "chrome://global/locale/dom/dom.properties", -#ifdef MOZ_SVG "chrome://global/locale/svg/svg.properties", -#endif "chrome://branding/locale/brand.properties", "chrome://global/locale/commonDialogs.properties" }; @@ -4501,7 +4147,7 @@ nsContentUtils::GetLocalizedEllipsis() { static PRUnichar sBuf[4] = { 0, 0, 0, 0 }; if (!sBuf[0]) { - nsAutoString tmp(GetLocalizedStringPref("intl.ellipsis")); + nsAdoptingString tmp = Preferences::GetLocalizedString("intl.ellipsis"); PRUint32 len = NS_MIN(PRUint32(tmp.Length()), PRUint32(NS_ARRAY_LENGTH(sBuf) - 1)); CopyUnicodeTo(tmp, 0, sBuf, len); @@ -6193,35 +5839,6 @@ nsContentUtils::CheckCCWrapperTraversal(nsISupports* aScriptObjectHolder, } #endif -mozAutoRemovableBlockerRemover::mozAutoRemovableBlockerRemover(nsIDocument* aDocument MOZILLA_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL) -{ - MOZILLA_GUARD_OBJECT_NOTIFIER_INIT; - mNestingLevel = nsContentUtils::GetRemovableScriptBlockerLevel(); - mDocument = aDocument; - nsISupports* sink = aDocument ? aDocument->GetCurrentContentSink() : nsnull; - mObserver = do_QueryInterface(sink); - for (PRUint32 i = 0; i < mNestingLevel; ++i) { - if (mObserver) { - mObserver->EndUpdate(mDocument, UPDATE_CONTENT_MODEL); - } - nsContentUtils::RemoveRemovableScriptBlocker(); - } - - NS_ASSERTION(nsContentUtils::IsSafeToRunScript(), "killing mutation events"); -} - -mozAutoRemovableBlockerRemover::~mozAutoRemovableBlockerRemover() -{ - NS_ASSERTION(nsContentUtils::GetRemovableScriptBlockerLevel() == 0, - "Should have had none"); - for (PRUint32 i = 0; i < mNestingLevel; ++i) { - nsContentUtils::AddRemovableScriptBlocker(); - if (mObserver) { - mObserver->BeginUpdate(mDocument, UPDATE_CONTENT_MODEL); - } - } -} - // static PRBool nsContentUtils::IsFocusedContent(const nsIContent* aContent) @@ -6322,21 +5939,6 @@ nsContentUtils::PlatformToDOMLineBreaks(nsString &aString) } } -static nsIView* GetDisplayRootFor(nsIView* aView) -{ - nsIView *displayRoot = aView; - for (;;) { - nsIView *displayParent = displayRoot->GetParent(); - if (!displayParent) - return displayRoot; - - if (displayRoot->GetFloating() && !displayParent->GetFloating()) - return displayRoot; - displayRoot = displayParent; - } - return nsnull; -} - static already_AddRefed LayerManagerForDocumentInternal(nsIDocument *aDoc, bool aRequirePersistent, bool* aAllowRetaining) @@ -6372,7 +5974,7 @@ LayerManagerForDocumentInternal(nsIDocument *aDoc, bool aRequirePersistent, if (VM) { nsIView* rootView = VM->GetRootView(); if (rootView) { - nsIView* displayRoot = GetDisplayRootFor(rootView); + nsIView* displayRoot = nsIViewManager::GetDisplayRootFor(rootView); if (displayRoot) { nsIWidget* widget = displayRoot->GetNearestWidget(nsnull); if (widget) { diff --git a/content/base/src/nsCrossSiteListenerProxy.cpp b/content/base/src/nsCrossSiteListenerProxy.cpp index d79cfb15872..2905fc40479 100644 --- a/content/base/src/nsCrossSiteListenerProxy.cpp +++ b/content/base/src/nsCrossSiteListenerProxy.cpp @@ -60,6 +60,9 @@ #include "nsClassHashtable.h" #include "nsHashKeys.h" #include "nsStreamUtils.h" +#include "mozilla/Preferences.h" + +using namespace mozilla; #define PREFLIGHT_CACHE_SIZE 100 @@ -369,8 +372,10 @@ NS_IMPL_ISUPPORTS5(nsCORSListenerProxy, nsIStreamListener, void nsCORSListenerProxy::Startup() { - nsContentUtils::AddBoolPrefVarCache("content.cors.disable", &gDisableCORS); - nsContentUtils::AddBoolPrefVarCache("content.cors.no_private_data", &gDisableCORSPrivateData); + Preferences::AddBoolVarCache(&gDisableCORS, + "content.cors.disable"); + Preferences::AddBoolVarCache(&gDisableCORSPrivateData, + "content.cors.no_private_data"); } /* static */ diff --git a/content/base/src/nsDOMAttribute.cpp b/content/base/src/nsDOMAttribute.cpp index 874cfc28f6d..73e6249c300 100644 --- a/content/base/src/nsDOMAttribute.cpp +++ b/content/base/src/nsDOMAttribute.cpp @@ -610,9 +610,8 @@ nsDOMAttribute::AppendChildTo(nsIContent* aKid, PRBool aNotify) } nsresult -nsDOMAttribute::RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutationEvent) +nsDOMAttribute::RemoveChildAt(PRUint32 aIndex, PRBool aNotify) { - NS_ASSERTION(aMutationEvent, "Someone tried to inhibit mutations on attribute child removal."); if (aIndex != 0 || !mChild) { return NS_OK; } diff --git a/content/base/src/nsDOMAttribute.h b/content/base/src/nsDOMAttribute.h index cd9192606ad..b2381fe012e 100644 --- a/content/base/src/nsDOMAttribute.h +++ b/content/base/src/nsDOMAttribute.h @@ -94,7 +94,7 @@ public: virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify); virtual nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify); - virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutationEvent = PR_TRUE); + virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify); virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor); virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor); virtual nsresult DispatchDOMEvent(nsEvent* aEvent, nsIDOMEvent* aDOMEvent, diff --git a/content/base/src/nsDOMBlobBuilder.cpp b/content/base/src/nsDOMBlobBuilder.cpp index 3aad463f982..482f345ca93 100644 --- a/content/base/src/nsDOMBlobBuilder.cpp +++ b/content/base/src/nsDOMBlobBuilder.cpp @@ -221,7 +221,7 @@ nsDOMMultipartBlob::MozSlice(PRInt64 aStart, PRInt64 aEnd, return NS_OK; } -class nsDOMBlobBuilder : public nsIDOMBlobBuilder +class nsDOMBlobBuilder : public nsIDOMMozBlobBuilder { public: nsDOMBlobBuilder() @@ -229,7 +229,7 @@ public: {} NS_DECL_ISUPPORTS - NS_DECL_NSIDOMBLOBBUILDER + NS_DECL_NSIDOMMOZBLOBBUILDER protected: nsresult AppendVoidPtr(void* aData, PRUint32 aLength); nsresult AppendString(JSString* aString, JSContext* aCx); @@ -287,7 +287,7 @@ DOMCI_DATA(MozBlobBuilder, nsDOMBlobBuilder) NS_IMPL_ADDREF(nsDOMBlobBuilder) NS_IMPL_RELEASE(nsDOMBlobBuilder) NS_INTERFACE_MAP_BEGIN(nsDOMBlobBuilder) - NS_INTERFACE_MAP_ENTRY(nsIDOMBlobBuilder) + NS_INTERFACE_MAP_ENTRY(nsIDOMMozBlobBuilder) NS_INTERFACE_MAP_ENTRY(nsISupports) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozBlobBuilder) NS_INTERFACE_MAP_END diff --git a/content/base/src/nsDOMFile.cpp b/content/base/src/nsDOMFile.cpp index 24b306f0be7..9c4a0b8a2db 100644 --- a/content/base/src/nsDOMFile.cpp +++ b/content/base/src/nsDOMFile.cpp @@ -64,6 +64,7 @@ #include "nsStringStream.h" #include "CheckedInt.h" #include "nsJSUtils.h" +#include "mozilla/Preferences.h" #include "plbase64.h" #include "prmem.h" @@ -499,12 +500,12 @@ nsDOMFile::GuessCharset(nsIInputStream *aStream, "universal_charset_detector"); if (!detector) { // No universal charset detector, try the default charset detector - const nsAdoptingString& detectorName = - nsContentUtils::GetLocalizedStringPref("intl.charset.detector"); + const nsAdoptingCString& detectorName = + Preferences::GetLocalizedCString("intl.charset.detector"); if (!detectorName.IsEmpty()) { nsCAutoString detectorContractID; detectorContractID.AssignLiteral(NS_CHARSET_DETECTOR_CONTRACTID_BASE); - AppendUTF16toUTF8(detectorName, detectorContractID); + detectorContractID += detectorName; detector = do_CreateInstance(detectorContractID.get()); } } diff --git a/content/base/src/nsDOMFileReader.cpp b/content/base/src/nsDOMFileReader.cpp index a00a5422047..ae3f34b3e6c 100644 --- a/content/base/src/nsDOMFileReader.cpp +++ b/content/base/src/nsDOMFileReader.cpp @@ -77,6 +77,9 @@ #include "nsLayoutStatics.h" #include "nsIScriptObjectPrincipal.h" #include "nsFileDataProtocolHandler.h" +#include "mozilla/Preferences.h" + +using namespace mozilla; #define LOAD_STR "load" #define ERROR_STR "error" @@ -684,12 +687,12 @@ nsDOMFileReader::GuessCharset(const char *aFileData, "universal_charset_detector"); if (!detector) { // No universal charset detector, try the default charset detector - const nsAdoptingString& detectorName = - nsContentUtils::GetLocalizedStringPref("intl.charset.detector"); + const nsAdoptingCString& detectorName = + Preferences::GetLocalizedCString("intl.charset.detector"); if (!detectorName.IsEmpty()) { nsCAutoString detectorContractID; detectorContractID.AssignLiteral(NS_CHARSET_DETECTOR_CONTRACTID_BASE); - AppendUTF16toUTF8(detectorName, detectorContractID); + detectorContractID += detectorName; detector = do_CreateInstance(detectorContractID.get()); } } diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index d11abcf47cc..391767cf1f2 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -203,6 +203,9 @@ static NS_DEFINE_CID(kDOMEventGroupCID, NS_DOMEVENTGROUP_CID); #include "nsXULAppAPI.h" #include "nsDOMTouchEvent.h" +#include "mozilla/Preferences.h" + +using namespace mozilla; using namespace mozilla::dom; typedef nsTArray LinkArray; @@ -1685,8 +1688,6 @@ NS_INTERFACE_TABLE_HEAD(nsDocument) NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY NS_DOCUMENT_INTERFACE_TABLE_BEGIN(nsDocument) NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDocument) - NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMDocumentStyle) - NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMNSDocumentStyle) NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMDocumentXBL) NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIScriptObjectPrincipal) NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOM3EventTarget) @@ -1870,6 +1871,8 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsDocument) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnloadBlocker) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mFirstBaseNodeWithHref) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mDOMImplementation) + NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR_AMBIGUOUS(mImageMaps, + nsIDOMNodeList) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOriginalDocument) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mCachedEncoder) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mStateObjectCached) @@ -1922,6 +1925,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDocument) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mDisplayDocument) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mFirstBaseNodeWithHref) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mDOMImplementation) + NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mImageMaps) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOriginalDocument) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mCachedEncoder) @@ -3446,9 +3450,8 @@ nsDocument::AppendChildTo(nsIContent* aKid, PRBool aNotify) } nsresult -nsDocument::RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutationEvent) +nsDocument::RemoveChildAt(PRUint32 aIndex, PRBool aNotify) { - NS_ASSERTION(aMutationEvent, "Someone tried to inhibit mutations on document child removal."); nsCOMPtr oldKid = GetChildAt(aIndex); if (!oldKid) { return NS_OK; @@ -3460,7 +3463,7 @@ nsDocument::RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutationEvent } nsresult rv = - doRemoveChildAt(aIndex, aNotify, oldKid, mChildren, aMutationEvent); + doRemoveChildAt(aIndex, aNotify, oldKid, mChildren); mCachedRootElement = nsnull; return rv; } @@ -3949,12 +3952,7 @@ nsDocument::BeginUpdate(nsUpdateType aUpdateType) } ++mUpdateNestLevel; - if (aUpdateType == UPDATE_CONTENT_MODEL) { - nsContentUtils::AddRemovableScriptBlocker(); - } - else { - nsContentUtils::AddScriptBlocker(); - } + nsContentUtils::AddScriptBlocker(); NS_DOCUMENT_NOTIFY_OBSERVERS(BeginUpdate, (this, aUpdateType)); } @@ -3963,12 +3961,7 @@ nsDocument::EndUpdate(nsUpdateType aUpdateType) { NS_DOCUMENT_NOTIFY_OBSERVERS(EndUpdate, (this, aUpdateType)); - if (aUpdateType == UPDATE_CONTENT_MODEL) { - nsContentUtils::RemoveRemovableScriptBlocker(); - } - else { - nsContentUtils::RemoveScriptBlocker(); - } + nsContentUtils::RemoveScriptBlocker(); --mUpdateNestLevel; @@ -4542,20 +4535,6 @@ nsDocument::CreateAttributeNS(const nsAString & aNamespaceURI, return CallQueryInterface(attribute, aResult); } -NS_IMETHODIMP -nsDocument::CreateEntityReference(const nsAString& aName, - nsIDOMEntityReference** aReturn) -{ - NS_ENSURE_ARG_POINTER(aReturn); - *aReturn = nsnull; - - if (IsHTML()) { - return NS_ERROR_DOM_NOT_SUPPORTED_ERR; - } - - return NS_OK; -} - NS_IMETHODIMP nsDocument::GetElementsByTagName(const nsAString& aTagname, nsIDOMNodeList** aReturn) @@ -5162,13 +5141,11 @@ nsDocument::GetTitle(nsAString& aTitle) rootElement->GetAttr(kNameSpaceID_None, nsGkAtoms::title, tmp); break; #endif -#ifdef MOZ_SVG case kNameSpaceID_SVG: if (rootElement->Tag() == nsGkAtoms::svg) { GetTitleFromElement(kNameSpaceID_SVG, tmp); break; } // else fall through -#endif default: GetTitleFromElement(kNameSpaceID_XHTML, tmp); break; @@ -5187,10 +5164,8 @@ nsDocument::SetTitle(const nsAString& aTitle) return NS_OK; switch (rootElement->GetNameSpaceID()) { -#ifdef MOZ_SVG case kNameSpaceID_SVG: return NS_OK; // SVG doesn't support setting a title -#endif #ifdef MOZ_XUL case kNameSpaceID_XUL: return rootElement->SetAttr(kNameSpaceID_None, nsGkAtoms::title, @@ -6152,12 +6127,6 @@ nsDocument::AdoptNode(nsIDOMNode *aAdoptedNode, nsIDOMNode **aResult) return CallQueryInterface(adoptedNode, aResult); } -NS_IMETHODIMP -nsDocument::NormalizeDocument() -{ - return Normalize(); -} - NS_IMETHODIMP nsDocument::GetOwnerDocument(nsIDOMDocument** aOwnerDocument) { @@ -8163,6 +8132,48 @@ nsDocument::GetStateObject(nsIVariant** aState) return NS_OK; } +Element* +nsDocument::FindImageMap(const nsAString& aUseMapValue) +{ + if (aUseMapValue.IsEmpty()) { + return nsnull; + } + + nsAString::const_iterator start, end; + aUseMapValue.BeginReading(start); + aUseMapValue.EndReading(end); + + PRInt32 hash = aUseMapValue.FindChar('#'); + if (hash < 0) { + return nsnull; + } + // aUsemap contains a '#', set start to point right after the '#' + start.advance(hash + 1); + + if (start == end) { + return nsnull; // aUsemap == "#" + } + + const nsAString& mapName = Substring(start, end); + + if (!mImageMaps) { + mImageMaps = new nsContentList(this, kNameSpaceID_XHTML, nsGkAtoms::map, nsGkAtoms::map); + } + + PRUint32 i, n = mImageMaps->Length(PR_TRUE); + for (i = 0; i < n; ++i) { + nsIContent* map = mImageMaps->GetNodeAt(i); + if (map->AttrValueIs(kNameSpaceID_None, nsGkAtoms::id, mapName, + eCaseMatters) || + map->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name, mapName, + eIgnoreCase)) { + return map->AsElement(); + } + } + + return nsnull; +} + nsresult nsDocument::AddImage(imgIRequest* aImage) { @@ -8261,7 +8272,7 @@ nsresult nsDocument::SetImageLockingState(PRBool aLocked) { if (XRE_GetProcessType() == GeckoProcessType_Content && - !nsContentUtils::GetBoolPref("content.image.allow_locking", PR_TRUE)) { + !Preferences::GetBool("content.image.allow_locking", PR_TRUE)) { return NS_OK; } diff --git a/content/base/src/nsDocument.h b/content/base/src/nsDocument.h index 38cc19c4f13..4571b2b8c2c 100644 --- a/content/base/src/nsDocument.h +++ b/content/base/src/nsDocument.h @@ -53,8 +53,6 @@ #include "nsHashSets.h" #include "nsIDOMXMLDocument.h" #include "nsIDOMDocumentXBL.h" -#include "nsIDOMNSDocument.h" -#include "nsIDOMNSDocumentStyle.h" #include "nsStubDocumentObserver.h" #include "nsIDOM3EventTarget.h" #include "nsIDOMNSEventTarget.h" @@ -490,8 +488,6 @@ protected: // the interface. class nsDocument : public nsIDocument, public nsIDOMXMLDocument, // inherits nsIDOMDocument - public nsIDOMNSDocument, - public nsIDOMNSDocumentStyle, public nsIDOMDocumentXBL, public nsSupportsWeakReference, public nsIDOMEventTarget, @@ -540,7 +536,7 @@ public: * Get the Content-Type of this document. */ // NS_IMETHOD GetContentType(nsAString& aContentType); - // Already declared in nsIDOMNSDocument + // Already declared in nsIDOMDocument /** * Set the Content-Type of this document. @@ -730,7 +726,7 @@ public: virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify); virtual nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify); - virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutationEvent = PR_TRUE); + virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify); virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor); virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor); virtual nsresult DispatchDOMEvent(nsEvent* aEvent, nsIDOMEvent* aDOMEvent, @@ -791,15 +787,6 @@ public: // nsIDOMXMLDocument NS_DECL_NSIDOMXMLDOCUMENT - // nsIDOMNSDocument - NS_DECL_NSIDOMNSDOCUMENT - - // nsIDOMDocumentStyle - NS_DECL_NSIDOMDOCUMENTSTYLE - - // nsIDOMNSDocumentStyle - NS_DECL_NSIDOMNSDOCUMENTSTYLE - // nsIDOMDocumentXBL NS_DECL_NSIDOMDOCUMENTXBL @@ -961,6 +948,8 @@ public: virtual nsresult GetStateObject(nsIVariant** aResult); + virtual Element* FindImageMap(const nsAString& aNormalizedMapName); + protected: friend class nsNodeUtils; @@ -1225,6 +1214,8 @@ private: nsCOMPtr mDOMImplementation; + nsRefPtr mImageMaps; + nsCString mScrollToRef; PRUint8 mScrolledToRefAlready : 1; PRUint8 mChangeScrollPosWhenScrollingToRef : 1; @@ -1241,7 +1232,6 @@ protected: #define NS_DOCUMENT_INTERFACE_TABLE_BEGIN(_class) \ NS_NODE_OFFSET_AND_INTERFACE_TABLE_BEGIN(_class) \ NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMDocument, nsDocument) \ - NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMNSDocument, nsDocument) \ NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMEventTarget, nsDocument) \ NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMNode, nsDocument) diff --git a/content/base/src/nsEventSource.cpp b/content/base/src/nsEventSource.cpp index d3112ff3350..ee29db88cd1 100755 --- a/content/base/src/nsEventSource.cpp +++ b/content/base/src/nsEventSource.cpp @@ -57,6 +57,9 @@ #include "nsICharsetConverterManager.h" #include "nsIChannelPolicy.h" #include "nsIContentSecurityPolicy.h" +#include "mozilla/Preferences.h" + +using namespace mozilla; #define REPLACEMENT_CHAR (PRUnichar)0xFFFD #define BOM_CHAR (PRUnichar)0xFEFF @@ -296,8 +299,8 @@ nsEventSource::Init(nsIPrincipal* aPrincipal, mOrigin = origin; mReconnectionTime = - nsContentUtils::GetIntPref("dom.server-events.default-reconnection-time", - DEFAULT_RECONNECTION_TIME_VALUE); + Preferences::GetInt("dom.server-events.default-reconnection-time", + DEFAULT_RECONNECTION_TIME_VALUE); nsCOMPtr convManager = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv); @@ -775,7 +778,7 @@ nsEventSource::GetInterface(const nsIID & aIID, PRBool nsEventSource::PrefEnabled() { - return nsContentUtils::GetBoolPref("dom.server-events.enabled", PR_FALSE); + return Preferences::GetBool("dom.server-events.enabled", PR_FALSE); } nsresult diff --git a/content/base/src/nsFileDataProtocolHandler.cpp b/content/base/src/nsFileDataProtocolHandler.cpp index e4934d35b8b..b0d06a51447 100644 --- a/content/base/src/nsFileDataProtocolHandler.cpp +++ b/content/base/src/nsFileDataProtocolHandler.cpp @@ -161,12 +161,23 @@ public: nsCOMPtr mPrincipal; }; +static NS_DEFINE_CID(kThisSimpleURIImplementationCID, + NS_THIS_SIMPLEURI_IMPLEMENTATION_CID); + NS_IMPL_ADDREF_INHERITED(nsFileDataURI, nsSimpleURI) NS_IMPL_RELEASE_INHERITED(nsFileDataURI, nsSimpleURI) + NS_INTERFACE_MAP_BEGIN(nsFileDataURI) NS_INTERFACE_MAP_ENTRY(nsIURIWithPrincipal) if (aIID.Equals(kFILEDATAURICID)) - foundInterface = static_cast(this); + foundInterface = static_cast(this); + else if (aIID.Equals(kThisSimpleURIImplementationCID)) { + // Need to return explicitly here, because if we just set foundInterface + // to null the NS_INTERFACE_MAP_END_INHERITING will end up calling into + // nsSimplURI::QueryInterface and finding something for this CID. + *aInstancePtr = nsnull; + return NS_NOINTERFACE; + } else NS_INTERFACE_MAP_END_INHERITING(nsSimpleURI) @@ -257,15 +268,20 @@ nsFileDataURI::EqualsInternal(nsIURI* aOther, return NS_OK; } - nsresult rv = mPrincipal->Equals(otherFileDataUri->mPrincipal, aResult); - NS_ENSURE_SUCCESS(rv, rv); - - if (!*aResult) { + // Compare the member data that our base class knows about. + if (!nsSimpleURI::EqualsInternal(otherFileDataUri, aRefHandlingMode)) { + *aResult = PR_FALSE; return NS_OK; - } + } - return nsSimpleURI::EqualsInternal(otherFileDataUri, aRefHandlingMode, - aResult); + // Compare the piece of additional member data that we add to base class. + if (mPrincipal && otherFileDataUri->mPrincipal) { + // Both of us have mPrincipals. Compare them. + return mPrincipal->Equals(otherFileDataUri->mPrincipal, aResult); + } + // else, at least one of us lacks a principal; only equal if *both* lack it. + *aResult = (!mPrincipal && !otherFileDataUri->mPrincipal); + return NS_OK; } // nsIClassInfo methods: diff --git a/content/base/src/nsFrameLoader.cpp b/content/base/src/nsFrameLoader.cpp index 8515337552b..4168acb7672 100644 --- a/content/base/src/nsFrameLoader.cpp +++ b/content/base/src/nsFrameLoader.cpp @@ -83,7 +83,7 @@ #include "nsISHistory.h" #include "nsISHistoryInternal.h" #include "nsIDocShellHistory.h" -#include "nsIDOMNSHTMLDocument.h" +#include "nsIDOMHTMLDocument.h" #include "nsIXULWindow.h" #include "nsIEditor.h" #include "nsIEditorDocShell.h" @@ -114,6 +114,8 @@ #include "TabParent.h" #include "mozilla/layout/RenderFrameParent.h" +#include "mozilla/Preferences.h" + using namespace mozilla; using namespace mozilla::dom; using namespace mozilla::layers; @@ -818,7 +820,7 @@ nsFrameLoader::Show(PRInt32 marginWidth, PRInt32 marginHeight, nsCOMPtr presShell; mDocShell->GetPresShell(getter_AddRefs(presShell)); if (presShell) { - nsCOMPtr doc = + nsCOMPtr doc = do_QueryInterface(presShell->GetDocument()); if (doc) { @@ -836,7 +838,7 @@ nsFrameLoader::Show(PRInt32 marginWidth, PRInt32 marginHeight, doc->SetDesignMode(NS_LITERAL_STRING("off")); doc->SetDesignMode(NS_LITERAL_STRING("on")); } else { - // Re-initialie the presentation for contenteditable documents + // Re-initialize the presentation for contenteditable documents nsCOMPtr editorDocshell = do_QueryInterface(mDocShell); if (editorDocshell) { PRBool editable = PR_FALSE, @@ -1346,8 +1348,8 @@ nsFrameLoader::ShouldUseRemoteProcess() return false; } - PRBool remoteDisabled = nsContentUtils::GetBoolPref("dom.ipc.tabs.disabled", - PR_FALSE); + PRBool remoteDisabled = + Preferences::GetBool("dom.ipc.tabs.disabled", PR_FALSE); if (remoteDisabled) { return false; } @@ -1366,8 +1368,7 @@ nsFrameLoader::ShouldUseRemoteProcess() return true; } - PRBool remoteEnabled = nsContentUtils::GetBoolPref("dom.ipc.tabs.enabled", - PR_FALSE); + PRBool remoteEnabled = Preferences::GetBool("dom.ipc.tabs.enabled", PR_FALSE); return (bool) remoteEnabled; } diff --git a/content/base/src/nsGenericDOMDataNode.cpp b/content/base/src/nsGenericDOMDataNode.cpp index f4fe5320c6e..482a6b80c1b 100644 --- a/content/base/src/nsGenericDOMDataNode.cpp +++ b/content/base/src/nsGenericDOMDataNode.cpp @@ -723,7 +723,7 @@ nsGenericDOMDataNode::InsertChildAt(nsIContent* aKid, PRUint32 aIndex, } nsresult -nsGenericDOMDataNode::RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutationEvent) +nsGenericDOMDataNode::RemoveChildAt(PRUint32 aIndex, PRBool aNotify) { return NS_OK; } @@ -846,52 +846,6 @@ nsGenericDOMDataNode::SplitText(PRUint32 aOffset, nsIDOMText** aReturn) return rv; } -//---------------------------------------------------------------------- - -// Implementation of the nsGenericDOMDataNode nsIDOM3Text tearoff - -NS_IMPL_CYCLE_COLLECTION_CLASS(nsText3Tearoff) - -NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsText3Tearoff) - NS_INTERFACE_MAP_ENTRY(nsIDOM3Text) -NS_INTERFACE_MAP_END_AGGREGATED(mNode) - -NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsText3Tearoff) - NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mNode) -NS_IMPL_CYCLE_COLLECTION_UNLINK_END - -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsText3Tearoff) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR_AMBIGUOUS(mNode, nsIContent) -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END - -NS_IMPL_CYCLE_COLLECTING_ADDREF(nsText3Tearoff) -NS_IMPL_CYCLE_COLLECTING_RELEASE(nsText3Tearoff) - -NS_IMETHODIMP -nsText3Tearoff::GetIsElementContentWhitespace(PRBool *aReturn) -{ - *aReturn = mNode->IsElementContentWhitespace(); - return NS_OK; -} - -NS_IMETHODIMP -nsText3Tearoff::GetWholeText(nsAString& aWholeText) -{ - return mNode->GetWholeText(aWholeText); -} - -NS_IMETHODIMP -nsText3Tearoff::ReplaceWholeText(const nsAString& aContent, - nsIDOMText **aReturn) -{ - nsresult rv; - nsIContent* result = mNode->ReplaceWholeText(PromiseFlatString(aContent), - &rv); - return result ? CallQueryInterface(result, aReturn) : rv; -} - -// Implementation of the nsIDOM3Text interface - /* static */ PRInt32 nsGenericDOMDataNode::FirstLogicallyAdjacentTextNode(nsIContent* aParent, PRInt32 aIndex) @@ -918,7 +872,7 @@ nsGenericDOMDataNode::LastLogicallyAdjacentTextNode(nsIContent* aParent, } nsresult -nsGenericTextNode::GetWholeText(nsAString& aWholeText) +nsGenericDOMDataNode::GetWholeText(nsAString& aWholeText) { nsIContent* parent = GetParent(); @@ -949,21 +903,21 @@ nsGenericTextNode::GetWholeText(nsAString& aWholeText) return NS_OK; } -nsIContent* -nsGenericTextNode::ReplaceWholeText(const nsAFlatString& aContent, - nsresult* aResult) +nsresult +nsGenericDOMDataNode::ReplaceWholeText(const nsAString& aContent, + nsIDOMText **aResult) { - *aResult = NS_OK; + *aResult = nsnull; // Handle parent-less nodes nsCOMPtr parent = GetParent(); if (!parent) { if (aContent.IsEmpty()) { - return nsnull; + return NS_OK; } SetNodeValue(aContent); - return this; + return CallQueryInterface(this, aResult); } // We're relying on mozAutoSubtreeModified to keep the doc alive here. @@ -976,8 +930,7 @@ nsGenericTextNode::ReplaceWholeText(const nsAFlatString& aContent, if (index < 0) { NS_WARNING("Trying to use .replaceWholeText with an anonymous text node " "child of a binding parent?"); - *aResult = NS_ERROR_DOM_NOT_SUPPORTED_ERR; - return nsnull; + return NS_ERROR_DOM_NOT_SUPPORTED_ERR; } // We don't support entity references or read-only nodes, so remove the @@ -1016,11 +969,11 @@ nsGenericTextNode::ReplaceWholeText(const nsAFlatString& aContent, // Empty string means we removed this node too. if (aContent.IsEmpty()) { - return nsnull; + return NS_OK; } - SetText(aContent.get(), aContent.Length(), PR_TRUE); - return this; + SetText(aContent.BeginReading(), aContent.Length(), PR_TRUE); + return CallQueryInterface(this, aResult); } //---------------------------------------------------------------------- diff --git a/content/base/src/nsGenericDOMDataNode.h b/content/base/src/nsGenericDOMDataNode.h index 3557ac0511e..68ef37e7535 100644 --- a/content/base/src/nsGenericDOMDataNode.h +++ b/content/base/src/nsGenericDOMDataNode.h @@ -46,7 +46,6 @@ #include "nsIContent.h" #include "nsIDOMCharacterData.h" #include "nsIDOMEventTarget.h" -#include "nsIDOM3Text.h" #include "nsTextFragment.h" #include "nsDOMError.h" #include "nsIEventListenerManager.h" @@ -155,7 +154,7 @@ public: virtual PRInt32 IndexOf(nsINode* aPossibleChild) const; virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify); - virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutationEvent = PR_TRUE); + virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify); virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor); virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor); virtual nsresult DispatchDOMEvent(nsEvent* aEvent, nsIDOMEvent* aDOMEvent, @@ -328,7 +327,15 @@ protected: nsresult SplitText(PRUint32 aOffset, nsIDOMText** aReturn); - friend class nsText3Tearoff; + nsresult GetWholeText(nsAString& aWholeText); + + nsresult ReplaceWholeText(const nsAString& aContent, nsIDOMText **aReturn); + + nsresult GetIsElementContentWhitespace(PRBool *aReturn) + { + *aReturn = TextIsOnlyWhitespace(); + return NS_OK; + } static PRInt32 FirstLogicallyAdjacentTextNode(nsIContent* aParent, PRInt32 aIndex); @@ -360,45 +367,6 @@ private: already_AddRefed GetCurrentValueAtom(); }; -class nsGenericTextNode : public nsGenericDOMDataNode -{ -public: - nsGenericTextNode(already_AddRefed aNodeInfo) - : nsGenericDOMDataNode(aNodeInfo) - { - } - - PRBool IsElementContentWhitespace() - { - return TextIsOnlyWhitespace(); - } - nsresult GetWholeText(nsAString& aWholeText); - - nsIContent* ReplaceWholeText(const nsAFlatString& aContent, - nsresult *aResult); -}; - -/** Tearoff class for the nsIDOM3Text portion of nsGenericDOMDataNode. */ -class nsText3Tearoff : public nsIDOM3Text -{ -public: - NS_DECL_CYCLE_COLLECTING_ISUPPORTS - - NS_DECL_NSIDOM3TEXT - - NS_DECL_CYCLE_COLLECTION_CLASS(nsText3Tearoff) - - nsText3Tearoff(nsGenericTextNode *aNode) : mNode(aNode) - { - } - -protected: - virtual ~nsText3Tearoff() {} - -private: - nsRefPtr mNode; -}; - //---------------------------------------------------------------------- /** diff --git a/content/base/src/nsGenericElement.cpp b/content/base/src/nsGenericElement.cpp index 0a68cfa8d07..34bc4c06304 100644 --- a/content/base/src/nsGenericElement.cpp +++ b/content/base/src/nsGenericElement.cpp @@ -94,14 +94,10 @@ #include "nsXBLBinding.h" #include "nsIXBLService.h" #include "nsPIDOMWindow.h" -#include "nsIBoxObject.h" #include "nsPIBoxObject.h" -#include "nsIDOMNSDocument.h" #include "nsIDOMNSElement.h" #include "nsClientRect.h" -#ifdef MOZ_SVG #include "nsSVGUtils.h" -#endif #include "nsLayoutUtils.h" #include "nsGkAtoms.h" #include "nsContentUtils.h" @@ -149,9 +145,7 @@ #include "nsTPtrArray.h" #include "prprf.h" -#ifdef MOZ_SVG #include "nsSVGFeatures.h" -#endif /* MOZ_SVG */ using namespace mozilla::dom; namespace css = mozilla::css; @@ -3663,14 +3657,13 @@ nsINode::doInsertChildAt(nsIContent* aKid, PRUint32 aIndex, } nsresult -nsGenericElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutationEvent) +nsGenericElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify) { nsCOMPtr oldKid = mAttrsAndChildren.GetSafeChildAt(aIndex); NS_ASSERTION(oldKid == GetChildAt(aIndex), "Unexpected child in RemoveChildAt"); if (oldKid) { - return doRemoveChildAt(aIndex, aNotify, oldKid, mAttrsAndChildren, - aMutationEvent); + return doRemoveChildAt(aIndex, aNotify, oldKid, mAttrsAndChildren); } return NS_OK; @@ -3678,8 +3671,7 @@ nsGenericElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutatio nsresult nsINode::doRemoveChildAt(PRUint32 aIndex, PRBool aNotify, - nsIContent* aKid, nsAttrAndChildArray& aChildArray, - PRBool aMutationEvent) + nsIContent* aKid, nsAttrAndChildArray& aChildArray) { NS_PRECONDITION(aKid && aKid->GetNodeParent() == this && aKid == GetChildAt(aIndex) && @@ -3991,10 +3983,10 @@ PRBool IsAllowedAsChild(nsIContent* aNewChild, PRUint16 aNewNodeType, void nsGenericElement::FireNodeInserted(nsIDocument* aDoc, nsINode* aParent, - nsCOMArray& aNodes) + nsTArray >& aNodes) { - PRInt32 count = aNodes.Count(); - for (PRInt32 i = 0; i < count; ++i) { + PRUint32 count = aNodes.Length(); + for (PRUint32 i = 0; i < count; ++i) { nsIContent* childContent = aNodes[i]; if (nsContentUtils::HasMutationListeners(childContent, @@ -4159,57 +4151,18 @@ nsINode::ReplaceOrInsertBefore(PRBool aReplace, nsINode* aNewChild, // Copy the children into a separate array to avoid having to deal with // mutations to the fragment while we're inserting. - nsCOMArray fragChildren; - if (!fragChildren.SetCapacity(count)) { - return NS_ERROR_OUT_OF_MEMORY; - } - PRUint32 i; - for (i = 0; i < count; i++) { + nsAutoTArray, 50> fragChildren; + fragChildren.SetCapacity(count); + for (PRUint32 i = 0; i < count; i++) { nsIContent* child = newContent->GetChildAt(i); NS_ASSERTION(child->GetCurrentDoc() == nsnull, "How did we get a child with a current doc?"); - fragChildren.AppendObject(child); + fragChildren.AppendElement(child); } - // Remove the children from the fragment and flag for possible mutations. - PRBool mutated = PR_FALSE; - for (i = count; i > 0;) { - // We don't need to update i if someone mutates the DOM. The only thing - // that'd happen is that the resulting child list might be unexpected, - // but we should never crash since RemoveChildAt is out-of-bounds safe. - nsMutationGuard guard; + // Remove the children from the fragment. + for (PRUint32 i = count; i > 0;) { newContent->RemoveChildAt(--i, PR_TRUE); - mutated = mutated || guard.Mutated(1); - } - - // If we've had any unexpected mutations so far we need to recheck that - // the child can still be inserted. - if (mutated) { - for (i = 0; i < count; ++i) { - // Get the n:th child from the array. - nsIContent* childContent = fragChildren[i]; - if (!HasSameOwnerDoc(childContent) || - doc != childContent->GetOwnerDoc()) { - return NS_ERROR_DOM_WRONG_DOCUMENT_ERR; - } - - nsCOMPtr tmpNode = do_QueryInterface(childContent); - PRUint16 tmpType = 0; - tmpNode->GetNodeType(&tmpType); - - if (childContent->GetNodeParent() || - !IsAllowedAsChild(childContent, tmpType, this, PR_FALSE, - refContent)) { - return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR; - } - } - - insPos = refContent ? IndexOf(refContent) : GetChildCount(); - if (insPos < 0) { - // Someone seriously messed up the childlist. We have no idea - // where to insert the remaining children, so just bail. - return NS_ERROR_DOM_NOT_FOUND_ERR; - } } PRBool appending = @@ -4219,12 +4172,10 @@ nsINode::ReplaceOrInsertBefore(PRBool aReplace, nsINode* aNewChild, // Iterate through the fragment's children, and insert them in the new // parent - for (i = 0; i < count; ++i, ++insPos) { - nsIContent* childContent = fragChildren[i]; - + for (PRUint32 i = 0; i < count; ++i, ++insPos) { // XXXbz how come no reparenting here? That seems odd... // Insert the child. - res = InsertChildAt(childContent, insPos, PR_FALSE); + res = InsertChildAt(fragChildren[i], insPos, !appending); if (NS_FAILED(res)) { // Make sure to notify on any children that we did succeed to insert if (appending && i != 0) { @@ -4234,22 +4185,17 @@ nsINode::ReplaceOrInsertBefore(PRBool aReplace, nsINode* aNewChild, } return res; } - - if (!appending) { - nsNodeUtils::ContentInserted(this, childContent, insPos); - } } - // Notify + // Notify and fire mutation events when appending if (appending) { nsNodeUtils::ContentAppended(static_cast(this), firstInsertedContent, firstInsPos); - } - - // Fire mutation events. Optimize for the case when there are no listeners - if (nsContentUtils:: - HasMutationListeners(doc, NS_EVENT_BITS_MUTATION_NODEINSERTED)) { - nsGenericElement::FireNodeInserted(doc, this, fragChildren); + // Optimize for the case when there are no listeners + if (nsContentUtils:: + HasMutationListeners(doc, NS_EVENT_BITS_MUTATION_NODEINSERTED)) { + nsGenericElement::FireNodeInserted(doc, this, fragChildren); + } } } else { @@ -4629,7 +4575,7 @@ nsGenericElement::SetAttr(PRInt32 aNamespaceID, nsIAtom* aName, // Hold a script blocker while calling ParseAttribute since that can call // out to id-observers - nsAutoRemovableScriptBlocker scriptBlocker; + nsAutoScriptBlocker scriptBlocker; nsAttrValue attrValue; if (!ParseAttribute(aNamespaceID, aName, aValue, attrValue)) { diff --git a/content/base/src/nsGenericElement.h b/content/base/src/nsGenericElement.h index 35869244f97..59aa562962d 100644 --- a/content/base/src/nsGenericElement.h +++ b/content/base/src/nsGenericElement.h @@ -329,7 +329,7 @@ public: virtual PRInt32 IndexOf(nsINode* aPossibleChild) const; virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify); - virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutationEvent = PR_TRUE); + virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify); virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor); virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor); virtual nsresult DispatchDOMEvent(nsEvent* aEvent, nsIDOMEvent* aDOMEvent, @@ -596,7 +596,7 @@ public: */ static void FireNodeInserted(nsIDocument* aDoc, nsINode* aParent, - nsCOMArray& aNodes); + nsTArray >& aNodes); /** * Helper methods for implementing querySelector/querySelectorAll diff --git a/content/base/src/nsGkAtomList.h b/content/base/src/nsGkAtomList.h index 72c5cbac91d..ed3769ea08f 100644 --- a/content/base/src/nsGkAtomList.h +++ b/content/base/src/nsGkAtomList.h @@ -1097,7 +1097,6 @@ GK_ATOM(z_index, "z-index") GK_ATOM(zeroDigit, "zero-digit") -#ifdef MOZ_SVG GK_ATOM(percentage, "%") GK_ATOM(A, "A") GK_ATOM(alignment_baseline, "alignment-baseline") @@ -1347,13 +1346,13 @@ GK_ATOM(x, "x") GK_ATOM(x1, "x1") GK_ATOM(x2, "x2") GK_ATOM(xChannelSelector, "xChannelSelector") +GK_ATOM(xor_, "xor") GK_ATOM(y, "y") GK_ATOM(y1, "y1") GK_ATOM(y2, "y2") GK_ATOM(yChannelSelector, "yChannelSelector") GK_ATOM(z, "z") GK_ATOM(zoomAndPan, "zoomAndPan") -#endif #ifdef MOZ_SMIL GK_ATOM(accumulate, "accumulate") @@ -1670,10 +1669,6 @@ GK_ATOM(xref_, "xref") GK_ATOM(math, "math") // the only one without an underscore #endif -#if defined(MOZ_SVG) || defined(MOZ_MATHML) -GK_ATOM(xor_, "xor") -#endif - #ifndef DISABLE_XFORMS_HOOKS GK_ATOM(avg, "avg") GK_ATOM(booleanFromString, "boolean-from-string") @@ -1774,7 +1769,6 @@ GK_ATOM(viewportFrame, "ViewportFrame") #ifdef MOZ_XUL GK_ATOM(XULLabelFrame, "XULLabelFrame") #endif -#ifdef MOZ_SVG GK_ATOM(svgAFrame, "SVGAFrame") GK_ATOM(svgClipPathFrame, "SVGClipPathFrame") GK_ATOM(svgDefsFrame, "SVGDefsFrame") @@ -1799,7 +1793,6 @@ GK_ATOM(svgTextFrame, "SVGTextFrame") GK_ATOM(svgTextPathFrame, "SVGTextPathFrame") GK_ATOM(svgTSpanFrame, "SVGTSpanFrame") GK_ATOM(svgUseFrame, "SVGUseFrame") -#endif #ifdef MOZ_MEDIA GK_ATOM(HTMLVideoFrame, "VideoFrame") GK_ATOM(onloadstart, "onloadstart") diff --git a/content/base/src/nsImageLoadingContent.cpp b/content/base/src/nsImageLoadingContent.cpp index c499adbd4ee..8d7a5004cf7 100644 --- a/content/base/src/nsImageLoadingContent.cpp +++ b/content/base/src/nsImageLoadingContent.cpp @@ -76,9 +76,7 @@ #include "nsContentPolicyUtils.h" #include "nsEventDispatcher.h" #include "nsDOMClassInfo.h" -#ifdef MOZ_SVG #include "nsSVGEffects.h" -#endif #include "mozAutoDocUpdate.h" @@ -358,10 +356,8 @@ nsImageLoadingContent::OnStopDecode(imgIRequest* aRequest, FireEvent(NS_LITERAL_STRING("error")); } -#ifdef MOZ_SVG nsCOMPtr thisNode = do_QueryInterface(this); nsSVGEffects::InvalidateDirectRenderingObservers(thisNode->AsElement()); -#endif return NS_OK; } diff --git a/content/base/src/nsNameSpaceManager.cpp b/content/base/src/nsNameSpaceManager.cpp index 34350285aa1..6cbeedc6741 100644 --- a/content/base/src/nsNameSpaceManager.cpp +++ b/content/base/src/nsNameSpaceManager.cpp @@ -268,9 +268,7 @@ NameSpaceManagerImpl::HasElementCreator(PRInt32 aNameSpaceID) #ifdef MOZ_MATHML aNameSpaceID == kNameSpaceID_MathML || #endif -#ifdef MOZ_SVG aNameSpaceID == kNameSpaceID_SVG || -#endif aNameSpaceID == kNameSpaceID_XMLEvents || PR_FALSE; } diff --git a/content/base/src/nsObjectLoadingContent.cpp b/content/base/src/nsObjectLoadingContent.cpp index 877e49be598..f60961b52fe 100644 --- a/content/base/src/nsObjectLoadingContent.cpp +++ b/content/base/src/nsObjectLoadingContent.cpp @@ -1497,11 +1497,8 @@ nsObjectLoadingContent::GetCapabilities() const { return eSupportImages | eSupportPlugins | - eSupportDocuments -#ifdef MOZ_SVG - | eSupportSVG -#endif - ; + eSupportDocuments | + eSupportSVG; } void @@ -1706,12 +1703,8 @@ nsObjectLoadingContent::GetTypeOfContent(const nsCString& aMIMEType) return eType_Image; } -#ifdef MOZ_SVG PRBool isSVG = aMIMEType.LowerCaseEqualsLiteral("image/svg+xml"); PRBool supportedSVG = isSVG && (caps & eSupportSVG); -#else - PRBool supportedSVG = PR_FALSE; -#endif if (((caps & eSupportDocuments) || supportedSVG) && IsSupportedDocument(aMIMEType)) { return eType_Document; diff --git a/content/base/src/nsObjectLoadingContent.h b/content/base/src/nsObjectLoadingContent.h index 68559d662da..aa676b69910 100644 --- a/content/base/src/nsObjectLoadingContent.h +++ b/content/base/src/nsObjectLoadingContent.h @@ -195,9 +195,7 @@ class nsObjectLoadingContent : public nsImageLoadingContent eSupportDocuments = PR_BIT(2), // Documents are supported // (nsIDocumentLoaderFactory) // This flag always includes SVG -#ifdef MOZ_SVG eSupportSVG = PR_BIT(3), // SVG is supported (image/svg+xml) -#endif eSupportClassID = PR_BIT(4), // The classid attribute is supported eOverrideServerType = PR_BIT(5) // The server-sent MIME type is ignored // (ignored if no type is specified) diff --git a/content/base/src/nsPlainTextSerializer.cpp b/content/base/src/nsPlainTextSerializer.cpp index 6914b94efb3..2adeab9ba7e 100644 --- a/content/base/src/nsPlainTextSerializer.cpp +++ b/content/base/src/nsPlainTextSerializer.cpp @@ -58,7 +58,9 @@ #include "nsCRT.h" #include "nsIParserService.h" #include "mozilla/dom/Element.h" +#include "mozilla/Preferences.h" +using namespace mozilla; using namespace mozilla::dom; #define PREF_STRUCTS "converter.html2txt.structs" @@ -206,28 +208,27 @@ nsPlainTextSerializer::Init(PRUint32 aFlags, PRUint32 aWrapColumn, if (mFlags & nsIDocumentEncoder::OutputFormatted) { // Get some prefs that controls how we do formatted output - mStructs = nsContentUtils::GetBoolPref(PREF_STRUCTS, mStructs); + mStructs = Preferences::GetBool(PREF_STRUCTS, mStructs); mHeaderStrategy = - nsContentUtils::GetIntPref(PREF_HEADER_STRATEGY, mHeaderStrategy); + Preferences::GetInt(PREF_HEADER_STRATEGY, mHeaderStrategy); // The quotesPreformatted pref is a temporary measure. See bug 69638. mQuotesPreformatted = - nsContentUtils::GetBoolPref("editor.quotesPreformatted", - mQuotesPreformatted); + Preferences::GetBool("editor.quotesPreformatted", mQuotesPreformatted); // DontWrapAnyQuotes is set according to whether plaintext mail // is wrapping to window width -- see bug 134439. // We'll only want this if we're wrapping and formatted. if (mFlags & nsIDocumentEncoder::OutputWrap || mWrapColumn > 0) { mDontWrapAnyQuotes = - nsContentUtils::GetBoolPref("mail.compose.wrap_to_window_width", - mDontWrapAnyQuotes); + Preferences::GetBool("mail.compose.wrap_to_window_width", + mDontWrapAnyQuotes); } } // XXX We should let the caller pass this in. - if (nsContentUtils::GetBoolPref("browser.frames.enabled")) { + if (Preferences::GetBool("browser.frames.enabled")) { mFlags &= ~nsIDocumentEncoder::OutputNoFramesContent; } else { diff --git a/content/base/src/nsRange.cpp b/content/base/src/nsRange.cpp index 99d2bf9c527..13035ba8248 100644 --- a/content/base/src/nsRange.cpp +++ b/content/base/src/nsRange.cpp @@ -46,7 +46,6 @@ #include "nsReadableUtils.h" #include "nsIDOMNode.h" #include "nsIDOMDocument.h" -#include "nsIDOMNSDocument.h" #include "nsIDOMDocumentFragment.h" #include "nsIContent.h" #include "nsIDocument.h" diff --git a/content/base/src/nsStyledElement.cpp b/content/base/src/nsStyledElement.cpp index 3c1a522db1f..27f1dc60ffd 100644 --- a/content/base/src/nsStyledElement.cpp +++ b/content/base/src/nsStyledElement.cpp @@ -52,10 +52,7 @@ #include "mozilla/css/Loader.h" #include "nsIDOMMutationEvent.h" #include "nsXULElement.h" - -#ifdef MOZ_SVG #include "nsIDOMSVGStylable.h" -#endif namespace css = mozilla::css; @@ -136,7 +133,7 @@ nsStyledElementNotElementCSSInlineStyle::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRBool aNotify) { - nsAutoRemovableScriptBlocker scriptBlocker; + nsAutoScriptBlocker scriptBlocker; if (aAttribute == nsGkAtoms::id && aNameSpaceID == kNameSpaceID_None) { // Have to do this before clearing flag. See RemoveFromIdTable RemoveFromIdTable(); diff --git a/content/base/src/nsTextNode.cpp b/content/base/src/nsTextNode.cpp index c3dc9be6da1..ed5bb2e2d1d 100644 --- a/content/base/src/nsTextNode.cpp +++ b/content/base/src/nsTextNode.cpp @@ -40,7 +40,6 @@ */ #include "nsTextNode.h" -#include "nsIDOM3Text.h" #include "nsContentUtils.h" #include "nsIDOMEventListener.h" #include "nsIDOMEventTarget.h" @@ -142,7 +141,7 @@ NS_NewTextNode(nsIContent** aInstancePtrResult, } nsTextNode::nsTextNode(already_AddRefed aNodeInfo) - : nsGenericTextNode(aNodeInfo) + : nsGenericDOMDataNode(aNodeInfo) { } @@ -159,7 +158,6 @@ DOMCI_NODE_DATA(Text, nsTextNode) NS_INTERFACE_TABLE_HEAD(nsTextNode) NS_NODE_INTERFACE_TABLE3(nsTextNode, nsIDOMNode, nsIDOMText, nsIDOMCharacterData) - NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOM3Text, new nsText3Tearoff(this)) NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsTextNode) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Text) NS_INTERFACE_MAP_END_INHERITING(nsGenericDOMDataNode) diff --git a/content/base/src/nsTextNode.h b/content/base/src/nsTextNode.h index c68a6f63a57..c37107a9f8e 100644 --- a/content/base/src/nsTextNode.h +++ b/content/base/src/nsTextNode.h @@ -41,7 +41,6 @@ #include "nsGenericDOMDataNode.h" #include "nsIDOMText.h" -#include "nsIDOM3Text.h" #include "nsContentUtils.h" #include "nsIDOMEventListener.h" #include "nsIDOMEventTarget.h" @@ -53,7 +52,7 @@ /** * Class used to implement DOM text nodes */ -class nsTextNode : public nsGenericTextNode, +class nsTextNode : public nsGenericDOMDataNode, public nsIDOMText { public: diff --git a/content/base/src/nsWebSocket.cpp b/content/base/src/nsWebSocket.cpp index 9fe8a2fbe9f..dd349278ab9 100644 --- a/content/base/src/nsWebSocket.cpp +++ b/content/base/src/nsWebSocket.cpp @@ -75,6 +75,7 @@ #include "nsIWebSocketProtocol.h" #include "nsILoadGroup.h" #include "nsIRequest.h" +#include "mozilla/Preferences.h" using namespace mozilla; @@ -902,7 +903,7 @@ nsWebSocket::CreateAndDispatchCloseEvent(PRBool aWasClean) PRBool nsWebSocket::PrefEnabled() { - return nsContentUtils::GetBoolPref("network.websocket.enabled", PR_TRUE); + return Preferences::GetBool("network.websocket.enabled", PR_TRUE); } void diff --git a/content/base/src/nsXMLHttpRequest.cpp b/content/base/src/nsXMLHttpRequest.cpp index 5b8395f1721..77e7d4b8fb9 100644 --- a/content/base/src/nsXMLHttpRequest.cpp +++ b/content/base/src/nsXMLHttpRequest.cpp @@ -426,7 +426,8 @@ nsXMLHttpRequest::nsXMLHttpRequest() mErrorLoad(PR_FALSE), mTimerIsActive(PR_FALSE), mProgressEventWasDelayed(PR_FALSE), mLoadLengthComputable(PR_FALSE), mLoadTotal(0), - mFirstStartRequestSeen(PR_FALSE) + mFirstStartRequestSeen(PR_FALSE), + mResultArrayBuffer(nsnull) { mResponseBodyUnicode.SetIsVoid(PR_TRUE); nsLayoutStatics::AddRef(); @@ -450,6 +451,12 @@ nsXMLHttpRequest::~nsXMLHttpRequest() nsLayoutStatics::Release(); } +void +nsXMLHttpRequest::RootResultArrayBuffer() +{ + nsContentUtils::PreserveWrapper(static_cast(this), this); +} + /** * This Init method is called from the factory constructor. */ @@ -572,9 +579,9 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsXMLHttpRequest, nsIXMLHttpRequestUpload) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END - NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsXMLHttpRequest, nsXHREventTarget) + tmp->mResultArrayBuffer = nsnull; NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mContext) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mChannel) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mReadRequest) @@ -592,6 +599,14 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsXMLHttpRequest, NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mUpload) NS_IMPL_CYCLE_COLLECTION_UNLINK_END +NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(nsXMLHttpRequest, + nsXHREventTarget) + if(tmp->mResultArrayBuffer) { + NS_IMPL_CYCLE_COLLECTION_TRACE_JS_CALLBACK(tmp->mResultArrayBuffer, + "mResultArrayBuffer") + } +NS_IMPL_CYCLE_COLLECTION_TRACE_END + DOMCI_DATA(XMLHttpRequest, nsXMLHttpRequest) // QueryInterface implementation for nsXMLHttpRequest @@ -839,27 +854,20 @@ NS_IMETHODIMP nsXMLHttpRequest::GetResponseText(nsAString& aResponseText) return rv; } -nsresult nsXMLHttpRequest::GetResponseArrayBuffer(jsval *aResult) +nsresult nsXMLHttpRequest::CreateResponseArrayBuffer(JSContext *aCx) { - JSContext *cx = nsContentUtils::GetCurrentJSContext(); - if (!cx) + if (!aCx) return NS_ERROR_FAILURE; - if (!(mState & (XML_HTTP_REQUEST_DONE | - XML_HTTP_REQUEST_LOADING))) { - *aResult = JSVAL_NULL; - return NS_OK; - } - PRInt32 dataLen = mResponseBody.Length(); - JSObject *obj = js_CreateArrayBuffer(cx, dataLen); - if (!obj) + RootResultArrayBuffer(); + mResultArrayBuffer = js_CreateArrayBuffer(aCx, dataLen); + if (!mResultArrayBuffer) { return NS_ERROR_FAILURE; - - *aResult = OBJECT_TO_JSVAL(obj); + } if (dataLen > 0) { - js::ArrayBuffer *abuf = js::ArrayBuffer::fromJSObject(obj); + js::ArrayBuffer *abuf = js::ArrayBuffer::fromJSObject(mResultArrayBuffer); NS_ASSERTION(abuf, "What happened?"); memcpy(abuf->data, mResponseBody.BeginReading(), dataLen); } @@ -954,7 +962,11 @@ NS_IMETHODIMP nsXMLHttpRequest::GetResponse(JSContext *aCx, jsval *aResult) case XML_HTTP_RESPONSE_TYPE_ARRAYBUFFER: if (mState & XML_HTTP_REQUEST_DONE) { - rv = GetResponseArrayBuffer(aResult); + if (!mResultArrayBuffer) { + rv = CreateResponseArrayBuffer(aCx); + NS_ENSURE_SUCCESS(rv, rv); + } + *aResult = OBJECT_TO_JSVAL(mResultArrayBuffer); } else { *aResult = JSVAL_NULL; } @@ -1073,7 +1085,8 @@ nsXMLHttpRequest::Abort() mResponseBodyUnicode.SetIsVoid(PR_TRUE); mResponseBlob = nsnull; mState |= XML_HTTP_REQUEST_ABORTED; - + mResultArrayBuffer = nsnull; + if (!(mState & (XML_HTTP_REQUEST_UNSENT | XML_HTTP_REQUEST_OPENED | XML_HTTP_REQUEST_DONE))) { diff --git a/content/base/src/nsXMLHttpRequest.h b/content/base/src/nsXMLHttpRequest.h index 2ab09881ed2..8ee3039d738 100644 --- a/content/base/src/nsXMLHttpRequest.h +++ b/content/base/src/nsXMLHttpRequest.h @@ -208,11 +208,11 @@ public: void SetRequestObserver(nsIRequestObserver* aObserver); - NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsXMLHttpRequest, + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(nsXMLHttpRequest, nsXHREventTarget) - PRBool AllowUploadProgress(); - + void RootResultArrayBuffer(); + protected: friend class nsMultipartProxyListener; @@ -224,7 +224,7 @@ protected: PRUint32 toOffset, PRUint32 count, PRUint32 *writeCount); - nsresult GetResponseArrayBuffer(jsval *aResult); + nsresult CreateResponseArrayBuffer(JSContext* aCx); void CreateResponseBlob(nsIRequest *request); // Change the state of the object with this. The broadcast argument // determines if the onreadystatechange listener should be called. @@ -345,6 +345,8 @@ protected: nsCOMPtr mRedirectCallback; nsCOMPtr mNewRedirectChannel; + + JSObject* mResultArrayBuffer; }; // helper class to expose a progress DOM Event diff --git a/content/base/test/test_XHR.html b/content/base/test/test_XHR.html index 9052729e6b5..4f370b34969 100644 --- a/content/base/test/test_XHR.html +++ b/content/base/test/test_XHR.html @@ -134,6 +134,16 @@ ab = xhr.response; ok(ab != null, "should have a non-null arraybuffer"); arraybuffer_equals_to(ab, "\xaa\xee\0\x03\xff\xff\xff\xff\xbb\xbb\xbb\xbb"); +// test array buffer GetResult returns the same object +xhr = new XMLHttpRequest(); +xhr.open("GET", 'file_XHR_binary1.bin', false); +xhr.responseType = 'arraybuffer'; +xhr.send(null) +is(xhr.status, 200, "wrong status"); +checkResponseTextAccessThrows(xhr); +checkResponseXMLAccessThrows(xhr); +is(xhr.response, xhr.response, "returns the same ArrayBuffer"); + // test response (responseType='blob') var onloadCount = 0; function checkOnloadCount() { diff --git a/content/base/test/test_classList.html b/content/base/test/test_classList.html index 37329e32bfa..9e19e552485 100644 --- a/content/base/test/test_classList.html +++ b/content/base/test/test_classList.html @@ -165,22 +165,17 @@ function testClassList(e) { // item() method - // TODO out of bounds array indexing should return undefined according to the - // WebIDL spec. They are returning an empty string at the moment. (bug 529328) - var OOB_VALUE = ""; - todo_is(OOB_VALUE, undefined, "Wrong out of bounds value"); - e.setAttribute("class", "a"); is(e.classList.item(-1), null, "wrong classList.item() result"); - is(e.classList[-1], OOB_VALUE, "wrong classList[] result"); + is(e.classList[-1], undefined, "wrong classList[] result"); is(e.classList.item(0), "a", "wrong classList.item() result"); - is(e.classList[0], "a", "wrong classList.item() result"); + is(e.classList[0], "a", "wrong classList[] result"); is(e.classList.item(1), null, "wrong classList.item() result"); - is(e.classList[1], OOB_VALUE, "wrong classList.item() result"); + is(e.classList[1], undefined, "wrong classList[] result"); e.setAttribute("class", "aa AA aa"); is(e.classList.item(-1), null, "wrong classList.item() result"); - is(e.classList[-1], OOB_VALUE, "wrong classList[] result"); + is(e.classList[-1], undefined, "wrong classList[] result"); is(e.classList.item(0), "aa", "wrong classList.item() result"); is(e.classList[0], "aa", "wrong classList[] result"); is(e.classList.item(1), "AA", "wrong classList.item() result"); @@ -188,22 +183,21 @@ function testClassList(e) { is(e.classList.item(2), "aa", "wrong classList.item() result"); is(e.classList[2], "aa", "wrong classList[] result"); is(e.classList.item(3), null, "wrong classList.item() result"); - is(e.classList[3], OOB_VALUE, "wrong classList[] result"); + is(e.classList[3], undefined, "wrong classList[] result"); is(e.classList.item(0xffffffff), null, "wrong classList.item() result"); - // XXX returns undefined for index >= 0xffffffff - todo_is(e.classList[0xffffffff], OOB_VALUE, "wrong classList[] result"); + is(e.classList[0xffffffff], undefined, "wrong classList[] result"); is(e.classList.item(0xfffffffe), null, "wrong classList.item() result"); - is(e.classList[0xffffffe], OOB_VALUE, "wrong classList[] result"); + is(e.classList[0xffffffe], undefined, "wrong classList[] result"); e.setAttribute("class", "a b"); is(e.classList.item(-1), null, "wrong classList.item() result"); - is(e.classList[-1], OOB_VALUE, "wrong classList[] result"); + is(e.classList[-1], undefined, "wrong classList[] result"); is(e.classList.item(0), "a", "wrong classList.item() result"); is(e.classList[0], "a", "wrong classList[] result"); is(e.classList.item(1), "b", "wrong classList.item() result"); is(e.classList[1], "b", "wrong classList[] result"); is(e.classList.item(2), null, "wrong classList.item() result"); - is(e.classList[2], OOB_VALUE, "wrong classList[] result"); + is(e.classList[2], undefined, "wrong classList[] result"); // contains() method diff --git a/content/base/test/test_text_replaceWholeText.html b/content/base/test/test_text_replaceWholeText.html index 0fbe28e883b..780a1b6f962 100644 --- a/content/base/test/test_text_replaceWholeText.html +++ b/content/base/test/test_text_replaceWholeText.html @@ -25,7 +25,6 @@ SimpleTest.waitForExplicitFinish(); var xmlDoc; -function entity(n) { return xmlDoc.createEntityReference(n); } function text(t) { return document.createTextNode(t); } function element() { return document.createElement("div"); } function cdata(t) @@ -233,20 +232,6 @@ function endTests() is(outer.lastChild, first, "should be no more text at end"); } -function entityTests() -{ - todo_isnot(entity("bar"), null, - "need implementation update if we ever support entity nodes!"); - - var root = xmlDoc.documentElement; - is(root.lastChild.firstChild.nodeType, Node.TEXT_NODE, - "uh-oh, did we start supporting entity references as nodes?"); - is(root.lastChild.lastChild.nodeType, Node.ELEMENT_NODE, - "uh-oh, did we start supporting entity references as nodes?"); - - // If any of the above ever fails, add tests here! -} - function test() { try @@ -254,7 +239,6 @@ function test() startTests(); middleTests(); endTests(); - entityTests(); } catch (e) { diff --git a/content/base/test/test_text_wholeText.html b/content/base/test/test_text_wholeText.html index 70b1ab4c6e4..35513d49832 100644 --- a/content/base/test/test_text_wholeText.html +++ b/content/base/test/test_text_wholeText.html @@ -25,7 +25,6 @@ SimpleTest.waitForExplicitFinish(); var xmlDoc; -function entity(n) { return xmlDoc.createEntityReference(n); } function text(t) { return document.createTextNode(t); } function element() { return document.createElement("div"); } function cdata(t) @@ -207,20 +206,6 @@ function noParentTests() "orphaned cdatasection should have wholeText == data"); } -function entityTests() -{ - todo_isnot(entity("bar"), null, - "need implementation update if we ever support entity nodes!"); - - var root = xmlDoc.documentElement; - is(root.lastChild.firstChild.nodeType, Node.TEXT_NODE, - "uh-oh, did we start supporting entity references as nodes?"); - is(root.lastChild.lastChild.nodeType, Node.ELEMENT_NODE, - "uh-oh, did we start supporting entity references as nodes?"); - - // If any of the above ever fails, add tests here! -} - function tests() { try @@ -229,7 +214,6 @@ function tests() middleTests(); lastTests(); noParentTests(); - entityTests(); } catch (e) { diff --git a/content/canvas/src/WebGLContext.cpp b/content/canvas/src/WebGLContext.cpp index 1cd821a6cb6..d39e496389f 100644 --- a/content/canvas/src/WebGLContext.cpp +++ b/content/canvas/src/WebGLContext.cpp @@ -64,9 +64,7 @@ #include "gfxCrashReporterUtils.h" -#ifdef MOZ_SVG #include "nsSVGEffects.h" -#endif #include "prenv.h" @@ -277,9 +275,7 @@ WebGLContext::Invalidate() if (!mCanvasElement) return; -#ifdef MOZ_SVG nsSVGEffects::InvalidateDirectRenderingObservers(HTMLCanvasElement()); -#endif mInvalidated = PR_TRUE; HTMLCanvasElement()->InvalidateCanvasContent(nsnull); diff --git a/content/canvas/src/nsCanvasRenderingContext2D.cpp b/content/canvas/src/nsCanvasRenderingContext2D.cpp index 245d51d934c..976d890cfaf 100644 --- a/content/canvas/src/nsCanvasRenderingContext2D.cpp +++ b/content/canvas/src/nsCanvasRenderingContext2D.cpp @@ -536,11 +536,9 @@ protected: { ContextState& state = CurrentState(); - // The spec says we should not draw shadows when the alpha value is 0, - // regardless of the operator being used. return state.StyleIsColor(STYLE_SHADOW) && NS_GET_A(state.colorStyles[STYLE_SHADOW]) > 0 && - (state.shadowOffset != gfxPoint(0, 0) || state.shadowBlur != 0); + mThebes->CurrentOperator() == gfxContext::OPERATOR_OVER; } /** @@ -1037,9 +1035,7 @@ nsCanvasRenderingContext2D::Redraw() return NS_OK; } -#ifdef MOZ_SVG nsSVGEffects::InvalidateDirectRenderingObservers(HTMLCanvasElement()); -#endif HTMLCanvasElement()->InvalidateCanvasContent(nsnull); @@ -1064,9 +1060,7 @@ nsCanvasRenderingContext2D::Redraw(const gfxRect& r) return NS_OK; } -#ifdef MOZ_SVG nsSVGEffects::InvalidateDirectRenderingObservers(HTMLCanvasElement()); -#endif HTMLCanvasElement()->InvalidateCanvasContent(&r); @@ -1430,7 +1424,7 @@ NS_IMETHODIMP nsCanvasRenderingContext2D::SetTransform(float m11, float m12, float m21, float m22, float dx, float dy) { if (!FloatValidate(m11,m12,m21,m22,dx,dy)) - return NS_ERROR_DOM_SYNTAX_ERR; + return NS_OK; gfxMatrix matrix(m11, m12, m21, m22, dx, dy); mThebes->SetMatrix(matrix); @@ -2097,7 +2091,7 @@ nsCanvasRenderingContext2D::BezierCurveTo(float cp1x, float cp1y, float x, float y) { if (!FloatValidate(cp1x,cp1y,cp2x,cp2y,x,y)) - return NS_ERROR_DOM_SYNTAX_ERR; + return NS_OK; mHasPath = PR_TRUE; mThebes->CurveTo(gfxPoint(cp1x, cp1y), @@ -2111,7 +2105,7 @@ NS_IMETHODIMP nsCanvasRenderingContext2D::ArcTo(float x1, float y1, float x2, float y2, float radius) { if (!FloatValidate(x1,y1,x2,y2,radius)) - return NS_ERROR_DOM_SYNTAX_ERR; + return NS_OK; if (radius < 0) return NS_ERROR_DOM_INDEX_SIZE_ERR; diff --git a/content/canvas/test/Makefile.in b/content/canvas/test/Makefile.in index fa508e2cdb3..3d30e9b3d96 100644 --- a/content/canvas/test/Makefile.in +++ b/content/canvas/test/Makefile.in @@ -80,6 +80,7 @@ _TEST_FILES_0 = \ test_2d.composite.uncovered.image.source-in.html \ test_2d.composite.uncovered.image.source-out.html \ test_toDataURL_lowercase_ascii.html \ + test_toDataURL_parameters.html \ test_mozGetAsFile.html \ test_canvas_strokeStyle_getter.html \ test_bug613794.html \ diff --git a/content/canvas/test/test_canvas.html b/content/canvas/test/test_canvas.html index 96fb75ea6cf..f75776b24b2 100644 --- a/content/canvas/test/test_canvas.html +++ b/content/canvas/test/test_canvas.html @@ -11880,7 +11880,7 @@ isPixel(ctx, 90,45, 0,255,0,255, 0); } catch (e) { _thrown_outer = true; } -todo(!_thrown_outer, 'should not throw exception'); +ok(!_thrown_outer, 'should not throw exception'); } @@ -12393,7 +12393,7 @@ isPixel(ctx, 90,45, 0,255,0,255, 0); } catch (e) { _thrown_outer = true; } -todo(!_thrown_outer, 'should not throw exception'); +ok(!_thrown_outer, 'should not throw exception'); } @@ -18995,7 +18995,7 @@ isPixel(ctx, 50,25, 0,255,0,255, 0); } catch (e) { _thrown_outer = true; } -todo(!_thrown_outer, 'should not throw exception'); +ok(!_thrown_outer, 'should not throw exception'); } @@ -19537,21 +19537,23 @@ var canvas = document.getElementById('c614'); var ctx = canvas.getContext('2d'); netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); +var _threw = false; try { var data = canvas.toDataURL('image/png', 'quality=100'); - ok(false, "Should have thrown an exception for invalid args to png encoder"); } catch (e) { - is(e.result, Components.results.NS_ERROR_INVALID_ARG, "Exception was wrong for png encoder"); + _threw = true; } +ok(!_threw, "Should not throw an exception for invalid args to png encoder"); +_threw = false; try { var data = canvas.toDataURL('image/jpeg', 'foobar=true'); - ok(false, "Should have thrown an exception for invalid args to jpeg encoder"); } catch (e) { - is(e.result, Components.results.NS_ERROR_INVALID_ARG, "Exception was wrong for jpeg encoder"); + _threw = true; } +ok(!_threw, "Should not throw an exception for invalid args to jpeg encoder"); } @@ -20761,7 +20763,7 @@ ok(/^data:image\/png[;,]/.test(data), "data =~ /^data:image\\/png[;,]/"); } catch (e) { _thrown_outer = true; } -todo(!_thrown_outer, 'should not throw exception'); +ok(!_thrown_outer, 'should not throw exception'); } @@ -20788,7 +20790,7 @@ ok(/^data:image\/png[;,]/.test(data), "data =~ /^data:image\\/png[;,]/"); } catch (e) { _thrown_outer = true; } -todo(!_thrown_outer, 'should not throw exception'); +ok(!_thrown_outer, 'should not throw exception'); } @@ -20816,7 +20818,7 @@ ok(/^data:image\/png[;,]/.test(data), "data =~ /^data:image\\/png[;,]/"); } catch (e) { _thrown_outer = true; } -todo(!_thrown_outer, 'should not throw exception'); +ok(!_thrown_outer, 'should not throw exception'); } @@ -21410,6 +21412,11 @@ function runTests() { // they are in these tests //test_2d_shadow_composite_3(); //test_2d_shadow_composite_4(); + // Shadows should not be drawn if the operator is not source-over (the spec doesn't + // say this yet, but it should be changed). These tests assume shadows will + // be drawn with operators other than source-over: + //test_2d_shadow_composite_1(); + //test_2d_shadow_composite_2(); try { test_2d_canvas_readonly(); } catch (e) { @@ -23795,16 +23802,6 @@ function runTests() { } catch (e) { ok(false, "unexpected exception thrown in: test_2d_shadow_clip_3"); } - try { - test_2d_shadow_composite_1(); - } catch (e) { - ok(false, "unexpected exception thrown in: test_2d_shadow_composite_1"); - } - try { - test_2d_shadow_composite_2(); - } catch (e) { - ok(false, "unexpected exception thrown in: test_2d_shadow_composite_2"); - } try { test_2d_shadow_gradient_alpha(); } catch (e) { diff --git a/content/canvas/test/test_toDataURL_parameters.html b/content/canvas/test/test_toDataURL_parameters.html new file mode 100644 index 00000000000..0a58ec3a441 --- /dev/null +++ b/content/canvas/test/test_toDataURL_parameters.html @@ -0,0 +1,55 @@ + +Canvas test: toDataURL parameters (Bug 564388) + + + + +

    +This test covers the JPEG quality parameter. If (when) the HTML5 spec changes the +allowed parameters for ToDataURL, new tests should go here. +

    +

    FAIL (fallback content)

    + diff --git a/content/canvas/test/webgl/failing_tests_mac.txt b/content/canvas/test/webgl/failing_tests_mac.txt index a5025fcda8e..8faf4eab915 100644 --- a/content/canvas/test/webgl/failing_tests_mac.txt +++ b/content/canvas/test/webgl/failing_tests_mac.txt @@ -1,4 +1,3 @@ -conformance/canvas-test.html conformance/gl-getshadersource.html conformance/gl-object-get-calls.html conformance/texture-npot.html diff --git a/content/canvas/test/webgl/test_webgl_conformance_test_suite.html b/content/canvas/test/webgl/test_webgl_conformance_test_suite.html index b1732e7a516..588c6f5744f 100644 --- a/content/canvas/test/webgl/test_webgl_conformance_test_suite.html +++ b/content/canvas/test/webgl/test_webgl_conformance_test_suite.html @@ -365,10 +365,6 @@ function start() { var testsToIgnore = []; - // canvas-test.html is currently failing on Windows XP test slaves - if (kIsWindows && !kIsWindowsVistaOrHigher) - testsToIgnore.push('conformance/canvas-test.html'); - var testsSuccessful = []; runTestSuite(); diff --git a/content/events/public/nsIPrivateDOMEvent.h b/content/events/public/nsIPrivateDOMEvent.h index 1892cda8ec5..a32f1dab949 100644 --- a/content/events/public/nsIPrivateDOMEvent.h +++ b/content/events/public/nsIPrivateDOMEvent.h @@ -97,12 +97,10 @@ nsresult NS_NewDOMBeforeUnloadEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, nsEvent* aEvent); nsresult NS_NewDOMPageTransitionEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, nsEvent* aEvent); -#ifdef MOZ_SVG nsresult NS_NewDOMSVGEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, class nsEvent* aEvent); nsresult NS_NewDOMSVGZoomEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, class nsGUIEvent* aEvent); -#endif // MOZ_SVG #ifdef MOZ_SMIL nsresult NS_NewDOMTimeEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, class nsEvent* aEvent); diff --git a/content/events/src/nsDOMEvent.cpp b/content/events/src/nsDOMEvent.cpp index a04e80e6654..1fa9cee9a5e 100644 --- a/content/events/src/nsDOMEvent.cpp +++ b/content/events/src/nsDOMEvent.cpp @@ -57,6 +57,9 @@ #include "nsIScriptSecurityManager.h" #include "nsIScriptError.h" #include "nsDOMPopStateEvent.h" +#include "mozilla/Preferences.h" + +using namespace mozilla; static const char* const sEventNames[] = { "mousedown", "mouseup", "click", "dblclick", "mouseover", @@ -76,10 +79,8 @@ static const char* const sEventNames[] = { "DOMActivate", "DOMFocusIn", "DOMFocusOut", "pageshow", "pagehide", "DOMMouseScroll", "MozMousePixelScroll", "offline", "online", "copy", "cut", "paste", "open", "message", -#ifdef MOZ_SVG "SVGLoad", "SVGUnload", "SVGAbort", "SVGError", "SVGResize", "SVGScroll", "SVGZoom", -#endif // MOZ_SVG #ifdef MOZ_SMIL "beginEvent", "endEvent", "repeatEvent", #endif // MOZ_SMIL @@ -774,7 +775,6 @@ NS_METHOD nsDOMEvent::DuplicatePrivateData() static_cast(mEvent)->detail); break; } -#ifdef MOZ_SVG case NS_SVG_EVENT: { newEvent = new nsEvent(PR_FALSE, msg); @@ -789,7 +789,6 @@ NS_METHOD nsDOMEvent::DuplicatePrivateData() newEvent->eventStructType = NS_SVGZOOM_EVENT; break; } -#endif // MOZ_SVG #ifdef MOZ_SMIL case NS_SMIL_TIME_EVENT: { @@ -1088,8 +1087,7 @@ nsDOMEvent::PopupAllowedEventsChanged() nsMemory::Free(sPopupAllowedEvents); } - nsAdoptingCString str = - nsContentUtils::GetCharPref("dom.popup_allowed_events"); + nsAdoptingCString str = Preferences::GetCString("dom.popup_allowed_events"); // We'll want to do this even if str is empty to avoid looking up // this pref all the time if it's not set. @@ -1265,7 +1263,6 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType) return sEventNames[eDOMEvents_open]; case NS_MESSAGE: return sEventNames[eDOMEvents_message]; -#ifdef MOZ_SVG case NS_SVG_LOAD: return sEventNames[eDOMEvents_SVGLoad]; case NS_SVG_UNLOAD: @@ -1280,7 +1277,6 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType) return sEventNames[eDOMEvents_SVGScroll]; case NS_SVG_ZOOM: return sEventNames[eDOMEvents_SVGZoom]; -#endif // MOZ_SVG #ifdef MOZ_SMIL case NS_SMIL_BEGIN: return sEventNames[eDOMEvents_beginEvent]; diff --git a/content/events/src/nsDOMEvent.h b/content/events/src/nsDOMEvent.h index 18c7a357ac4..92fd8a75fcd 100644 --- a/content/events/src/nsDOMEvent.h +++ b/content/events/src/nsDOMEvent.h @@ -138,7 +138,6 @@ public: eDOMEvents_paste, eDOMEvents_open, eDOMEvents_message, -#ifdef MOZ_SVG eDOMEvents_SVGLoad, eDOMEvents_SVGUnload, eDOMEvents_SVGAbort, @@ -146,7 +145,6 @@ public: eDOMEvents_SVGResize, eDOMEvents_SVGScroll, eDOMEvents_SVGZoom, -#endif // MOZ_SVG #ifdef MOZ_SMIL eDOMEvents_beginEvent, eDOMEvents_endEvent, diff --git a/content/events/src/nsDOMTouchEvent.cpp b/content/events/src/nsDOMTouchEvent.cpp index 8fbd374a2c3..a1ac1ed1239 100644 --- a/content/events/src/nsDOMTouchEvent.cpp +++ b/content/events/src/nsDOMTouchEvent.cpp @@ -41,6 +41,9 @@ #include "nsIClassInfo.h" #include "nsIXPCScriptable.h" #include "nsContentUtils.h" +#include "mozilla/Preferences.h" + +using namespace mozilla; DOMCI_DATA(Touch, nsDOMTouch) @@ -323,7 +326,7 @@ nsDOMTouchEvent::PrefEnabled() static PRBool sPrefValue = PR_FALSE; if (!sDidCheckPref) { sDidCheckPref = PR_TRUE; - sPrefValue = nsContentUtils::GetBoolPref("dom.w3c_touch_events.enabled", PR_FALSE); + sPrefValue = Preferences::GetBool("dom.w3c_touch_events.enabled", PR_FALSE); if (sPrefValue) { nsContentUtils::InitializeTouchEventTable(); } diff --git a/content/events/src/nsEventDispatcher.cpp b/content/events/src/nsEventDispatcher.cpp index ec2083ed481..65b165e48a1 100644 --- a/content/events/src/nsEventDispatcher.cpp +++ b/content/events/src/nsEventDispatcher.cpp @@ -755,14 +755,12 @@ nsEventDispatcher::CreateEvent(nsPresContext* aPresContext, case NS_TEXT_EVENT: return NS_NewDOMTextEvent(aDOMEvent, aPresContext, static_cast(aEvent)); -#ifdef MOZ_SVG case NS_SVG_EVENT: return NS_NewDOMSVGEvent(aDOMEvent, aPresContext, aEvent); case NS_SVGZOOM_EVENT: return NS_NewDOMSVGZoomEvent(aDOMEvent, aPresContext, static_cast(aEvent)); -#endif // MOZ_SVG #ifdef MOZ_SMIL case NS_SMIL_TIME_EVENT: return NS_NewDOMTimeEvent(aDOMEvent, aPresContext, aEvent); @@ -822,14 +820,12 @@ nsEventDispatcher::CreateEvent(nsPresContext* aPresContext, aEventType.LowerCaseEqualsLiteral("events") || aEventType.LowerCaseEqualsLiteral("htmlevents")) return NS_NewDOMEvent(aDOMEvent, aPresContext, nsnull); -#ifdef MOZ_SVG if (aEventType.LowerCaseEqualsLiteral("svgevent") || aEventType.LowerCaseEqualsLiteral("svgevents")) return NS_NewDOMSVGEvent(aDOMEvent, aPresContext, nsnull); if (aEventType.LowerCaseEqualsLiteral("svgzoomevent") || aEventType.LowerCaseEqualsLiteral("svgzoomevents")) return NS_NewDOMSVGZoomEvent(aDOMEvent, aPresContext, nsnull); -#endif // MOZ_SVG #ifdef MOZ_SMIL if (aEventType.LowerCaseEqualsLiteral("timeevent") || aEventType.LowerCaseEqualsLiteral("timeevents")) diff --git a/content/events/src/nsEventListenerManager.cpp b/content/events/src/nsEventListenerManager.cpp index fd690dd712f..af61f10a3ed 100644 --- a/content/events/src/nsEventListenerManager.cpp +++ b/content/events/src/nsEventListenerManager.cpp @@ -53,9 +53,7 @@ #include "nsIDOMCompositionListener.h" #include "nsIDOMUIListener.h" #include "nsITextControlFrame.h" -#ifdef MOZ_SVG #include "nsGkAtoms.h" -#endif // MOZ_SVG #include "nsPIDOMWindow.h" #include "nsIPrivateDOMEvent.h" #include "nsIJSEventListener.h" @@ -82,7 +80,6 @@ #include "nsIScriptObjectOwner.h" // for nsIScriptEventHandlerOwner #include "nsFocusManager.h" #include "nsIDOMElement.h" -#include "nsIDOMNSDocument.h" #include "nsContentUtils.h" #include "nsJSUtils.h" #include "nsIDOMEventGroup.h" @@ -1006,7 +1003,6 @@ nsEventListenerManager::CompileEventHandlerInternal(nsIScriptContext *aContext, if (content) { nsAutoString handlerBody; nsIAtom* attrName = aName; -#ifdef MOZ_SVG if (aName == nsGkAtoms::onSVGLoad) attrName = nsGkAtoms::onload; else if (aName == nsGkAtoms::onSVGUnload) @@ -1021,7 +1017,6 @@ nsEventListenerManager::CompileEventHandlerInternal(nsIScriptContext *aContext, attrName = nsGkAtoms::onscroll; else if (aName == nsGkAtoms::onSVGZoom) attrName = nsGkAtoms::onzoom; -#endif // MOZ_SVG #ifdef MOZ_SMIL else if (aName == nsGkAtoms::onbeginEvent) attrName = nsGkAtoms::onbegin; diff --git a/content/events/src/nsEventStateManager.cpp b/content/events/src/nsEventStateManager.cpp index 7855bd56aac..b3a167df205 100644 --- a/content/events/src/nsEventStateManager.cpp +++ b/content/events/src/nsEventStateManager.cpp @@ -78,8 +78,6 @@ #include "nsIDOMHTMLBodyElement.h" #include "nsIDOMXULControlElement.h" #include "nsIDOMXULTextboxElement.h" -#include "nsImageMapUtils.h" -#include "nsIHTMLDocument.h" #include "nsINameSpaceManager.h" #include "nsIBaseWindow.h" #include "nsIView.h" @@ -96,7 +94,6 @@ #include "nsIDocShellTreeNode.h" #include "nsIWebNavigation.h" #include "nsIContentViewer.h" -#include "nsIPrefBranch2.h" #ifdef MOZ_XUL #include "nsXULPopupManager.h" #endif @@ -153,11 +150,15 @@ #include "nsICommandParams.h" #include "mozilla/Services.h" #include "mozAutoDocUpdate.h" +#include "nsHTMLLabelElement.h" + +#include "mozilla/Preferences.h" #ifdef XP_MACOSX #import #endif +using namespace mozilla; using namespace mozilla::dom; //#define DEBUG_DOCSHELL_FOCUS @@ -325,7 +326,7 @@ GetDocumentFromWindow(nsIDOMWindow *aWindow) static PRInt32 GetAccessModifierMaskFromPref(PRInt32 aItemType) { - PRInt32 accessKey = nsContentUtils::GetIntPref("ui.key.generalAccessKey", -1); + PRInt32 accessKey = Preferences::GetInt("ui.key.generalAccessKey", -1); switch (accessKey) { case -1: break; // use the individual prefs case nsIDOMKeyEvent::DOM_VK_SHIFT: return NS_MODIFIER_SHIFT; @@ -337,9 +338,9 @@ GetAccessModifierMaskFromPref(PRInt32 aItemType) switch (aItemType) { case nsIDocShellTreeItem::typeChrome: - return nsContentUtils::GetIntPref("ui.key.chromeAccess", 0); + return Preferences::GetInt("ui.key.chromeAccess", 0); case nsIDocShellTreeItem::typeContent: - return nsContentUtils::GetIntPref("ui.key.contentAccess", 0); + return Preferences::GetInt("ui.key.contentAccess", 0); default: return 0; } @@ -584,7 +585,7 @@ nsMouseWheelTransaction::OnFailToScrollTarget() { NS_PRECONDITION(sTargetFrame, "We don't have mouse scrolling transaction"); - if (nsContentUtils::GetBoolPref("test.mousescroll", PR_FALSE)) { + if (Preferences::GetBool("test.mousescroll", PR_FALSE)) { // This event is used for automated tests, see bug 442774. nsContentUtils::DispatchTrustedEvent( sTargetFrame->GetContent()->GetOwnerDoc(), @@ -612,7 +613,7 @@ nsMouseWheelTransaction::OnTimeout(nsITimer* aTimer, void* aClosure) // the next DOM event might create strange situation for us. EndTransaction(); - if (nsContentUtils::GetBoolPref("test.mousescroll", PR_FALSE)) { + if (Preferences::GetBool("test.mousescroll", PR_FALSE)) { // This event is used for automated tests, see bug 442774. nsContentUtils::DispatchTrustedEvent( frame->GetContent()->GetOwnerDoc(), @@ -651,15 +652,13 @@ nsMouseWheelTransaction::GetScreenPoint(nsGUIEvent* aEvent) PRUint32 nsMouseWheelTransaction::GetTimeoutTime() { - return (PRUint32) - nsContentUtils::GetIntPref("mousewheel.transaction.timeout", 1500); + return Preferences::GetUint("mousewheel.transaction.timeout", 1500); } PRUint32 nsMouseWheelTransaction::GetIgnoreMoveDelayTime() { - return (PRUint32) - nsContentUtils::GetIntPref("mousewheel.transaction.ignoremovedelay", 100); + return Preferences::GetUint("mousewheel.transaction.ignoremovedelay", 100); } PRBool @@ -708,13 +707,13 @@ nsMouseWheelTransaction::ComputeAcceleratedWheelDelta(PRInt32 aDelta, PRInt32 nsMouseWheelTransaction::GetAccelerationStart() { - return nsContentUtils::GetIntPref("mousewheel.acceleration.start", -1); + return Preferences::GetInt("mousewheel.acceleration.start", -1); } PRInt32 nsMouseWheelTransaction::GetAccelerationFactor() { - return nsContentUtils::GetIntPref("mousewheel.acceleration.factor", -1); + return Preferences::GetInt("mousewheel.acceleration.factor", -1); } PRInt32 @@ -828,6 +827,31 @@ nsEventStateManager::UpdateUserActivityTimer(void) return NS_OK; } +static const char* kObservedPrefs[] = { + "accessibility.accesskeycausesactivation", + "nglayout.events.dispatchLeftClickOnly", + "ui.key.generalAccessKey", + "ui.key.chromeAccess", + "ui.key.contentAccess", + "ui.click_hold_context_menus", +#if 0 + "mousewheel.withaltkey.action", + "mousewheel.withaltkey.numlines", + "mousewheel.withaltkey.sysnumlines", + "mousewheel.withcontrolkey.action", + "mousewheel.withcontrolkey.numlines", + "mousewheel.withcontrolkey.sysnumlines", + "mousewheel.withnokey.action", + "mousewheel.withnokey.numlines", + "mousewheel.withnokey.sysnumlines", + "mousewheel.withshiftkey.action", + "mousewheel.withshiftkey.numlines", + "mousewheel.withshiftkey.sysnumlines", +#endif + "dom.popup_allowed_events", + nsnull +}; + nsresult nsEventStateManager::Init() { @@ -838,44 +862,19 @@ nsEventStateManager::Init() observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_TRUE); - nsIPrefBranch2* prefBranch = nsContentUtils::GetPrefBranch(); - - if (prefBranch) { - if (sESMInstanceCount == 1) { - sLeftClickOnly = - nsContentUtils::GetBoolPref("nglayout.events.dispatchLeftClickOnly", - sLeftClickOnly); - sChromeAccessModifier = - GetAccessModifierMaskFromPref(nsIDocShellTreeItem::typeChrome); - sContentAccessModifier = - GetAccessModifierMaskFromPref(nsIDocShellTreeItem::typeContent); - } - prefBranch->AddObserver("accessibility.accesskeycausesactivation", this, PR_TRUE); - prefBranch->AddObserver("nglayout.events.dispatchLeftClickOnly", this, PR_TRUE); - prefBranch->AddObserver("ui.key.generalAccessKey", this, PR_TRUE); - prefBranch->AddObserver("ui.key.chromeAccess", this, PR_TRUE); - prefBranch->AddObserver("ui.key.contentAccess", this, PR_TRUE); - prefBranch->AddObserver("ui.click_hold_context_menus", this, PR_TRUE); -#if 0 - prefBranch->AddObserver("mousewheel.withaltkey.action", this, PR_TRUE); - prefBranch->AddObserver("mousewheel.withaltkey.numlines", this, PR_TRUE); - prefBranch->AddObserver("mousewheel.withaltkey.sysnumlines", this, PR_TRUE); - prefBranch->AddObserver("mousewheel.withcontrolkey.action", this, PR_TRUE); - prefBranch->AddObserver("mousewheel.withcontrolkey.numlines", this, PR_TRUE); - prefBranch->AddObserver("mousewheel.withcontrolkey.sysnumlines", this, PR_TRUE); - prefBranch->AddObserver("mousewheel.withnokey.action", this, PR_TRUE); - prefBranch->AddObserver("mousewheel.withnokey.numlines", this, PR_TRUE); - prefBranch->AddObserver("mousewheel.withnokey.sysnumlines", this, PR_TRUE); - prefBranch->AddObserver("mousewheel.withshiftkey.action", this, PR_TRUE); - prefBranch->AddObserver("mousewheel.withshiftkey.numlines", this, PR_TRUE); - prefBranch->AddObserver("mousewheel.withshiftkey.sysnumlines", this, PR_TRUE); -#endif - - prefBranch->AddObserver("dom.popup_allowed_events", this, PR_TRUE); + if (sESMInstanceCount == 1) { + sLeftClickOnly = + Preferences::GetBool("nglayout.events.dispatchLeftClickOnly", + sLeftClickOnly); + sChromeAccessModifier = + GetAccessModifierMaskFromPref(nsIDocShellTreeItem::typeChrome); + sContentAccessModifier = + GetAccessModifierMaskFromPref(nsIDocShellTreeItem::typeContent); } + Preferences::AddWeakObservers(this, kObservedPrefs); mClickHoldContextMenu = - nsContentUtils::GetBoolPref("ui.click_hold_context_menus", PR_FALSE); + Preferences::GetBool("ui.click_hold_context_menus", PR_FALSE); return NS_OK; } @@ -923,33 +922,7 @@ nsEventStateManager::~nsEventStateManager() nsresult nsEventStateManager::Shutdown() { - nsIPrefBranch2* prefBranch = nsContentUtils::GetPrefBranch(); - - if (prefBranch) { - prefBranch->RemoveObserver("accessibility.accesskeycausesactivation", this); - prefBranch->RemoveObserver("nglayout.events.dispatchLeftClickOnly", this); - prefBranch->RemoveObserver("ui.key.generalAccessKey", this); - prefBranch->RemoveObserver("ui.key.chromeAccess", this); - prefBranch->RemoveObserver("ui.key.contentAccess", this); - prefBranch->RemoveObserver("ui.click_hold_context_menus", this); -#if 0 - prefBranch->RemoveObserver("mousewheel.withshiftkey.action", this); - prefBranch->RemoveObserver("mousewheel.withshiftkey.numlines", this); - prefBranch->RemoveObserver("mousewheel.withshiftkey.sysnumlines", this); - prefBranch->RemoveObserver("mousewheel.withcontrolkey.action", this); - prefBranch->RemoveObserver("mousewheel.withcontrolkey.numlines", this); - prefBranch->RemoveObserver("mousewheel.withcontrolkey.sysnumlines", this); - prefBranch->RemoveObserver("mousewheel.withaltkey.action", this); - prefBranch->RemoveObserver("mousewheel.withaltkey.numlines", this); - prefBranch->RemoveObserver("mousewheel.withaltkey.sysnumlines", this); - prefBranch->RemoveObserver("mousewheel.withnokey.action", this); - prefBranch->RemoveObserver("mousewheel.withnokey.numlines", this); - prefBranch->RemoveObserver("mousewheel.withnokey.sysnumlines", this); -#endif - - prefBranch->RemoveObserver("dom.popup_allowed_events", this); - } - + Preferences::RemoveObservers(this, kObservedPrefs); m_haveShutdown = PR_TRUE; return NS_OK; } @@ -968,12 +941,12 @@ nsEventStateManager::Observe(nsISupports *aSubject, nsDependentString data(someData); if (data.EqualsLiteral("accessibility.accesskeycausesactivation")) { sKeyCausesActivation = - nsContentUtils::GetBoolPref("accessibility.accesskeycausesactivation", - sKeyCausesActivation); + Preferences::GetBool("accessibility.accesskeycausesactivation", + sKeyCausesActivation); } else if (data.EqualsLiteral("nglayout.events.dispatchLeftClickOnly")) { sLeftClickOnly = - nsContentUtils::GetBoolPref("nglayout.events.dispatchLeftClickOnly", - sLeftClickOnly); + Preferences::GetBool("nglayout.events.dispatchLeftClickOnly", + sLeftClickOnly); } else if (data.EqualsLiteral("ui.key.generalAccessKey")) { sChromeAccessModifier = GetAccessModifierMaskFromPref(nsIDocShellTreeItem::typeChrome); @@ -987,7 +960,7 @@ nsEventStateManager::Observe(nsISupports *aSubject, GetAccessModifierMaskFromPref(nsIDocShellTreeItem::typeContent); } else if (data.EqualsLiteral("ui.click_hold_context_menus")) { mClickHoldContextMenu = - nsContentUtils::GetBoolPref("ui.click_hold_context_menus", PR_FALSE); + Preferences::GetBool("ui.click_hold_context_menus", PR_FALSE); #if 0 } else if (data.EqualsLiteral("mousewheel.withaltkey.action")) { } else if (data.EqualsLiteral("mousewheel.withaltkey.numlines")) { @@ -1720,7 +1693,7 @@ nsEventStateManager::CreateClickHoldTimer(nsPresContext* inPresContext, mClickHoldTimer = do_CreateInstance("@mozilla.org/timer;1"); if (mClickHoldTimer) { PRInt32 clickHoldDelay = - nsContentUtils::GetIntPref("ui.click_hold_context_menus.delay", 500); + Preferences::GetInt("ui.click_hold_context_menus.delay", 500); mClickHoldTimer->InitWithFuncCallback(sClickHoldCallback, this, clickHoldDelay, nsITimer::TYPE_ONE_SHOT); @@ -2401,8 +2374,8 @@ nsEventStateManager::ChangeTextSize(PRInt32 change) NS_ENSURE_SUCCESS(rv, rv); float textzoom; - float zoomMin = ((float)nsContentUtils::GetIntPref("zoom.minPercent", 50)) / 100; - float zoomMax = ((float)nsContentUtils::GetIntPref("zoom.maxPercent", 300)) / 100; + float zoomMin = ((float)Preferences::GetInt("zoom.minPercent", 50)) / 100; + float zoomMax = ((float)Preferences::GetInt("zoom.maxPercent", 300)) / 100; mv->GetTextZoom(&textzoom); textzoom += ((float)change) / 10; if (textzoom < zoomMin) @@ -2422,8 +2395,8 @@ nsEventStateManager::ChangeFullZoom(PRInt32 change) NS_ENSURE_SUCCESS(rv, rv); float fullzoom; - float zoomMin = ((float)nsContentUtils::GetIntPref("zoom.minPercent", 50)) / 100; - float zoomMax = ((float)nsContentUtils::GetIntPref("zoom.maxPercent", 300)) / 100; + float zoomMin = ((float)Preferences::GetInt("zoom.minPercent", 50)) / 100; + float zoomMax = ((float)Preferences::GetInt("zoom.maxPercent", 300)) / 100; mv->GetFullZoom(&fullzoom); fullzoom += ((float)change) / 10; if (fullzoom < zoomMin) @@ -2464,10 +2437,11 @@ nsEventStateManager::DoScrollZoom(nsIFrame *aTargetFrame, // positive adjustment to decrease zoom, negative to increase PRInt32 change = (adjustment > 0) ? -1 : 1; - if (nsContentUtils::GetBoolPref("browser.zoom.full")) + if (Preferences::GetBool("browser.zoom.full")) { ChangeFullZoom(change); - else + } else { ChangeTextSize(change); + } } } @@ -2608,7 +2582,7 @@ nsEventStateManager::GetWheelActionFor(nsMouseScrollEvent* aMouseEvent) nsCAutoString prefName; GetBasePrefKeyForMouseWheel(aMouseEvent, prefName); prefName.Append(".action"); - return nsContentUtils::GetIntPref(prefName.get()); + return Preferences::GetInt(prefName.get()); } PRInt32 @@ -2619,7 +2593,7 @@ nsEventStateManager::GetScrollLinesFor(nsMouseScrollEvent* aMouseEvent) nsCAutoString prefName; GetBasePrefKeyForMouseWheel(aMouseEvent, prefName); prefName.Append(".numlines"); - return nsContentUtils::GetIntPref(prefName.get()); + return Preferences::GetInt(prefName.get()); } PRBool @@ -2628,7 +2602,7 @@ nsEventStateManager::UseSystemScrollSettingFor(nsMouseScrollEvent* aMouseEvent) nsCAutoString prefName; GetBasePrefKeyForMouseWheel(aMouseEvent, prefName); prefName.Append(".sysnumlines"); - return nsContentUtils::GetBoolPref(prefName.get()); + return Preferences::GetBool(prefName.get()); } nsresult @@ -3467,7 +3441,7 @@ nsEventStateManager::UpdateCursor(nsPresContext* aPresContext, hotspotY = framecursor.mHotspotY; } - if (nsContentUtils::GetBoolPref("ui.use_activity_cursor", PR_FALSE)) { + if (Preferences::GetBool("ui.use_activity_cursor", PR_FALSE)) { // Check whether or not to show the busy cursor nsCOMPtr pcContainer = aPresContext->GetContainer(); nsCOMPtr docShell(do_QueryInterface(pcContainer)); @@ -4227,35 +4201,26 @@ nsEventStateManager::GetEventTargetContent(nsEvent* aEvent) return content; } -static already_AddRefed -GetLabelTarget(nsIContent* aLabel) +static Element* +GetLabelTarget(nsIContent* aPossibleLabel) { - nsCOMPtr label = do_QueryInterface(aLabel); + nsHTMLLabelElement* label = nsHTMLLabelElement::FromContent(aPossibleLabel); if (!label) return nsnull; - nsCOMPtr target; - label->GetControl(getter_AddRefs(target)); - nsIContent* targetContent = nsnull; - if (target) { - CallQueryInterface(target, &targetContent); - } - return targetContent; + return label->GetLabeledElement(); } static bool -IsAncestorOf(nsIContent* aPossibleAncestor, nsIContent* aPossibleDescendant, - PRBool aFollowLabels) +IsAncestorOf(nsIContent* aPossibleAncestor, nsIContent* aPossibleDescendant) { for (; aPossibleDescendant; aPossibleDescendant = aPossibleDescendant->GetParent()) { if (aPossibleAncestor == aPossibleDescendant) return true; - if (aFollowLabels) { - nsCOMPtr labelTarget = GetLabelTarget(aPossibleDescendant); - if (labelTarget == aPossibleAncestor) - return true; - } + Element* labelTarget = GetLabelTarget(aPossibleDescendant); + if (labelTarget == aPossibleAncestor) + return true; } return false; } @@ -4273,14 +4238,14 @@ ShouldShowFocusRing(nsIContent* aContent) } nsEventStates -nsEventStateManager::GetContentState(nsIContent *aContent, PRBool aFollowLabels) +nsEventStateManager::GetContentState(nsIContent *aContent) { nsEventStates state = aContent->IntrinsicState(); - if (IsAncestorOf(aContent, mActiveContent, aFollowLabels)) { + if (IsAncestorOf(aContent, mActiveContent)) { state |= NS_EVENT_STATE_ACTIVE; } - if (IsAncestorOf(aContent, mHoverContent, aFollowLabels)) { + if (IsAncestorOf(aContent, mHoverContent)) { state |= NS_EVENT_STATE_HOVER; } @@ -4352,7 +4317,7 @@ NotifyAncestors(nsIDocument* aDocument, nsIContent* aStartNode, { while (aStartNode && aStartNode != aStopBefore) { aDocument->ContentStateChanged(aStartNode, aState); - nsCOMPtr labelTarget = GetLabelTarget(aStartNode); + Element* labelTarget = GetLabelTarget(aStartNode); if (labelTarget) { aDocument->ContentStateChanged(labelTarget, aState); } diff --git a/content/events/src/nsEventStateManager.h b/content/events/src/nsEventStateManager.h index 08646892976..c9d5a6afa59 100644 --- a/content/events/src/nsEventStateManager.h +++ b/content/events/src/nsEventStateManager.h @@ -122,15 +122,9 @@ public: /** * Returns the content state of aContent. * @param aContent The control whose state is requested. - * @param aFollowLabels Whether to reflect a label's content state on its - * associated control. If aFollowLabels is true and - * aContent is a control which has a label that has the - * hover or active content state set, GetContentState - * will pretend that those states are also set on aContent. * @return The content state. */ - virtual nsEventStates GetContentState(nsIContent *aContent, - PRBool aFollowLabels = PR_FALSE); + virtual nsEventStates GetContentState(nsIContent *aContent); /** * Notify that the given NS_EVENT_STATE_* bit has changed for this content. diff --git a/content/events/test/Makefile.in b/content/events/test/Makefile.in index 0eb455d8219..b9ef4e527c2 100644 --- a/content/events/test/Makefile.in +++ b/content/events/test/Makefile.in @@ -104,6 +104,8 @@ _TEST_FILES = \ test_bug641477.html \ test_bug648573.html \ test_bug615597.html \ + test_bug656379-1.html \ + test_bug656379-2.html \ test_bug656954.html \ $(NULL) diff --git a/content/events/test/test_bug656379-1.html b/content/events/test/test_bug656379-1.html new file mode 100644 index 00000000000..4a0f3b0bdb8 --- /dev/null +++ b/content/events/test/test_bug656379-1.html @@ -0,0 +1,199 @@ + + + + + Test for Bug 656379 + + + + + + + + +Mozilla Bug 426082 +

    + +
    +
    +
    +

    +

    +

    Something under the label

    + + + + + + + + + diff --git a/content/events/test/test_bug656379-2.html b/content/events/test/test_bug656379-2.html new file mode 100644 index 00000000000..30087e4cc10 --- /dev/null +++ b/content/events/test/test_bug656379-2.html @@ -0,0 +1,63 @@ + + + + + Test for Bug 656379 + + + + + + + +Mozilla Bug 656379 +

    + + + +

    + +
    +
    +
    + + diff --git a/content/html/content/public/nsHTMLCanvasElement.h b/content/html/content/public/nsHTMLCanvasElement.h index 630a789899d..bdfc075f123 100644 --- a/content/html/content/public/nsHTMLCanvasElement.h +++ b/content/html/content/public/nsHTMLCanvasElement.h @@ -181,7 +181,7 @@ protected: PRUint32& aSize, bool& aFellBackToPNG); nsresult ToDataURLImpl(const nsAString& aMimeType, - const nsAString& aEncoderOptions, + nsIVariant* aEncoderOptions, nsAString& aDataURL); nsresult MozGetAsFileImpl(const nsAString& aName, const nsAString& aType, diff --git a/content/html/content/src/Makefile.in b/content/html/content/src/Makefile.in index 7937c34f84f..26bc9023399 100644 --- a/content/html/content/src/Makefile.in +++ b/content/html/content/src/Makefile.in @@ -48,7 +48,6 @@ LIBXUL_LIBRARY = 1 EXPORTS = \ - nsImageMapUtils.h \ nsClientRect.h \ nsHTMLDNSPrefetch.h \ $(NULL) @@ -58,7 +57,6 @@ CPPSRCS = \ nsHTMLDNSPrefetch.cpp \ nsGenericHTMLElement.cpp \ nsFormSubmission.cpp \ - nsImageMapUtils.cpp \ nsTextEditorState.cpp \ nsHTMLElement.cpp \ nsHTMLAnchorElement.cpp \ @@ -68,7 +66,6 @@ CPPSRCS = \ nsHTMLButtonElement.cpp \ nsHTMLCanvasElement.cpp \ nsHTMLDataListElement.cpp \ - nsHTMLDelElement.cpp \ nsHTMLDivElement.cpp \ nsHTMLFieldSetElement.cpp \ nsHTMLFontElement.cpp \ @@ -86,6 +83,7 @@ CPPSRCS = \ nsHTMLLinkElement.cpp \ nsHTMLMapElement.cpp \ nsHTMLMetaElement.cpp \ + nsHTMLModElement.cpp \ nsHTMLObjectElement.cpp \ nsHTMLOListElement.cpp \ nsHTMLSharedObjectElement.cpp \ diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index c72d0dd1bea..3868ed4ed5f 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -48,7 +48,6 @@ #include "nsIDOMHTMLDocument.h" #include "nsIDOMAttr.h" #include "nsIDOMDocumentFragment.h" -#include "nsIDOMNSHTMLDocument.h" #include "nsIDOMNSHTMLElement.h" #include "nsIDOMElementCSSInlineStyle.h" #include "nsIDOMWindow.h" @@ -116,6 +115,9 @@ #include "mozilla/dom/Element.h" #include "nsHTMLFieldSetElement.h" +#include "mozilla/Preferences.h" + +using namespace mozilla; using namespace mozilla::dom; #include "nsThreadUtils.h" @@ -779,12 +781,12 @@ nsGenericHTMLElement::SetInnerHTML(const nsAString& aInnerHTML) PRInt32 newChildCount = GetChildCount(); if (newChildCount && nsContentUtils:: HasMutationListeners(doc, NS_EVENT_BITS_MUTATION_NODEINSERTED)) { - nsCOMArray childNodes; + nsAutoTArray, 50> childNodes; NS_ASSERTION(newChildCount - oldChildCount >= 0, "What, some unexpected dom mutation has happened?"); childNodes.SetCapacity(newChildCount - oldChildCount); for (nsINode::ChildIterator iter(this); !iter.IsDone(); iter.Next()) { - childNodes.AppendObject(iter); + childNodes.AppendElement(iter); } nsGenericElement::FireNodeInserted(doc, this, childNodes); } @@ -896,8 +898,7 @@ nsGenericHTMLElement::GetSpellcheck(PRBool* aSpellcheck) // NOTE: Do not reflect a pref value of 0 back to the DOM getter. // The web page should not know if the user has disabled spellchecking. // We'll catch this in the editor itself. - PRInt32 spellcheckLevel = - nsContentUtils::GetIntPref("layout.spellcheckDefault", 1); + PRInt32 spellcheckLevel = Preferences::GetInt("layout.spellcheckDefault", 1); if (spellcheckLevel == 2) { // "Spellcheck multi- and single-line" *aSpellcheck = PR_TRUE; // Spellchecked by default } @@ -2545,7 +2546,7 @@ nsGenericHTMLFormElement::BindToTree(nsIDocument* aDocument, // the document should not be already loaded and the "browser.autofocus" // preference should be 'true'. if (IsAutofocusable() && HasAttr(kNameSpaceID_None, nsGkAtoms::autofocus) && - nsContentUtils::GetBoolPref("browser.autofocus", PR_TRUE)) { + Preferences::GetBool("browser.autofocus", PR_TRUE)) { nsCOMPtr event = new nsAutoFocusEvent(this); rv = NS_DispatchToCurrentThread(event); NS_ENSURE_SUCCESS(rv, rv); diff --git a/content/html/content/src/nsHTMLCanvasElement.cpp b/content/html/content/src/nsHTMLCanvasElement.cpp index 873d8941161..381155a289e 100644 --- a/content/html/content/src/nsHTMLCanvasElement.cpp +++ b/content/html/content/src/nsHTMLCanvasElement.cpp @@ -47,6 +47,7 @@ #include "nsIXPConnect.h" #include "jsapi.h" #include "nsJSUtils.h" +#include "nsMathUtils.h" #include "nsFrameManager.h" #include "nsDisplayList.h" @@ -196,32 +197,17 @@ nsHTMLCanvasElement::ParseAttribute(PRInt32 aNamespaceID, // nsHTMLCanvasElement::toDataURL NS_IMETHODIMP -nsHTMLCanvasElement::ToDataURL(const nsAString& aType, const nsAString& aParams, +nsHTMLCanvasElement::ToDataURL(const nsAString& aType, nsIVariant* aParams, PRUint8 optional_argc, nsAString& aDataURL) { // do a trust check if this is a write-only canvas - // or if we're trying to use the 2-arg form - if ((mWriteOnly || optional_argc >= 2) && - !nsContentUtils::IsCallerTrustedForRead()) { + if (mWriteOnly && !nsContentUtils::IsCallerTrustedForRead()) { return NS_ERROR_DOM_SECURITY_ERR; } return ToDataURLImpl(aType, aParams, aDataURL); } - -// nsHTMLCanvasElement::toDataURLAs -// -// Native-callers only - -NS_IMETHODIMP -nsHTMLCanvasElement::ToDataURLAs(const nsAString& aMimeType, - const nsAString& aEncoderOptions, - nsAString& aDataURL) -{ - return ToDataURLImpl(aMimeType, aEncoderOptions, aDataURL); -} - nsresult nsHTMLCanvasElement::ExtractData(const nsAString& aType, const nsAString& aOptions, @@ -323,7 +309,7 @@ nsHTMLCanvasElement::ExtractData(const nsAString& aType, nsresult nsHTMLCanvasElement::ToDataURLImpl(const nsAString& aMimeType, - const nsAString& aEncoderOptions, + nsIVariant* aEncoderOptions, nsAString& aDataURL) { bool fallbackToPNG = false; @@ -337,11 +323,30 @@ nsHTMLCanvasElement::ToDataURLImpl(const nsAString& aMimeType, nsAutoString type; nsContentUtils::ASCIIToLower(aMimeType, type); + nsAutoString params; + + // Quality parameter is only valid for the image/jpeg MIME type + if (type.EqualsLiteral("image/jpeg")) { + PRUint16 vartype; + + if (aEncoderOptions && + NS_SUCCEEDED(aEncoderOptions->GetDataType(&vartype)) && + vartype <= nsIDataType::VTYPE_DOUBLE) { + + double quality; + // Quality must be between 0.0 and 1.0, inclusive + if (NS_SUCCEEDED(aEncoderOptions->GetAsDouble(&quality)) && + quality >= 0.0 && quality <= 1.0) { + params.AppendLiteral("quality="); + params.AppendInt(NS_lround(quality * 100.0)); + } + } + } + PRUint32 imgSize = 0; char* imgData; - nsresult rv = ExtractData(type, aEncoderOptions, imgData, - imgSize, fallbackToPNG); + nsresult rv = ExtractData(type, params, imgData, imgSize, fallbackToPNG); NS_ENSURE_SUCCESS(rv, rv); // base 64, result will be NULL terminated diff --git a/content/html/content/src/nsHTMLDNSPrefetch.cpp b/content/html/content/src/nsHTMLDNSPrefetch.cpp index 36ee2f26a0f..3da3675bbe0 100644 --- a/content/html/content/src/nsHTMLDNSPrefetch.cpp +++ b/content/html/content/src/nsHTMLDNSPrefetch.cpp @@ -54,7 +54,6 @@ #include "nsIDNSRecord.h" #include "nsIDNSService.h" #include "nsICancelable.h" -#include "nsContentUtils.h" #include "nsGkAtoms.h" #include "nsIDocument.h" #include "nsThreadUtils.h" @@ -62,6 +61,9 @@ #include "nsIObserverService.h" #include "mozilla/dom/Link.h" +#include "mozilla/Preferences.h" + +using namespace mozilla; using namespace mozilla::dom; using namespace mozilla::net; @@ -94,12 +96,12 @@ nsHTMLDNSPrefetch::Initialize() sPrefetches->Activate(); - nsContentUtils::AddBoolPrefVarCache("network.dns.disablePrefetchFromHTTPS", - &sDisablePrefetchHTTPSPref); + Preferences::AddBoolVarCache(&sDisablePrefetchHTTPSPref, + "network.dns.disablePrefetchFromHTTPS"); // Default is false, so we need an explicit call to prime the cache. sDisablePrefetchHTTPSPref = - nsContentUtils::GetBoolPref("network.dns.disablePrefetchFromHTTPS", PR_TRUE); + Preferences::GetBool("network.dns.disablePrefetchFromHTTPS", PR_TRUE); NS_IF_RELEASE(sDNSService); nsresult rv; diff --git a/content/html/content/src/nsHTMLFieldSetElement.cpp b/content/html/content/src/nsHTMLFieldSetElement.cpp index 30eb1f21b69..aa4141a3cb2 100644 --- a/content/html/content/src/nsHTMLFieldSetElement.cpp +++ b/content/html/content/src/nsHTMLFieldSetElement.cpp @@ -217,8 +217,7 @@ nsHTMLFieldSetElement::InsertChildAt(nsIContent* aChild, PRUint32 aIndex, } nsresult -nsHTMLFieldSetElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify, - PRBool aMutationEvent /* = PR_TRUE */) +nsHTMLFieldSetElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify) { bool firstLegendHasChanged = false; @@ -236,7 +235,7 @@ nsHTMLFieldSetElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify, } } - nsresult rv = nsGenericHTMLFormElement::RemoveChildAt(aIndex, aNotify, aMutationEvent); + nsresult rv = nsGenericHTMLFormElement::RemoveChildAt(aIndex, aNotify); NS_ENSURE_SUCCESS(rv, rv); if (firstLegendHasChanged) { diff --git a/content/html/content/src/nsHTMLFieldSetElement.h b/content/html/content/src/nsHTMLFieldSetElement.h index a4d2732de5f..a4931569995 100644 --- a/content/html/content/src/nsHTMLFieldSetElement.h +++ b/content/html/content/src/nsHTMLFieldSetElement.h @@ -76,8 +76,7 @@ public: virtual nsresult InsertChildAt(nsIContent* aChild, PRUint32 aIndex, PRBool aNotify); - virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify, - PRBool aMutationEvent = PR_TRUE); + virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify); // nsIFormControl NS_IMETHOD_(PRUint32) GetType() const { return NS_FORM_FIELDSET; } diff --git a/content/html/content/src/nsHTMLFormElement.cpp b/content/html/content/src/nsHTMLFormElement.cpp index 600fa60fdee..4220e40094f 100644 --- a/content/html/content/src/nsHTMLFormElement.cpp +++ b/content/html/content/src/nsHTMLFormElement.cpp @@ -328,9 +328,8 @@ DOMCI_NODE_DATA(HTMLFormElement, nsHTMLFormElement) // QueryInterface implementation for nsHTMLFormElement NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLFormElement) - NS_HTML_CONTENT_INTERFACE_TABLE6(nsHTMLFormElement, + NS_HTML_CONTENT_INTERFACE_TABLE5(nsHTMLFormElement, nsIDOMHTMLFormElement, - nsIDOMNSHTMLFormElement, nsIForm, nsIWebProgressListener, nsIRadioGroupContainer, diff --git a/content/html/content/src/nsHTMLFormElement.h b/content/html/content/src/nsHTMLFormElement.h index f464463ada3..6ce99c6cf8c 100644 --- a/content/html/content/src/nsHTMLFormElement.h +++ b/content/html/content/src/nsHTMLFormElement.h @@ -44,7 +44,6 @@ #include "nsFormSubmission.h" #include "nsGenericHTMLElement.h" #include "nsIDOMHTMLFormElement.h" -#include "nsIDOMNSHTMLFormElement.h" #include "nsIWebProgressListener.h" #include "nsIRadioGroupContainer.h" #include "nsIURI.h" @@ -93,7 +92,6 @@ private: class nsHTMLFormElement : public nsGenericHTMLElement, public nsIDOMHTMLFormElement, - public nsIDOMNSHTMLFormElement, public nsIWebProgressListener, public nsIForm, public nsIRadioGroupContainer_MOZILLA_2_0_BRANCH @@ -119,9 +117,6 @@ public: // nsIDOMHTMLFormElement NS_DECL_NSIDOMHTMLFORMELEMENT - // nsIDOMNSHTMLFormElement - NS_DECL_NSIDOMNSHTMLFORMELEMENT - // nsIWebProgressListener NS_DECL_NSIWEBPROGRESSLISTENER diff --git a/content/html/content/src/nsHTMLHRElement.cpp b/content/html/content/src/nsHTMLHRElement.cpp index 951c411bd09..6e0bcdf8a3a 100644 --- a/content/html/content/src/nsHTMLHRElement.cpp +++ b/content/html/content/src/nsHTMLHRElement.cpp @@ -34,10 +34,11 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -#include "nsIDOMHTMLHRElement.h" -#include "nsIDOMNSHTMLHRElement.h" -#include "nsIDOMEventTarget.h" + #include "nsGenericHTMLElement.h" +#include "nsIDOMHTMLHRElement.h" + +#include "nsIDOMEventTarget.h" #include "nsGkAtoms.h" #include "nsStyleConsts.h" #include "nsPresContext.h" @@ -46,8 +47,7 @@ #include "nsCSSProps.h" class nsHTMLHRElement : public nsGenericHTMLElement, - public nsIDOMHTMLHRElement, - public nsIDOMNSHTMLHRElement + public nsIDOMHTMLHRElement { public: nsHTMLHRElement(already_AddRefed aNodeInfo); @@ -68,9 +68,6 @@ public: // nsIDOMHTMLHRElement NS_DECL_NSIDOMHTMLHRELEMENT - // nsIDOMNSHTMLHRElement - NS_DECL_NSIDOMNSHTMLHRELEMENT - virtual PRBool ParseAttribute(PRInt32 aNamespaceID, nsIAtom* aAttribute, const nsAString& aValue, @@ -103,9 +100,8 @@ DOMCI_NODE_DATA(HTMLHRElement, nsHTMLHRElement) // QueryInterface implementation for nsHTMLHRElement NS_INTERFACE_TABLE_HEAD(nsHTMLHRElement) - NS_HTML_CONTENT_INTERFACE_TABLE2(nsHTMLHRElement, - nsIDOMHTMLHRElement, - nsIDOMNSHTMLHRElement) + NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLHRElement, + nsIDOMHTMLHRElement) NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLHRElement, nsGenericHTMLElement) NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLHRElement) diff --git a/content/html/content/src/nsHTMLIFrameElement.cpp b/content/html/content/src/nsHTMLIFrameElement.cpp index 11f395a2572..4c7c700b838 100644 --- a/content/html/content/src/nsHTMLIFrameElement.cpp +++ b/content/html/content/src/nsHTMLIFrameElement.cpp @@ -37,10 +37,8 @@ #include "nsIDOMHTMLIFrameElement.h" #include "nsGenericHTMLElement.h" #include "nsIDOMDocument.h" -#ifdef MOZ_SVG #include "nsIDOMGetSVGDocument.h" #include "nsIDOMSVGDocument.h" -#endif #include "nsGkAtoms.h" #include "nsIDocument.h" #include "nsMappedAttributes.h" @@ -52,9 +50,7 @@ using namespace mozilla::dom; class nsHTMLIFrameElement : public nsGenericHTMLFrameElement , public nsIDOMHTMLIFrameElement -#ifdef MOZ_SVG , public nsIDOMGetSVGDocument -#endif { public: nsHTMLIFrameElement(already_AddRefed aNodeInfo, @@ -76,10 +72,8 @@ public: // nsIDOMHTMLIFrameElement NS_DECL_NSIDOMHTMLIFRAMEELEMENT -#ifdef MOZ_SVG // nsIDOMGetSVGDocument NS_DECL_NSIDOMGETSVGDOCUMENT -#endif // nsIContent virtual PRBool ParseAttribute(PRInt32 aNamespaceID, @@ -117,9 +111,7 @@ DOMCI_NODE_DATA(HTMLIFrameElement, nsHTMLIFrameElement) NS_INTERFACE_TABLE_HEAD(nsHTMLIFrameElement) NS_HTML_CONTENT_INTERFACE_TABLE_BEGIN(nsHTMLIFrameElement) NS_INTERFACE_TABLE_ENTRY(nsHTMLIFrameElement, nsIDOMHTMLIFrameElement) -#ifdef MOZ_SVG NS_INTERFACE_TABLE_ENTRY(nsHTMLIFrameElement, nsIDOMGetSVGDocument) -#endif NS_OFFSET_AND_INTERFACE_TABLE_END NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLIFrameElement, nsGenericHTMLFrameElement) @@ -146,13 +138,11 @@ nsHTMLIFrameElement::GetContentDocument(nsIDOMDocument** aContentDocument) return nsGenericHTMLFrameElement::GetContentDocument(aContentDocument); } -#ifdef MOZ_SVG NS_IMETHODIMP nsHTMLIFrameElement::GetSVGDocument(nsIDOMDocument **aResult) { return GetContentDocument(aResult); } -#endif PRBool nsHTMLIFrameElement::ParseAttribute(PRInt32 aNamespaceID, diff --git a/content/html/content/src/nsHTMLImageElement.cpp b/content/html/content/src/nsHTMLImageElement.cpp index 841f3b0e983..b7b77fa3e4b 100644 --- a/content/html/content/src/nsHTMLImageElement.cpp +++ b/content/html/content/src/nsHTMLImageElement.cpp @@ -70,12 +70,13 @@ #include "nsRuleData.h" #include "nsIJSContextStack.h" -#include "nsImageMapUtils.h" #include "nsIDOMHTMLMapElement.h" #include "nsEventDispatcher.h" #include "nsLayoutUtils.h" +#include "mozilla/Preferences.h" +using namespace mozilla; using namespace mozilla::dom; // XXX nav attrs: suppress @@ -150,7 +151,6 @@ public: void MaybeLoadImage(); virtual nsXPCClassInfo* GetClassInfo(); protected: - nsPoint GetXY(); nsSize GetWidthHeight(); }; @@ -250,42 +250,6 @@ nsHTMLImageElement::GetComplete(PRBool* aComplete) return NS_OK; } -nsPoint -nsHTMLImageElement::GetXY() -{ - nsPoint point(0, 0); - - nsIFrame* frame = GetPrimaryFrame(Flush_Layout); - - if (!frame) { - return point; - } - - nsIFrame* layer = nsLayoutUtils::GetClosestLayer(frame->GetParent()); - nsPoint origin(frame->GetOffsetTo(layer)); - // Convert to pixels using that scale - point.x = nsPresContext::AppUnitsToIntCSSPixels(origin.x); - point.y = nsPresContext::AppUnitsToIntCSSPixels(origin.y); - - return point; -} - -NS_IMETHODIMP -nsHTMLImageElement::GetX(PRInt32* aX) -{ - *aX = GetXY().x; - - return NS_OK; -} - -NS_IMETHODIMP -nsHTMLImageElement::GetY(PRInt32* aY) -{ - *aY = GetXY().y; - - return NS_OK; -} - nsSize nsHTMLImageElement::GetWidthHeight() { @@ -456,9 +420,7 @@ nsHTMLImageElement::IsHTMLFocusable(PRBool aWithMouse, // XXXbz which document should this be using? sXBL/XBL2 issue! I // think that GetOwnerDoc() is right, since we don't want to // assume stuff about the document we're bound to. - nsCOMPtr imageMap = - nsImageMapUtils::FindImageMap(GetOwnerDoc(), usemap); - if (imageMap) { + if (GetOwnerDoc() && GetOwnerDoc()->FindImageMap(usemap)) { if (aTabIndex) { // Use tab index on individual map areas *aTabIndex = (sTabFocusModel & eTabFocus_linksMask)? 0 : -1; @@ -500,7 +462,7 @@ nsHTMLImageElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, // If caller is not chrome and dom.disable_image_src_set is true, // prevent setting image.src by exiting early - if (nsContentUtils::GetBoolPref("dom.disable_image_src_set") && + if (Preferences::GetBool("dom.disable_image_src_set") && !nsContentUtils::IsCallerChrome()) { return NS_OK; } diff --git a/content/html/content/src/nsHTMLLabelElement.cpp b/content/html/content/src/nsHTMLLabelElement.cpp index b626925d8b7..99379545110 100644 --- a/content/html/content/src/nsHTMLLabelElement.cpp +++ b/content/html/content/src/nsHTMLLabelElement.cpp @@ -34,11 +34,14 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + +/** + * Implementation of HTML