import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo
69
dom/xml/CDATASection.cpp
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
#include "mozilla/dom/CDATASection.h"
|
||||
#include "mozilla/dom/CDATASectionBinding.h"
|
||||
#include "mozilla/IntegerPrintfMacros.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
CDATASection::~CDATASection()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(CDATASection, nsGenericDOMDataNode, nsIDOMNode,
|
||||
nsIDOMCharacterData, nsIDOMText,
|
||||
nsIDOMCDATASection)
|
||||
|
||||
JSObject*
|
||||
CDATASection::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
return CDATASectionBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
bool
|
||||
CDATASection::IsNodeOfType(uint32_t aFlags) const
|
||||
{
|
||||
return !(aFlags & ~(eCONTENT | eTEXT | eDATA_NODE));
|
||||
}
|
||||
|
||||
nsGenericDOMDataNode*
|
||||
CDATASection::CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo, bool aCloneText) const
|
||||
{
|
||||
RefPtr<mozilla::dom::NodeInfo> ni = aNodeInfo;
|
||||
CDATASection *it = new CDATASection(ni.forget());
|
||||
if (it && aCloneText) {
|
||||
it->mText = mText;
|
||||
}
|
||||
|
||||
return it;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void
|
||||
CDATASection::List(FILE* out, int32_t aIndent) const
|
||||
{
|
||||
int32_t index;
|
||||
for (index = aIndent; --index >= 0; ) fputs(" ", out);
|
||||
|
||||
fprintf(out, "CDATASection refcount=%" PRIuPTR "<", mRefCnt.get());
|
||||
|
||||
nsAutoString tmp;
|
||||
ToCString(tmp, 0, mText.GetLength());
|
||||
fputs(NS_LossyConvertUTF16toASCII(tmp).get(), out);
|
||||
|
||||
fputs(">\n", out);
|
||||
}
|
||||
|
||||
void
|
||||
CDATASection::DumpContent(FILE* out, int32_t aIndent,
|
||||
bool aDumpAll) const {
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
79
dom/xml/CDATASection.h
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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_CDATASection_h
|
||||
#define mozilla_dom_CDATASection_h
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsIDOMCDATASection.h"
|
||||
#include "mozilla/dom/Text.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class CDATASection final : public Text,
|
||||
public nsIDOMCDATASection
|
||||
{
|
||||
private:
|
||||
void Init()
|
||||
{
|
||||
MOZ_ASSERT(mNodeInfo->NodeType() == nsIDOMNode::CDATA_SECTION_NODE,
|
||||
"Bad NodeType in aNodeInfo");
|
||||
}
|
||||
|
||||
virtual ~CDATASection();
|
||||
|
||||
public:
|
||||
explicit CDATASection(already_AddRefed<mozilla::dom::NodeInfo> aNodeInfo)
|
||||
: Text(aNodeInfo)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
explicit CDATASection(nsNodeInfoManager* aNodeInfoManager)
|
||||
: Text(aNodeInfoManager->GetNodeInfo(nsGkAtoms::cdataTagName,
|
||||
nullptr, kNameSpaceID_None,
|
||||
nsIDOMNode::CDATA_SECTION_NODE))
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIDOMNode
|
||||
NS_FORWARD_NSIDOMNODE_TO_NSINODE
|
||||
|
||||
// nsIDOMCharacterData
|
||||
NS_FORWARD_NSIDOMCHARACTERDATA(nsGenericDOMDataNode::)
|
||||
using nsGenericDOMDataNode::SetData; // Prevent hiding overloaded virtual function.
|
||||
|
||||
// nsIDOMText
|
||||
NS_FORWARD_NSIDOMTEXT(nsGenericDOMDataNode::)
|
||||
|
||||
// nsIDOMCDATASection
|
||||
// Empty interface
|
||||
|
||||
// nsINode
|
||||
virtual bool IsNodeOfType(uint32_t aFlags) const override;
|
||||
|
||||
virtual nsGenericDOMDataNode* CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo,
|
||||
bool aCloneText) const override;
|
||||
|
||||
virtual nsIDOMNode* AsDOMNode() override { return this; }
|
||||
#ifdef DEBUG
|
||||
virtual void List(FILE* out, int32_t aIndent) const override;
|
||||
virtual void DumpContent(FILE* out, int32_t aIndent,bool aDumpAll) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_CDATASection_h
|
||||
133
dom/xml/ProcessingInstruction.cpp
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "mozilla/dom/ProcessingInstruction.h"
|
||||
#include "mozilla/dom/ProcessingInstructionBinding.h"
|
||||
#include "mozilla/dom/XMLStylesheetProcessingInstruction.h"
|
||||
#include "mozilla/IntegerPrintfMacros.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
already_AddRefed<mozilla::dom::ProcessingInstruction>
|
||||
NS_NewXMLProcessingInstruction(nsNodeInfoManager *aNodeInfoManager,
|
||||
const nsAString& aTarget,
|
||||
const nsAString& aData)
|
||||
{
|
||||
using mozilla::dom::ProcessingInstruction;
|
||||
using mozilla::dom::XMLStylesheetProcessingInstruction;
|
||||
|
||||
NS_PRECONDITION(aNodeInfoManager, "Missing nodeinfo manager");
|
||||
|
||||
nsCOMPtr<nsIAtom> target = NS_Atomize(aTarget);
|
||||
MOZ_ASSERT(target);
|
||||
|
||||
if (target == nsGkAtoms::xml_stylesheet) {
|
||||
RefPtr<XMLStylesheetProcessingInstruction> pi =
|
||||
new XMLStylesheetProcessingInstruction(aNodeInfoManager, aData);
|
||||
return pi.forget();
|
||||
}
|
||||
|
||||
RefPtr<mozilla::dom::NodeInfo> ni;
|
||||
ni = aNodeInfoManager->GetNodeInfo(nsGkAtoms::processingInstructionTagName,
|
||||
nullptr, kNameSpaceID_None,
|
||||
nsIDOMNode::PROCESSING_INSTRUCTION_NODE,
|
||||
target);
|
||||
|
||||
RefPtr<ProcessingInstruction> instance =
|
||||
new ProcessingInstruction(ni.forget(), aData);
|
||||
|
||||
return instance.forget();
|
||||
}
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
ProcessingInstruction::ProcessingInstruction(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
||||
const nsAString& aData)
|
||||
: nsGenericDOMDataNode(Move(aNodeInfo))
|
||||
{
|
||||
MOZ_ASSERT(mNodeInfo->NodeType() == nsIDOMNode::PROCESSING_INSTRUCTION_NODE,
|
||||
"Bad NodeType in aNodeInfo");
|
||||
|
||||
SetTextInternal(0, mText.GetLength(),
|
||||
aData.BeginReading(), aData.Length(),
|
||||
false); // Don't notify (bug 420429).
|
||||
}
|
||||
|
||||
ProcessingInstruction::~ProcessingInstruction()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(ProcessingInstruction, nsGenericDOMDataNode,
|
||||
nsIDOMNode, nsIDOMCharacterData,
|
||||
nsIDOMProcessingInstruction)
|
||||
|
||||
JSObject*
|
||||
ProcessingInstruction::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
return ProcessingInstructionBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ProcessingInstruction::GetTarget(nsAString& aTarget)
|
||||
{
|
||||
aTarget = NodeName();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
ProcessingInstruction::GetAttrValue(nsIAtom *aName, nsAString& aValue)
|
||||
{
|
||||
nsAutoString data;
|
||||
|
||||
GetData(data);
|
||||
return nsContentUtils::GetPseudoAttributeValue(data, aName, aValue);
|
||||
}
|
||||
|
||||
bool
|
||||
ProcessingInstruction::IsNodeOfType(uint32_t aFlags) const
|
||||
{
|
||||
return !(aFlags & ~(eCONTENT | ePROCESSING_INSTRUCTION | eDATA_NODE));
|
||||
}
|
||||
|
||||
nsGenericDOMDataNode*
|
||||
ProcessingInstruction::CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo,
|
||||
bool aCloneText) const
|
||||
{
|
||||
nsAutoString data;
|
||||
nsGenericDOMDataNode::GetData(data);
|
||||
RefPtr<mozilla::dom::NodeInfo> ni = aNodeInfo;
|
||||
return new ProcessingInstruction(ni.forget(), data);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void
|
||||
ProcessingInstruction::List(FILE* out, int32_t aIndent) const
|
||||
{
|
||||
int32_t index;
|
||||
for (index = aIndent; --index >= 0; ) fputs(" ", out);
|
||||
|
||||
fprintf(out, "Processing instruction refcount=%" PRIuPTR "<", mRefCnt.get());
|
||||
|
||||
nsAutoString tmp;
|
||||
ToCString(tmp, 0, mText.GetLength());
|
||||
tmp.Insert(nsDependentAtomString(NodeInfo()->GetExtraName()).get(), 0);
|
||||
fputs(NS_LossyConvertUTF16toASCII(tmp).get(), out);
|
||||
|
||||
fputs(">\n", out);
|
||||
}
|
||||
|
||||
void
|
||||
ProcessingInstruction::DumpContent(FILE* out, int32_t aIndent,
|
||||
bool aDumpAll) const
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
85
dom/xml/ProcessingInstruction.h
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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_ProcessingInstruction_h
|
||||
#define mozilla_dom_ProcessingInstruction_h
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsIDOMProcessingInstruction.h"
|
||||
#include "nsGenericDOMDataNode.h"
|
||||
#include "nsAString.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class ProcessingInstruction : public nsGenericDOMDataNode,
|
||||
public nsIDOMProcessingInstruction
|
||||
{
|
||||
public:
|
||||
ProcessingInstruction(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
||||
const nsAString& aData);
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIDOMNode
|
||||
NS_FORWARD_NSIDOMNODE_TO_NSINODE
|
||||
|
||||
// nsIDOMCharacterData
|
||||
NS_FORWARD_NSIDOMCHARACTERDATA(nsGenericDOMDataNode::)
|
||||
using nsGenericDOMDataNode::SetData; // Prevent hiding overloaded virtual function.
|
||||
|
||||
// nsIDOMProcessingInstruction
|
||||
NS_DECL_NSIDOMPROCESSINGINSTRUCTION
|
||||
|
||||
// nsINode
|
||||
virtual bool IsNodeOfType(uint32_t aFlags) const override;
|
||||
|
||||
virtual nsGenericDOMDataNode* CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo,
|
||||
bool aCloneText) const override;
|
||||
|
||||
#ifdef DEBUG
|
||||
virtual void List(FILE* out, int32_t aIndent) const override;
|
||||
virtual void DumpContent(FILE* out, int32_t aIndent, bool aDumpAll) const override;
|
||||
#endif
|
||||
|
||||
virtual nsIDOMNode* AsDOMNode() override { return this; }
|
||||
|
||||
// WebIDL API
|
||||
void GetTarget(nsString& aTarget)
|
||||
{
|
||||
aTarget = NodeName();
|
||||
}
|
||||
protected:
|
||||
virtual ~ProcessingInstruction();
|
||||
|
||||
/**
|
||||
* This will parse the content of the PI, to extract the value of the pseudo
|
||||
* attribute with the name specified in aName. See
|
||||
* http://www.w3.org/TR/xml-stylesheet/#NT-StyleSheetPI for the specification
|
||||
* which is used to parse the content of the PI.
|
||||
*
|
||||
* @param aName the name of the attribute to get the value for
|
||||
* @param aValue [out] the value for the attribute with name specified in
|
||||
* aAttribute. Empty if the attribute isn't present.
|
||||
*/
|
||||
bool GetAttrValue(nsIAtom *aName, nsAString& aValue);
|
||||
|
||||
virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
/**
|
||||
* aNodeInfoManager must not be null.
|
||||
*/
|
||||
already_AddRefed<mozilla::dom::ProcessingInstruction>
|
||||
NS_NewXMLProcessingInstruction(nsNodeInfoManager *aNodeInfoManager,
|
||||
const nsAString& aTarget,
|
||||
const nsAString& aData);
|
||||
|
||||
#endif // mozilla_dom_ProcessingInstruction_h
|
||||
625
dom/xml/XMLDocument.cpp
Normal file
|
|
@ -0,0 +1,625 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
|
||||
#include "mozilla/dom/XMLDocument.h"
|
||||
#include "nsParserCIID.h"
|
||||
#include "nsCharsetSource.h"
|
||||
#include "nsIXMLContentSink.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIContentViewerContainer.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsHTMLParts.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIBaseWindow.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIDOMDocumentType.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIHttpChannelInternal.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsError.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsLayoutCID.h"
|
||||
#include "mozilla/dom/Attr.h"
|
||||
#include "nsCExternalHandlerService.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "mozilla/EventListenerManager.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIAuthPrompt.h"
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
#include "nsContentPolicyUtils.h"
|
||||
#include "nsNodeUtils.h"
|
||||
#include "nsIConsoleService.h"
|
||||
#include "nsIScriptError.h"
|
||||
#include "nsIHTMLDocument.h"
|
||||
#include "mozilla/BasicEvents.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/XMLDocumentBinding.h"
|
||||
#include "mozilla/dom/DocumentBinding.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
// ==================================================================
|
||||
// =
|
||||
// ==================================================================
|
||||
|
||||
|
||||
nsresult
|
||||
NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
|
||||
const nsAString& aNamespaceURI,
|
||||
const nsAString& aQualifiedName,
|
||||
nsIDOMDocumentType* aDoctype,
|
||||
nsIURI* aDocumentURI,
|
||||
nsIURI* aBaseURI,
|
||||
nsIPrincipal* aPrincipal,
|
||||
bool aLoadedAsData,
|
||||
nsIGlobalObject* aEventObject,
|
||||
DocumentFlavor aFlavor)
|
||||
{
|
||||
// Note: can't require that aDocumentURI/aBaseURI/aPrincipal be non-null,
|
||||
// since at least one caller (XMLHttpRequest) doesn't have decent args to
|
||||
// pass in.
|
||||
|
||||
nsresult rv;
|
||||
|
||||
*aInstancePtrResult = nullptr;
|
||||
|
||||
nsCOMPtr<nsIDocument> d;
|
||||
bool isHTML = false;
|
||||
bool isXHTML = false;
|
||||
if (aFlavor == DocumentFlavorSVG) {
|
||||
rv = NS_NewSVGDocument(getter_AddRefs(d));
|
||||
} else if (aFlavor == DocumentFlavorHTML) {
|
||||
rv = NS_NewHTMLDocument(getter_AddRefs(d));
|
||||
isHTML = true;
|
||||
} else if (aFlavor == DocumentFlavorPlain) {
|
||||
rv = NS_NewXMLDocument(getter_AddRefs(d), aLoadedAsData, true);
|
||||
} else if (aDoctype) {
|
||||
MOZ_ASSERT(aFlavor == DocumentFlavorLegacyGuess);
|
||||
nsAutoString publicId, name;
|
||||
aDoctype->GetPublicId(publicId);
|
||||
if (publicId.IsEmpty()) {
|
||||
aDoctype->GetName(name);
|
||||
}
|
||||
if (name.EqualsLiteral("html") ||
|
||||
publicId.EqualsLiteral("-//W3C//DTD HTML 4.01//EN") ||
|
||||
publicId.EqualsLiteral("-//W3C//DTD HTML 4.01 Frameset//EN") ||
|
||||
publicId.EqualsLiteral("-//W3C//DTD HTML 4.01 Transitional//EN") ||
|
||||
publicId.EqualsLiteral("-//W3C//DTD HTML 4.0//EN") ||
|
||||
publicId.EqualsLiteral("-//W3C//DTD HTML 4.0 Frameset//EN") ||
|
||||
publicId.EqualsLiteral("-//W3C//DTD HTML 4.0 Transitional//EN")) {
|
||||
rv = NS_NewHTMLDocument(getter_AddRefs(d));
|
||||
isHTML = true;
|
||||
} else if (publicId.EqualsLiteral("-//W3C//DTD XHTML 1.0 Strict//EN") ||
|
||||
publicId.EqualsLiteral("-//W3C//DTD XHTML 1.0 Transitional//EN") ||
|
||||
publicId.EqualsLiteral("-//W3C//DTD XHTML 1.0 Frameset//EN")) {
|
||||
rv = NS_NewHTMLDocument(getter_AddRefs(d));
|
||||
isHTML = true;
|
||||
isXHTML = true;
|
||||
}
|
||||
else if (publicId.EqualsLiteral("-//W3C//DTD SVG 1.1//EN")) {
|
||||
rv = NS_NewSVGDocument(getter_AddRefs(d));
|
||||
}
|
||||
// XXX Add support for XUL documents.
|
||||
else {
|
||||
rv = NS_NewXMLDocument(getter_AddRefs(d));
|
||||
}
|
||||
} else {
|
||||
MOZ_ASSERT(aFlavor == DocumentFlavorLegacyGuess);
|
||||
rv = NS_NewXMLDocument(getter_AddRefs(d));
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (isHTML) {
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(d);
|
||||
NS_ASSERTION(htmlDoc, "HTML Document doesn't implement nsIHTMLDocument?");
|
||||
htmlDoc->SetCompatibilityMode(eCompatibility_FullStandards);
|
||||
htmlDoc->SetIsXHTML(isXHTML);
|
||||
}
|
||||
nsDocument* doc = static_cast<nsDocument*>(d.get());
|
||||
doc->SetLoadedAsData(aLoadedAsData);
|
||||
doc->nsDocument::SetDocumentURI(aDocumentURI);
|
||||
// Must set the principal first, since SetBaseURI checks it.
|
||||
doc->SetPrincipal(aPrincipal);
|
||||
doc->SetBaseURI(aBaseURI);
|
||||
|
||||
// We need to set the script handling object after we set the principal such
|
||||
// that the doc group is assigned correctly.
|
||||
if (nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(aEventObject)) {
|
||||
d->SetScriptHandlingObject(sgo);
|
||||
} else if (aEventObject){
|
||||
d->SetScopeObject(aEventObject);
|
||||
}
|
||||
|
||||
// XMLDocuments and documents "created in memory" get to be UTF-8 by default,
|
||||
// unlike the legacy HTML mess
|
||||
doc->SetDocumentCharacterSet(NS_LITERAL_CSTRING("UTF-8"));
|
||||
|
||||
if (aDoctype) {
|
||||
nsCOMPtr<nsIDOMNode> tmpNode;
|
||||
rv = doc->AppendChild(aDoctype, getter_AddRefs(tmpNode));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
if (!aQualifiedName.IsEmpty()) {
|
||||
nsCOMPtr<nsIDOMElement> root;
|
||||
rv = doc->CreateElementNS(aNamespaceURI, aQualifiedName,
|
||||
getter_AddRefs(root));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> tmpNode;
|
||||
|
||||
rv = doc->AppendChild(root, getter_AddRefs(tmpNode));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
*aInstancePtrResult = doc;
|
||||
NS_ADDREF(*aInstancePtrResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewXMLDocument(nsIDocument** aInstancePtrResult, bool aLoadedAsData,
|
||||
bool aIsPlainDocument)
|
||||
{
|
||||
RefPtr<XMLDocument> doc = new XMLDocument();
|
||||
|
||||
nsresult rv = doc->Init();
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
*aInstancePtrResult = nullptr;
|
||||
return rv;
|
||||
}
|
||||
|
||||
doc->SetLoadedAsData(aLoadedAsData);
|
||||
doc->mIsPlainDocument = aIsPlainDocument;
|
||||
doc.forget(aInstancePtrResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewXBLDocument(nsIDOMDocument** aInstancePtrResult,
|
||||
nsIURI* aDocumentURI,
|
||||
nsIURI* aBaseURI,
|
||||
nsIPrincipal* aPrincipal)
|
||||
{
|
||||
nsresult rv = NS_NewDOMDocument(aInstancePtrResult,
|
||||
NS_LITERAL_STRING("http://www.mozilla.org/xbl"),
|
||||
NS_LITERAL_STRING("bindings"), nullptr,
|
||||
aDocumentURI, aBaseURI, aPrincipal, false,
|
||||
nullptr, DocumentFlavorLegacyGuess);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDocument> idoc = do_QueryInterface(*aInstancePtrResult);
|
||||
nsDocument* doc = static_cast<nsDocument*>(idoc.get());
|
||||
doc->SetLoadedAsInteractiveData(true);
|
||||
doc->SetReadyStateInternal(nsIDocument::READYSTATE_COMPLETE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
XMLDocument::XMLDocument(const char* aContentType)
|
||||
: nsDocument(aContentType),
|
||||
mAsync(true)
|
||||
{
|
||||
// NOTE! nsDocument::operator new() zeroes out all members, so don't
|
||||
// bother initializing members to 0.
|
||||
|
||||
mType = eGenericXML;
|
||||
}
|
||||
|
||||
XMLDocument::~XMLDocument()
|
||||
{
|
||||
// XXX We rather crash than hang
|
||||
mLoopingForSyncLoad = false;
|
||||
}
|
||||
|
||||
// QueryInterface implementation for XMLDocument
|
||||
NS_IMPL_ISUPPORTS_INHERITED(XMLDocument, nsDocument, nsIDOMXMLDocument)
|
||||
|
||||
nsresult
|
||||
XMLDocument::Init()
|
||||
{
|
||||
nsresult rv = nsDocument::Init();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
XMLDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup)
|
||||
{
|
||||
nsDocument::Reset(aChannel, aLoadGroup);
|
||||
}
|
||||
|
||||
void
|
||||
XMLDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup,
|
||||
nsIPrincipal* aPrincipal)
|
||||
{
|
||||
if (mChannelIsPending) {
|
||||
StopDocumentLoad();
|
||||
mChannel->Cancel(NS_BINDING_ABORTED);
|
||||
mChannelIsPending = false;
|
||||
}
|
||||
|
||||
nsDocument::ResetToURI(aURI, aLoadGroup, aPrincipal);
|
||||
}
|
||||
|
||||
bool
|
||||
XMLDocument::Load(const nsAString& aUrl, ErrorResult& aRv)
|
||||
{
|
||||
bool hasHadScriptObject = true;
|
||||
nsIScriptGlobalObject* scriptObject =
|
||||
GetScriptHandlingObject(hasHadScriptObject);
|
||||
if (!scriptObject && hasHadScriptObject) {
|
||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> callingDoc = GetEntryDocument();
|
||||
nsCOMPtr<nsIPrincipal> principal = NodePrincipal();
|
||||
|
||||
// The callingDoc's Principal and doc's Principal should be the same
|
||||
if (callingDoc && (callingDoc->NodePrincipal() != principal)) {
|
||||
nsContentUtils::ReportToConsole(nsIScriptError::errorFlag,
|
||||
NS_LITERAL_CSTRING("DOM"),
|
||||
callingDoc,
|
||||
nsContentUtils::eDOM_PROPERTIES,
|
||||
"XMLDocumentLoadPrincipalMismatch");
|
||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Reporting a warning on ourselves is rather pointless, because we probably
|
||||
// have no window id (and hence the warning won't show up in any web console)
|
||||
// and probably aren't considered a "content document" because we're not
|
||||
// loaded in a docshell, so won't accumulate telemetry for use counters. Try
|
||||
// warning on our entry document, if any, since that should have things like
|
||||
// window ids and associated docshells.
|
||||
nsIDocument* docForWarning = callingDoc ? callingDoc.get() : this;
|
||||
if (nsContentUtils::IsCallerChrome()) {
|
||||
docForWarning->WarnOnceAbout(nsIDocument::eChromeUseOfDOM3LoadMethod);
|
||||
} else {
|
||||
docForWarning->WarnOnceAbout(nsIDocument::eUseOfDOM3LoadMethod);
|
||||
}
|
||||
|
||||
nsIURI *baseURI = mDocumentURI;
|
||||
nsAutoCString charset;
|
||||
|
||||
if (callingDoc) {
|
||||
baseURI = callingDoc->GetDocBaseURI();
|
||||
charset = callingDoc->GetDocumentCharacterSet();
|
||||
}
|
||||
|
||||
// Create a new URI
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = NS_NewURI(getter_AddRefs(uri), aUrl, charset.get(), baseURI);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (nsContentUtils::IsSystemPrincipal(principal)) {
|
||||
// We're called from chrome, check to make sure the URI we're
|
||||
// about to load is also chrome.
|
||||
|
||||
bool isChrome = false;
|
||||
if (NS_FAILED(uri->SchemeIs("chrome", &isChrome)) || !isChrome) {
|
||||
nsAutoCString spec;
|
||||
if (mDocumentURI)
|
||||
mDocumentURI->GetSpec(spec);
|
||||
|
||||
nsAutoString error;
|
||||
error.AssignLiteral("Cross site loading using document.load is no "
|
||||
"longer supported. Use XMLHttpRequest instead.");
|
||||
nsCOMPtr<nsIScriptError> errorObject =
|
||||
do_CreateInstance(NS_SCRIPTERROR_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return false;
|
||||
}
|
||||
|
||||
rv = errorObject->InitWithWindowID(error,
|
||||
NS_ConvertUTF8toUTF16(spec),
|
||||
EmptyString(),
|
||||
0, 0, nsIScriptError::warningFlag,
|
||||
"DOM",
|
||||
callingDoc ?
|
||||
callingDoc->InnerWindowID() :
|
||||
this->InnerWindowID());
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIConsoleService> consoleService =
|
||||
do_GetService(NS_CONSOLESERVICE_CONTRACTID);
|
||||
if (consoleService) {
|
||||
consoleService->LogMessage(errorObject);
|
||||
}
|
||||
|
||||
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Partial Reset, need to restore principal for security reasons and
|
||||
// event listener manager so that load listeners etc. will
|
||||
// remain. This should be done before the security check is done to
|
||||
// ensure that the document is reset even if the new document can't
|
||||
// be loaded. Note that we need to hold a strong ref to |principal|
|
||||
// here, because ResetToURI will null out our node principal before
|
||||
// setting the new one.
|
||||
RefPtr<EventListenerManager> elm(mListenerManager);
|
||||
mListenerManager = nullptr;
|
||||
|
||||
// When we are called from JS we can find the load group for the page,
|
||||
// and add ourselves to it. This way any pending requests
|
||||
// will be automatically aborted if the user leaves the page.
|
||||
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
if (callingDoc) {
|
||||
loadGroup = callingDoc->GetDocumentLoadGroup();
|
||||
}
|
||||
|
||||
ResetToURI(uri, loadGroup, principal);
|
||||
|
||||
mListenerManager = elm;
|
||||
|
||||
// Create a channel
|
||||
nsCOMPtr<nsIInterfaceRequestor> req = nsContentUtils::SameOriginChecker();
|
||||
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
// nsIRequest::LOAD_BACKGROUND prevents throbber from becoming active,
|
||||
// which in turn keeps STOP button from becoming active
|
||||
rv = NS_NewChannel(getter_AddRefs(channel),
|
||||
uri,
|
||||
callingDoc ? callingDoc.get() :
|
||||
static_cast<nsIDocument*>(this),
|
||||
nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_IS_BLOCKED,
|
||||
nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST,
|
||||
loadGroup,
|
||||
req,
|
||||
nsIRequest::LOAD_BACKGROUND);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO Bug 1189945: Remove nsIChannel CorsMode flag and set Request.mode
|
||||
// based on nsILoadInfo securityFlags instead. This block will be removed
|
||||
// when Request.mode set correctly.
|
||||
nsCOMPtr<nsIHttpChannelInternal> httpChannel = do_QueryInterface(channel);
|
||||
if (httpChannel) {
|
||||
httpChannel->SetCorsMode(nsIHttpChannelInternal::CORS_MODE_SAME_ORIGIN);
|
||||
}
|
||||
|
||||
// StartDocumentLoad asserts that readyState is uninitialized, so
|
||||
// uninitialize it. SetReadyStateInternal make this transition invisible to
|
||||
// Web content. But before doing that, assert that the current readyState
|
||||
// is complete as it should be after the call to ResetToURI() above.
|
||||
MOZ_ASSERT(GetReadyStateEnum() == nsIDocument::READYSTATE_COMPLETE,
|
||||
"Bad readyState");
|
||||
SetReadyStateInternal(nsIDocument::READYSTATE_UNINITIALIZED);
|
||||
|
||||
// Prepare for loading the XML document "into oneself"
|
||||
nsCOMPtr<nsIStreamListener> listener;
|
||||
if (NS_FAILED(rv = StartDocumentLoad(kLoadAsData, channel,
|
||||
loadGroup, nullptr,
|
||||
getter_AddRefs(listener),
|
||||
false))) {
|
||||
NS_ERROR("XMLDocument::Load: Failed to start the document load.");
|
||||
aRv.Throw(rv);
|
||||
return false;
|
||||
}
|
||||
|
||||
// After this point, if we error out of this method we should clear
|
||||
// mChannelIsPending.
|
||||
|
||||
// Start an asynchronous read of the XML document
|
||||
rv = channel->AsyncOpen2(listener);
|
||||
if (NS_FAILED(rv)) {
|
||||
mChannelIsPending = false;
|
||||
aRv.Throw(rv);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mAsync) {
|
||||
nsCOMPtr<nsIThread> thread = do_GetCurrentThread();
|
||||
|
||||
nsAutoSyncOperation sync(this);
|
||||
mLoopingForSyncLoad = true;
|
||||
while (mLoopingForSyncLoad) {
|
||||
if (!NS_ProcessNextEvent(thread))
|
||||
break;
|
||||
}
|
||||
|
||||
// We set return to true unless there was a parsing error
|
||||
Element* rootElement = GetRootElement();
|
||||
if (!rootElement) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (rootElement->LocalName().EqualsLiteral("parsererror")) {
|
||||
nsAutoString ns;
|
||||
rootElement->GetNamespaceURI(ns);
|
||||
if (ns.EqualsLiteral("http://www.mozilla.org/newlayout/xml/parsererror.xml")) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
XMLDocument::SetSuppressParserErrorElement(bool aSuppress)
|
||||
{
|
||||
mSuppressParserErrorElement = aSuppress;
|
||||
}
|
||||
|
||||
bool
|
||||
XMLDocument::SuppressParserErrorElement()
|
||||
{
|
||||
return mSuppressParserErrorElement;
|
||||
}
|
||||
|
||||
void
|
||||
XMLDocument::SetSuppressParserErrorConsoleMessages(bool aSuppress)
|
||||
{
|
||||
mSuppressParserErrorConsoleMessages = aSuppress;
|
||||
}
|
||||
|
||||
bool
|
||||
XMLDocument::SuppressParserErrorConsoleMessages()
|
||||
{
|
||||
return mSuppressParserErrorConsoleMessages;
|
||||
}
|
||||
|
||||
nsresult
|
||||
XMLDocument::StartDocumentLoad(const char* aCommand,
|
||||
nsIChannel* aChannel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener,
|
||||
bool aReset,
|
||||
nsIContentSink* aSink)
|
||||
{
|
||||
nsresult rv = nsDocument::StartDocumentLoad(aCommand,
|
||||
aChannel, aLoadGroup,
|
||||
aContainer,
|
||||
aDocListener, aReset, aSink);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (nsCRT::strcmp("loadAsInteractiveData", aCommand) == 0) {
|
||||
mLoadedAsInteractiveData = true;
|
||||
aCommand = kLoadAsData; // XBL, for example, needs scripts and styles
|
||||
}
|
||||
|
||||
|
||||
int32_t charsetSource = kCharsetFromDocTypeDefault;
|
||||
nsAutoCString charset(NS_LITERAL_CSTRING("UTF-8"));
|
||||
TryChannelCharset(aChannel, charsetSource, charset, nullptr);
|
||||
|
||||
nsCOMPtr<nsIURI> aUrl;
|
||||
rv = aChannel->GetURI(getter_AddRefs(aUrl));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID);
|
||||
|
||||
mParser = do_CreateInstance(kCParserCID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIXMLContentSink> sink;
|
||||
|
||||
if (aSink) {
|
||||
sink = do_QueryInterface(aSink);
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIDocShell> docShell;
|
||||
if (aContainer) {
|
||||
docShell = do_QueryInterface(aContainer);
|
||||
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
|
||||
}
|
||||
rv = NS_NewXMLContentSink(getter_AddRefs(sink), this, aUrl, docShell,
|
||||
aChannel);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
// Set the parser as the stream listener for the document loader...
|
||||
rv = CallQueryInterface(mParser, aDocListener);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
NS_ASSERTION(mChannel, "How can we not have a channel here?");
|
||||
mChannelIsPending = true;
|
||||
|
||||
SetDocumentCharacterSet(charset);
|
||||
mParser->SetDocumentCharset(charset, charsetSource);
|
||||
mParser->SetCommand(aCommand);
|
||||
mParser->SetContentSink(sink);
|
||||
mParser->Parse(aUrl, nullptr, (void *)this);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
XMLDocument::EndLoad()
|
||||
{
|
||||
mChannelIsPending = false;
|
||||
mLoopingForSyncLoad = false;
|
||||
|
||||
mSynchronousDOMContentLoaded = (mLoadedAsData || mLoadedAsInteractiveData);
|
||||
nsDocument::EndLoad();
|
||||
if (mSynchronousDOMContentLoaded) {
|
||||
mSynchronousDOMContentLoaded = false;
|
||||
nsDocument::SetReadyStateInternal(nsIDocument::READYSTATE_COMPLETE);
|
||||
// Generate a document load event for the case when an XML
|
||||
// document was loaded as pure data without any presentation
|
||||
// attached to it.
|
||||
WidgetEvent event(true, eLoad);
|
||||
EventDispatcher::Dispatch(static_cast<nsIDocument*>(this), nullptr, &event);
|
||||
}
|
||||
}
|
||||
|
||||
/* virtual */ void
|
||||
XMLDocument::DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const
|
||||
{
|
||||
nsDocument::DocAddSizeOfExcludingThis(aWindowSizes);
|
||||
}
|
||||
|
||||
// nsIDOMDocument interface
|
||||
|
||||
nsresult
|
||||
XMLDocument::Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const
|
||||
{
|
||||
NS_ASSERTION(aNodeInfo->NodeInfoManager() == mNodeInfoManager,
|
||||
"Can't import this document into another document!");
|
||||
|
||||
RefPtr<XMLDocument> clone = new XMLDocument();
|
||||
nsresult rv = CloneDocHelper(clone);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// State from XMLDocument
|
||||
clone->mAsync = mAsync;
|
||||
clone->mIsPlainDocument = mIsPlainDocument;
|
||||
|
||||
return CallQueryInterface(clone.get(), aResult);
|
||||
}
|
||||
|
||||
JSObject*
|
||||
XMLDocument::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
if (mIsPlainDocument) {
|
||||
return DocumentBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
return XMLDocumentBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
110
dom/xml/XMLDocument.h
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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_XMLDocument_h
|
||||
#define mozilla_dom_XMLDocument_h
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsDocument.h"
|
||||
#include "nsIDOMXMLDocument.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
||||
class nsIURI;
|
||||
class nsIChannel;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class XMLDocument : public nsDocument,
|
||||
public nsIDOMXMLDocument
|
||||
{
|
||||
public:
|
||||
explicit XMLDocument(const char* aContentType = "application/xml");
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
virtual void Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup) override;
|
||||
virtual void ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup,
|
||||
nsIPrincipal* aPrincipal) override;
|
||||
|
||||
virtual void SetSuppressParserErrorElement(bool aSuppress) override;
|
||||
virtual bool SuppressParserErrorElement() override;
|
||||
|
||||
virtual void SetSuppressParserErrorConsoleMessages(bool aSuppress) override;
|
||||
virtual bool SuppressParserErrorConsoleMessages() override;
|
||||
|
||||
virtual nsresult StartDocumentLoad(const char* aCommand, nsIChannel* channel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener,
|
||||
bool aReset = true,
|
||||
nsIContentSink* aSink = nullptr) override;
|
||||
|
||||
virtual void EndLoad() override;
|
||||
|
||||
// nsIDOMXMLDocument
|
||||
NS_DECL_NSIDOMXMLDOCUMENT
|
||||
|
||||
virtual nsresult Init() override;
|
||||
|
||||
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
|
||||
|
||||
virtual void DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const override;
|
||||
// DocAddSizeOfIncludingThis is inherited from nsIDocument.
|
||||
|
||||
|
||||
// WebIDL API
|
||||
bool Load(const nsAString& aUrl, mozilla::ErrorResult& aRv);
|
||||
bool Async() const
|
||||
{
|
||||
return mAsync;
|
||||
}
|
||||
void SetAsync(bool aAsync)
|
||||
{
|
||||
mAsync = aAsync;
|
||||
}
|
||||
|
||||
// .location is [Unforgeable], so we have to make it clear that the
|
||||
// nsIDocument version applies to us (it's shadowed by the XPCOM thing on
|
||||
// nsDocument).
|
||||
using nsIDocument::GetLocation;
|
||||
// But then we need to also pull in the nsDocument XPCOM version
|
||||
// because nsXULDocument tries to forward to it.
|
||||
using nsDocument::GetLocation;
|
||||
|
||||
protected:
|
||||
virtual ~XMLDocument();
|
||||
|
||||
virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
friend nsresult (::NS_NewXMLDocument)(nsIDocument**, bool, bool);
|
||||
|
||||
|
||||
// mChannelIsPending indicates whether we're currently asynchronously loading
|
||||
// data from mChannel (via document.load() or normal load). It's set to true
|
||||
// when we first find out about the channel (StartDocumentLoad) and set to
|
||||
// false in EndLoad or if ResetToURI() is called. In the latter case our
|
||||
// mChannel is also cancelled. Note that if this member is true, mChannel
|
||||
// cannot be null.
|
||||
bool mChannelIsPending;
|
||||
bool mAsync;
|
||||
bool mLoopingForSyncLoad;
|
||||
|
||||
// If true. we're really a Document, not an XMLDocument
|
||||
bool mIsPlainDocument;
|
||||
|
||||
// If true, do not output <parsererror> elements. Per spec, XMLHttpRequest
|
||||
// shouldn't output them, whereas DOMParser/others should (see bug 918703).
|
||||
bool mSuppressParserErrorElement;
|
||||
|
||||
// If true, do not log parsing errors to the web console (see bug 884693).
|
||||
bool mSuppressParserErrorConsoleMessages;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_XMLDocument_h
|
||||
196
dom/xml/XMLStylesheetProcessingInstruction.cpp
Normal file
|
|
@ -0,0 +1,196 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
#include "XMLStylesheetProcessingInstruction.h"
|
||||
#include "mozilla/dom/XMLStylesheetProcessingInstructionBinding.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
// nsISupports implementation
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(XMLStylesheetProcessingInstruction)
|
||||
NS_INTERFACE_TABLE_INHERITED(XMLStylesheetProcessingInstruction, nsIDOMNode,
|
||||
nsIDOMProcessingInstruction,
|
||||
nsIStyleSheetLinkingElement)
|
||||
NS_INTERFACE_TABLE_TAIL_INHERITING(ProcessingInstruction)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(XMLStylesheetProcessingInstruction,
|
||||
ProcessingInstruction)
|
||||
NS_IMPL_RELEASE_INHERITED(XMLStylesheetProcessingInstruction,
|
||||
ProcessingInstruction)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(XMLStylesheetProcessingInstruction)
|
||||
|
||||
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(XMLStylesheetProcessingInstruction,
|
||||
ProcessingInstruction)
|
||||
tmp->nsStyleLinkElement::Unlink();
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
|
||||
XMLStylesheetProcessingInstruction::~XMLStylesheetProcessingInstruction()
|
||||
{
|
||||
}
|
||||
|
||||
JSObject*
|
||||
XMLStylesheetProcessingInstruction::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
return XMLStylesheetProcessingInstructionBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
// nsIContent
|
||||
|
||||
nsresult
|
||||
XMLStylesheetProcessingInstruction::BindToTree(nsIDocument* aDocument,
|
||||
nsIContent* aParent,
|
||||
nsIContent* aBindingParent,
|
||||
bool aCompileEventHandlers)
|
||||
{
|
||||
nsresult rv = ProcessingInstruction::BindToTree(aDocument, aParent,
|
||||
aBindingParent,
|
||||
aCompileEventHandlers);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
void (XMLStylesheetProcessingInstruction::*update)() =
|
||||
&XMLStylesheetProcessingInstruction::UpdateStyleSheetInternal;
|
||||
nsContentUtils::AddScriptRunner(NewRunnableMethod(this, update));
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
XMLStylesheetProcessingInstruction::UnbindFromTree(bool aDeep, bool aNullParent)
|
||||
{
|
||||
nsCOMPtr<nsIDocument> oldDoc = GetUncomposedDoc();
|
||||
|
||||
ProcessingInstruction::UnbindFromTree(aDeep, aNullParent);
|
||||
UpdateStyleSheetInternal(oldDoc, nullptr);
|
||||
}
|
||||
|
||||
// nsIDOMNode
|
||||
|
||||
void
|
||||
XMLStylesheetProcessingInstruction::SetNodeValueInternal(const nsAString& aNodeValue,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
nsGenericDOMDataNode::SetNodeValueInternal(aNodeValue, aError);
|
||||
if (!aError.Failed()) {
|
||||
UpdateStyleSheetInternal(nullptr, nullptr, true);
|
||||
}
|
||||
}
|
||||
|
||||
// nsStyleLinkElement
|
||||
|
||||
NS_IMETHODIMP
|
||||
XMLStylesheetProcessingInstruction::GetCharset(nsAString& aCharset)
|
||||
{
|
||||
return GetAttrValue(nsGkAtoms::charset, aCharset) ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
/* virtual */ void
|
||||
XMLStylesheetProcessingInstruction::OverrideBaseURI(nsIURI* aNewBaseURI)
|
||||
{
|
||||
mOverriddenBaseURI = aNewBaseURI;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIURI>
|
||||
XMLStylesheetProcessingInstruction::GetStyleSheetURL(bool* aIsInline)
|
||||
{
|
||||
*aIsInline = false;
|
||||
|
||||
nsAutoString href;
|
||||
if (!GetAttrValue(nsGkAtoms::href, href)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsIURI *baseURL;
|
||||
nsAutoCString charset;
|
||||
nsIDocument *document = OwnerDoc();
|
||||
baseURL = mOverriddenBaseURI ?
|
||||
mOverriddenBaseURI.get() :
|
||||
document->GetDocBaseURI();
|
||||
charset = document->GetDocumentCharacterSet();
|
||||
|
||||
nsCOMPtr<nsIURI> aURI;
|
||||
NS_NewURI(getter_AddRefs(aURI), href, charset.get(), baseURL);
|
||||
return aURI.forget();
|
||||
}
|
||||
|
||||
void
|
||||
XMLStylesheetProcessingInstruction::GetStyleSheetInfo(nsAString& aTitle,
|
||||
nsAString& aType,
|
||||
nsAString& aMedia,
|
||||
bool* aIsScoped,
|
||||
bool* aIsAlternate)
|
||||
{
|
||||
aTitle.Truncate();
|
||||
aType.Truncate();
|
||||
aMedia.Truncate();
|
||||
*aIsScoped = false;
|
||||
*aIsAlternate = false;
|
||||
|
||||
// xml-stylesheet PI is special only in prolog
|
||||
if (!nsContentUtils::InProlog(this)) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsAutoString data;
|
||||
GetData(data);
|
||||
|
||||
nsContentUtils::GetPseudoAttributeValue(data, nsGkAtoms::title, aTitle);
|
||||
|
||||
nsAutoString alternate;
|
||||
nsContentUtils::GetPseudoAttributeValue(data,
|
||||
nsGkAtoms::alternate,
|
||||
alternate);
|
||||
|
||||
// if alternate, does it have title?
|
||||
if (alternate.EqualsLiteral("yes")) {
|
||||
if (aTitle.IsEmpty()) { // alternates must have title
|
||||
return;
|
||||
}
|
||||
|
||||
*aIsAlternate = true;
|
||||
}
|
||||
|
||||
nsContentUtils::GetPseudoAttributeValue(data, nsGkAtoms::media, aMedia);
|
||||
|
||||
nsAutoString type;
|
||||
nsContentUtils::GetPseudoAttributeValue(data, nsGkAtoms::type, type);
|
||||
|
||||
nsAutoString mimeType, notUsed;
|
||||
nsContentUtils::SplitMimeType(type, mimeType, notUsed);
|
||||
if (!mimeType.IsEmpty() && !mimeType.LowerCaseEqualsLiteral("text/css")) {
|
||||
aType.Assign(type);
|
||||
return;
|
||||
}
|
||||
|
||||
// If we get here we assume that we're loading a css file, so set the
|
||||
// type to 'text/css'
|
||||
aType.AssignLiteral("text/css");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
nsGenericDOMDataNode*
|
||||
XMLStylesheetProcessingInstruction::CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo,
|
||||
bool aCloneText) const
|
||||
{
|
||||
nsAutoString data;
|
||||
nsGenericDOMDataNode::GetData(data);
|
||||
RefPtr<mozilla::dom::NodeInfo> ni = aNodeInfo;
|
||||
return new XMLStylesheetProcessingInstruction(ni.forget(), data);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
93
dom/xml/XMLStylesheetProcessingInstruction.h
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/Attributes.h"
|
||||
#include "mozilla/dom/ProcessingInstruction.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsStyleLinkElement.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class XMLStylesheetProcessingInstruction final
|
||||
: public ProcessingInstruction
|
||||
, public nsStyleLinkElement
|
||||
{
|
||||
public:
|
||||
XMLStylesheetProcessingInstruction(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
||||
const nsAString& aData)
|
||||
: ProcessingInstruction(Move(aNodeInfo), aData)
|
||||
{
|
||||
}
|
||||
|
||||
XMLStylesheetProcessingInstruction(nsNodeInfoManager* aNodeInfoManager,
|
||||
const nsAString& aData)
|
||||
: ProcessingInstruction(aNodeInfoManager->GetNodeInfo(
|
||||
nsGkAtoms::processingInstructionTagName,
|
||||
nullptr, kNameSpaceID_None,
|
||||
nsIDOMNode::PROCESSING_INSTRUCTION_NODE,
|
||||
nsGkAtoms::xml_stylesheet), aData)
|
||||
{
|
||||
}
|
||||
|
||||
virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// CC
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XMLStylesheetProcessingInstruction,
|
||||
ProcessingInstruction)
|
||||
|
||||
// nsIDOMNode
|
||||
virtual void SetNodeValueInternal(const nsAString& aNodeValue,
|
||||
mozilla::ErrorResult& aError) override;
|
||||
|
||||
// nsIContent
|
||||
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||
nsIContent* aBindingParent,
|
||||
bool aCompileEventHandlers) override;
|
||||
virtual void UnbindFromTree(bool aDeep = true,
|
||||
bool aNullParent = true) override;
|
||||
|
||||
// nsIStyleSheetLinkingElement
|
||||
virtual void OverrideBaseURI(nsIURI* aNewBaseURI) override;
|
||||
|
||||
// nsStyleLinkElement
|
||||
NS_IMETHOD GetCharset(nsAString& aCharset) override;
|
||||
|
||||
virtual void SetData(const nsAString& aData, mozilla::ErrorResult& rv) override
|
||||
{
|
||||
nsGenericDOMDataNode::SetData(aData, rv);
|
||||
if (rv.Failed()) {
|
||||
return;
|
||||
}
|
||||
UpdateStyleSheetInternal(nullptr, nullptr, true);
|
||||
}
|
||||
using ProcessingInstruction::SetData; // Prevent hiding overloaded virtual function.
|
||||
|
||||
protected:
|
||||
virtual ~XMLStylesheetProcessingInstruction();
|
||||
|
||||
nsCOMPtr<nsIURI> mOverriddenBaseURI;
|
||||
|
||||
already_AddRefed<nsIURI> GetStyleSheetURL(bool* aIsInline) override;
|
||||
void GetStyleSheetInfo(nsAString& aTitle,
|
||||
nsAString& aType,
|
||||
nsAString& aMedia,
|
||||
bool* aIsScoped,
|
||||
bool* aIsAlternate) override;
|
||||
virtual nsGenericDOMDataNode* CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo,
|
||||
bool aCloneText) const override;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_XMLStylesheetProcessingInstruction_h
|
||||
1
dom/xml/crashtests/1038887.xhtml
Normal file
|
|
@ -0,0 +1 @@
|
|||
<?xml-stylesheet type="text/xsl" href="http://notexistingurl"?><html xmlns="http://www.w3.org/1999/xhtml"></html>
|
||||
62
dom/xml/crashtests/136896-1.xml
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
<?xml version="1.0" standalone="yes"?>
|
||||
<!DOCTYPE SITES
|
||||
[
|
||||
<!ELEMENT SITES (VERSION, SITE+)>
|
||||
<!ELEMENT VERSION (#PCDATA)>
|
||||
<!ELEMENT SITE (ID, NAME, MAXADDR, MAXALIASES, MAXQUOTA, TYPE, DOMAINS?, USERS?, ALIASES?)>
|
||||
<!ELEMENT DOMAINS (DOMAIN*)>
|
||||
<!ELEMENT DOMAIN (#PCDATA)>
|
||||
|
||||
<!ELEMENT USERS (USER*)>
|
||||
<!ELEMENT USER (ID, NAME, ROA, ROC, QUOTA, TYPE)>
|
||||
|
||||
<!ELEMENT ALIASES (ALIAS*)>
|
||||
<!ELEMENT ALIAS (LEFTPART, RIGHTPART)>
|
||||
|
||||
<!ELEMENT ID (#PCDATA)>
|
||||
<!ELEMENT NAME (#PCDATA)>
|
||||
<!ELEMENT MAXADDR (#PCDATA)>
|
||||
<!ELEMENT MAXALIASES (#PCDATA)>
|
||||
<!ELEMENT MAXQUOTA (#PCDATA)>
|
||||
<!ELEMENT TYPE (#PCDATA)>
|
||||
|
||||
<!ELEMENT ROA (#PCDATA)>
|
||||
<!ELEMENT ROC (#PCDATA)>
|
||||
<!ELEMENT QUOTA (#PCDATA)>
|
||||
|
||||
<!ELEMENT LEFTPART (#PCDATA)>
|
||||
<!ELEMENT RIGHTPART (#PCDATA)>
|
||||
]
|
||||
>
|
||||
<SITES>
|
||||
<VERSION>1</VERSION>
|
||||
<SITE>
|
||||
<ID>60</ID>
|
||||
<NAME>abtauchen</NAME>
|
||||
<MAXADDR>1</MAXADDR>
|
||||
<MAXALIASES>1</MAXALIASES>
|
||||
<MAXQUOTA>10240</MAXQUOTA>
|
||||
<TYPE>p</TYPE>
|
||||
<DOMAINS>
|
||||
<DOMAIN>abtauchen.at</DOMAIN>
|
||||
<DOMAIN>abtauchen.com</DOMAIN>
|
||||
<DOMAIN>abtauchen.net</DOMAIN>
|
||||
</DOMAINS>
|
||||
<USERS>
|
||||
<USER>
|
||||
<ID>83</ID>
|
||||
<NAME>info</NAME>
|
||||
<ROA>y</ROA>
|
||||
<ROC>n</ROC>
|
||||
<QUOTA>10240</QUOTA>
|
||||
<TYPE>p</TYPE>
|
||||
</USER>
|
||||
</USERS>
|
||||
<ALIASES>
|
||||
<ALIAS>
|
||||
<LEFTPART>*</LEFTPART>
|
||||
<RIGHTPART>info</RIGHTPART>
|
||||
</ALIAS>
|
||||
</ALIASES>
|
||||
</SITE>
|
||||
</SITES>
|
||||
2
dom/xml/crashtests/185285-1.xml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<link xmlns="http://www.w3.org/1999/xhtml" href="some.css" rel="stylesheet" />
|
||||
<x />
|
||||
9
dom/xml/crashtests/382636-1.xml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
</head>
|
||||
<body onload="document.cloneNode(true);">
|
||||
|
||||
<img src="tree.gif" />
|
||||
|
||||
</body>
|
||||
</html>
|
||||
5
dom/xml/crashtests/382636-2.svg
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" onload="document.cloneNode(true);">
|
||||
|
||||
<image xlink:href="tree.gif" width="49" height="60" />
|
||||
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 183 B |
9
dom/xml/crashtests/382636-3.xhtml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
</head>
|
||||
<body onload="document.cloneNode(true);">
|
||||
|
||||
<img src="tree.gif" />
|
||||
|
||||
</body>
|
||||
</html>
|
||||
5
dom/xml/crashtests/382636-4.xul
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="try { document.cloneNode(true); } catch (e) { }">
|
||||
|
||||
<image src="tree.gif" width="49" height="60" flex="none" />
|
||||
|
||||
</window>
|
||||
18
dom/xml/crashtests/420429.xul
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="boom();">
|
||||
|
||||
<?xml-stylesheet?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
function boom()
|
||||
{
|
||||
window.addEventListener("DOMCharacterDataModified", function(){}, false);
|
||||
document.documentElement.cloneNode(true).getElementsByTagName("*").length;
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</window>
|
||||
17
dom/xml/crashtests/431703-1.xhtml
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<script>
|
||||
<![CDATA[
|
||||
|
||||
function boom()
|
||||
{
|
||||
document.body.innerHTML = '<circle xmlns="http://www.w3.org/2000/svg" onload=""/>';
|
||||
}
|
||||
|
||||
]]>
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body onload="boom();"></body>
|
||||
|
||||
</html>
|
||||
3
dom/xml/crashtests/453278-frame.xml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<xml xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<xml xlink:href="#" xlink:actuate="onLoad" xlink:type="simple"/>
|
||||
</xml>
|
||||
9
dom/xml/crashtests/453278.html
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<title> Bug 453278 - Crash [@ nsContentUtils::TriggerLink] with xlink stuff in display: none iframe</title><style>
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<iframe id="content" src="453278-frame.xml" style="display: none;"></iframe>
|
||||
</body>
|
||||
</html>
|
||||
8
dom/xml/crashtests/803586.xhtml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<?xml-stylesheet href="foo.css" ?>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<script>
|
||||
document.firstChild.nodeValue = null
|
||||
</script>
|
||||
</head>
|
||||
</html>
|
||||
15
dom/xml/crashtests/994740-1.xhtml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<script>
|
||||
<![CDATA[
|
||||
|
||||
function boom()
|
||||
{
|
||||
document.createElement("head").innerHTML = "<";
|
||||
}
|
||||
|
||||
]]>
|
||||
</script></head>
|
||||
|
||||
<body onload="boom();"></body>
|
||||
</html>
|
||||
12
dom/xml/crashtests/crashtests.list
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
load 136896-1.xml
|
||||
load 185285-1.xml
|
||||
load 382636-1.xml
|
||||
load 382636-2.svg
|
||||
load 382636-3.xhtml
|
||||
load 382636-4.xul # Throws (bug 455856)
|
||||
load 420429.xul
|
||||
load 431703-1.xhtml
|
||||
load 453278.html
|
||||
load 803586.xhtml
|
||||
load 994740-1.xhtml
|
||||
load 1038887.xhtml
|
||||
BIN
dom/xml/crashtests/tree.gif
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
2164
dom/xml/htmlmathml-f.ent
Normal file
46
dom/xml/moz.build
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# 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/.
|
||||
|
||||
DIRS += ['resources']
|
||||
|
||||
MOCHITEST_MANIFESTS += ['test/mochitest.ini']
|
||||
|
||||
EXPORTS += [
|
||||
'nsIXMLContentSink.h',
|
||||
]
|
||||
|
||||
EXPORTS.mozilla.dom += [
|
||||
'CDATASection.h',
|
||||
'nsXMLElement.h',
|
||||
'ProcessingInstruction.h',
|
||||
'XMLDocument.h',
|
||||
'XMLStylesheetProcessingInstruction.h',
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'CDATASection.cpp',
|
||||
'nsXMLContentSink.cpp',
|
||||
'nsXMLElement.cpp',
|
||||
'nsXMLFragmentContentSink.cpp',
|
||||
'nsXMLPrettyPrinter.cpp',
|
||||
'ProcessingInstruction.cpp',
|
||||
'XMLDocument.cpp',
|
||||
'XMLStylesheetProcessingInstruction.cpp',
|
||||
]
|
||||
|
||||
FINAL_LIBRARY = 'xul'
|
||||
|
||||
LOCAL_INCLUDES += [
|
||||
'/caps',
|
||||
'/dom/base',
|
||||
'/dom/html',
|
||||
'/dom/xul',
|
||||
'/layout/style',
|
||||
]
|
||||
|
||||
RESOURCE_FILES.dtd += [
|
||||
'htmlmathml-f.ent',
|
||||
]
|
||||
57
dom/xml/nsIXMLContentSink.h
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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 nsIXMLContentSink_h___
|
||||
#define nsIXMLContentSink_h___
|
||||
|
||||
#include "nsIContentSink.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIDocument;
|
||||
class nsIURI;
|
||||
class nsIChannel;
|
||||
|
||||
#define NS_IXMLCONTENT_SINK_IID \
|
||||
{ 0x63fedea0, 0x9b0f, 0x4d64, \
|
||||
{ 0x9b, 0xa5, 0x37, 0xc6, 0x99, 0x73, 0x29, 0x35 } }
|
||||
|
||||
/**
|
||||
* This interface represents a content sink for generic XML files.
|
||||
* The goal of this sink is to deal with XML documents that do not
|
||||
* have pre-built semantics, though it may also be implemented for
|
||||
* cases in which semantics are hard-wired.
|
||||
*
|
||||
* The expectation is that the parser has already performed
|
||||
* well-formedness and validity checking.
|
||||
*
|
||||
* XXX The expectation is that entity expansion will be done by the sink
|
||||
* itself. This would require, however, that the sink has the ability
|
||||
* to query the parser for entity replacement text.
|
||||
*
|
||||
* XXX This interface does not contain a mechanism for the sink to
|
||||
* get specific schema/DTD information from the parser. This information
|
||||
* may be necessary for entity expansion. It is also necessary for
|
||||
* building the DOM portions that relate to the schema.
|
||||
*
|
||||
* XXX This interface does not deal with the presence of an external
|
||||
* subset. It seems possible that this could be dealt with completely
|
||||
* at the parser level.
|
||||
*/
|
||||
|
||||
class nsIXMLContentSink : public nsIContentSink {
|
||||
public:
|
||||
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IXMLCONTENT_SINK_IID)
|
||||
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIXMLContentSink, NS_IXMLCONTENT_SINK_IID)
|
||||
|
||||
nsresult
|
||||
NS_NewXMLContentSink(nsIXMLContentSink** aInstancePtrResult, nsIDocument* aDoc,
|
||||
nsIURI* aURL, nsISupports* aContainer,
|
||||
nsIChannel *aChannel);
|
||||
|
||||
#endif // nsIXMLContentSink_h___
|
||||
1590
dom/xml/nsXMLContentSink.cpp
Normal file
204
dom/xml/nsXMLContentSink.h
Normal file
|
|
@ -0,0 +1,204 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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 nsXMLContentSink_h__
|
||||
#define nsXMLContentSink_h__
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsContentSink.h"
|
||||
#include "nsIXMLContentSink.h"
|
||||
#include "nsIExpatSink.h"
|
||||
#include "nsIDocumentTransformer.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsIDTD.h"
|
||||
#include "mozilla/dom/FromParser.h"
|
||||
|
||||
class nsIDocument;
|
||||
class nsIURI;
|
||||
class nsIContent;
|
||||
class nsIParser;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class NodeInfo;
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
typedef enum {
|
||||
eXMLContentSinkState_InProlog,
|
||||
eXMLContentSinkState_InDocumentElement,
|
||||
eXMLContentSinkState_InEpilog
|
||||
} XMLContentSinkState;
|
||||
|
||||
struct StackNode {
|
||||
nsCOMPtr<nsIContent> mContent;
|
||||
uint32_t mNumFlushed;
|
||||
};
|
||||
|
||||
class nsXMLContentSink : public nsContentSink,
|
||||
public nsIXMLContentSink,
|
||||
public nsITransformObserver,
|
||||
public nsIExpatSink
|
||||
{
|
||||
public:
|
||||
nsXMLContentSink();
|
||||
|
||||
nsresult Init(nsIDocument* aDoc,
|
||||
nsIURI* aURL,
|
||||
nsISupports* aContainer,
|
||||
nsIChannel* aChannel);
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(nsXMLContentSink,
|
||||
nsContentSink)
|
||||
|
||||
NS_DECL_NSIEXPATSINK
|
||||
|
||||
// nsIContentSink
|
||||
NS_IMETHOD WillParse(void) override;
|
||||
NS_IMETHOD WillBuildModel(nsDTDMode aDTDMode) override;
|
||||
NS_IMETHOD DidBuildModel(bool aTerminated) override;
|
||||
NS_IMETHOD WillInterrupt(void) override;
|
||||
NS_IMETHOD WillResume(void) override;
|
||||
NS_IMETHOD SetParser(nsParserBase* aParser) override;
|
||||
virtual void FlushPendingNotifications(mozFlushType aType) override;
|
||||
NS_IMETHOD SetDocumentCharset(nsACString& aCharset) override;
|
||||
virtual nsISupports *GetTarget() override;
|
||||
virtual bool IsScriptExecuting() override;
|
||||
virtual void ContinueInterruptedParsingAsync() override;
|
||||
|
||||
// nsITransformObserver
|
||||
NS_IMETHOD OnDocumentCreated(nsIDocument *aResultDocument) override;
|
||||
NS_IMETHOD OnTransformDone(nsresult aResult, nsIDocument *aResultDocument) override;
|
||||
|
||||
// nsICSSLoaderObserver
|
||||
NS_IMETHOD StyleSheetLoaded(mozilla::StyleSheet* aSheet,
|
||||
bool aWasAlternate,
|
||||
nsresult aStatus) override;
|
||||
static bool ParsePIData(const nsString &aData, nsString &aHref,
|
||||
nsString &aTitle, nsString &aMedia,
|
||||
bool &aIsAlternate);
|
||||
|
||||
protected:
|
||||
virtual ~nsXMLContentSink();
|
||||
|
||||
nsIParser* GetParser();
|
||||
|
||||
void ContinueInterruptedParsingIfEnabled();
|
||||
|
||||
// Start layout. If aIgnorePendingSheets is true, this will happen even if
|
||||
// we still have stylesheet loads pending. Otherwise, we'll wait until the
|
||||
// stylesheets are all done loading.
|
||||
virtual void MaybeStartLayout(bool aIgnorePendingSheets);
|
||||
|
||||
virtual nsresult AddAttributes(const char16_t** aNode, nsIContent* aContent);
|
||||
nsresult AddText(const char16_t* aString, int32_t aLength);
|
||||
|
||||
virtual bool OnOpenContainer(const char16_t **aAtts,
|
||||
uint32_t aAttsCount,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aTagName,
|
||||
uint32_t aLineNumber) { return true; }
|
||||
// Set the given content as the root element for the created document
|
||||
// don't set if root element was already set.
|
||||
// return TRUE if this call set the root element
|
||||
virtual bool SetDocElement(int32_t aNameSpaceID,
|
||||
nsIAtom *aTagName,
|
||||
nsIContent *aContent);
|
||||
virtual bool NotifyForDocElement() { return true; }
|
||||
virtual nsresult CreateElement(const char16_t** aAtts, uint32_t aAttsCount,
|
||||
mozilla::dom::NodeInfo* aNodeInfo, uint32_t aLineNumber,
|
||||
nsIContent** aResult, bool* aAppendContent,
|
||||
mozilla::dom::FromParser aFromParser);
|
||||
|
||||
// aParent is allowed to be null here if this is the root content
|
||||
// being closed
|
||||
virtual nsresult CloseElement(nsIContent* aContent);
|
||||
|
||||
virtual nsresult FlushText(bool aReleaseTextNode = true);
|
||||
|
||||
nsresult AddContentAsLeaf(nsIContent *aContent);
|
||||
|
||||
nsIContent* GetCurrentContent();
|
||||
StackNode* GetCurrentStackNode();
|
||||
nsresult PushContent(nsIContent *aContent);
|
||||
void PopContent();
|
||||
bool HaveNotifiedForCurrentContent() const;
|
||||
|
||||
nsresult FlushTags() override;
|
||||
|
||||
void UpdateChildCounts() override;
|
||||
|
||||
void DidAddContent()
|
||||
{
|
||||
if (!mXSLTProcessor && IsTimeToNotify()) {
|
||||
FlushTags();
|
||||
}
|
||||
}
|
||||
|
||||
// nsContentSink override
|
||||
virtual nsresult ProcessStyleLink(nsIContent* aElement,
|
||||
const nsSubstring& aHref,
|
||||
bool aAlternate,
|
||||
const nsSubstring& aTitle,
|
||||
const nsSubstring& aType,
|
||||
const nsSubstring& aMedia) override;
|
||||
|
||||
nsresult LoadXSLStyleSheet(nsIURI* aUrl);
|
||||
|
||||
bool CanStillPrettyPrint();
|
||||
|
||||
nsresult MaybePrettyPrint();
|
||||
|
||||
bool IsMonolithicContainer(mozilla::dom::NodeInfo* aNodeInfo);
|
||||
|
||||
nsresult HandleStartElement(const char16_t *aName, const char16_t **aAtts,
|
||||
uint32_t aAttsCount, uint32_t aLineNumber,
|
||||
bool aInterruptable);
|
||||
nsresult HandleEndElement(const char16_t *aName, bool aInterruptable);
|
||||
nsresult HandleCharacterData(const char16_t *aData, uint32_t aLength,
|
||||
bool aInterruptable);
|
||||
|
||||
nsCOMPtr<nsIContent> mDocElement;
|
||||
nsCOMPtr<nsIContent> mCurrentHead; // When set, we're in an XHTML <haed>
|
||||
|
||||
XMLContentSinkState mState;
|
||||
|
||||
// The length of the valid data in mText.
|
||||
int32_t mTextLength;
|
||||
|
||||
int32_t mNotifyLevel;
|
||||
nsCOMPtr<nsIContent> mLastTextNode;
|
||||
|
||||
uint8_t mPrettyPrintXML : 1;
|
||||
uint8_t mPrettyPrintHasSpecialRoot : 1;
|
||||
uint8_t mPrettyPrintHasFactoredElements : 1;
|
||||
uint8_t mPrettyPrinting : 1; // True if we called PrettyPrint() and it
|
||||
// decided we should in fact prettyprint.
|
||||
// True to call prevent script execution in the fragment mode.
|
||||
uint8_t mPreventScriptExecution : 1;
|
||||
|
||||
nsTArray<StackNode> mContentStack;
|
||||
|
||||
nsCOMPtr<nsIDocumentTransformer> mXSLTProcessor;
|
||||
|
||||
// Holds the children in the prolog until the root element is added, after which they're
|
||||
// inserted in the document. However, if we're doing an XSLT transform this will
|
||||
// actually hold all the children of the source document, until the transform is
|
||||
// finished. After the transform is finished we'll just discard the children.
|
||||
nsTArray<nsCOMPtr<nsIContent>> mDocumentChildren;
|
||||
|
||||
static const int NS_ACCUMULATION_BUFFER_SIZE = 4096;
|
||||
// Our currently accumulated text that we have not flushed to a textnode yet.
|
||||
char16_t mText[NS_ACCUMULATION_BUFFER_SIZE];
|
||||
};
|
||||
|
||||
#endif // nsXMLContentSink_h__
|
||||
32
dom/xml/nsXMLElement.cpp
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
#include "nsXMLElement.h"
|
||||
#include "mozilla/dom/ElementBinding.h"
|
||||
#include "mozilla/dom/ElementInlines.h"
|
||||
#include "nsContentUtils.h" // nsAutoScriptBlocker
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
||||
nsresult
|
||||
NS_NewXMLElement(Element** aInstancePtrResult,
|
||||
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
|
||||
{
|
||||
nsXMLElement* it = new nsXMLElement(aNodeInfo);
|
||||
NS_ADDREF(*aInstancePtrResult = it);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(nsXMLElement, Element,
|
||||
nsIDOMNode, nsIDOMElement)
|
||||
|
||||
JSObject*
|
||||
nsXMLElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
return ElementBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
NS_IMPL_ELEMENT_CLONE(nsXMLElement)
|
||||
44
dom/xml/nsXMLElement.h
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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 nsXMLElement_h___
|
||||
#define nsXMLElement_h___
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "mozilla/dom/ElementInlines.h"
|
||||
#include "mozilla/dom/DOMRect.h"
|
||||
|
||||
class nsXMLElement : public mozilla::dom::Element,
|
||||
public nsIDOMElement
|
||||
{
|
||||
public:
|
||||
explicit nsXMLElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
||||
: mozilla::dom::Element(aNodeInfo)
|
||||
{
|
||||
}
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIDOMNode
|
||||
NS_FORWARD_NSIDOMNODE_TO_NSINODE
|
||||
|
||||
// nsIDOMElement
|
||||
NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
|
||||
|
||||
// nsINode interface methods
|
||||
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
|
||||
|
||||
virtual nsIDOMNode* AsDOMNode() override { return this; }
|
||||
|
||||
protected:
|
||||
virtual ~nsXMLElement() {}
|
||||
|
||||
virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
};
|
||||
|
||||
#endif // nsXMLElement_h___
|
||||
431
dom/xml/nsXMLFragmentContentSink.cpp
Normal file
|
|
@ -0,0 +1,431 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsXMLContentSink.h"
|
||||
#include "nsIFragmentContentSink.h"
|
||||
#include "nsIXMLContentSink.h"
|
||||
#include "nsContentSink.h"
|
||||
#include "nsIExpatSink.h"
|
||||
#include "nsIDTD.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMDocumentFragment.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "mozilla/dom/NodeInfo.h"
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
#include "nsError.h"
|
||||
#include "nsIConsoleService.h"
|
||||
#include "nsIScriptError.h"
|
||||
#include "nsTHashtable.h"
|
||||
#include "nsHashKeys.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsScriptLoader.h"
|
||||
#include "mozilla/css/Loader.h"
|
||||
#include "mozilla/dom/DocumentFragment.h"
|
||||
#include "mozilla/dom/ProcessingInstruction.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
||||
class nsXMLFragmentContentSink : public nsXMLContentSink,
|
||||
public nsIFragmentContentSink
|
||||
{
|
||||
public:
|
||||
nsXMLFragmentContentSink();
|
||||
|
||||
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(nsXMLFragmentContentSink,
|
||||
nsXMLContentSink)
|
||||
|
||||
// nsIExpatSink
|
||||
NS_IMETHOD HandleDoctypeDecl(const nsAString& aSubset,
|
||||
const nsAString& aName,
|
||||
const nsAString& aSystemId,
|
||||
const nsAString& aPublicId,
|
||||
nsISupports* aCatalogData) override;
|
||||
NS_IMETHOD HandleProcessingInstruction(const char16_t* aTarget,
|
||||
const char16_t* aData) override;
|
||||
NS_IMETHOD HandleXMLDeclaration(const char16_t* aVersion,
|
||||
const char16_t* aEncoding,
|
||||
int32_t aStandalone) override;
|
||||
NS_IMETHOD ReportError(const char16_t* aErrorText,
|
||||
const char16_t* aSourceText,
|
||||
nsIScriptError* aError,
|
||||
bool* aRetval) override;
|
||||
|
||||
// nsIContentSink
|
||||
NS_IMETHOD WillBuildModel(nsDTDMode aDTDMode) override;
|
||||
NS_IMETHOD DidBuildModel(bool aTerminated) override;
|
||||
NS_IMETHOD SetDocumentCharset(nsACString& aCharset) override;
|
||||
virtual nsISupports* GetTarget() override;
|
||||
NS_IMETHOD DidProcessATokenImpl();
|
||||
|
||||
// nsIXMLContentSink
|
||||
|
||||
// nsIFragmentContentSink
|
||||
NS_IMETHOD FinishFragmentParsing(nsIDOMDocumentFragment** aFragment) override;
|
||||
NS_IMETHOD SetTargetDocument(nsIDocument* aDocument) override;
|
||||
NS_IMETHOD WillBuildContent() override;
|
||||
NS_IMETHOD DidBuildContent() override;
|
||||
NS_IMETHOD IgnoreFirstContainer() override;
|
||||
NS_IMETHOD SetPreventScriptExecution(bool aPreventScriptExecution) override;
|
||||
|
||||
protected:
|
||||
virtual ~nsXMLFragmentContentSink();
|
||||
|
||||
virtual bool SetDocElement(int32_t aNameSpaceID,
|
||||
nsIAtom* aTagName,
|
||||
nsIContent* aContent) override;
|
||||
virtual nsresult CreateElement(const char16_t** aAtts, uint32_t aAttsCount,
|
||||
mozilla::dom::NodeInfo* aNodeInfo, uint32_t aLineNumber,
|
||||
nsIContent** aResult, bool* aAppendContent,
|
||||
mozilla::dom::FromParser aFromParser) override;
|
||||
virtual nsresult CloseElement(nsIContent* aContent) override;
|
||||
|
||||
virtual void MaybeStartLayout(bool aIgnorePendingSheets) override;
|
||||
|
||||
// nsContentSink overrides
|
||||
virtual nsresult ProcessStyleLink(nsIContent* aElement,
|
||||
const nsSubstring& aHref,
|
||||
bool aAlternate,
|
||||
const nsSubstring& aTitle,
|
||||
const nsSubstring& aType,
|
||||
const nsSubstring& aMedia) override;
|
||||
nsresult LoadXSLStyleSheet(nsIURI* aUrl);
|
||||
void StartLayout();
|
||||
|
||||
nsCOMPtr<nsIDocument> mTargetDocument;
|
||||
// the fragment
|
||||
nsCOMPtr<nsIContent> mRoot;
|
||||
bool mParseError;
|
||||
};
|
||||
|
||||
static nsresult
|
||||
NewXMLFragmentContentSinkHelper(nsIFragmentContentSink** aResult)
|
||||
{
|
||||
nsXMLFragmentContentSink* it = new nsXMLFragmentContentSink();
|
||||
|
||||
NS_ADDREF(*aResult = it);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewXMLFragmentContentSink(nsIFragmentContentSink** aResult)
|
||||
{
|
||||
return NewXMLFragmentContentSinkHelper(aResult);
|
||||
}
|
||||
|
||||
nsXMLFragmentContentSink::nsXMLFragmentContentSink()
|
||||
: mParseError(false)
|
||||
{
|
||||
mRunsToCompletion = true;
|
||||
}
|
||||
|
||||
nsXMLFragmentContentSink::~nsXMLFragmentContentSink()
|
||||
{
|
||||
}
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsXMLFragmentContentSink)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIFragmentContentSink)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsXMLContentSink)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsXMLFragmentContentSink, nsXMLContentSink)
|
||||
NS_IMPL_RELEASE_INHERITED(nsXMLFragmentContentSink, nsXMLContentSink)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(nsXMLFragmentContentSink)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsXMLFragmentContentSink,
|
||||
nsXMLContentSink)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTargetDocument)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRoot)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLFragmentContentSink::WillBuildModel(nsDTDMode aDTDMode)
|
||||
{
|
||||
if (mRoot) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mState = eXMLContentSinkState_InDocumentElement;
|
||||
|
||||
NS_ASSERTION(mTargetDocument, "Need a document!");
|
||||
|
||||
mRoot = new DocumentFragment(mNodeInfoManager);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLFragmentContentSink::DidBuildModel(bool aTerminated)
|
||||
{
|
||||
// Drop our reference to the parser to get rid of a circular
|
||||
// reference.
|
||||
mParser = nullptr;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLFragmentContentSink::SetDocumentCharset(nsACString& aCharset)
|
||||
{
|
||||
NS_NOTREACHED("fragments shouldn't set charset");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsISupports *
|
||||
nsXMLFragmentContentSink::GetTarget()
|
||||
{
|
||||
return mTargetDocument;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool
|
||||
nsXMLFragmentContentSink::SetDocElement(int32_t aNameSpaceID,
|
||||
nsIAtom* aTagName,
|
||||
nsIContent *aContent)
|
||||
{
|
||||
// this is a fragment, not a document
|
||||
return false;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXMLFragmentContentSink::CreateElement(const char16_t** aAtts, uint32_t aAttsCount,
|
||||
mozilla::dom::NodeInfo* aNodeInfo, uint32_t aLineNumber,
|
||||
nsIContent** aResult, bool* aAppendContent,
|
||||
FromParser /*aFromParser*/)
|
||||
{
|
||||
// Claim to not be coming from parser, since we don't do any of the
|
||||
// fancy CloseElement stuff.
|
||||
nsresult rv = nsXMLContentSink::CreateElement(aAtts, aAttsCount,
|
||||
aNodeInfo, aLineNumber,
|
||||
aResult, aAppendContent,
|
||||
NOT_FROM_PARSER);
|
||||
|
||||
// When we aren't grabbing all of the content we, never open a doc
|
||||
// element, we run into trouble on the first element, so we don't append,
|
||||
// and simply push this onto the content stack.
|
||||
if (mContentStack.Length() == 0) {
|
||||
*aAppendContent = false;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXMLFragmentContentSink::CloseElement(nsIContent* aContent)
|
||||
{
|
||||
// don't do fancy stuff in nsXMLContentSink
|
||||
if (mPreventScriptExecution &&
|
||||
(aContent->IsHTMLElement(nsGkAtoms::script) ||
|
||||
aContent->IsSVGElement(nsGkAtoms::script))) {
|
||||
nsCOMPtr<nsIScriptElement> sele = do_QueryInterface(aContent);
|
||||
NS_ASSERTION(sele, "script did QI correctly!");
|
||||
sele->PreventExecution();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsXMLFragmentContentSink::MaybeStartLayout(bool aIgnorePendingSheets)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLFragmentContentSink::HandleDoctypeDecl(const nsAString & aSubset,
|
||||
const nsAString & aName,
|
||||
const nsAString & aSystemId,
|
||||
const nsAString & aPublicId,
|
||||
nsISupports* aCatalogData)
|
||||
{
|
||||
NS_NOTREACHED("fragments shouldn't have doctype declarations");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLFragmentContentSink::HandleProcessingInstruction(const char16_t *aTarget,
|
||||
const char16_t *aData)
|
||||
{
|
||||
FlushText();
|
||||
|
||||
const nsDependentString target(aTarget);
|
||||
const nsDependentString data(aData);
|
||||
|
||||
RefPtr<ProcessingInstruction> node =
|
||||
NS_NewXMLProcessingInstruction(mNodeInfoManager, target, data);
|
||||
|
||||
// no special processing here. that should happen when the fragment moves into the document
|
||||
return AddContentAsLeaf(node);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLFragmentContentSink::HandleXMLDeclaration(const char16_t *aVersion,
|
||||
const char16_t *aEncoding,
|
||||
int32_t aStandalone)
|
||||
{
|
||||
NS_NOTREACHED("fragments shouldn't have XML declarations");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLFragmentContentSink::ReportError(const char16_t* aErrorText,
|
||||
const char16_t* aSourceText,
|
||||
nsIScriptError *aError,
|
||||
bool *_retval)
|
||||
{
|
||||
NS_PRECONDITION(aError && aSourceText && aErrorText, "Check arguments!!!");
|
||||
|
||||
// The expat driver should report the error.
|
||||
*_retval = true;
|
||||
|
||||
mParseError = true;
|
||||
|
||||
#ifdef DEBUG
|
||||
// Report the error to stderr.
|
||||
fprintf(stderr,
|
||||
"\n%s\n%s\n\n",
|
||||
NS_LossyConvertUTF16toASCII(aErrorText).get(),
|
||||
NS_LossyConvertUTF16toASCII(aSourceText).get());
|
||||
#endif
|
||||
|
||||
// The following code is similar to the cleanup in nsXMLContentSink::ReportError()
|
||||
mState = eXMLContentSinkState_InProlog;
|
||||
|
||||
// Clear the current content
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(mRoot));
|
||||
if (node) {
|
||||
for (;;) {
|
||||
nsCOMPtr<nsIDOMNode> child, dummy;
|
||||
node->GetLastChild(getter_AddRefs(child));
|
||||
if (!child)
|
||||
break;
|
||||
node->RemoveChild(child, getter_AddRefs(dummy));
|
||||
}
|
||||
}
|
||||
|
||||
// Clear any buffered-up text we have. It's enough to set the length to 0.
|
||||
// The buffer itself is allocated when we're created and deleted in our
|
||||
// destructor, so don't mess with it.
|
||||
mTextLength = 0;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXMLFragmentContentSink::ProcessStyleLink(nsIContent* aElement,
|
||||
const nsSubstring& aHref,
|
||||
bool aAlternate,
|
||||
const nsSubstring& aTitle,
|
||||
const nsSubstring& aType,
|
||||
const nsSubstring& aMedia)
|
||||
{
|
||||
// don't process until moved to document
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXMLFragmentContentSink::LoadXSLStyleSheet(nsIURI* aUrl)
|
||||
{
|
||||
NS_NOTREACHED("fragments shouldn't have XSL style sheets");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
void
|
||||
nsXMLFragmentContentSink::StartLayout()
|
||||
{
|
||||
NS_NOTREACHED("fragments shouldn't layout");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLFragmentContentSink::FinishFragmentParsing(nsIDOMDocumentFragment** aFragment)
|
||||
{
|
||||
*aFragment = nullptr;
|
||||
mTargetDocument = nullptr;
|
||||
mNodeInfoManager = nullptr;
|
||||
mScriptLoader = nullptr;
|
||||
mCSSLoader = nullptr;
|
||||
mContentStack.Clear();
|
||||
mDocumentURI = nullptr;
|
||||
mDocShell = nullptr;
|
||||
mDocElement = nullptr;
|
||||
mCurrentHead = nullptr;
|
||||
if (mParseError) {
|
||||
//XXX PARSE_ERR from DOM3 Load and Save would be more appropriate
|
||||
mRoot = nullptr;
|
||||
mParseError = false;
|
||||
return NS_ERROR_DOM_SYNTAX_ERR;
|
||||
} else if (mRoot) {
|
||||
nsresult rv = CallQueryInterface(mRoot, aFragment);
|
||||
mRoot = nullptr;
|
||||
return rv;
|
||||
} else {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLFragmentContentSink::SetTargetDocument(nsIDocument* aTargetDocument)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aTargetDocument);
|
||||
|
||||
mTargetDocument = aTargetDocument;
|
||||
mNodeInfoManager = aTargetDocument->NodeInfoManager();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLFragmentContentSink::WillBuildContent()
|
||||
{
|
||||
PushContent(mRoot);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLFragmentContentSink::DidBuildContent()
|
||||
{
|
||||
// Note: we need to FlushText() here because if we don't, we might not get
|
||||
// an end element to do it for us, so make sure.
|
||||
if (!mParseError) {
|
||||
FlushText();
|
||||
}
|
||||
PopContent();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLFragmentContentSink::DidProcessATokenImpl()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLFragmentContentSink::IgnoreFirstContainer()
|
||||
{
|
||||
NS_NOTREACHED("XML isn't as broken as HTML");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLFragmentContentSink::SetPreventScriptExecution(bool aPrevent)
|
||||
{
|
||||
mPreventScriptExecution = aPrevent;
|
||||
return NS_OK;
|
||||
}
|
||||
268
dom/xml/nsXMLPrettyPrinter.cpp
Normal file
|
|
@ -0,0 +1,268 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* 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/. */
|
||||
|
||||
#include "nsXMLPrettyPrinter.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsICSSDeclaration.h"
|
||||
#include "nsIDOMDocumentXBL.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIXSLTProcessor.h"
|
||||
#include "nsSyncLoadService.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "nsIDOMDocumentFragment.h"
|
||||
#include "nsBindingManager.h"
|
||||
#include "nsXBLService.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsVariant.h"
|
||||
#include "mozilla/dom/CustomEvent.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsXMLPrettyPrinter,
|
||||
nsIDocumentObserver,
|
||||
nsIMutationObserver)
|
||||
|
||||
nsXMLPrettyPrinter::nsXMLPrettyPrinter() : mDocument(nullptr),
|
||||
mUnhookPending(false)
|
||||
{
|
||||
}
|
||||
|
||||
nsXMLPrettyPrinter::~nsXMLPrettyPrinter()
|
||||
{
|
||||
NS_ASSERTION(!mDocument, "we shouldn't be referencing the document still");
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXMLPrettyPrinter::PrettyPrint(nsIDocument* aDocument,
|
||||
bool* aDidPrettyPrint)
|
||||
{
|
||||
*aDidPrettyPrint = false;
|
||||
|
||||
// Check for iframe with display:none. Such iframes don't have presshells
|
||||
if (!aDocument->GetShell()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// check if we're in an invisible iframe
|
||||
nsPIDOMWindowOuter *internalWin = aDocument->GetWindow();
|
||||
nsCOMPtr<Element> frameElem;
|
||||
if (internalWin) {
|
||||
frameElem = internalWin->GetFrameElementInternal();
|
||||
}
|
||||
|
||||
if (frameElem) {
|
||||
nsCOMPtr<nsICSSDeclaration> computedStyle;
|
||||
if (nsIDocument* frameOwnerDoc = frameElem->OwnerDoc()) {
|
||||
nsPIDOMWindowOuter* window = frameOwnerDoc->GetDefaultView();
|
||||
if (window) {
|
||||
nsCOMPtr<nsPIDOMWindowInner> innerWindow =
|
||||
window->GetCurrentInnerWindow();
|
||||
|
||||
ErrorResult dummy;
|
||||
computedStyle = innerWindow->GetComputedStyle(*frameElem,
|
||||
EmptyString(),
|
||||
dummy);
|
||||
dummy.SuppressException();
|
||||
}
|
||||
}
|
||||
|
||||
if (computedStyle) {
|
||||
nsAutoString visibility;
|
||||
computedStyle->GetPropertyValue(NS_LITERAL_STRING("visibility"),
|
||||
visibility);
|
||||
if (!visibility.EqualsLiteral("visible")) {
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check the pref
|
||||
if (!Preferences::GetBool("layout.xml.prettyprint", true)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Ok, we should prettyprint. Let's do it!
|
||||
*aDidPrettyPrint = true;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Load the XSLT
|
||||
nsCOMPtr<nsIURI> xslUri;
|
||||
rv = NS_NewURI(getter_AddRefs(xslUri),
|
||||
NS_LITERAL_CSTRING("chrome://global/content/xml/XMLPrettyPrint.xsl"));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> xslDocument;
|
||||
rv = nsSyncLoadService::LoadDocument(xslUri, nsIContentPolicy::TYPE_XSLT,
|
||||
nsContentUtils::GetSystemPrincipal(),
|
||||
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
|
||||
nullptr, true, mozilla::net::RP_Default,
|
||||
getter_AddRefs(xslDocument));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Transform the document
|
||||
nsCOMPtr<nsIXSLTProcessor> transformer =
|
||||
do_CreateInstance("@mozilla.org/document-transformer;1?type=xslt", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = transformer->ImportStylesheet(xslDocument);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMDocumentFragment> resultFragment;
|
||||
nsCOMPtr<nsIDOMDocument> sourceDocument = do_QueryInterface(aDocument);
|
||||
rv = transformer->TransformToFragment(sourceDocument, sourceDocument,
|
||||
getter_AddRefs(resultFragment));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
//
|
||||
// Apply the prettprint XBL binding.
|
||||
//
|
||||
// We take some shortcuts here. In particular, we don't bother invoking the
|
||||
// contstructor (since the binding has no constructor), and we don't bother
|
||||
// calling LoadBindingDocument because it's a chrome:// URI and thus will get
|
||||
// sync loaded no matter what.
|
||||
//
|
||||
|
||||
// Grab the XBL service.
|
||||
nsXBLService* xblService = nsXBLService::GetInstance();
|
||||
NS_ENSURE_TRUE(xblService, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
// Compute the binding URI.
|
||||
nsCOMPtr<nsIURI> bindingUri;
|
||||
rv = NS_NewURI(getter_AddRefs(bindingUri),
|
||||
NS_LITERAL_STRING("chrome://global/content/xml/XMLPrettyPrint.xml#prettyprint"));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Compute the bound element.
|
||||
nsCOMPtr<nsIContent> rootCont = aDocument->GetRootElement();
|
||||
NS_ENSURE_TRUE(rootCont, NS_ERROR_UNEXPECTED);
|
||||
|
||||
// Grab the system principal.
|
||||
nsCOMPtr<nsIPrincipal> sysPrincipal;
|
||||
nsContentUtils::GetSecurityManager()->
|
||||
GetSystemPrincipal(getter_AddRefs(sysPrincipal));
|
||||
|
||||
// Load the bindings.
|
||||
RefPtr<nsXBLBinding> unused;
|
||||
bool ignored;
|
||||
rv = xblService->LoadBindings(rootCont, bindingUri, sysPrincipal,
|
||||
getter_AddRefs(unused), &ignored);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Fire an event at the bound element to pass it |resultFragment|.
|
||||
RefPtr<CustomEvent> event =
|
||||
NS_NewDOMCustomEvent(rootCont, nullptr, nullptr);
|
||||
MOZ_ASSERT(event);
|
||||
nsCOMPtr<nsIWritableVariant> resultFragmentVariant = new nsVariant();
|
||||
rv = resultFragmentVariant->SetAsISupports(resultFragment);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
rv = event->InitCustomEvent(NS_LITERAL_STRING("prettyprint-dom-created"),
|
||||
/* bubbles = */ false, /* cancelable = */ false,
|
||||
/* detail = */ resultFragmentVariant);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
event->SetTrusted(true);
|
||||
bool dummy;
|
||||
rv = rootCont->DispatchEvent(event, &dummy);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Observe the document so we know when to switch to "normal" view
|
||||
aDocument->AddObserver(this);
|
||||
mDocument = aDocument;
|
||||
|
||||
NS_ADDREF_THIS();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsXMLPrettyPrinter::MaybeUnhook(nsIContent* aContent)
|
||||
{
|
||||
// If there either aContent is null (the document-node was modified) or
|
||||
// there isn't a binding parent we know it's non-anonymous content.
|
||||
if ((!aContent || !aContent->GetBindingParent()) && !mUnhookPending) {
|
||||
// Can't blindly to mUnhookPending after AddScriptRunner,
|
||||
// since AddScriptRunner _could_ in theory run us
|
||||
// synchronously
|
||||
mUnhookPending = true;
|
||||
nsContentUtils::AddScriptRunner(
|
||||
NewRunnableMethod(this, &nsXMLPrettyPrinter::Unhook));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsXMLPrettyPrinter::Unhook()
|
||||
{
|
||||
mDocument->RemoveObserver(this);
|
||||
nsCOMPtr<Element> element = mDocument->GetDocumentElement();
|
||||
|
||||
if (element) {
|
||||
mDocument->BindingManager()->ClearBinding(element);
|
||||
}
|
||||
|
||||
mDocument = nullptr;
|
||||
|
||||
NS_RELEASE_THIS();
|
||||
}
|
||||
|
||||
void
|
||||
nsXMLPrettyPrinter::AttributeChanged(nsIDocument* aDocument,
|
||||
Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aOldValue)
|
||||
{
|
||||
MaybeUnhook(aElement);
|
||||
}
|
||||
|
||||
void
|
||||
nsXMLPrettyPrinter::ContentAppended(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aFirstNewContent,
|
||||
int32_t aNewIndexInContainer)
|
||||
{
|
||||
MaybeUnhook(aContainer);
|
||||
}
|
||||
|
||||
void
|
||||
nsXMLPrettyPrinter::ContentInserted(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
int32_t aIndexInContainer)
|
||||
{
|
||||
MaybeUnhook(aContainer);
|
||||
}
|
||||
|
||||
void
|
||||
nsXMLPrettyPrinter::ContentRemoved(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
int32_t aIndexInContainer,
|
||||
nsIContent* aPreviousSibling)
|
||||
{
|
||||
MaybeUnhook(aContainer);
|
||||
}
|
||||
|
||||
void
|
||||
nsXMLPrettyPrinter::NodeWillBeDestroyed(const nsINode* aNode)
|
||||
{
|
||||
mDocument = nullptr;
|
||||
NS_RELEASE_THIS();
|
||||
}
|
||||
|
||||
|
||||
nsresult NS_NewXMLPrettyPrinter(nsXMLPrettyPrinter** aPrinter)
|
||||
{
|
||||
*aPrinter = new nsXMLPrettyPrinter;
|
||||
NS_ADDREF(*aPrinter);
|
||||
return NS_OK;
|
||||
}
|
||||
59
dom/xml/nsXMLPrettyPrinter.h
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* 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 nsXMLPrettyPrinter_h__
|
||||
#define nsXMLPrettyPrinter_h__
|
||||
|
||||
#include "nsStubDocumentObserver.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsIDocument;
|
||||
|
||||
class nsXMLPrettyPrinter : public nsStubDocumentObserver
|
||||
{
|
||||
public:
|
||||
nsXMLPrettyPrinter();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIMutationObserver
|
||||
NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
|
||||
NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
|
||||
NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
|
||||
NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
|
||||
NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED
|
||||
|
||||
/**
|
||||
* This will prettyprint the document if the document is loaded in a
|
||||
* displayed window.
|
||||
*
|
||||
* @param aDocument document to prettyprint
|
||||
* @param [out] aDidPrettyPrint if true, and error not returned, actually
|
||||
* went ahead with prettyprinting the document.
|
||||
*/
|
||||
nsresult PrettyPrint(nsIDocument* aDocument, bool* aDidPrettyPrint);
|
||||
|
||||
/**
|
||||
* Unhook the prettyprinter
|
||||
*/
|
||||
void Unhook();
|
||||
private:
|
||||
virtual ~nsXMLPrettyPrinter();
|
||||
|
||||
/**
|
||||
* Signals for unhooking by setting mUnhookPending if the node changed is
|
||||
* non-anonymous content.
|
||||
*
|
||||
* @param aContent content that has changed
|
||||
*/
|
||||
void MaybeUnhook(nsIContent* aContent);
|
||||
|
||||
nsIDocument* mDocument; //weak. Set as long as we're observing the document
|
||||
bool mUnhookPending;
|
||||
};
|
||||
|
||||
nsresult NS_NewXMLPrettyPrinter(nsXMLPrettyPrinter** aPrinter);
|
||||
|
||||
#endif //nsXMLPrettyPrinter_h__
|
||||
11
dom/xml/resources/XMLMonoPrint.css
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
@charset "UTF-8";
|
||||
/* 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/. */
|
||||
|
||||
@import url("chrome://global/content/xml/XMLPrettyPrint.css");
|
||||
|
||||
#top > .expander-open {
|
||||
font-family: monospace;
|
||||
white-space: pre;
|
||||
}
|
||||
41
dom/xml/resources/XMLPrettyPrint.css
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
@charset "UTF-8";
|
||||
/* 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/. */
|
||||
|
||||
@import url("resource://gre-resources/viewsource.css");
|
||||
|
||||
#header {
|
||||
background-color: #ccc;
|
||||
border-bottom: 3px solid black;
|
||||
padding: 0.5em;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.expander-content {
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
.expander {
|
||||
cursor: pointer;
|
||||
-moz-user-select: none;
|
||||
text-align: center;
|
||||
vertical-align: top;
|
||||
width: 1em;
|
||||
display: inline-block;
|
||||
margin-left: -1em;
|
||||
}
|
||||
|
||||
#top > .expander-open, #top > .expander-closed {
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
.expander-closed > .expander-content {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.comment {
|
||||
font-family: monospace;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
43
dom/xml/resources/XMLPrettyPrint.xml
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- 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/. -->
|
||||
|
||||
<bindings xmlns="http://www.mozilla.org/xbl"
|
||||
xmlns:html="http://www.w3.org/1999/xhtml">
|
||||
|
||||
<binding id="prettyprint" bindToUntrustedContent="true">
|
||||
|
||||
<content><html:div id='top' class="highlight"/>
|
||||
<html:span style="display: none;"><children/></html:span>
|
||||
</content>
|
||||
|
||||
<handlers>
|
||||
<handler event="click" button="0">
|
||||
<![CDATA[
|
||||
try {
|
||||
var par = event.originalTarget;
|
||||
if (par.nodeName == 'div' && par.className == 'expander') {
|
||||
if (par.parentNode.className == 'expander-closed') {
|
||||
par.parentNode.className = 'expander-open';
|
||||
event.originalTarget.firstChild.data = '\u2212';
|
||||
}
|
||||
else {
|
||||
par.parentNode.className = 'expander-closed';
|
||||
event.originalTarget.firstChild.data = '+';
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
]]>
|
||||
</handler>
|
||||
<handler event="prettyprint-dom-created" allowuntrusted="false">
|
||||
<![CDATA[
|
||||
document.getAnonymousNodes(this).item(0).appendChild(event.detail);
|
||||
]]>
|
||||
</handler>
|
||||
</handlers>
|
||||
|
||||
</binding>
|
||||
|
||||
</bindings>
|
||||
137
dom/xml/resources/XMLPrettyPrint.xsl
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- 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/. -->
|
||||
|
||||
<!DOCTYPE overlay [
|
||||
<!ENTITY % prettyPrintDTD SYSTEM "chrome://global/locale/xml/prettyprint.dtd">
|
||||
%prettyPrintDTD;
|
||||
<!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd">
|
||||
%globalDTD;
|
||||
]>
|
||||
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
||||
<xsl:output method="xml"/>
|
||||
|
||||
<xsl:template match="/">
|
||||
<link href="chrome://global/content/xml/XMLPrettyPrint.css" type="text/css" rel="stylesheet"/>
|
||||
<link title="Monospace" href="chrome://global/content/xml/XMLMonoPrint.css" type="text/css" rel="alternate stylesheet"/>
|
||||
<div id="header" dir="&locale.dir;">
|
||||
<p>
|
||||
&xml.nostylesheet;
|
||||
</p>
|
||||
</div>
|
||||
<xsl:apply-templates/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="*">
|
||||
<div>
|
||||
<xsl:text><</xsl:text>
|
||||
<span class="start-tag"><xsl:value-of select="name(.)"/></span>
|
||||
<xsl:apply-templates select="@*"/>
|
||||
<xsl:text>/></xsl:text>
|
||||
</div>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="*[node()]">
|
||||
<div>
|
||||
<xsl:text><</xsl:text>
|
||||
<span class="start-tag"><xsl:value-of select="name(.)"/></span>
|
||||
<xsl:apply-templates select="@*"/>
|
||||
<xsl:text>></xsl:text>
|
||||
|
||||
<span class="text"><xsl:value-of select="."/></span>
|
||||
|
||||
<xsl:text></</xsl:text>
|
||||
<span class="end-tag"><xsl:value-of select="name(.)"/></span>
|
||||
<xsl:text>></xsl:text>
|
||||
</div>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="*[* or processing-instruction() or comment() or string-length(.) > 50]">
|
||||
<div class="expander-open">
|
||||
<xsl:call-template name="expander"/>
|
||||
|
||||
<xsl:text><</xsl:text>
|
||||
<span class="start-tag"><xsl:value-of select="name(.)"/></span>
|
||||
<xsl:apply-templates select="@*"/>
|
||||
<xsl:text>></xsl:text>
|
||||
|
||||
<div class="expander-content"><xsl:apply-templates/></div>
|
||||
|
||||
<xsl:text></</xsl:text>
|
||||
<span class="end-tag"><xsl:value-of select="name(.)"/></span>
|
||||
<xsl:text>></xsl:text>
|
||||
</div>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@*">
|
||||
<xsl:text> </xsl:text>
|
||||
<span class="attribute-name"><xsl:value-of select="name(.)"/></span>
|
||||
<xsl:text>=</xsl:text>
|
||||
<span class="attribute-value">"<xsl:value-of select="."/>"</span>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="text()">
|
||||
<xsl:if test="normalize-space(.)">
|
||||
<xsl:value-of select="."/>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="processing-instruction()">
|
||||
<div class="pi">
|
||||
<xsl:text><?</xsl:text>
|
||||
<xsl:value-of select="name(.)"/>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:value-of select="."/>
|
||||
<xsl:text>?></xsl:text>
|
||||
</div>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="processing-instruction()[string-length(.) > 50]">
|
||||
<div class="expander-open">
|
||||
<xsl:call-template name="expander"/>
|
||||
|
||||
<span class="pi">
|
||||
<xsl:text> <?</xsl:text>
|
||||
<xsl:value-of select="name(.)"/>
|
||||
</span>
|
||||
<div class="expander-content pi"><xsl:value-of select="."/></div>
|
||||
<span class="pi">
|
||||
<xsl:text>?></xsl:text>
|
||||
</span>
|
||||
</div>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="comment()">
|
||||
<div class="comment">
|
||||
<xsl:text><!--</xsl:text>
|
||||
<xsl:value-of select="."/>
|
||||
<xsl:text>--></xsl:text>
|
||||
</div>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="comment()[string-length(.) > 50]">
|
||||
<div class="expander-open">
|
||||
<xsl:call-template name="expander"/>
|
||||
|
||||
<span class="comment">
|
||||
<xsl:text><!--</xsl:text>
|
||||
</span>
|
||||
<div class="expander-content comment">
|
||||
<xsl:value-of select="."/>
|
||||
</div>
|
||||
<span class="comment">
|
||||
<xsl:text>--></xsl:text>
|
||||
</span>
|
||||
</div>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="expander">
|
||||
<div class="expander">−</div>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
9
dom/xml/resources/jar.mn
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# 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/.
|
||||
|
||||
toolkit.jar:
|
||||
content/global/xml/XMLPrettyPrint.css (XMLPrettyPrint.css)
|
||||
content/global/xml/XMLMonoPrint.css (XMLMonoPrint.css)
|
||||
content/global/xml/XMLPrettyPrint.xml (XMLPrettyPrint.xml)
|
||||
content/global/xml/XMLPrettyPrint.xsl (XMLPrettyPrint.xsl)
|
||||
7
dom/xml/resources/moz.build
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# 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/.
|
||||
|
||||
JAR_MANIFESTS += ['jar.mn']
|
||||
2
dom/xml/test/file_bug293347.xml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<?xml-stylesheet type="text/xsl" href="file_bug293347xslt.xml"?>
|
||||
<doc/>
|
||||
19
dom/xml/test/file_bug293347xslt.xml
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
<xsl:template match="/doc">
|
||||
<html>
|
||||
<body>
|
||||
<div></div>
|
||||
<div>
|
||||
<script>
|
||||
didThrow = false;
|
||||
try {
|
||||
document.write("shrimp");
|
||||
} catch (e) {
|
||||
didThrow = true;
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
22
dom/xml/test/file_bug392338.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var modifyObserver = {
|
||||
observe: function(subject, topic, data) {
|
||||
if (topic == 'http-on-modify-request') {
|
||||
var testOk = false;
|
||||
try {
|
||||
// We should be able to QI the request to an nsIChannel, then get
|
||||
// the notificationCallbacks without throwing an exception.
|
||||
var ir = subject.QueryInterface(Components.interfaces.nsIChannel).notificationCallbacks;
|
||||
|
||||
// The notificationCallbacks should be an nsIInterfaceRequestor.
|
||||
testOk = ir.toString().indexOf(Components.interfaces.nsIInterfaceRequestor) != -1;
|
||||
} catch (e) {
|
||||
}
|
||||
sendAsyncMessage('modify-request-completed', testOk);
|
||||
Services.obs.removeObserver(modifyObserver, 'http-on-modify-request');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Services.obs.addObserver(modifyObserver, 'http-on-modify-request', false);
|
||||
15
dom/xml/test/mochitest.ini
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
[DEFAULT]
|
||||
support-files =
|
||||
file_bug293347.xml
|
||||
file_bug293347xslt.xml
|
||||
file_bug392338.js
|
||||
|
||||
[test_bug232004.xhtml]
|
||||
[test_bug293347.html]
|
||||
[test_bug343870.xhtml]
|
||||
[test_bug355213.xhtml]
|
||||
[test_bug392338.html]
|
||||
[test_bug399502.xhtml]
|
||||
[test_bug445330.html]
|
||||
[test_bug691215.html]
|
||||
[test_viewport.xhtml]
|
||||
BIN
dom/xml/test/old/books/bethlehem.gif
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
BIN
dom/xml/test/old/books/bill.gif
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
97
dom/xml/test/old/books/books.js
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
|
||||
// An inefficient, but effective bubble sort
|
||||
function sort(collection, key)
|
||||
{
|
||||
var i, j;
|
||||
var count = collection.length;
|
||||
var parent, child;
|
||||
|
||||
for (i = count-1; i >= 0; i--) {
|
||||
for (j = 1; j <= i; j++) {
|
||||
if (collection[j-1][key] > collection[j][key]) {
|
||||
// Move the item both in the local array and
|
||||
// in the tree
|
||||
child = collection[j];
|
||||
parent = child.parentNode;
|
||||
|
||||
collection[j] = collection[j-1];
|
||||
collection[j-1] = child;
|
||||
|
||||
parent.removeChild(child);
|
||||
parent.insertBefore(child, collection[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set user properties on the nodes in the collection
|
||||
// based on information found in its children. For example,
|
||||
// make a property "Author" based on the content of the
|
||||
// "Author" element found in the childNode list of the node.
|
||||
// This makes later sorting more efficient
|
||||
function collectInfo(nodes, propNames)
|
||||
{
|
||||
var i, j, k;
|
||||
var ncount = nodes.length;
|
||||
var pcount = propNames.length;
|
||||
|
||||
for (i = 0; i < ncount; i++) {
|
||||
var node = nodes[i];
|
||||
var childNodes = node.childNodes;
|
||||
var ccount = childNodes.length;
|
||||
|
||||
for (j = 0; j < ccount; j++) {
|
||||
var child = childNodes[j];
|
||||
|
||||
if (child.nodeType == Node.ELEMENT_NODE) {
|
||||
var tagName = child.tagName;
|
||||
|
||||
for (k = 0; k < pcount; k++) {
|
||||
var prop = propNames[k];
|
||||
if (prop == tagName) {
|
||||
node[prop] = child.firstChild.data;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var enabled = true;
|
||||
function toggleStyleSheet()
|
||||
{
|
||||
if (enabled) {
|
||||
document.styleSheets[2].disabled = true;
|
||||
}
|
||||
else {
|
||||
document.styleSheets[2].disabled = false;
|
||||
}
|
||||
|
||||
enabled = !enabled;
|
||||
}
|
||||
|
||||
// XXX This is a workaround for a bug where
|
||||
// changing the disabled state of a stylesheet can't
|
||||
// be done in an event handler. For now, we do it
|
||||
// in a zero-delay timeout.
|
||||
function initiateToggle()
|
||||
{
|
||||
setTimeout(toggleStyleSheet, 0);
|
||||
}
|
||||
|
||||
var sortableProps = new Array("Author", "Title", "ISBN");
|
||||
var books = new Array();
|
||||
|
||||
// We uppercase the tagName as a workaround for a bug
|
||||
// that loses the original case of the tag.
|
||||
var bookset = document.getElementsByTagName("Book");
|
||||
|
||||
// We need to create a "non-live" array to operate on. Since
|
||||
// we'll be moving things around in this array, we can't use
|
||||
// the read-only, live one returned by getElementsByTagName.
|
||||
for (var i=0; i < bookset.length; i++) {
|
||||
books[i] = bookset[i];
|
||||
}
|
||||
|
||||
collectInfo(books, sortableProps);
|
||||
|
||||
103
dom/xml/test/old/books/books.xml
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="common.css" type="text/css"?>
|
||||
<?xml-stylesheet href="classic.css" type="text/css"?>
|
||||
<?xml-stylesheet href="list.css" type="text/css"?>
|
||||
|
||||
<!DOCTYPE SearchResult>
|
||||
|
||||
<SearchResult xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
|
||||
<Header>
|
||||
<Toolbar>
|
||||
<html:form>
|
||||
<Label>Sort by:</Label>
|
||||
<html:input type="button" id="Author" onclick="sort(books,this.id)" value="Author"/>
|
||||
<html:input type="button" id="Title" onclick="sort(books,this.id)" value="Title"/>
|
||||
<html:input type="button" id="ISBN" onclick="sort(books,this.id)" value="ISBN #"/>
|
||||
<html:input type="button" id="toggle" value="Toggle Style" onclick="initiateToggle(); return false;"/>
|
||||
</html:form>
|
||||
</Toolbar>
|
||||
|
||||
<SearchTitle>Amazon.com Search Results for: the keywords include "Road"</SearchTitle>
|
||||
</Header>
|
||||
|
||||
<BookSet>
|
||||
|
||||
<Book>
|
||||
<BookCover><html:img src="kerouac.gif" width="100" height="140"/></BookCover>
|
||||
<Title xlink:type="simple" xlink:show="replace" xlink:href="http://www.amazon.com/exec/obidos/ASIN/0140042598/002-5969498-2733628">On the Road</Title>
|
||||
<Author>Kerouac, Jack</Author>
|
||||
<ISBN>0140042598</ISBN>
|
||||
<Synopsis>
|
||||
On The Road, the most famous of Jack Kerouac's works, is not only the soul of the Beat movement and literature, but one of the most important novels of the century. Like nearly all of Kerouac's writing, On The Road is thinly fictionalized autobiography, filled with a cast made of Kerouac's real life friends, lovers, and fellow travelers. Narrated by Sal Paradise, one of Kerouac's alter-egos, On the Road is a cross-country bohemian odyssey that not only influenced writing in the years since its 1957 publication but penetrated into the deepest levels of American thought and culture.
|
||||
</Synopsis>
|
||||
<ListPrice>$12.95</ListPrice>
|
||||
<Price>$10.36</Price>
|
||||
</Book>
|
||||
|
||||
<Book>
|
||||
<BookCover><html:img src="bill.gif" width="100" height="140" /></BookCover>
|
||||
<Title xlink:type="simple" xlink:show="replace" xlink:href="http://www.amazon.com/exec/obidos/ASIN/0140260404/002-5969498-2733628">The Road Ahead</Title>
|
||||
<Author>Gates, Bill</Author>
|
||||
<ISBN>666666666</ISBN>
|
||||
<Synopsis>
|
||||
In a study, the founder of Microsoft presents his vision for the future in which he sees the digital technologies of the coming years changing the way we buy, work, learn, and communicate. But he doesn't mention XML!
|
||||
</Synopsis>
|
||||
<ListPrice>$15.95</ListPrice>
|
||||
<Price>$12.76</Price>
|
||||
</Book>
|
||||
|
||||
<Book>
|
||||
<BookCover><html:img src="welville.gif" width="100" height="140" /></BookCover>
|
||||
<Title xlink:type="simple" xlink:show="replace" xlink:href="http://www.amazon.com/exec/obidos/ASIN/0140167188/002-5969498-2733628">The Road to Wellville</Title>
|
||||
<Author>Boyle, T. Coraghessan</Author>
|
||||
<ISBN>0140167188</ISBN>
|
||||
<Synopsis>
|
||||
A snobbish wife and her henpecked husband travel to Dr. Kellogg's spa in turn-of-the-century Battle Creek, where the youth-crazed affluent succumb to quackery. By the author of East is East.
|
||||
</Synopsis>
|
||||
<ListPrice>$12.95</ListPrice>
|
||||
<Price>$10.36</Price>
|
||||
</Book>
|
||||
|
||||
<Book>
|
||||
<BookCover><html:img src="road.gif" width="100" height="140" /></BookCover>
|
||||
<Title xlink:type="simple" xlink:show="replace" xlink:href="http://www.amazon.com/exec/obidos/ASIN/1562512625/002-5969498-2733628">AAA Road Atlas 1999</Title>
|
||||
<Author>A. A. A.</Author>
|
||||
<ISBN>1562512625</ISBN>
|
||||
<Synopsis>
|
||||
The definitive road atlas to the United States, Canada and Mexico.
|
||||
</Synopsis>
|
||||
<ListPrice>$9.95</ListPrice>
|
||||
<Price>$9.95</Price>
|
||||
</Book>
|
||||
|
||||
<Book>
|
||||
<BookCover><html:img src="bethlehem.gif" width="100" height="140" /></BookCover>
|
||||
<Title xlink:type="simple" xlink:show="replace" xlink:href="http://www.amazon.com/exec/obidos/ASIN/0449219143/002-5969498-2733628">Bethlehem Road</Title>
|
||||
<Author>Perry, Anne</Author>
|
||||
<ISBN>0449219143</ISBN>
|
||||
<Synopsis>
|
||||
He might be elegant, but there's no mistaking it--the gentleman tied to the lamppost on Westminster Bridge is definitely dead. Before Inspector Thomas Pitt can even speculate on why anyone should want to kill the eminent M.P., Sir Lockwood, a colleague of his, meets the same fate at the same spot. The public is outraged, and clever Charlotte Pitt, Thomas's well-born wife, helps her hard-pressed husband by scouting society's drawing rooms for clues to these appalling crimes. Meanwhile, another victim is being stalked....
|
||||
</Synopsis>
|
||||
<ListPrice>$6.99</ListPrice>
|
||||
<Price>$5.59</Price>
|
||||
</Book>
|
||||
|
||||
<Book>
|
||||
<BookCover><html:img src="charing.gif" width="100" height="140" /></BookCover>
|
||||
<Title xlink:type="simple" xlink:show="replace" xlink:href="http://www.amazon.com/exec/obidos/ASIN/0140143505/002-5969498-2733628">84 Charing Cross Road</Title>
|
||||
<Author>Hanff, Helene</Author>
|
||||
<ISBN>0140143505</ISBN>
|
||||
<Synopsis>
|
||||
84, Charing Cross Road is a charming record of bibliophilia, cultural difference, and imaginative sympathy. For 20 years, an outspoken New York writer and a rather more restrained London bookseller carried on an increasingly touching correspondence...
|
||||
</Synopsis>
|
||||
<ListPrice>$9.95</ListPrice>
|
||||
<Price>$7.96</Price>
|
||||
</Book>
|
||||
|
||||
</BookSet>
|
||||
|
||||
<html:script src="books.js" />
|
||||
|
||||
</SearchResult>
|
||||
BIN
dom/xml/test/old/books/charing.gif
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
78
dom/xml/test/old/books/classic.css
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
|
||||
|
||||
BookSet {
|
||||
display: block;
|
||||
}
|
||||
|
||||
Book {
|
||||
float: left;
|
||||
display: block;
|
||||
width: 300px;
|
||||
background-color: #f1f1f1;
|
||||
border: 1px solid #cccccc;
|
||||
margin-right: 8px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
BookCover {
|
||||
display: inline;
|
||||
float: left;
|
||||
margin-right: 10px;
|
||||
padding: 5px;
|
||||
width: 100px;
|
||||
height: 140px;
|
||||
}
|
||||
|
||||
Title {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
color: blue;
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
Author {
|
||||
display: block;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
Synopsis {
|
||||
display: block;
|
||||
overflow: scroll;
|
||||
height: 100px;
|
||||
width: 155px;
|
||||
padding: 3px;
|
||||
background-color: #ddddff;
|
||||
}
|
||||
|
||||
|
||||
ListPrice {
|
||||
display: block;
|
||||
text-align: right;
|
||||
padding-right: 15px;
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
|
||||
Price {
|
||||
display: block;
|
||||
color: rgb(20,100,0);
|
||||
text-align:right;
|
||||
padding-right: 15px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
|
||||
Price:before {
|
||||
content: "Our Price: ";
|
||||
}
|
||||
|
||||
ISBN {
|
||||
display: block;
|
||||
font-family: monospace;
|
||||
font-size: 8pt;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
43
dom/xml/test/old/books/common.css
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
SearchResult {
|
||||
display: block;
|
||||
margin-top: 8px;
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
Header {
|
||||
width: 612px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
SearchTitle {
|
||||
display: block;
|
||||
width: 280px;
|
||||
border-bottom: thin solid black;
|
||||
padding-bottom: 6px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
SearchTitle:first-line {
|
||||
font-family: Verdana, Sans-Serif;
|
||||
color: #cc6600;
|
||||
font-size: 14pt;
|
||||
}
|
||||
|
||||
Toolbar {
|
||||
font-family: Verdana, Sans-Serif;
|
||||
float: right;
|
||||
font-size: 7pt;
|
||||
display: block;
|
||||
border: ridge #ddddff 4px;
|
||||
width: 220px;
|
||||
margin-right: 0px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
Label {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
input {
|
||||
margin-top: 2px;
|
||||
}
|
||||
BIN
dom/xml/test/old/books/kerouac.gif
Normal file
|
After Width: | Height: | Size: 49 KiB |
61
dom/xml/test/old/books/list.css
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
|
||||
BookSet {
|
||||
display: block;
|
||||
}
|
||||
|
||||
Book {
|
||||
display: list-item;
|
||||
float: none;
|
||||
border: none;
|
||||
background: inherit;
|
||||
}
|
||||
|
||||
BookCover {
|
||||
display: none;
|
||||
}
|
||||
|
||||
Title {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
color: blue;
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
Author {
|
||||
display: block;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
Synopsis {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
ListPrice {
|
||||
display: none;
|
||||
text-align: right;
|
||||
padding-right: 15px;
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
|
||||
Price {
|
||||
display: block;
|
||||
color: rgb(20,100,0);
|
||||
font-weight: bold;
|
||||
text-align:left;
|
||||
}
|
||||
|
||||
|
||||
Price:before {
|
||||
content: "Our Price: ";
|
||||
}
|
||||
|
||||
ISBN {
|
||||
display: block;
|
||||
font-family: monospace;
|
||||
font-size: 8pt;
|
||||
}
|
||||
|
||||
|
||||
BIN
dom/xml/test/old/books/road.gif
Normal file
|
After Width: | Height: | Size: 7.8 KiB |
BIN
dom/xml/test/old/books/welville.gif
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
621
dom/xml/test/old/docbook.css
Normal file
|
|
@ -0,0 +1,621 @@
|
|||
/* 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/. */
|
||||
|
||||
Book {
|
||||
display: block;
|
||||
padding-left: 8px;
|
||||
padding-top: 8px;
|
||||
font-family: Courier;
|
||||
font-size: 10pt;
|
||||
}
|
||||
|
||||
Abbrev {
|
||||
display: block;
|
||||
}
|
||||
|
||||
Affiliation {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
Appendix Title {
|
||||
font-weight: bold;
|
||||
font-family: Arial;
|
||||
font-size: 24pt;
|
||||
margin-bottom: 10pt;
|
||||
display: block;
|
||||
}
|
||||
|
||||
Para Author {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
Author {
|
||||
display: block;
|
||||
}
|
||||
|
||||
AuthorGroup {
|
||||
font-size: 12pt;
|
||||
margin-top: 25pt;
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
BiblioDiv Title {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
Blockquote {
|
||||
display: block;
|
||||
margin-top: 3pt;
|
||||
margin-left: 30pt;
|
||||
}
|
||||
|
||||
Book Title {
|
||||
font-weight: bold;
|
||||
font-family: Arial;
|
||||
font-size: 18pt;
|
||||
margin-bottom: 10pt;
|
||||
display: block;
|
||||
}
|
||||
|
||||
BookInfo {
|
||||
display: block;
|
||||
margin-bottom: 30pt;
|
||||
}
|
||||
|
||||
BridgeHead {
|
||||
display: block;
|
||||
font-size: 16pt;
|
||||
font-weight: bold;
|
||||
color: teal;
|
||||
}
|
||||
|
||||
Caution {
|
||||
font-weight: bold;
|
||||
color: red;
|
||||
}
|
||||
|
||||
Caution:before {
|
||||
content: "Caution:";
|
||||
}
|
||||
|
||||
Chapter {
|
||||
display: block;
|
||||
margin-bottom: 25pt;
|
||||
}
|
||||
|
||||
Chapter Title {
|
||||
font-weight: bold;
|
||||
font-family: Arial;
|
||||
font-size: 20pt;
|
||||
margin-bottom: 10pt;
|
||||
display: block;
|
||||
}
|
||||
|
||||
CiteTitle {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
CmdSynopsis {
|
||||
display: block;
|
||||
}
|
||||
|
||||
CO {
|
||||
display: block;
|
||||
}
|
||||
|
||||
Command {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
Comment {
|
||||
display: block;
|
||||
}
|
||||
|
||||
ComputerOutput {
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
Copyright {
|
||||
display: block;
|
||||
}
|
||||
|
||||
Para CorpAuthor {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
CorpAuthor {
|
||||
display: block;
|
||||
}
|
||||
|
||||
Email {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
Editor {
|
||||
display: block;
|
||||
}
|
||||
|
||||
Emphasis {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
ErrorType {
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
Example {
|
||||
display: block;
|
||||
margin-top: 10pt;
|
||||
margin-bottom: 10pt;
|
||||
}
|
||||
|
||||
Example Title {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
font-size: 14pt;
|
||||
}
|
||||
|
||||
Figure Title {
|
||||
font-family: Arial;
|
||||
font-size: 10pt;
|
||||
font-style: italic;
|
||||
font-weight: bold;
|
||||
display: block;
|
||||
}
|
||||
|
||||
Filename {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
Figure {
|
||||
display: block;
|
||||
margin-top: 10pt;
|
||||
}
|
||||
|
||||
FirstTerm {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
ForeignPhrase {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
FormalPara {
|
||||
display: block;
|
||||
}
|
||||
|
||||
FormalPara Title {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
FuncSynopsis {
|
||||
display: block;
|
||||
}
|
||||
|
||||
FuncSynopsisInfo {
|
||||
display: block;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
Function {
|
||||
font-family: monospace;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
Glossary {
|
||||
display: block;
|
||||
}
|
||||
|
||||
GlossDef {
|
||||
display: block;
|
||||
margin-left: 15pt;
|
||||
}
|
||||
|
||||
GlossList {
|
||||
display: block;
|
||||
}
|
||||
|
||||
GlossSee {
|
||||
display: block;
|
||||
margin-left: 15pt;
|
||||
}
|
||||
|
||||
GlossTerm {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
InformalTable {
|
||||
display: block;
|
||||
margin-top: 10pt;
|
||||
margin-bottom: 10pt;
|
||||
}
|
||||
|
||||
Interface {
|
||||
font-family: Arial;
|
||||
}
|
||||
|
||||
ISBN {
|
||||
display: block;
|
||||
font-size: 10pt;
|
||||
}
|
||||
|
||||
ItemizedList {
|
||||
display: block;
|
||||
margin-top: 5pt;
|
||||
margin-left: 20pt;
|
||||
}
|
||||
|
||||
LineAnnotation {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
Link {
|
||||
color: blue;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
ListItem {
|
||||
margin-left: 25pt;
|
||||
display: list-item;
|
||||
}
|
||||
|
||||
Literal {
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
LiteralLayout {
|
||||
white-space: pre;
|
||||
display: block;
|
||||
}
|
||||
|
||||
Member {
|
||||
display: block;
|
||||
margin-left: 15pt;
|
||||
}
|
||||
|
||||
OLink {
|
||||
display: block;
|
||||
font-size: 12pt;
|
||||
}
|
||||
|
||||
Option {
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
OrderedList {
|
||||
margin-top: 5pt;
|
||||
margin-left: 20pt;
|
||||
margin-bottom: 10pt;
|
||||
display: block;
|
||||
list-style-type: decimal;
|
||||
}
|
||||
|
||||
OrderedList Para {
|
||||
display: block;
|
||||
margin-top: 15pt;
|
||||
}
|
||||
|
||||
Para OtherCredit {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
OtherCredit {
|
||||
display: block;
|
||||
}
|
||||
|
||||
Para {
|
||||
display: block;
|
||||
margin-top: 8pt;
|
||||
}
|
||||
|
||||
Para LiteralLayout {
|
||||
display: block;
|
||||
margin-top: 4pt;
|
||||
margin-left: 10pt;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
Para Screen {
|
||||
margin-top: 7pt;
|
||||
margin-left: 10pt;
|
||||
margin-bottom: 7pt;
|
||||
display: block;
|
||||
}
|
||||
|
||||
Parameter {
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
Part Title {
|
||||
font-size: 24pt;
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
Preface {
|
||||
display: block;
|
||||
margin-top: 10pt;
|
||||
}
|
||||
|
||||
Procedure {
|
||||
display: block;
|
||||
}
|
||||
|
||||
ProgramListing {
|
||||
display: block;
|
||||
white-space: pre;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
ProgramListingCO {
|
||||
display: block;
|
||||
white-space: pre;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
PublisherName {
|
||||
font-family: Times, New, Roman;
|
||||
font-size: 20pt;
|
||||
margin-top: 15pt;
|
||||
margin-bottom: 15pt;
|
||||
display: block;
|
||||
}
|
||||
|
||||
RefEntry {
|
||||
display: block;
|
||||
}
|
||||
|
||||
RefEntryTitle {
|
||||
display: block;
|
||||
font-size: 20pt;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
RefName {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
RefNameDiv {
|
||||
display: block;
|
||||
}
|
||||
|
||||
RefSect1 {
|
||||
display: block;
|
||||
margin-top: 10pt;
|
||||
}
|
||||
|
||||
RefSect1 Title {
|
||||
font-size: 14pt;
|
||||
}
|
||||
|
||||
RefSect1Info {
|
||||
display: block;
|
||||
font-size: small;
|
||||
}
|
||||
|
||||
RefSect2 {
|
||||
display: block;
|
||||
margin-top: 10pt;
|
||||
}
|
||||
|
||||
RefSect2 Title {
|
||||
font-size: 14pt;
|
||||
}
|
||||
|
||||
RefSect2Info {
|
||||
display: block;
|
||||
font-size: small;
|
||||
}
|
||||
|
||||
RefSect3 {
|
||||
display: block;
|
||||
margin-top: 10pt;
|
||||
}
|
||||
|
||||
RefSect3 Title {
|
||||
font-size: 14pt;
|
||||
}
|
||||
|
||||
RefSect3Info {
|
||||
display: block;
|
||||
font-size: small;
|
||||
}
|
||||
|
||||
RefSynopsisDiv {
|
||||
display: block;
|
||||
margin-top: 15pt;
|
||||
}
|
||||
|
||||
RefSynopsisDiv Title {
|
||||
display: block;
|
||||
font-size: 18pt;
|
||||
}
|
||||
|
||||
Replaceable {
|
||||
font-family: Arial;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
Screen {
|
||||
display: block;
|
||||
margin-left: 20pt;
|
||||
margin-bottom: 10pt;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
ScreenCO {
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
ScreenShot {
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
Sect1 {
|
||||
display: block;
|
||||
margin-top: 16pt;
|
||||
}
|
||||
|
||||
Sect1 Title {
|
||||
font-family: Arial;
|
||||
font-size: 20pt;
|
||||
font-weight: bold;
|
||||
display: block;
|
||||
}
|
||||
|
||||
Sect2 {
|
||||
display: block;
|
||||
margin-top: 15pt;
|
||||
}
|
||||
|
||||
Sect2 Title {
|
||||
font-family: Arial;
|
||||
font-size: 14pt;
|
||||
font-weight: bold;
|
||||
display: block;
|
||||
}
|
||||
|
||||
Sect3 {
|
||||
display: block;
|
||||
margin-top: 15pt;
|
||||
}
|
||||
|
||||
Sect3 Title {
|
||||
font-family: Arial;
|
||||
font-size: 14pt;
|
||||
font-weight: bold;
|
||||
display: block;
|
||||
}
|
||||
|
||||
SegListItem {
|
||||
display: block;
|
||||
}
|
||||
|
||||
SegmentedList {
|
||||
display: block;
|
||||
}
|
||||
|
||||
SegmentedList Title {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
Sidebar {
|
||||
display: block;
|
||||
margin-top: 15pt;
|
||||
margin-left: 30pt;
|
||||
font-family: Arial;
|
||||
font-size: 9pt;
|
||||
}
|
||||
|
||||
Step {
|
||||
display: block;
|
||||
}
|
||||
|
||||
Step Title {
|
||||
display: block;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
Subscript {
|
||||
font-size: 5pt;
|
||||
vertical-align: sub;
|
||||
}
|
||||
|
||||
Subtitle {
|
||||
font-family: Arial;
|
||||
font-size: 20pt;
|
||||
font-weight: bold;
|
||||
display: block;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
Superscript {
|
||||
font-size: 5pt;
|
||||
vertical-align: super;
|
||||
}
|
||||
|
||||
Synopsis {
|
||||
display: block;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
SystemItem {
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
Table {
|
||||
display: block;
|
||||
margin-top: 10pt;
|
||||
}
|
||||
|
||||
Table Title {
|
||||
font-family: Arial;
|
||||
font-size: 10pt;
|
||||
font-style: italic;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
Term {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
Title {
|
||||
font-family: Arial;
|
||||
font-size: 20pt;
|
||||
font-weight: bold;
|
||||
display: block;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
TitleAbbrev {
|
||||
font-family: Arial;
|
||||
font-size: 14pt;
|
||||
font-weight: bold;
|
||||
display: block;
|
||||
}
|
||||
|
||||
ULink {
|
||||
color: blue;
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
UserInput {
|
||||
font-family: monospace;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
VariableList Title {
|
||||
font-weight: bold;
|
||||
display: block;
|
||||
}
|
||||
|
||||
VarListEntry {
|
||||
display: block;
|
||||
margin-top: 10pt;
|
||||
}
|
||||
|
||||
VarListEntry Term {
|
||||
display: block;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
Warning {
|
||||
font-weight: bold;
|
||||
color: fuchsia;
|
||||
}
|
||||
|
||||
Warning:before {
|
||||
content: "Warning:";
|
||||
}
|
||||
|
||||
|
||||
Year {
|
||||
font-family: serif;
|
||||
font-weight: bold;
|
||||
}
|
||||
126
dom/xml/test/old/docbooktest.xml
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="docbook.css" type="text/css"?>
|
||||
<!DOCTYPE Book SYSTEM "docbook.dtd">
|
||||
<Book xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<Title>SoftQuad
|
||||
Inc.</Title>
|
||||
<p xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://www.w3.org/1999/xhtml">
|
||||
<h:img src="flamer.gif"/>
|
||||
<img src="flamer.gif"/>
|
||||
<button><b>some text</b></button>
|
||||
</p>
|
||||
<BookInfo> <BookBiblio> <Title>Demo Product Documentation</Title>
|
||||
<AuthorGroup><CorpAuthor>SoftQuad Inc.</CorpAuthor></AuthorGroup>
|
||||
</BookBiblio> </BookInfo> <Preface> <Title><Anchor
|
||||
Id="SDK3"/>Element Overview</Title>
|
||||
<BridgeHead>Introduction to Elements</BridgeHead>
|
||||
<Para>By far the vast majority of objects (apart from text) that authors
|
||||
encounter when traversing a document are Element nodes. </Para> </Preface>
|
||||
<Part> <Title><Anchor Id="SDK273"/>Element Interfaces</Title>
|
||||
<Chapter Label="1"> <Title><Anchor Id="SDK274"/>Elements and
|
||||
Attributes</Title>
|
||||
<Sect1> <Title><Anchor Id="SDK279"/>Introduction to Attributes
|
||||
</Title>
|
||||
<Para>Elements may have attributes associated with them; since the Element
|
||||
interface inherits from Node, the generic Node interface method
|
||||
<Function>getAttributes</Function> may be used to retrieve the set of all
|
||||
attributes for an element. </Para>
|
||||
<Para>There are methods on the Element interface to retrieve either an Attr
|
||||
object by name or an attribute value by name. In XML, where an attribute value
|
||||
may contain entity references, an Attr object should be retrieved to examine
|
||||
the possibly fairly complex sub-tree representing the attribute value. On the
|
||||
other hand, in HTML, where all attributes have simple string values, methods to
|
||||
directly access an attribute value can safely be used as a convenience. </Para>
|
||||
|
||||
<Para>Before you can access an Attribute, you must first gain access to the
|
||||
associated Element.</Para> </Sect1>
|
||||
<Sect1> <Title><Anchor Id="SDK378"/>Setting the Attribute
|
||||
Values</Title>
|
||||
<Para>Attr objects inherit the Node interface, but since they are not actually
|
||||
child nodes of the element they describe, the DOM does not consider them part
|
||||
of the document tree. Thus, the Node attributes parentNode, previousSibling,
|
||||
and nextSibling have a null value for Attr objects. The DOM takes the view that
|
||||
attributes are properties of elements rather than having a separate identity
|
||||
from the elements they are associated with; this should make it more efficient
|
||||
to implement such features as default attributes associated with all elements
|
||||
of a given type. Furthermore, Attr nodes may not be immediate children of a
|
||||
DocumentFragment. However, they can be associated with Element nodes contained
|
||||
within a DocumentFragment. In short, users and implementors of the DOM need to
|
||||
be aware that Attr nodes have some things in common with other objects
|
||||
inheriting the Node interface, but they also are quite distinct. </Para>
|
||||
<Para>The attribute's effective value is determined as follows:</Para>
|
||||
<ItemizedList Mark="Bullet"> <ListItem>
|
||||
<Para>If this attribute has been explicitly assigned any value, that value is
|
||||
the attribute's effective value</Para></ListItem> <ListItem>
|
||||
<Para>Otherwise, if there is a declaration for this attribute, and that
|
||||
declaration includes a default value, then that default value is the
|
||||
attribute's effective value</Para></ListItem> <ListItem>
|
||||
<Para>Otherwise, the attribute does not exist on this element in the structure
|
||||
model until it has been explicitly added.</Para></ListItem> </ItemizedList>
|
||||
<Para>In XML, where the value of an attribute can contain entity references,
|
||||
the child nodes of the Attr node provide a representation in which entity
|
||||
references are not expanded. These child nodes may be either Text or
|
||||
EntityReference nodes. Because the attribute type may be unknown, there are no
|
||||
tokenized attribute values. </Para>
|
||||
<Para>The following topics describe DOM attributes: </Para>
|
||||
<ItemizedList Mark="Bullet"> <ListItem>
|
||||
<Para>
|
||||
<ULink xlink:type="simple" xlink:show="replace"
|
||||
xlink:href="http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-637646024">Interface
|
||||
Attr</ULink> </Para></ListItem> <ListItem>
|
||||
<Para>
|
||||
<ULink xlink:type="simple" xlink:show="new"
|
||||
xlink:href="http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-745549614">
|
||||
Interface Element</ULink> </Para></ListItem> </ItemizedList> </Sect1></Chapter>
|
||||
|
||||
<Chapter Label="26" Role="funcref"> <Title><Anchor
|
||||
Id="SDK48"/>DOM Level 1 Core: Element Functions</Title>
|
||||
<RefEntry> <RefMeta><RefEntryTitle> <Anchor Id="setAttribute"/>setAttribute
|
||||
</RefEntryTitle></RefMeta> <RefNameDiv> <RefName>setAttribute</RefName>
|
||||
<RefPurpose>Sets the Attributes on the associated Element object</RefPurpose>
|
||||
<RefClass>Fundamental</RefClass> </RefNameDiv> <RefSynopsisDiv> <Title>
|
||||
<Anchor Id="SDK85"/>Syntax</Title>
|
||||
<RefSect2> <Title>OMG IDL</Title>
|
||||
<Synopsis><Type>void</Type> <Function>setAttribute</Function> (in
|
||||
<Type>DOMString</Type> <Parameter>name</Parameter>, in <Type>DOMString</Type>
|
||||
<Parameter>value</Parameter>) raises (<ErrorType>DOMException</ErrorType>);
|
||||
</Synopsis></RefSect2><RefSect2> <Title><Anchor Id="SDK86"/>Java</Title>
|
||||
<Synopsis><Type>public void</Type> <Function>setAttribute</Function> (
|
||||
<Type>String</Type> <Parameter>name</Parameter>, <Type>String</Type>
|
||||
<Parameter>value</Parameter>) throws (<ErrorType>DOMException</ErrorType>);
|
||||
</Synopsis> </RefSect2><RefSect2> <Title><Anchor Id="SDK87"/>ECMA Script
|
||||
</Title>
|
||||
<Synopsis> <Function>setAttribute</Function> (<Parameter>name, value
|
||||
</Parameter>)</Synopsis> </RefSect2></RefSynopsisDiv><RefSect1> <Title>
|
||||
<Anchor Id="SDK88"/>Parameters</Title>
|
||||
<VariableList> <VarListEntry><Term> <Parameter>name</Parameter></Term>
|
||||
<ListItem>
|
||||
<Para>(IN) The name of the attribute to create or alter.</Para> </ListItem>
|
||||
</VarListEntry><VarListEntry><Term> <Parameter>value</Parameter></Term>
|
||||
<ListItem>
|
||||
<Para>(IN) Value to set in string form</Para> </ListItem></VarListEntry>
|
||||
</VariableList></RefSect1><RefSect1> <Title><Anchor Id="SDK89"/>Exceptions
|
||||
</Title>
|
||||
<Para>These are the applicable exceptions. </Para> <InformalTable> <TGroup cols="2">
|
||||
<colspec colname="1" colnum="1" colwidth="0.630in"/>
|
||||
<colspec colname="2" colnum="2" colwidth="5.203in"/> <tbody>
|
||||
<row> <entry colname="1">
|
||||
<Para>INVALID_CHARACTER_ERR</Para></entry> <entry colname="2">
|
||||
<Para>Raised if the specified name contains an invalid character.</Para>
|
||||
</entry></row> <row> <entry colname="1">
|
||||
<Para> NO_MODIFICATION_ALLOWED_ERR</Para></entry> <entry colname="2">
|
||||
<Para>Raised if this node is readonly.</Para></entry> </row>
|
||||
</tbody>
|
||||
</TGroup></InformalTable></RefSect1><RefSect1> <Title><Anchor
|
||||
Id="SDK90"/>Remarks</Title>
|
||||
<Para> <Function>setAttribute</Function> adds a new attribute. If an attribute
|
||||
with that name is already present in the element, its value is changed to be
|
||||
that of the value parameter. This value is a simple string, it is not parsed as
|
||||
it is being set. So any markup (such as syntax to be recognized as an entity
|
||||
reference) is treated as literal text, and needs to be appropriately escaped by
|
||||
the implementation when it is written out.</Para>
|
||||
<Para> In order to assign an attribute value that contains entity references,
|
||||
the user must create an Attr node plus any Text and EntityReference nodes,
|
||||
build the appropriate subtree, and use <Function>setAttributeNode</Function> to
|
||||
assign it as the value of an attribute. </Para> </RefSect1></RefEntry>
|
||||
</Chapter></Part></Book>
|
||||
BIN
dom/xml/test/old/flamer.gif
Normal file
|
After Width: | Height: | Size: 11 KiB |
298
dom/xml/test/old/load/display.css
Normal file
|
|
@ -0,0 +1,298 @@
|
|||
/**
|
||||
* A CSS test file for display.xml
|
||||
*
|
||||
* This file is intentionally long to make parsing
|
||||
* it last a little longer.
|
||||
*/
|
||||
|
||||
/***********************************************
|
||||
* S O M E C O M M E N T S *
|
||||
**********************************************/
|
||||
doc {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* S O M E C O M M E N T S *
|
||||
**********************************************/
|
||||
foo {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* S O M E C O M M E N T S *
|
||||
**********************************************/
|
||||
d {
|
||||
display: block;
|
||||
color: red;
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* S O M E C O M M E N T S *
|
||||
**********************************************/
|
||||
f1 {
|
||||
display: block;
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* S O M E C O M M E N T S *
|
||||
**********************************************/
|
||||
f2 {
|
||||
display: block;
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* S O M E C O M M E N T S *
|
||||
**********************************************/
|
||||
f3 {
|
||||
display: block;
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* S O M E C O M M E N T S *
|
||||
**********************************************/
|
||||
f4 {
|
||||
display: block;
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* S O M E C O M M E N T S *
|
||||
**********************************************/
|
||||
f5 {
|
||||
display: block;
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* S O M E C O M M E N T S *
|
||||
**********************************************/
|
||||
f6 {
|
||||
display: block;
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* S O M E C O M M E N T S *
|
||||
**********************************************/
|
||||
f7 {
|
||||
display: block;
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* S O M E C O M M E N T S *
|
||||
**********************************************/
|
||||
f8 {
|
||||
display: block;
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* S O M E C O M M E N T S *
|
||||
**********************************************/
|
||||
f9 {
|
||||
display: block;
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* S O M E C O M M E N T S *
|
||||
**********************************************/
|
||||
f10 {
|
||||
display: block;
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* S O M E C O M M E N T S *
|
||||
**********************************************/
|
||||
f11 {
|
||||
display: block;
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* S O M E C O M M E N T S *
|
||||
**********************************************/
|
||||
f12 {
|
||||
display: block;
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* S O M E C O M M E N T S *
|
||||
**********************************************/
|
||||
f13 {
|
||||
display: block;
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* S O M E C O M M E N T S *
|
||||
**********************************************/
|
||||
f14 {
|
||||
display: block;
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* S O M E C O M M E N T S *
|
||||
**********************************************/
|
||||
f15 {
|
||||
display: block;
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* S O M E C O M M E N T S *
|
||||
**********************************************/
|
||||
f21 {
|
||||
display: block;
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* S O M E C O M M E N T S *
|
||||
**********************************************/
|
||||
f22 {
|
||||
display: block;
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* S O M E C O M M E N T S *
|
||||
**********************************************/
|
||||
f23 {
|
||||
display: block;
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* S O M E C O M M E N T S *
|
||||
**********************************************/
|
||||
f24 {
|
||||
display: block;
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* S O M E C O M M E N T S *
|
||||
**********************************************/
|
||||
f25 {
|
||||
display: block;
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* S O M E C O M M E N T S *
|
||||
**********************************************/
|
||||
f26 {
|
||||
display: block;
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* S O M E C O M M E N T S *
|
||||
**********************************************/
|
||||
f27 {
|
||||
display: block;
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* S O M E C O M M E N T S *
|
||||
**********************************************/
|
||||
f28 {
|
||||
display: block;
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* S O M E C O M M E N T S *
|
||||
**********************************************/
|
||||
f29 {
|
||||
display: block;
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* S O M E C O M M E N T S *
|
||||
**********************************************/
|
||||
f210 {
|
||||
display: block;
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* S O M E C O M M E N T S *
|
||||
**********************************************/
|
||||
f211 {
|
||||
display: block;
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* S O M E C O M M E N T S *
|
||||
**********************************************/
|
||||
f212 {
|
||||
display: block;
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* S O M E C O M M E N T S *
|
||||
**********************************************/
|
||||
f213 {
|
||||
display: block;
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* S O M E C O M M E N T S *
|
||||
**********************************************/
|
||||
f214 {
|
||||
display: block;
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* S O M E C O M M E N T S *
|
||||
**********************************************/
|
||||
f215 {
|
||||
display: block;
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
}
|
||||
9
dom/xml/test/old/load/display.xml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet type="text/css" href="display.css"?>
|
||||
<!DOCTYPE doc [
|
||||
<!ATTLIST d id ID #IMPLIED>
|
||||
]>
|
||||
<doc>
|
||||
<foo xmlns="foobar">One</foo> <x:bar xmlns:x="barfoo">Two</x:bar>
|
||||
<d id="id3">Three</d>
|
||||
</doc>
|
||||
56
dom/xml/test/old/load/load.html
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Synchronized document.load() test</title>
|
||||
<style type="text/css">
|
||||
.box {
|
||||
display: box;
|
||||
border: 1px solid black;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
.boxheader {
|
||||
font-weight: bold;
|
||||
color: maroon;
|
||||
}
|
||||
pre {
|
||||
margin-left: 2em;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
var xmlDoc = document.implementation.createDocument("", "test", null);
|
||||
|
||||
function documentLoaded(e) {
|
||||
var s = new XMLSerializer();
|
||||
var str = s.serializeToString(xmlDoc);
|
||||
document.getElementById("id1").firstChild.nodeValue = str;
|
||||
var eventProperties = "";
|
||||
for (prop in e) {
|
||||
eventProperties += prop + " : '" + e[prop] + "'\n";
|
||||
}
|
||||
document.getElementById("id2").firstChild.nodeValue =
|
||||
"Event object: " + e + "\n" +
|
||||
"Event properties:\n" +
|
||||
eventProperties;
|
||||
}
|
||||
|
||||
xmlDoc.addEventListener("load", documentLoaded, false);
|
||||
|
||||
function execute()
|
||||
{
|
||||
xmlDoc.load("test.xml");
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body onload="execute();">
|
||||
<h1>Synchronized document.load() test</h1>
|
||||
|
||||
<div class="box"><span class="boxheader">XML document serialized</span>
|
||||
<pre id="id1">@@No result@@</pre>
|
||||
</div>
|
||||
<div class="box"><span class="boxheader">Event information</span>
|
||||
<pre id="id2">@@No result@@</pre>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</body>
|
||||
</html>
|
||||
57
dom/xml/test/old/load/loadauth.html
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Synchronized document.load() test</title>
|
||||
<style type="text/css">
|
||||
.box {
|
||||
display: box;
|
||||
border: 1px solid black;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
.boxheader {
|
||||
font-weight: bold;
|
||||
color: maroon;
|
||||
}
|
||||
pre {
|
||||
margin-left: 2em;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
var xmlDoc = document.implementation.createDocument("", "test", null);
|
||||
|
||||
function documentLoaded(e) {
|
||||
var s = new XMLSerializer();
|
||||
var str = s.serializeToString(xmlDoc);
|
||||
document.getElementById("id1").firstChild.nodeValue = str;
|
||||
var eventProperties = "";
|
||||
for (prop in e) {
|
||||
eventProperties += prop + " : '" + e[prop] + "'\n";
|
||||
}
|
||||
document.getElementById("id2").firstChild.nodeValue =
|
||||
"Event object: " + e + "\n" +
|
||||
"Event properties:\n" +
|
||||
eventProperties;
|
||||
}
|
||||
|
||||
xmlDoc.addEventListener("load", documentLoaded, false);
|
||||
|
||||
function execute()
|
||||
{
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
xmlDoc.load("http://green/heikki/login/data.xml");
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body onload="execute();">
|
||||
<h1>Synchronized document.load() test</h1>
|
||||
|
||||
<div class="box"><span class="boxheader">XML document serialized</span>
|
||||
<pre id="id1">@@No result@@</pre>
|
||||
</div>
|
||||
<div class="box"><span class="boxheader">Event information</span>
|
||||
<pre id="id2">@@No result@@</pre>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</body>
|
||||
</html>
|
||||
56
dom/xml/test/old/load/loaddisplay.html
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Synchronized document.load() test</title>
|
||||
<style type="text/css">
|
||||
.box {
|
||||
display: box;
|
||||
border: 1px solid black;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
.boxheader {
|
||||
font-weight: bold;
|
||||
color: maroon;
|
||||
}
|
||||
pre {
|
||||
margin-left: 2em;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
var xmlDoc = document.implementation.createDocument("", "test", null);
|
||||
|
||||
function documentLoaded(e) {
|
||||
var s = new XMLSerializer();
|
||||
var str = s.serializeToString(xmlDoc);
|
||||
document.getElementById("id1").firstChild.nodeValue = str;
|
||||
var eventProperties = "";
|
||||
for (prop in e) {
|
||||
eventProperties += prop + " : '" + e[prop] + "'\n";
|
||||
}
|
||||
document.getElementById("id2").firstChild.nodeValue =
|
||||
"Event object: " + e + "\n" +
|
||||
"Event properties:\n" +
|
||||
eventProperties;
|
||||
}
|
||||
|
||||
xmlDoc.addEventListener("load", documentLoaded, false);
|
||||
|
||||
function execute()
|
||||
{
|
||||
xmlDoc.load("display.xml");
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body onload="execute();">
|
||||
<h1>Synchronized document.load() test</h1>
|
||||
|
||||
<div class="box"><span class="boxheader">XML document serialized</span>
|
||||
<pre id="id1">@@No result@@</pre>
|
||||
</div>
|
||||
<div class="box"><span class="boxheader">Event information</span>
|
||||
<pre id="id2">@@No result@@</pre>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</body>
|
||||
</html>
|
||||
7
dom/xml/test/old/load/test.xml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE doc [
|
||||
<!ATTLIST p id ID #IMPLIED>
|
||||
]>
|
||||
<doc>
|
||||
<p id="id1">Text from sample XML document.</p>
|
||||
</doc>
|
||||
67
dom/xml/test/old/script.xml
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="docbook.css" type="text/css"?>
|
||||
<!DOCTYPE Book System "file:///E|/Program%20Files/SoftQuad/XMetaL/Rules/docbook.dtd">
|
||||
<Book xmlns:html="http://www.w3.org/1999/xhtml">
|
||||
<Title>The Book</Title>
|
||||
<Chapter>
|
||||
<Title>Chapter 1.</Title>
|
||||
<Para>Yada yada <html:img src="mzcolor.gif"/> yada.</Para>
|
||||
</Chapter>
|
||||
<html:script>
|
||||
<![CDATA[
|
||||
function list(node)
|
||||
{
|
||||
var type = node.nodeType;
|
||||
if (type == Node.ELEMENT_NODE) {
|
||||
|
||||
// open tag
|
||||
dump("\<" + node.tagName);
|
||||
|
||||
// dump the attributes if any
|
||||
attributes = node.attributes;
|
||||
if (null != attributes) {
|
||||
var countAttrs = attributes.length;
|
||||
var index = 0;
|
||||
while(index < countAttrs) {
|
||||
att = attributes[index];
|
||||
if (null != att) {
|
||||
dump(" " + att.name + "=" + att.value);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
// recursively dump the children
|
||||
if (node.hasChildNodes()) {
|
||||
// close tag
|
||||
dump(">");
|
||||
|
||||
// get the children
|
||||
var children = node.childNodes;
|
||||
var length = children.length;
|
||||
var count = 0;
|
||||
while(count < length) {
|
||||
child = children[count];
|
||||
list(child);
|
||||
count++;
|
||||
}
|
||||
dump("</" + node.tagName + ">");
|
||||
}
|
||||
else {
|
||||
// close tag
|
||||
dump("/>");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// if it's a piece of text just dump the text
|
||||
else if (type == Node.TEXT_NODE) {
|
||||
dump(node.data);
|
||||
}
|
||||
}
|
||||
|
||||
list(document.documentElement);
|
||||
dump("\n");
|
||||
]]>
|
||||
</html:script>
|
||||
</Book>
|
||||
10
dom/xml/test/old/simple.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="docbook.css" type="text/css"?>
|
||||
<!DOCTYPE Book SYSTEM "file:///E|/Program%20Files/SoftQuad/XMetaL/Rules/docbook.dtd">
|
||||
<Book xmlns:html="http://www.w3.org/1999/xhtml">
|
||||
<Title>The Book</Title>
|
||||
<Chapter>
|
||||
<Title>Chapter 1.</Title>
|
||||
<Para>Yada yada <html:img src="mzcolor.gif"/> yada.</Para>
|
||||
</Chapter>
|
||||
</Book>
|
||||
137
dom/xml/test/old/toc/book.css
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
/* 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/. */
|
||||
|
||||
/* The book style must be the first style for our JavaScript to work */
|
||||
book {
|
||||
display: block;
|
||||
padding-left: 2em;
|
||||
padding-right: 2em;
|
||||
padding-top: 8px;
|
||||
font-size: 12pt;
|
||||
background-color: lightyellow;
|
||||
font-family: Arial;
|
||||
}
|
||||
|
||||
book title {
|
||||
font-weight: bold;
|
||||
font-size: 24pt;
|
||||
display: block;
|
||||
text-align: center;
|
||||
margin-top: 12pt;
|
||||
margin-bottom: 3pt;
|
||||
}
|
||||
|
||||
book subtitle {
|
||||
display: block;
|
||||
font-size:12pt;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
book abstract {
|
||||
display: block;
|
||||
margin-top: 3pt;
|
||||
}
|
||||
|
||||
input {
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
chapter {
|
||||
display: block;
|
||||
}
|
||||
|
||||
chapter title {
|
||||
font-weight: bold;
|
||||
font-size: 16pt;
|
||||
display: block;
|
||||
text-align: left;
|
||||
margin-top: 12pt;
|
||||
margin-bottom: 3pt;
|
||||
}
|
||||
|
||||
section {
|
||||
display: block;
|
||||
}
|
||||
|
||||
section title {
|
||||
display: block;
|
||||
font-size: 10pt;
|
||||
text-align: left;
|
||||
margin-top: 12pt;
|
||||
margin-bottom: 3pt;
|
||||
}
|
||||
|
||||
contents {
|
||||
display: block;
|
||||
}
|
||||
|
||||
para {
|
||||
display: block;
|
||||
margin-bottom: auto;
|
||||
margin-top: auto;
|
||||
font-size:11pt;
|
||||
}
|
||||
|
||||
link {
|
||||
display: inline;
|
||||
color: blue;
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
list {
|
||||
display: block;
|
||||
margin-right: 0;
|
||||
margin-bottom: auto;
|
||||
margin-top: auto;
|
||||
list-style-type: disc;
|
||||
margin-left: 40px;
|
||||
}
|
||||
|
||||
listitem {
|
||||
display: list-item;
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
emph {
|
||||
font-style: italic;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
ref {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
heading {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
navbar {
|
||||
font-family: Arial;
|
||||
font-size: 10pt;
|
||||
display: block;
|
||||
float: right;
|
||||
background-color: #CCE6F3;
|
||||
color: darkblue;
|
||||
width: 10em;
|
||||
margin-right: 0.5em;
|
||||
}
|
||||
|
||||
navbar title {
|
||||
font-size: 10pt;
|
||||
display: block;
|
||||
background-color: black;
|
||||
color: white;
|
||||
margin-bottom:0px;
|
||||
}
|
||||
|
||||
navbar content {
|
||||
display: block;
|
||||
padding: 0.3em;
|
||||
border: 1px solid black;
|
||||
font-size: 9pt;
|
||||
}
|
||||
|
||||
BIN
dom/xml/test/old/toc/irslogo.gif
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
dom/xml/test/old/toc/minus.gif
Normal file
|
After Width: | Height: | Size: 85 B |
BIN
dom/xml/test/old/toc/plus.gif
Normal file
|
After Width: | Height: | Size: 88 B |
292
dom/xml/test/old/toc/rights.xml
Normal file
|
|
@ -0,0 +1,292 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- Our script expects the book.css stylesheet first -->
|
||||
<?xml-stylesheet href="book.css" type="text/css"?>
|
||||
<?xml-stylesheet href="toc.css" type="text/css"?>
|
||||
<!DOCTYPE book [
|
||||
<!ATTLIST book id ID #IMPLIED>
|
||||
<!ATTLIST chapter id ID #IMPLIED>
|
||||
<!ATTLIST section id ID #IMPLIED>
|
||||
]>
|
||||
<book id="book" xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<html:a name="book"/>
|
||||
<html:script src="toc.js"/>
|
||||
<html:img src="irslogo.gif"/>
|
||||
<navbar>
|
||||
<title>Table of contents</title>
|
||||
<content>
|
||||
To toggle the Table of Contents, click on this button
|
||||
<html:input type="button" value="Contents" onclick="createToc();"/>
|
||||
</content>
|
||||
</navbar>
|
||||
|
||||
<title>Highlights of 1999 Tax Changes</title>
|
||||
<subtitle>(Rev. December 1999)</subtitle>
|
||||
|
||||
<chapter id="chap1">
|
||||
<html:a name="chap1"/>
|
||||
<title>Tax Changes for Individuals</title>
|
||||
<contents>
|
||||
<section id="chap1sec1">
|
||||
<html:a name="chap1sec1"/>
|
||||
<title>Child Tax Credit Increased</title>
|
||||
<contents>
|
||||
<para>
|
||||
The maximum child tax credit for each qualifying child will increase from $400 to $500 in 1999.
|
||||
</para>
|
||||
</contents>
|
||||
</section>
|
||||
<section id="chap1sec2">
|
||||
<html:a name="chap1sec2"/>
|
||||
<title>Standard Mileage Rate</title>
|
||||
<contents>
|
||||
<para>
|
||||
Beginning April 1, 1999, the optional standard mileage rate for operating your carfor business decreases to 31 cents a mile for each business mile. Until then, the business standard mileage rate of 32 1/2 cents per mile that was in effect for 1998 will continue to apply.
|
||||
</para>
|
||||
</contents>
|
||||
</section>
|
||||
<section id="chap1sec3">
|
||||
<html:a name="chap1sec3"/>
|
||||
<title>Estimated Tax Safe Harbor for Higher Income Individuals</title>
|
||||
<contents>
|
||||
<para>
|
||||
For estimated tax payments for tax years beginning in 1999, the safe harbor for higher income individuals (other than farmers and fishermen) has been modified. If your 1998 adjusted gross income was more than $150,000 ($75,000 if you aremarried filing a separate return for 1999), you will have to pay the smaller of 90% of your expected tax for 1999 or 105% (up from 100%) of the tax shown on your 1998 return (provided your 1998 return covered all 12 months) to avoid an estimated tax penalty.
|
||||
</para>
|
||||
<para>
|
||||
For more information on estimated tax, see
|
||||
<link xlink:type="simple" xlink:href="http://www.irs.ustreas.gov/prod/forms_pubs/pubs/p505toc.htm" xlink:show="replace" xlink:actuate="user">Publication 505</link>.
|
||||
</para>
|
||||
</contents>
|
||||
</section>
|
||||
<section id="chap1sec4">
|
||||
<html:a name="chap1sec4"/>
|
||||
<title>Self-Employed Health Insurance Deduction</title>
|
||||
<contents>
|
||||
<para>
|
||||
For 1999, the health insurance deduction for the self-employed is increased from 45% to 60% of the amount you pay for medical insurance for yourself and your family. For more information, see chapter 10 in
|
||||
<link xlink:type="simple" xlink:href="http://www.irs.ustreas.gov/prod/forms_pubs/pubs/p535toc.htm" xlink:show="replace" xlink:actuate="user">Publication 535</link>.
|
||||
</para>
|
||||
</contents>
|
||||
</section>
|
||||
<section id="chap1sec5">
|
||||
<html:a name="chap1sec5"/>
|
||||
<title>Social Security and Medicare Taxes</title>
|
||||
<contents>
|
||||
<para>
|
||||
For 1999, the employer and employee will continue to pay:
|
||||
<list>
|
||||
<listitem>
|
||||
1.6.2% each for social security tax (old-age, survivors, and disability insurance), and
|
||||
</listitem>
|
||||
<listitem>
|
||||
2.1.45% each for Medicare tax (hospital insurance).
|
||||
</listitem>
|
||||
</list>
|
||||
</para>
|
||||
<para>
|
||||
<heading>Wage limits.</heading>
|
||||
For social security tax, the maximum amount of 1999 wages subject to the tax has increased to $72,600. For Medicare tax, all covered 1999 wages are subject to the tax. There is no wage base limit. For information about these taxes, see
|
||||
<link xlink:type="simple" xlink:href="http://www.irs.ustreas.gov/prod/forms_pubs/pubs/p15toc.htm" xlink:show="replace" xlink:actuate="user">Publication 15</link>, <ref>Circular E, Employer's Tax Guide</ref>.
|
||||
</para>
|
||||
</contents>
|
||||
</section>
|
||||
<section id="chap1sec6">
|
||||
<html:a name="chap1sec6"/>
|
||||
<title>Self-Employment Tax</title>
|
||||
<contents>
|
||||
<para>
|
||||
The self-employment tax rate on net earnings remains the same for calendar year1999. This rate, 15.3%, is a total of 12.4% for social security (old-age, survivors, and disability insurance), and 2.9% for Medicare (hospital insurance).
|
||||
</para>
|
||||
<para>
|
||||
The maximum amount subject to the social security part for tax years beginning in 1999 has increased to $72,600. All net earnings of at least $400 are subject to the Medicare part.
|
||||
</para>
|
||||
</contents>
|
||||
</section>
|
||||
</contents>
|
||||
</chapter>
|
||||
|
||||
<chapter id="chap2">
|
||||
<html:a name="chap2"/>
|
||||
<title>Tax Changes for Businesses</title>
|
||||
<contents>
|
||||
<section id="chap2sec1">
|
||||
<html:a name="chap2sec1"/>
|
||||
<title>Social Security and Medicare Taxes</title>
|
||||
<contents>
|
||||
<para>
|
||||
For 1999, the employer and employee will continue to pay:
|
||||
<list>
|
||||
<listitem>
|
||||
6.2% each for social security tax (old-age, survivors, and disability insurance), and
|
||||
</listitem>
|
||||
<listitem>
|
||||
1.45% each for Medicare tax (hospital insurance).
|
||||
</listitem>
|
||||
</list>
|
||||
</para>
|
||||
<para>
|
||||
<heading>Wage limits.</heading> For social security tax, the maximum amount of 1999 wages subject to the tax has increased to $72,600. For Medicare tax, all covered 1999 wages are subject to the tax. There is no wage base limit. For information about these taxes and amounts to withhold, see
|
||||
<link xlink:type="simple" xlink:href="http://www.irs.ustreas.gov/prod/forms_pubs/pubs/p15toc.htm" xlink:show="replace" xlink:actuate="user">Publication 15</link>, <ref>Circular E, Employer's TaxGuide</ref>.
|
||||
</para>
|
||||
</contents>
|
||||
</section>
|
||||
<section id="chap2sec2">
|
||||
<html:a name="chap2sec2"/>
|
||||
<title>Employment Tax Deposits</title>
|
||||
<contents>
|
||||
<para>
|
||||
Under certain circumstances, the IRS can waive the penalty for a first-time depositor's inadvertent failure to timely deposit employment taxes. For deposits required to be made after January 18, 1999, this waiver is expanded to include the first deposit required to be made after a required change in frequency of a taxpayer's deposits.
|
||||
</para>
|
||||
</contents>
|
||||
</section>
|
||||
<section id="chap2sec3">
|
||||
<html:a name="chap2sec3"/>
|
||||
<title>Electronic Deposit of Taxes</title>
|
||||
<contents>
|
||||
<para>
|
||||
If you were first required to deposit taxes by electronic funds transfer after June 30, 1997, the IRS will not impose the penalty for not doing so before July 1, 1999. Previously, the IRS had waived the penalty through December 31, 1998. For information about depositing taxes electronically, see <link xlink:type="simple" xlink:href="http://www.irs.ustreas.gov/prod/forms_pubs/pubs/p15toc.htm" xlink:show="replace" xlink:actuate="user">Publication 15</link>.
|
||||
</para>
|
||||
</contents>
|
||||
</section>
|
||||
<section id="chap2sec4">
|
||||
<html:a name="chap2sec4"/>
|
||||
<title>941 TeleFile</title>
|
||||
<contents>
|
||||
<para>
|
||||
Beginning with the first quarter of 1998, many employers were able to file Form941 by phone, toll free. If you receive 941 TeleFile with your Form 941 package, check page TEL-1 of the <ref>941 TeleFile Instructions</ref> to see if you qualify for this quick, convenient, and easy method of filing.
|
||||
</para>
|
||||
</contents>
|
||||
</section>
|
||||
<section id="chap2sec5">
|
||||
<html:a name="chap2sec5"/>
|
||||
<title>941 On-Line</title>
|
||||
<contents>
|
||||
<para>
|
||||
In 1998, a limited number of employers were allowed to file Form 941 using commercially available software to create the return and then transmitting the return electronically to IRS through a third party. 941 On-Line uses Electronic Data Interchange (EDI) format. In 1999, IRS expects to make the 941 On-Line filing option available nationwide.
|
||||
</para>
|
||||
</contents>
|
||||
</section>
|
||||
<section id="chap2sec6">
|
||||
<html:a name="chap2sec6"/>
|
||||
<title>Self-Employment Tax </title>
|
||||
<contents>
|
||||
<para>
|
||||
The self-employment tax rate on net earnings remains the same for calendar year 1999. This rate, 15.3%, is a total of 12.4% for social security (old-age, survivors,and disability insurance), and 2.9% for Medicare (hospital insurance).
|
||||
</para>
|
||||
<para>
|
||||
The maximum amount subject to the social security part for tax years beginning in 1999 has increased to $72,600. All net earnings of at least $400 are subject to the Medicare part.
|
||||
</para>
|
||||
</contents>
|
||||
</section>
|
||||
</contents>
|
||||
</chapter>
|
||||
|
||||
<chapter id="chap3">
|
||||
<html:a name="chap3"/>
|
||||
<title>IRA and other Retirement Plans</title>
|
||||
<contents>
|
||||
<section id="chap3sec1">
|
||||
<html:a name="chap3sec1"/>
|
||||
<title>Hardship Distributions</title>
|
||||
<contents>
|
||||
<para>
|
||||
Beginning in 1999, hardship distributions from 401(k) plans and 403(b) plans are not eligible rollover distributions. They cannot be rolled over into a traditional IRA. For more information on traditional IRAs, see <link xlink:type="simple" xlink:href="http://www.irs.ustreas.gov/prod/forms_pubs/pubs/p590toc.htm" xlink:show="replace" xlink:actuate="user">Publication 590</link>.
|
||||
</para>
|
||||
</contents>
|
||||
</section>
|
||||
</contents>
|
||||
</chapter>
|
||||
|
||||
<chapter id="chap4">
|
||||
<html:a name="chap4"/>
|
||||
<title>Gift and Estate Taxes</title>
|
||||
<contents>
|
||||
<section id="chap4sec1">
|
||||
<html:a name="chap4sec1"/>
|
||||
<title>New Deduction From Gross Estate</title>
|
||||
<contents>
|
||||
<para>
|
||||
For estates of decedents dying after 1997, the executor can elect to deduct the adjusted value of a qualified family-owned business interest, up to a limited amount, from the gross estate. For more information, see section 2057 of the Internal Revenue Code and the instructions for Schedule T, Form 706, <ref>United States Estate (and Generation-Skipping Transfer) Tax Return</ref>.
|
||||
</para>
|
||||
</contents>
|
||||
</section>
|
||||
<section id="chap4sec2">
|
||||
<html:a name="chap4sec2"/>
|
||||
<title>Suit for Refund</title>
|
||||
<contents>
|
||||
<para>
|
||||
Effective July 23, 1998, an executor no longer needs to wait until all the installment payments have been made before filing a suit for refund with a federal district court or the U.S. Court of Federal Claims if the following conditions are met.
|
||||
<list>
|
||||
<listitem>
|
||||
The estate consists largely of an interest in a closely-held business.
|
||||
</listitem>
|
||||
<listitem>
|
||||
The estate elected to make tax payments through the installment method.
|
||||
</listitem>
|
||||
</list>
|
||||
</para>
|
||||
<para>
|
||||
However, all of the following must be true before a suit can be filed.
|
||||
<list>
|
||||
<listitem>
|
||||
All installment payments due on or before the date the suit is filed have been made.
|
||||
</listitem>
|
||||
<listitem>
|
||||
No accelerated installment payments have been made.
|
||||
</listitem>
|
||||
<listitem>
|
||||
No Tax Court case is pending with respect to any estate tax liability.
|
||||
</listitem>
|
||||
<listitem>
|
||||
The time for petitioning the Tax Court has passed if a notice of deficiency was issued to the estate regarding its liability for estate tax.
|
||||
</listitem>
|
||||
<listitem>
|
||||
No proceeding is pending for a declaratory judgment by the Tax Court on whether the estate is eligible to pay tax in installments.
|
||||
</listitem>
|
||||
</list>
|
||||
</para>
|
||||
<para>
|
||||
In addition, the executor must <emph>not</emph>:
|
||||
<list>
|
||||
<listitem>
|
||||
Include any previously litigated issues in the current suit for refund, and
|
||||
</listitem>
|
||||
<listitem>
|
||||
Discontinue making timely installment payments while the court considers the suit for refund.
|
||||
</listitem>
|
||||
</list>
|
||||
</para>
|
||||
</contents>
|
||||
</section>
|
||||
</contents>
|
||||
</chapter>
|
||||
|
||||
<chapter id="chap5">
|
||||
<html:a name="chap5"/>
|
||||
<title>Excise Tax</title>
|
||||
<contents>
|
||||
<section id="chap5sec1">
|
||||
<html:a name="chap5sec1"/>
|
||||
<title>Air Transportation Taxes</title>
|
||||
<contents>
|
||||
<para>
|
||||
For 1999, the tax on the use of international air travel facilities will be $12.20 for both arrivals and departures. In the case of air transportation between the continental United States and Alaska or between Alaska and Hawaii, the use-of-international-facilities tax on departures will be $6.10.
|
||||
</para>
|
||||
</contents>
|
||||
</section>
|
||||
<section id="chap5sec2">
|
||||
<html:a name="chap5sec2"/>
|
||||
<title>Luxury Tax</title>
|
||||
<contents>
|
||||
<para>
|
||||
For 1999, the luxury tax on a passenger vehicle is reduced from 7% to 6% of the amount of the sales price that exceeds the base amount. The base amount for 1999 is $36,000.
|
||||
</para>
|
||||
<para>
|
||||
The base amount is increased for electric vehicles and clean-fuel vehicles. See <link xlink:type="simple" xlink:href="http://www.irs.ustreas.gov/prod/forms_pubs/pubs/p510toc.htm" xlink:show="replace" xlink:actuate="user">Publication 510</link> for information on these amounts.
|
||||
</para>
|
||||
</contents>
|
||||
</section>
|
||||
</contents>
|
||||
</chapter>
|
||||
|
||||
</book>
|
||||
77
dom/xml/test/old/toc/toc.css
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
/* 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/. */
|
||||
|
||||
toc {
|
||||
position:fixed;
|
||||
top:0;
|
||||
left:0;
|
||||
width:12em;
|
||||
height:100%;
|
||||
border-right: 1px solid black;
|
||||
background-color: #CCE6F3;
|
||||
font-family: Arial;
|
||||
overflow:auto;
|
||||
color: darkblue;
|
||||
}
|
||||
|
||||
toc > title {
|
||||
display: block;
|
||||
font-size:12pt;
|
||||
font-weight: bold;
|
||||
background-color: black;
|
||||
color:white;
|
||||
}
|
||||
|
||||
toclink:visited {
|
||||
color: purple;
|
||||
}
|
||||
|
||||
toclink:active {
|
||||
color: red;
|
||||
}
|
||||
|
||||
level1 {
|
||||
display: block;
|
||||
font-weight:bold;
|
||||
font-size:12pt;
|
||||
margin-left: 4px;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
level1 > toclink {
|
||||
list-style-position: inside;
|
||||
text-decoration: none;
|
||||
color: darkblue;
|
||||
}
|
||||
|
||||
level2 {
|
||||
display: block;
|
||||
font-size:11pt;
|
||||
margin-left: 8px;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
level2 > toclink {
|
||||
list-style-position: inside;
|
||||
text-decoration: none;
|
||||
color: darkblue;
|
||||
}
|
||||
|
||||
level3 {
|
||||
display: list-item;
|
||||
font-size: 8pt;
|
||||
margin-left: 12px;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
level3 > toclink {
|
||||
list-style-position: inside;
|
||||
text-decoration: none;
|
||||
color: darkblue;
|
||||
}
|
||||
|
||||
toc img {
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
117
dom/xml/test/old/toc/toc.js
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
/* 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/. */
|
||||
|
||||
// Event handler for display togglers in Table of Contents
|
||||
function toggleDisplay(event)
|
||||
{
|
||||
if (event.target.localName != "img")
|
||||
return;
|
||||
var img = event.target;
|
||||
var div = img.nextSibling.nextSibling;
|
||||
|
||||
// Change the display: property of the container to
|
||||
// hide and show the container.
|
||||
if (div.style.display == "none") {
|
||||
div.style.display = "block";
|
||||
img.src = "minus.gif";
|
||||
}
|
||||
else {
|
||||
div.style.display = "none";
|
||||
img.src = "plus.gif";
|
||||
}
|
||||
}
|
||||
|
||||
// Function that recurses down the tree, looking for
|
||||
// structural elements. For each structural element,
|
||||
// a corresponding element is created in the table of
|
||||
// contents.
|
||||
var searchTags = new Array("book", "chapter", "section");
|
||||
var tocTags = new Array("level1", "level2", "level3");
|
||||
function addToToc(root, tocFrame)
|
||||
{
|
||||
var i;
|
||||
var newTocFrame = tocFrame;
|
||||
var newTocElement = null;
|
||||
var newTocLink = null;
|
||||
|
||||
for (i=0; i < searchTags.length; i++) {
|
||||
if (root.tagName == searchTags[i]) {
|
||||
// If we've found a structural element, create the
|
||||
// equivalent TOC element.
|
||||
newTocElement = document.createElement(tocTags[i]);
|
||||
// Create the toclink element that is a link to the
|
||||
// corresponding structural element.
|
||||
newTocLink = document.createElement("toclink");
|
||||
newTocLink.setAttributeNS("http://www.w3.org/1999/xlink","xlink:type", "simple");
|
||||
newTocLink.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href", "#"+ root.getAttribute("id"));
|
||||
newTocLink.setAttributeNS("http://www.w3.org/1999/xlink","xlink:show", "replace");
|
||||
newTocElement.appendChild(newTocLink);
|
||||
|
||||
// Create the image and toggling container in the table of contents
|
||||
if (i < searchTags.length-1) {
|
||||
var img = document.createElementNS("http://www.w3.org/1999/xhtml","img");
|
||||
img.src = "minus.gif";
|
||||
newTocElement.insertBefore(img,newTocLink);
|
||||
|
||||
newTocFrame = document.createElementNS("http://www.w3.org/1999/xhtml","div");
|
||||
newTocElement.appendChild(newTocFrame);
|
||||
}
|
||||
else {
|
||||
newTocFrame = null;
|
||||
}
|
||||
|
||||
tocFrame.appendChild(newTocElement);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Recurse down through the childNodes list
|
||||
for (i=0; i < root.childNodes.length; i++) {
|
||||
var child = root.childNodes[i];
|
||||
if (child.nodeType == Node.ELEMENT_NODE) {
|
||||
if ((newTocLink != null) && (child.tagName == "title")) {
|
||||
var text = child.firstChild.cloneNode(true);
|
||||
newTocLink.appendChild(text);
|
||||
}
|
||||
else {
|
||||
addToToc(child, newTocFrame);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create the root table of contents element (a fixed element)
|
||||
// and its contents.
|
||||
function createToc()
|
||||
{
|
||||
if (document.getElementsByTagName("toc").length == 0) {
|
||||
var toc = document.createElement("toc");
|
||||
var title = document.createElement("title");
|
||||
title.appendChild(document.createTextNode("Table of Contents"));
|
||||
toc.appendChild(title);
|
||||
|
||||
// Recurse down and build up the document element
|
||||
addToToc(document.documentElement, toc);
|
||||
|
||||
// Since we've created the toc element as a fixed element,
|
||||
// insert a rule that shifts over the document element by
|
||||
// the width of the toc element.
|
||||
document.styleSheets[0].cssRules[0].style.marginLeft = "12em";
|
||||
document.documentElement.appendChild(toc);
|
||||
|
||||
// Attach the event handler for table of contents buttons.
|
||||
// This will only work for content that is already a part
|
||||
// of a document, which is why we had to wait until here
|
||||
// to do this.
|
||||
toc.addEventListener("mouseup",toggleDisplay,1);
|
||||
} else {
|
||||
// Hide the table of contents.
|
||||
// This is not very intelligent if we have a static document, we should
|
||||
// just hide/show the toc via stylesheet mungling
|
||||
document.documentElement.removeChild(document.getElementsByTagName("toc")[0]);
|
||||
document.styleSheets[0].cssRules[0].style.marginLeft = "0em";
|
||||
}
|
||||
}
|
||||
|
||||
16
dom/xml/test/old/xlink/auto.xml
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="link.css" type="text/css"?>
|
||||
<root xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<p>Testing simple XLinks that must fire immediately on load.</p>
|
||||
<mylink xlink:type="simple" xlink:actuate="onLoad" xlink:show="new" xlink:href="resource:/res/samples/test0.html">
|
||||
Must not open automatically, illegal</mylink>
|
||||
<mylink xlink:type="simple" xlink:actuate="onLoad" xlink:show="new" xlink:href="http://www.mozilla.org">
|
||||
Must open automatically in new window (www.mozilla.org)</mylink>
|
||||
<mylink xlink:type="simple" xlink:actuate="onLoad" xlink:show="new" xlink:href="http://www.mozillazine.org">
|
||||
Must open automatically in new window (www.mozillazine.org)</mylink>
|
||||
<mylink xlink:type="simple" xlink:actuate="onLoad" xlink:show="replace" xlink:href="http://www.mozilla.org/mozorg.html">
|
||||
Must load automatically in same window - "Refresh" (At a glance)</mylink>
|
||||
<mylink xlink:type="simple" xlink:actuate="onLoad" xlink:show="replace" xlink:href="http://www.netscape.com">
|
||||
Must not load automatically, one refresh link fired already (www.netscape.com)</mylink>
|
||||
</root>
|
||||
|
||||
22
dom/xml/test/old/xlink/link.css
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/* 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/. */
|
||||
|
||||
@namespace xlink url(http://www.w3.org/1999/xlink);
|
||||
|
||||
root {
|
||||
display: block;
|
||||
padding: +5px;
|
||||
}
|
||||
|
||||
p {
|
||||
display: block;
|
||||
}
|
||||
|
||||
mylink {
|
||||
display: block;
|
||||
cursor: pointer;
|
||||
color: blue;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
14
dom/xml/test/old/xlink/manual.xml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="link.css" type="text/css"?>
|
||||
<root xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<p>Testing manual simple XLinks.</p>
|
||||
<mylink xlink:type="simple" xlink:show="new" xlink:href="resource:/res/samples/test0.html">
|
||||
Must not open, illegal</mylink>
|
||||
<mylink xlink:type="simple" xlink:show="new" xlink:href="http://www.mozilla.org">
|
||||
Must open in new window (www.mozilla.org)</mylink>
|
||||
<mylink xlink:type="simple" xlink:show="replace" xlink:href="http://www.mozillazine.org">
|
||||
Must open in same window (www.mozillazine.org)</mylink>
|
||||
<mylink xlink:type="simple" xlink:show="foo" xlink:href="http://www.mozilla.org/">
|
||||
Foo</mylink>
|
||||
</root>
|
||||
|
||||
28
dom/xml/test/old/xmlbase/xmlbase.css
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/* 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/. */
|
||||
|
||||
@namespace xlink url(http://www.w3.org/1999/xlink);
|
||||
|
||||
title {
|
||||
font-weight: bold;
|
||||
display: block;
|
||||
}
|
||||
|
||||
xlink|link {
|
||||
color: blue;
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
display: inline;
|
||||
padding-left: +5px;
|
||||
}
|
||||
|
||||
sect1,sect2,sect3 {
|
||||
display: block;
|
||||
padding-left: +20px;
|
||||
}
|
||||
|
||||
p {
|
||||
display: block;
|
||||
padding-left: +5px;
|
||||
}
|
||||
82
dom/xml/test/old/xmlbase/xmlbase.xml
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<?xml-stylesheet href="xmlbase.css" type="text/css"?>
|
||||
<root xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>Root: no xml:base</title>
|
||||
<xlink:link xlink:type="simple" xlink:href="a.xml">a.xml</xlink:link>
|
||||
<p>Expected: <current path>/a.xml</p>
|
||||
<sect1 xml:base="http://www.mozilla.org">
|
||||
<title>Sect1: xml:base="http://www.mozilla.org"</title>
|
||||
<xlink:link xlink:type="simple" xlink:href="b.xml">b.xml</xlink:link>
|
||||
<p>Expected: http://www.mozilla.org/b.xml</p>
|
||||
<sect2 xml:base="/base">
|
||||
<title>Sect2: xml:base="/base"</title>
|
||||
<xlink:link xlink:type="simple" xlink:href="c.xml">c.xml</xlink:link>
|
||||
<p>Expected: http://www.mozilla.org/base/c.xml</p>
|
||||
<sect3 xml:base="">
|
||||
<title>Sect3: xml:base=""</title>
|
||||
<xlink:link xlink:type="simple" xlink:href="d.xml">d.xml</xlink:link>
|
||||
<p>Expected: http://www.mozilla.org/base/d.xml</p>
|
||||
</sect3>
|
||||
<sect3 xml:base="/">
|
||||
<title>Sect3: xml:base="/"</title>
|
||||
<xlink:link xlink:type="simple" xlink:href="d-2.xml">d-2.xml</xlink:link>
|
||||
<p>Expected: http://www.mozilla.org/d-2.xml</p>
|
||||
</sect3>
|
||||
<sect3 xml:base="/foobar">
|
||||
<title>Sect3: xml:base="/foobar"</title>
|
||||
<xlink:link xlink:type="simple" xlink:href="e.xml">e.xml</xlink:link>
|
||||
<p>Expected: http://www.mozilla.org/foobar/e.xml</p>
|
||||
</sect3>
|
||||
<sect3 xml:base="ding/dong">
|
||||
<title>Sect3: xml:base="ding/dong"</title>
|
||||
<xlink:link xlink:type="simple" xlink:href="f.xml">f.xml</xlink:link>
|
||||
<p>Expected: http://www.mozilla.org/base/ding/dong/f.xml</p>
|
||||
</sect3>
|
||||
</sect2>
|
||||
<sect2 xml:base="http://www.netscape.com">
|
||||
<title>Sect2: xml:base="http://www.netscape.com"</title>
|
||||
<xlink:link xlink:type="simple" xlink:href="g.xml">g.xml</xlink:link>
|
||||
<p>Expected: http://www.netscape.com/g.xml</p>
|
||||
</sect2>
|
||||
<sect2 xml:base="http://www.netscape.com">
|
||||
<title>Sect2: xml:base="http://www.netscape.com"</title>
|
||||
<xlink:link xlink:type="simple" xlink:href="http://www.mozilla.org/foobar/h.xml">http://www.mozilla.org/foobar/h.xml</xlink:link>
|
||||
<p>Expected: http://www.mozilla.org/foobar/h.xml</p>
|
||||
</sect2>
|
||||
<sect2 xml:base="http://www.netscape.com">
|
||||
<title>Sect2: xml:base="http://www.netscape.com"</title>
|
||||
<xlink:link xlink:type="simple" xlink:href="i.xml" xml:base="wow">i.xml, this element has xml:base="wow"</xlink:link>
|
||||
<p>Expected: http://www.netscape.com/wow/i.xml</p>
|
||||
</sect2>
|
||||
</sect1>
|
||||
<sect1 xml:base="nothere">
|
||||
<title>Sect1: xml:base="nothere"</title>
|
||||
<xlink:link xlink:type="simple" xlink:href="j.xml">j.xml</xlink:link>
|
||||
<p>Expected: <current path>/nothere/j.xml</p>
|
||||
</sect1>
|
||||
<sect1 xml:base="/not">
|
||||
<title>Sect1: xml:base="/not"</title>
|
||||
<xlink:link xlink:type="simple" xlink:href="k.xml">k.xml</xlink:link>
|
||||
<p>Expected: file:///not/k.xml</p>
|
||||
</sect1>
|
||||
<sect1 xml:base="http://foobar.com/ä ö/">
|
||||
<title>Sect1: xml:base="http://foobar.com/ä ö/"</title>
|
||||
<xlink:link xlink:type="simple" xlink:href="l.xml">l.xml</xlink:link>
|
||||
<p>Expected: http://foobar.com/%E4%20%F6/l.xml</p>
|
||||
</sect1>
|
||||
<sect1 xml:base="http://foobar.com/ /%20/">
|
||||
<title>Sect1: xml:base="http://foobar.com/ /%20/"</title>
|
||||
<xlink:link xlink:type="simple" xlink:href="m.xml">m.xml</xlink:link>
|
||||
<p>Expected: http://foobar.com/%20/%20/m.xml</p>
|
||||
</sect1>
|
||||
<sect1 xml:base="chrome://navigator">
|
||||
<title>Sect1: xml:base="chrome://navigator"</title>
|
||||
<xlink:link xlink:type="simple" xlink:href="n.xml">n.xml</xlink:link>
|
||||
<p>Expected: |current path|/n.xml because chrome URL is not allowed</p>
|
||||
<sect2 xml:base="http://www.mozilla.org">
|
||||
<title>Sect2: xml:base="http://www.mozilla.org"</title>
|
||||
<xlink:link xlink:type="simple" xlink:href="o.xml" xml:base="chrome://navigator">o.xml, this element has xml:base="chrome://navigator"</xlink:link>
|
||||
<p>Expected: http://www.mozilla.org/o.xml because chrome base is not allowed</p>
|
||||
</sect2>
|
||||
</sect1>
|
||||
</root>
|
||||
38
dom/xml/test/test_bug232004.xhtml
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=232004
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 232004</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"/>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=232004">Mozilla Bug 232004</a>
|
||||
<p id="display">
|
||||
<input id="one" type="text" />
|
||||
<input style="display: none" id="two" type="text" />
|
||||
</p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
<![CDATA[
|
||||
|
||||
/** Test for Bug 232004 **/
|
||||
|
||||
$("one").focus();
|
||||
is(document.activeElement, $("one"), "node one should be focused");
|
||||
|
||||
$("two").focus();
|
||||
isnot(document.activeElement, $("two"),
|
||||
"node two has display:none and should not take focus");
|
||||
|
||||
]]>
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
33
dom/xml/test/test_bug293347.html
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=293347
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 293347</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=293347">Mozilla Bug 293347</a>
|
||||
<p id="display"></p>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function done(iframe) {
|
||||
win = iframe.contentWindow;
|
||||
is(win.document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "div")
|
||||
.length, 2, "doc still intact");
|
||||
is(win.document.body.namespaceURI, "http://www.w3.org/1999/xhtml",
|
||||
"doc body still intact");
|
||||
is(win.didThrow, true, "doc.write throwing");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
</script>
|
||||
<iframe src="file_bug293347.xml" onload="done(this)"></iframe>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
39
dom/xml/test/test_bug343870.xhtml
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=343870
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 343870</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=343870">Mozilla Bug 343870</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
<![CDATA[
|
||||
|
||||
/** Test for Bug 343870 **/
|
||||
function doTest() {
|
||||
var dataDoc = document.getElementById("d").contentDocument;
|
||||
is(dataDoc.getElementById("lf").firstChild.data, "\n");
|
||||
is(dataDoc.getElementById("cr").firstChild.data, "\n");
|
||||
is(dataDoc.getElementById("crlf").firstChild.data, "\n");
|
||||
is(dataDoc.getElementById("escapedcr").firstChild.data, "\r");
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(doTest);
|
||||
addLoadEvent(SimpleTest.finish);
|
||||
|
||||
]]>
|
||||
</script>
|
||||
</pre>
|
||||
<iframe id="d" src="data:application/xml,%3C%3Fxml version%3D'1.0' encoding%3D'utf-8'%3F%3E%3Chtml xmlns%3D'http%3A//www.w3.org/1999/xhtml'%3E%3Cp id%3D'lf'%3E%0A%3C/p%3E%3Cp id%3D'cr'%3E%0D%3C/p%3E%3Cp id%3D'crlf'%3E%0D%0A%3C/p%3E%3Cp id%3D'escapedcr'%3E%26%2313;%3C/p%3E%3C/html%3E"></iframe>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
35
dom/xml/test/test_bug355213.xhtml
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=355213
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 355213</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=355213">Mozilla Bug 355213</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
<![CDATA[
|
||||
|
||||
/** Test for Bug 355213 **/
|
||||
var firstWidth = document.getElementById('display').offsetWidth;
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(
|
||||
function() {
|
||||
is(firstWidth, document.getElementById('test').offsetWidth,
|
||||
"Width should not change");
|
||||
});
|
||||
addLoadEvent(SimpleTest.finish);
|
||||
|
||||
]]>
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
42
dom/xml/test/test_bug392338.html
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=392338
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 392338</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=392338">Mozilla Bug 392338</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
/** Test for Bug 392338 **/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(function() {
|
||||
var doc = document.implementation.createDocument("", "", null);
|
||||
|
||||
var chromeScriptUrl = SimpleTest.getTestFileURL("file_bug392338.js");
|
||||
var script = SpecialPowers.loadChromeScript(chromeScriptUrl);
|
||||
|
||||
script.addMessageListener('modify-request-completed', function ml(data) {
|
||||
ok(data, "XMLDocument should have notificationCallbacks");
|
||||
script.removeMessageListener('modify-request-completed', ml);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
|
||||
doc.load(window.location.href);
|
||||
});
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
41
dom/xml/test/test_bug399502.xhtml
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<?xml version="1.0"?>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=399502
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 399502</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=399502">Mozilla Bug 399502</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
<![CDATA[
|
||||
|
||||
/** Test for Bug 399502 **/
|
||||
|
||||
var xmldoc;
|
||||
function runTest() {
|
||||
xmldoc = document.implementation.createDocument("", "", null);
|
||||
xmldoc.onload = function(evt) {
|
||||
ok(true, "Onload handler didn't get called!");
|
||||
SimpleTest.finish();
|
||||
};
|
||||
xmldoc.load("test_bug399502.xhtml");
|
||||
}
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(runTest);
|
||||
|
||||
|
||||
]]>
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
55
dom/xml/test/test_bug445330.html
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=445330
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 445330</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=445330">Mozilla Bug 445330</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
/** Test for Bug 445330 **/
|
||||
|
||||
var loadCounter = 0;
|
||||
var dclCounter = 0;
|
||||
|
||||
function runTest() {
|
||||
var doc = document.implementation.createDocument("", "", null);
|
||||
doc.onload = function(evt) {
|
||||
++loadCounter;
|
||||
ok(dclCounter == 1, "DOMContentLoaded should have fired.");
|
||||
if (loadCounter == 1 && dclCounter == 1) {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
};
|
||||
|
||||
doc.addEventListener("DOMContentLoaded",
|
||||
function (evt) {
|
||||
++dclCounter;
|
||||
ok(loadCounter == 0, "load event shouldn't have fired.");
|
||||
if (loadCounter == 1 && dclCounter == 1) {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
},
|
||||
true);
|
||||
|
||||
doc.load("");
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(runTest);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
52
dom/xml/test/test_bug691215.html
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=691215
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 691215</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=691215">Mozilla Bug 691215</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 691215 **/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var url = "data:text/xml,<root/>";
|
||||
var w;
|
||||
|
||||
addLoadEvent(function() {
|
||||
// Need a separate window because we do not prettyprint in iframes. This is
|
||||
// why this test can't be a crashtest.
|
||||
w = window.open(url);
|
||||
// Need to poll for load completion, sadly
|
||||
setTimeout(checker, 0);
|
||||
});
|
||||
|
||||
function checker() {
|
||||
if (w.location.href != url ||
|
||||
w.document.readyState != "complete") {
|
||||
setTimeout(checker, 0);
|
||||
return;
|
||||
}
|
||||
var doc = w.document;
|
||||
var n = doc.createElement("span");
|
||||
doc.replaceChild(n, doc.documentElement);
|
||||
w.close();
|
||||
ok(1, "Hey, we got here, that's good");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
57
dom/xml/test/test_viewport.xhtml
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
<?xml version="1.0"?>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=436083
|
||||
-->
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<meta name="viewport" content="height=398, width=4224, minimum-scale=0.1,
|
||||
initial-scale=2.3, maximum-scale=45.2, user-scalable=no" />
|
||||
<title>Test for Viewport META Tag Parsing</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=436083">Mozilla Bug 436083</a>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
<![CDATA[
|
||||
|
||||
/** Test for Viewport META Tag **/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function testViewport() {
|
||||
|
||||
/* Grab Viewport Metadata from the document header. */
|
||||
var windowUtils = SpecialPowers.getDOMWindowUtils(window);
|
||||
var vpWidth =
|
||||
parseInt(windowUtils.getDocumentMetadata("viewport-width"));
|
||||
var vpHeight =
|
||||
parseInt(windowUtils.getDocumentMetadata("viewport-height"));
|
||||
var vpInitialScale =
|
||||
parseFloat(windowUtils.getDocumentMetadata("viewport-initial-scale"));
|
||||
var vpMaxScale =
|
||||
parseFloat(windowUtils.getDocumentMetadata("viewport-maximum-scale"));
|
||||
var vpMinScale =
|
||||
parseFloat(windowUtils.getDocumentMetadata("viewport-minimum-scale"));
|
||||
var vpUserScalable =
|
||||
windowUtils.getDocumentMetadata("viewport-user-scalable");
|
||||
|
||||
is(vpWidth, 4224, "Should get proper width");
|
||||
is(vpHeight, 398, "Should get proper height");
|
||||
is(vpInitialScale, 2.3, "Should get proper initial scale");
|
||||
is(vpMaxScale, 45.2, "Should get proper max scale");
|
||||
is(vpMinScale, 0.1, "Should get proper min scale");
|
||||
is(vpUserScalable, "no", "Should get proper user scalable parameter");
|
||||
}
|
||||
|
||||
addLoadEvent(testViewport);
|
||||
addLoadEvent(SimpleTest.finish);
|
||||
]]>
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||