OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 RenderBox* box = renderBox(); | 334 RenderBox* box = renderBox(); |
335 ASSERT(box); | 335 ASSERT(box); |
336 m_transform->makeIdentity(); | 336 m_transform->makeIdentity(); |
337 box->style()->applyTransform(*m_transform, box->borderBoxRect().size(),
RenderStyle::IncludeTransformOrigin); | 337 box->style()->applyTransform(*m_transform, box->borderBoxRect().size(),
RenderStyle::IncludeTransformOrigin); |
338 } | 338 } |
339 | 339 |
340 if (had3DTransform != has3DTransform()) | 340 if (had3DTransform != has3DTransform()) |
341 dirty3DTransformedDescendantStatus(); | 341 dirty3DTransformedDescendantStatus(); |
342 } | 342 } |
343 | 343 |
| 344 TransformationMatrix RenderLayer::currentTransform() const |
| 345 { |
| 346 if (!m_transform) |
| 347 return TransformationMatrix(); |
| 348 |
| 349 #if USE(ACCELERATED_COMPOSITING) |
| 350 if (renderer()->style()->isRunningAcceleratedAnimation()) { |
| 351 TransformationMatrix currTransform; |
| 352 RefPtr<RenderStyle> style = renderer()->animation()->getAnimatedStyleFor
Renderer(renderer()); |
| 353 style->applyTransform(currTransform, renderBox()->borderBoxRect().size()
, RenderStyle::IncludeTransformOrigin); |
| 354 return currTransform; |
| 355 } |
| 356 #endif |
| 357 |
| 358 return *m_transform; |
| 359 } |
| 360 |
344 void RenderLayer::setHasVisibleContent(bool b) | 361 void RenderLayer::setHasVisibleContent(bool b) |
345 { | 362 { |
346 if (m_hasVisibleContent == b && !m_visibleContentStatusDirty) | 363 if (m_hasVisibleContent == b && !m_visibleContentStatusDirty) |
347 return; | 364 return; |
348 m_visibleContentStatusDirty = false; | 365 m_visibleContentStatusDirty = false; |
349 m_hasVisibleContent = b; | 366 m_hasVisibleContent = b; |
350 if (m_hasVisibleContent) { | 367 if (m_hasVisibleContent) { |
351 RenderBoxModelObject* repaintContainer = renderer()->containerForRepaint
(); | 368 RenderBoxModelObject* repaintContainer = renderer()->containerForRepaint
(); |
352 m_repaintRect = renderer()->clippedOverflowRectForRepaint(repaintContain
er); | 369 m_repaintRect = renderer()->clippedOverflowRectForRepaint(repaintContain
er); |
353 m_outlineBox = renderer()->outlineBoundsForRepaint(repaintContainer); | 370 m_outlineBox = renderer()->outlineBoundsForRepaint(repaintContainer); |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 if (!renderer()->hasTransform()) | 603 if (!renderer()->hasTransform()) |
587 return FloatPoint(); | 604 return FloatPoint(); |
588 | 605 |
589 const IntRect borderBox = toRenderBox(renderer())->borderBoxRect(); | 606 const IntRect borderBox = toRenderBox(renderer())->borderBoxRect(); |
590 RenderStyle* style = renderer()->style(); | 607 RenderStyle* style = renderer()->style(); |
591 | 608 |
592 return FloatPoint(style->perspectiveOriginX().calcFloatValue(borderBox.width
()), | 609 return FloatPoint(style->perspectiveOriginX().calcFloatValue(borderBox.width
()), |
593 style->perspectiveOriginY().calcFloatValue(borderBox.heigh
t())); | 610 style->perspectiveOriginY().calcFloatValue(borderBox.heigh
t())); |
594 } | 611 } |
595 | 612 |
596 RenderLayer *RenderLayer::stackingContext() const | 613 RenderLayer* RenderLayer::stackingContext() const |
597 { | 614 { |
598 RenderLayer* curr = parent(); | 615 RenderLayer* layer = parent(); |
599 for ( ; curr && !curr->renderer()->isRenderView() && !curr->renderer()->isRo
ot() && | 616 while (layer && !layer->renderer()->isRenderView() && !layer->renderer()->is
Root() && layer->renderer()->style()->hasAutoZIndex()) |
600 curr->renderer()->style()->hasAutoZIndex(); | 617 layer = layer->parent(); |
601 curr = curr->parent()) { } | 618 return layer; |
602 return curr; | |
603 } | 619 } |
604 | 620 |
605 RenderLayer* RenderLayer::enclosingPositionedAncestor() const | 621 RenderLayer* RenderLayer::enclosingPositionedAncestor() const |
606 { | 622 { |
607 RenderLayer* curr = parent(); | 623 RenderLayer* curr = parent(); |
608 for ( ; curr && !curr->renderer()->isRenderView() && !curr->renderer()->isPo
sitioned() && !curr->renderer()->isRelPositioned() && !curr->hasTransform(); | 624 for ( ; curr && !curr->renderer()->isRenderView() && !curr->renderer()->isPo
sitioned() && !curr->renderer()->isRelPositioned() && !curr->hasTransform(); |
609 curr = curr->parent()) { } | 625 curr = curr->parent()) { } |
610 return curr; | 626 return curr; |
611 } | 627 } |
612 | 628 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 return renderArena->allocate(sz); | 762 return renderArena->allocate(sz); |
747 } | 763 } |
748 | 764 |
749 void RenderLayer::operator delete(void* ptr, size_t sz) | 765 void RenderLayer::operator delete(void* ptr, size_t sz) |
750 { | 766 { |
751 // Stash size where destroy can find it. | 767 // Stash size where destroy can find it. |
752 *(size_t *)ptr = sz; | 768 *(size_t *)ptr = sz; |
753 } | 769 } |
754 | 770 |
755 void RenderLayer::destroy(RenderArena* renderArena) | 771 void RenderLayer::destroy(RenderArena* renderArena) |
756 { | 772 { |
757 delete this; | 773 delete this; |
758 | 774 |
759 // Recover the size left there for us by operator delete and free the memory
. | 775 // Recover the size left there for us by operator delete and free the memory
. |
760 renderArena->free(*(size_t *)this, this); | 776 renderArena->free(*(size_t *)this, this); |
761 } | 777 } |
762 | 778 |
763 void RenderLayer::addChild(RenderLayer* child, RenderLayer* beforeChild) | 779 void RenderLayer::addChild(RenderLayer* child, RenderLayer* beforeChild) |
764 { | 780 { |
765 RenderLayer* prevSibling = beforeChild ? beforeChild->previousSibling() : la
stChild(); | 781 RenderLayer* prevSibling = beforeChild ? beforeChild->previousSibling() : la
stChild(); |
766 if (prevSibling) { | 782 if (prevSibling) { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 | 872 |
857 // Now walk our kids and reattach them to our parent. | 873 // Now walk our kids and reattach them to our parent. |
858 RenderLayer* current = m_first; | 874 RenderLayer* current = m_first; |
859 while (current) { | 875 while (current) { |
860 RenderLayer* next = current->nextSibling(); | 876 RenderLayer* next = current->nextSibling(); |
861 removeChild(current); | 877 removeChild(current); |
862 parent->addChild(current, nextSib); | 878 parent->addChild(current, nextSib); |
863 current->updateLayerPositions(); | 879 current->updateLayerPositions(); |
864 current = next; | 880 current = next; |
865 } | 881 } |
866 | 882 |
867 destroy(renderer()->renderArena()); | 883 m_renderer->destroyLayer(); |
868 } | 884 } |
869 | 885 |
870 void RenderLayer::insertOnlyThisLayer() | 886 void RenderLayer::insertOnlyThisLayer() |
871 { | 887 { |
872 if (!m_parent && renderer()->parent()) { | 888 if (!m_parent && renderer()->parent()) { |
873 // We need to connect ourselves when our renderer() has a parent. | 889 // We need to connect ourselves when our renderer() has a parent. |
874 // Find our enclosingLayer and add ourselves. | 890 // Find our enclosingLayer and add ourselves. |
875 RenderLayer* parentLayer = renderer()->parent()->enclosingLayer(); | 891 RenderLayer* parentLayer = renderer()->parent()->enclosingLayer(); |
876 RenderLayer* beforeChild = parentLayer->reflectionLayer() != this ? rend
erer()->parent()->findNextLayer(parentLayer, renderer()) : 0; | 892 RenderLayer* beforeChild = parentLayer->reflectionLayer() != this ? rend
erer()->parent()->findNextLayer(parentLayer, renderer()) : 0; |
877 if (parentLayer) | 893 if (parentLayer) |
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1764 | 1780 |
1765 // Paint the resizer control. | 1781 // Paint the resizer control. |
1766 DEFINE_STATIC_LOCAL(RefPtr<Image>, resizeCornerImage, (Image::loadPlatformRe
source("textAreaResizeCorner"))); | 1782 DEFINE_STATIC_LOCAL(RefPtr<Image>, resizeCornerImage, (Image::loadPlatformRe
source("textAreaResizeCorner"))); |
1767 IntPoint imagePoint(absRect.right() - resizeCornerImage->width(), absRect.bo
ttom() - resizeCornerImage->height()); | 1783 IntPoint imagePoint(absRect.right() - resizeCornerImage->width(), absRect.bo
ttom() - resizeCornerImage->height()); |
1768 context->drawImage(resizeCornerImage.get(), imagePoint); | 1784 context->drawImage(resizeCornerImage.get(), imagePoint); |
1769 | 1785 |
1770 // Draw a frame around the resizer (1px grey line) if there are any scrollba
rs present. | 1786 // Draw a frame around the resizer (1px grey line) if there are any scrollba
rs present. |
1771 // Clipping will exclude the right and bottom edges of this frame. | 1787 // Clipping will exclude the right and bottom edges of this frame. |
1772 if (m_hBar || m_vBar) { | 1788 if (m_hBar || m_vBar) { |
1773 context->save(); | 1789 context->save(); |
| 1790 context->clip(absRect); |
1774 IntRect largerCorner = absRect; | 1791 IntRect largerCorner = absRect; |
1775 largerCorner.setSize(IntSize(largerCorner.width() + 1, largerCorner.heig
ht() + 1)); | 1792 largerCorner.setSize(IntSize(largerCorner.width() + 1, largerCorner.heig
ht() + 1)); |
1776 context->setStrokeColor(Color(makeRGB(217, 217, 217))); | 1793 context->setStrokeColor(Color(makeRGB(217, 217, 217))); |
1777 context->setStrokeThickness(1.0f); | 1794 context->setStrokeThickness(1.0f); |
1778 context->setFillColor(Color::transparent); | 1795 context->setFillColor(Color::transparent); |
1779 context->drawRect(largerCorner); | 1796 context->drawRect(largerCorner); |
1780 context->restore(); | 1797 context->restore(); |
1781 } | 1798 } |
1782 } | 1799 } |
1783 | 1800 |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2222 // layer, and the accumulated transform which lets up map through preser
ve-3d layers. | 2239 // layer, and the accumulated transform which lets up map through preser
ve-3d layers. |
2223 // | 2240 // |
2224 // We can't just map hitTestPoint and hitTestRect because they may have
been flattened (losing z) | 2241 // We can't just map hitTestPoint and hitTestRect because they may have
been flattened (losing z) |
2225 // by our container. | 2242 // by our container. |
2226 IntPoint localPoint = roundedIntPoint(newTransformState->mappedPoint()); | 2243 IntPoint localPoint = roundedIntPoint(newTransformState->mappedPoint()); |
2227 IntRect localHitTestRect = newTransformState->mappedQuad().enclosingBoun
dingBox(); | 2244 IntRect localHitTestRect = newTransformState->mappedQuad().enclosingBoun
dingBox(); |
2228 | 2245 |
2229 // Now do a hit test with the root layer shifted to be us. | 2246 // Now do a hit test with the root layer shifted to be us. |
2230 return hitTestLayer(this, containerLayer, request, result, localHitTestR
ect, localPoint, true, newTransformState.get(), zOffset); | 2247 return hitTestLayer(this, containerLayer, request, result, localHitTestR
ect, localPoint, true, newTransformState.get(), zOffset); |
2231 } | 2248 } |
| 2249 |
| 2250 // Ensure our lists and 3d status are up-to-date. |
| 2251 updateLayerListsIfNeeded(); |
| 2252 update3DTransformedDescendantStatus(); |
2232 | 2253 |
2233 RefPtr<HitTestingTransformState> localTransformState; | 2254 RefPtr<HitTestingTransformState> localTransformState; |
2234 if (appliedTransform) { | 2255 if (appliedTransform) { |
2235 // We computed the correct state in the caller (above code), so just ref
erence it. | 2256 // We computed the correct state in the caller (above code), so just ref
erence it. |
2236 ASSERT(transformState); | 2257 ASSERT(transformState); |
2237 localTransformState = const_cast<HitTestingTransformState*>(transformSta
te); | 2258 localTransformState = const_cast<HitTestingTransformState*>(transformSta
te); |
2238 } else if (transformState || m_has3DTransformedDescendant) { | 2259 } else if (transformState || m_has3DTransformedDescendant || preserves3D())
{ |
2239 // We need transform state for the first time, or to offset the containe
r state, so create it here. | 2260 // We need transform state for the first time, or to offset the containe
r state, so create it here. |
2240 localTransformState = createLocalTransformState(rootLayer, containerLaye
r, hitTestRect, hitTestPoint, transformState); | 2261 localTransformState = createLocalTransformState(rootLayer, containerLaye
r, hitTestRect, hitTestPoint, transformState); |
2241 } | 2262 } |
2242 | 2263 |
2243 RefPtr<HitTestingTransformState> unflattenedTransformState = localTransformS
tate; | 2264 RefPtr<HitTestingTransformState> unflattenedTransformState = localTransformS
tate; |
2244 if (localTransformState && !preserves3D()) { | 2265 if (localTransformState && !preserves3D()) { |
2245 // Keep a copy of the pre-flattening state, for computing z-offsets for
the container | 2266 // Keep a copy of the pre-flattening state, for computing z-offsets for
the container |
2246 unflattenedTransformState = HitTestingTransformState::create(*localTrans
formState); | 2267 unflattenedTransformState = HitTestingTransformState::create(*localTrans
formState); |
2247 // This layer is flattening, so flatten the state passed to descendants. | 2268 // This layer is flattening, so flatten the state passed to descendants. |
2248 localTransformState->flatten(); | 2269 localTransformState->flatten(); |
2249 } | 2270 } |
2250 | 2271 |
2251 // Calculate the clip rects we should use. | 2272 // Calculate the clip rects we should use. |
2252 IntRect layerBounds; | 2273 IntRect layerBounds; |
2253 IntRect bgRect; | 2274 IntRect bgRect; |
2254 IntRect fgRect; | 2275 IntRect fgRect; |
2255 IntRect outlineRect; | 2276 IntRect outlineRect; |
2256 calculateRects(rootLayer, hitTestRect, layerBounds, bgRect, fgRect, outlineR
ect); | 2277 calculateRects(rootLayer, hitTestRect, layerBounds, bgRect, fgRect, outlineR
ect); |
2257 | 2278 |
2258 // Ensure our lists and 3d status are up-to-date. | |
2259 updateLayerListsIfNeeded(); | |
2260 update3DTransformedDescendantStatus(); | |
2261 | |
2262 // The following are used for keeping track of the z-depth of the hit point
of 3d-transformed | 2279 // The following are used for keeping track of the z-depth of the hit point
of 3d-transformed |
2263 // descendants. | 2280 // descendants. |
2264 double localZOffset = -numeric_limits<double>::infinity(); | 2281 double localZOffset = -numeric_limits<double>::infinity(); |
2265 double* zOffsetForDescendantsPtr = 0; | 2282 double* zOffsetForDescendantsPtr = 0; |
2266 double* zOffsetForContentsPtr = 0; | 2283 double* zOffsetForContentsPtr = 0; |
2267 | 2284 |
2268 bool depthSortDescendants = false; | 2285 bool depthSortDescendants = false; |
2269 if (preserves3D()) { | 2286 if (preserves3D()) { |
2270 depthSortDescendants = true; | 2287 depthSortDescendants = true; |
2271 // Our layers can depth-test with our container, so share the z depth po
inter with the container, if it passed one down. | 2288 // Our layers can depth-test with our container, so share the z depth po
inter with the container, if it passed one down. |
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3114 if (m_marquee) | 3131 if (m_marquee) |
3115 m_marquee->suspend(); | 3132 m_marquee->suspend(); |
3116 | 3133 |
3117 for (RenderLayer* curr = firstChild(); curr; curr = curr->nextSibling()) | 3134 for (RenderLayer* curr = firstChild(); curr; curr = curr->nextSibling()) |
3118 curr->suspendMarquees(); | 3135 curr->suspendMarquees(); |
3119 } | 3136 } |
3120 | 3137 |
3121 } // namespace WebCore | 3138 } // namespace WebCore |
3122 | 3139 |
3123 | 3140 |
OLD | NEW |