OLD | NEW |
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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 } | 327 } |
328 | 328 |
329 for (RenderObject* child = o.slowFirstChild(); child; child = child->nextSib
ling()) { | 329 for (RenderObject* child = o.slowFirstChild(); child; child = child->nextSib
ling()) { |
330 if (child->hasLayer()) | 330 if (child->hasLayer()) |
331 continue; | 331 continue; |
332 write(ts, *child, indent + 1, behavior); | 332 write(ts, *child, indent + 1, behavior); |
333 } | 333 } |
334 } | 334 } |
335 | 335 |
336 static void write(TextStream& ts, RenderLayer& l, | 336 static void write(TextStream& ts, RenderLayer& l, |
337 const LayoutRect& layerBounds, const LayoutRect& backgroundCli
pRect, const LayoutRect& clipRect, | 337 const LayoutRect& layerBounds, const LayoutRect& backgroundCli
pRect, |
338 int indent = 0, RenderAsTextBehavior behavior = RenderAsTextBe
haviorNormal) | 338 int indent = 0, RenderAsTextBehavior behavior = RenderAsTextBe
haviorNormal) |
339 { | 339 { |
340 IntRect adjustedLayoutBounds = pixelSnappedIntRect(layerBounds); | 340 IntRect adjustedLayoutBounds = pixelSnappedIntRect(layerBounds); |
341 IntRect adjustedBackgroundClipRect = pixelSnappedIntRect(backgroundClipRect)
; | 341 IntRect adjustedBackgroundClipRect = pixelSnappedIntRect(backgroundClipRect)
; |
342 IntRect adjustedClipRect = pixelSnappedIntRect(clipRect); | |
343 | 342 |
344 writeIndent(ts, indent); | 343 writeIndent(ts, indent); |
345 | 344 |
346 ts << "layer "; | 345 ts << "layer "; |
347 | 346 |
348 if (behavior & RenderAsTextShowAddresses) | 347 if (behavior & RenderAsTextShowAddresses) |
349 ts << static_cast<const void*>(&l) << " "; | 348 ts << static_cast<const void*>(&l) << " "; |
350 | 349 |
351 ts << adjustedLayoutBounds; | 350 ts << adjustedLayoutBounds; |
352 | 351 |
353 if (!adjustedLayoutBounds.isEmpty()) { | 352 if (!adjustedLayoutBounds.isEmpty()) { |
354 if (!adjustedBackgroundClipRect.contains(adjustedLayoutBounds)) | 353 if (!adjustedBackgroundClipRect.contains(adjustedLayoutBounds)) |
355 ts << " backgroundClip " << adjustedBackgroundClipRect; | 354 ts << " backgroundClip " << adjustedBackgroundClipRect; |
356 if (!adjustedClipRect.contains(adjustedLayoutBounds)) | |
357 ts << " clip " << adjustedClipRect; | |
358 } | 355 } |
359 | 356 |
360 ts << "\n"; | 357 ts << "\n"; |
361 write(ts, *l.renderer(), indent + 1, behavior); | 358 write(ts, *l.renderer(), indent + 1, behavior); |
362 } | 359 } |
363 | 360 |
364 void RenderTreeAsText::writeLayers(TextStream& ts, const RenderLayer* rootLayer,
RenderLayer* layer, | 361 void RenderTreeAsText::writeLayers(TextStream& ts, const RenderLayer* rootLayer,
RenderLayer* layer, |
365 const LayoutRect& paintRect, int indent, RenderAsTextBehavior behavior) | 362 const LayoutRect& paintRect, int indent, RenderAsTextBehavior behavior) |
366 { | 363 { |
367 // FIXME: Apply overflow to the root layer to not break every test. Complete
hack. Sigh. | 364 // FIXME: Apply overflow to the root layer to not break every test. Complete
hack. Sigh. |
368 LayoutRect paintDirtyRect(paintRect); | 365 LayoutRect paintDirtyRect(paintRect); |
369 if (rootLayer == layer) { | 366 if (rootLayer == layer) { |
370 paintDirtyRect.setWidth(max<LayoutUnit>(paintDirtyRect.width(), rootLaye
r->renderer()->layoutOverflowRect().maxX())); | 367 paintDirtyRect.setWidth(max<LayoutUnit>(paintDirtyRect.width(), rootLaye
r->renderer()->layoutOverflowRect().maxX())); |
371 paintDirtyRect.setHeight(max<LayoutUnit>(paintDirtyRect.height(), rootLa
yer->renderer()->layoutOverflowRect().maxY())); | 368 paintDirtyRect.setHeight(max<LayoutUnit>(paintDirtyRect.height(), rootLa
yer->renderer()->layoutOverflowRect().maxY())); |
372 } | 369 } |
373 | 370 |
374 // Calculate the clip rects we should use. | 371 // Calculate the clip rects we should use. |
375 LayoutRect layerBounds; | 372 LayoutRect layerBounds; |
376 ClipRect damageRect, clipRectToApply; | 373 ClipRect damageRect; |
377 layer->clipper().calculateRects(ClipRectsContext(rootLayer, UncachedClipRect
s), paintDirtyRect, layerBounds, damageRect, clipRectToApply); | 374 layer->clipper().calculateRects(ClipRectsContext(rootLayer, UncachedClipRect
s), paintDirtyRect, layerBounds, damageRect); |
378 | 375 |
379 // FIXME: Apply overflow to the root layer to not break every test. Complete
hack. Sigh. | 376 // FIXME: Apply overflow to the root layer to not break every test. Complete
hack. Sigh. |
380 if (rootLayer == layer) | 377 if (rootLayer == layer) |
381 layerBounds.setSize(layer->size().expandedTo(pixelSnappedIntSize(layer->
renderer()->maxLayoutOverflow(), LayoutPoint(0, 0)))); | 378 layerBounds.setSize(layer->size().expandedTo(pixelSnappedIntSize(layer->
renderer()->maxLayoutOverflow(), LayoutPoint(0, 0)))); |
382 | 379 |
383 // Ensure our lists are up-to-date. | 380 // Ensure our lists are up-to-date. |
384 layer->stackingNode()->updateLayerListsIfNeeded(); | 381 layer->stackingNode()->updateLayerListsIfNeeded(); |
385 | 382 |
386 bool shouldPaint = (behavior & RenderAsTextShowAllLayers) ? true : layer->in
tersectsDamageRect(layerBounds, damageRect.rect(), rootLayer); | 383 bool shouldPaint = (behavior & RenderAsTextShowAllLayers) ? true : layer->in
tersectsDamageRect(layerBounds, damageRect.rect(), rootLayer); |
387 | 384 |
388 if (shouldPaint) | 385 if (shouldPaint) |
389 write(ts, *layer, layerBounds, damageRect.rect(), clipRectToApply.rect()
, indent, behavior); | 386 write(ts, *layer, layerBounds, damageRect.rect(), indent, behavior); |
390 | 387 |
391 if (Vector<RenderLayerStackingNode*>* normalFlowList = layer->stackingNode()
->normalFlowList()) { | 388 if (Vector<RenderLayerStackingNode*>* normalFlowList = layer->stackingNode()
->normalFlowList()) { |
392 int currIndent = indent; | 389 int currIndent = indent; |
393 if (behavior & RenderAsTextShowLayerNesting) { | 390 if (behavior & RenderAsTextShowLayerNesting) { |
394 writeIndent(ts, indent); | 391 writeIndent(ts, indent); |
395 ts << " normal flow list(" << normalFlowList->size() << ")\n"; | 392 ts << " normal flow list(" << normalFlowList->size() << ")\n"; |
396 ++currIndent; | 393 ++currIndent; |
397 } | 394 } |
398 for (unsigned i = 0; i != normalFlowList->size(); ++i) | 395 for (unsigned i = 0; i != normalFlowList->size(); ++i) |
399 writeLayers(ts, rootLayer, normalFlowList->at(i)->layer(), paintDirt
yRect, currIndent, behavior); | 396 writeLayers(ts, rootLayer, normalFlowList->at(i)->layer(), paintDirt
yRect, currIndent, behavior); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 element->document().updateLayout(); | 490 element->document().updateLayout(); |
494 | 491 |
495 RenderObject* renderer = element->renderer(); | 492 RenderObject* renderer = element->renderer(); |
496 if (!renderer || !renderer->isBox()) | 493 if (!renderer || !renderer->isBox()) |
497 return String(); | 494 return String(); |
498 | 495 |
499 return externalRepresentation(toRenderBox(renderer), behavior | RenderAsText
ShowAllLayers); | 496 return externalRepresentation(toRenderBox(renderer), behavior | RenderAsText
ShowAllLayers); |
500 } | 497 } |
501 | 498 |
502 } // namespace blink | 499 } // namespace blink |
OLD | NEW |