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

Side by Side Diff: Source/core/layout/LayoutTreeAsText.cpp

Issue 899163003: Move rendering/RenderObject to layout/LayoutObject. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 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
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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } 155 }
156 result.append('"'); 156 result.append('"');
157 return result.toString(); 157 return result.toString();
158 } 158 }
159 159
160 TextStream& operator<<(TextStream& ts, const Color& c) 160 TextStream& operator<<(TextStream& ts, const Color& c)
161 { 161 {
162 return ts << c.nameForLayoutTreeAsText(); 162 return ts << c.nameForLayoutTreeAsText();
163 } 163 }
164 164
165 void LayoutTreeAsText::writeRenderObject(TextStream& ts, const RenderObject& o, LayoutAsTextBehavior behavior) 165 void LayoutTreeAsText::writeLayoutObject(TextStream& ts, const LayoutObject& o, LayoutAsTextBehavior behavior)
166 { 166 {
167 ts << o.renderName(); 167 ts << o.renderName();
168 168
169 if (behavior & LayoutAsTextShowAddresses) 169 if (behavior & LayoutAsTextShowAddresses)
170 ts << " " << static_cast<const void*>(&o); 170 ts << " " << static_cast<const void*>(&o);
171 171
172 if (o.style() && o.style()->zIndex()) 172 if (o.style() && o.style()->zIndex())
173 ts << " zI: " << o.style()->zIndex(); 173 ts << " zI: " << o.style()->zIndex();
174 174
175 if (o.node()) { 175 if (o.node()) {
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 if (run.dirOverride()) 423 if (run.dirOverride())
424 ts << " override"; 424 ts << " override";
425 } 425 }
426 ts << ": " 426 ts << ": "
427 << quoteAndEscapeNonPrintables(String(o.text()).substring(run.start(), r un.len())); 427 << quoteAndEscapeNonPrintables(String(o.text()).substring(run.start(), r un.len()));
428 if (run.hasHyphen()) 428 if (run.hasHyphen())
429 ts << " + hyphen string " << quoteAndEscapeNonPrintables(o.style()->hyph enString()); 429 ts << " + hyphen string " << quoteAndEscapeNonPrintables(o.style()->hyph enString());
430 ts << "\n"; 430 ts << "\n";
431 } 431 }
432 432
433 void write(TextStream& ts, const RenderObject& o, int indent, LayoutAsTextBehavi or behavior) 433 void write(TextStream& ts, const LayoutObject& o, int indent, LayoutAsTextBehavi or behavior)
434 { 434 {
435 if (o.isSVGShape()) { 435 if (o.isSVGShape()) {
436 write(ts, toRenderSVGShape(o), indent); 436 write(ts, toRenderSVGShape(o), indent);
437 return; 437 return;
438 } 438 }
439 if (o.isSVGGradientStop()) { 439 if (o.isSVGGradientStop()) {
440 writeSVGGradientStop(ts, toRenderSVGGradientStop(o), indent); 440 writeSVGGradientStop(ts, toRenderSVGGradientStop(o), indent);
441 return; 441 return;
442 } 442 }
443 if (o.isSVGResourceContainer()) { 443 if (o.isSVGResourceContainer()) {
(...skipping 16 matching lines...) Expand all
460 writeSVGInlineText(ts, toRenderSVGInlineText(o), indent); 460 writeSVGInlineText(ts, toRenderSVGInlineText(o), indent);
461 return; 461 return;
462 } 462 }
463 if (o.isSVGImage()) { 463 if (o.isSVGImage()) {
464 writeSVGImage(ts, toRenderSVGImage(o), indent); 464 writeSVGImage(ts, toRenderSVGImage(o), indent);
465 return; 465 return;
466 } 466 }
467 467
468 writeIndent(ts, indent); 468 writeIndent(ts, indent);
469 469
470 LayoutTreeAsText::writeRenderObject(ts, o, behavior); 470 LayoutTreeAsText::writeLayoutObject(ts, o, behavior);
471 ts << "\n"; 471 ts << "\n";
472 472
473 if (o.isText() && !o.isBR()) { 473 if (o.isText() && !o.isBR()) {
474 const RenderText& text = toRenderText(o); 474 const RenderText& text = toRenderText(o);
475 for (InlineTextBox* box = text.firstTextBox(); box; box = box->nextTextB ox()) { 475 for (InlineTextBox* box = text.firstTextBox(); box; box = box->nextTextB ox()) {
476 writeIndent(ts, indent + 1); 476 writeIndent(ts, indent + 1);
477 writeTextRun(ts, text, *box); 477 writeTextRun(ts, text, *box);
478 } 478 }
479 } 479 }
480 480
481 for (RenderObject* child = o.slowFirstChild(); child; child = child->nextSib ling()) { 481 for (LayoutObject* child = o.slowFirstChild(); child; child = child->nextSib ling()) {
482 if (child->hasLayer()) 482 if (child->hasLayer())
483 continue; 483 continue;
484 write(ts, *child, indent + 1, behavior); 484 write(ts, *child, indent + 1, behavior);
485 } 485 }
486 486
487 if (o.isRenderPart()) { 487 if (o.isRenderPart()) {
488 Widget* widget = toRenderPart(o).widget(); 488 Widget* widget = toRenderPart(o).widget();
489 if (widget && widget->isFrameView()) { 489 if (widget && widget->isFrameView()) {
490 FrameView* view = toFrameView(widget); 490 FrameView* view = toFrameView(widget);
491 RenderView* root = view->renderView(); 491 RenderView* root = view->renderView();
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 result.append('}'); 674 result.append('}');
675 } 675 }
676 } else { 676 } else {
677 result.appendLiteral("document"); 677 result.appendLiteral("document");
678 } 678 }
679 } 679 }
680 680
681 return result.toString(); 681 return result.toString();
682 } 682 }
683 683
684 static void writeSelection(TextStream& ts, const RenderObject* o) 684 static void writeSelection(TextStream& ts, const LayoutObject* o)
685 { 685 {
686 Node* n = o->node(); 686 Node* n = o->node();
687 if (!n || !n->isDocumentNode()) 687 if (!n || !n->isDocumentNode())
688 return; 688 return;
689 689
690 Document* doc = toDocument(n); 690 Document* doc = toDocument(n);
691 LocalFrame* frame = doc->frame(); 691 LocalFrame* frame = doc->frame();
692 if (!frame) 692 if (!frame)
693 return; 693 return;
694 694
(...skipping 19 matching lines...) Expand all
714 LayoutTreeAsText::writeLayers(ts, layer, layer, layer->rect(), 0, behavior); 714 LayoutTreeAsText::writeLayers(ts, layer, layer, layer->rect(), 0, behavior);
715 writeSelection(ts, renderer); 715 writeSelection(ts, renderer);
716 return ts.release(); 716 return ts.release();
717 } 717 }
718 718
719 String externalRepresentation(LocalFrame* frame, LayoutAsTextBehavior behavior) 719 String externalRepresentation(LocalFrame* frame, LayoutAsTextBehavior behavior)
720 { 720 {
721 if (!(behavior & LayoutAsTextDontUpdateLayout)) 721 if (!(behavior & LayoutAsTextDontUpdateLayout))
722 frame->document()->updateLayout(); 722 frame->document()->updateLayout();
723 723
724 RenderObject* renderer = frame->contentRenderer(); 724 LayoutObject* renderer = frame->contentRenderer();
725 if (!renderer || !renderer->isBox()) 725 if (!renderer || !renderer->isBox())
726 return String(); 726 return String();
727 727
728 PrintContext printContext(frame); 728 PrintContext printContext(frame);
729 if (behavior & LayoutAsTextPrintingMode) 729 if (behavior & LayoutAsTextPrintingMode)
730 printContext.begin(toRenderBox(renderer)->size().width().toFloat()); 730 printContext.begin(toRenderBox(renderer)->size().width().toFloat());
731 731
732 return externalRepresentation(toRenderBox(renderer), behavior); 732 return externalRepresentation(toRenderBox(renderer), behavior);
733 } 733 }
734 734
735 String externalRepresentation(Element* element, LayoutAsTextBehavior behavior) 735 String externalRepresentation(Element* element, LayoutAsTextBehavior behavior)
736 { 736 {
737 // Doesn't support printing mode. 737 // Doesn't support printing mode.
738 ASSERT(!(behavior & LayoutAsTextPrintingMode)); 738 ASSERT(!(behavior & LayoutAsTextPrintingMode));
739 if (!(behavior & LayoutAsTextDontUpdateLayout)) 739 if (!(behavior & LayoutAsTextDontUpdateLayout))
740 element->document().updateLayout(); 740 element->document().updateLayout();
741 741
742 RenderObject* renderer = element->renderer(); 742 LayoutObject* renderer = element->renderer();
743 if (!renderer || !renderer->isBox()) 743 if (!renderer || !renderer->isBox())
744 return String(); 744 return String();
745 745
746 return externalRepresentation(toRenderBox(renderer), behavior | LayoutAsText ShowAllLayers); 746 return externalRepresentation(toRenderBox(renderer), behavior | LayoutAsText ShowAllLayers);
747 } 747 }
748 748
749 static void writeCounterValuesFromChildren(TextStream& stream, RenderObject* par ent, bool& isFirstCounter) 749 static void writeCounterValuesFromChildren(TextStream& stream, LayoutObject* par ent, bool& isFirstCounter)
750 { 750 {
751 for (RenderObject* child = parent->slowFirstChild(); child; child = child->n extSibling()) { 751 for (LayoutObject* child = parent->slowFirstChild(); child; child = child->n extSibling()) {
752 if (child->isCounter()) { 752 if (child->isCounter()) {
753 if (!isFirstCounter) 753 if (!isFirstCounter)
754 stream << " "; 754 stream << " ";
755 isFirstCounter = false; 755 isFirstCounter = false;
756 String str(toRenderText(child)->text()); 756 String str(toRenderText(child)->text());
757 stream << str; 757 stream << str;
758 } 758 }
759 } 759 }
760 } 760 }
761 761
762 String counterValueForElement(Element* element) 762 String counterValueForElement(Element* element)
763 { 763 {
764 // Make sure the element is not freed during the layout. 764 // Make sure the element is not freed during the layout.
765 RefPtrWillBeRawPtr<Element> protector(element); 765 RefPtrWillBeRawPtr<Element> protector(element);
766 element->document().updateLayout(); 766 element->document().updateLayout();
767 TextStream stream; 767 TextStream stream;
768 bool isFirstCounter = true; 768 bool isFirstCounter = true;
769 // The counter renderers should be children of :before or :after pseudo-elem ents. 769 // The counter renderers should be children of :before or :after pseudo-elem ents.
770 if (RenderObject* before = element->pseudoElementRenderer(BEFORE)) 770 if (LayoutObject* before = element->pseudoElementRenderer(BEFORE))
771 writeCounterValuesFromChildren(stream, before, isFirstCounter); 771 writeCounterValuesFromChildren(stream, before, isFirstCounter);
772 if (RenderObject* after = element->pseudoElementRenderer(AFTER)) 772 if (LayoutObject* after = element->pseudoElementRenderer(AFTER))
773 writeCounterValuesFromChildren(stream, after, isFirstCounter); 773 writeCounterValuesFromChildren(stream, after, isFirstCounter);
774 return stream.release(); 774 return stream.release();
775 } 775 }
776 776
777 String markerTextForListItem(Element* element) 777 String markerTextForListItem(Element* element)
778 { 778 {
779 // Make sure the element is not freed during the layout. 779 // Make sure the element is not freed during the layout.
780 RefPtrWillBeRawPtr<Element> protector(element); 780 RefPtrWillBeRawPtr<Element> protector(element);
781 element->document().updateLayout(); 781 element->document().updateLayout();
782 782
783 RenderObject* renderer = element->renderer(); 783 LayoutObject* renderer = element->renderer();
784 if (!renderer || !renderer->isListItem()) 784 if (!renderer || !renderer->isListItem())
785 return String(); 785 return String();
786 786
787 return toRenderListItem(renderer)->markerText(); 787 return toRenderListItem(renderer)->markerText();
788 } 788 }
789 789
790 } // namespace blink 790 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutTreeAsText.h ('k') | Source/core/layout/compositing/CompositedLayerMapping.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698