Fix for bug 836809 (Convert XMLStyleSheetProcessingInstruction to WebIDL) - rename nsXMLStylesheetPI to mozilla::dom::XMLStylesheetProcessingInstruction. r=bz.

--HG--
rename : content/xml/content/src/nsXMLStylesheetPI.cpp => content/xml/content/src/XMLStylesheetProcessingInstruction.cpp
rename : content/xml/content/src/nsXMLStylesheetPI.cpp => content/xml/content/src/XMLStylesheetProcessingInstruction.h
extra : rebase_source : 054540510a51031e461b56475f5b62b676565e10
This commit is contained in:
Peter Van der Beken 2013-02-01 13:28:36 +01:00
parent ee4a060f18
commit c98c55e10c
3 changed files with 109 additions and 96 deletions

View File

@ -20,13 +20,14 @@ EXPORTS_NAMESPACES = mozilla/dom
EXPORTS_mozilla/dom = \
CDATASection.h \
ProcessingInstruction.h \
XMLStylesheetProcessingInstruction.h \
$(NULL)
CPPSRCS = \
nsXMLElement.cpp \
CDATASection.cpp \
ProcessingInstruction.cpp \
nsXMLStylesheetPI.cpp \
XMLStylesheetProcessingInstruction.cpp \
$(NULL)
# we don't want the shared lib, but we want to force the creation of a static lib.

View File

@ -3,122 +3,65 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/Element.h"
#include "nsIDOMLinkStyle.h"
#include "nsIDOMStyleSheet.h"
#include "nsIDocument.h"
#include "nsIStyleSheet.h"
#include "nsIURI.h"
#include "nsStyleLinkElement.h"
#include "XMLStylesheetProcessingInstruction.h"
#include "nsNetUtil.h"
#include "mozilla/dom/ProcessingInstruction.h"
#include "nsUnicharUtils.h"
#include "nsGkAtoms.h"
#include "nsThreadUtils.h"
#include "nsContentUtils.h"
using namespace mozilla;
using namespace dom;
DOMCI_NODE_DATA(XMLStylesheetProcessingInstruction,
mozilla::dom::XMLStylesheetProcessingInstruction)
class nsXMLStylesheetPI : public ProcessingInstruction,
public nsStyleLinkElement
{
public:
nsXMLStylesheetPI(already_AddRefed<nsINodeInfo> aNodeInfo, const nsAString& aData);
virtual ~nsXMLStylesheetPI();
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
// CC
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsXMLStylesheetPI,
ProcessingInstruction)
// nsIDOMNode
virtual void SetNodeValueInternal(const nsAString& aNodeValue,
mozilla::ErrorResult& aError);
// nsIContent
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent,
bool aCompileEventHandlers);
virtual void UnbindFromTree(bool aDeep = true,
bool aNullParent = true);
// nsIStyleSheetLinkingElement
virtual void OverrideBaseURI(nsIURI* aNewBaseURI);
// nsStyleLinkElement
NS_IMETHOD GetCharset(nsAString& aCharset);
virtual nsXPCClassInfo* GetClassInfo();
protected:
nsCOMPtr<nsIURI> mOverriddenBaseURI;
already_AddRefed<nsIURI> GetStyleSheetURL(bool* aIsInline);
void GetStyleSheetInfo(nsAString& aTitle,
nsAString& aType,
nsAString& aMedia,
bool* aIsScoped,
bool* aIsAlternate);
virtual nsGenericDOMDataNode* CloneDataNode(nsINodeInfo *aNodeInfo,
bool aCloneText) const;
};
namespace mozilla {
namespace dom {
// nsISupports implementation
DOMCI_NODE_DATA(XMLStylesheetProcessingInstruction, nsXMLStylesheetPI)
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsXMLStylesheetPI)
NS_NODE_INTERFACE_TABLE4(nsXMLStylesheetPI, nsIDOMNode,
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(XMLStylesheetProcessingInstruction)
NS_NODE_INTERFACE_TABLE4(XMLStylesheetProcessingInstruction, nsIDOMNode,
nsIDOMProcessingInstruction, nsIDOMLinkStyle,
nsIStyleSheetLinkingElement)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(XMLStylesheetProcessingInstruction)
NS_INTERFACE_MAP_END_INHERITING(ProcessingInstruction)
NS_IMPL_ADDREF_INHERITED(nsXMLStylesheetPI, ProcessingInstruction)
NS_IMPL_RELEASE_INHERITED(nsXMLStylesheetPI, ProcessingInstruction)
NS_IMPL_ADDREF_INHERITED(XMLStylesheetProcessingInstruction,
ProcessingInstruction)
NS_IMPL_RELEASE_INHERITED(XMLStylesheetProcessingInstruction,
ProcessingInstruction)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsXMLStylesheetPI,
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(XMLStylesheetProcessingInstruction,
ProcessingInstruction)
tmp->nsStyleLinkElement::Traverse(cb);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsXMLStylesheetPI,
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(XMLStylesheetProcessingInstruction,
ProcessingInstruction)
tmp->nsStyleLinkElement::Unlink();
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
nsXMLStylesheetPI::nsXMLStylesheetPI(already_AddRefed<nsINodeInfo> aNodeInfo,
const nsAString& aData)
: ProcessingInstruction(aNodeInfo, aData)
{
}
nsXMLStylesheetPI::~nsXMLStylesheetPI()
XMLStylesheetProcessingInstruction::~XMLStylesheetProcessingInstruction()
{
}
// nsIContent
nsresult
nsXMLStylesheetPI::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent,
bool aCompileEventHandlers)
XMLStylesheetProcessingInstruction::BindToTree(nsIDocument* aDocument,
nsIContent* aParent,
nsIContent* aBindingParent,
bool aCompileEventHandlers)
{
nsresult rv = ProcessingInstruction::BindToTree(aDocument, aParent,
aBindingParent,
aCompileEventHandlers);
NS_ENSURE_SUCCESS(rv, rv);
void (nsXMLStylesheetPI::*update)() = &nsXMLStylesheetPI::UpdateStyleSheetInternal;
void (XMLStylesheetProcessingInstruction::*update)() =
&XMLStylesheetProcessingInstruction::UpdateStyleSheetInternal;
nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, update));
return rv;
}
void
nsXMLStylesheetPI::UnbindFromTree(bool aDeep, bool aNullParent)
XMLStylesheetProcessingInstruction::UnbindFromTree(bool aDeep, bool aNullParent)
{
nsCOMPtr<nsIDocument> oldDoc = GetCurrentDoc();
@ -129,8 +72,8 @@ nsXMLStylesheetPI::UnbindFromTree(bool aDeep, bool aNullParent)
// nsIDOMNode
void
nsXMLStylesheetPI::SetNodeValueInternal(const nsAString& aNodeValue,
ErrorResult& aError)
XMLStylesheetProcessingInstruction::SetNodeValueInternal(const nsAString& aNodeValue,
ErrorResult& aError)
{
nsGenericDOMDataNode::SetNodeValueInternal(aNodeValue, aError);
if (!aError.Failed()) {
@ -141,19 +84,19 @@ nsXMLStylesheetPI::SetNodeValueInternal(const nsAString& aNodeValue,
// nsStyleLinkElement
NS_IMETHODIMP
nsXMLStylesheetPI::GetCharset(nsAString& aCharset)
XMLStylesheetProcessingInstruction::GetCharset(nsAString& aCharset)
{
return GetAttrValue(nsGkAtoms::charset, aCharset) ? NS_OK : NS_ERROR_FAILURE;
}
/* virtual */ void
nsXMLStylesheetPI::OverrideBaseURI(nsIURI* aNewBaseURI)
XMLStylesheetProcessingInstruction::OverrideBaseURI(nsIURI* aNewBaseURI)
{
mOverriddenBaseURI = aNewBaseURI;
}
already_AddRefed<nsIURI>
nsXMLStylesheetPI::GetStyleSheetURL(bool* aIsInline)
XMLStylesheetProcessingInstruction::GetStyleSheetURL(bool* aIsInline)
{
*aIsInline = false;
@ -176,11 +119,11 @@ nsXMLStylesheetPI::GetStyleSheetURL(bool* aIsInline)
}
void
nsXMLStylesheetPI::GetStyleSheetInfo(nsAString& aTitle,
nsAString& aType,
nsAString& aMedia,
bool* aIsScoped,
bool* aIsAlternate)
XMLStylesheetProcessingInstruction::GetStyleSheetInfo(nsAString& aTitle,
nsAString& aType,
nsAString& aMedia,
bool* aIsScoped,
bool* aIsAlternate)
{
aTitle.Truncate();
aType.Truncate();
@ -232,14 +175,18 @@ nsXMLStylesheetPI::GetStyleSheetInfo(nsAString& aTitle,
}
nsGenericDOMDataNode*
nsXMLStylesheetPI::CloneDataNode(nsINodeInfo *aNodeInfo, bool aCloneText) const
XMLStylesheetProcessingInstruction::CloneDataNode(nsINodeInfo *aNodeInfo,
bool aCloneText) const
{
nsAutoString data;
nsGenericDOMDataNode::GetData(data);
nsCOMPtr<nsINodeInfo> ni = aNodeInfo;
return new nsXMLStylesheetPI(ni.forget(), data);
return new XMLStylesheetProcessingInstruction(ni.forget(), data);
}
} // namespace dom
} // namespace mozilla
nsresult
NS_NewXMLStylesheetProcessingInstruction(nsIContent** aInstancePtrResult,
nsNodeInfoManager *aNodeInfoManager,
@ -256,12 +203,10 @@ NS_NewXMLStylesheetProcessingInstruction(nsIContent** aInstancePtrResult,
nsGkAtoms::xml_stylesheet);
NS_ENSURE_TRUE(ni, NS_ERROR_OUT_OF_MEMORY);
nsXMLStylesheetPI *instance = new nsXMLStylesheetPI(ni.forget(), aData);
if (!instance) {
return NS_ERROR_OUT_OF_MEMORY;
}
nsRefPtr<mozilla::dom::XMLStylesheetProcessingInstruction> instance =
new mozilla::dom::XMLStylesheetProcessingInstruction(ni.forget(), aData);
NS_ADDREF(*aInstancePtrResult = instance);
instance.forget(aInstancePtrResult);
return NS_OK;
}

View File

@ -0,0 +1,67 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_XMLStylesheetProcessingInstruction_h
#define mozilla_dom_XMLStylesheetProcessingInstruction_h
#include "mozilla/dom/ProcessingInstruction.h"
#include "nsStyleLinkElement.h"
namespace mozilla {
namespace dom {
class XMLStylesheetProcessingInstruction : public ProcessingInstruction,
public nsStyleLinkElement
{
public:
XMLStylesheetProcessingInstruction(already_AddRefed<nsINodeInfo> aNodeInfo,
const nsAString& aData)
: ProcessingInstruction(aNodeInfo, aData)
{
}
virtual ~XMLStylesheetProcessingInstruction();
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
// CC
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XMLStylesheetProcessingInstruction,
ProcessingInstruction)
// nsIDOMNode
virtual void SetNodeValueInternal(const nsAString& aNodeValue,
mozilla::ErrorResult& aError);
// nsIContent
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent,
bool aCompileEventHandlers);
virtual void UnbindFromTree(bool aDeep = true,
bool aNullParent = true);
// nsIStyleSheetLinkingElement
virtual void OverrideBaseURI(nsIURI* aNewBaseURI);
// nsStyleLinkElement
NS_IMETHOD GetCharset(nsAString& aCharset);
virtual nsXPCClassInfo* GetClassInfo();
protected:
nsCOMPtr<nsIURI> mOverriddenBaseURI;
already_AddRefed<nsIURI> GetStyleSheetURL(bool* aIsInline);
void GetStyleSheetInfo(nsAString& aTitle,
nsAString& aType,
nsAString& aMedia,
bool* aIsScoped,
bool* aIsAlternate);
virtual nsGenericDOMDataNode* CloneDataNode(nsINodeInfo *aNodeInfo,
bool aCloneText) const;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_XMLStylesheetProcessingInstruction_h