2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-01-05 05:50:21 +04:00
|
|
|
/* 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/. */
|
|
|
|
|
2013-01-09 03:25:47 +04:00
|
|
|
#include "mozilla/dom/Element.h"
|
2013-01-05 05:50:21 +04:00
|
|
|
#include "mozilla/dom/SVGStyleElement.h"
|
|
|
|
#include "nsContentUtils.h"
|
|
|
|
#include "mozilla/dom/SVGStyleElementBinding.h"
|
|
|
|
|
|
|
|
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Style)
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
JSObject*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
SVGStyleElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-01-05 05:50:21 +04:00
|
|
|
{
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
return SVGStyleElementBinding::Wrap(aCx, this, aGivenProto);
|
2013-01-05 05:50:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISupports methods
|
|
|
|
|
2017-09-01 02:29:22 +03:00
|
|
|
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(SVGStyleElement,
|
|
|
|
SVGStyleElementBase,
|
|
|
|
nsIStyleSheetLinkingElement,
|
|
|
|
nsIMutationObserver)
|
2013-01-05 05:50:21 +04:00
|
|
|
|
2013-08-02 05:29:05 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(SVGStyleElement)
|
|
|
|
|
2013-01-05 05:50:21 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(SVGStyleElement,
|
|
|
|
SVGStyleElementBase)
|
|
|
|
tmp->nsStyleLinkElement::Traverse(cb);
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
2013-08-02 05:29:05 +04:00
|
|
|
|
2013-01-05 05:50:21 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(SVGStyleElement,
|
|
|
|
SVGStyleElementBase)
|
|
|
|
tmp->nsStyleLinkElement::Unlink();
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
2014-06-20 06:01:40 +04:00
|
|
|
SVGStyleElement::SVGStyleElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
2013-01-05 05:50:21 +04:00
|
|
|
: SVGStyleElementBase(aNodeInfo)
|
|
|
|
{
|
|
|
|
AddMutationObserver(this);
|
|
|
|
}
|
|
|
|
|
2014-07-09 01:23:16 +04:00
|
|
|
SVGStyleElement::~SVGStyleElement()
|
|
|
|
{
|
|
|
|
}
|
2013-01-05 05:50:21 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIDOMNode methods
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGStyleElement)
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIContent methods
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
SVGStyleElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent,
|
|
|
|
bool aCompileEventHandlers)
|
|
|
|
{
|
|
|
|
nsresult rv = SVGStyleElementBase::BindToTree(aDocument, aParent,
|
|
|
|
aBindingParent,
|
|
|
|
aCompileEventHandlers);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
void (SVGStyleElement::*update)() = &SVGStyleElement::UpdateStyleSheetInternal;
|
2017-06-12 22:34:10 +03:00
|
|
|
nsContentUtils::AddScriptRunner(
|
|
|
|
NewRunnableMethod("dom::SVGStyleElement::BindToTree", this, update));
|
2013-01-05 05:50:21 +04:00
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SVGStyleElement::UnbindFromTree(bool aDeep, bool aNullParent)
|
|
|
|
{
|
2014-10-03 16:32:26 +04:00
|
|
|
nsCOMPtr<nsIDocument> oldDoc = GetUncomposedDoc();
|
2014-06-12 05:15:22 +04:00
|
|
|
ShadowRoot* oldShadow = GetContainingShadow();
|
2013-01-05 05:50:21 +04:00
|
|
|
SVGStyleElementBase::UnbindFromTree(aDeep, aNullParent);
|
2018-04-24 13:50:35 +03:00
|
|
|
Unused << UpdateStyleSheetInternal(oldDoc, oldShadow);
|
2013-01-05 05:50:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2018-01-03 22:21:23 +03:00
|
|
|
SVGStyleElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
|
|
|
|
const nsAttrValue* aValue,
|
|
|
|
const nsAttrValue* aOldValue,
|
|
|
|
nsIPrincipal* aMaybeScriptedPrincipal,
|
|
|
|
bool aNotify)
|
2013-01-05 05:50:21 +04:00
|
|
|
{
|
2018-01-03 22:21:23 +03:00
|
|
|
if (aNameSpaceID == kNameSpaceID_None) {
|
2013-01-09 03:25:48 +04:00
|
|
|
if (aName == nsGkAtoms::title ||
|
|
|
|
aName == nsGkAtoms::media ||
|
|
|
|
aName == nsGkAtoms::type) {
|
2018-04-24 13:50:35 +03:00
|
|
|
Unused << UpdateStyleSheetInternal(nullptr, nullptr, ForceUpdate::Yes);
|
2013-01-09 03:25:48 +04:00
|
|
|
}
|
2013-01-05 05:50:21 +04:00
|
|
|
}
|
|
|
|
|
2018-01-03 22:21:23 +03:00
|
|
|
return SVGStyleElementBase::AfterSetAttr(aNameSpaceID, aName, aValue,
|
|
|
|
aOldValue, aMaybeScriptedPrincipal,
|
|
|
|
aNotify);
|
2013-01-05 05:50:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SVGStyleElement::ParseAttribute(int32_t aNamespaceID,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* aAttribute,
|
2013-01-05 05:50:21 +04:00
|
|
|
const nsAString& aValue,
|
2017-11-02 06:35:52 +03:00
|
|
|
nsIPrincipal* aMaybeScriptedPrincipal,
|
2013-01-05 05:50:21 +04:00
|
|
|
nsAttrValue& aResult)
|
|
|
|
{
|
|
|
|
if (aNamespaceID == kNameSpaceID_None &&
|
|
|
|
aAttribute == nsGkAtoms::crossorigin) {
|
|
|
|
ParseCORSValue(aValue, aResult);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return SVGStyleElementBase::ParseAttribute(aNamespaceID, aAttribute, aValue,
|
2017-11-02 06:35:52 +03:00
|
|
|
aMaybeScriptedPrincipal, aResult);
|
2013-01-05 05:50:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIMutationObserver methods
|
|
|
|
|
|
|
|
void
|
2018-03-01 14:36:58 +03:00
|
|
|
SVGStyleElement::CharacterDataChanged(nsIContent* aContent,
|
2018-02-27 17:30:27 +03:00
|
|
|
const CharacterDataChangeInfo&)
|
2013-01-05 05:50:21 +04:00
|
|
|
{
|
|
|
|
ContentChanged(aContent);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-03-01 14:36:58 +03:00
|
|
|
SVGStyleElement::ContentAppended(nsIContent* aFirstNewContent)
|
2013-01-05 05:50:21 +04:00
|
|
|
{
|
2018-03-01 14:36:58 +03:00
|
|
|
ContentChanged(aFirstNewContent->GetParent());
|
2013-01-05 05:50:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-03-01 14:36:58 +03:00
|
|
|
SVGStyleElement::ContentInserted(nsIContent* aChild)
|
2013-01-05 05:50:21 +04:00
|
|
|
{
|
|
|
|
ContentChanged(aChild);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-03-01 14:36:58 +03:00
|
|
|
SVGStyleElement::ContentRemoved(nsIContent* aChild,
|
2013-01-05 05:50:21 +04:00
|
|
|
nsIContent* aPreviousSibling)
|
|
|
|
{
|
|
|
|
ContentChanged(aChild);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SVGStyleElement::ContentChanged(nsIContent* aContent)
|
|
|
|
{
|
|
|
|
if (nsContentUtils::IsInSameAnonymousTree(this, aContent)) {
|
2018-04-24 13:50:35 +03:00
|
|
|
Unused << UpdateStyleSheetInternal(nullptr, nullptr);
|
2013-01-05 05:50:21 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2013-02-03 00:23:19 +04:00
|
|
|
void
|
|
|
|
SVGStyleElement::GetXmlspace(nsAString & aXmlspace)
|
2013-01-05 05:50:21 +04:00
|
|
|
{
|
|
|
|
GetAttr(kNameSpaceID_XML, nsGkAtoms::space, aXmlspace);
|
|
|
|
}
|
2013-02-03 00:23:19 +04:00
|
|
|
|
2013-01-05 05:50:21 +04:00
|
|
|
void
|
|
|
|
SVGStyleElement::SetXmlspace(const nsAString & aXmlspace, ErrorResult& rv)
|
|
|
|
{
|
|
|
|
rv = SetAttr(kNameSpaceID_XML, nsGkAtoms::space, aXmlspace, true);
|
|
|
|
}
|
|
|
|
|
2013-02-03 00:23:19 +04:00
|
|
|
void
|
|
|
|
SVGStyleElement::GetMedia(nsAString & aMedia)
|
|
|
|
{
|
2018-04-04 06:58:49 +03:00
|
|
|
GetAttr(nsGkAtoms::media, aMedia);
|
2013-02-03 00:23:19 +04:00
|
|
|
}
|
|
|
|
|
2013-01-08 12:36:21 +04:00
|
|
|
void
|
2013-01-09 03:25:48 +04:00
|
|
|
SVGStyleElement::SetMedia(const nsAString& aMedia, ErrorResult& rv)
|
2013-01-08 12:36:21 +04:00
|
|
|
{
|
2018-04-04 06:58:49 +03:00
|
|
|
SetAttr(nsGkAtoms::media, aMedia, rv);
|
2013-01-08 12:36:21 +04:00
|
|
|
}
|
|
|
|
|
2013-02-03 00:23:19 +04:00
|
|
|
void
|
|
|
|
SVGStyleElement::GetType(nsAString & aType)
|
|
|
|
{
|
2018-04-04 06:58:49 +03:00
|
|
|
GetAttr(nsGkAtoms::type, aType);
|
2013-02-03 00:23:19 +04:00
|
|
|
}
|
|
|
|
|
2013-01-08 12:36:21 +04:00
|
|
|
void
|
2013-01-09 03:25:48 +04:00
|
|
|
SVGStyleElement::SetType(const nsAString& aType, ErrorResult& rv)
|
2013-01-08 12:36:21 +04:00
|
|
|
{
|
2018-04-04 06:58:49 +03:00
|
|
|
SetAttr(nsGkAtoms::type, aType, rv);
|
2013-01-08 12:36:21 +04:00
|
|
|
}
|
|
|
|
|
2013-02-03 00:23:19 +04:00
|
|
|
void
|
|
|
|
SVGStyleElement::GetTitle(nsAString & aTitle)
|
|
|
|
{
|
2018-04-04 06:58:49 +03:00
|
|
|
GetAttr(nsGkAtoms::title, aTitle);
|
2013-02-03 00:23:19 +04:00
|
|
|
}
|
|
|
|
|
2013-01-08 12:36:21 +04:00
|
|
|
void
|
2013-01-09 03:25:48 +04:00
|
|
|
SVGStyleElement::SetTitle(const nsAString& aTitle, ErrorResult& rv)
|
2013-01-08 12:36:21 +04:00
|
|
|
{
|
2018-04-04 06:58:49 +03:00
|
|
|
SetAttr(nsGkAtoms::title, aTitle, rv);
|
2013-01-08 12:36:21 +04:00
|
|
|
}
|
2013-01-05 05:50:21 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsStyleLinkElement methods
|
|
|
|
|
|
|
|
already_AddRefed<nsIURI>
|
2017-10-06 05:40:48 +03:00
|
|
|
SVGStyleElement::GetStyleSheetURL(bool* aIsInline, nsIPrincipal** aTriggeringPrincipal)
|
2013-01-05 05:50:21 +04:00
|
|
|
{
|
|
|
|
*aIsInline = true;
|
2017-10-06 05:40:48 +03:00
|
|
|
*aTriggeringPrincipal = nullptr;
|
2013-01-05 05:50:21 +04:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SVGStyleElement::GetStyleSheetInfo(nsAString& aTitle,
|
|
|
|
nsAString& aType,
|
|
|
|
nsAString& aMedia,
|
|
|
|
bool* aIsAlternate)
|
|
|
|
{
|
|
|
|
*aIsAlternate = false;
|
|
|
|
|
|
|
|
nsAutoString title;
|
|
|
|
GetAttr(kNameSpaceID_None, nsGkAtoms::title, title);
|
|
|
|
title.CompressWhitespace();
|
|
|
|
aTitle.Assign(title);
|
|
|
|
|
|
|
|
GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia);
|
|
|
|
// The SVG spec is formulated in terms of the CSS2 spec,
|
|
|
|
// which specifies that media queries are case insensitive.
|
|
|
|
nsContentUtils::ASCIIToLower(aMedia);
|
|
|
|
|
|
|
|
GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType);
|
|
|
|
if (aType.IsEmpty()) {
|
|
|
|
aType.AssignLiteral("text/css");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CORSMode
|
|
|
|
SVGStyleElement::GetCORSMode() const
|
|
|
|
{
|
|
|
|
return AttrValueToCORSMode(GetParsedAttr(nsGkAtoms::crossorigin));
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|