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

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

Issue 2280153002: Refactoring out the code in LayoutTreeAsText::writeLayoutObject. (Closed)
Patch Set: Codereview update Created 4 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
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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 String tagName = getTagName(o.node()); 176 String tagName = getTagName(o.node());
177 if (!tagName.isEmpty()) { 177 if (!tagName.isEmpty()) {
178 ts << " {" << tagName << "}"; 178 ts << " {" << tagName << "}";
179 // flag empty or unstyled AppleStyleSpan because we never 179 // flag empty or unstyled AppleStyleSpan because we never
180 // want to leave them in the DOM 180 // want to leave them in the DOM
181 if (isEmptyOrUnstyledAppleStyleSpan(o.node())) 181 if (isEmptyOrUnstyledAppleStyleSpan(o.node()))
182 ts << " *empty or unstyled AppleStyleSpan*"; 182 ts << " *empty or unstyled AppleStyleSpan*";
183 } 183 }
184 } 184 }
185 185
186 LayoutBlock* cb = o.containingBlock(); 186 LayoutRect rect = o.debugRect();
187 bool adjustForTableCells = cb ? cb->isTableCell() : false; 187 ts << " " << rect;
188
189 LayoutRect r;
190 if (o.isText()) {
191 // FIXME: Would be better to dump the bounding box x and y rather than t he first run's x and y, but that would involve updating
192 // many test results.
193 const LayoutText& text = toLayoutText(o);
194 IntRect linesBox = enclosingIntRect(text.linesBoundingBox());
195 r = LayoutRect(IntRect(text.firstRunX(), text.firstRunY(), linesBox.widt h(), linesBox.height()));
196 if (adjustForTableCells && !text.hasTextBoxes())
197 adjustForTableCells = false;
198 } else if (o.isLayoutInline()) {
199 // FIXME: Would be better not to just dump 0, 0 as the x and y here.
200 const LayoutInline& inlineFlow = toLayoutInline(o);
201 IntRect linesBox = enclosingIntRect(inlineFlow.linesBoundingBox());
202 r = LayoutRect(IntRect(0, 0, linesBox.width(), linesBox.height()));
203 adjustForTableCells = false;
204 } else if (o.isTableCell()) {
205 // FIXME: Deliberately dump the "inner" box of table cells, since that i s what current results reflect. We'd like
206 // to clean up the results to dump both the outer box and the intrinsic padding so that both bits of information are
207 // captured by the results.
208 const LayoutTableCell& cell = toLayoutTableCell(o);
209 r = LayoutRect(cell.location().x(), cell.location().y() + cell.intrinsic PaddingBefore(), cell.size().width(), cell.size().height() - cell.intrinsicPaddi ngBefore() - cell.intrinsicPaddingAfter());
210 } else if (o.isBox()) {
211 r = toLayoutBox(&o)->frameRect();
212 }
213
214 // FIXME: Temporary in order to ensure compatibility with existing layout te st results.
215 if (adjustForTableCells)
216 r.move(0, -toLayoutTableCell(o.containingBlock())->intrinsicPaddingBefor e());
217
218 if (o.isLayoutView()) {
219 r.setWidth(LayoutUnit(toLayoutView(o).viewWidth(IncludeScrollbars)));
220 r.setHeight(LayoutUnit(toLayoutView(o).viewHeight(IncludeScrollbars)));
221 }
222
223 ts << " " << r;
224 188
225 if (!(o.isText() && !o.isBR())) { 189 if (!(o.isText() && !o.isBR())) {
226 if (o.isFileUploadControl()) 190 if (o.isFileUploadControl())
227 ts << " " << quoteAndEscapeNonPrintables(toLayoutFileUploadControl(& o)->fileTextValue()); 191 ts << " " << quoteAndEscapeNonPrintables(toLayoutFileUploadControl(& o)->fileTextValue());
228 192
229 if (o.parent()) { 193 if (o.parent()) {
230 Color color = o.resolveColor(CSSPropertyColor); 194 Color color = o.resolveColor(CSSPropertyColor);
231 if (o.parent()->resolveColor(CSSPropertyColor) != color) 195 if (o.parent()->resolveColor(CSSPropertyColor) != color)
232 ts << " [color=" << color << "]"; 196 ts << " [color=" << color << "]";
233 197
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 element->document().updateStyleAndLayout(); 809 element->document().updateStyleAndLayout();
846 810
847 LayoutObject* layoutObject = element->layoutObject(); 811 LayoutObject* layoutObject = element->layoutObject();
848 if (!layoutObject || !layoutObject->isListItem()) 812 if (!layoutObject || !layoutObject->isListItem())
849 return String(); 813 return String();
850 814
851 return toLayoutListItem(layoutObject)->markerText(); 815 return toLayoutListItem(layoutObject)->markerText();
852 } 816 }
853 817
854 } // namespace blink 818 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698