| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights
reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights
reserved. |
| 3 * | 3 * |
| 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. | 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. |
| 5 * | 5 * |
| 6 * Other contributors: | 6 * Other contributors: |
| 7 * Robert O'Callahan <roc+@cs.cmu.edu> | 7 * Robert O'Callahan <roc+@cs.cmu.edu> |
| 8 * David Baron <dbaron@fas.harvard.edu> | 8 * David Baron <dbaron@fas.harvard.edu> |
| 9 * Christian Biesinger <cbiesinger@web.de> | 9 * Christian Biesinger <cbiesinger@web.de> |
| 10 * Randall Jesup <rjesup@wgate.com> | 10 * Randall Jesup <rjesup@wgate.com> |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 #include "sky/engine/platform/graphics/filters/SourceGraphic.h" | 71 #include "sky/engine/platform/graphics/filters/SourceGraphic.h" |
| 72 #include "sky/engine/platform/transforms/ScaleTransformOperation.h" | 72 #include "sky/engine/platform/transforms/ScaleTransformOperation.h" |
| 73 #include "sky/engine/platform/transforms/TransformationMatrix.h" | 73 #include "sky/engine/platform/transforms/TransformationMatrix.h" |
| 74 #include "sky/engine/platform/transforms/TranslateTransformOperation.h" | 74 #include "sky/engine/platform/transforms/TranslateTransformOperation.h" |
| 75 #include "sky/engine/public/platform/Platform.h" | 75 #include "sky/engine/public/platform/Platform.h" |
| 76 #include "sky/engine/wtf/StdLibExtras.h" | 76 #include "sky/engine/wtf/StdLibExtras.h" |
| 77 #include "sky/engine/wtf/text/CString.h" | 77 #include "sky/engine/wtf/text/CString.h" |
| 78 | 78 |
| 79 namespace blink { | 79 namespace blink { |
| 80 | 80 |
| 81 RenderLayer::RenderLayer(RenderLayerModelObject* renderer, LayerType type) | 81 RenderLayer::RenderLayer(RenderBox* renderer, LayerType type) |
| 82 : m_layerType(type) | 82 : m_layerType(type) |
| 83 , m_hasSelfPaintingLayerDescendant(false) | 83 , m_hasSelfPaintingLayerDescendant(false) |
| 84 , m_hasSelfPaintingLayerDescendantDirty(false) | 84 , m_hasSelfPaintingLayerDescendantDirty(false) |
| 85 , m_isRootLayer(renderer->isRenderView()) | 85 , m_isRootLayer(renderer->isRenderView()) |
| 86 , m_usedTransparency(false) | 86 , m_usedTransparency(false) |
| 87 , m_3DTransformedDescendantStatusDirty(true) | 87 , m_3DTransformedDescendantStatusDirty(true) |
| 88 , m_has3DTransformedDescendant(false) | 88 , m_has3DTransformedDescendant(false) |
| 89 , m_hasFilterInfo(false) | 89 , m_hasFilterInfo(false) |
| 90 , m_renderer(renderer) | 90 , m_renderer(renderer) |
| 91 , m_parent(0) | 91 , m_parent(0) |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 TransformationMatrix RenderLayer::perspectiveTransform() const | 354 TransformationMatrix RenderLayer::perspectiveTransform() const |
| 355 { | 355 { |
| 356 if (!renderer()->hasTransform()) | 356 if (!renderer()->hasTransform()) |
| 357 return TransformationMatrix(); | 357 return TransformationMatrix(); |
| 358 | 358 |
| 359 RenderStyle* style = renderer()->style(); | 359 RenderStyle* style = renderer()->style(); |
| 360 if (!style->hasPerspective()) | 360 if (!style->hasPerspective()) |
| 361 return TransformationMatrix(); | 361 return TransformationMatrix(); |
| 362 | 362 |
| 363 // Maybe fetch the perspective from the backing? | 363 // Maybe fetch the perspective from the backing? |
| 364 const IntRect borderBox = toRenderBox(renderer())->pixelSnappedBorderBoxRect
(); | 364 const IntRect borderBox = renderer()->pixelSnappedBorderBoxRect(); |
| 365 const float boxWidth = borderBox.width(); | 365 const float boxWidth = borderBox.width(); |
| 366 const float boxHeight = borderBox.height(); | 366 const float boxHeight = borderBox.height(); |
| 367 | 367 |
| 368 float perspectiveOriginX = floatValueForLength(style->perspectiveOriginX(),
boxWidth); | 368 float perspectiveOriginX = floatValueForLength(style->perspectiveOriginX(),
boxWidth); |
| 369 float perspectiveOriginY = floatValueForLength(style->perspectiveOriginY(),
boxHeight); | 369 float perspectiveOriginY = floatValueForLength(style->perspectiveOriginY(),
boxHeight); |
| 370 | 370 |
| 371 // A perspective origin of 0,0 makes the vanishing point in the center of th
e element. | 371 // A perspective origin of 0,0 makes the vanishing point in the center of th
e element. |
| 372 // We want it to be in the top-left, so subtract half the height and width. | 372 // We want it to be in the top-left, so subtract half the height and width. |
| 373 perspectiveOriginX -= boxWidth / 2.0f; | 373 perspectiveOriginX -= boxWidth / 2.0f; |
| 374 perspectiveOriginY -= boxHeight / 2.0f; | 374 perspectiveOriginY -= boxHeight / 2.0f; |
| 375 | 375 |
| 376 TransformationMatrix t; | 376 TransformationMatrix t; |
| 377 t.translate(perspectiveOriginX, perspectiveOriginY); | 377 t.translate(perspectiveOriginX, perspectiveOriginY); |
| 378 t.applyPerspective(style->perspective()); | 378 t.applyPerspective(style->perspective()); |
| 379 t.translate(-perspectiveOriginX, -perspectiveOriginY); | 379 t.translate(-perspectiveOriginX, -perspectiveOriginY); |
| 380 | 380 |
| 381 return t; | 381 return t; |
| 382 } | 382 } |
| 383 | 383 |
| 384 FloatPoint RenderLayer::perspectiveOrigin() const | 384 FloatPoint RenderLayer::perspectiveOrigin() const |
| 385 { | 385 { |
| 386 if (!renderer()->hasTransform()) | 386 if (!renderer()->hasTransform()) |
| 387 return FloatPoint(); | 387 return FloatPoint(); |
| 388 | 388 |
| 389 const LayoutRect borderBox = toRenderBox(renderer())->borderBoxRect(); | 389 const LayoutRect borderBox = renderer()->borderBoxRect(); |
| 390 RenderStyle* style = renderer()->style(); | 390 RenderStyle* style = renderer()->style(); |
| 391 | 391 |
| 392 return FloatPoint(floatValueForLength(style->perspectiveOriginX(), borderBox
.width().toFloat()), floatValueForLength(style->perspectiveOriginY(), borderBox.
height().toFloat())); | 392 return FloatPoint(floatValueForLength(style->perspectiveOriginX(), borderBox
.width().toFloat()), floatValueForLength(style->perspectiveOriginY(), borderBox.
height().toFloat())); |
| 393 } | 393 } |
| 394 | 394 |
| 395 RenderLayer* RenderLayer::enclosingPositionedAncestor() const | 395 RenderLayer* RenderLayer::enclosingPositionedAncestor() const |
| 396 { | 396 { |
| 397 RenderLayer* curr = parent(); | 397 RenderLayer* curr = parent(); |
| 398 while (curr && !curr->isPositionedContainer()) | 398 while (curr && !curr->isPositionedContainer()) |
| 399 curr = curr->parent(); | 399 curr = curr->parent(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 417 if (curr->requiresFullLayerImageForFilters()) | 417 if (curr->requiresFullLayerImageForFilters()) |
| 418 return const_cast<RenderLayer*>(curr); | 418 return const_cast<RenderLayer*>(curr); |
| 419 } | 419 } |
| 420 | 420 |
| 421 return 0; | 421 return 0; |
| 422 } | 422 } |
| 423 | 423 |
| 424 bool RenderLayer::hasAncestorWithFilterOutsets() const | 424 bool RenderLayer::hasAncestorWithFilterOutsets() const |
| 425 { | 425 { |
| 426 for (const RenderLayer* curr = this; curr; curr = curr->parent()) { | 426 for (const RenderLayer* curr = this; curr; curr = curr->parent()) { |
| 427 RenderLayerModelObject* renderer = curr->renderer(); | 427 RenderBox* renderer = curr->renderer(); |
| 428 if (renderer->style()->hasFilterOutsets()) | 428 if (renderer->style()->hasFilterOutsets()) |
| 429 return true; | 429 return true; |
| 430 } | 430 } |
| 431 return false; | 431 return false; |
| 432 } | 432 } |
| 433 | 433 |
| 434 RenderLayer* RenderLayer::transparentPaintingAncestor() | 434 RenderLayer* RenderLayer::transparentPaintingAncestor() |
| 435 { | 435 { |
| 436 for (RenderLayer* curr = parent(); curr; curr = curr->parent()) { | 436 for (RenderLayer* curr = parent(); curr; curr = curr->parent()) { |
| 437 if (curr->isTransparent()) | 437 if (curr->isTransparent()) |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 | 643 |
| 644 // Clear out all the clip rects. | 644 // Clear out all the clip rects. |
| 645 m_clipper.clearClipRectsIncludingDescendants(); | 645 m_clipper.clearClipRectsIncludingDescendants(); |
| 646 } | 646 } |
| 647 | 647 |
| 648 // Returns the layer reached on the walk up towards the ancestor. | 648 // Returns the layer reached on the walk up towards the ancestor. |
| 649 static inline const RenderLayer* accumulateOffsetTowardsAncestor(const RenderLay
er* layer, const RenderLayer* ancestorLayer, LayoutPoint& location) | 649 static inline const RenderLayer* accumulateOffsetTowardsAncestor(const RenderLay
er* layer, const RenderLayer* ancestorLayer, LayoutPoint& location) |
| 650 { | 650 { |
| 651 ASSERT(ancestorLayer != layer); | 651 ASSERT(ancestorLayer != layer); |
| 652 | 652 |
| 653 const RenderLayerModelObject* renderer = layer->renderer(); | 653 const RenderBox* renderer = layer->renderer(); |
| 654 EPosition position = renderer->style()->position(); | 654 EPosition position = renderer->style()->position(); |
| 655 | 655 |
| 656 RenderLayer* parentLayer; | 656 RenderLayer* parentLayer; |
| 657 if (position == AbsolutePosition) { | 657 if (position == AbsolutePosition) { |
| 658 // Do what enclosingPositionedAncestor() does, but check for ancestorLay
er along the way. | 658 // Do what enclosingPositionedAncestor() does, but check for ancestorLay
er along the way. |
| 659 parentLayer = layer->parent(); | 659 parentLayer = layer->parent(); |
| 660 bool foundAncestorFirst = false; | 660 bool foundAncestorFirst = false; |
| 661 while (parentLayer) { | 661 while (parentLayer) { |
| 662 // RenderFlowThread is a positioned container, child of RenderView,
positioned at (0,0). | 662 // RenderFlowThread is a positioned container, child of RenderView,
positioned at (0,0). |
| 663 // This implies that, for out-of-flow positioned elements inside a R
enderFlowThread, | 663 // This implies that, for out-of-flow positioned elements inside a R
enderFlowThread, |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 } | 1049 } |
| 1050 } | 1050 } |
| 1051 | 1051 |
| 1052 void showLayerTree(const blink::RenderObject* renderer) | 1052 void showLayerTree(const blink::RenderObject* renderer) |
| 1053 { | 1053 { |
| 1054 if (!renderer) | 1054 if (!renderer) |
| 1055 return; | 1055 return; |
| 1056 showLayerTree(renderer->enclosingLayer()); | 1056 showLayerTree(renderer->enclosingLayer()); |
| 1057 } | 1057 } |
| 1058 #endif | 1058 #endif |
| OLD | NEW |