Commit 3bae146b authored by Abhijeet Kandalkar's avatar Abhijeet Kandalkar Committed by Commit Bot

Remove unwanted ToElementOrNull and use To<Element> in place of ToElementOrDie

This CL removes the unused definition of ToElementOrNull as all the
occurrences of ToElementOrNull() is already replaced with
DynamicTo<Element>.

This CL uses To<Element> and CHECK() in place of ToElementOrDie() and
removes subsequent definition of ToElementOrDie().

Bug: 891908
Change-Id: I41328a58a8540aa1a981ed3f5609585e92865001
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1692761Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Commit-Queue: Abhijeet Kandalkar <abhijeet@igalia.com>
Cr-Commit-Position: refs/heads/master@{#676545}
parent 20a60334
......@@ -1224,47 +1224,6 @@ inline const T* ToElement(const Node* node) {
return static_cast<const T*>(node);
}
template <typename T>
inline T* ToElementOrNull(Node& node) {
return IsElementOfType<const T>(node) ? static_cast<T*>(&node) : nullptr;
}
template <typename T>
inline T* ToElementOrNull(Node* node) {
return (node && IsElementOfType<const T>(*node)) ? static_cast<T*>(node)
: nullptr;
}
template <typename T>
inline const T* ToElementOrNull(const Node& node) {
return IsElementOfType<const T>(node) ? static_cast<const T*>(&node)
: nullptr;
}
template <typename T>
inline const T* ToElementOrNull(const Node* node) {
return (node && IsElementOfType<const T>(*node)) ? static_cast<const T*>(node)
: nullptr;
}
template <typename T>
inline T& ToElementOrDie(Node& node) {
CHECK(IsElementOfType<const T>(node));
return static_cast<T&>(node);
}
template <typename T>
inline T* ToElementOrDie(Node* node) {
CHECK(!node || IsElementOfType<const T>(*node));
return static_cast<T*>(node);
}
template <typename T>
inline const T& ToElementOrDie(const Node& node) {
CHECK(IsElementOfType<const T>(node));
return static_cast<const T&>(node);
}
template <typename T>
inline const T* ToElementOrDie(const Node* node) {
CHECK(!node || IsElementOfType<const T>(*node));
return static_cast<const T*>(node);
}
inline bool IsDisabledFormControl(const Node* node) {
auto* element = DynamicTo<Element>(node);
return element && element->IsDisabledFormControl();
......
......@@ -548,8 +548,8 @@ void DateTimeEditElement::Trace(Visitor* visitor) {
}
inline Element* DateTimeEditElement::FieldsWrapperElement() const {
DCHECK(firstChild());
return ToElementOrDie(firstChild());
CHECK(!firstChild() || IsA<Element>(firstChild()));
return To<Element>(firstChild());
}
void DateTimeEditElement::AddField(DateTimeFieldElement* field) {
......
......@@ -323,16 +323,20 @@ void FileInputType::CreateShadowSubtree() {
void FileInputType::DisabledAttributeChanged() {
DCHECK(IsShadowHost(GetElement()));
CHECK(!GetElement().UserAgentShadowRoot()->firstChild() ||
IsA<Element>(GetElement().UserAgentShadowRoot()->firstChild()));
if (Element* button =
ToElementOrDie(GetElement().UserAgentShadowRoot()->firstChild()))
To<Element>(GetElement().UserAgentShadowRoot()->firstChild()))
button->SetBooleanAttribute(kDisabledAttr,
GetElement().IsDisabledFormControl());
}
void FileInputType::MultipleAttributeChanged() {
DCHECK(IsShadowHost(GetElement()));
CHECK(!GetElement().UserAgentShadowRoot()->firstChild() ||
IsA<Element>(GetElement().UserAgentShadowRoot()->firstChild()));
if (Element* button =
ToElementOrDie(GetElement().UserAgentShadowRoot()->firstChild()))
To<Element>(GetElement().UserAgentShadowRoot()->firstChild()))
button->setAttribute(
kValueAttr,
AtomicString(GetLocale().QueryString(
......
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