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

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

Issue 595603002: Cleanup RenderTreeAsText (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 result.append('{'); 151 result.append('{');
152 appendUnsignedAsHex(c, result); 152 appendUnsignedAsHex(c, result);
153 result.append('}'); 153 result.append('}');
154 } 154 }
155 } 155 }
156 } 156 }
157 result.append('"'); 157 result.append('"');
158 return result.toString(); 158 return result.toString();
159 } 159 }
160 160
161 TextStream& operator<<(TextStream& ts, const Color& c)
162 {
163 return ts << c.nameForRenderTreeAsText();
164 }
165
161 void RenderTreeAsText::writeRenderObject(TextStream& ts, const RenderObject& o, RenderAsTextBehavior behavior) 166 void RenderTreeAsText::writeRenderObject(TextStream& ts, const RenderObject& o, RenderAsTextBehavior behavior)
162 { 167 {
163 ts << o.renderName(); 168 ts << o.renderName();
164 169
165 if (behavior & RenderAsTextShowAddresses) 170 if (behavior & RenderAsTextShowAddresses)
166 ts << " " << static_cast<const void*>(&o); 171 ts << " " << static_cast<const void*>(&o);
167 172
168 if (o.style() && o.style()->zIndex()) 173 if (o.style() && o.style()->zIndex())
169 ts << " zI: " << o.style()->zIndex(); 174 ts << " zI: " << o.style()->zIndex();
170 175
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 219
215 ts << " " << r; 220 ts << " " << r;
216 221
217 if (!(o.isText() && !o.isBR())) { 222 if (!(o.isText() && !o.isBR())) {
218 if (o.isFileUploadControl()) 223 if (o.isFileUploadControl())
219 ts << " " << quoteAndEscapeNonPrintables(toRenderFileUploadControl(& o)->fileTextValue()); 224 ts << " " << quoteAndEscapeNonPrintables(toRenderFileUploadControl(& o)->fileTextValue());
220 225
221 if (o.parent()) { 226 if (o.parent()) {
222 Color color = o.resolveColor(CSSPropertyColor); 227 Color color = o.resolveColor(CSSPropertyColor);
223 if (o.parent()->resolveColor(CSSPropertyColor) != color) 228 if (o.parent()->resolveColor(CSSPropertyColor) != color)
224 ts << " [color=" << color.nameForRenderTreeAsText() << "]"; 229 ts << " [color=" << color << "]";
225 230
226 // Do not dump invalid or transparent backgrounds, since that is the default. 231 // Do not dump invalid or transparent backgrounds, since that is the default.
227 Color backgroundColor = o.resolveColor(CSSPropertyBackgroundColor); 232 Color backgroundColor = o.resolveColor(CSSPropertyBackgroundColor);
228 if (o.parent()->resolveColor(CSSPropertyBackgroundColor) != backgrou ndColor 233 if (o.parent()->resolveColor(CSSPropertyBackgroundColor) != backgrou ndColor
229 && backgroundColor.rgb()) 234 && backgroundColor.rgb())
230 ts << " [bgcolor=" << backgroundColor.nameForRenderTreeAsText() << "]"; 235 ts << " [bgcolor=" << backgroundColor << "]";
231 236
232 Color textFillColor = o.resolveColor(CSSPropertyWebkitTextFillColor) ; 237 Color textFillColor = o.resolveColor(CSSPropertyWebkitTextFillColor) ;
233 if (o.parent()->resolveColor(CSSPropertyWebkitTextFillColor) != text FillColor 238 if (o.parent()->resolveColor(CSSPropertyWebkitTextFillColor) != text FillColor
234 && textFillColor != color && textFillColor.rgb()) 239 && textFillColor != color && textFillColor.rgb())
235 ts << " [textFillColor=" << textFillColor.nameForRenderTreeAsTex t() << "]"; 240 ts << " [textFillColor=" << textFillColor << "]";
236 241
237 Color textStrokeColor = o.resolveColor(CSSPropertyWebkitTextStrokeCo lor); 242 Color textStrokeColor = o.resolveColor(CSSPropertyWebkitTextStrokeCo lor);
238 if (o.parent()->resolveColor(CSSPropertyWebkitTextStrokeColor) != te xtStrokeColor 243 if (o.parent()->resolveColor(CSSPropertyWebkitTextStrokeColor) != te xtStrokeColor
239 && textStrokeColor != color && textStrokeColor.rgb()) 244 && textStrokeColor != color && textStrokeColor.rgb())
240 ts << " [textStrokeColor=" << textStrokeColor.nameForRenderTreeA sText() << "]"; 245 ts << " [textStrokeColor=" << textStrokeColor << "]";
241 246
242 if (o.parent()->style()->textStrokeWidth() != o.style()->textStrokeW idth() && o.style()->textStrokeWidth() > 0) 247 if (o.parent()->style()->textStrokeWidth() != o.style()->textStrokeW idth() && o.style()->textStrokeWidth() > 0)
243 ts << " [textStrokeWidth=" << o.style()->textStrokeWidth() << "] "; 248 ts << " [textStrokeWidth=" << o.style()->textStrokeWidth() << "] ";
244 } 249 }
245 250
246 if (!o.isBoxModelObject()) 251 if (!o.isBoxModelObject())
247 return; 252 return;
248 253
249 const RenderBoxModelObject& box = toRenderBoxModelObject(o); 254 const RenderBoxModelObject& box = toRenderBoxModelObject(o);
250 if (box.borderTop() || box.borderRight() || box.borderBottom() || box.bo rderLeft()) { 255 if (box.borderTop() || box.borderRight() || box.borderBottom() || box.bo rderLeft()) {
251 ts << " [border:"; 256 ts << " [border:";
252 257
253 BorderValue prevBorder = o.style()->borderTop(); 258 BorderValue prevBorder = o.style()->borderTop();
254 if (!box.borderTop()) 259 if (!box.borderTop())
255 ts << " none"; 260 ts << " none";
256 else { 261 else {
257 ts << " (" << box.borderTop() << "px "; 262 ts << " (" << box.borderTop() << "px ";
258 printBorderStyle(ts, o.style()->borderTopStyle()); 263 printBorderStyle(ts, o.style()->borderTopStyle());
259 Color col = o.resolveColor(CSSPropertyBorderTopColor); 264 ts << o.resolveColor(CSSPropertyBorderTopColor) << ")";
260 ts << col.nameForRenderTreeAsText() << ")";
261 } 265 }
262 266
263 if (o.style()->borderRight() != prevBorder) { 267 if (o.style()->borderRight() != prevBorder) {
264 prevBorder = o.style()->borderRight(); 268 prevBorder = o.style()->borderRight();
265 if (!box.borderRight()) 269 if (!box.borderRight())
266 ts << " none"; 270 ts << " none";
267 else { 271 else {
268 ts << " (" << box.borderRight() << "px "; 272 ts << " (" << box.borderRight() << "px ";
269 printBorderStyle(ts, o.style()->borderRightStyle()); 273 printBorderStyle(ts, o.style()->borderRightStyle());
270 Color col = o.resolveColor(CSSPropertyBorderRightColor); 274 ts << o.resolveColor(CSSPropertyBorderRightColor) << ")";
271 ts << col.nameForRenderTreeAsText() << ")";
272 } 275 }
273 } 276 }
274 277
275 if (o.style()->borderBottom() != prevBorder) { 278 if (o.style()->borderBottom() != prevBorder) {
276 prevBorder = box.style()->borderBottom(); 279 prevBorder = box.style()->borderBottom();
277 if (!box.borderBottom()) 280 if (!box.borderBottom())
278 ts << " none"; 281 ts << " none";
279 else { 282 else {
280 ts << " (" << box.borderBottom() << "px "; 283 ts << " (" << box.borderBottom() << "px ";
281 printBorderStyle(ts, o.style()->borderBottomStyle()); 284 printBorderStyle(ts, o.style()->borderBottomStyle());
282 Color col = o.resolveColor(CSSPropertyBorderBottomColor); 285 ts << o.resolveColor(CSSPropertyBorderBottomColor) << ")";
283 ts << col.nameForRenderTreeAsText() << ")";
284 } 286 }
285 } 287 }
286 288
287 if (o.style()->borderLeft() != prevBorder) { 289 if (o.style()->borderLeft() != prevBorder) {
288 prevBorder = o.style()->borderLeft(); 290 prevBorder = o.style()->borderLeft();
289 if (!box.borderLeft()) 291 if (!box.borderLeft())
290 ts << " none"; 292 ts << " none";
291 else { 293 else {
292 ts << " (" << box.borderLeft() << "px "; 294 ts << " (" << box.borderLeft() << "px ";
293 printBorderStyle(ts, o.style()->borderLeftStyle()); 295 printBorderStyle(ts, o.style()->borderLeftStyle());
294 Color col = o.resolveColor(CSSPropertyBorderLeftColor); 296 ts << o.resolveColor(CSSPropertyBorderLeftColor) << ")";
295 ts << col.nameForRenderTreeAsText() << ")";
296 } 297 }
297 } 298 }
298 299
299 ts << "]"; 300 ts << "]";
300 } 301 }
301 } 302 }
302 303
303 if (o.isTableCell()) { 304 if (o.isTableCell()) {
304 const RenderTableCell& c = toRenderTableCell(o); 305 const RenderTableCell& c = toRenderTableCell(o);
305 ts << " [r=" << c.rowIndex() << " c=" << c.col() << " rs=" << c.rowSpan( ) << " cs=" << c.colSpan() << "]"; 306 ts << " [r=" << c.rowIndex() << " c=" << c.col() << " rs=" << c.rowSpan( ) << " cs=" << c.colSpan() << "]";
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 element->document().updateLayout(); 773 element->document().updateLayout();
773 774
774 RenderObject* renderer = element->renderer(); 775 RenderObject* renderer = element->renderer();
775 if (!renderer || !renderer->isListItem()) 776 if (!renderer || !renderer->isListItem())
776 return String(); 777 return String();
777 778
778 return toRenderListItem(renderer)->markerText(); 779 return toRenderListItem(renderer)->markerText();
779 } 780 }
780 781
781 } // namespace blink 782 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderTreeAsText.h ('k') | Source/core/rendering/svg/SVGRenderTreeAsText.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698