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

Unified Diff: Source/core/layout/LayoutTreeAsText.cpp

Issue 1180573003: Add option to dump line box tree when dumping layout tree. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: tweaks Created 5 years, 6 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/layout/LayoutTreeAsText.h ('k') | Source/platform/text/TextStream.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/layout/LayoutTreeAsText.cpp
diff --git a/Source/core/layout/LayoutTreeAsText.cpp b/Source/core/layout/LayoutTreeAsText.cpp
index 8dc7c93b5ae6a51a6900a890fdca7c108dc7b303..7fd0da5d1d1b72b2bb1594d66da68c2c1604a77b 100644
--- a/Source/core/layout/LayoutTreeAsText.cpp
+++ b/Source/core/layout/LayoutTreeAsText.cpp
@@ -35,6 +35,7 @@
#include "core/frame/LocalFrame.h"
#include "core/frame/Settings.h"
#include "core/html/HTMLElement.h"
+#include "core/layout/LayoutBlockFlow.h"
#include "core/layout/LayoutDetailsMarker.h"
#include "core/layout/LayoutFileUploadControl.h"
#include "core/layout/LayoutInline.h"
@@ -55,6 +56,7 @@
#include "core/layout/svg/SVGLayoutTreeAsText.h"
#include "core/page/PrintContext.h"
#include "core/paint/DeprecatedPaintLayer.h"
+#include "platform/LayoutUnit.h"
#include "wtf/HexNumber.h"
#include "wtf/Vector.h"
#include "wtf/unicode/CharacterNames.h"
@@ -404,6 +406,52 @@ void LayoutTreeAsText::writeLayoutObject(TextStream& ts, const LayoutObject& o,
}
}
+static void writeInlineBox(TextStream& ts, const InlineBox *box, int indent)
esprehn 2015/06/10 22:07:13 * goes with the type, not the var, also I think yo
szager1 2015/06/10 23:30:33 I fixed all the '*' placements. Why pass a refere
+{
+ writeIndent(ts, indent);
+ ts << "+ ";
+ ts << box->boxName() << " {" << box->layoutObject().debugName() << "}"
+ << " pos=(" << box->x() << "," << box->y() << ")"
+ << " size=(" << box->width() << "," << box->height() << ")"
+ << " baseline=" << box->baselinePosition(AlphabeticBaseline)
+ << "/" << box->baselinePosition(IdeographicBaseline);
+}
+
+static void writeInlineTextBox(TextStream& ts, const InlineTextBox *textBox, int indent)
esprehn 2015/06/10 22:07:13 ditto
+{
+ writeInlineBox(ts, textBox, indent);
+ String value = textBox->text();
+ value.replaceWithLiteral('\\', "\\\\");
+ value.replaceWithLiteral('\n', "\\n");
+ value.replaceWithLiteral('"', "\\\"");
+ ts << " range=(" << textBox->start() << "," << (textBox->start() + textBox->len()) << ")"
+ << " \"" << value << "\"";
+}
+
+static void writeInlineFlowBox(TextStream& ts, const InlineFlowBox *rootBox, int indent)
esprehn 2015/06/10 22:07:12 ditto
+{
+ writeInlineBox(ts, rootBox, indent);
+ ts << "\n";
+ for (const InlineBox* box = rootBox->firstChild(); box; box = box->nextOnLine()) {
+ if (box->isInlineFlowBox()) {
+ writeInlineFlowBox(ts, static_cast<const InlineFlowBox*>(box), indent + 1);
+ continue;
+ }
+ if (box->isInlineTextBox())
+ writeInlineTextBox(ts, static_cast<const InlineTextBox*>(box), indent + 1);
+ else
+ writeInlineBox(ts, box, indent + 1);
+ ts << "\n";
+ }
+}
+
+void LayoutTreeAsText::writeLineBoxTree(TextStream& ts, const LayoutBlockFlow& o, int indent)
+{
+ for (const InlineFlowBox *rootBox = o.firstLineBox(); rootBox; rootBox = rootBox->nextLineBox()) {
esprehn 2015/06/10 22:07:12 * with the type.
+ writeInlineFlowBox(ts, rootBox, indent);
+ }
+}
+
static void writeTextRun(TextStream& ts, const LayoutText& o, const InlineTextBox& run)
{
// FIXME: For now use an "enclosingIntRect" model for x, y and logicalWidth, although this makes it harder
@@ -469,6 +517,10 @@ void write(TextStream& ts, const LayoutObject& o, int indent, LayoutAsTextBehavi
LayoutTreeAsText::writeLayoutObject(ts, o, behavior);
ts << "\n";
+ if ((behavior & LayoutAsTextShowLineTrees) && o.isLayoutBlockFlow()) {
+ LayoutTreeAsText::writeLineBoxTree(ts, toLayoutBlockFlow(o), indent + 1);
+ }
+
if (o.isText() && !o.isBR()) {
const LayoutText& text = toLayoutText(o);
for (InlineTextBox* box = text.firstTextBox(); box; box = box->nextTextBox()) {
« no previous file with comments | « Source/core/layout/LayoutTreeAsText.h ('k') | Source/platform/text/TextStream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698