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/. */
|
|
|
|
|
2020-07-15 02:40:05 +03:00
|
|
|
#ifndef DOM_SVG_SVGSTYLEELEMENT_H_
|
|
|
|
#define DOM_SVG_SVGSTYLEELEMENT_H_
|
2013-01-05 05:50:21 +04:00
|
|
|
|
2013-05-30 00:43:41 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2020-05-21 06:07:16 +03:00
|
|
|
#include "mozilla/dom/LinkStyle.h"
|
2018-12-21 11:58:14 +03:00
|
|
|
#include "SVGElement.h"
|
2013-01-05 05:50:21 +04:00
|
|
|
#include "nsStubMutationObserver.h"
|
|
|
|
|
|
|
|
nsresult NS_NewSVGStyleElement(
|
2014-06-20 06:01:40 +04:00
|
|
|
nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
|
2013-01-05 05:50:21 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2020-07-15 13:37:55 +03:00
|
|
|
using SVGStyleElementBase = SVGElement;
|
2018-12-21 11:58:14 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class SVGStyleElement final : public SVGStyleElementBase,
|
2020-05-21 06:07:16 +03:00
|
|
|
public nsStubMutationObserver,
|
|
|
|
public LinkStyle {
|
2013-01-05 05:50:21 +04:00
|
|
|
protected:
|
|
|
|
friend nsresult(::NS_NewSVGStyleElement(
|
|
|
|
nsIContent** aResult,
|
2014-06-20 06:01:40 +04:00
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
|
2018-09-21 23:45:49 +03:00
|
|
|
explicit SVGStyleElement(
|
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
|
2019-04-18 01:38:02 +03:00
|
|
|
~SVGStyleElement() = default;
|
2013-01-05 05:50:21 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapNode(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
2013-01-05 05:50:21 +04:00
|
|
|
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGStyleElement, SVGStyleElementBase)
|
|
|
|
|
|
|
|
// nsIContent
|
Bug 1555216 - Change the signature of BindToTree to be (BindContext&, nsINode& aParentNode). r=bzbarsky
BindContext was going to have way more information at first, but then I realized
that most of the things I wanted to know were basically a flag away using the
parent node.
Still I think it's worth it, now experimenting with BindToTree will only mean
adding a field to a struct that's included from a couple cpp files, instead of a
massive pain.
I also think this is clearer, and doing this highlights quite a few
inconsistencies in our code which I've left untouched, but commented with
FIXMEs.
Steps are:
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsresult BindToTree(Document\* aDocument, nsIContent\* aParent,#nsresult BindToTree(BindContext\&, nsINode\& aParent)#g' $file; done
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's# nsIContent\* aBindingParent) override#override#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(Document\* aDocument, nsIContent\* aParent,#::BindToTree(BindContext\& aContext, nsINode\& aParent)#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsIContent\* aBindingParent)##g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(aDocument, aParent, aBindingParent)#::BindToTree(aContext, aParent)#g' $file; done
$ ./mach clang-format
Then manual fixups.
Depends on D32948
Differential Revision: https://phabricator.services.mozilla.com/D32949
2019-05-29 07:27:04 +03:00
|
|
|
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
|
2019-05-29 01:47:08 +03:00
|
|
|
virtual void UnbindFromTree(bool aNullParent = true) override;
|
2018-01-03 22:21:23 +03:00
|
|
|
virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
|
|
|
|
const nsAttrValue* aValue,
|
|
|
|
const nsAttrValue* aOldValue,
|
|
|
|
nsIPrincipal* aMaybeScriptedPrincipal,
|
|
|
|
bool aNotify) override;
|
2013-01-05 05:50:21 +04:00
|
|
|
virtual bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
2017-11-02 06:35:52 +03:00
|
|
|
nsIPrincipal* aMaybeScriptedPrincipal,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsAttrValue& aResult) override;
|
2013-01-05 05:50:21 +04:00
|
|
|
|
2018-08-09 02:58:44 +03:00
|
|
|
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
|
2013-01-05 05:50:21 +04:00
|
|
|
|
|
|
|
// nsIMutationObserver
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
|
|
|
|
|
|
|
|
// WebIDL
|
2013-02-03 00:23:19 +04:00
|
|
|
void GetMedia(nsAString& aMedia);
|
|
|
|
void SetMedia(const nsAString& aMedia, ErrorResult& rv);
|
|
|
|
void GetType(nsAString& aType);
|
|
|
|
void SetType(const nsAString& aType, ErrorResult& rv);
|
|
|
|
void GetTitle(nsAString& aTitle);
|
|
|
|
void SetTitle(const nsAString& aTitle, ErrorResult& rv);
|
2013-01-05 05:50:21 +04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// Dummy init method to make the NS_IMPL_NS_NEW_SVG_ELEMENT and
|
|
|
|
// NS_IMPL_ELEMENT_CLONE_WITH_INIT usable with this class. This should be
|
|
|
|
// completely optimized away.
|
|
|
|
inline nsresult Init() { return NS_OK; }
|
|
|
|
|
2020-05-21 06:07:16 +03:00
|
|
|
// LinkStyle overrides
|
|
|
|
nsIContent& AsContent() final { return *this; }
|
|
|
|
const LinkStyle* AsLinkStyle() const final { return this; }
|
2018-05-08 07:11:56 +03:00
|
|
|
Maybe<SheetInfo> GetStyleSheetInfo() final;
|
2013-01-05 05:50:21 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Common method to call from the various mutation observer methods.
|
|
|
|
* aContent is a content node that's either the one that changed or its
|
|
|
|
* parent; we should only respond to the change if aContent is non-anonymous.
|
|
|
|
*/
|
|
|
|
void ContentChanged(nsIContent* aContent);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2020-07-15 02:40:05 +03:00
|
|
|
#endif // DOM_SVG_SVGSTYLEELEMENT_H_
|