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: */
|
2012-05-21 15:12:37 +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/. */
|
2008-01-09 01:36:46 +03:00
|
|
|
|
2019-09-13 19:27:54 +03:00
|
|
|
#ifndef mozilla_dom_MathMLElement_h_
|
|
|
|
#define mozilla_dom_MathMLElement_h_
|
2008-01-09 01:36:46 +03:00
|
|
|
|
2013-05-30 00:43:41 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2008-01-09 01:36:46 +03:00
|
|
|
#include "nsMappedAttributeElement.h"
|
2011-06-24 16:54:28 +04:00
|
|
|
#include "Link.h"
|
2008-01-09 01:36:46 +03:00
|
|
|
|
|
|
|
class nsCSSValue;
|
|
|
|
|
2014-03-18 08:48:19 +04:00
|
|
|
namespace mozilla {
|
2014-03-18 08:48:20 +04:00
|
|
|
class EventChainPostVisitor;
|
2014-03-18 08:48:19 +04:00
|
|
|
class EventChainPreVisitor;
|
2019-09-13 19:27:54 +03:00
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
typedef nsMappedAttributeElement MathMLElementBase;
|
2014-03-18 08:48:19 +04:00
|
|
|
|
2008-01-09 01:36:46 +03:00
|
|
|
/*
|
|
|
|
* The base class for MathML elements.
|
|
|
|
*/
|
2019-09-13 19:27:54 +03:00
|
|
|
class MathMLElement final : public MathMLElementBase,
|
|
|
|
public mozilla::dom::Link {
|
2008-01-09 01:36:46 +03:00
|
|
|
public:
|
2019-09-13 19:27:54 +03:00
|
|
|
explicit MathMLElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
|
|
|
|
explicit MathMLElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
|
2008-01-09 01:36:46 +03:00
|
|
|
|
2019-09-13 19:27:54 +03:00
|
|
|
// Implementation of nsISupports is inherited from MathMLElementBase
|
2008-01-09 01:36:46 +03:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
2019-10-04 22:05:36 +03:00
|
|
|
NS_IMPL_FROMNODE(MathMLElement, kNameSpaceID_MathML)
|
|
|
|
|
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
|
|
|
nsresult BindToTree(BindContext&, nsINode& aParent) override;
|
2019-05-29 01:47:08 +03:00
|
|
|
virtual void UnbindFromTree(bool aNullParent = true) override;
|
2008-01-09 01:36:46 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
|
2008-01-09 01:36:46 +03:00
|
|
|
const nsAString& aValue,
|
2017-11-02 06:35:52 +03:00
|
|
|
nsIPrincipal* aMaybeScriptedPrincipal,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsAttrValue& aResult) override;
|
2008-01-09 01:36:46 +03:00
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction()
|
|
|
|
const override;
|
2008-01-09 01:36:46 +03:00
|
|
|
|
2008-02-07 07:09:03 +03:00
|
|
|
enum {
|
|
|
|
PARSE_ALLOW_UNITLESS = 0x01, // unitless 0 will be turned into 0px
|
2012-12-27 20:12:05 +04:00
|
|
|
PARSE_ALLOW_NEGATIVE = 0x02,
|
2013-01-07 07:24:13 +04:00
|
|
|
PARSE_SUPPRESS_WARNINGS = 0x04,
|
|
|
|
CONVERT_UNITLESS_TO_PERCENT = 0x08
|
2008-02-07 07:09:03 +03:00
|
|
|
};
|
2012-05-16 02:30:14 +04:00
|
|
|
static bool ParseNamedSpaceValue(const nsString& aString,
|
2019-08-22 09:29:26 +03:00
|
|
|
nsCSSValue& aCSSValue, uint32_t aFlags,
|
|
|
|
const Document& aDocument);
|
2012-05-16 02:30:14 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool ParseNumericValue(const nsString& aString, nsCSSValue& aCSSValue,
|
2019-01-02 16:05:23 +03:00
|
|
|
uint32_t aFlags, Document* aDocument);
|
2008-01-09 01:36:46 +03:00
|
|
|
|
|
|
|
static void MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
|
2018-06-22 19:48:42 +03:00
|
|
|
mozilla::MappedDeclarations&);
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2018-04-05 20:42:41 +03:00
|
|
|
void GetEventTargetParent(mozilla::EventChainPreVisitor& aVisitor) override;
|
2019-04-02 22:06:11 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
nsresult PostHandleEvent(mozilla::EventChainPostVisitor& aVisitor) override;
|
2018-08-09 02:58:44 +03:00
|
|
|
nsresult Clone(mozilla::dom::NodeInfo*, nsINode** aResult) const override;
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual mozilla::EventStates IntrinsicState() const override;
|
|
|
|
virtual bool IsNodeOfType(uint32_t aFlags) const override;
|
2008-01-09 01:36:46 +03:00
|
|
|
|
|
|
|
// Set during reflow as necessary. Does a style change notification,
|
|
|
|
// aNotify must be true.
|
2011-09-29 10:19:26 +04:00
|
|
|
void SetIncrementScriptLevel(bool aIncrementScriptLevel, bool aNotify);
|
|
|
|
bool GetIncrementScriptLevel() const { return mIncrementScriptLevel; }
|
2008-01-09 01:36:46 +03:00
|
|
|
|
2019-10-04 22:05:36 +03:00
|
|
|
int32_t TabIndexDefault() final;
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsFocusableInternal(int32_t* aTabIndex,
|
|
|
|
bool aWithMouse) override;
|
|
|
|
virtual bool IsLink(nsIURI** aURI) const override;
|
|
|
|
virtual void GetLinkTarget(nsAString& aTarget) override;
|
|
|
|
virtual already_AddRefed<nsIURI> GetHrefURI() const override;
|
2011-06-24 16:54:28 +04:00
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
virtual void NodeInfoChanged(Document* aOldDoc) override {
|
2017-04-15 18:55:05 +03:00
|
|
|
ClearHasPendingLinkUpdate();
|
2019-09-13 19:27:54 +03:00
|
|
|
MathMLElementBase::NodeInfoChanged(aOldDoc);
|
2017-04-15 18:55:05 +03:00
|
|
|
}
|
|
|
|
|
2019-10-04 22:05:36 +03:00
|
|
|
void RecompileScriptEventListeners() final;
|
|
|
|
bool IsEventAttributeNameInternal(nsAtom* aName) final;
|
|
|
|
|
2013-02-06 13:42:16 +04:00
|
|
|
protected:
|
2020-03-09 18:21:21 +03:00
|
|
|
virtual ~MathMLElement() = default;
|
2014-07-09 01:23:15 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapNode(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
2013-02-06 13:42:16 +04:00
|
|
|
|
2019-10-04 22:05:36 +03:00
|
|
|
nsresult BeforeSetAttr(int32_t aNamespaceID, nsAtom* aName,
|
|
|
|
const nsAttrValueOrString* aValue, bool aNotify) final;
|
2017-10-03 01:05:19 +03:00
|
|
|
virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
|
2017-06-07 20:28:20 +03:00
|
|
|
const nsAttrValue* aValue,
|
|
|
|
const nsAttrValue* aOldValue,
|
2017-10-10 00:33:38 +03:00
|
|
|
nsIPrincipal* aSubjectPrincipal,
|
2017-06-07 20:28:20 +03:00
|
|
|
bool aNotify) override;
|
|
|
|
|
2008-01-09 01:36:46 +03:00
|
|
|
private:
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mIncrementScriptLevel;
|
2008-01-09 01:36:46 +03:00
|
|
|
};
|
|
|
|
|
2019-09-13 19:27:54 +03:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_MathMLElement_h_
|