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

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

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

Powered by Google App Engine
This is Rietveld 408576698