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

Unified Diff: Source/core/rendering/RenderTreeAsText.cpp

Issue 415243003: Drop slower Node::hasID() / Node::hasClass() methods (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 months 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
« no previous file with comments | « Source/core/dom/Node.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderTreeAsText.cpp
diff --git a/Source/core/rendering/RenderTreeAsText.cpp b/Source/core/rendering/RenderTreeAsText.cpp
index 9544a0e622f2031ebe03b70f7d96da8405956436..3905d7bff748d71e5e8cf938d4d7f63a8299fdfc 100644
--- a/Source/core/rendering/RenderTreeAsText.cpp
+++ b/Source/core/rendering/RenderTreeAsText.cpp
@@ -348,17 +348,18 @@ void RenderTreeAsText::writeRenderObject(TextStream& ts, const RenderObject& o,
}
if (behavior & RenderAsTextShowIDAndClass) {
- if (Node* node = o.node()) {
- if (node->hasID())
- ts << " id=\"" + toElement(node)->getIdAttribute() + "\"";
+ Node* node = o.node();
+ if (node && node->isElementNode()) {
+ Element& element = toElement(*node);
+ if (element.hasID())
+ ts << " id=\"" + element.getIdAttribute() + "\"";
- if (node->hasClass()) {
+ if (element.hasClass()) {
ts << " class=\"";
- Element* element = toElement(node);
- for (size_t i = 0; i < element->classNames().size(); ++i) {
+ for (size_t i = 0; i < element.classNames().size(); ++i) {
if (i > 0)
ts << " ";
- ts << element->classNames()[i];
+ ts << element.classNames()[i];
}
ts << "\"";
}
« no previous file with comments | « Source/core/dom/Node.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698