Bug 238327: Implement the svg:style element.

Changes to svg-only files r=afri  (not part of build)
Changes to transformiix files r=peterv sr=jst
Changes to other files r/sr=jst
This commit is contained in:
sicking%bigfoot.com 2004-04-12 23:21:42 +00:00
parent ec6b46ac12
commit 9614803598
11 changed files with 500 additions and 67 deletions

View File

@ -91,6 +91,7 @@ SVG_ATOM(image_rendering, "image-rendering")
SVG_ATOM(kerning, "kerning")
SVG_ATOM(letter_spacing, "letter-spacing")
SVG_ATOM(mask, "mask")
SVG_ATOM(media, "media")
SVG_ATOM(opacity, "opacity")
SVG_ATOM(pathLength, "pathLength")
SVG_ATOM(pointer_events, "pointer-events")
@ -99,6 +100,7 @@ SVG_ATOM(r, "r")
SVG_ATOM(rx, "rx")
SVG_ATOM(ry, "ry")
SVG_ATOM(shape_rendering, "shape-rendering")
SVG_ATOM(space, "sacee")
SVG_ATOM(stroke, "stroke")
SVG_ATOM(stroke_dasharray, "stroke-dasharray")
SVG_ATOM(stroke_dashoffset, "stroke-dashoffset")
@ -111,7 +113,9 @@ SVG_ATOM(style, "style")
SVG_ATOM(text_anchor, "text-anchor")
SVG_ATOM(text_decoration, "text-decoration")
SVG_ATOM(text_rendering, "text-rendering")
SVG_ATOM(title, "title")
SVG_ATOM(transform, "transform")
SVG_ATOM(type, "type")
SVG_ATOM(unicode_bidi, "unicode-bidi")
SVG_ATOM(viewBox, "viewBox")
SVG_ATOM(visibility, "visibility")

View File

@ -39,7 +39,8 @@ REQUIRES = xpcom \
pref \
necko \
xpconnect \
webshell
webshell \
unicharutil
CPPSRCS = \
nsSVGAnimatedLength.cpp \
@ -73,6 +74,7 @@ CPPSRCS = \
nsSVGRect.cpp \
nsSVGRectElement.cpp \
nsSVGSVGElement.cpp \
nsSVGStyleElement.cpp \
nsSVGStyleValue.cpp \
nsSVGTSpanElement.cpp \
nsSVGTextElement.cpp \

View File

@ -91,6 +91,7 @@ SVG_ATOM(image_rendering, "image-rendering")
SVG_ATOM(kerning, "kerning")
SVG_ATOM(letter_spacing, "letter-spacing")
SVG_ATOM(mask, "mask")
SVG_ATOM(media, "media")
SVG_ATOM(opacity, "opacity")
SVG_ATOM(pathLength, "pathLength")
SVG_ATOM(pointer_events, "pointer-events")
@ -99,6 +100,7 @@ SVG_ATOM(r, "r")
SVG_ATOM(rx, "rx")
SVG_ATOM(ry, "ry")
SVG_ATOM(shape_rendering, "shape-rendering")
SVG_ATOM(space, "sacee")
SVG_ATOM(stroke, "stroke")
SVG_ATOM(stroke_dasharray, "stroke-dasharray")
SVG_ATOM(stroke_dashoffset, "stroke-dashoffset")
@ -111,7 +113,9 @@ SVG_ATOM(style, "style")
SVG_ATOM(text_anchor, "text-anchor")
SVG_ATOM(text_decoration, "text-decoration")
SVG_ATOM(text_rendering, "text-rendering")
SVG_ATOM(title, "title")
SVG_ATOM(transform, "transform")
SVG_ATOM(type, "type")
SVG_ATOM(unicode_bidi, "unicode-bidi")
SVG_ATOM(viewBox, "viewBox")
SVG_ATOM(visibility, "visibility")

View File

@ -70,6 +70,8 @@ nsresult
NS_NewSVGTSpanElement(nsIContent **aResult, nsINodeInfo *aNodeInfo);
nsresult
NS_NewSVGImageElement(nsIContent **aResult, nsINodeInfo *aNodeInfo);
nsresult
NS_NewSVGStyleElement(nsIContent **aResult, nsINodeInfo *aNodeInfo);
class nsSVGElementFactory : public nsIElementFactory
@ -147,13 +149,15 @@ nsSVGElementFactory::CreateInstanceByTag(nsINodeInfo *aNodeInfo,
return NS_NewSVGForeignObjectElement(aResult, aNodeInfo);
if (name == nsSVGAtoms::path)
return NS_NewSVGPathElement(aResult, aNodeInfo);
else if (name == nsSVGAtoms::text)
if (name == nsSVGAtoms::text)
return NS_NewSVGTextElement(aResult, aNodeInfo);
else if (name == nsSVGAtoms::tspan)
if (name == nsSVGAtoms::tspan)
return NS_NewSVGTSpanElement(aResult, aNodeInfo);
else if (name == nsSVGAtoms::image)
if (name == nsSVGAtoms::image)
return NS_NewSVGImageElement(aResult, aNodeInfo);
if (name == nsSVGAtoms::style)
return NS_NewSVGStyleElement(aResult, aNodeInfo);
// if we don't know what to create, just create a standard xml element:
return NS_NewXMLElement(aResult, aNodeInfo);
}

View File

@ -0,0 +1,338 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ----- BEGIN LICENSE BLOCK -----
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Mozilla SVG project.
*
* The Initial Developer of the Original Code is
* Crocodile Clips Ltd..
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ----- END LICENSE BLOCK ----- */
#include "nsSVGElement.h"
#include "nsSVGAtoms.h"
#include "nsIDOMSVGStyleElement.h"
#include "nsUnicharUtils.h"
#include "nsStyleLinkElement.h"
typedef nsSVGElement nsSVGStyleElementBase;
class nsSVGStyleElement : public nsSVGStyleElementBase,
public nsIDOMSVGStyleElement,
public nsStyleLinkElement
{
protected:
friend nsresult NS_NewSVGStyleElement(nsIContent **aResult,
nsINodeInfo *aNodeInfo);
nsSVGStyleElement();
virtual ~nsSVGStyleElement();
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMSVGSTYLEELEMENT
// xxx I wish we could use virtual inheritance
NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGStyleElementBase::)
NS_FORWARD_NSIDOMELEMENT(nsSVGStyleElementBase::)
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGStyleElementBase::)
// nsIContent
virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
PRBool aNotify, PRBool aDeepSetDocument);
virtual nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify,
PRBool aDeepSetDocument);
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
virtual void SetDocument(nsIDocument* aDocument, PRBool aDeep,
PRBool aCompileEventHandlers);
nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAString& aValue, PRBool aNotify)
{
return SetAttr(aNameSpaceID, aName, nsnull, aValue, aNotify);
}
virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
nsIAtom* aPrefix, const nsAString& aValue,
PRBool aNotify);
virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
PRBool aNotify);
protected:
// nsStyleLinkElement overrides
void GetStyleSheetURL(PRBool* aIsInline,
nsIURI** aURI);
void GetStyleSheetInfo(nsAString& aTitle,
nsAString& aType,
nsAString& aMedia,
PRBool* aIsAlternate);
};
nsresult NS_NewSVGStyleElement(nsIContent **aResult, nsINodeInfo *aNodeInfo)
{
*aResult = nsnull;
nsSVGStyleElement* it = new nsSVGStyleElement();
if (!it) return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(it);
nsresult rv = it->Init(aNodeInfo);
if (NS_FAILED(rv)) {
it->Release();
return rv;
}
*aResult = it;
return NS_OK;
}
//----------------------------------------------------------------------
// nsISupports methods
NS_IMPL_ADDREF_INHERITED(nsSVGStyleElement,nsSVGStyleElementBase)
NS_IMPL_RELEASE_INHERITED(nsSVGStyleElement,nsSVGStyleElementBase)
NS_INTERFACE_MAP_BEGIN(nsSVGStyleElement)
NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGStyleElement)
NS_INTERFACE_MAP_ENTRY(nsIDOMLinkStyle)
NS_INTERFACE_MAP_ENTRY(nsIStyleSheetLinkingElement)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGStyleElement)
NS_INTERFACE_MAP_END_INHERITING(nsSVGStyleElementBase)
//----------------------------------------------------------------------
// Implementation
nsSVGStyleElement::nsSVGStyleElement()
{
}
nsSVGStyleElement::~nsSVGStyleElement()
{
}
//----------------------------------------------------------------------
// nsIDOMNode methods
NS_IMETHODIMP
nsSVGStyleElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
{
*aReturn = nsnull;
nsSVGStyleElement* it = new nsSVGStyleElement();
if (!it) return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(it);
nsresult rv = it->Init(mNodeInfo);
if (NS_FAILED(rv)) {
it->Release();
return rv;
}
rv = CopyNode(it, aDeep);
if (NS_FAILED(rv)) {
it->Release();
return rv;
}
*aReturn = it;
return NS_OK;
}
//----------------------------------------------------------------------
// nsIContent methods
nsresult
nsSVGStyleElement::InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
PRBool aNotify, PRBool aDeepSetDocument)
{
nsresult rv =
nsSVGStyleElementBase::InsertChildAt(aKid, aIndex, aNotify,
aDeepSetDocument);
if (NS_SUCCEEDED(rv)) {
UpdateStyleSheet();
}
return rv;
}
nsresult
nsSVGStyleElement::AppendChildTo(nsIContent* aKid, PRBool aNotify,
PRBool aDeepSetDocument)
{
nsresult rv =
nsSVGStyleElementBase::AppendChildTo(aKid, aNotify, aDeepSetDocument);
if (NS_SUCCEEDED(rv)) {
UpdateStyleSheet();
}
return rv;
}
nsresult
nsSVGStyleElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
{
nsresult rv = nsSVGStyleElementBase::RemoveChildAt(aIndex, aNotify);
if (NS_SUCCEEDED(rv)) {
UpdateStyleSheet();
}
return rv;
}
void
nsSVGStyleElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
PRBool aCompileEventHandlers)
{
nsCOMPtr<nsIDocument> oldDoc = mDocument;
nsSVGStyleElementBase::SetDocument(aDocument, aDeep, aCompileEventHandlers);
UpdateStyleSheet(oldDoc);
}
nsresult
nsSVGStyleElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
nsIAtom* aPrefix, const nsAString& aValue,
PRBool aNotify)
{
nsresult rv = nsSVGStyleElementBase::SetAttr(aNameSpaceID, aName, aPrefix,
aValue, aNotify);
if (NS_SUCCEEDED(rv)) {
UpdateStyleSheet();
}
return rv;
}
nsresult
nsSVGStyleElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
PRBool aNotify)
{
nsresult rv = nsSVGStyleElementBase::UnsetAttr(aNameSpaceID, aAttribute,
aNotify);
if (NS_SUCCEEDED(rv)) {
UpdateStyleSheet();
}
return rv;
}
//----------------------------------------------------------------------
// nsIDOMSVGStyleElement methods
/* attribute DOMString xmlspace; */
NS_IMETHODIMP nsSVGStyleElement::GetXmlspace(nsAString & aXmlspace)
{
GetAttr(kNameSpaceID_XML, nsSVGAtoms::space, aXmlspace);
return NS_OK;
}
NS_IMETHODIMP nsSVGStyleElement::SetXmlspace(const nsAString & aXmlspace)
{
return SetAttr(kNameSpaceID_XML, nsSVGAtoms::space, aXmlspace, PR_TRUE);
}
/* attribute DOMString type; */
NS_IMETHODIMP nsSVGStyleElement::GetType(nsAString & aType)
{
GetAttr(kNameSpaceID_None, nsSVGAtoms::type, aType);
return NS_OK;
}
NS_IMETHODIMP nsSVGStyleElement::SetType(const nsAString & aType)
{
return SetAttr(kNameSpaceID_None, nsSVGAtoms::type, aType, PR_TRUE);
}
/* attribute DOMString media; */
NS_IMETHODIMP nsSVGStyleElement::GetMedia(nsAString & aMedia)
{
GetAttr(kNameSpaceID_None, nsSVGAtoms::media, aMedia);
return NS_OK;
}
NS_IMETHODIMP nsSVGStyleElement::SetMedia(const nsAString & aMedia)
{
return SetAttr(kNameSpaceID_XML, nsSVGAtoms::media, aMedia, PR_TRUE);
}
/* attribute DOMString title; */
NS_IMETHODIMP nsSVGStyleElement::GetTitle(nsAString & aTitle)
{
GetAttr(kNameSpaceID_None, nsSVGAtoms::title, aTitle);
return NS_OK;
}
NS_IMETHODIMP nsSVGStyleElement::SetTitle(const nsAString & aTitle)
{
return SetAttr(kNameSpaceID_XML, nsSVGAtoms::title, aTitle, PR_TRUE);
}
//----------------------------------------------------------------------
// nsStyleLinkElement methods
void
nsSVGStyleElement::GetStyleSheetURL(PRBool* aIsInline,
nsIURI** aURI)
{
*aURI = nsnull;
*aIsInline = PR_TRUE;
return;
}
void
nsSVGStyleElement::GetStyleSheetInfo(nsAString& aTitle,
nsAString& aType,
nsAString& aMedia,
PRBool* aIsAlternate)
{
*aIsAlternate = PR_FALSE;
nsAutoString title;
GetAttr(kNameSpaceID_None, nsSVGAtoms::title, title);
title.CompressWhitespace();
aTitle.Assign(title);
GetAttr(kNameSpaceID_None, nsSVGAtoms::media, aMedia);
// SVG spec refers to the HTML4.0 spec which is inconsistent, make it
// case INSENSITIVE
ToLowerCase(aMedia);
GetAttr(kNameSpaceID_None, nsSVGAtoms::type, aType);
return;
}

View File

@ -427,83 +427,95 @@ nsXMLContentSink::CreateElement(const PRUnichar** aAtts, PRUint32 aAttsCount,
{
NS_ASSERTION(aNodeInfo, "can't create element without nodeinfo");
*aResult = nsnull;
*aAppendContent = PR_TRUE;
nsresult rv = NS_OK;
PRInt32 nameSpaceID = aNodeInfo->NamespaceID();
nsCOMPtr<nsIContent> content;
// XHTML needs some special attention
if (nameSpaceID != kNameSpaceID_XHTML) {
if (aNodeInfo->NamespaceEquals(kNameSpaceID_XHTML)) {
mPrettyPrintHasFactoredElements = PR_TRUE;
nsIHTMLContent* htmlContent = nsnull;
rv = NS_CreateHTMLElement(&htmlContent, aNodeInfo, PR_TRUE);
NS_ENSURE_SUCCESS(rv, rv);
nsIContent* tmp = htmlContent;
content.swap(tmp);
}
else {
// The first step here is to see if someone has provided their
// own content element implementation (e.g., XUL or MathML).
// This is done based off a contractid/namespace scheme.
nsCOMPtr<nsIElementFactory> elementFactory;
rv = nsContentUtils::GetNSManagerWeakRef()->
GetElementFactory(nameSpaceID, getter_AddRefs(elementFactory));
GetElementFactory(aNodeInfo->NamespaceID(),
getter_AddRefs(elementFactory));
NS_ENSURE_SUCCESS(rv, rv);
elementFactory->CreateInstanceByTag(aNodeInfo, aResult);
rv = elementFactory->CreateInstanceByTag(aNodeInfo,
getter_AddRefs(content));
NS_ENSURE_SUCCESS(rv, rv);
// If we care, find out if we just used a special factory.
if (!mPrettyPrintHasFactoredElements && !mPrettyPrintHasSpecialRoot &&
mPrettyPrintXML) {
PRBool hasFactory = PR_FALSE;
rv = nsContentUtils::GetNSManagerWeakRef()->HasRegisteredFactory(nameSpaceID, &hasFactory);
rv = nsContentUtils::GetNSManagerWeakRef()->
HasRegisteredFactory(aNodeInfo->NamespaceID(), &hasFactory);
NS_ENSURE_SUCCESS(rv, rv);
mPrettyPrintHasFactoredElements = hasFactory;
}
return NS_OK;
if (!aNodeInfo->NamespaceEquals(kNameSpaceID_SVG)) {
content.swap(*aResult);
return NS_OK;
}
}
mPrettyPrintHasFactoredElements = PR_TRUE;
nsCOMPtr<nsIHTMLContent> htmlContent;
rv = NS_CreateHTMLElement(getter_AddRefs(htmlContent), aNodeInfo, PR_TRUE);
NS_ENSURE_SUCCESS(rv, rv);
rv = CallQueryInterface(htmlContent, aResult);
NS_ENSURE_SUCCESS(rv, rv);
nsIAtom *tagAtom = aNodeInfo->NameAtom();
if (tagAtom == nsHTMLAtoms::script) {
if (aNodeInfo->Equals(nsHTMLAtoms::script, kNameSpaceID_XHTML)) {
// Don't append the content to the tree until we're all
// done collecting its contents
mConstrainSize = PR_FALSE;
mScriptLineNo = aLineNumber;
*aAppendContent = PR_FALSE;
}
else if (tagAtom == nsHTMLAtoms::title) {
else if (aNodeInfo->Equals(nsHTMLAtoms::title, kNameSpaceID_XHTML)) {
if (mTitleText.IsEmpty()) {
mInTitle = PR_TRUE; // The first title wins
}
}
else if (tagAtom == nsHTMLAtoms::link || tagAtom == nsHTMLAtoms::style) {
nsCOMPtr<nsIStyleSheetLinkingElement> ssle(do_QueryInterface(htmlContent));
else if (aNodeInfo->Equals(nsHTMLAtoms::link, kNameSpaceID_XHTML) ||
aNodeInfo->Equals(nsHTMLAtoms::style, kNameSpaceID_XHTML) ||
aNodeInfo->Equals(nsHTMLAtoms::style, kNameSpaceID_SVG)) {
nsCOMPtr<nsIStyleSheetLinkingElement> ssle(do_QueryInterface(content));
if (ssle) {
ssle->InitStyleLinkElement(mParser, PR_FALSE);
ssle->SetEnableUpdates(PR_FALSE);
}
} else if (tagAtom == nsHTMLAtoms::img ||
tagAtom == nsHTMLAtoms::input ||
tagAtom == nsHTMLAtoms::object ||
tagAtom == nsHTMLAtoms::applet) {
}
else if (aNodeInfo->Equals(nsHTMLAtoms::img, kNameSpaceID_XHTML) ||
aNodeInfo->Equals(nsHTMLAtoms::input, kNameSpaceID_XHTML) ||
aNodeInfo->Equals(nsHTMLAtoms::object, kNameSpaceID_XHTML) ||
aNodeInfo->Equals(nsHTMLAtoms::applet, kNameSpaceID_XHTML)) {
nsAutoString cmd;
if (mParser) {
mParser->GetCommand(cmd);
}
if (cmd.EqualsWithConversion(kLoadAsData)) {
// XXXbz Should this be in HandleStartElement so it applies to all
// elements, not just XHTML ones? We don't have any non-XHTML
// image loading things yet, but....
nsCOMPtr<nsIImageLoadingContent> imgLoader(do_QueryInterface(htmlContent));
// XXXbz Should this be done to all elements, not just XHTML ones?
// We don't have any non-XHTML image loading things yet, but....
nsCOMPtr<nsIImageLoadingContent> imgLoader(do_QueryInterface(content));
if (imgLoader) {
imgLoader->SetLoadingEnabled(PR_FALSE);
}
}
}
content.swap(*aResult);
return NS_OK;
}
@ -514,19 +526,22 @@ nsXMLContentSink::CloseElement(nsIContent* aContent, PRBool* aAppendContent)
NS_ASSERTION(aContent, "missing element to close");
*aAppendContent = PR_FALSE;
if (!aContent->IsContentOfType(nsIContent::eHTML)) {
nsINodeInfo* nodeInfo = aContent->GetNodeInfo();
if (!nodeInfo->NamespaceEquals(kNameSpaceID_XHTML) &&
!nodeInfo->NamespaceEquals(kNameSpaceID_SVG)) {
return NS_OK;
}
nsIAtom *tagAtom = aContent->Tag();
nsresult rv = NS_OK;
if (tagAtom == nsHTMLAtoms::script) {
if (nodeInfo->Equals(nsHTMLAtoms::script, kNameSpaceID_XHTML)) {
rv = ProcessEndSCRIPTTag(aContent);
*aAppendContent = PR_TRUE;
}
else if (tagAtom == nsHTMLAtoms::title && mInTitle) {
else if (nodeInfo->Equals(nsHTMLAtoms::title, kNameSpaceID_XHTML) &&
mInTitle) {
// The first title wins
nsCOMPtr<nsIDOMNSDocument> dom_doc(do_QueryInterface(mDocument));
if (dom_doc) {
@ -535,17 +550,19 @@ nsXMLContentSink::CloseElement(nsIContent* aContent, PRBool* aAppendContent)
}
mInTitle = PR_FALSE;
}
else if (tagAtom == nsHTMLAtoms::base && !mHasProcessedBase) {
else if (nodeInfo->Equals(nsHTMLAtoms::base, kNameSpaceID_XHTML) &&
!mHasProcessedBase) {
// The first base wins
rv = ProcessBASETag(aContent);
mHasProcessedBase = PR_TRUE;
}
else if (tagAtom == nsHTMLAtoms::meta) {
else if (nodeInfo->Equals(nsHTMLAtoms::meta, kNameSpaceID_XHTML)) {
rv = ProcessMETATag(aContent);
}
else if (tagAtom == nsHTMLAtoms::link || tagAtom == nsHTMLAtoms::style) {
else if (nodeInfo->Equals(nsHTMLAtoms::link, kNameSpaceID_XHTML) ||
nodeInfo->Equals(nsHTMLAtoms::style, kNameSpaceID_XHTML) ||
nodeInfo->Equals(nsHTMLAtoms::style, kNameSpaceID_SVG)) {
nsCOMPtr<nsIStyleSheetLinkingElement> ssle(do_QueryInterface(aContent));
if (ssle) {
ssle->SetEnableUpdates(PR_TRUE);
rv = ssle->UpdateStyleSheet(nsnull, nsnull);

View File

@ -67,6 +67,7 @@ XPIDLSRCS = \
nsIDOMSVGRectElement.idl \
nsIDOMSVGSVGElement.idl \
nsIDOMSVGStylable.idl \
nsIDOMSVGStyleElement.idl \
nsIDOMSVGTextContentElement.idl \
nsIDOMSVGTextElement.idl \
nsIDOMSVGTextPositionElem.idl \

View File

@ -0,0 +1,53 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* IBM Corporation.
* Portions created by the Initial Developer are Copyright (C) 2003
* IBM Corporation. All Rights Reserved.
*
* Contributor(s):
* IBM Corporation
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIDOMSVGElement.idl"
[scriptable, uuid(9af0d129-b366-4aa8-b7d8-8dce93148d91)]
interface nsIDOMSVGStyleElement
: nsIDOMSVGElement
{
attribute DOMString xmlspace;
// raises DOMException on setting
attribute DOMString type;
// raises DOMException on setting
attribute DOMString media;
// raises DOMException on setting
attribute DOMString title;
// raises DOMException on setting
};

View File

@ -285,6 +285,7 @@ enum nsDOMClassInfoID {
eDOMClassInfo_SVGTSpanElement_id,
eDOMClassInfo_SVGAnimatedString_id,
eDOMClassInfo_SVGImageElement_id,
eDOMClassInfo_SVGStyleElement_id,
#endif //MOZ_SVG
// This one better be the last one in this list

View File

@ -331,6 +331,7 @@
#include "nsIDOMSVGAnimatedString.h"
#include "nsIDOMSVGImageElement.h"
#include "nsIDOMSVGURIReference.h"
#include "nsIDOMSVGStyleElement.h"
#endif
#include "nsIImageDocument.h"
@ -866,6 +867,8 @@ static nsDOMClassInfoData sClassInfoData[] = {
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGImageElement, nsElementSH,
ELEMENT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGStyleElement, nsElementSH,
ELEMENT_SCRIPTABLE_FLAGS)
#endif
};
@ -2325,6 +2328,12 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(SVGStyleElement, nsIDOMSVGStyleElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStyleElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMLinkStyle)
DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
#endif //MOZ_SVG
#ifdef NS_DEBUG

View File

@ -264,6 +264,23 @@ void txMozillaXMLOutput::endElement(const nsAString& aName, const PRInt32 aNsID)
endHTMLElement(element);
}
if (mCreatingNewDocument) {
// Handle all sorts of stylesheets
nsCOMPtr<nsIStyleSheetLinkingElement> ssle =
do_QueryInterface(mCurrentNode);
if (ssle) {
ssle->SetEnableUpdates(PR_TRUE);
if (ssle->UpdateStyleSheet(nsnull, mNotifier) ==
NS_ERROR_HTMLPARSER_BLOCK) {
nsCOMPtr<nsIStyleSheet> stylesheet;
ssle->GetStyleSheet(*getter_AddRefs(stylesheet));
if (mNotifier) {
mNotifier->AddStyleSheet(stylesheet);
}
}
}
}
// Add the element to the tree if it wasn't added before and take one step
// up the tree
// we can't use GetParentNode to check if mCurrentNode is the
@ -416,6 +433,14 @@ void txMozillaXMLOutput::startElement(const nsAString& aName,
}
if (mCreatingNewDocument) {
// Handle all sorts of stylesheets
nsCOMPtr<nsIStyleSheetLinkingElement> ssle =
do_QueryInterface(element);
if (ssle) {
ssle->InitStyleLinkElement(nsnull, PR_FALSE);
ssle->SetEnableUpdates(PR_FALSE);
}
nsCOMPtr<nsIContent> cont = do_QueryInterface(element);
NS_ASSERTION(cont, "element doesn't implement nsIContent");
nsCOMPtr<nsIDocument> doc = do_QueryInterface(mDocument);
@ -569,14 +594,6 @@ void txMozillaXMLOutput::startHTMLElement(nsIDOMElement* aElement, PRBool aXHTML
rv = aElement->AppendChild(meta, getter_AddRefs(dummy));
NS_ASSERTION(NS_SUCCEEDED(rv), "Can't append meta");
}
else if (mCreatingNewDocument) {
nsCOMPtr<nsIStyleSheetLinkingElement> ssle =
do_QueryInterface(aElement);
if (ssle) {
ssle->InitStyleLinkElement(nsnull, PR_FALSE);
ssle->SetEnableUpdates(PR_FALSE);
}
}
}
void txMozillaXMLOutput::endHTMLElement(nsIDOMElement* aElement)
@ -656,23 +673,6 @@ void txMozillaXMLOutput::endHTMLElement(nsIDOMElement* aElement)
nsCOMPtr<nsIAtom> header = do_GetAtom(httpEquiv);
processHTTPEquiv(header, value);
}
// Handle all sorts of stylesheets
if (mCreatingNewDocument) {
nsCOMPtr<nsIStyleSheetLinkingElement> ssle =
do_QueryInterface(aElement);
if (ssle) {
ssle->SetEnableUpdates(PR_TRUE);
rv = ssle->UpdateStyleSheet(nsnull, mNotifier);
if (rv == NS_ERROR_HTMLPARSER_BLOCK) {
nsCOMPtr<nsIStyleSheet> stylesheet;
ssle->GetStyleSheet(*getter_AddRefs(stylesheet));
if (mNotifier) {
mNotifier->AddStyleSheet(stylesheet);
}
}
}
}
}
void txMozillaXMLOutput::processHTTPEquiv(nsIAtom* aHeader, const nsAString& aValue)