Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Unified Diff: third_party/WebKit/Source/core/dom/Element.h

Issue 2534873004: Avoid unchecked casts in UA shadow DOM. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/Element.h
diff --git a/third_party/WebKit/Source/core/dom/Element.h b/third_party/WebKit/Source/core/dom/Element.h
index aa41e1dba60254cceaefc0a5dfb2ba5b30c429da..750f24249cce3a8f99f382c4896e140eb54f9ebd 100644
--- a/third_party/WebKit/Source/core/dom/Element.h
+++ b/third_party/WebKit/Source/core/dom/Element.h
@@ -961,6 +961,27 @@ inline const T* toElement(const Node* node) {
return static_cast<const T*>(node);
}
+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) {
return node->isElementNode() && toElement(node)->isDisabledFormControl();
}

Powered by Google App Engine
This is Rietveld 408576698