Commit a7473217 authored by Abhijeet Kandalkar's avatar Abhijeet Kandalkar Committed by Commit Bot

Remove DEFINE_ELEMENT_TYPE_CASTS for blink directory

The goal of this CL is to clean the element.h file and remove
DEFINE_ELEMENT_TYPE_CASTS to adopt new downcast helpers.

This CL removes DEFINE_ELEMENT_TYPE_CASTS for SVG,Html and MathML
element.

Bug: 891908
Change-Id: I3f1ef7357780d49381e486dc01a09557c17ce39c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1958426Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Reviewed-by: default avatarChristian Biesinger <cbiesinger@chromium.org>
Commit-Queue: Abhijeet Kandalkar <abhijeet@igalia.com>
Cr-Commit-Position: refs/heads/master@{#723051}
parent dace0dea
...@@ -1384,13 +1384,6 @@ inline bool IsAtShadowBoundary(const Element* element) { ...@@ -1384,13 +1384,6 @@ inline bool IsAtShadowBoundary(const Element* element) {
// These macros do the same as their NODE equivalents but additionally provide a // These macros do the same as their NODE equivalents but additionally provide a
// template specialization for isElementOfType<>() so that the Traversal<> API // template specialization for isElementOfType<>() so that the Traversal<> API
// works for these Element types. // works for these Element types.
#define DEFINE_ELEMENT_TYPE_CASTS(thisType, predicate) \
template <> \
inline bool IsElementOfType<const thisType>(const Node& node) { \
return node.predicate; \
} \
DEFINE_NODE_TYPE_CASTS(thisType, predicate)
#define DEFINE_ELEMENT_TYPE_CASTS_WITH_FUNCTION(thisType) \ #define DEFINE_ELEMENT_TYPE_CASTS_WITH_FUNCTION(thisType) \
template <> \ template <> \
inline bool IsElementOfType<const thisType>(const Node& node) { \ inline bool IsElementOfType<const thisType>(const Node& node) { \
......
...@@ -215,19 +215,20 @@ class CORE_EXPORT HTMLElement : public Element { ...@@ -215,19 +215,20 @@ class CORE_EXPORT HTMLElement : public Element {
void OnXMLLangAttrChanged(const AttributeModificationParams&); void OnXMLLangAttrChanged(const AttributeModificationParams&);
}; };
DEFINE_ELEMENT_TYPE_CASTS(HTMLElement, IsHTMLElement());
template <>
struct DowncastTraits<HTMLElement> {
static bool AllowFrom(const Node& node) { return node.IsHTMLElement(); }
};
template <typename T> template <typename T>
bool IsElementOfType(const HTMLElement&); bool IsElementOfType(const HTMLElement&);
template <> template <>
inline bool IsElementOfType<const HTMLElement>(const HTMLElement&) { inline bool IsElementOfType<const HTMLElement>(const HTMLElement&) {
return true; return true;
} }
template <>
inline bool IsElementOfType<const HTMLElement>(const Node& node) {
return IsA<HTMLElement>(node);
}
template <>
struct DowncastTraits<HTMLElement> {
static bool AllowFrom(const Node& node) { return node.IsHTMLElement(); }
};
inline HTMLElement::HTMLElement(const QualifiedName& tag_name, inline HTMLElement::HTMLElement(const QualifiedName& tag_name,
Document& document, Document& document,
......
...@@ -105,7 +105,8 @@ ContainerNode* ParentForClickEventInteractiveElementSensitive( ...@@ -105,7 +105,8 @@ ContainerNode* ParentForClickEventInteractiveElementSensitive(
const Node& node) { const Node& node) {
// IE doesn't dispatch click events for mousedown/mouseup events across form // IE doesn't dispatch click events for mousedown/mouseup events across form
// controls. // controls.
if (node.IsHTMLElement() && ToHTMLElement(node).IsInteractiveContent()) auto* html_element = DynamicTo<HTMLElement>(node);
if (html_element && html_element->IsInteractiveContent())
return nullptr; return nullptr;
return FlatTreeTraversal::Parent(node); return FlatTreeTraversal::Parent(node);
......
...@@ -37,19 +37,20 @@ class CORE_EXPORT MathMLElement : public Element { ...@@ -37,19 +37,20 @@ class CORE_EXPORT MathMLElement : public Element {
delete; // This will catch anyone doing an unnecessary check. delete; // This will catch anyone doing an unnecessary check.
}; };
DEFINE_ELEMENT_TYPE_CASTS(MathMLElement, IsMathMLElement());
template <>
struct DowncastTraits<MathMLElement> {
static bool AllowFrom(const Node& node) { return node.IsMathMLElement(); }
};
template <typename T> template <typename T>
bool IsElementOfType(const MathMLElement&); bool IsElementOfType(const MathMLElement&);
template <> template <>
inline bool IsElementOfType<const MathMLElement>(const MathMLElement&) { inline bool IsElementOfType<const MathMLElement>(const MathMLElement&) {
return true; return true;
} }
template <>
inline bool IsElementOfType<const MathMLElement>(const Node& node) {
return IsA<MathMLElement>(node);
}
template <>
struct DowncastTraits<MathMLElement> {
static bool AllowFrom(const Node& node) { return node.IsMathMLElement(); }
};
inline bool Node::HasTagName(const MathMLQualifiedName& name) const { inline bool Node::HasTagName(const MathMLQualifiedName& name) const {
auto* mathml_element = DynamicTo<MathMLElement>(this); auto* mathml_element = DynamicTo<MathMLElement>(this);
......
...@@ -334,20 +334,20 @@ struct SVGAttributeHashTranslator { ...@@ -334,20 +334,20 @@ struct SVGAttributeHashTranslator {
} }
}; };
DEFINE_ELEMENT_TYPE_CASTS(SVGElement, IsSVGElement());
template <>
struct DowncastTraits<SVGElement> {
static bool AllowFrom(const Node& node) { return node.IsSVGElement(); }
};
template <typename T> template <typename T>
bool IsElementOfType(const SVGElement&); bool IsElementOfType(const SVGElement&);
template <> template <>
inline bool IsElementOfType<const SVGElement>(const SVGElement&) { inline bool IsElementOfType<const SVGElement>(const SVGElement&) {
return true; return true;
} }
template <>
inline bool IsElementOfType<const SVGElement>(const Node& node) {
return IsA<SVGElement>(node);
}
template <>
struct DowncastTraits<SVGElement> {
static bool AllowFrom(const Node& node) { return node.IsSVGElement(); }
};
inline bool Node::HasTagName(const SVGQualifiedName& name) const { inline bool Node::HasTagName(const SVGQualifiedName& name) const {
auto* svg_element = DynamicTo<SVGElement>(this); auto* svg_element = DynamicTo<SVGElement>(this);
return svg_element && svg_element->HasTagName(name); return svg_element && svg_element->HasTagName(name);
......
...@@ -431,10 +431,10 @@ TEST_F(AccessibilityTest, InitRelationCache) { ...@@ -431,10 +431,10 @@ TEST_F(AccessibilityTest, InitRelationCache) {
const AXObject* input_b = GetAXObjectByElementId("b"); const AXObject* input_b = GetAXObjectByElementId("b");
ASSERT_NE(nullptr, input_b); ASSERT_NE(nullptr, input_b);
EXPECT_TRUE( EXPECT_TRUE(GetAXObjectCache().MayHaveHTMLLabel(
GetAXObjectCache().MayHaveHTMLLabel(ToHTMLElement(*input_a->GetNode()))); To<HTMLElement>(*input_a->GetNode())));
EXPECT_FALSE( EXPECT_FALSE(GetAXObjectCache().MayHaveHTMLLabel(
GetAXObjectCache().MayHaveHTMLLabel(ToHTMLElement(*input_b->GetNode()))); To<HTMLElement>(*input_b->GetNode())));
// Note: retrieve the LI first and check that its parent is not // Note: retrieve the LI first and check that its parent is not
// the paragraph element. If we were to retrieve the UL element, // the paragraph element. If we were to retrieve the UL element,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment