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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/layout/LayoutTreeAsText.h ('k') | Source/platform/text/TextStream.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 17 matching lines...) Expand all
28 28
29 #include "core/HTMLNames.h" 29 #include "core/HTMLNames.h"
30 #include "core/css/StylePropertySet.h" 30 #include "core/css/StylePropertySet.h"
31 #include "core/dom/Document.h" 31 #include "core/dom/Document.h"
32 #include "core/dom/PseudoElement.h" 32 #include "core/dom/PseudoElement.h"
33 #include "core/editing/FrameSelection.h" 33 #include "core/editing/FrameSelection.h"
34 #include "core/frame/FrameView.h" 34 #include "core/frame/FrameView.h"
35 #include "core/frame/LocalFrame.h" 35 #include "core/frame/LocalFrame.h"
36 #include "core/frame/Settings.h" 36 #include "core/frame/Settings.h"
37 #include "core/html/HTMLElement.h" 37 #include "core/html/HTMLElement.h"
38 #include "core/layout/LayoutBlockFlow.h"
38 #include "core/layout/LayoutDetailsMarker.h" 39 #include "core/layout/LayoutDetailsMarker.h"
39 #include "core/layout/LayoutFileUploadControl.h" 40 #include "core/layout/LayoutFileUploadControl.h"
40 #include "core/layout/LayoutInline.h" 41 #include "core/layout/LayoutInline.h"
41 #include "core/layout/LayoutListItem.h" 42 #include "core/layout/LayoutListItem.h"
42 #include "core/layout/LayoutListMarker.h" 43 #include "core/layout/LayoutListMarker.h"
43 #include "core/layout/LayoutPart.h" 44 #include "core/layout/LayoutPart.h"
44 #include "core/layout/LayoutTableCell.h" 45 #include "core/layout/LayoutTableCell.h"
45 #include "core/layout/LayoutView.h" 46 #include "core/layout/LayoutView.h"
46 #include "core/layout/compositing/CompositedDeprecatedPaintLayerMapping.h" 47 #include "core/layout/compositing/CompositedDeprecatedPaintLayerMapping.h"
47 #include "core/layout/line/InlineTextBox.h" 48 #include "core/layout/line/InlineTextBox.h"
48 #include "core/layout/svg/LayoutSVGContainer.h" 49 #include "core/layout/svg/LayoutSVGContainer.h"
49 #include "core/layout/svg/LayoutSVGGradientStop.h" 50 #include "core/layout/svg/LayoutSVGGradientStop.h"
50 #include "core/layout/svg/LayoutSVGImage.h" 51 #include "core/layout/svg/LayoutSVGImage.h"
51 #include "core/layout/svg/LayoutSVGInlineText.h" 52 #include "core/layout/svg/LayoutSVGInlineText.h"
52 #include "core/layout/svg/LayoutSVGPath.h" 53 #include "core/layout/svg/LayoutSVGPath.h"
53 #include "core/layout/svg/LayoutSVGRoot.h" 54 #include "core/layout/svg/LayoutSVGRoot.h"
54 #include "core/layout/svg/LayoutSVGText.h" 55 #include "core/layout/svg/LayoutSVGText.h"
55 #include "core/layout/svg/SVGLayoutTreeAsText.h" 56 #include "core/layout/svg/SVGLayoutTreeAsText.h"
56 #include "core/page/PrintContext.h" 57 #include "core/page/PrintContext.h"
57 #include "core/paint/DeprecatedPaintLayer.h" 58 #include "core/paint/DeprecatedPaintLayer.h"
59 #include "platform/LayoutUnit.h"
58 #include "wtf/HexNumber.h" 60 #include "wtf/HexNumber.h"
59 #include "wtf/Vector.h" 61 #include "wtf/Vector.h"
60 #include "wtf/unicode/CharacterNames.h" 62 #include "wtf/unicode/CharacterNames.h"
61 63
62 namespace blink { 64 namespace blink {
63 65
64 using namespace HTMLNames; 66 using namespace HTMLNames;
65 67
66 static void printBorderStyle(TextStream& ts, const EBorderStyle borderStyle) 68 static void printBorderStyle(TextStream& ts, const EBorderStyle borderStyle)
67 { 69 {
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 if (havePrevious) 399 if (havePrevious)
398 ts << ","; 400 ts << ",";
399 ts << " positioned child"; 401 ts << " positioned child";
400 } 402 }
401 403
402 if (needsLayout) 404 if (needsLayout)
403 ts << ")"; 405 ts << ")";
404 } 406 }
405 } 407 }
406 408
409 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
410 {
411 writeIndent(ts, indent);
412 ts << "+ ";
413 ts << box->boxName() << " {" << box->layoutObject().debugName() << "}"
414 << " pos=(" << box->x() << "," << box->y() << ")"
415 << " size=(" << box->width() << "," << box->height() << ")"
416 << " baseline=" << box->baselinePosition(AlphabeticBaseline)
417 << "/" << box->baselinePosition(IdeographicBaseline);
418 }
419
420 static void writeInlineTextBox(TextStream& ts, const InlineTextBox *textBox, int indent)
esprehn 2015/06/10 22:07:13 ditto
421 {
422 writeInlineBox(ts, textBox, indent);
423 String value = textBox->text();
424 value.replaceWithLiteral('\\', "\\\\");
425 value.replaceWithLiteral('\n', "\\n");
426 value.replaceWithLiteral('"', "\\\"");
427 ts << " range=(" << textBox->start() << "," << (textBox->start() + textBox-> len()) << ")"
428 << " \"" << value << "\"";
429 }
430
431 static void writeInlineFlowBox(TextStream& ts, const InlineFlowBox *rootBox, int indent)
esprehn 2015/06/10 22:07:12 ditto
432 {
433 writeInlineBox(ts, rootBox, indent);
434 ts << "\n";
435 for (const InlineBox* box = rootBox->firstChild(); box; box = box->nextOnLin e()) {
436 if (box->isInlineFlowBox()) {
437 writeInlineFlowBox(ts, static_cast<const InlineFlowBox*>(box), inden t + 1);
438 continue;
439 }
440 if (box->isInlineTextBox())
441 writeInlineTextBox(ts, static_cast<const InlineTextBox*>(box), inden t + 1);
442 else
443 writeInlineBox(ts, box, indent + 1);
444 ts << "\n";
445 }
446 }
447
448 void LayoutTreeAsText::writeLineBoxTree(TextStream& ts, const LayoutBlockFlow& o , int indent)
449 {
450 for (const InlineFlowBox *rootBox = o.firstLineBox(); rootBox; rootBox = roo tBox->nextLineBox()) {
esprehn 2015/06/10 22:07:12 * with the type.
451 writeInlineFlowBox(ts, rootBox, indent);
452 }
453 }
454
407 static void writeTextRun(TextStream& ts, const LayoutText& o, const InlineTextBo x& run) 455 static void writeTextRun(TextStream& ts, const LayoutText& o, const InlineTextBo x& run)
408 { 456 {
409 // FIXME: For now use an "enclosingIntRect" model for x, y and logicalWidth, although this makes it harder 457 // FIXME: For now use an "enclosingIntRect" model for x, y and logicalWidth, although this makes it harder
410 // to detect any changes caused by the conversion to floating point. :( 458 // to detect any changes caused by the conversion to floating point. :(
411 int x = run.x(); 459 int x = run.x();
412 int y = run.y(); 460 int y = run.y();
413 int logicalWidth = (run.left() + run.logicalWidth()).ceil() - x; 461 int logicalWidth = (run.left() + run.logicalWidth()).ceil() - x;
414 462
415 // FIXME: Table cell adjustment is temporary until results can be updated. 463 // FIXME: Table cell adjustment is temporary until results can be updated.
416 if (o.containingBlock()->isTableCell()) 464 if (o.containingBlock()->isTableCell())
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 if (o.isSVGImage()) { 510 if (o.isSVGImage()) {
463 writeSVGImage(ts, toLayoutSVGImage(o), indent); 511 writeSVGImage(ts, toLayoutSVGImage(o), indent);
464 return; 512 return;
465 } 513 }
466 514
467 writeIndent(ts, indent); 515 writeIndent(ts, indent);
468 516
469 LayoutTreeAsText::writeLayoutObject(ts, o, behavior); 517 LayoutTreeAsText::writeLayoutObject(ts, o, behavior);
470 ts << "\n"; 518 ts << "\n";
471 519
520 if ((behavior & LayoutAsTextShowLineTrees) && o.isLayoutBlockFlow()) {
521 LayoutTreeAsText::writeLineBoxTree(ts, toLayoutBlockFlow(o), indent + 1) ;
522 }
523
472 if (o.isText() && !o.isBR()) { 524 if (o.isText() && !o.isBR()) {
473 const LayoutText& text = toLayoutText(o); 525 const LayoutText& text = toLayoutText(o);
474 for (InlineTextBox* box = text.firstTextBox(); box; box = box->nextTextB ox()) { 526 for (InlineTextBox* box = text.firstTextBox(); box; box = box->nextTextB ox()) {
475 writeIndent(ts, indent + 1); 527 writeIndent(ts, indent + 1);
476 writeTextRun(ts, text, *box); 528 writeTextRun(ts, text, *box);
477 } 529 }
478 } 530 }
479 531
480 for (LayoutObject* child = o.slowFirstChild(); child; child = child->nextSib ling()) { 532 for (LayoutObject* child = o.slowFirstChild(); child; child = child->nextSib ling()) {
481 if (child->hasLayer()) 533 if (child->hasLayer())
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 element->document().updateLayout(); 832 element->document().updateLayout();
781 833
782 LayoutObject* layoutObject = element->layoutObject(); 834 LayoutObject* layoutObject = element->layoutObject();
783 if (!layoutObject || !layoutObject->isListItem()) 835 if (!layoutObject || !layoutObject->isListItem())
784 return String(); 836 return String();
785 837
786 return toLayoutListItem(layoutObject)->markerText(); 838 return toLayoutListItem(layoutObject)->markerText();
787 } 839 }
788 840
789 } // namespace blink 841 } // namespace blink
OLDNEW
« 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