diff --git a/engine/core/rendering/RenderBox.cpp b/engine/core/rendering/RenderBox.cpp index c47ab38c41a4758002a0506656a1a094f1d3c0d7..87dd4600a375e067830f622c7beacdb9d1348bd6 100644 --- a/engine/core/rendering/RenderBox.cpp +++ b/engine/core/rendering/RenderBox.cpp @@ -281,6 +281,17 @@ FloatQuad RenderBox::absoluteContentQuad() const return localToAbsoluteQuad(FloatRect(rect)); } +FloatPoint RenderBox::perspectiveOrigin() const +{ + if (!hasTransform()) + return FloatPoint(); + + const LayoutRect borderBox = borderBoxRect(); + return FloatPoint( + floatValueForLength(style()->perspectiveOriginX(), borderBox.width().toFloat()), + floatValueForLength(style()->perspectiveOriginY(), borderBox.height().toFloat())); +} + void RenderBox::addFocusRingRects(Vector& rects, const LayoutPoint& additionalOffset, const RenderBox*) const { if (!size().isEmpty()) @@ -835,7 +846,7 @@ void RenderBox::paintLayerContents(GraphicsContext* context, const LayerPainting } } - if (layer()->isTransparent()) { + if (isTransparent()) { context->save(); LayoutRect clipRect = intersection(paintingInfo.paintDirtyRect, transparencyClipBox(layer(), localPaintingInfo.rootLayer, localPaintingInfo.subPixelAccumulation)); @@ -873,7 +884,7 @@ void RenderBox::paintLayerContents(GraphicsContext* context, const LayerPainting layer()->restoreClip(context, localPaintingInfo.paintDirtyRect, contentRect); - if (layer()->isTransparent()) { + if (isTransparent()) { context->endLayer(); context->restore(); } diff --git a/engine/core/rendering/RenderBox.h b/engine/core/rendering/RenderBox.h index 7f9191888bae7896d70d34e4d15aa686937e725e..8ce3293f3c60e8b935d726e1231c7465f457b090 100644 --- a/engine/core/rendering/RenderBox.h +++ b/engine/core/rendering/RenderBox.h @@ -172,6 +172,8 @@ public: // The content box converted to absolute coords (taking transforms into account). FloatQuad absoluteContentQuad() const; + FloatPoint perspectiveOrigin() const; + // This returns the content area of the box (excluding padding and border). The only difference with contentBoxRect is that computedCSSContentBoxRect // does include the intrinsic padding in the content box as this is what some callers expect (like getComputedStyle). LayoutRect computedCSSContentBoxRect() const { return LayoutRect(borderLeft() + computedCSSPaddingLeft(), borderTop() + computedCSSPaddingTop(), clientWidth() - computedCSSPaddingLeft() - computedCSSPaddingRight(), clientHeight() - computedCSSPaddingTop() - computedCSSPaddingBottom()); } diff --git a/engine/core/rendering/RenderLayer.cpp b/engine/core/rendering/RenderLayer.cpp index 041407529dd008d2eec2607e5e91ce57edc292d2..644a5af3fa51acee0e608edbb767291876ab1e16 100644 --- a/engine/core/rendering/RenderLayer.cpp +++ b/engine/core/rendering/RenderLayer.cpp @@ -92,8 +92,7 @@ RenderLayer::RenderLayer(RenderBox* renderer, LayerType type) , m_last(0) , m_clipper(*renderer) { - updateStackingNode(); - + m_stackingNode = adoptPtr(new RenderLayerStackingNode(this)); m_isSelfPaintingLayer = shouldBeSelfPaintingLayer(); } @@ -102,33 +101,15 @@ RenderLayer::~RenderLayer() removeFilterInfoIfNeeded(); } -String RenderLayer::debugName() const -{ - return renderer()->debugName(); -} - -LayoutSize RenderLayer::subpixelAccumulation() const -{ - return m_subpixelAccumulation; -} - -void RenderLayer::setSubpixelAccumulation(const LayoutSize& size) -{ - m_subpixelAccumulation = size; -} - void RenderLayer::updateLayerPositionsAfterLayout() { - TRACE_EVENT0("blink", "RenderLayer::updateLayerPositionsAfterLayout"); - m_clipper.clearClipRectsIncludingDescendants(); } void RenderLayer::updateTransformationMatrix() { if (m_transform) { - RenderBox* box = renderBox(); - ASSERT(box); + RenderBox* box = renderer(); m_transform->makeIdentity(); box->style()->applyTransform(*m_transform, box->pixelSnappedBorderBoxRect().size(), RenderStyle::IncludeTransformOrigin); // FIXME(sky): We shouldn't need to do this once Skia has 4x4 matrix support. @@ -166,38 +147,6 @@ void RenderLayer::updateTransform(const RenderStyle* oldStyle, RenderStyle* newS dirty3DTransformedDescendantStatus(); } -static RenderLayer* enclosingLayerForContainingBlock(RenderLayer* layer) -{ - if (RenderObject* containingBlock = layer->renderer()->containingBlock()) - return containingBlock->enclosingLayer(); - return 0; -} - -RenderLayer* RenderLayer::renderingContextRoot() -{ - RenderLayer* renderingContext = 0; - - if (shouldPreserve3D()) - renderingContext = this; - - for (RenderLayer* current = enclosingLayerForContainingBlock(this); current && current->shouldPreserve3D(); current = enclosingLayerForContainingBlock(current)) - renderingContext = current; - - return renderingContext; -} - -RenderLayer* RenderLayer::enclosingOverflowClipLayer(IncludeSelfOrNot includeSelf) const -{ - const RenderLayer* layer = (includeSelf == IncludeSelf) ? this : parent(); - while (layer) { - if (layer->renderer()->hasOverflowClip()) - return const_cast(layer); - - layer = layer->parent(); - } - return 0; -} - void RenderLayer::dirty3DTransformedDescendantStatus() { RenderLayerStackingNode* stackingNode = m_stackingNode->ancestorStackingContextNode(); @@ -241,14 +190,9 @@ bool RenderLayer::update3DTransformedDescendantStatus() IntSize RenderLayer::size() const { - if (renderer()->isInline() && renderer()->isRenderInline()) - return toRenderInline(renderer())->linesBoundingBox().size(); - // FIXME: Is snapping the size really needed here? - if (RenderBox* box = renderBox()) - return pixelSnappedIntSize(box->size(), box->location()); - - return IntSize(); + RenderBox* box = renderer(); + return pixelSnappedIntSize(box->size(), box->location()); } LayoutPoint RenderLayer::location() const @@ -261,8 +205,8 @@ LayoutPoint RenderLayer::location() const IntRect lineBox = inlineFlow->linesBoundingBox(); inlineBoundingBoxOffset = toSize(lineBox.location()); localPoint += inlineBoundingBoxOffset; - } else if (RenderBox* box = renderBox()) { - localPoint += box->locationOffset(); + } else { + localPoint += renderer()->locationOffset(); } if (!renderer()->isOutOfFlowPositioned() && renderer()->parent()) { @@ -285,47 +229,6 @@ LayoutPoint RenderLayer::location() const return localPoint; } -TransformationMatrix RenderLayer::perspectiveTransform() const -{ - if (!renderer()->hasTransform()) - return TransformationMatrix(); - - RenderStyle* style = renderer()->style(); - if (!style->hasPerspective()) - return TransformationMatrix(); - - // Maybe fetch the perspective from the backing? - const IntRect borderBox = renderer()->pixelSnappedBorderBoxRect(); - const float boxWidth = borderBox.width(); - const float boxHeight = borderBox.height(); - - float perspectiveOriginX = floatValueForLength(style->perspectiveOriginX(), boxWidth); - float perspectiveOriginY = floatValueForLength(style->perspectiveOriginY(), boxHeight); - - // A perspective origin of 0,0 makes the vanishing point in the center of the element. - // We want it to be in the top-left, so subtract half the height and width. - perspectiveOriginX -= boxWidth / 2.0f; - perspectiveOriginY -= boxHeight / 2.0f; - - TransformationMatrix t; - t.translate(perspectiveOriginX, perspectiveOriginY); - t.applyPerspective(style->perspective()); - t.translate(-perspectiveOriginX, -perspectiveOriginY); - - return t; -} - -FloatPoint RenderLayer::perspectiveOrigin() const -{ - if (!renderer()->hasTransform()) - return FloatPoint(); - - const LayoutRect borderBox = renderer()->borderBoxRect(); - RenderStyle* style = renderer()->style(); - - return FloatPoint(floatValueForLength(style->perspectiveOriginX(), borderBox.width().toFloat()), floatValueForLength(style->perspectiveOriginY(), borderBox.height().toFloat())); -} - RenderLayer* RenderLayer::enclosingPositionedAncestor() const { RenderLayer* curr = parent(); @@ -527,14 +430,6 @@ void RenderLayer::convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutR rect.move(-delta.x(), -delta.y()); } -void RenderLayer::updateStackingNode() -{ - if (requiresStackingNode()) - m_stackingNode = adoptPtr(new RenderLayerStackingNode(this)); - else - m_stackingNode = nullptr; -} - static bool inContainingBlockChain(RenderLayer* startLayer, RenderLayer* endLayer) { if (startLayer == endLayer) @@ -617,8 +512,7 @@ LayoutRect RenderLayer::logicalBoundingBox() const if (renderer()->isInline() && renderer()->isRenderInline()) { result = toRenderInline(renderer())->linesVisualOverflowBoundingBox(); } else { - RenderBox* box = renderBox(); - ASSERT(box); + RenderBox* box = renderer(); result = box->borderBoxRect(); result.unite(box->visualOverflowRect()); } @@ -716,22 +610,12 @@ bool RenderLayer::shouldBeSelfPaintingLayer() const return m_layerType == NormalLayer; } -bool RenderLayer::hasBoxDecorationsOrBackground() const -{ - return renderer()->style()->hasBoxDecorations() || renderer()->style()->hasBackground(); -} - -bool RenderLayer::hasVisibleBoxDecorations() const -{ - return hasBoxDecorationsOrBackground(); -} - void RenderLayer::updateFilters(const RenderStyle* oldStyle, const RenderStyle* newStyle) { if (!newStyle->hasFilter() && (!oldStyle || !oldStyle->hasFilter())) return; - if (!hasFilter()) { + if (!renderer()->hasFilter()) { removeFilterInfoIfNeeded(); return; } diff --git a/engine/core/rendering/RenderLayer.h b/engine/core/rendering/RenderLayer.h index 3916819a759c4c4d883db2aabcd16060df42dc3d..8c8815accb50b5af5eb5c9fb4a0cca7e220bd702 100644 --- a/engine/core/rendering/RenderLayer.h +++ b/engine/core/rendering/RenderLayer.h @@ -73,11 +73,7 @@ public: RenderLayer(RenderBox*, LayerType); ~RenderLayer(); - String debugName() const; - RenderBox* renderer() const { return m_renderer; } - // FIXME(sky): Remove - RenderBox* renderBox() const { return m_renderer; } RenderLayer* parent() const { return m_parent; } RenderLayer* previousSibling() const { return m_previous; } RenderLayer* nextSibling() const { return m_next; } @@ -91,14 +87,9 @@ public: void insertOnlyThisLayer(); void styleChanged(StyleDifference, const RenderStyle* oldStyle); - - // FIXME: Many people call this function while it has out-of-date information. bool isSelfPaintingLayer() const { return m_isSelfPaintingLayer; } - void setLayerType(LayerType layerType) { m_layerType = layerType; } - bool isTransparent() const { return renderer()->isTransparent(); } - const RenderLayer* root() const { const RenderLayer* curr = this; @@ -109,30 +100,20 @@ public: LayoutPoint location() const; IntSize size() const; - LayoutRect rect() const { return LayoutRect(location(), size()); } bool isRootLayer() const { return m_isRootLayer; } void updateLayerPositionsAfterLayout(); - void updateTransformationMatrix(); - RenderLayer* renderingContextRoot(); RenderLayerStackingNode* stackingNode() { return m_stackingNode.get(); } const RenderLayerStackingNode* stackingNode() const { return m_stackingNode.get(); } - bool hasBoxDecorationsOrBackground() const; - bool hasVisibleBoxDecorations() const; - // True if this layer container renderers that paint. - bool hasNonEmptyChildRenderers() const; - // Gets the nearest enclosing positioned ancestor layer (also includes // the layer and the root layer). RenderLayer* enclosingPositionedAncestor() const; - RenderLayer* enclosingOverflowClipLayer(IncludeSelfOrNot = IncludeSelf) const; - const RenderLayer* compositingContainer() const; void convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutPoint&) const; @@ -144,25 +125,11 @@ public: // Bounding box relative to some ancestor layer. Pass offsetFromRoot if known. LayoutRect physicalBoundingBox(const RenderLayer* ancestorLayer, const LayoutPoint* offsetFromRoot = 0) const; LayoutRect physicalBoundingBoxIncludingReflectionAndStackingChildren(const RenderLayer* ancestorLayer, const LayoutPoint& offsetFromRoot) const; - - // If true, this layer's children are included in its bounds for overlap testing. - // We can't rely on the children's positions if this layer has a filter that could have moved the children's pixels around. - bool overlapBoundsIncludeChildren() const { return hasFilter() && renderer()->style()->filter().hasFilterThatMovesPixels(); } - LayoutRect boundingBoxForCompositing(const RenderLayer* ancestorLayer = 0) const; - LayoutSize subpixelAccumulation() const; - void setSubpixelAccumulation(const LayoutSize&); - - bool hasTransform() const { return renderer()->hasTransform(); } // This transform has the transform-origin baked in. TransformationMatrix* transform() const { return m_transform.get(); } - // Get the perspective transform, which is applied to transformed sublayers. - // Returns true if the layer has a -webkit-perspective. - // Note that this transform has the perspective-origin baked in. - TransformationMatrix perspectiveTransform() const; - FloatPoint perspectiveOrigin() const; bool preserves3D() const { return renderer()->style()->transformStyle3D() == TransformStyle3DPreserve3D; } bool has3DTransform() const { return m_transform && !m_transform->isAffine(); } @@ -173,8 +140,6 @@ public: // FIXME: reflections should force transform-style to be flat in the style: https://bugs.webkit.org/show_bug.cgi?id=106959 bool shouldPreserve3D() const { return renderer()->style()->transformStyle3D() == TransformStyle3DPreserve3D; } - bool hasFilter() const { return renderer()->hasFilter(); } - void* operator new(size_t); // Only safe to call from RenderBox::destroyLayer() void operator delete(void*); @@ -196,16 +161,13 @@ public: bool hasFilterInfo() const { return m_hasFilterInfo; } void setHasFilterInfo(bool hasFilterInfo) { m_hasFilterInfo = hasFilterInfo; } - void updateFilters(const RenderStyle* oldStyle, const RenderStyle* newStyle); - RenderLayerClipper& clipper() { return m_clipper; } const RenderLayerClipper& clipper() const { return m_clipper; } inline bool isPositionedContainer() const { // FIXME: This is not in sync with containingBlock. - RenderBox* layerRenderer = renderer(); - return isRootLayer() || layerRenderer->isPositioned() || hasTransform(); + return isRootLayer() || renderer()->isPositioned() || renderer()->hasTransform(); } void clipToRect(const LayerPaintingInfo&, GraphicsContext*, const ClipRect&, BorderRadiusClippingRule = IncludeSelfForBorderRadius); @@ -220,14 +182,9 @@ private: void setFirstChild(RenderLayer* first) { m_first = first; } void setLastChild(RenderLayer* last) { m_last = last; } - LayoutPoint renderBoxLocation() const { return renderer()->location(); } - bool shouldBeSelfPaintingLayer() const; - // FIXME: We should only create the stacking node if needed. - bool requiresStackingNode() const { return true; } - void updateStackingNode(); - + void updateFilters(const RenderStyle* oldStyle, const RenderStyle* newStyle); void updateTransform(const RenderStyle* oldStyle, RenderStyle* newStyle); void dirty3DTransformedDescendantStatus(); @@ -260,8 +217,6 @@ private: RenderLayerClipper m_clipper; // FIXME: Lazily allocate? OwnPtr m_stackingNode; - - LayoutSize m_subpixelAccumulation; // The accumulated subpixel offset of a composited layer's composited bounds compared to absolute coordinates. }; } // namespace blink diff --git a/engine/core/rendering/RenderObject.cpp b/engine/core/rendering/RenderObject.cpp index 9a6ca0bbed58076462ee1c171c84c0b303126210..59d41ff06d6471b65d8138fca180b3416c6c6654 100644 --- a/engine/core/rendering/RenderObject.cpp +++ b/engine/core/rendering/RenderObject.cpp @@ -1432,7 +1432,7 @@ void RenderObject::getTransformFromContainer(const RenderObject* containerObject if (containerObject && containerObject->hasLayer() && containerObject->style()->hasPerspective()) { // Perpsective on the container affects us, so we have to factor it in here. ASSERT(containerObject->hasLayer()); - FloatPoint perspectiveOrigin = toRenderBox(containerObject)->layer()->perspectiveOrigin(); + FloatPoint perspectiveOrigin = toRenderBox(containerObject)->perspectiveOrigin(); TransformationMatrix perspectiveMatrix; perspectiveMatrix.applyPerspective(containerObject->style()->perspective()); diff --git a/engine/core/rendering/RenderTreeAsText.cpp b/engine/core/rendering/RenderTreeAsText.cpp index 2546bca0d7db298b4e6c5f48cd2777d96cf2383c..4b12bf75f55c9d35ef548da92a0982ce3e6a7b82 100644 --- a/engine/core/rendering/RenderTreeAsText.cpp +++ b/engine/core/rendering/RenderTreeAsText.cpp @@ -356,8 +356,6 @@ static void write(TextStream& ts, RenderLayer& l, if (!adjustedClipRect.contains(adjustedLayoutBounds)) ts << " clip " << adjustedClipRect; } - if (l.isTransparent()) - ts << " transparent"; ts << "\n"; write(ts, *l.renderer(), indent + 1, behavior); @@ -369,8 +367,8 @@ void RenderTreeAsText::writeLayers(TextStream& ts, const RenderLayer* rootLayer, // FIXME: Apply overflow to the root layer to not break every test. Complete hack. Sigh. LayoutRect paintDirtyRect(paintRect); if (rootLayer == layer) { - paintDirtyRect.setWidth(max(paintDirtyRect.width(), rootLayer->renderBox()->layoutOverflowRect().maxX())); - paintDirtyRect.setHeight(max(paintDirtyRect.height(), rootLayer->renderBox()->layoutOverflowRect().maxY())); + paintDirtyRect.setWidth(max(paintDirtyRect.width(), rootLayer->renderer()->layoutOverflowRect().maxX())); + paintDirtyRect.setHeight(max(paintDirtyRect.height(), rootLayer->renderer()->layoutOverflowRect().maxY())); } // Calculate the clip rects we should use. @@ -380,7 +378,7 @@ void RenderTreeAsText::writeLayers(TextStream& ts, const RenderLayer* rootLayer, // FIXME: Apply overflow to the root layer to not break every test. Complete hack. Sigh. if (rootLayer == layer) - layerBounds.setSize(layer->size().expandedTo(pixelSnappedIntSize(layer->renderBox()->maxLayoutOverflow(), LayoutPoint(0, 0)))); + layerBounds.setSize(layer->size().expandedTo(pixelSnappedIntSize(layer->renderer()->maxLayoutOverflow(), LayoutPoint(0, 0)))); // Ensure our lists are up-to-date. layer->stackingNode()->updateLayerListsIfNeeded();