diff --git a/mozilla/content/base/public/nsContentPolicyUtils.h b/mozilla/content/base/public/nsContentPolicyUtils.h index 3ef2c78ec07..ec557ba5528 100644 --- a/mozilla/content/base/public/nsContentPolicyUtils.h +++ b/mozilla/content/base/public/nsContentPolicyUtils.h @@ -33,7 +33,7 @@ class nsIDOMElement; -#define NS_CONTENTPOLICY_PROGID "layout.content-policy.1" +#define NS_CONTENTPOLICY_CONTRACTID "@mozilla.org/layout/content-policy;1" #define NS_CONTENTPOLICY_CATEGORY "content-policy" #define NS_CONTENTPOLICY_CID \ {0x0e3afd3d, 0xeb60, 0x4c2b, \ @@ -43,7 +43,7 @@ class nsIDOMElement; #define CHECK_CONTENT_POLICY(action, result) \ PR_BEGIN_MACRO \ nsresult rv; \ - NS_WITH_SERVICE(nsIContentPolicy, policy, NS_CONTENTPOLICY_PROGID, &rv); \ + NS_WITH_SERVICE(nsIContentPolicy, policy, NS_CONTENTPOLICY_CONTRACTID, &rv); \ if (NS_FAILED(rv)) \ return rv; \ \ diff --git a/mozilla/content/base/public/nsIContentSerializer.h b/mozilla/content/base/public/nsIContentSerializer.h index 1568e92c0a8..7e3a968b164 100644 --- a/mozilla/content/base/public/nsIContentSerializer.h +++ b/mozilla/content/base/public/nsIContentSerializer.h @@ -74,7 +74,7 @@ class nsIContentSerializer : public nsISupports { NS_IMETHOD Flush(nsAWritableString& aStr) = 0; }; -#define NS_CONTENTSERIALIZER_PROGID_PREFIX \ -"component://netscape/layout/contentserializer?mimetype=" +#define NS_CONTENTSERIALIZER_CONTRACTID_PREFIX \ +"@mozilla.org/layout/contentserializer;1?mimetype=" #endif /* __gen_nsIContentSerializer_h__ */ diff --git a/mozilla/content/base/public/nsIDocument.h b/mozilla/content/base/public/nsIDocument.h index 94c446f6de4..7763cf76ad0 100644 --- a/mozilla/content/base/public/nsIDocument.h +++ b/mozilla/content/base/public/nsIDocument.h @@ -54,7 +54,7 @@ class nsINameSpaceManager; class nsIDOMDocumentFragment; class nsILineBreaker; class nsIWordBreaker; -class nsIDOMSelection; +class nsISelection; class nsIChannel; class nsIPrincipal; class nsINodeInfoManager; @@ -306,14 +306,14 @@ public: * NOTE: we may way to place the result in a stream, * but we will use a string for now -- gpk */ - NS_IMETHOD CreateXIF(nsAWritableString & aBuffer, nsIDOMSelection* aSelection = nsnull) = 0; + NS_IMETHOD CreateXIF(nsAWritableString & aBuffer, nsISelection* aSelection = nsnull) = 0; NS_IMETHOD ToXIF(nsIXIFConverter * aConverter, nsIDOMNode* aNode) = 0; virtual void BeginConvertToXIF(nsIXIFConverter * aConverter, nsIDOMNode* aNode) = 0; virtual void ConvertChildrenToXIF(nsIXIFConverter * aConverter, nsIDOMNode* aNode) = 0; virtual void FinishConvertToXIF(nsIXIFConverter * aConverter, nsIDOMNode* aNode) = 0; /* Helper methods to help determine the logical positioning of content */ - virtual PRBool IsInSelection(nsIDOMSelection* aSelection, const nsIContent *aContent) const = 0; + virtual PRBool IsInSelection(nsISelection* aSelection, const nsIContent *aContent) const = 0; virtual nsIContent* GetPrevContent(const nsIContent *aContent) const = 0; virtual nsIContent* GetNextContent(const nsIContent *aContent) const = 0; diff --git a/mozilla/content/base/public/nsIDocumentEncoder.h b/mozilla/content/base/public/nsIDocumentEncoder.h index 49432d95f39..826a98837da 100644 --- a/mozilla/content/base/public/nsIDocumentEncoder.h +++ b/mozilla/content/base/public/nsIDocumentEncoder.h @@ -28,8 +28,8 @@ class nsIDocumentEncoder; class nsIDocument; -class nsIDOMSelection; class nsIDOMRange; +class nsISelection; class nsIOutputStream; class nsISupportsArray; @@ -50,8 +50,7 @@ class nsISupportsArray; {0x83, 0x0f, 0x00, 0x10, 0x4b, 0xed, 0x04, 0x5e} \ } -#define NS_DOC_ENCODER_PROGID_BASE \ - "component://netscape/layout/documentEncoder?type=" +#define NS_DOC_ENCODER_CONTRACTID_BASE "@mozilla.org/layout/documentEncoder;1?type=" class nsIDocumentEncoder : public nsISupports { @@ -122,7 +121,7 @@ public: * selection is used for encoding, otherwise the entire * document is encoded. */ - NS_IMETHOD SetSelection(nsIDOMSelection* aSelection) = 0; + NS_IMETHOD SetSelection(nsISelection* aSelection) = 0; /** * If the range is set to a non-null value, then the diff --git a/mozilla/content/base/public/nsIDocumentViewer.h b/mozilla/content/base/public/nsIDocumentViewer.h index 2587c200256..6a1cd1b2adb 100644 --- a/mozilla/content/base/public/nsIDocumentViewer.h +++ b/mozilla/content/base/public/nsIDocumentViewer.h @@ -28,9 +28,7 @@ class nsIDocument; class nsIPresContext; class nsIPresShell; class nsIStyleSheet; -#ifdef MOZ_XSL class nsITransformMediator; -#endif #define NS_IDOCUMENT_VIEWER_IID \ { 0xa6cf9057, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}} @@ -55,9 +53,7 @@ public: NS_IMETHOD CreateDocumentViewerUsing(nsIPresContext* aPresContext, nsIDocumentViewer*& aResult) = 0; -#ifdef MOZ_XSL NS_IMETHOD SetTransformMediator(nsITransformMediator* aMediator)=0; -#endif }; #endif /* nsIDocumentViewer_h___ */ diff --git a/mozilla/content/base/public/nsIElementFactory.h b/mozilla/content/base/public/nsIElementFactory.h index 840dad93b31..207f0eea046 100644 --- a/mozilla/content/base/public/nsIElementFactory.h +++ b/mozilla/content/base/public/nsIElementFactory.h @@ -42,14 +42,14 @@ public: nsIContent** aResult) = 0; }; -// ProgIDs for element factory registration -#define NS_ELEMENT_FACTORY_PROGID "component://netscape/layout/element-factory" -#define NS_ELEMENT_FACTORY_PROGID_PREFIX NS_ELEMENT_FACTORY_PROGID "?namespace=" +// ContractIDs for element factory registration +#define NS_ELEMENT_FACTORY_CONTRACTID "@mozilla.org/layout/element-factory;1" +#define NS_ELEMENT_FACTORY_CONTRACTID_PREFIX NS_ELEMENT_FACTORY_CONTRACTID "?namespace=" #define NS_HTML_NAMESPACE "http://www.w3.org/1999/xhtml" #define NS_XML_NAMESPACE "http://www.w3.org/XML/1998/namespace" -#define NS_HTML_ELEMENT_FACTORY_PROGID NS_ELEMENT_FACTORY_PROGID_PREFIX NS_HTML_NAMESPACE -#define NS_XML_ELEMENT_FACTORY_PROGID NS_ELEMENT_FACTORY_PROGID_PREFIX NS_XML_NAMESPACE +#define NS_HTML_ELEMENT_FACTORY_CONTRACTID NS_ELEMENT_FACTORY_CONTRACTID_PREFIX NS_HTML_NAMESPACE +#define NS_XML_ELEMENT_FACTORY_CONTRACTID NS_ELEMENT_FACTORY_CONTRACTID_PREFIX NS_XML_NAMESPACE #endif /* nsIElementFactory_h___ */ diff --git a/mozilla/content/base/public/nsIHTMLToTextSink.h b/mozilla/content/base/public/nsIHTMLToTextSink.h index f8609d7727f..3db28e5b8f2 100644 --- a/mozilla/content/base/public/nsIHTMLToTextSink.h +++ b/mozilla/content/base/public/nsIHTMLToTextSink.h @@ -26,7 +26,7 @@ #include "nsISupports.h" #include "nsAWritableString.h" -#define NS_PLAINTEXTSINK_PROGID "component://netscape/layout/plaintextsink" +#define NS_PLAINTEXTSINK_CONTRACTID "@mozilla.org/layout/plaintextsink;1" /* starting interface: nsIContentSerializer */ #define NS_IHTMLTOTEXTSINK_IID_STR "b12b5643-07cb-401e-aabb-64b2dcd2717f" diff --git a/mozilla/content/base/public/nsINodeInfo.h b/mozilla/content/base/public/nsINodeInfo.h index 276985143fb..e56d1a47d53 100644 --- a/mozilla/content/base/public/nsINodeInfo.h +++ b/mozilla/content/base/public/nsINodeInfo.h @@ -60,7 +60,7 @@ class nsString; { 0xb622469b, 0x4dcf, 0x45c4, \ {0xb0, 0xb9, 0xa7, 0x32, 0xbc, 0xee, 0xa5, 0xcc} } -#define NS_NODEINFOMANAGER_PROGID "component://netscape/layout/nodeinfomanager" +#define NS_NODEINFOMANAGER_CONTRACTID "@mozilla.org/layout/nodeinfomanager;1" class nsINodeInfo : public nsISupports diff --git a/mozilla/content/base/public/nsISelectionController.idl b/mozilla/content/base/public/nsISelectionController.idl index ef2d91998e1..158933213a8 100644 --- a/mozilla/content/base/public/nsISelectionController.idl +++ b/mozilla/content/base/public/nsISelectionController.idl @@ -24,11 +24,11 @@ #include "nsISupports.idl" #include "domstubs.idl" - +#include "nsISelection.idl" %{C++ -class nsIDOMSelection; +class nsISelection; typedef short SelectionType; typedef short SelectionRegion; class nsIDOMNode; @@ -86,7 +86,7 @@ interface nsISelectionController : nsISupports * @param aType will hold the type of selection //SelectionType * @param _return will hold the return value */ - nsIDOMSelection getSelection(in short type); + nsISelection getSelection(in short type); /** * ScrollSelectionIntoView scrolls a region of the selection, diff --git a/mozilla/content/base/src/nsCommentNode.cpp b/mozilla/content/base/src/nsCommentNode.cpp index 043d9c19500..36efb66b165 100644 --- a/mozilla/content/base/src/nsCommentNode.cpp +++ b/mozilla/content/base/src/nsCommentNode.cpp @@ -26,7 +26,8 @@ #include "nsIContent.h" #include "nsFrame.h" #include "nsLayoutAtoms.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" +#include "nsISelectionPrivate.h" #include "nsIXIFConverter.h" #include "nsIDocument.h" #include "nsIEnumerator.h" @@ -403,7 +404,7 @@ nsresult nsCommentNode::ConvertContentToXIF(nsIXIFConverter* aConverter) const { const nsIContent* content = this; - nsCOMPtr sel; + nsCOMPtr sel; aConverter->GetSelection(getter_AddRefs(sel)); nsIDocument* document; nsresult res; @@ -423,7 +424,8 @@ nsCommentNode::ConvertContentToXIF(nsIXIFConverter* aConverter) const if (sel != nsnull && document->IsInSelection(sel,content)) { nsIEnumerator *enumerator; - if (NS_SUCCEEDED(sel->GetEnumerator(&enumerator))) { + nsCOMPtr selPrivate(do_QueryInterface(sel)); + if (NS_SUCCEEDED(selPrivate->GetEnumerator(&enumerator))) { for (enumerator->First();NS_OK != enumerator->IsDone(); enumerator->Next()) { nsIDOMRange* range = nsnull; if (NS_SUCCEEDED(enumerator->CurrentItem((nsISupports**)&range))) { diff --git a/mozilla/content/base/src/nsContentPolicy.cpp b/mozilla/content/base/src/nsContentPolicy.cpp index ab64bae17d0..0e129563294 100644 --- a/mozilla/content/base/src/nsContentPolicy.cpp +++ b/mozilla/content/base/src/nsContentPolicy.cpp @@ -48,7 +48,7 @@ nsContentPolicy::nsContentPolicy() { NS_INIT_REFCNT(); nsresult rv; - NS_WITH_SERVICE(nsICategoryManager, catman, NS_CATEGORYMANAGER_PROGID, &rv); + NS_WITH_SERVICE(nsICategoryManager, catman, NS_CATEGORYMANAGER_CONTRACTID, &rv); if (NS_FAILED(rv)) /* log an error? */ return; @@ -72,7 +72,7 @@ nsContentPolicy::nsContentPolicy() } /* - * Populate mPolicies with policy services named by progids in the + * Populate mPolicies with policy services named by contractids in the * "content-policy" category. */ nsCOMPtr item; @@ -81,12 +81,12 @@ nsContentPolicy::nsContentPolicy() if (NS_FAILED(rv)) continue; - nsXPIDLCString progid; - if (NS_FAILED(string->GetData(getter_Copies(progid)))) + nsXPIDLCString contractid; + if (NS_FAILED(string->GetData(getter_Copies(contractid)))) continue; #ifdef DEBUG_shaver - fprintf(stderr, "POLICY: loading %s\n", (const char *)progid); + fprintf(stderr, "POLICY: loading %s\n", (const char *)contractid); #endif /* * Create this policy service and add to mPolicies. @@ -94,7 +94,7 @@ nsContentPolicy::nsContentPolicy() * Should we try to parse as a CID, in case the component prefers to be * registered that way? */ - nsCOMPtr policy = do_GetService(progid, &rv); + nsCOMPtr policy = do_GetService(contractid, &rv); if (NS_SUCCEEDED(rv)) mPolicies->AppendElement(policy); } diff --git a/mozilla/content/base/src/nsDOMAttribute.cpp b/mozilla/content/base/src/nsDOMAttribute.cpp index d48d00c7c7f..4829cda18e7 100644 --- a/mozilla/content/base/src/nsDOMAttribute.cpp +++ b/mozilla/content/base/src/nsDOMAttribute.cpp @@ -310,6 +310,16 @@ nsDOMAttribute::HasChildNodes(PRBool* aHasChildNodes) return NS_OK; } +NS_IMETHODIMP +nsDOMAttribute::HasAttributes(PRBool* aHasAttributes) +{ + NS_ENSURE_ARG_POINTER(aHasAttributes); + + *aHasAttributes = PR_FALSE; + + return NS_OK; +} + NS_IMETHODIMP nsDOMAttribute::GetFirstChild(nsIDOMNode** aFirstChild) { @@ -510,10 +520,11 @@ nsDOMAttribute::Normalize() } NS_IMETHODIMP -nsDOMAttribute::Supports(const nsAReadableString& aFeature, const nsAReadableString& aVersion, - PRBool* aReturn) +nsDOMAttribute::IsSupported(const nsAReadableString& aFeature, + const nsAReadableString& aVersion, + PRBool* aReturn) { - return nsGenericElement::InternalSupports(aFeature, aVersion, aReturn); + return nsGenericElement::InternalIsSupported(aFeature, aVersion, aReturn); } diff --git a/mozilla/content/base/src/nsDocument.cpp b/mozilla/content/base/src/nsDocument.cpp index 1215f8cbc70..bb08ff330ad 100644 --- a/mozilla/content/base/src/nsDocument.cpp +++ b/mozilla/content/base/src/nsDocument.cpp @@ -87,7 +87,7 @@ #include "nsLayoutAtoms.h" #include "nsLayoutCID.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIDOMRange.h" #include "nsIEnumerator.h" #include "nsDOMError.h" @@ -421,7 +421,7 @@ nsDOMImplementation::HasFeature(const nsAReadableString& aFeature, const nsAReadableString& aVersion, PRBool* aReturn) { - return nsGenericElement::InternalSupports(aFeature, aVersion, aReturn); + return nsGenericElement::InternalIsSupported(aFeature, aVersion, aReturn); } NS_IMETHODIMP @@ -1010,7 +1010,7 @@ nsDocument::GetPrincipal(nsIPrincipal **aPrincipal) if (!mPrincipal) { nsresult rv; NS_WITH_SERVICE(nsIScriptSecurityManager, securityManager, - NS_SCRIPTSECURITYMANAGER_PROGID, &rv); + NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv); if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv = securityManager->GetCodebasePrincipal(mDocumentURL, @@ -1082,8 +1082,8 @@ NS_IMETHODIMP nsDocument::SetDocumentCharacterSet(const nsAReadableString& aChar PRInt32 n = mCharSetObservers.Count(); for (PRInt32 i = 0; i < n; i++) { nsIObserver* observer = (nsIObserver*) mCharSetObservers.ElementAt(i); - observer->Observe((nsIDocument*) this, NS_LITERAL_STRING("charset"), - nsPromiseFlatString(aCharSetID)); + observer->Observe((nsIDocument*) this, NS_LITERAL_STRING("charset").get(), + nsPromiseFlatString(aCharSetID).get()); } } return NS_OK; @@ -2385,7 +2385,7 @@ nsDocument::GetAnonymousNodes(nsIDOMElement* aElement, nsIDOMNodeList** aResult) *aResult = nsnull; // Use the XBL service to get a content list. - NS_WITH_SERVICE(nsIXBLService, xblService, "component://netscape/xbl", &rv); + NS_WITH_SERVICE(nsIXBLService, xblService, "@mozilla.org/xbl;1", &rv); if (!xblService) return rv; @@ -2593,6 +2593,16 @@ nsDocument::HasChildNodes(PRBool* aHasChildNodes) return NS_OK; } +NS_IMETHODIMP +nsDocument::HasAttributes(PRBool* aHasAttributes) +{ + NS_ENSURE_ARG(aHasAttributes); + + *aHasAttributes = PR_FALSE; + + return NS_OK; +} + NS_IMETHODIMP nsDocument::GetFirstChild(nsIDOMNode** aFirstChild) { @@ -2968,10 +2978,11 @@ nsDocument::Normalize() } NS_IMETHODIMP -nsDocument::Supports(const nsAReadableString& aFeature, const nsAReadableString& aVersion, - PRBool* aReturn) +nsDocument::IsSupported(const nsAReadableString& aFeature, + const nsAReadableString& aVersion, + PRBool* aReturn) { - return nsGenericElement::InternalSupports(aFeature, aVersion, aReturn); + return nsGenericElement::InternalIsSupported(aFeature, aVersion, aReturn); } NS_IMETHODIMP @@ -3344,7 +3355,7 @@ NS_IMETHODIMP nsDocument::ToXIF(nsIXIFConverter* aConverter, nsIDOMNode* aNode) { nsresult result=NS_OK; - nsCOMPtr sel; + nsCOMPtr sel; aConverter->GetSelection(getter_AddRefs(sel)); if (sel) { @@ -3376,7 +3387,7 @@ nsDocument::ToXIF(nsIXIFConverter* aConverter, nsIDOMNode* aNode) } NS_IMETHODIMP -nsDocument::CreateXIF(nsAWritableString & aBuffer, nsIDOMSelection* aSelection) +nsDocument::CreateXIF(nsAWritableString & aBuffer, nsISelection* aSelection) { nsresult result=NS_OK; @@ -3584,19 +3595,19 @@ nsDocument::SaveFile(nsFileSpec* aFileSpec, // Get a document encoder instance: nsCOMPtr encoder; - char* progid = (char *)nsMemory::Alloc(strlen(NS_DOC_ENCODER_PROGID_BASE) + char* contractid = (char *)nsMemory::Alloc(strlen(NS_DOC_ENCODER_CONTRACTID_BASE) + aFormatType.Length() + 1); - if (! progid) + if (! contractid) return NS_ERROR_OUT_OF_MEMORY; - strcpy(progid, NS_DOC_ENCODER_PROGID_BASE); + strcpy(contractid, NS_DOC_ENCODER_CONTRACTID_BASE); char* type = aFormatType.ToNewCString(); - strcat(progid, type); + strcat(contractid, type); nsCRT::free(type); - rv = nsComponentManager::CreateInstance(progid, + rv = nsComponentManager::CreateInstance(contractid, nsnull, NS_GET_IID(nsIDocumentEncoder), getter_AddRefs(encoder)); - nsCRT::free(progid); + nsCRT::free(contractid); if (NS_FAILED(rv)) return rv; @@ -3674,7 +3685,7 @@ nsDocument::GetBindingManager(nsIBindingManager** aResult) { nsresult rv; if (!mBindingManager) { - mBindingManager = do_CreateInstance("component://netscape/xbl/binding-manager", &rv); + mBindingManager = do_CreateInstance("@mozilla.org/xbl/binding-manager;1", &rv); if (NS_FAILED(rv)) return NS_ERROR_FAILURE; } @@ -3766,7 +3777,7 @@ nsIContent* nsDocument::FindContent(const nsIContent* aStartNode, * @return PR_TRUE if the content is found within the selection */ PRBool -nsDocument::IsInSelection(nsIDOMSelection* aSelection, const nsIContent* aContent) const +nsDocument::IsInSelection(nsISelection* aSelection, const nsIContent* aContent) const { PRBool aYes = PR_FALSE; nsCOMPtr node (do_QueryInterface((nsIContent *) aContent)); diff --git a/mozilla/content/base/src/nsDocument.h b/mozilla/content/base/src/nsDocument.h index fda087a204f..e50e6f5efaa 100644 --- a/mozilla/content/base/src/nsDocument.h +++ b/mozilla/content/base/src/nsDocument.h @@ -358,7 +358,7 @@ public: * document to XIF (XML Interchange Format) * and places the result in aBuffer. */ - NS_IMETHOD CreateXIF(nsAWritableString & aBuffer, nsIDOMSelection* aSelection); + NS_IMETHOD CreateXIF(nsAWritableString & aBuffer, nsISelection* aSelection); NS_IMETHOD ToXIF(nsIXIFConverter * aConverter, nsIDOMNode* aNode); virtual void BeginConvertToXIF(nsIXIFConverter * aConverter, nsIDOMNode* aNode); virtual void ConvertChildrenToXIF(nsIXIFConverter * aConverter, nsIDOMNode* aNode); @@ -448,7 +448,7 @@ public: nsEventStatus* aEventStatus); - virtual PRBool IsInSelection(nsIDOMSelection* aSelection, const nsIContent *aContent) const; + virtual PRBool IsInSelection(nsISelection* aSelection, const nsIContent *aContent) const; virtual nsIContent* GetPrevContent(const nsIContent *aContent) const; virtual nsIContent* GetNextContent(const nsIContent *aContent) const; diff --git a/mozilla/content/base/src/nsDocumentEncoder.cpp b/mozilla/content/base/src/nsDocumentEncoder.cpp index b54a0f16d9d..cca92884e43 100644 --- a/mozilla/content/base/src/nsDocumentEncoder.cpp +++ b/mozilla/content/base/src/nsDocumentEncoder.cpp @@ -29,7 +29,7 @@ #include "nsIComponentManager.h" #include "nsIServiceManager.h" #include "nsIDocument.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIPresShell.h" #include "nsParserCIID.h" #include "nsIParser.h" @@ -73,7 +73,7 @@ public: NS_DECL_ISUPPORTS // Inherited methods from nsIDocumentEncoder - NS_IMETHOD SetSelection(nsIDOMSelection* aSelection); + NS_IMETHOD SetSelection(nsISelection* aSelection); NS_IMETHOD SetRange(nsIDOMRange* aRange); NS_IMETHOD SetWrapColumn(PRUint32 aWC); NS_IMETHOD SetCharset(const nsAReadableString& aCharset); @@ -106,7 +106,7 @@ protected: static PRBool IncludeInContext_HTML(nsIDOMNode *aNode); nsCOMPtr mDocument; - nsCOMPtr mSelection; + nsCOMPtr mSelection; nsCOMPtr mRange; nsCOMPtr mStream; nsCOMPtr mSerializer; @@ -200,7 +200,7 @@ nsDocumentEncoder::SetWrapColumn(PRUint32 aWC) } NS_IMETHODIMP -nsDocumentEncoder::SetSelection(nsIDOMSelection* aSelection) +nsDocumentEncoder::SetSelection(nsISelection* aSelection) { mSelection = aSelection; return NS_OK; @@ -680,14 +680,6 @@ nsDocumentEncoder::SerializeRangeToString(nsIDOMRange *aRange, PRInt32 i = startAncestors.Count(); - nsVoidArray commonAncestors; - commonAncestors = startAncestors; - - nsresult rv = NS_OK; - - rv = SerializeRangeContextStart(commonAncestors, aOutputString); - NS_ENSURE_SUCCESS(rv, rv); - while (i--) { nsIDOMNode *node = NS_STATIC_CAST(nsIDOMNode *, startAncestors.ElementAt(i)); @@ -697,6 +689,14 @@ nsDocumentEncoder::SerializeRangeToString(nsIDOMRange *aRange, break; } + nsVoidArray commonAncestors; + nsRange::FillArrayWithAncestors(&commonAncestors, commonParent); + + nsresult rv = NS_OK; + + rv = SerializeRangeContextStart(commonAncestors, aOutputString); + NS_ENSURE_SUCCESS(rv, rv); + rv = SerializeRangeNodes(startAncestors, commonParent, start, startOffset, end, endOffset, aOutputString); NS_ENSURE_SUCCESS(rv, rv); @@ -720,7 +720,7 @@ nsDocumentEncoder::EncodeToString(nsAWritableString& aOutputString) // xxx Also make sure mString is a mime type "text/html" or "text/plain" - nsCAutoString progId(NS_CONTENTSERIALIZER_PROGID_PREFIX); + nsCAutoString progId(NS_CONTENTSERIALIZER_CONTRACTID_PREFIX); progId.AppendWithConversion(mMimeType); mSerializer = do_CreateInstance(NS_STATIC_CAST(const char *, progId)); diff --git a/mozilla/content/base/src/nsDocumentFragment.cpp b/mozilla/content/base/src/nsDocumentFragment.cpp index a45a1535527..ad3923d36ff 100644 --- a/mozilla/content/base/src/nsDocumentFragment.cpp +++ b/mozilla/content/base/src/nsDocumentFragment.cpp @@ -89,14 +89,17 @@ public: { return mInner.AppendChild(aNewChild, aReturn); } NS_IMETHOD HasChildNodes(PRBool* aReturn) { return mInner.HasChildNodes(aReturn); } + NS_IMETHOD HasAttributes(PRBool* aReturn) + { return mInner.HasAttributes(aReturn); } NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn); NS_IMETHOD GetPrefix(nsAWritableString& aPrefix); NS_IMETHOD SetPrefix(const nsAReadableString& aPrefix); NS_IMETHOD GetNamespaceURI(nsAWritableString& aNamespaceURI); NS_IMETHOD GetLocalName(nsAWritableString& aLocalName); NS_IMETHOD Normalize(); - NS_IMETHOD Supports(const nsAReadableString& aFeature, const nsAReadableString& aVersion, - PRBool* aReturn); + NS_IMETHOD IsSupported(const nsAReadableString& aFeature, + const nsAReadableString& aVersion, + PRBool* aReturn); // interface nsIScriptObjectOwner NS_IMETHOD GetScriptObject(nsIScriptContext* aContext, void** aScriptObject); @@ -428,10 +431,11 @@ nsDocumentFragment::Normalize() NS_IMETHODIMP -nsDocumentFragment::Supports(const nsAReadableString& aFeature, const nsAReadableString& aVersion, - PRBool* aReturn) +nsDocumentFragment::IsSupported(const nsAReadableString& aFeature, + const nsAReadableString& aVersion, + PRBool* aReturn) { - return nsGenericElement::InternalSupports(aFeature, aVersion, aReturn); + return nsGenericElement::InternalIsSupported(aFeature, aVersion, aReturn); } NS_IMETHODIMP diff --git a/mozilla/content/base/src/nsDocumentViewer.cpp b/mozilla/content/base/src/nsDocumentViewer.cpp index 478ec12ffef..2fdc26272c9 100644 --- a/mozilla/content/base/src/nsDocumentViewer.cpp +++ b/mozilla/content/base/src/nsDocumentViewer.cpp @@ -45,7 +45,8 @@ #include "nsIScriptGlobalObject.h" #include "nsILinkHandler.h" #include "nsIDOMDocument.h" -#include "nsIDOMSelectionListener.h" +#include "nsISelectionListener.h" +#include "nsISelectionPrivate.h" #include "nsIDOMHTMLDocument.h" #include "nsIDOMHTMLElement.h" #include "nsIDOMRange.h" @@ -85,9 +86,7 @@ #include "nsIDOMFocusListener.h" #include "nsISelectionController.h" -#ifdef MOZ_XSL #include "nsITransformMediator.h" -#endif static NS_DEFINE_CID(kEventQueueService, NS_EVENTQUEUESERVICE_CID); @@ -106,16 +105,15 @@ class DocumentViewerImpl; #pragma mark ** nsDocViwerSelectionListener ** #endif -class nsDocViwerSelectionListener : public nsIDOMSelectionListener +class nsDocViwerSelectionListener : public nsISelectionListener { public: // nsISupports interface... NS_DECL_ISUPPORTS - // nsIDOMSelectionListerner interface - NS_DECL_IDOMSELECTIONLISTENER - + // nsISelectionListerner interface + NS_DECL_NSISELECTIONLISTENER nsDocViwerSelectionListener() : mDocViewer(NULL) @@ -215,9 +213,7 @@ public: NS_IMETHOD GetPresContext(nsIPresContext*& aResult); NS_IMETHOD CreateDocumentViewerUsing(nsIPresContext* aPresContext, nsIDocumentViewer*& aResult); -#ifdef MOZ_XSL NS_IMETHOD SetTransformMediator(nsITransformMediator* aMediator); -#endif // nsIContentViewerEdit NS_DECL_NSICONTENTVIEWEREDIT @@ -245,7 +241,7 @@ private: nsresult MakeWindow(nsIWidget* aParentWidget, const nsRect& aBounds); - nsresult GetDocumentSelection(nsIDOMSelection **aSelection); + nsresult GetDocumentSelection(nsISelection **aSelection); // // The following three methods are used for printing... @@ -266,11 +262,9 @@ protected: nsCOMPtr mDeviceContext; // ??? can't hurt, but... nsIView* mView; // [WEAK] cleaned up by view mgr - // the following six items are explicitly in this order + // the following seven items are explicitly in this order // so they will be destroyed in the reverse order (pinkerton, scc) -#ifdef MOZ_XSL nsCOMPtr mTransformMediator; -#endif nsCOMPtr mDocument; nsCOMPtr mWindow; // ??? should we really own it? nsCOMPtr mViewManager; @@ -279,7 +273,7 @@ protected: nsCOMPtr mUAStyleSheet; - nsCOMPtr mSelectionListener; + nsCOMPtr mSelectionListener; nsCOMPtr mFocusListener; PRBool mEnableRendering; @@ -436,12 +430,13 @@ DocumentViewerImpl::~DocumentViewerImpl() if (mPresShell) { // Break circular reference (or something) mPresShell->EndObservingDocument(); - nsCOMPtr selection; + nsCOMPtr selection; rv = GetDocumentSelection(getter_AddRefs(selection)); - if (NS_FAILED(rv) || !selection) + nsCOMPtr selPrivate(do_QueryInterface(selection)); + if (NS_FAILED(rv) || !selPrivate) return; if (mSelectionListener) - selection->RemoveSelectionListener(mSelectionListener); + selPrivate->RemoveSelectionListener(mSelectionListener); } } @@ -592,15 +587,16 @@ DocumentViewerImpl::Init(nsIWidget* aParentWidget, // this is the owning reference. The nsCOMPtr will take care of releasing // our ref to the listener on destruction. NS_ADDREF(selectionListener); - rv = selectionListener->QueryInterface(NS_GET_IID(nsIDOMSelectionListener), getter_AddRefs(mSelectionListener)); + rv = selectionListener->QueryInterface(NS_GET_IID(nsISelectionListener), getter_AddRefs(mSelectionListener)); NS_RELEASE(selectionListener); if (NS_FAILED(rv)) return rv; - nsCOMPtr selection; + nsCOMPtr selection; rv = GetDocumentSelection(getter_AddRefs(selection)); if (NS_FAILED(rv)) return rv; - rv = selection->AddSelectionListener(mSelectionListener); + nsCOMPtr selPrivate(do_QueryInterface(selection)); + rv = selPrivate->AddSelectionListener(mSelectionListener); if (NS_FAILED(rv)) return rv; //focus listener @@ -1087,7 +1083,7 @@ DocumentViewerImpl::CreateStyleSet(nsIDocument* aDocument, } } - NS_WITH_SERVICE(nsIChromeRegistry, chromeRegistry, "component://netscape/chrome/chrome-registry", &rv); + NS_WITH_SERVICE(nsIChromeRegistry, chromeRegistry, "@mozilla.org/chrome/chrome-registry;1", &rv); if (NS_SUCCEEDED(rv) && chromeRegistry) { nsCOMPtr sheets; chromeRegistry->GetBackstopSheets(getter_AddRefs(sheets)); @@ -1194,7 +1190,7 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget, return rv; } -nsresult DocumentViewerImpl::GetDocumentSelection(nsIDOMSelection **aSelection) +nsresult DocumentViewerImpl::GetDocumentSelection(nsISelection **aSelection) { if (!aSelection) return NS_ERROR_NULL_POINTER; if (!mPresShell) return NS_ERROR_NOT_INITIALIZED; @@ -1296,7 +1292,6 @@ void DocumentViewerImpl::DocumentReadyForPrinting() } } -#ifdef MOZ_XSL NS_IMETHODIMP DocumentViewerImpl::SetTransformMediator(nsITransformMediator* aMediator) { @@ -1305,7 +1300,6 @@ DocumentViewerImpl::SetTransformMediator(nsITransformMediator* aMediator) mTransformMediator = aMediator; return NS_OK; } -#endif #ifdef XP_MAC #pragma mark - @@ -1338,7 +1332,7 @@ NS_IMETHODIMP DocumentViewerImpl::SelectAll() // XXX this is a temporary implementation copied from nsWebShell // for now. I think nsDocument and friends should have some helper // functions to make this easier. - nsCOMPtr selection; + nsCOMPtr selection; nsresult rv; rv = GetDocumentSelection(getter_AddRefs(selection)); if (NS_FAILED(rv)) return rv; @@ -1361,7 +1355,7 @@ NS_IMETHODIMP DocumentViewerImpl::SelectAll() } if (!bodyNode) return NS_ERROR_FAILURE; - rv = selection->ClearSelection(); + rv = selection->RemoveAllRanges(); if (NS_FAILED(rv)) return rv; static NS_DEFINE_CID(kCDOMRangeCID, NS_RANGE_CID); @@ -1385,7 +1379,7 @@ NS_IMETHODIMP DocumentViewerImpl::CopySelection() NS_IMETHODIMP DocumentViewerImpl::GetCopyable(PRBool *aCopyable) { - nsCOMPtr selection; + nsCOMPtr selection; nsresult rv; rv = GetDocumentSelection(getter_AddRefs(selection)); if (NS_FAILED(rv)) return rv; @@ -1763,7 +1757,7 @@ NS_IMETHODIMP DocumentViewerImpl::GetDefaultCharacterSet(PRUnichar** aDefaultCha webShell = do_QueryInterface(mContainer); if (webShell) { - nsCOMPtr prefs(do_GetService(NS_PREF_PROGID)); + nsCOMPtr prefs(do_GetService(NS_PREF_CONTRACTID)); if(prefs) prefs->GetLocalizedUnicharPref("intl.charset.default", &gDefCharset); } @@ -1922,7 +1916,7 @@ NS_IMETHODIMP DocumentViewerImpl::SizeToContent() #pragma mark - #endif -NS_IMPL_ISUPPORTS(nsDocViwerSelectionListener, NS_GET_IID(nsIDOMSelectionListener)); +NS_IMPL_ISUPPORTS(nsDocViwerSelectionListener, NS_GET_IID(nsISelectionListener)); nsresult nsDocViwerSelectionListener::Init(DocumentViewerImpl *aDocViewer) { @@ -1931,12 +1925,12 @@ nsresult nsDocViwerSelectionListener::Init(DocumentViewerImpl *aDocViewer) } -NS_IMETHODIMP nsDocViwerSelectionListener::NotifySelectionChanged(nsIDOMDocument *, nsIDOMSelection *, short) +NS_IMETHODIMP nsDocViwerSelectionListener::NotifySelectionChanged(nsIDOMDocument *, nsISelection *, short) { NS_ASSERTION(mDocViewer, "Should have doc viewer!"); // get the selection state - nsCOMPtr selection; + nsCOMPtr selection; nsresult rv = mDocViewer->GetDocumentSelection(getter_AddRefs(selection)); if (NS_FAILED(rv)) return rv; diff --git a/mozilla/content/base/src/nsGenericDOMDataNode.cpp b/mozilla/content/base/src/nsGenericDOMDataNode.cpp index 24930c61606..c4af63ba33d 100644 --- a/mozilla/content/base/src/nsGenericDOMDataNode.cpp +++ b/mozilla/content/base/src/nsGenericDOMDataNode.cpp @@ -30,7 +30,8 @@ #include "nsIXIFConverter.h" #include "nsRange.h" #include "nsTextContentChangeData.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" +#include "nsISelectionPrivate.h" #include "nsIEnumerator.h" #include "nsReadableUtils.h" @@ -231,11 +232,11 @@ nsGenericDOMDataNode::Normalize() } nsresult -nsGenericDOMDataNode::Supports(const nsAReadableString& aFeature, - const nsAReadableString& aVersion, - PRBool* aReturn) +nsGenericDOMDataNode::IsSupported(const nsAReadableString& aFeature, + const nsAReadableString& aVersion, + PRBool* aReturn) { - return nsGenericElement::InternalSupports(aFeature, aVersion, aReturn); + return nsGenericElement::InternalIsSupported(aFeature, aVersion, aReturn); } #if 0 @@ -321,7 +322,7 @@ nsGenericDOMDataNode::SubstringData(PRUint32 aStart, aReturn.Assign(mText.Get2b() + aStart, amount); } else { - aReturn.Assign(NS_ConvertASCIItoUCS2(mText.Get1b() + aStart, amount), amount); + aReturn.Assign(NS_ConvertASCIItoUCS2(mText.Get1b() + aStart, amount).get(), amount); } return NS_OK; @@ -558,13 +559,14 @@ nsGenericDOMDataNode::ConvertContentToXIF(const nsIContent *aOuterContent, nsIXIFConverter* aConverter) const { const nsIContent* content = aOuterContent; - nsCOMPtr sel; + nsCOMPtr sel; aConverter->GetSelection(getter_AddRefs(sel)); if (sel && mDocument && mDocument->IsInSelection(sel,content)) { nsCOMPtr enumerator; - if (NS_SUCCEEDED(sel->GetEnumerator(getter_AddRefs(enumerator)))) { + nsCOMPtr selPrivate(do_QueryInterface(sel)); + if (NS_SUCCEEDED(selPrivate->GetEnumerator(getter_AddRefs(enumerator)))) { for (enumerator->First();NS_OK != enumerator->IsDone(); enumerator->Next()) { nsIDOMRange* range = nsnull; if (NS_SUCCEEDED(enumerator->CurrentItem((nsISupports**)&range))) { @@ -999,7 +1001,7 @@ nsGenericDOMDataNode::CopyText(nsAWritableString& aResult) aResult.Assign(mText.Get2b(), mText.GetLength()); } else { - aResult.Assign(NS_ConvertASCIItoUCS2(mText.Get1b(), mText.GetLength()), + aResult.Assign(NS_ConvertASCIItoUCS2(mText.Get1b(), mText.GetLength()).get(), mText.GetLength()); } return NS_OK; diff --git a/mozilla/content/base/src/nsGenericDOMDataNode.h b/mozilla/content/base/src/nsGenericDOMDataNode.h index 44c3b143895..6c9b298cedf 100644 --- a/mozilla/content/base/src/nsGenericDOMDataNode.h +++ b/mozilla/content/base/src/nsGenericDOMDataNode.h @@ -69,6 +69,11 @@ struct nsGenericDOMDataNode { *aHasChildNodes = PR_FALSE; return NS_OK; } + nsresult HasAttributes(PRBool* aHasAttributes) { + NS_ENSURE_ARG_POINTER(aHasAttributes); + *aHasAttributes = PR_FALSE; + return NS_OK; + } nsresult GetFirstChild(nsIDOMNode** aFirstChild) { NS_ENSURE_ARG_POINTER(aFirstChild); *aFirstChild = nsnull; @@ -116,8 +121,9 @@ struct nsGenericDOMDataNode { nsresult GetPrefix(nsAWritableString& aPrefix); nsresult SetPrefix(const nsAReadableString& aPrefix); nsresult Normalize(); - nsresult Supports(const nsAReadableString& aFeature, const nsAReadableString& aVersion, - PRBool* aReturn); + nsresult IsSupported(const nsAReadableString& aFeature, + const nsAReadableString& aVersion, + PRBool* aReturn); // Implementation for nsIDOMCharacterData nsresult GetData(nsAWritableString& aData); @@ -285,14 +291,14 @@ struct nsGenericDOMDataNode { * NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn); */ #define NS_IMPL_IDOMNODE_USING_GENERIC_DOM_DATA(_g) \ - NS_IMETHOD GetNodeName(nsAWritableString& aNodeName); \ - NS_IMETHOD GetLocalName(nsAWritableString& aLocalName) { \ + NS_IMETHOD GetNodeName(nsAWritableString& aNodeName); \ + NS_IMETHOD GetLocalName(nsAWritableString& aLocalName) { \ return GetNodeName(aLocalName); \ } \ - NS_IMETHOD GetNodeValue(nsAWritableString& aNodeValue) { \ + NS_IMETHOD GetNodeValue(nsAWritableString& aNodeValue) { \ return _g.GetNodeValue(aNodeValue); \ } \ - NS_IMETHOD SetNodeValue(const nsAReadableString& aNodeValue) { \ + NS_IMETHOD SetNodeValue(const nsAReadableString& aNodeValue) { \ return _g.SetNodeValue(this, aNodeValue); \ } \ NS_IMETHOD GetNodeType(PRUint16* aNodeType); \ @@ -305,6 +311,9 @@ struct nsGenericDOMDataNode { NS_IMETHOD HasChildNodes(PRBool* aHasChildNodes) { \ return _g.HasChildNodes(aHasChildNodes); \ } \ + NS_IMETHOD HasAttributes(PRBool* aHasAttributes) { \ + return _g.HasAttributes(aHasAttributes); \ + } \ NS_IMETHOD GetFirstChild(nsIDOMNode** aFirstChild) { \ return _g.GetFirstChild(aFirstChild); \ } \ @@ -337,29 +346,30 @@ struct nsGenericDOMDataNode { NS_IMETHOD GetOwnerDocument(nsIDOMDocument** aOwnerDocument) { \ return _g.GetOwnerDocument(aOwnerDocument); \ } \ - NS_IMETHOD GetNamespaceURI(nsAWritableString& aNamespaceURI) { \ + NS_IMETHOD GetNamespaceURI(nsAWritableString& aNamespaceURI) { \ return _g.GetNamespaceURI(aNamespaceURI); \ } \ - NS_IMETHOD GetPrefix(nsAWritableString& aPrefix) { \ + NS_IMETHOD GetPrefix(nsAWritableString& aPrefix) { \ return _g.GetPrefix(aPrefix); \ } \ - NS_IMETHOD SetPrefix(const nsAReadableString& aPrefix) { \ + NS_IMETHOD SetPrefix(const nsAReadableString& aPrefix) { \ return _g.SetPrefix(aPrefix); \ } \ NS_IMETHOD Normalize() { \ return NS_OK; \ } \ - NS_IMETHOD Supports(const nsAReadableString& aFeature, const nsAReadableString& aVersion,\ + NS_IMETHOD IsSupported(const nsAReadableString& aFeature, \ + const nsAReadableString& aVersion, \ PRBool* aReturn) { \ - return _g.Supports(aFeature, aVersion, aReturn); \ + return _g.IsSupported(aFeature, aVersion, aReturn); \ } \ NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn); -#define NS_IMPL_IDOMCHARACTERDATA_USING_GENERIC_DOM_DATA(_g) \ - NS_IMETHOD GetData(nsAWritableString& aData) { \ +#define NS_IMPL_IDOMCHARACTERDATA_USING_GENERIC_DOM_DATA(_g) \ + NS_IMETHOD GetData(nsAWritableString& aData) { \ return _g.GetData(aData); \ } \ - NS_IMETHOD SetData(const nsAReadableString& aData) { \ + NS_IMETHOD SetData(const nsAReadableString& aData) { \ return _g.SetData(this, aData); \ } \ NS_IMETHOD GetLength(PRUint32* aLength) { \ @@ -368,10 +378,10 @@ struct nsGenericDOMDataNode { NS_IMETHOD SubstringData(PRUint32 aStart, PRUint32 aEnd, nsAWritableString& aReturn) { \ return _g.SubstringData(aStart, aEnd, aReturn); \ } \ - NS_IMETHOD AppendData(const nsAReadableString& aData) { \ + NS_IMETHOD AppendData(const nsAReadableString& aData) { \ return _g.AppendData(this, aData); \ } \ - NS_IMETHOD InsertData(PRUint32 aOffset, const nsAReadableString& aData) { \ + NS_IMETHOD InsertData(PRUint32 aOffset, const nsAReadableString& aData) { \ return _g.InsertData(this, aOffset, aData); \ } \ NS_IMETHOD DeleteData(PRUint32 aOffset, PRUint32 aCount) { \ diff --git a/mozilla/content/base/src/nsGenericElement.cpp b/mozilla/content/base/src/nsGenericElement.cpp index 1f95ae812d1..2212afaf283 100644 --- a/mozilla/content/base/src/nsGenericElement.cpp +++ b/mozilla/content/base/src/nsGenericElement.cpp @@ -632,9 +632,9 @@ nsGenericElement::SetPrefix(const nsAReadableString& aPrefix) } nsresult -nsGenericElement::InternalSupports(const nsAReadableString& aFeature, - const nsAReadableString& aVersion, - PRBool* aReturn) +nsGenericElement::InternalIsSupported(const nsAReadableString& aFeature, + const nsAReadableString& aVersion, + PRBool* aReturn) { NS_ENSURE_ARG_POINTER(aReturn); *aReturn = PR_FALSE; @@ -665,10 +665,24 @@ nsGenericElement::InternalSupports(const nsAReadableString& aFeature, } nsresult -nsGenericElement::Supports(const nsAReadableString& aFeature, const nsAReadableString& aVersion, - PRBool* aReturn) +nsGenericElement::IsSupported(const nsAReadableString& aFeature, + const nsAReadableString& aVersion, + PRBool* aReturn) { - return InternalSupports(aFeature, aVersion, aReturn); + return InternalIsSupported(aFeature, aVersion, aReturn); +} + +nsresult +nsGenericElement::HasAttributes(PRBool* aReturn) +{ + NS_ENSURE_ARG_POINTER(aReturn); + PRInt32 attrCount = 0; + + mContent->GetAttributeCount(attrCount); + + *aReturn = !!attrCount; + + return NS_OK; } nsresult @@ -840,7 +854,7 @@ nsGenericElement::GetElementsByTagName(const nsAReadableString& aTagname, return NS_ERROR_OUT_OF_MEMORY; } - return list->QueryInterface(NS_GET_IID(nsIDOMNode), (void **)aReturn); + return list->QueryInterface(NS_GET_IID(nsIDOMNodeList), (void **)aReturn); } nsresult @@ -1702,7 +1716,7 @@ nsGenericElement::GetScriptObject(nsIScriptContext* aContext, // We have a binding that must be installed. nsresult rv; PRBool dummy; - NS_WITH_SERVICE(nsIXBLService, xblService, "component://netscape/xbl", &rv); + NS_WITH_SERVICE(nsIXBLService, xblService, "@mozilla.org/xbl;1", &rv); xblService->LoadBindings(mContent, value, PR_FALSE, getter_AddRefs(binding), &dummy); if (binding) { binding->ExecuteAttachedHandler(); @@ -2420,7 +2434,7 @@ nsGenericElement::TriggerLink(nsIPresContext* aPresContext, nsresult proceed = NS_OK; // Check that this page is allowed to load this URI. NS_WITH_SERVICE(nsIScriptSecurityManager, securityManager, - NS_SCRIPTSECURITYMANAGER_PROGID, &rv); + NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv); nsCOMPtr absURI; if (NS_SUCCEEDED(rv)) rv = NS_NewURI(getter_AddRefs(absURI), absURLSpec, aBaseURL); @@ -2457,7 +2471,7 @@ nsGenericElement::AddScriptEventListener(nsIAtom* aAttribute, if (!context) { // Get JSContext from stack. - nsCOMPtr stack(do_GetService("nsThreadJSContextStack")); + nsCOMPtr stack(do_GetService("@mozilla.org/js/xpc/ContextStack;1")); NS_ENSURE_TRUE(stack, NS_ERROR_FAILURE); NS_ENSURE_SUCCESS(stack->Peek(&cx), NS_ERROR_FAILURE); diff --git a/mozilla/content/base/src/nsGenericElement.h b/mozilla/content/base/src/nsGenericElement.h index b91b04d9914..a1f784e5f56 100644 --- a/mozilla/content/base/src/nsGenericElement.h +++ b/mozilla/content/base/src/nsGenericElement.h @@ -139,8 +139,9 @@ public: nsresult GetPrefix(nsAWritableString& aPrefix); nsresult SetPrefix(const nsAReadableString& aPrefix); nsresult Normalize(); - nsresult Supports(const nsAReadableString& aFeature, - const nsAReadableString& aVersion, PRBool* aReturn); + nsresult IsSupported(const nsAReadableString& aFeature, + const nsAReadableString& aVersion, PRBool* aReturn); + nsresult HasAttributes(PRBool* aHasAttributes); // Implementation for nsIDOMElement nsresult GetTagName(nsAWritableString& aTagName); @@ -269,8 +270,9 @@ public: static nsIAtom* CutNameSpacePrefix(nsString& aString); - static nsresult InternalSupports(const nsAReadableString& aFeature, - const nsAReadableString& aVersion, PRBool* aReturn); + static nsresult InternalIsSupported(const nsAReadableString& aFeature, + const nsAReadableString& aVersion, + PRBool* aReturn); nsDOMSlots *GetDOMSlots(); void MaybeClearDOMSlots(); @@ -384,13 +386,13 @@ public: * NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn); */ #define NS_IMPL_IDOMNODE_USING_GENERIC(_g) \ - NS_IMETHOD GetNodeName(nsAWritableString& aNodeName) { \ + NS_IMETHOD GetNodeName(nsAWritableString& aNodeName) { \ return _g.GetNodeName(aNodeName); \ } \ - NS_IMETHOD GetNodeValue(nsAWritableString& aNodeValue) { \ + NS_IMETHOD GetNodeValue(nsAWritableString& aNodeValue) { \ return _g.GetNodeValue(aNodeValue); \ } \ - NS_IMETHOD SetNodeValue(const nsAReadableString& aNodeValue) { \ + NS_IMETHOD SetNodeValue(const nsAReadableString& aNodeValue) { \ return _g.SetNodeValue(aNodeValue); \ } \ NS_IMETHOD GetNodeType(PRUint16* aNodeType) { \ @@ -405,6 +407,9 @@ public: NS_IMETHOD HasChildNodes(PRBool* aHasChildNodes) { \ return _g.HasChildNodes(aHasChildNodes); \ } \ + NS_IMETHOD HasAttributes(PRBool* aHasAttributes) { \ + return _g.HasAttributes(aHasAttributes); \ + } \ NS_IMETHOD GetFirstChild(nsIDOMNode** aFirstChild) { \ return _g.GetFirstChild(aFirstChild); \ } \ @@ -420,16 +425,16 @@ public: NS_IMETHOD GetAttributes(nsIDOMNamedNodeMap** aAttributes) { \ return _g.GetAttributes(aAttributes); \ } \ - NS_IMETHOD GetNamespaceURI(nsAWritableString& aNamespaceURI) { \ + NS_IMETHOD GetNamespaceURI(nsAWritableString& aNamespaceURI) { \ return _g.GetNamespaceURI(aNamespaceURI); \ } \ - NS_IMETHOD GetPrefix(nsAWritableString& aPrefix) { \ + NS_IMETHOD GetPrefix(nsAWritableString& aPrefix) { \ return _g.GetPrefix(aPrefix); \ } \ - NS_IMETHOD SetPrefix(const nsAReadableString& aPrefix) { \ + NS_IMETHOD SetPrefix(const nsAReadableString& aPrefix) { \ return _g.SetPrefix(aPrefix); \ } \ - NS_IMETHOD GetLocalName(nsAWritableString& aLocalName) { \ + NS_IMETHOD GetLocalName(nsAWritableString& aLocalName) { \ return _g.GetLocalName(aLocalName); \ } \ NS_IMETHOD InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, \ @@ -453,9 +458,9 @@ public: NS_IMETHOD Normalize() { \ return _g.Normalize(); \ } \ - NS_IMETHOD Supports(const nsAReadableString& aFeature, \ - const nsAReadableString& aVersion, PRBool* aReturn) { \ - return _g.Supports(aFeature, aVersion, aReturn); \ + NS_IMETHOD IsSupported(const nsAReadableString& aFeature, \ + const nsAReadableString& aVersion, PRBool* aReturn) { \ + return _g.IsSupported(aFeature, aVersion, aReturn); \ } /** @@ -464,7 +469,7 @@ public: * nsGenericHTMLContainerContent) */ #define NS_IMPL_IDOMELEMENT_USING_GENERIC(_g) \ - NS_IMETHOD GetTagName(nsAWritableString& aTagName) { \ + NS_IMETHOD GetTagName(nsAWritableString& aTagName) { \ return _g.GetTagName(aTagName); \ } \ NS_IMETHOD GetAttribute(const nsAReadableString& aName, nsAWritableString& aReturn) { \ @@ -473,10 +478,10 @@ public: NS_IMETHOD SetAttribute(const nsAReadableString& aName, const nsAReadableString& aValue) { \ return _g.SetAttribute(aName, aValue); \ } \ - NS_IMETHOD RemoveAttribute(const nsAReadableString& aName) { \ + NS_IMETHOD RemoveAttribute(const nsAReadableString& aName) { \ return _g.RemoveAttribute(aName); \ } \ - NS_IMETHOD GetAttributeNode(const nsAReadableString& aName, \ + NS_IMETHOD GetAttributeNode(const nsAReadableString& aName, \ nsIDOMAttr** aReturn) { \ return _g.GetAttributeNode(aName, aReturn); \ } \ @@ -486,40 +491,40 @@ public: NS_IMETHOD RemoveAttributeNode(nsIDOMAttr* aOldAttr, nsIDOMAttr** aReturn) {\ return _g.RemoveAttributeNode(aOldAttr, aReturn); \ } \ - NS_IMETHOD GetElementsByTagName(const nsAReadableString& aTagname, \ + NS_IMETHOD GetElementsByTagName(const nsAReadableString& aTagname, \ nsIDOMNodeList** aReturn) { \ return _g.GetElementsByTagName(aTagname, aReturn); \ } \ - NS_IMETHOD GetAttributeNS(const nsAReadableString& aNamespaceURI, \ + NS_IMETHOD GetAttributeNS(const nsAReadableString& aNamespaceURI, \ const nsAReadableString& aLocalName, nsAWritableString& aReturn) { \ return _g.GetAttributeNS(aNamespaceURI, aLocalName, aReturn); \ } \ - NS_IMETHOD SetAttributeNS(const nsAReadableString& aNamespaceURI, \ - const nsAReadableString& aQualifiedName, \ - const nsAReadableString& aValue) { \ + NS_IMETHOD SetAttributeNS(const nsAReadableString& aNamespaceURI, \ + const nsAReadableString& aQualifiedName, \ + const nsAReadableString& aValue) { \ return _g.SetAttributeNS(aNamespaceURI, aQualifiedName, aValue); \ } \ - NS_IMETHOD RemoveAttributeNS(const nsAReadableString& aNamespaceURI, \ - const nsAReadableString& aLocalName) { \ + NS_IMETHOD RemoveAttributeNS(const nsAReadableString& aNamespaceURI, \ + const nsAReadableString& aLocalName) { \ return _g.RemoveAttributeNS(aNamespaceURI, aLocalName); \ } \ - NS_IMETHOD GetAttributeNodeNS(const nsAReadableString& aNamespaceURI, \ - const nsAReadableString& aLocalName, \ + NS_IMETHOD GetAttributeNodeNS(const nsAReadableString& aNamespaceURI, \ + const nsAReadableString& aLocalName, \ nsIDOMAttr** aReturn) { \ return _g.GetAttributeNodeNS(aNamespaceURI, aLocalName, aReturn); \ } \ NS_IMETHOD SetAttributeNodeNS(nsIDOMAttr* aNewAttr, nsIDOMAttr** aReturn) { \ return _g.SetAttributeNodeNS(aNewAttr, aReturn); \ } \ - NS_IMETHOD GetElementsByTagNameNS(const nsAReadableString& aNamespaceURI, \ - const nsAReadableString& aLocalName, \ + NS_IMETHOD GetElementsByTagNameNS(const nsAReadableString& aNamespaceURI, \ + const nsAReadableString& aLocalName, \ nsIDOMNodeList** aReturn) { \ return _g.GetElementsByTagNameNS(aNamespaceURI, aLocalName, aReturn); \ } \ - NS_IMETHOD HasAttribute(const nsAReadableString& aName, PRBool* aReturn) { \ + NS_IMETHOD HasAttribute(const nsAReadableString& aName, PRBool* aReturn) { \ return _g.HasAttribute(aName, aReturn); \ } \ - NS_IMETHOD HasAttributeNS(const nsAReadableString& aNamespaceURI, \ + NS_IMETHOD HasAttributeNS(const nsAReadableString& aNamespaceURI, \ const nsAReadableString& aLocalName, PRBool* aReturn) { \ return _g.HasAttributeNS(aNamespaceURI, aLocalName, aReturn); \ } diff --git a/mozilla/content/base/src/nsNodeInfo.cpp b/mozilla/content/base/src/nsNodeInfo.cpp index f607b86310d..bae5d9c904d 100644 --- a/mozilla/content/base/src/nsNodeInfo.cpp +++ b/mozilla/content/base/src/nsNodeInfo.cpp @@ -347,7 +347,8 @@ nsNodeInfo::NamespaceEquals(const nsAReadableString& aNamespaceURI) NS_IMETHODIMP_(PRBool) nsNodeInfo::QualifiedNameEquals(const nsAReadableString& aQualifiedName) { - const PRUnichar *qname = nsPromiseFlatString(aQualifiedName); + nsPromiseFlatString flatName(aQualifiedName); + const PRUnichar *qname = flatName.get(); PRUint32 i = 0; if (mInner.mPrefix) { diff --git a/mozilla/content/base/src/nsPlainTextSerializer.cpp b/mozilla/content/base/src/nsPlainTextSerializer.cpp index 484a4338d71..7e628353fc6 100644 --- a/mozilla/content/base/src/nsPlainTextSerializer.cpp +++ b/mozilla/content/base/src/nsPlainTextSerializer.cpp @@ -157,7 +157,7 @@ nsPlainTextSerializer::Init(PRUint32 aFlags, PRUint32 aWrapColumn) mLineBreak.AssignWithConversion(NS_LINEBREAK); // Platform/default // Get some prefs - NS_WITH_SERVICE(nsIPref, prefs, NS_PREF_PROGID, &rv); + NS_WITH_SERVICE(nsIPref, prefs, NS_PREF_CONTRACTID, &rv); if (NS_SUCCEEDED(rv) && prefs) { prefs->GetBoolPref(PREF_STRUCTS, &mStructs); diff --git a/mozilla/content/base/src/nsSelection.cpp b/mozilla/content/base/src/nsSelection.cpp index 47aee641859..2aae8271c3d 100644 --- a/mozilla/content/base/src/nsSelection.cpp +++ b/mozilla/content/base/src/nsSelection.cpp @@ -20,7 +20,7 @@ */ /* - * Implementation of selection: nsIDOMSelection and nsIFrameSelection + * Implementation of selection: nsISelection,nsISelectionPrivate and nsIFrameSelection */ #include "nsCOMPtr.h" @@ -29,8 +29,9 @@ #include "nsIEnumerator.h" #include "nsIDOMRange.h" #include "nsIFrameSelection.h" -#include "nsIDOMSelection.h" -#include "nsIDOMSelectionListener.h" +#include "nsISelection.h" +#include "nsISelectionPrivate.h" +#include "nsISelectionListener.h" #include "nsIFocusTracker.h" #include "nsIComponentManager.h" #include "nsLayoutCID.h" @@ -45,7 +46,7 @@ #include "nsIDOMNodeList.h" #include "nsITextContent.h" -#include "nsIDOMSelectionListener.h" +#include "nsISelectionListener.h" #include "nsIContentIterator.h" #include "nsIDocumentEncoder.h" #include "nsIIndependentSelection.h" @@ -58,8 +59,6 @@ #include "nsIPresShell.h" #include "nsICaret.h" -#include "nsIScriptObjectOwner.h" -#include "nsIScriptGlobalObject.h" // included for view scrolling #include "nsIViewManager.h" @@ -113,7 +112,7 @@ class nsSelectionIterator; class nsSelection; class nsAutoScrollTimer; -class nsDOMSelection : public nsIDOMSelection , public nsIScriptObjectOwner, public nsSupportsWeakReference, public nsIIndependentSelection +class nsDOMSelection : public nsISelection , public nsISelectionPrivate, public nsSupportsWeakReference, public nsIIndependentSelection { public: nsDOMSelection(); @@ -124,7 +123,7 @@ public: /*BEGIN nsIIndependentSelection interface implementations */ NS_IMETHOD SetPresShell(nsIPresShell *aPresShell); - /*BEGIN nsIDOMSelection interface implementations*/ + /*BEGIN nsISelection,Private interface implementations*/ NS_IMETHOD GetAnchorNode(nsIDOMNode** aAnchorNode); NS_IMETHOD GetAnchorOffset(PRInt32* aAnchorOffset); NS_IMETHOD GetFocusNode(nsIDOMNode** aFocusNode); @@ -132,10 +131,11 @@ public: NS_IMETHOD GetIsCollapsed(PRBool* aIsCollapsed); NS_IMETHOD GetRangeCount(PRInt32* aRangeCount); NS_IMETHOD GetRangeAt(PRInt32 aIndex, nsIDOMRange** aReturn); - NS_IMETHOD ClearSelection(); + NS_IMETHOD RemoveAllRanges(); NS_IMETHOD Collapse(nsIDOMNode* aParentNode, PRInt32 aOffset); NS_IMETHOD CollapseToStart(); NS_IMETHOD CollapseToEnd(); + NS_IMETHOD SelectAllChildren(nsIDOMNode* parentNode); NS_IMETHOD Extend(nsIDOMNode* aParentNode, PRInt32 aOffset); NS_IMETHOD ContainsNode(nsIDOMNode* aNode, PRBool aRecursive, PRBool* aAYes); NS_IMETHOD DeleteFromDocument(); @@ -145,21 +145,17 @@ public: NS_IMETHOD StartBatchChanges(); NS_IMETHOD EndBatchChanges(); - NS_IMETHOD AddSelectionListener(nsIDOMSelectionListener* aNewListener); - NS_IMETHOD RemoveSelectionListener(nsIDOMSelectionListener* aListenerToRemove); + NS_IMETHOD AddSelectionListener(nsISelectionListener* aNewListener); + NS_IMETHOD RemoveSelectionListener(nsISelectionListener* aListenerToRemove); NS_IMETHOD GetEnumerator(nsIEnumerator **aIterator); - NS_IMETHOD ToString(const nsAReadableString& aFormatType, PRUint32 aFlags, PRInt32 aWrapCount, nsAWritableString& aReturn); + NS_IMETHOD ToString(PRUnichar **_retval); + NS_IMETHOD ToStringWithFormat(const char *aFormatType, PRUint32 aFlags, PRInt32 aWrapCount, PRUnichar ** aReturn); - NS_IMETHOD SetHint(PRBool aHintRight); - NS_IMETHOD GetHint(PRBool *aHintRight); + NS_IMETHOD GetInterlinePosition(PRBool *aInterlinePosition); + NS_IMETHOD SetInterlinePosition(PRBool aInterlinePosition); -/*END nsIDOMSelection interface implementations*/ - -/*BEGIN nsIScriptObjectOwner interface implementations*/ - NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); - NS_IMETHOD SetScriptObject(void *aScriptObject); -/*END nsIScriptObjectOwner interface implementations*/ +/*END nsISelection interface implementations*/ // utility methods for scrolling the selection into view nsresult GetPresContext(nsIPresContext **aPresContext); @@ -258,8 +254,6 @@ private: nsSelection *mFrameSelection; nsWeakPtr mPresShellWeak; //weak reference to presshell. - // for nsIScriptObjectOwner - void* mScriptObject; SelectionType mType;//type of this nsDOMSelection; nsAutoScrollTimer *mAutoScrollTimer; // timer for autoscrolling. nsCOMPtr mSelectionListeners; @@ -269,9 +263,9 @@ private: class nsSelectionBatcher { private: - nsCOMPtr mSelection; + nsCOMPtr mSelection; public: - nsSelectionBatcher(nsIDOMSelection *aSelection) : mSelection(aSelection) + nsSelectionBatcher(nsISelectionPrivate *aSelection) : mSelection(aSelection) { if (mSelection) mSelection->StartBatchChanges(); } @@ -312,7 +306,7 @@ public: NS_IMETHOD ClearTableCellSelection(){mSelectingTableCellMode = 0; return NS_OK;} NS_IMETHOD GetTableCellSelectionStyleColor(const nsStyleColor **aStyleColor); - NS_IMETHOD GetSelection(SelectionType aType, nsIDOMSelection **aDomSelection); + NS_IMETHOD GetSelection(SelectionType aType, nsISelection **aDomSelection); NS_IMETHOD ScrollSelectionIntoView(SelectionType aType, SelectionRegion aRegion); NS_IMETHOD RepaintSelection(nsIPresContext* aPresContext, SelectionType aType); NS_IMETHOD GetFrameForNodeOffset(nsIContent *aNode, PRInt32 aOffset, HINT aHint, nsIFrame **aReturnFrame, PRInt32 *aReturnOffset); @@ -491,7 +485,7 @@ public: if (!mTimer) { nsresult result; - mTimer = do_CreateInstance("component://netscape/timer", &result); + mTimer = do_CreateInstance("@mozilla.org/timer;1", &result); if (NS_FAILED(result)) return result; @@ -597,14 +591,14 @@ nsresult NS_NewSelection(nsIFrameSelection **aFrameSelection) return NS_OK; } -nsresult NS_NewDomSelection(nsIDOMSelection **aDomSelection); +nsresult NS_NewDomSelection(nsISelection **aDomSelection); -nsresult NS_NewDomSelection(nsIDOMSelection **aDomSelection) +nsresult NS_NewDomSelection(nsISelection **aDomSelection) { nsDOMSelection *rlist = new nsDOMSelection; if (!rlist) return NS_ERROR_OUT_OF_MEMORY; - *aDomSelection = (nsIDOMSelection *)rlist; + *aDomSelection = (nsISelection *)rlist; rlist->AddRef(); return NS_OK; } @@ -630,6 +624,8 @@ GetIndexFromSelectionType(SelectionType aType) case nsISelectionController::SELECTION_IME_SELECTEDCONVERTEDTEXT: return 5; break; default:return -1;break; } + /* NOTREACHED */ + return 0; } static SelectionType @@ -646,6 +642,8 @@ GetSelectionTypeFromIndex(PRInt8 aIndex) default: return nsISelectionController::SELECTION_NORMAL;break; } + /* NOTREACHED */ + return 0; } @@ -854,14 +852,14 @@ nsSelection::nsSelection() // Check to see if the autocopy pref is enabled // and add the autocopy listener if it is nsresult rv; - NS_WITH_SERVICE(nsIPref, prefs, "component://netscape/preferences", &rv); + NS_WITH_SERVICE(nsIPref, prefs, "@mozilla.org/preferences;1", &rv); if (NS_SUCCEEDED(rv) && prefs) { static char pref[] = "clipboard.autocopy"; PRBool autoCopy = PR_FALSE; if (NS_SUCCEEDED(prefs->GetBoolPref(pref, &autoCopy)) && autoCopy) { - NS_WITH_SERVICE(nsIAutoCopyService, autoCopyService, "component://netscape/autocopy", &rv); + NS_WITH_SERVICE(nsIAutoCopyService, autoCopyService, "@mozilla.org/autocopy;1", &rv); if (NS_SUCCEEDED(rv) && autoCopyService) { @@ -876,7 +874,7 @@ nsSelection::nsSelection() mDelayCaretOverExistingSelection = PR_TRUE; mDelayedMouseEventValid = PR_FALSE; - mReason = nsIDOMSelectionListener::NO_REASON; + mReason = nsISelectionListener::NO_REASON; } @@ -1449,35 +1447,33 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA InvalidateDesiredX(); pos.mDirection = eDirNext; mHint = HINTLEFT;//stick to this line - PostReason(nsIDOMSelectionListener::KEYPRESS_REASON); + PostReason(nsISelectionListener::KEYPRESS_REASON); break; case nsIDOMKeyEvent::DOM_VK_LEFT : //no break InvalidateDesiredX(); mHint = HINTRIGHT;//stick to opposite of movement - PostReason(nsIDOMSelectionListener::KEYPRESS_REASON); + PostReason(nsISelectionListener::KEYPRESS_REASON); break; case nsIDOMKeyEvent::DOM_VK_DOWN : pos.mAmount = eSelectLine; pos.mDirection = eDirNext;//no break here - PostReason(nsIDOMSelectionListener::KEYPRESS_REASON); + PostReason(nsISelectionListener::KEYPRESS_REASON); break; case nsIDOMKeyEvent::DOM_VK_UP : pos.mAmount = eSelectLine; - PostReason(nsIDOMSelectionListener::KEYPRESS_REASON); + PostReason(nsISelectionListener::KEYPRESS_REASON); break; case nsIDOMKeyEvent::DOM_VK_HOME : InvalidateDesiredX(); pos.mAmount = eSelectBeginLine; - InvalidateDesiredX(); mHint = HINTRIGHT;//stick to opposite of movement - PostReason(nsIDOMSelectionListener::KEYPRESS_REASON); + PostReason(nsISelectionListener::KEYPRESS_REASON); break; case nsIDOMKeyEvent::DOM_VK_END : InvalidateDesiredX(); pos.mAmount = eSelectEndLine; - InvalidateDesiredX(); mHint = HINTLEFT;//stick to this line - PostReason(nsIDOMSelectionListener::KEYPRESS_REASON); + PostReason(nsISelectionListener::KEYPRESS_REASON); break; default :return NS_ERROR_FAILURE; } @@ -1506,7 +1502,7 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA if (NS_SUCCEEDED(result = frame->PeekOffset(context, &pos)) && pos.mResultContent) { mHint = (HINT)pos.mPreferLeft; - PostReason(nsIDOMSelectionListener::MOUSEUP_REASON);//force an update as though we used the mouse. + PostReason(nsISelectionListener::MOUSEUP_REASON);//force an update as though we used the mouse. result = TakeFocus(pos.mResultContent, pos.mContentOffset, pos.mContentOffset, aContinue, PR_FALSE); } } @@ -1566,13 +1562,23 @@ nsSelection::HandleKeyEvent(nsIPresContext* aPresContext, nsGUIEvent *aGuiEvent) //BEGIN nsIFrameSelection methods NS_IMETHODIMP -nsDOMSelection::ToString(const nsAReadableString& aFormatType, PRUint32 aFlags, PRInt32 aWrapCount, nsAWritableString& aReturn) +nsDOMSelection::ToString(PRUnichar **aReturn) +{ + return ToStringWithFormat("text/plain", 0, 0, aReturn); +} + + +NS_IMETHODIMP +nsDOMSelection::ToStringWithFormat(const char * aFormatType, PRUint32 aFlags, + PRInt32 aWrapCol, PRUnichar **aReturn) { nsresult rv = NS_OK; + if (!aReturn) + return NS_ERROR_NULL_POINTER; nsCOMPtr encoder; - nsCAutoString formatType( NS_DOC_ENCODER_PROGID_BASE ); - formatType.AppendWithConversion(aFormatType); + nsCAutoString formatType( NS_DOC_ENCODER_CONTRACTID_BASE ); + formatType.Append(aFormatType); rv = nsComponentManager::CreateInstance(formatType, nsnull, NS_GET_IID(nsIDocumentEncoder), @@ -1591,21 +1597,23 @@ nsDOMSelection::ToString(const nsAReadableString& aFormatType, PRUint32 aFlags, // Flags should always include OutputSelectionOnly if we're coming from here: aFlags |= nsIDocumentEncoder::OutputSelectionOnly; - - rv = encoder->Init(doc, aFormatType, aFlags); + nsAutoString readstring; + readstring.AssignWithConversion(aFormatType); + rv = encoder->Init(doc, readstring, aFlags); NS_ENSURE_SUCCESS(rv, rv); encoder->SetSelection(this); - if (aWrapCount != 0) - encoder->SetWrapColumn(aWrapCount); - - rv = encoder->EncodeToString(aReturn); + if (aWrapCol != 0) + encoder->SetWrapColumn(aWrapCol); + nsAutoString tmp; + rv = encoder->EncodeToString(tmp); + *aReturn = tmp.ToNewUnicode();//get the unicode pointer from it. this is temporary return rv; } NS_IMETHODIMP -nsDOMSelection::SetHint(PRBool aHintRight) +nsDOMSelection::SetInterlinePosition(PRBool aHintRight) { nsIFrameSelection::HINT hint; if (aHintRight) @@ -1616,7 +1624,7 @@ nsDOMSelection::SetHint(PRBool aHintRight) } NS_IMETHODIMP -nsDOMSelection::GetHint(PRBool *aHintRight) +nsDOMSelection::GetInterlinePosition(PRBool *aHintRight) { nsIFrameSelection::HINT hint; nsresult rv = mFrameSelection->GetHint(&hint); @@ -1627,7 +1635,6 @@ nsDOMSelection::GetHint(PRBool *aHintRight) return rv; } - NS_IMETHODIMP nsSelection::HandleClick(nsIContent *aNewFocus, PRUint32 aContentOffset, PRUint32 aContentEndOffset, PRBool aContinueSelection, @@ -1641,7 +1648,7 @@ nsSelection::HandleClick(nsIContent *aNewFocus, PRUint32 aContentOffset, // Don't take focus when dragging off of a table if (!mSelectingTableCells) { - PostReason(nsIDOMSelectionListener::MOUSEDOWN_REASON + nsIDOMSelectionListener::DRAG_REASON); + PostReason(nsISelectionListener::MOUSEDOWN_REASON + nsISelectionListener::DRAG_REASON); return TakeFocus(aNewFocus, aContentOffset, aContentEndOffset, aContinueSelection, aMultipleSelection); } @@ -1837,7 +1844,13 @@ printf("SetMouseDownState to FALSE - stopping cell selection\n"); mSelectingTableCells = PR_FALSE; mStartSelectedCell = nsnull; mEndSelectedCell = nsnull; - PostReason(aState?nsIDOMSelectionListener::MOUSEDOWN_REASON:nsIDOMSelectionListener::MOUSEUP_REASON);//not a drag reason + + short reason; + if (aState) + reason = nsISelectionListener::MOUSEDOWN_REASON; + else + reason = nsISelectionListener::MOUSEUP_REASON; + PostReason(reason);//not a drag reason NotifySelectionListeners(nsISelectionController::SELECTION_NORMAL);//notify that reason is mouse up please. } return NS_OK; @@ -1868,14 +1881,14 @@ nsSelection::GetTableCellSelectionStyleColor(const nsStyleColor **aStyleColor) NS_IMETHODIMP -nsSelection::GetSelection(SelectionType aType, nsIDOMSelection **aDomSelection) +nsSelection::GetSelection(SelectionType aType, nsISelection **aDomSelection) { if (!aDomSelection) return NS_ERROR_NULL_POINTER; PRInt8 index = GetIndexFromSelectionType(aType); if (index < 0) return NS_ERROR_INVALID_ARG; - *aDomSelection = mDomSelections[index]; + *aDomSelection = NS_REINTERPRET_CAST(nsISelection *,mDomSelections[index]); (*aDomSelection)->AddRef(); return NS_OK; } @@ -2095,7 +2108,7 @@ NS_IMETHODIMP nsSelection::SelectAll() } PRInt32 numChildren; rootContent->ChildCount(numChildren); - PostReason(nsIDOMSelectionListener::NO_REASON); + PostReason(nsISelectionListener::NO_REASON); return TakeFocus(mLimiter, 0, numChildren, PR_FALSE, PR_FALSE); } @@ -2198,7 +2211,7 @@ nsresult nsSelection::ClearNormalSelection() { PRInt8 index = GetIndexFromSelectionType(nsISelectionController::SELECTION_NORMAL); - return mDomSelections[index]->ClearSelection(); + return mDomSelections[index]->RemoveAllRanges(); } nsresult @@ -2294,7 +2307,7 @@ printf("HandleTableSelection: Dragged into a new cell\n"); { // Force new selection block mStartSelectedCell = nsnull; - mDomSelections[index]->ClearSelection(); + mDomSelections[index]->RemoveAllRanges(); mSelectingTableCellMode = (startRowIndex == curRowIndex) ? TABLESELECTION_ROW : TABLESELECTION_COLUMN; @@ -2344,7 +2357,7 @@ printf("HandleTableSelection: Mouse down event\n"); else { // No cells selected -- remove non-cell selection - mDomSelections[index]->ClearSelection(); + mDomSelections[index]->RemoveAllRanges(); } mSelectingTableCells = PR_TRUE; // Signal to start drag-cell-selection mSelectingTableCellMode = aTarget; @@ -2368,8 +2381,8 @@ printf("HandleTableSelection: Saving mUnselectCellOnMouseUp\n"); nsCOMPtr previousCellContent = do_QueryInterface(previousCellNode); if (!IsInSameTable(previousCellContent, childContent, nsnull)) { - mDomSelections[index]->ClearSelection(); - // Reset selection mode that is cleared in ClearSelection + mDomSelections[index]->RemoveAllRanges(); + // Reset selection mode that is cleared in RemoveAllRanges mSelectingTableCellMode = aTarget; } @@ -2389,7 +2402,7 @@ printf("HandleTableSelection: Saving mUnselectCellOnMouseUp\n"); mEndSelectedCell = nsnull; // Remove existing selection and select the table - mDomSelections[index]->ClearSelection(); + mDomSelections[index]->RemoveAllRanges(); return CreateAndAddRange(parentNode, aContentOffset); } else if (aTarget == TABLESELECTION_ROW || aTarget == TABLESELECTION_COLUMN) @@ -2401,8 +2414,8 @@ printf("HandleTableSelection: Saving mUnselectCellOnMouseUp\n"); // Force new selection block mStartSelectedCell = nsnull; - mDomSelections[index]->ClearSelection(); - // Always do this AFTER ClearSelection + mDomSelections[index]->RemoveAllRanges(); + // Always do this AFTER RemoveAllRanges mSelectingTableCellMode = aTarget; return SelectRowOrColumn(childContent, aTarget); } @@ -3054,7 +3067,7 @@ nsSelection::GetHint(HINT *aHintRight) #pragma mark - #endif -//BEGIN nsIDOMSelection interface implementations +//BEGIN nsISelection interface implementations @@ -3204,7 +3217,7 @@ nsSelection::GetLimiter(nsIContent **aLimiterContent) } -//END nsIDOMSelection interface implementations +//END nsISelection interface implementations #ifdef XP_MAC #pragma mark - @@ -3225,7 +3238,6 @@ nsDOMSelection::nsDOMSelection(nsSelection *aList) mFixupState = PR_FALSE; mDirection = eDirNext; NS_NewISupportsArray(getter_AddRefs(mRangeArray)); - mScriptObject = nsnull; mAutoScrollTimer = nsnull; NS_NewISupportsArray(getter_AddRefs(mSelectionListeners)); NS_INIT_REFCNT(); @@ -3238,7 +3250,6 @@ nsDOMSelection::nsDOMSelection() mFixupState = PR_FALSE; mDirection = eDirNext; NS_NewISupportsArray(getter_AddRefs(mRangeArray)); - mScriptObject = nsnull; mAutoScrollTimer = nsnull; NS_NewISupportsArray(getter_AddRefs(mSelectionListeners)); NS_INIT_REFCNT(); @@ -3279,7 +3290,7 @@ NS_IMPL_ADDREF(nsDOMSelection) NS_IMPL_RELEASE(nsDOMSelection) -NS_IMPL_QUERY_INTERFACE4(nsDOMSelection, nsIDOMSelection, nsIScriptObjectOwner, nsISupportsWeakReference, nsIIndependentSelection) +NS_IMPL_QUERY_INTERFACE4(nsDOMSelection, nsISelection, nsISelectionPrivate, nsISupportsWeakReference, nsIIndependentSelection) NS_IMETHODIMP @@ -3696,12 +3707,13 @@ nsDOMSelection::selectFrames(nsIPresContext* aPresContext, while (NS_ENUMERATOR_FALSE == aInnerIter->IsDone()) { result = aInnerIter->CurrentNode(getter_AddRefs(innercontent)); - if (NS_FAILED(result) || !innercontent) - continue; - result = mFrameSelection->GetTracker()->GetPrimaryFrameFor(innercontent, &frame); - if (NS_SUCCEEDED(result) && frame) - //NOTE: aRange and eSpreadDown are now IGNORED. Selected state is set only for given frame - frame->SetSelected(aPresContext, aRange,aFlags,eSpreadDown);//spread from here to hit all frames in flow + if (NS_SUCCEEDED(result) && innercontent) + { + result = mFrameSelection->GetTracker()->GetPrimaryFrameFor(innercontent, &frame); + if (NS_SUCCEEDED(result) && frame) + //NOTE: aRange and eSpreadDown are now IGNORED. Selected state is set only for given frame + frame->SetSelected(aPresContext, aRange,aFlags,eSpreadDown);//spread from here to hit all frames in flow + } result = aInnerIter->Next(); if (NS_FAILED(result)) return result; @@ -4514,10 +4526,10 @@ nsDOMSelection::GetEnumerator(nsIEnumerator **aIterator) -/** ClearSelection zeroes the selection +/** RemoveAllRanges zeroes the selection */ NS_IMETHODIMP -nsDOMSelection::ClearSelection() +nsDOMSelection::RemoveAllRanges() { if (!mFrameSelection) return NS_OK;//nothing to do @@ -5520,6 +5532,45 @@ nsDOMSelection::Extend(nsIDOMNode* aParentNode, PRInt32 aOffset) return mFrameSelection->NotifySelectionListeners(GetType()); } +static inline nsresult GetChildOffset(nsIDOMNode *aChild, nsIDOMNode *aParent, PRInt32 &aOffset) +{ + NS_ASSERTION((aChild && aParent), "bad args"); + if (!aChild || !aParent) return NS_ERROR_NULL_POINTER; + nsCOMPtr content = do_QueryInterface(aParent); + nsCOMPtr cChild = do_QueryInterface(aChild); + if (!cChild || !content) return NS_ERROR_NULL_POINTER; + nsresult res = content->IndexOf(cChild, aOffset); + return res; +} + +NS_IMETHODIMP +nsDOMSelection::SelectAllChildren(nsIDOMNode* aParentNode) +{ + NS_ENSURE_ARG_POINTER(aParentNode); + + if (mFrameSelection) + { + mFrameSelection->PostReason(nsISelectionListener::SELECTALL_REASON); + } + nsresult result = Collapse(aParentNode, 0); + if (NS_SUCCEEDED(result)) + { + nsCOMPtrlastChild; + result = aParentNode->GetLastChild(getter_AddRefs(lastChild)); + if ((NS_SUCCEEDED(result)) && lastChild) + { + PRInt32 numBodyChildren=0; + GetChildOffset(lastChild, aParentNode, numBodyChildren); + if (mFrameSelection) + { + mFrameSelection->PostReason(nsISelectionListener::SELECTALL_REASON); + } + result = Extend(aParentNode, numBodyChildren+1); + } + } + return result; +} + NS_IMETHODIMP nsDOMSelection::ContainsNode(nsIDOMNode* aNode, PRBool aRecursive, PRBool* aYes) { @@ -6602,7 +6653,7 @@ nsDOMSelection::ScrollIntoView(SelectionRegion aRegion) NS_IMETHODIMP -nsDOMSelection::AddSelectionListener(nsIDOMSelectionListener* aNewListener) +nsDOMSelection::AddSelectionListener(nsISelectionListener* aNewListener) { if (!mSelectionListeners) return NS_ERROR_FAILURE; @@ -6618,7 +6669,7 @@ nsDOMSelection::AddSelectionListener(nsIDOMSelectionListener* aNewListener) NS_IMETHODIMP -nsDOMSelection::RemoveSelectionListener(nsIDOMSelectionListener* aListenerToRemove) +nsDOMSelection::RemoveSelectionListener(nsISelectionListener* aListenerToRemove) { if (!mSelectionListeners) return NS_ERROR_FAILURE; @@ -6660,7 +6711,7 @@ nsDOMSelection::NotifySelectionListeners() for (PRUint32 i = 0; i < cnt;i++) { nsCOMPtr isupports(dont_AddRef(mSelectionListeners->ElementAt(i))); - nsCOMPtr thisListener = do_QueryInterface(isupports); + nsCOMPtr thisListener = do_QueryInterface(isupports); if (thisListener) thisListener->NotifySelectionChanged(domdoc,this, reason); } @@ -6695,27 +6746,3 @@ nsDOMSelection::DeleteFromDocument() return mFrameSelection->DeleteFromDocument(); } -// BEGIN nsIScriptObjectOwner interface implementations -NS_IMETHODIMP -nsDOMSelection::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject) -{ - nsresult res = NS_OK; - nsIScriptGlobalObject *globalObj = aContext->GetGlobalObject(); - - if (nsnull == mScriptObject) { - res = NS_NewScriptSelection(aContext, (nsISupports *)(nsIDOMSelection *)this, globalObj, (void**)&mScriptObject); - } - *aScriptObject = mScriptObject; - - NS_RELEASE(globalObj); - return res; -} - -NS_IMETHODIMP -nsDOMSelection::SetScriptObject(void *aScriptObject) -{ - mScriptObject = aScriptObject; - return NS_OK; -} - -// END nsIScriptObjectOwner interface implementations diff --git a/mozilla/content/events/src/nsEventListenerManager.cpp b/mozilla/content/events/src/nsEventListenerManager.cpp index d69b78bfdc1..4c981f4b261 100644 --- a/mozilla/content/events/src/nsEventListenerManager.cpp +++ b/mozilla/content/events/src/nsEventListenerManager.cpp @@ -673,7 +673,7 @@ nsresult nsEventListenerManager::RegisterScriptEventListener(nsIScriptContext *a // You'd think it'd work just to get the JSContext from aContext, but that's actually the // JSContext whose private object parents the object in aScriptObjectOwner. nsresult rv; - NS_WITH_SERVICE(nsIJSContextStack, stack, "nsThreadJSContextStack", + NS_WITH_SERVICE(nsIJSContextStack, stack, "@mozilla.org/js/xpc/ContextStack;1", &rv); if (NS_FAILED(rv)) return rv; @@ -684,7 +684,7 @@ nsresult nsEventListenerManager::RegisterScriptEventListener(nsIScriptContext *a if (NS_FAILED(rv = aScriptObjectOwner->GetScriptObject(aContext, (void**)&jsobj))) return rv; NS_WITH_SERVICE(nsIScriptSecurityManager, securityManager, - NS_SCRIPTSECURITYMANAGER_PROGID, &rv); + NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv); if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv = securityManager->CheckScriptAccess(cx, jsobj, @@ -809,6 +809,10 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext, if (aFlags & NS_EVENT_FLAG_INIT) { aFlags |= (NS_EVENT_FLAG_BUBBLE | NS_EVENT_FLAG_CAPTURE); } + //Set the value of the internal PreventDefault flag properly based on aEventStatus + if (*aEventStatus == nsEventStatus_eConsumeNoDefault) { + aEvent->flags |= NS_EVENT_FLAG_NO_DEFAULT; + } /* Without this addref, certain events, notably ones bound to keys which cause window deletion, can destroy this object diff --git a/mozilla/content/events/src/nsEventStateManager.cpp b/mozilla/content/events/src/nsEventStateManager.cpp index dcdbe9e2649..c8259675921 100644 --- a/mozilla/content/events/src/nsEventStateManager.cpp +++ b/mozilla/content/events/src/nsEventStateManager.cpp @@ -47,7 +47,7 @@ #include "nsIWebShell.h" #include "nsIBaseWindow.h" #include "nsIScrollableView.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIFrameSelection.h" #include "nsIDeviceContext.h" #include "nsIScriptGlobalObject.h" @@ -126,6 +126,7 @@ nsEventStateManager::nsEventStateManager() mFirstBlurEvent = nsnull; mFirstFocusEvent = nsnull; mAccessKeys = nsnull; + hHover = PR_FALSE; NS_INIT_REFCNT(); ++mInstanceCount; @@ -138,7 +139,7 @@ nsEventStateManager::Init() { nsresult rv; NS_WITH_SERVICE(nsIObserverService, observerService, - NS_OBSERVERSERVICE_PROGID, &rv); + NS_OBSERVERSERVICE_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) { nsAutoString topic; topic.AssignWithConversion(NS_XPCOM_SHUTDOWN_OBSERVER_ID); @@ -146,6 +147,11 @@ nsEventStateManager::Init() } rv = getPrefService(); + + if (NS_SUCCEEDED(rv)) { + mPrefService->GetBoolPref("nglayout.events.showHierarchicalHover", &hHover); + } + return rv; } @@ -189,7 +195,7 @@ nsEventStateManager::~nsEventStateManager() nsresult rv; NS_WITH_SERVICE (nsIObserverService, observerService, - NS_OBSERVERSERVICE_PROGID, &rv); + NS_OBSERVERSERVICE_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) { nsAutoString topic; topic.AssignWithConversion(NS_XPCOM_SHUTDOWN_OBSERVER_ID); @@ -472,7 +478,13 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext, if (commandDispatcher) { commandDispatcher->SetActive(PR_TRUE); - commandDispatcher->SetSuppressFocus(PR_FALSE); // Unsuppress and let the command dispatcher listen again. + + PRBool isSuppressed; + commandDispatcher->GetSuppressFocus(&isSuppressed); + while(isSuppressed){ + commandDispatcher->SetSuppressFocus(PR_FALSE); // Unsuppress and let the command dispatcher listen again. + commandDispatcher->GetSuppressFocus(&isSuppressed); + } commandDispatcher->SetSuppressFocusScroll(PR_FALSE); } } @@ -584,7 +596,11 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext, nsKeyEvent* keyEvent = (nsKeyEvent*)aEvent; #ifdef XP_MAC - PRBool isSpecialAccessKeyDown = keyEvent->isMeta; + // (pinkerton, joki, saari) IE5 for mac uses Control for access keys. The HTML4 spec + // suggests to use command on mac, but this really sucks (imagine someone having a "q" + // as an access key and not letting you quit the app!). As a result, we've made a + // command decision 1 day before tree lockdown to change it to the control key. + PRBool isSpecialAccessKeyDown = keyEvent->isControl; #else PRBool isSpecialAccessKeyDown = keyEvent->isAlt; #endif @@ -887,6 +903,11 @@ nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext, SetContentState(newFocus, NS_EVENT_STATE_ACTIVE); } + else { + // if we're here, the event handler returned false, so stop + // any of our own processing of a drag. Workaround for bug 43258. + StopTrackingDragGesture(); + } } break; case NS_MOUSE_LEFT_BUTTON_UP: @@ -2311,8 +2332,24 @@ nsEventStateManager::GetContentState(nsIContent *aContent, PRInt32& aState) if (aContent == mActiveContent) { aState |= NS_EVENT_STATE_ACTIVE; } - if (aContent == mHoverContent) { - aState |= NS_EVENT_STATE_HOVER; + if (hHover) { + //If using hierchical hover check the ancestor chain of mHoverContent + //to see if we are on it. + nsCOMPtr parent = mHoverContent; + nsIContent* child; + while (parent) { + if (aContent == parent.get()) { + aState |= NS_EVENT_STATE_HOVER; + break; + } + child = parent; + child->GetParent(*getter_AddRefs(parent)); + } + } + else { + if (aContent == mHoverContent) { + aState |= NS_EVENT_STATE_HOVER; + } } if (aContent == mCurrentFocus) { aState |= NS_EVENT_STATE_FOCUS; @@ -2352,9 +2389,61 @@ nsEventStateManager::SetContentState(nsIContent *aContent, PRInt32 aState) NS_IF_ADDREF(mActiveContent); } + nsCOMPtr newHover = nsnull; + nsCOMPtr oldHover = nsnull; + nsCOMPtr commonHoverParent = nsnull; if ((aState & NS_EVENT_STATE_HOVER) && (aContent != mHoverContent)) { - //transferring ref to notifyContent from mHoverContent - notifyContent[1] = mHoverContent; // notify hover first, since more common case + if (hHover) { + newHover = aContent; + oldHover = mHoverContent; + + //Find closest common parent + nsCOMPtr parent1 = mHoverContent; + nsCOMPtr parent2; + if (mHoverContent && aContent) { + while (parent1) { + parent2 = aContent; + while (parent2) { + if (parent1 == parent2) { + commonHoverParent = parent1; + break; + } + nsIContent* child2 = parent2; + child2->GetParent(*getter_AddRefs(parent2)); + } + if (commonHoverParent) { + break; + } + nsIContent* child1 = parent1; + child1->GetParent(*getter_AddRefs(parent1)); + } + } + //If new hover content is null we get the top parent of mHoverContent + else if (mHoverContent) { + nsCOMPtr parent = mHoverContent; + nsIContent* child = nsnull; + while (parent) { + child = parent; + child->GetParent(*getter_AddRefs(parent)); + } + commonHoverParent = child; + } + //Else if old hover content is null we get the top parent of aContent + else { + nsCOMPtr parent = aContent; + nsIContent* child = nsnull; + while (parent) { + child = parent; + child->GetParent(*getter_AddRefs(parent)); + } + commonHoverParent = child; + } + NS_IF_RELEASE(mHoverContent); + } + else { + //transferring ref to notifyContent from mHoverContent + notifyContent[1] = mHoverContent; // notify hover first, since more common case + } mHoverContent = aContent; NS_IF_ADDREF(mHoverContent); } @@ -2427,11 +2516,63 @@ nsEventStateManager::SetContentState(nsIContent *aContent, PRInt32 aState) } } - if (notifyContent[0]) { // have at least one to notify about + if (notifyContent[0] || newHover || oldHover) { // have at least one to notify about nsIDocument *document; // this presumes content can't get/lose state if not connected to doc - notifyContent[0]->GetDocument(document); + if (notifyContent[0]) { + notifyContent[0]->GetDocument(document); + } + else if (newHover) { + newHover->GetDocument(document); + } + else { + oldHover->GetDocument(document); + } if (document) { document->BeginUpdate(); + + //Notify all content from newHover to the commonHoverParent + if (newHover) { + nsCOMPtr parent; + newHover->GetParent(*getter_AddRefs(parent)); + document->ContentStatesChanged(newHover, parent); + while (parent && parent != commonHoverParent) { + parent->GetParent(*getter_AddRefs(newHover)); + if (newHover && newHover != commonHoverParent) { + newHover->GetParent(*getter_AddRefs(parent)); + if (parent == commonHoverParent) { + document->ContentStatesChanged(newHover, nsnull); + } + else { + document->ContentStatesChanged(newHover, parent); + } + } + else { + break; + } + } + } + //Notify all content from oldHover to the commonHoverParent + if (oldHover) { + nsCOMPtr parent; + oldHover->GetParent(*getter_AddRefs(parent)); + document->ContentStatesChanged(oldHover, parent); + while (parent && parent != commonHoverParent) { + parent->GetParent(*getter_AddRefs(oldHover)); + if (oldHover && oldHover != commonHoverParent) { + oldHover->GetParent(*getter_AddRefs(parent)); + if (parent == commonHoverParent) { + document->ContentStatesChanged(oldHover, nsnull); + } + else { + document->ContentStatesChanged(oldHover, parent); + } + } + else { + break; + } + } + } + document->ContentStatesChanged(notifyContent[0], notifyContent[1]); if (notifyContent[2]) { // more that two notifications are needed (should be rare) // XXX a further optimization here would be to group the notification pairs diff --git a/mozilla/content/events/src/nsEventStateManager.h b/mozilla/content/events/src/nsEventStateManager.h index 1526503bff2..357896a0e5c 100644 --- a/mozilla/content/events/src/nsEventStateManager.h +++ b/mozilla/content/events/src/nsEventStateManager.h @@ -179,6 +179,9 @@ protected: // For mousewheel preferences handling nsCOMPtr mPrefService; PRBool m_haveShutdown; + + //Pref for using hierarchical hover (possibly expensive) or not + PRBool hHover; }; extern nsresult NS_NewEventStateManager(nsIEventStateManager** aInstancePtrResult); diff --git a/mozilla/content/html/content/src/nsAttributeContent.cpp b/mozilla/content/html/content/src/nsAttributeContent.cpp index d2dc724948e..f4da0f72f26 100644 --- a/mozilla/content/html/content/src/nsAttributeContent.cpp +++ b/mozilla/content/html/content/src/nsAttributeContent.cpp @@ -31,7 +31,7 @@ #include "nsIXIFConverter.h" #include "nsRange.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIEnumerator.h" @@ -472,7 +472,7 @@ nsAttributeContent::CopyText(nsAWritableString& aResult) aResult.Assign(mText.Get2b(), mText.GetLength()); } else { - aResult.Assign(NS_ConvertASCIItoUCS2(mText.Get1b(), mText.GetLength()), mText.GetLength()); + aResult.Assign(NS_ConvertASCIItoUCS2(mText.Get1b(), mText.GetLength()).get(), mText.GetLength()); } return NS_OK; } diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp index bf669857943..d391fef2113 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp @@ -812,7 +812,7 @@ nsGenericHTMLElement::GetInnerHTML(nsAWritableString& aInnerHTML) nsresult rv = NS_OK; nsCOMPtr docEncoder; - docEncoder = do_CreateInstance(NS_DOC_ENCODER_PROGID_BASE "text/html"); + docEncoder = do_CreateInstance(NS_DOC_ENCODER_CONTRACTID_BASE "text/html"); NS_ENSURE_TRUE(docEncoder, NS_ERROR_FAILURE); @@ -1042,6 +1042,36 @@ nsGenericHTMLElement::HandleDOMEventForAnchors(nsIContent* aOuter, nsresult ret = HandleDOMEvent(aPresContext, aEvent, aDOMEvent, aFlags, aEventStatus); + //Need to check if we hit an imagemap area and if so see if we're handling + //the event on that map or on a link farther up the tree. If we're on a + //link farther up, do nothing. + if (NS_SUCCEEDED(ret)) { + PRBool targetIsArea = PR_FALSE; + + nsCOMPtr esm; + if (NS_SUCCEEDED(aPresContext->GetEventStateManager(getter_AddRefs(esm))) && esm) { + nsCOMPtr target; + esm->GetEventTargetContent(aEvent, getter_AddRefs(target)); + if (target) { + nsCOMPtr tag; + target->GetTag(*getter_AddRefs(tag)); + if (tag && tag.get() == nsHTMLAtoms::area) { + targetIsArea = PR_TRUE; + } + } + } + + if (targetIsArea) { + //We are over an area. If our element is not one, then return without + //running anchor code. + nsCOMPtr tag; + GetTag(*getter_AddRefs(tag)); + if (tag && tag.get() != nsHTMLAtoms::area) { + return ret; + } + } + } + if ((NS_OK == ret) && (nsEventStatus_eIgnore == *aEventStatus) && !(aFlags & NS_EVENT_FLAG_CAPTURE)) { // If we're here, then aOuter should be an nsILink. We'll use the @@ -1060,6 +1090,9 @@ nsGenericHTMLElement::HandleDOMEventForAnchors(nsIContent* aOuter, if (hrefCStr) { nsAutoString href; href.AssignWithConversion(hrefCStr); + // Strip off any unneeded CF/LF (for Bug 52119) + // It can't be done in the parser because of Bug 15204 + href.StripChars("\r\n"); switch (aEvent->message) { case NS_MOUSE_LEFT_BUTTON_DOWN: @@ -1074,7 +1107,6 @@ nsGenericHTMLElement::HandleDOMEventForAnchors(nsIContent* aOuter, NS_RELEASE(stateManager); } NS_RELEASE(handler); - *aEventStatus = nsEventStatus_eConsumeNoDefault; } } break; @@ -1122,11 +1154,14 @@ nsGenericHTMLElement::HandleDOMEventForAnchors(nsIContent* aOuter, case NS_MOUSE_ENTER_SYNTH: { +#if 0 nsIEventStateManager *stateManager; if (NS_OK == aPresContext->GetEventStateManager(&stateManager)) { stateManager->SetContentState(mContent, NS_EVENT_STATE_HOVER); NS_RELEASE(stateManager); } + *aEventStatus = nsEventStatus_eConsumeNoDefault; +#endif } // Set the status bar the same for focus and mouseover case NS_FOCUS_CONTENT: @@ -1141,21 +1176,22 @@ nsGenericHTMLElement::HandleDOMEventForAnchors(nsIContent* aOuter, ret = TriggerLink(aPresContext, eLinkVerb_Replace, baseURL, href, target, PR_FALSE); NS_IF_RELEASE(baseURL); - *aEventStatus = nsEventStatus_eConsumeNoDefault; } break; case NS_MOUSE_EXIT_SYNTH: { +#if 0 nsIEventStateManager *stateManager; if (NS_OK == aPresContext->GetEventStateManager(&stateManager)) { stateManager->SetContentState(nsnull, NS_EVENT_STATE_HOVER); NS_RELEASE(stateManager); } + *aEventStatus = nsEventStatus_eConsumeNoDefault; +#endif nsAutoString empty; ret = TriggerLink(aPresContext, eLinkVerb_Replace, nsnull, empty, empty, PR_FALSE); - *aEventStatus = nsEventStatus_eConsumeNoDefault; } break; @@ -2788,7 +2824,7 @@ nsGenericHTMLElement::MapCommonAttributesInto(const nsIHTMLMappedAttributes* aAt aAttributes->GetAttribute(nsHTMLAtoms::lang, value); if (value.GetUnit() == eHTMLUnit_String) { if (!gLangService) { - nsServiceManager::GetService(NS_LANGUAGEATOMSERVICE_PROGID, + nsServiceManager::GetService(NS_LANGUAGEATOMSERVICE_CONTRACTID, NS_GET_IID(nsILanguageAtomService), (nsISupports**) &gLangService); if (!gLangService) { return; diff --git a/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp b/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp index ab7731cc1b6..cb2e7666eeb 100644 --- a/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp @@ -345,7 +345,7 @@ nsHTMLAnchorElement::StringToAttribute(nsIAtom* aAttribute, } } else if (aAttribute == nsHTMLAtoms::suppress) { - if (nsCRT::strcasecmp(nsPromiseFlatString(aValue), NS_LITERAL_STRING("true"))) { + if (nsCRT::strcasecmp(nsPromiseFlatString(aValue).get(), NS_LITERAL_STRING("true").get())) { aResult.SetEmptyValue(); // XXX? shouldn't just leave "true" return NS_CONTENT_ATTR_HAS_VALUE; } diff --git a/mozilla/content/html/content/src/nsHTMLInputElement.cpp b/mozilla/content/html/content/src/nsHTMLInputElement.cpp index f3adb38cedb..88aa78e51e0 100644 --- a/mozilla/content/html/content/src/nsHTMLInputElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLInputElement.cpp @@ -424,7 +424,7 @@ nsHTMLInputElement::SetValue(const nsAReadableString& aValue) if (NS_FORM_INPUT_FILE == type) { nsresult result; NS_WITH_SERVICE(nsIScriptSecurityManager, securityManager, - NS_SCRIPTSECURITYMANAGER_PROGID, &result); + NS_SCRIPTSECURITYMANAGER_CONTRACTID, &result); if (NS_FAILED(result)) return result; PRBool enabled; @@ -1356,7 +1356,7 @@ nsHTMLInputElement::GetControllers(nsIControllers** aResult) if (!mControllers) { return NS_ERROR_NULL_POINTER; } nsresult rv; - nsCOMPtr controller = do_CreateInstance("component://netscape/editor/editorcontroller", &rv); + nsCOMPtr controller = do_CreateInstance("@mozilla.org/editor/editorcontroller;1", &rv); if (NS_FAILED(rv)) return rv; nsCOMPtr editorController = do_QueryInterface(controller, &rv); if (NS_FAILED(rv)) return rv; diff --git a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp index 21822d194b7..93b4da436f4 100644 --- a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp @@ -925,7 +925,7 @@ nsHTMLSelectElement::SetOptionSelectedByIndex(PRInt32 aIndex, PRBool aIsSelected if (-1 != aIndex) { if (aIsSelected) { nsCOMPtr thisVal; - res = nsComponentManager::CreateInstance(NS_SUPPORTS_PRINT32_PROGID, + res = nsComponentManager::CreateInstance(NS_SUPPORTS_PRINT32_CONTRACTID, nsnull, NS_GET_IID(nsISupportsPRInt32), (void**)getter_AddRefs(thisVal)); if (NS_SUCCEEDED(res) && thisVal) { res = thisVal->SetData(aIndex); diff --git a/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp b/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp index c967d87b757..17e9587d7b8 100644 --- a/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp @@ -681,7 +681,7 @@ nsHTMLTextAreaElement::GetControllers(nsIControllers** aResult) if (!mControllers) { return NS_ERROR_NULL_POINTER; } nsresult rv; - nsCOMPtr controller = do_CreateInstance("component://netscape/editor/editorcontroller", &rv); + nsCOMPtr controller = do_CreateInstance("@mozilla.org/editor/editorcontroller;1", &rv); if (NS_FAILED(rv)) return rv; nsCOMPtr editorController = do_QueryInterface(controller, &rv); if (NS_FAILED(rv)) return rv; diff --git a/mozilla/content/html/content/src/nsHTMLUtils.cpp b/mozilla/content/html/content/src/nsHTMLUtils.cpp index 98cf5ba4a22..a1de3788b02 100644 --- a/mozilla/content/html/content/src/nsHTMLUtils.cpp +++ b/mozilla/content/html/content/src/nsHTMLUtils.cpp @@ -85,7 +85,7 @@ NS_MakeAbsoluteURIWithCharset(char* *aResult, convmgr = aConvMgr; } else { - convmgr = do_GetService(NS_CHARSETCONVERTERMANAGER_PROGID); + convmgr = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID); } if (! convmgr) @@ -167,7 +167,7 @@ nsHTMLUtils::AddRef() nsServiceManager::GetService(kIOServiceCID, NS_GET_IID(nsIIOService), NS_REINTERPRET_CAST(nsISupports**, &IOService)); - nsServiceManager::GetService(NS_CHARSETCONVERTERMANAGER_PROGID, + nsServiceManager::GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, NS_GET_IID(nsICharsetConverterManager), NS_REINTERPRET_CAST(nsISupports**, &CharsetMgr)); } @@ -178,7 +178,7 @@ void nsHTMLUtils::Release() { if (--gRefCnt == 0) { - nsServiceManager::ReleaseService(NS_CHARSETCONVERTERMANAGER_PROGID, CharsetMgr); + nsServiceManager::ReleaseService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, CharsetMgr); nsServiceManager::ReleaseService(kIOServiceCID, IOService); } } diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index cafa6bcaaa9..1a623bb6d79 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -477,7 +477,6 @@ public: PRUnichar* mText; PRInt32 mTextLength; PRInt32 mTextSize; - PRInt32 mIgnoredOpenCount; }; //---------------------------------------------------------------------- @@ -1158,7 +1157,6 @@ SinkContext::SinkContext(HTMLContentSink* aSink) mTextSize = 0; mLastTextNode = nsnull; mLastTextNodeSize = 0; - mIgnoredOpenCount = 0; } SinkContext::~SinkContext() @@ -1297,13 +1295,6 @@ SinkContext::OpenContainer(const nsIParserNode& aNode) SINK_TRACE_NODE(SINK_TRACE_CALLS, "SinkContext::OpenContainer", aNode, mStackPos, mSink); - // XXX - Hack to handle stack over flow ( Bug 18480 ) - if (mStackPos > 1000) { - mIgnoredOpenCount++; - return AddLeaf(aNode); - } - // XXX - Hack Ends - nsresult rv; if (mStackPos + 1 > mStackSize) { rv = GrowStack(); @@ -1405,13 +1396,6 @@ SinkContext::CloseContainer(const nsIParserNode& aNode) { nsresult result = NS_OK; - // XXX - Hack to handle stack over flow ( Bug 18480 ) - if (mIgnoredOpenCount) { - mIgnoredOpenCount--; - return NS_OK; - } - // XXX -Hack Ends. - // Flush any collected text content. Release the last text // node to indicate that no more should be added to it. FlushTextAndRelease(); @@ -2472,7 +2456,7 @@ HTMLContentSink::WillInterrupt() mNotificationTimer->Cancel(); } - mNotificationTimer = do_CreateInstance("component://netscape/timer", &result); + mNotificationTimer = do_CreateInstance("@mozilla.org/timer;1", &result); if (NS_SUCCEEDED(result)) { SINK_TRACE(SINK_TRACE_REFLOW, ("HTMLContentSink::WillInterrupt: setting up timer with delay %d", delay)); @@ -3008,7 +2992,7 @@ HTMLContentSink::OpenNoscript(const nsIParserNode& aNode) { nsresult result=mCurrentContext->OpenContainer(aNode); if(NS_SUCCEEDED(result)) { - NS_WITH_SERVICE(nsIPref, prefs, "component://netscape/preferences", &result); + NS_WITH_SERVICE(nsIPref, prefs, "@mozilla.org/preferences;1", &result); if(NS_SUCCEEDED(result)) { PRBool jsEnabled; result=prefs->GetBoolPref("javascript.enabled", &jsEnabled); @@ -3641,7 +3625,7 @@ HTMLContentSink::ProcessBaseHref(const nsString& aBaseHref) //-- Make sure this page is allowed to load this URL nsresult rv; NS_WITH_SERVICE(nsIScriptSecurityManager, securityManager, - NS_SCRIPTSECURITYMANAGER_PROGID, &rv); + NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv); if (NS_FAILED(rv)) return; nsCOMPtr baseHrefURI; rv = NS_NewURI(getter_AddRefs(baseHrefURI), aBaseHref, nsnull); @@ -4331,7 +4315,7 @@ HTMLContentSink::ProcessMETATag(const nsIParserNode& aNode) if (NS_SUCCEEDED(rv)) { NS_WITH_SERVICE(nsIScriptSecurityManager, securityManager, - NS_SCRIPTSECURITYMANAGER_PROGID, + NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) { rv = securityManager->CheckLoadURI(baseURI, @@ -4351,7 +4335,7 @@ HTMLContentSink::ProcessMETATag(const nsIParserNode& aNode) } } // END refresh else if (!header.CompareWithConversion("set-cookie", PR_TRUE)) { - nsCOMPtr cookieServ = do_GetService(NS_COOKIESERVICE_PROGID, &rv); + nsCOMPtr cookieServ = do_GetService(NS_COOKIESERVICE_CONTRACTID, &rv); if (NS_FAILED(rv)) return rv; nsCOMPtr baseURI; @@ -4359,7 +4343,7 @@ HTMLContentSink::ProcessMETATag(const nsIParserNode& aNode) rv = webNav->GetCurrentURI(getter_AddRefs(baseURI)); if (NS_FAILED(rv)) return rv; - rv = cookieServ->SetCookieString(baseURI, nsnull, result); // need to add nsHTMLDocument parameter + rv = cookieServ->SetCookieString(baseURI, mDocument, result); if (NS_FAILED(rv)) return rv; } // END set-cookie @@ -4884,8 +4868,20 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode) MOZ_TIMER_STOP(mWatch); // Don't process scripts that aren't JavaScript and don't process - // scripts that are inside iframes, noframe, or noscript tags. - if (isJavaScript && !mNumOpenIFRAMES && !mInsideNoXXXTag) { + // scripts that are inside iframes, noframe, or noscript tags, + // or if the script context has script evaluation disabled: + PRBool scriptsEnabled = PR_TRUE; + nsCOMPtr globalObject; + mDocument->GetScriptGlobalObject(getter_AddRefs(globalObject)); + if (globalObject) + { + nsCOMPtr context; + if (NS_SUCCEEDED(globalObject->GetContext(getter_AddRefs(context))) + && context) + context->GetScriptsEnabled(&scriptsEnabled); + } + + if (scriptsEnabled && isJavaScript && !mNumOpenIFRAMES && !mInsideNoXXXTag) { mScriptLanguageVersion = jsVersionString; // If there is a SRC attribute... @@ -4900,7 +4896,7 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode) // Check that this page is allowed to load this URI. NS_WITH_SERVICE(nsIScriptSecurityManager, securityManager, - NS_SCRIPTSECURITYMANAGER_PROGID, &rv); + NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv); if (NS_FAILED(rv)) return rv; rv = securityManager->CheckLoadURI(mDocumentBaseURL, mScriptURI, PR_FALSE); diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index 4f2079c457c..7f00c0741bc 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -93,6 +93,7 @@ #include "nsIEventListenerManager.h" #include "nsISelectElement.h" #include "nsIFrameSelection.h" +#include "nsISelectionPrivate.h"//for toStringwithformat code #include "nsICharsetDetector.h" #include "nsICharsetDetectionAdaptor.h" @@ -109,8 +110,8 @@ #include "nsHTMLParts.h" //for createelementNS -#define DETECTOR_PROGID_MAX 127 -static char g_detector_progid[DETECTOR_PROGID_MAX + 1]; +#define DETECTOR_CONTRACTID_MAX 127 +static char g_detector_contractid[DETECTOR_CONTRACTID_MAX + 1]; static PRBool gInitDetector = PR_FALSE; static PRBool gPlugDetector = PR_FALSE; //static PRBool gBookmarkCharset = PR_TRUE; @@ -154,18 +155,18 @@ static int PR_CALLBACK MyPrefChangedCallback(const char*aPrefName, void* instance_data) { nsresult rv; - NS_WITH_SERVICE(nsIPref, prefs, "component://netscape/preferences", &rv); + NS_WITH_SERVICE(nsIPref, prefs, "@mozilla.org/preferences;1", &rv); PRUnichar* detector_name = nsnull; if(NS_SUCCEEDED(rv) && NS_SUCCEEDED( rv = prefs->GetLocalizedUnicharPref("intl.charset.detector", &detector_name))) { if(nsCRT::strlen(detector_name) > 0) { - PL_strncpy(g_detector_progid, NS_CHARSET_DETECTOR_PROGID_BASE,DETECTOR_PROGID_MAX); - PL_strncat(g_detector_progid, NS_ConvertUCS2toUTF8(detector_name),DETECTOR_PROGID_MAX); + PL_strncpy(g_detector_contractid, NS_CHARSET_DETECTOR_CONTRACTID_BASE,DETECTOR_CONTRACTID_MAX); + PL_strncat(g_detector_contractid, NS_ConvertUCS2toUTF8(detector_name),DETECTOR_CONTRACTID_MAX); gPlugDetector = PR_TRUE; } else { - g_detector_progid[0]=0; + g_detector_contractid[0]=0; gPlugDetector = PR_FALSE; } PR_FREEIF(detector_name); @@ -339,7 +340,7 @@ nsHTMLDocument::~nsHTMLDocument() if (--gRefCntRDFService == 0) { - nsServiceManager::ReleaseService("component://netscape/rdf/rdf-service", gRDF); + nsServiceManager::ReleaseService("@mozilla.org/rdf/rdf-service;1", gRDF); } } @@ -769,7 +770,7 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand, nsresult rv_detect = NS_OK; if(! gInitDetector) { - nsCOMPtr pref(do_GetService(NS_PREF_PROGID)); + nsCOMPtr pref(do_GetService(NS_PREF_CONTRACTID)); if(pref) { PRUnichar* detector_name = nsnull; @@ -777,8 +778,8 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand, rv_detect = pref->GetLocalizedUnicharPref("intl.charset.detector", &detector_name))) { - PL_strncpy(g_detector_progid, NS_CHARSET_DETECTOR_PROGID_BASE,DETECTOR_PROGID_MAX); - PL_strncat(g_detector_progid, NS_ConvertUCS2toUTF8(detector_name),DETECTOR_PROGID_MAX); + PL_strncpy(g_detector_contractid, NS_CHARSET_DETECTOR_CONTRACTID_BASE,DETECTOR_CONTRACTID_MAX); + PL_strncat(g_detector_contractid, NS_ConvertUCS2toUTF8(detector_name),DETECTOR_CONTRACTID_MAX); gPlugDetector = PR_TRUE; PR_FREEIF(detector_name); } @@ -821,15 +822,13 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand, } } - if(bTryCache) + if(bTryCache && urlSpec) { nsCOMPtr cacheMgr; - cacheMgr = do_GetService(NS_NETWORK_CACHE_MANAGER_PROGID, &rv); - NS_ASSERTION(NS_SUCCEEDED(rv),"Cannot get cache mgr"); - if(NS_SUCCEEDED(rv) && urlSpec) + cacheMgr = do_GetService(NS_NETWORK_CACHE_MANAGER_CONTRACTID, &rv); + if(NS_SUCCEEDED(rv)) { rv = cacheMgr->GetCachedNetData(urlSpec, nsnull, 0, cacheFlags, getter_AddRefs(cachedData)); - NS_ASSERTION(NS_SUCCEEDED(rv),"Cannot get cached net data"); if(NS_SUCCEEDED(rv)) { if(kCharsetFromCache > charsetSource) { @@ -863,11 +862,11 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand, if((kCharsetFromAutoDetection > charsetSource ) && gPlugDetector) { - nsCOMPtr cdet = do_CreateInstance(g_detector_progid, + nsCOMPtr cdet = do_CreateInstance(g_detector_contractid, &rv_detect); if(NS_SUCCEEDED( rv_detect )) { - cdetflt = do_CreateInstance(NS_CHARSET_DETECTION_ADAPTOR_PROGID, + cdetflt = do_CreateInstance(NS_CHARSET_DETECTION_ADAPTOR_CONTRACTID, &rv_detect); if(NS_SUCCEEDED( rv_detect )) { @@ -1574,6 +1573,12 @@ nsHTMLDocument::HasChildNodes(PRBool* aReturn) return nsDocument::HasChildNodes(aReturn); } +NS_IMETHODIMP +nsHTMLDocument::HasAttributes(PRBool* aReturn) +{ + return nsDocument::HasAttributes(aReturn); +} + NS_IMETHODIMP nsHTMLDocument::GetNodeName(nsAWritableString& aNodeName) { @@ -1665,10 +1670,11 @@ nsHTMLDocument::Normalize() } NS_IMETHODIMP -nsHTMLDocument::Supports(const nsAReadableString& aFeature, const nsAReadableString& aVersion, - PRBool* aReturn) +nsHTMLDocument::IsSupported(const nsAReadableString& aFeature, + const nsAReadableString& aVersion, + PRBool* aReturn) { - return nsDocument::Supports(aFeature, aVersion, aReturn); + return nsDocument::IsSupported(aFeature, aVersion, aReturn); } @@ -1776,7 +1782,7 @@ nsHTMLDocument::SetDomain(const nsAReadableString& aDomain) // Get codebase principal nsresult rv; NS_WITH_SERVICE(nsIScriptSecurityManager, securityManager, - NS_SCRIPTSECURITYMANAGER_PROGID, &rv); + NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv); if (NS_FAILED(rv)) return NS_ERROR_FAILURE; nsCOMPtr newCodebase; @@ -2835,22 +2841,29 @@ nsHTMLDocument::GetSelection(nsAWritableString& aReturn) if (!selection) return NS_OK; - nsCOMPtr domSelection; + nsCOMPtr domSelection; selection->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(domSelection)); if (!domSelection) return NS_OK; + nsCOMPtr privSel(do_QueryInterface(domSelection)); nsCOMPtr consoleService - (do_GetService("mozilla.consoleservice.1")); + (do_GetService("@mozilla.org/consoleservice;1")); if (consoleService) { - consoleService->LogStringMessage(NS_LITERAL_STRING("Deprecated method document.getSelection() called. Please use window.getSelection() instead.")); + consoleService->LogStringMessage(NS_LITERAL_STRING("Deprecated method document.getSelection() called. Please use window.getSelection() instead.").get()); } - - return domSelection->ToString(NS_ConvertASCIItoUCS2("text/plain"), nsIDocumentEncoder::OutputFormatted |nsIDocumentEncoder::OutputSelectionOnly, 0, aReturn); + PRUnichar *tmp; + nsresult rv = privSel->ToStringWithFormat("text/plain", nsIDocumentEncoder::OutputFormatted |nsIDocumentEncoder::OutputSelectionOnly, 0, &tmp); + if (tmp) + { + aReturn.Assign(tmp); + nsMemory::Free(tmp); + } + return rv; } NS_IMETHODIMP @@ -4131,7 +4144,7 @@ nsHTMLDocument::GetForms(nsIDOMHTMLCollection** aForms) } PRBool -nsHTMLDocument::IsInSelection(nsIDOMSelection* aSelection, +nsHTMLDocument::IsInSelection(nsISelection* aSelection, const nsIContent* aContent) const { nsIAtom* tag; diff --git a/mozilla/content/html/document/src/nsHTMLDocument.h b/mozilla/content/html/document/src/nsHTMLDocument.h index 1f21a911565..81f488b15a0 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.h +++ b/mozilla/content/html/document/src/nsHTMLDocument.h @@ -145,7 +145,7 @@ public: /* * Like nsDocument::IsInSelection except it always includes the body node */ - virtual PRBool IsInSelection(nsIDOMSelection* aSelection, const nsIContent *aContent) const; + virtual PRBool IsInSelection(nsISelection* aSelection, const nsIContent *aContent) const; virtual nsresult Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup); protected: diff --git a/mozilla/content/html/style/src/nsCSSLoader.cpp b/mozilla/content/html/style/src/nsCSSLoader.cpp index 9f4082091d6..cd42ece86c8 100644 --- a/mozilla/content/html/style/src/nsCSSLoader.cpp +++ b/mozilla/content/html/style/src/nsCSSLoader.cpp @@ -770,9 +770,9 @@ CSSLoaderImpl::SheetComplete(nsICSSStyleSheet* aSheet, SheetLoadData* aLoadData) { #ifdef INCLUDE_XUL if (IsChromeURI(aLoadData->mURL)) { - nsCOMPtr utils(do_GetService("component://netscape/rdf/xul-content-utils")); + nsCOMPtr utils(do_GetService("@mozilla.org/rdf/xul-content-utils;1")); if (utils && utils->UseXULCache()) { - nsCOMPtr cache(do_GetService("component://netscape/rdf/xul-prototype-cache")); + nsCOMPtr cache(do_GetService("@mozilla.org/rdf/xul-prototype-cache;1")); if (cache) { nsCOMPtr sheet; cache->GetStyleSheet(aLoadData->mURL, getter_AddRefs(sheet)); @@ -1317,7 +1317,7 @@ CSSLoaderImpl::LoadStyleLink(nsIContent* aElement, //-- Make sure this page is allowed to load this URL nsresult rv; - NS_WITH_SERVICE(nsIScriptSecurityManager, secMan, NS_SCRIPTSECURITYMANAGER_PROGID, &rv); + NS_WITH_SERVICE(nsIScriptSecurityManager, secMan, NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv); if (NS_FAILED(rv)) return rv; nsIURI* docURI; rv = mDocument->GetBaseURL(docURI); @@ -1337,9 +1337,9 @@ CSSLoaderImpl::LoadStyleLink(nsIContent* aElement, nsICSSStyleSheet* sheet = (nsICSSStyleSheet*)mLoadedSheets.Get(&key); #ifdef INCLUDE_XUL if (!sheet && IsChromeURI(aURL)) { - nsCOMPtr utils(do_GetService("component://netscape/rdf/xul-content-utils")); + nsCOMPtr utils(do_GetService("@mozilla.org/rdf/xul-content-utils;1")); if (utils && utils->UseXULCache()) { - nsCOMPtr cache(do_GetService("component://netscape/rdf/xul-prototype-cache")); + nsCOMPtr cache(do_GetService("@mozilla.org/rdf/xul-prototype-cache;1")); if (cache) { nsCOMPtr cachedSheet; cache->GetStyleSheet(aURL, getter_AddRefs(cachedSheet)); @@ -1413,9 +1413,9 @@ CSSLoaderImpl::LoadChildSheet(nsICSSStyleSheet* aParentSheet, nsICSSStyleSheet* sheet = (nsICSSStyleSheet*)mLoadedSheets.Get(&key); #ifdef INCLUDE_XUL if (!sheet && IsChromeURI(aURL)) { - nsCOMPtr utils(do_GetService("component://netscape/rdf/xul-content-utils")); + nsCOMPtr utils(do_GetService("@mozilla.org/rdf/xul-content-utils;1")); if (utils && utils->UseXULCache()) { - nsCOMPtr cache(do_GetService("component://netscape/rdf/xul-prototype-cache")); + nsCOMPtr cache(do_GetService("@mozilla.org/rdf/xul-prototype-cache;1")); if (cache) { nsCOMPtr cachedSheet; cache->GetStyleSheet(aURL, getter_AddRefs(cachedSheet)); diff --git a/mozilla/content/html/style/src/nsCSSScanner.cpp b/mozilla/content/html/style/src/nsCSSScanner.cpp index 45df711b4e4..0c1e5a9171b 100644 --- a/mozilla/content/html/style/src/nsCSSScanner.cpp +++ b/mozilla/content/html/style/src/nsCSSScanner.cpp @@ -223,9 +223,9 @@ void nsCSSScanner::ReportError(const nsAReadableString& aError) // Log it to the JavaScript console nsCOMPtr consoleService - (do_GetService("mozilla.consoleservice.1")); + (do_GetService("@mozilla.org/consoleservice;1")); nsCOMPtr errorObject - (do_CreateInstance("mozilla.scripterror.1")); + (do_CreateInstance("@mozilla.org/scripterror;1")); if (consoleService && errorObject) { nsresult rv; diff --git a/mozilla/content/html/style/src/nsCSSStyleRule.cpp b/mozilla/content/html/style/src/nsCSSStyleRule.cpp index 2b1dafe23c5..9d697844670 100644 --- a/mozilla/content/html/style/src/nsCSSStyleRule.cpp +++ b/mozilla/content/html/style/src/nsCSSStyleRule.cpp @@ -615,6 +615,11 @@ void nsCSSSelector::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize) } } +nsresult nsCSSSelector::ToString( nsAWritableString& aString ) const +{ + return NS_OK; +} + // -- CSSImportantRule ------------------------------- static nscoord CalcLength(const nsCSSValue& aValue, const nsFont& aFont, @@ -1056,7 +1061,6 @@ protected: protected: nsCSSSelector mSelector; - nsString mSelectorText; nsICSSDeclaration* mDeclaration; PRInt32 mWeight; CSSImportantRule* mImportantRule; @@ -1070,7 +1074,7 @@ PRUint32 gStyleRuleCount=0; CSSStyleRuleImpl::CSSStyleRuleImpl(const nsCSSSelector& aSelector) : nsCSSRule(), - mSelector(aSelector), mSelectorText(), mDeclaration(nsnull), + mSelector(aSelector), mDeclaration(nsnull), mWeight(0), mImportantRule(nsnull), mDOMDeclaration(nsnull), mScriptObject(nsnull) @@ -1084,7 +1088,6 @@ CSSStyleRuleImpl::CSSStyleRuleImpl(const nsCSSSelector& aSelector) CSSStyleRuleImpl::CSSStyleRuleImpl(const CSSStyleRuleImpl& aCopy) : nsCSSRule(aCopy), mSelector(aCopy.mSelector), - mSelectorText(aCopy.mSelectorText), mDeclaration(nsnull), mWeight(aCopy.mWeight), mImportantRule(nsnull), @@ -1291,12 +1294,12 @@ void CSSStyleRuleImpl::DeleteSelector(nsCSSSelector* aSelector) void CSSStyleRuleImpl::SetSourceSelectorText(const nsString& aSelectorText) { - mSelectorText = aSelectorText; + /* no need for set, since get recreates the string */ } void CSSStyleRuleImpl::GetSourceSelectorText(nsString& aSelectorText) const { - aSelectorText = mSelectorText; + mSelector.ToString( aSelectorText ); } @@ -3273,7 +3276,7 @@ CSSStyleRuleImpl::List(FILE* out, PRInt32 aIndent) const * SizeOf method: * * Self (reported as CSSStyleRuleImpl's size): -* 1) sizeof(*this) + size of the mSelectorText +* 1) sizeof(*this) * + sizeof the DOMDeclaration if it exists and is unique * * Contained / Aggregated data (not reported as CSSStyleRuleImpl's size): @@ -3304,11 +3307,6 @@ void CSSStyleRuleImpl::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize) // remove the sizeof the mSelector's class since we count it seperately below aSize -= sizeof(mSelector); - // add in the length of the selectorText - mSelectorText.SizeOf(aSizeOfHandler, &localSize); - aSize += localSize; - aSize -= sizeof(mSelectorText); // counted in sizeof(*this) and nsString.SizeOf() - // and add the size of the DOMDeclaration // XXX - investigate the size and quantity of these if(mDOMDeclaration && uniqueItems->AddItem(mDOMDeclaration)){ @@ -3338,8 +3336,13 @@ CSSStyleRuleImpl::GetType(PRUint16* aType) NS_IMETHODIMP CSSStyleRuleImpl::GetCssText(nsAWritableString& aCssText) { - aCssText.Assign(mSelectorText); - // XXX TBI append declaration too + mSelector.ToString( aCssText ); + if (mDeclaration) + { + nsAutoString tempString; + mDeclaration->ToString( tempString ); + aCssText.Append( tempString ); + } return NS_OK; } @@ -3369,7 +3372,7 @@ CSSStyleRuleImpl::GetParentRule(nsIDOMCSSRule** aParentRule) NS_IMETHODIMP CSSStyleRuleImpl::GetSelectorText(nsAWritableString& aSelectorText) { - aSelectorText.Assign(mSelectorText); + mSelector.ToString( aSelectorText ); return NS_OK; } @@ -3379,7 +3382,6 @@ CSSStyleRuleImpl::SetSelectorText(const nsAReadableString& aSelectorText) // XXX TBI - get a parser and re-parse the selectors, // XXX then need to re-compute the cascade // XXX and dirty sheet - mSelectorText = aSelectorText; return NS_OK; } diff --git a/mozilla/content/html/style/src/nsDOMCSSDeclaration.cpp b/mozilla/content/html/style/src/nsDOMCSSDeclaration.cpp index d5129565354..7d8f41e5ec1 100644 --- a/mozilla/content/html/style/src/nsDOMCSSDeclaration.cpp +++ b/mozilla/content/html/style/src/nsDOMCSSDeclaration.cpp @@ -334,18 +334,6 @@ nsDOMCSSDeclaration::SetBackgroundRepeat(const nsAReadableString& aBackgroundRep return SetProperty(NS_ConvertASCIItoUCS2("background-repeat"), aBackgroundRepeat, nsAutoString()); } -NS_IMETHODIMP -nsDOMCSSDeclaration::GetBehavior(nsAWritableString& aBehavior) -{ - return GetPropertyValue(NS_ConvertASCIItoUCS2("behavior"), aBehavior); -} - -NS_IMETHODIMP -nsDOMCSSDeclaration::SetBehavior(const nsAReadableString& aBehavior) -{ - return SetProperty(NS_ConvertASCIItoUCS2("behavior"), aBehavior, nsAutoString()); -} - NS_IMETHODIMP nsDOMCSSDeclaration::GetBorder(nsAWritableString& aBorder) { @@ -1153,48 +1141,56 @@ nsDOMCSSDeclaration::SetOrphans(const nsAReadableString& aOrphans) NS_IMETHODIMP nsDOMCSSDeclaration::GetOutline(nsAWritableString& aOutline) { + // XXX Because of the renaming to -moz-outline, this does nothing. return GetPropertyValue(NS_ConvertASCIItoUCS2("outline"), aOutline); } NS_IMETHODIMP nsDOMCSSDeclaration::SetOutline(const nsAReadableString& aOutline) { + // XXX Because of the renaming to -moz-outline, this does nothing. return SetProperty(NS_ConvertASCIItoUCS2("outline"), aOutline, nsAutoString()); } NS_IMETHODIMP nsDOMCSSDeclaration::GetOutlineColor(nsAWritableString& aOutlineColor) { + // XXX Because of the renaming to -moz-outline, this does nothing. return GetPropertyValue(NS_ConvertASCIItoUCS2("outline-color"), aOutlineColor); } NS_IMETHODIMP nsDOMCSSDeclaration::SetOutlineColor(const nsAReadableString& aOutlineColor) { + // XXX Because of the renaming to -moz-outline, this does nothing. return SetProperty(NS_ConvertASCIItoUCS2("outline-color"), aOutlineColor, nsAutoString()); } NS_IMETHODIMP nsDOMCSSDeclaration::GetOutlineStyle(nsAWritableString& aOutlineStyle) { + // XXX Because of the renaming to -moz-outline, this does nothing. return GetPropertyValue(NS_ConvertASCIItoUCS2("outline-style"), aOutlineStyle); } NS_IMETHODIMP nsDOMCSSDeclaration::SetOutlineStyle(const nsAReadableString& aOutlineStyle) { + // XXX Because of the renaming to -moz-outline, this does nothing. return SetProperty(NS_ConvertASCIItoUCS2("outline-style"), aOutlineStyle, nsAutoString()); } NS_IMETHODIMP nsDOMCSSDeclaration::GetOutlineWidth(nsAWritableString& aOutlineWidth) { + // XXX Because of the renaming to -moz-outline, this does nothing. return GetPropertyValue(NS_ConvertASCIItoUCS2("outline-width"), aOutlineWidth); } NS_IMETHODIMP nsDOMCSSDeclaration::SetOutlineWidth(const nsAReadableString& aOutlineWidth) { + // XXX Because of the renaming to -moz-outline, this does nothing. return SetProperty(NS_ConvertASCIItoUCS2("outline-width"), aOutlineWidth, nsAutoString()); } @@ -1726,15 +1722,26 @@ nsDOMCSSDeclaration::SetZIndex(const nsAReadableString& aZIndex) return SetProperty(NS_ConvertASCIItoUCS2("z-index"), aZIndex, nsAutoString()); } - -NS_IMETHODIMP -nsDOMCSSDeclaration::GetOpacity(nsAWritableString& aOpacity) +NS_IMETHODIMP +nsDOMCSSDeclaration::GetMozBinding(nsAWritableString& aBehavior) { - return GetPropertyValue(NS_ConvertASCIItoUCS2("opacity"), aOpacity); + return GetPropertyValue(NS_ConvertASCIItoUCS2("-moz-binding"), aBehavior); } NS_IMETHODIMP -nsDOMCSSDeclaration::SetOpacity(const nsAReadableString& aOpacity) +nsDOMCSSDeclaration::SetMozBinding(const nsAReadableString& aBehavior) { - return SetProperty(NS_ConvertASCIItoUCS2("opacity"), aOpacity, nsAutoString()); + return SetProperty(NS_ConvertASCIItoUCS2("-moz-binding"), aBehavior, nsAutoString()); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetMozOpacity(nsAWritableString& aOpacity) +{ + return GetPropertyValue(NS_ConvertASCIItoUCS2("-moz-opacity"), aOpacity); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetMozOpacity(const nsAReadableString& aOpacity) +{ + return SetProperty(NS_ConvertASCIItoUCS2("-moz-opacity"), aOpacity, nsAutoString()); } diff --git a/mozilla/content/html/style/src/nsICSSStyleRule.h b/mozilla/content/html/style/src/nsICSSStyleRule.h index 99357a2fefc..46a3ebe50c0 100644 --- a/mozilla/content/html/style/src/nsICSSStyleRule.h +++ b/mozilla/content/html/style/src/nsICSSStyleRule.h @@ -99,6 +99,7 @@ public: PRInt32 CalcWeight(void) const; void SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize); + nsresult ToString( nsAWritableString& aString ) const; public: PRInt32 mNameSpace; diff --git a/mozilla/content/shared/src/nsHTMLUtils.cpp b/mozilla/content/shared/src/nsHTMLUtils.cpp index 98cf5ba4a22..a1de3788b02 100644 --- a/mozilla/content/shared/src/nsHTMLUtils.cpp +++ b/mozilla/content/shared/src/nsHTMLUtils.cpp @@ -85,7 +85,7 @@ NS_MakeAbsoluteURIWithCharset(char* *aResult, convmgr = aConvMgr; } else { - convmgr = do_GetService(NS_CHARSETCONVERTERMANAGER_PROGID); + convmgr = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID); } if (! convmgr) @@ -167,7 +167,7 @@ nsHTMLUtils::AddRef() nsServiceManager::GetService(kIOServiceCID, NS_GET_IID(nsIIOService), NS_REINTERPRET_CAST(nsISupports**, &IOService)); - nsServiceManager::GetService(NS_CHARSETCONVERTERMANAGER_PROGID, + nsServiceManager::GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, NS_GET_IID(nsICharsetConverterManager), NS_REINTERPRET_CAST(nsISupports**, &CharsetMgr)); } @@ -178,7 +178,7 @@ void nsHTMLUtils::Release() { if (--gRefCnt == 0) { - nsServiceManager::ReleaseService(NS_CHARSETCONVERTERMANAGER_PROGID, CharsetMgr); + nsServiceManager::ReleaseService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, CharsetMgr); nsServiceManager::ReleaseService(kIOServiceCID, IOService); } } diff --git a/mozilla/content/xbl/src/nsBindingManager.cpp b/mozilla/content/xbl/src/nsBindingManager.cpp index 8ee0b1cd4a3..be1b22c091c 100644 --- a/mozilla/content/xbl/src/nsBindingManager.cpp +++ b/mozilla/content/xbl/src/nsBindingManager.cpp @@ -354,7 +354,7 @@ nsBindingManager::AddLayeredBinding(nsIContent* aContent, const nsAReadableStrin { // First we need to load our binding. nsresult rv; - NS_WITH_SERVICE(nsIXBLService, xblService, "component://netscape/xbl", &rv); + NS_WITH_SERVICE(nsIXBLService, xblService, "@mozilla.org/xbl;1", &rv); if (!xblService) return rv; @@ -411,21 +411,39 @@ NS_IMETHODIMP nsBindingManager::LoadBindingDocument(nsIDocument* aBoundDoc, const nsAReadableString& aURL, nsIDocument** aResult) { + nsCAutoString url; url.AssignWithConversion((const PRUnichar*)nsPromiseFlatString(aURL).get()); + + nsCOMPtr uri; + nsComponentManager::CreateInstance("@mozilla.org/network/standard-url;1", + nsnull, + NS_GET_IID(nsIURL), + getter_AddRefs(uri)); + uri->SetSpec(url); + + + nsCOMPtr docURL = getter_AddRefs(aBoundDoc->GetDocumentURL()); + nsXPIDLCString scheme; + docURL->GetScheme(getter_Copies(scheme)); + + nsXPIDLCString otherScheme; + uri->GetScheme(getter_Copies(otherScheme)); + // First we need to load our binding. *aResult = nsnull; nsresult rv; - NS_WITH_SERVICE(nsIXBLService, xblService, "component://netscape/xbl", &rv); + NS_WITH_SERVICE(nsIXBLService, xblService, "@mozilla.org/xbl;1", &rv); if (!xblService) return rv; // Load the binding doc. - nsCString url; url.AssignWithConversion((const PRUnichar*)nsPromiseFlatString(aURL)); nsCOMPtr info; xblService->LoadBindingDocumentInfo(nsnull, aBoundDoc, url, nsCAutoString(), PR_TRUE, getter_AddRefs(info)); if (!info) return NS_ERROR_FAILURE; - info->GetDocument(aResult); // Addref happens here. + if (!PL_strcmp(scheme, otherScheme)) + info->GetDocument(aResult); // Addref happens here. + return NS_OK; } diff --git a/mozilla/content/xbl/src/nsXBLBinding.cpp b/mozilla/content/xbl/src/nsXBLBinding.cpp index b64f69e2a6e..1aeb842ad48 100644 --- a/mozilla/content/xbl/src/nsXBLBinding.cpp +++ b/mozilla/content/xbl/src/nsXBLBinding.cpp @@ -171,6 +171,9 @@ nsXBLJSClass::Destroy() // Static initialization PRUint32 nsXBLBinding::gRefCnt = 0; +nsIAtom* nsXBLBinding::kXULTemplateAtom = nsnull; +nsIAtom* nsXBLBinding::kXULObservesAtom = nsnull; + nsIAtom* nsXBLBinding::kContentAtom = nsnull; nsIAtom* nsXBLBinding::kImplementationAtom = nsnull; nsIAtom* nsXBLBinding::kHandlersAtom = nsnull; @@ -284,6 +287,9 @@ nsXBLBinding::nsXBLBinding(const nsCString& aDocURI, const nsCString& aID) if (gRefCnt == 1) { kPool.Init("XBL Attribute Entries", kBucketSizes, kNumBuckets, kInitialSize); + kXULTemplateAtom = NS_NewAtom("template"); + kXULObservesAtom = NS_NewAtom("observes"); + kContentAtom = NS_NewAtom("content"); kImplementationAtom = NS_NewAtom("implementation"); kHandlersAtom = NS_NewAtom("handlers"); @@ -312,7 +318,7 @@ nsXBLBinding::nsXBLBinding(const nsCString& aDocURI, const nsCString& aID) kBindingDetachedAtom = NS_NewAtom("bindingdetached"); kInheritStyleAtom = NS_NewAtom("inheritstyle"); - nsServiceManager::GetService("component://netscape/xbl", + nsServiceManager::GetService("@mozilla.org/xbl;1", NS_GET_IID(nsIXBLService), (nsISupports**) &gXBLService); @@ -334,6 +340,9 @@ nsXBLBinding::~nsXBLBinding(void) // printf("REF COUNT DOWN: %d %s\n", gRefCnt, (const char*)mID); if (gRefCnt == 0) { + NS_RELEASE(kXULTemplateAtom); + NS_RELEASE(kXULObservesAtom); + NS_RELEASE(kContentAtom); NS_RELEASE(kImplementationAtom); NS_RELEASE(kHandlersAtom); @@ -361,7 +370,7 @@ nsXBLBinding::~nsXBLBinding(void) NS_RELEASE(kBindingAttachedAtom); NS_RELEASE(kInheritStyleAtom); - nsServiceManager::ReleaseService("component://netscape/xbl", gXBLService); + nsServiceManager::ReleaseService("@mozilla.org/xbl;1", gXBLService); gXBLService = nsnull; EventHandlerMapEntry* entry = kEventHandlerMap; @@ -510,31 +519,31 @@ nsXBLBinding::GenerateAnonymousContent(nsIContent* aBoundElement) // Plan to build the content by default. PRBool buildContent = PR_TRUE; - // See if there's an excludes attribute. - nsAutoString excludes; - content->GetAttribute(kNameSpaceID_None, kExcludesAtom, excludes); - if ( excludes != NS_LITERAL_STRING("*")) { + // See if there's an includes attribute. + nsAutoString includes; + content->GetAttribute(kNameSpaceID_None, kIncludesAtom, includes); + if ( includes != NS_LITERAL_STRING("*")) { PRInt32 childCount; aBoundElement->ChildCount(childCount); if (childCount > 0) { // We'll only build content if all the explicit children are - // in the excludes list. - - if (!excludes.IsEmpty()) { - // Walk the children and ensure that all of them - // are in the excludes array. - for (PRInt32 i = 0; i < childCount; i++) { - nsCOMPtr child; - aBoundElement->ChildAt(i, *getter_AddRefs(child)); - nsCOMPtr tag; - child->GetTag(*getter_AddRefs(tag)); - if (!IsInExcludesList(tag, excludes)) { + // in the includes list. + // Walk the children and ensure that all of them + // are in the includes array. + for (PRInt32 i = 0; i < childCount; i++) { + nsCOMPtr child; + aBoundElement->ChildAt(i, *getter_AddRefs(child)); + nsCOMPtr tag; + child->GetTag(*getter_AddRefs(tag)); + if (!IsInExcludesList(tag, includes)) { + // XXX HACK! Ignore