Commit 1f0db7b9 authored by tkent's avatar tkent Committed by Commit bot

Remove WTFLogAlways() usages from core/{dom,editing}/.

Use LOG(INFO) instead.

For single-line strings like showNode():
  [n:n:n/n:n:INFO:Node.cpp(n)] fooBar

For multiple-line strings like showTree():
  [n:n:n/n:n:INFO:Node.cpp(n)]
  BODY
          #text "\n"
          ...

* This CL removes Node::showNode().  It was a simple wrapper for operator<< for
  Node.

* As for HTMLFormattingElementList and SnapCoordinator, just call LOG(INFO)
  multiple times because they don't show tree structures.

BUG=638849

Review-Url: https://codereview.chromium.org/2292843002
Cr-Commit-Position: refs/heads/master@{#415262}
parent 090f099c
......@@ -1500,7 +1500,6 @@ static void dumpAttributeDesc(const Node& node, const QualifiedName& name, std::
ostream << ' ' << name.toString().utf8().data() << '=' << value;
}
// |std::ostream| version of |Node::showNode|
std::ostream& operator<<(std::ostream& ostream, const Node& node)
{
if (node.getNodeType() == Node::kProcessingInstructionNode)
......@@ -1545,16 +1544,6 @@ String Node::toString() const
return String(stream.str().c_str());
}
void Node::showNode(const char* prefix) const
{
std::stringstream stream;
if (prefix)
stream << prefix;
stream << *this << "\n";
// TODO(tkent): Replace WTFLogAlways with something else.
WTFLogAlways("%s", stream.str().c_str());
}
String Node::toTreeStringForThis() const
{
return toMarkedTreeString(this, "*");
......@@ -1735,8 +1724,7 @@ void Node::showTreeForThisAcrossFrame() const
rootNode = parentOrShadowHostOrFrameOwner(rootNode);
std::stringstream stream;
printSubTreeAcrossFrame(rootNode, this, "", stream);
// TODO(tkent): Replace WTFLogAlways with something else.
WTFLogAlways("%s", stream.str().c_str());
LOG(INFO) << "\n" << stream.str();
}
#endif
......@@ -2396,27 +2384,28 @@ v8::Local<v8::Object> Node::associateWithWrapper(v8::Isolate* isolate, const Wra
void showNode(const blink::Node* node)
{
if (node)
node->showNode("");
LOG(INFO) << *node;
else
fprintf(stderr, "Cannot showNode for (nil)\n");
LOG(INFO) << "Cannot showNode for <null>";
}
void showTree(const blink::Node* node)
{
// TODO(tkent): Replace WTFLogAlways with something else.
WTFLogAlways("%s", node ? node->toTreeStringForThis().utf8().data() : "Cannot showTree for <null>");
if (node)
LOG(INFO) << "\n" << node->toTreeStringForThis().utf8().data();
else
LOG(INFO) << "Cannot showTree for <null>";
}
void showNodePath(const blink::Node* node)
{
std::stringstream stream;
if (node)
if (node) {
std::stringstream stream;
node->printNodePathTo(stream);
else
stream << "Cannot showNodePath for <null>";
stream << "\n";
// TODO(tkent): Replace WTFLogAlways with something else.
WTFLogAlways("%s", stream.str().c_str());
LOG(INFO) << stream.str();
} else {
LOG(INFO) << "Cannot showNodePath for <null>";
}
}
#endif
......@@ -571,7 +571,6 @@ public:
#ifndef NDEBUG
String toString() const;
void showNode(const char* prefix = "") const;
String toTreeStringForThis() const;
String toFlatTreeStringForThis() const;
void printNodePathTo(std::ostream&) const;
......
......@@ -603,26 +603,29 @@ Position toPositionInDOMTree(const PositionInFlatTree& position)
#ifndef NDEBUG
template <typename Strategy>
void PositionTemplate<Strategy>::showAnchorTypeAndOffset() const
String PositionTemplate<Strategy>::toAnchorTypeAndOffsetString() const
{
StringBuilder builder;
switch (anchorType()) {
case PositionAnchorType::OffsetInAnchor:
fputs("offset", stderr);
builder.append("offset");
break;
case PositionAnchorType::BeforeChildren:
fputs("beforeChildren", stderr);
builder.append("beforeChildren");
break;
case PositionAnchorType::AfterChildren:
fputs("afterChildren", stderr);
builder.append("afterChildren");
break;
case PositionAnchorType::BeforeAnchor:
fputs("before", stderr);
builder.append("before");
break;
case PositionAnchorType::AfterAnchor:
fputs("after", stderr);
builder.append("after");
break;
}
fprintf(stderr, ", offset:%d\n", m_offset);
builder.append(", offset:");
builder.append(m_offset);
return builder.toString();
}
template <typename Strategy>
......@@ -630,9 +633,9 @@ void PositionTemplate<Strategy>::showTreeForThis() const
{
if (!anchorNode())
return;
// TODO(tkent): Replace WTFLogAlways with something else.
WTFLogAlways("%s", anchorNode()->toTreeStringForThis().utf8().data());
showAnchorTypeAndOffset();
LOG(INFO) << "\n"
<< anchorNode()->toTreeStringForThis().utf8().data()
<< toAnchorTypeAndOffsetString().utf8().data();
}
template <typename Strategy>
......@@ -640,9 +643,9 @@ void PositionTemplate<Strategy>::showTreeForThisInFlatTree() const
{
if (!anchorNode())
return;
// TODO(tkent): Replace WTFLogAlways with something else.
WTFLogAlways("%s", anchorNode()->toFlatTreeStringForThis().utf8().data());
showAnchorTypeAndOffset();
LOG(INFO) << "\n"
<< anchorNode()->toFlatTreeStringForThis().utf8().data()
<< toAnchorTypeAndOffsetString().utf8().data();
}
#endif
......
......@@ -176,7 +176,7 @@ public:
void debugPosition(const char* msg = "") const;
#ifndef NDEBUG
void showAnchorTypeAndOffset() const;
String toAnchorTypeAndOffsetString() const;
void showTreeForThis() const;
void showTreeForThisInFlatTree() const;
#endif
......
......@@ -806,14 +806,12 @@ void VisibleSelectionTemplate<Strategy>::debugPosition(const char* message) cons
template <typename Strategy>
void VisibleSelectionTemplate<Strategy>::showTreeForThis() const
{
if (start().anchorNode()) {
// TODO(tkent): Replace WTFLogAlways with something else.
WTFLogAlways("%s", start().anchorNode()->toMarkedTreeString(start().anchorNode(), "S", end().anchorNode(), "E").utf8().data());
fputs("start: ", stderr);
start().showAnchorTypeAndOffset();
fputs("end: ", stderr);
end().showAnchorTypeAndOffset();
}
if (!start().anchorNode())
return;
LOG(INFO) << "\n"
<< start().anchorNode()->toMarkedTreeString(start().anchorNode(), "S", end().anchorNode(), "E").utf8().data()
<< "start: " << start().toAnchorTypeAndOffsetString().utf8().data() << "\n"
<< "end: " << end().toAnchorTypeAndOffsetString().utf8().data();
}
#endif
......
......@@ -620,7 +620,7 @@ DEFINE_TRACE(HTMLElementStack)
void HTMLElementStack::show()
{
for (ElementRecord* record = m_top.get(); record; record = record->next())
record->element()->showNode();
LOG(INFO) << *record->element();
}
#endif
......
......@@ -206,9 +206,9 @@ void HTMLFormattingElementList::show()
for (unsigned i = 1; i <= m_entries.size(); ++i) {
const Entry& entry = m_entries[m_entries.size() - i];
if (entry.isMarker())
fprintf(stderr, "marker\n");
LOG(INFO) << "marker";
else
entry.element()->showNode();
LOG(INFO) << *entry.element();
}
}
......
......@@ -1318,7 +1318,7 @@ void LayoutObject::showLayoutObject(StringBuilder& stringBuilder) const
while (stringBuilder.length() < showTreeCharacterOffset)
stringBuilder.append(' ');
stringBuilder.append('\t');
node()->showNode(stringBuilder.toString().utf8().data());
WTFLogAlways("%s%s", stringBuilder.toString().utf8().data(), node()->toString().utf8().data());
} else {
WTFLogAlways("%s", stringBuilder.toString().utf8().data());
}
......
......@@ -157,11 +157,10 @@ void SnapCoordinator::showSnapAreaMap()
void SnapCoordinator::showSnapAreasFor(const LayoutBox* container)
{
const char* prefix = " ";
container->node()->showNode();
LOG(INFO) << *container->node();
if (SnapAreaSet* snapAreas = container->snapAreas()) {
for (auto& snapArea : *snapAreas) {
snapArea->node()->showNode(prefix);
LOG(INFO) << " " << *snapArea->node();
}
}
}
......
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