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

Side by Side Diff: Source/core/rendering/RenderTreeAsText.cpp

Issue 23819007: Have Node::document() return a reference instead of a pointer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 3 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/rendering/RenderTheme.cpp ('k') | Source/core/rendering/RenderVideo.cpp » ('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 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 if (l->renderer()->isRenderView()) { 713 if (l->renderer()->isRenderView()) {
714 RenderView* renderView = toRenderView(l->renderer()); 714 RenderView* renderView = toRenderView(l->renderer());
715 writeRenderNamedFlowThreads(ts, renderView, rootLayer, paintDirtyRect, i ndent, behavior); 715 writeRenderNamedFlowThreads(ts, renderView, rootLayer, paintDirtyRect, i ndent, behavior);
716 } 716 }
717 } 717 }
718 718
719 static String nodePosition(Node* node) 719 static String nodePosition(Node* node)
720 { 720 {
721 StringBuilder result; 721 StringBuilder result;
722 722
723 Element* body = node->document()->body(); 723 Element* body = node->document().body();
724 Node* parent; 724 Node* parent;
725 for (Node* n = node; n; n = parent) { 725 for (Node* n = node; n; n = parent) {
726 parent = n->parentOrShadowHostNode(); 726 parent = n->parentOrShadowHostNode();
727 if (n != node) 727 if (n != node)
728 result.appendLiteral(" of "); 728 result.appendLiteral(" of ");
729 if (parent) { 729 if (parent) {
730 if (body && n == body) { 730 if (body && n == body) {
731 // We don't care what offset body may be in the document. 731 // We don't care what offset body may be in the document.
732 result.appendLiteral("body"); 732 result.appendLiteral("body");
733 break; 733 break;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 printContext.begin(toRenderBox(renderer)->width()); 798 printContext.begin(toRenderBox(renderer)->width());
799 799
800 return externalRepresentation(toRenderBox(renderer), behavior); 800 return externalRepresentation(toRenderBox(renderer), behavior);
801 } 801 }
802 802
803 String externalRepresentation(Element* element, RenderAsTextBehavior behavior) 803 String externalRepresentation(Element* element, RenderAsTextBehavior behavior)
804 { 804 {
805 // Doesn't support printing mode. 805 // Doesn't support printing mode.
806 ASSERT(!(behavior & RenderAsTextPrintingMode)); 806 ASSERT(!(behavior & RenderAsTextPrintingMode));
807 if (!(behavior & RenderAsTextDontUpdateLayout)) 807 if (!(behavior & RenderAsTextDontUpdateLayout))
808 element->document()->updateLayout(); 808 element->document().updateLayout();
809 809
810 RenderObject* renderer = element->renderer(); 810 RenderObject* renderer = element->renderer();
811 if (!renderer || !renderer->isBox()) 811 if (!renderer || !renderer->isBox())
812 return String(); 812 return String();
813 813
814 return externalRepresentation(toRenderBox(renderer), behavior | RenderAsText ShowAllLayers); 814 return externalRepresentation(toRenderBox(renderer), behavior | RenderAsText ShowAllLayers);
815 } 815 }
816 816
817 static void writeCounterValuesFromChildren(TextStream& stream, RenderObject* par ent, bool& isFirstCounter) 817 static void writeCounterValuesFromChildren(TextStream& stream, RenderObject* par ent, bool& isFirstCounter)
818 { 818 {
819 for (RenderObject* child = parent->firstChild(); child; child = child->nextS ibling()) { 819 for (RenderObject* child = parent->firstChild(); child; child = child->nextS ibling()) {
820 if (child->isCounter()) { 820 if (child->isCounter()) {
821 if (!isFirstCounter) 821 if (!isFirstCounter)
822 stream << " "; 822 stream << " ";
823 isFirstCounter = false; 823 isFirstCounter = false;
824 String str(toRenderText(child)->text()); 824 String str(toRenderText(child)->text());
825 stream << str; 825 stream << str;
826 } 826 }
827 } 827 }
828 } 828 }
829 829
830 String counterValueForElement(Element* element) 830 String counterValueForElement(Element* element)
831 { 831 {
832 // Make sure the element is not freed during the layout. 832 // Make sure the element is not freed during the layout.
833 RefPtr<Element> elementRef(element); 833 RefPtr<Element> elementRef(element);
834 element->document()->updateLayout(); 834 element->document().updateLayout();
835 TextStream stream; 835 TextStream stream;
836 bool isFirstCounter = true; 836 bool isFirstCounter = true;
837 // The counter renderers should be children of :before or :after pseudo-elem ents. 837 // The counter renderers should be children of :before or :after pseudo-elem ents.
838 if (RenderObject* before = element->pseudoElementRenderer(BEFORE)) 838 if (RenderObject* before = element->pseudoElementRenderer(BEFORE))
839 writeCounterValuesFromChildren(stream, before, isFirstCounter); 839 writeCounterValuesFromChildren(stream, before, isFirstCounter);
840 if (RenderObject* after = element->pseudoElementRenderer(AFTER)) 840 if (RenderObject* after = element->pseudoElementRenderer(AFTER))
841 writeCounterValuesFromChildren(stream, after, isFirstCounter); 841 writeCounterValuesFromChildren(stream, after, isFirstCounter);
842 return stream.release(); 842 return stream.release();
843 } 843 }
844 844
845 String markerTextForListItem(Element* element) 845 String markerTextForListItem(Element* element)
846 { 846 {
847 // Make sure the element is not freed during the layout. 847 // Make sure the element is not freed during the layout.
848 RefPtr<Element> elementRef(element); 848 RefPtr<Element> elementRef(element);
849 element->document()->updateLayout(); 849 element->document().updateLayout();
850 850
851 RenderObject* renderer = element->renderer(); 851 RenderObject* renderer = element->renderer();
852 if (!renderer || !renderer->isListItem()) 852 if (!renderer || !renderer->isListItem())
853 return String(); 853 return String();
854 854
855 return toRenderListItem(renderer)->markerText(); 855 return toRenderListItem(renderer)->markerText();
856 } 856 }
857 857
858 } // namespace WebCore 858 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderTheme.cpp ('k') | Source/core/rendering/RenderVideo.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698