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