Optimize Element::HasClassName().

This optimizes Element::HasClassName() to avoid testing for and chasing
the same pointers twice.

While it might seem like the compiler would optimize away the
difference, it appears (from my local non-PGO build) that this change
removes a CMPQ instruction and a JE instruction from the generated code
on x86_64.

I found this while looking at a profile of the Speedometer3 subtest
TodoMVC-Preact-Complex-DOM.  But this is probably too small of an effect
to show up in our measurements.

Change-Id: Iecf42fe6dca77878d91dd0240b62d20ffd7bcdd8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5479574
Auto-Submit: David Baron <dbaron@chromium.org>
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Reviewed-by: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1292171}
diff --git a/third_party/blink/renderer/core/dom/element.h b/third_party/blink/renderer/core/dom/element.h
index b44fa2f..a45a3b1 100644
--- a/third_party/blink/renderer/core/dom/element.h
+++ b/third_party/blink/renderer/core/dom/element.h
@@ -1966,7 +1966,7 @@
 }
 
 inline bool Element::HasClassName(const AtomicString& class_name) const {
-  return HasClass() && ClassNames().Contains(class_name);
+  return HasElementData() && GetElementData()->ClassNames().Contains(class_name);
 }
 
 inline bool Element::HasID() const {