Title: [170220] trunk/Source/WebCore
Revision
170220
Author
[email protected]
Date
2014-06-20 15:57:42 -0700 (Fri, 20 Jun 2014)

Log Message

Introduce RenderLayer::offsetFromAncestorLayer() to make convertToLayerCoords() calls with
LayoutPoint(0, 0) as parameter more explicit.
https://bugs.webkit.org/show_bug.cgi?id=134092

Reviewed by Simon Fraser.

Most of the RenderLayer::convertToLayerCoords() callers are only interested in
the offset from the ancestor layer by passing LayoutPoint(0, 0) as the coordinate to convert.
Introducing offsetFromAncestorLayer() makes those calls more explicit/self-explanatory.
It helps simplifying the callsite's code.

No change in functionality.

* rendering/RenderGeometryMap.cpp:
(WebCore::RenderGeometryMap::mapToContainer):
(WebCore::RenderGeometryMap::pushMappingsToAncestor):
(WebCore::RenderGeometryMap::push):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::computeOffsetFromRoot):
(WebCore::RenderLayer::updateLayerPositions):
(WebCore::expandClipRectForRegionAndReflection):
(WebCore::expandClipRectForDescendantsAndReflection):
(WebCore::transparencyClipBox):
(WebCore::RenderLayer::convertToPixelSnappedLayerCoords):
(WebCore::accumulateOffsetTowardsAncestor):
(WebCore::RenderLayer::convertToLayerCoords):
(WebCore::RenderLayer::offsetFromAncestorLayer):
(WebCore::RenderLayer::clipToRect):
(WebCore::RenderLayer::paintLayerContents):
(WebCore::RenderLayer::paintLayerByApplyingTransform):
(WebCore::RenderLayer::collectFragments):
(WebCore::RenderLayer::paintTransformedLayerIntoFragments):
(WebCore::RenderLayer::createLocalTransformState):
(WebCore::RenderLayer::hitTestTransformedLayerInFragments):
(WebCore::RenderLayer::calculateClipRects):
* rendering/RenderLayer.h:
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateCompositedBounds):
(WebCore::RenderLayerBacking::updateGeometry):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::repaintInCompositedAncestor):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (170219 => 170220)


--- trunk/Source/WebCore/ChangeLog	2014-06-20 22:46:30 UTC (rev 170219)
+++ trunk/Source/WebCore/ChangeLog	2014-06-20 22:57:42 UTC (rev 170220)
@@ -1,3 +1,47 @@
+2014-06-19  Zalan Bujtas  <[email protected]>
+
+        Introduce RenderLayer::offsetFromAncestorLayer() to make convertToLayerCoords() calls with
+        LayoutPoint(0, 0) as parameter more explicit.
+        https://bugs.webkit.org/show_bug.cgi?id=134092
+
+        Reviewed by Simon Fraser.
+
+        Most of the RenderLayer::convertToLayerCoords() callers are only interested in
+        the offset from the ancestor layer by passing LayoutPoint(0, 0) as the coordinate to convert.
+        Introducing offsetFromAncestorLayer() makes those calls more explicit/self-explanatory.
+        It helps simplifying the callsite's code.
+
+        No change in functionality.
+
+        * rendering/RenderGeometryMap.cpp:
+        (WebCore::RenderGeometryMap::mapToContainer):
+        (WebCore::RenderGeometryMap::pushMappingsToAncestor):
+        (WebCore::RenderGeometryMap::push):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::computeOffsetFromRoot):
+        (WebCore::RenderLayer::updateLayerPositions):
+        (WebCore::expandClipRectForRegionAndReflection):
+        (WebCore::expandClipRectForDescendantsAndReflection):
+        (WebCore::transparencyClipBox):
+        (WebCore::RenderLayer::convertToPixelSnappedLayerCoords):
+        (WebCore::accumulateOffsetTowardsAncestor):
+        (WebCore::RenderLayer::convertToLayerCoords):
+        (WebCore::RenderLayer::offsetFromAncestorLayer):
+        (WebCore::RenderLayer::clipToRect):
+        (WebCore::RenderLayer::paintLayerContents):
+        (WebCore::RenderLayer::paintLayerByApplyingTransform):
+        (WebCore::RenderLayer::collectFragments):
+        (WebCore::RenderLayer::paintTransformedLayerIntoFragments):
+        (WebCore::RenderLayer::createLocalTransformState):
+        (WebCore::RenderLayer::hitTestTransformedLayerInFragments):
+        (WebCore::RenderLayer::calculateClipRects):
+        * rendering/RenderLayer.h:
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::updateCompositedBounds):
+        (WebCore::RenderLayerBacking::updateGeometry):
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::repaintInCompositedAncestor):
+
 2014-06-20  Myles C. Maxfield  <[email protected]>
 
         Removing dead code in platform/graphics/gpu

Modified: trunk/Source/WebCore/rendering/RenderGeometryMap.cpp (170219 => 170220)


--- trunk/Source/WebCore/rendering/RenderGeometryMap.cpp	2014-06-20 22:46:30 UTC (rev 170219)
+++ trunk/Source/WebCore/rendering/RenderGeometryMap.cpp	2014-06-20 22:57:42 UTC (rev 170220)
@@ -116,8 +116,6 @@
 #if !ASSERT_DISABLED
     FloatPoint rendererMappedResult = m_mapping.last().m_renderer->localToAbsolute(p, m_mapCoordinatesFlags);
     ASSERT(roundedIntPoint(rendererMappedResult) == roundedIntPoint(result));
-//    if (roundedIntPoint(rendererMappedResult) != roundedIntPoint(result))
-//        fprintf(stderr, "Mismatched point\n");
 #endif
 
     return result;
@@ -141,8 +139,6 @@
     // Inspector creates renderers with negative width <https://bugs.webkit.org/show_bug.cgi?id=87194>.
     // Taking FloatQuad bounds avoids spurious assertions because of that.
     ASSERT(enclosingIntRect(rendererMappedResult) == enclosingIntRect(FloatQuad(result).boundingBox()));
-//    if (enclosingIntRect(rendererMappedResult) != enclosingIntRect(FloatQuad(result).boundingBox()))
-//        fprintf(stderr, "Mismatched rects\n");
 #endif
 
     return result;
@@ -187,11 +183,8 @@
     // from mapping via layers.
     bool canConvertInLayerTree = ancestorLayer ? canMapBetweenRenderers(layer->renderer(), ancestorLayer->renderer()) : false;
 
-//    fprintf(stderr, "RenderGeometryMap::pushMappingsToAncestor from layer %p to layer %p, canConvertInLayerTree=%d\n", layer, ancestorLayer, canConvertInLayerTree);
-
     if (canConvertInLayerTree) {
-        LayoutPoint layerOffset;
-        layer->convertToLayerCoords(ancestorLayer, layerOffset);
+        LayoutSize layerOffset = layer->offsetFromAncestor(ancestorLayer);
         
         // The RenderView must be pushed first.
         if (!m_mapping.size()) {
@@ -200,7 +193,7 @@
         }
 
         TemporaryChange<size_t> positionChange(m_insertionPosition, m_mapping.size());
-        push(&renderer, toLayoutSize(layerOffset), /*accumulatingTransform*/ true, /*isNonUniform*/ false, /*isFixedPosition*/ false, /*hasTransform*/ false);
+        push(&renderer, layerOffset, /*accumulatingTransform*/ true, /*isNonUniform*/ false, /*isFixedPosition*/ false, /*hasTransform*/ false);
         return;
     }
     const RenderLayerModelObject* ancestorRenderer = ancestorLayer ? &ancestorLayer->renderer() : 0;
@@ -209,8 +202,6 @@
 
 void RenderGeometryMap::push(const RenderObject* renderer, const LayoutSize& offsetFromContainer, bool accumulatingTransform, bool isNonUniform, bool isFixedPosition, bool hasTransform)
 {
-//    fprintf(stderr, "RenderGeometryMap::push %p %d,%d isNonUniform=%d\n", renderer, offsetFromContainer.width().toInt(), offsetFromContainer.height().toInt(), isNonUniform);
-
     ASSERT(m_insertionPosition != notFound);
 
     m_mapping.insert(m_insertionPosition, RenderGeometryMapStep(renderer, accumulatingTransform, isNonUniform, isFixedPosition, hasTransform));

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (170219 => 170220)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2014-06-20 22:46:30 UTC (rev 170219)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2014-06-20 22:57:42 UTC (rev 170220)
@@ -367,15 +367,15 @@
     clearClipRects();
     
     if (hasOverflowControls()) {
-        LayoutPoint offsetFromRoot;
+        LayoutSize offsetFromRoot;
         if (geometryMap)
-            offsetFromRoot = LayoutPoint(geometryMap->absolutePoint(FloatPoint()));
+            offsetFromRoot = LayoutSize(toFloatSize(geometryMap->absolutePoint(FloatPoint())));
         else {
             // FIXME: It looks suspicious to call convertToLayerCoords here
             // as canUseConvertToLayerCoords may be true for an ancestor layer.
-            convertToLayerCoords(root(), offsetFromRoot);
+            offsetFromRoot = offsetFromAncestor(root());
         }
-        positionOverflowControls(toIntSize(roundedIntPoint(offsetFromRoot)));
+        positionOverflowControls(roundedIntSize(offsetFromRoot));
     }
 
     updateDescendantDependentFlags();
@@ -1560,11 +1560,7 @@
         RenderLayer* flowThreadLayer = region->flowThread()->layer();
         if (!layer->reflection() || layer->reflectionLayer() != flowThreadLayer) {
             LayoutRect flowThreadClipRect = transparencyClipBox(flowThreadLayer, rootLayer, transparencyBehavior, DescendantsOfTransparencyClipBox, paintBehavior);
-            
-            LayoutPoint offsetFromRoot;
-            layer->convertToLayerCoords(flowThreadLayer, offsetFromRoot);
-
-            LayoutSize moveOffset = (offsetFromRoot + regionContainer->contentBoxRect().location()) - region->flowThreadPortionRect().location();
+            LayoutSize moveOffset = (regionContainer->contentBoxRect().location() + layer->offsetFromAncestor(flowThreadLayer)) - region->flowThreadPortionRect().location();
             flowThreadClipRect.move(moveOffset);
             
             clipRect.unite(flowThreadClipRect);
@@ -1593,11 +1589,10 @@
     // FIXME: Accelerated compositing will eventually want to do something smart here to avoid incorporating this
     // size into the parent layer.
     if (layer->renderer().hasReflection()) {
-        LayoutPoint delta;
-        layer->convertToLayerCoords(rootLayer, delta);
-        clipRect.move(-delta.x(), -delta.y());
+        LayoutSize delta = layer->offsetFromAncestor(rootLayer);
+        clipRect.move(-delta.width(), -delta.height());
         clipRect.unite(layer->renderBox()->reflectedRect(clipRect));
-        clipRect.moveBy(delta);
+        clipRect.move(delta);
     }
 }
 
@@ -1615,11 +1610,10 @@
         RenderLayer::PaginationInclusionMode mode = transparencyBehavior == HitTestingTransparencyClipBox ? RenderLayer::IncludeCompositedPaginatedLayers : RenderLayer::ExcludeCompositedPaginatedLayers;
         const RenderLayer* paginationLayer = transparencyMode == DescendantsOfTransparencyClipBox ? layer->enclosingPaginationLayer(mode) : 0;
         const RenderLayer* rootLayerForTransform = paginationLayer ? paginationLayer : rootLayer;
-        LayoutPoint delta;
-        layer->convertToLayerCoords(rootLayerForTransform, delta);
+        LayoutSize delta = layer->offsetFromAncestor(rootLayerForTransform);
 
         TransformationMatrix transform;
-        transform.translate(delta.x(), delta.y());
+        transform.translate(delta.width(), delta.height());
         transform = transform * *layer->transform();
 
         // We don't use fragment boxes when collecting a transformed layer's bounding box, since it always
@@ -1638,10 +1632,7 @@
         // get our true bounding box.
         RenderFlowThread& enclosingFlowThread = toRenderFlowThread(paginationLayer->renderer());
         result = enclosingFlowThread.fragmentsBoundingBox(result);
-        
-        LayoutPoint rootLayerDelta;
-        paginationLayer->convertToLayerCoords(rootLayer, rootLayerDelta);
-        result.moveBy(rootLayerDelta);
+        result.move(paginationLayer->offsetFromAncestor(rootLayer));
         return result;
     }
     
@@ -1854,15 +1845,13 @@
 
 void RenderLayer::convertToPixelSnappedLayerCoords(const RenderLayer* ancestorLayer, IntPoint& roundedLocation, ColumnOffsetAdjustment adjustForColumns) const
 {
-    LayoutPoint location = roundedLocation;
-    convertToLayerCoords(ancestorLayer, location, adjustForColumns);
+    LayoutPoint location = convertToLayerCoords(ancestorLayer, roundedLocation, adjustForColumns);
     roundedLocation = roundedIntPoint(location);
 }
 
 void RenderLayer::convertToPixelSnappedLayerCoords(const RenderLayer* ancestorLayer, IntRect& roundedRect, ColumnOffsetAdjustment adjustForColumns) const
 {
-    LayoutRect rect = roundedRect;
-    convertToLayerCoords(ancestorLayer, rect, adjustForColumns);
+    LayoutRect rect = convertToLayerCoords(ancestorLayer, roundedRect, adjustForColumns);
     roundedRect = pixelSnappedIntRect(rect);
 }
 
@@ -1897,7 +1886,7 @@
     // element in render flow thread, we will hit the fixed positioned container before hitting the ancestor layer.
     if (position == FixedPosition && !fixedFlowThreadContainer) {
         // For a fixed layers, we need to walk up to the root to see if there's a fixed position container
-        // (e.g. a transformed layer). It's an error to call convertToLayerCoords() across a layer with a transform,
+        // (e.g. a transformed layer). It's an error to call offsetFromAncestor() across a layer with a transform,
         // so we should always find the ancestor at or before we find the fixed position container.
         RenderLayer* fixedPositionContainerLayer = 0;
         bool foundAncestor = false;
@@ -1915,12 +1904,8 @@
         ASSERT(fixedPositionContainerLayer); // We should have hit the RenderView's layer at least.
 
         if (fixedPositionContainerLayer != ancestorLayer) {
-            LayoutPoint fixedContainerCoords;
-            layer->convertToLayerCoords(fixedPositionContainerLayer, fixedContainerCoords);
-
-            LayoutPoint ancestorCoords;
-            ancestorLayer->convertToLayerCoords(fixedPositionContainerLayer, ancestorCoords);
-
+            LayoutSize fixedContainerCoords = layer->offsetFromAncestor(fixedPositionContainerLayer);
+            LayoutSize ancestorCoords = ancestorLayer->offsetFromAncestor(fixedPositionContainerLayer);
             location += (fixedContainerCoords - ancestorCoords);
             return ancestorLayer;
         }
@@ -1973,13 +1958,8 @@
             // Found ancestorLayer before the abs. positioned container, so compute offset of both relative
             // to enclosingPositionedAncestor and subtract.
             RenderLayer* positionedAncestor = parentLayer->enclosingPositionedAncestor();
-
-            LayoutPoint thisCoords;
-            layer->convertToLayerCoords(positionedAncestor, thisCoords);
-            
-            LayoutPoint ancestorCoords;
-            ancestorLayer->convertToLayerCoords(positionedAncestor, ancestorCoords);
-
+            LayoutSize thisCoords = layer->offsetFromAncestor(positionedAncestor);
+            LayoutSize ancestorCoords = ancestorLayer->offsetFromAncestor(positionedAncestor);
             location += (thisCoords - ancestorCoords);
             return ancestorLayer;
         }
@@ -2004,23 +1984,31 @@
     return parentLayer;
 }
 
-void RenderLayer::convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutPoint& location, ColumnOffsetAdjustment adjustForColumns) const
+LayoutPoint RenderLayer::convertToLayerCoords(const RenderLayer* ancestorLayer, const LayoutPoint& location, ColumnOffsetAdjustment adjustForColumns) const
 {
     if (ancestorLayer == this)
-        return;
+        return location;
 
     const RenderLayer* currLayer = this;
+    LayoutPoint locationInLayerCoords = location;
     while (currLayer && currLayer != ancestorLayer)
-        currLayer = accumulateOffsetTowardsAncestor(currLayer, ancestorLayer, location, adjustForColumns);
+        currLayer = accumulateOffsetTowardsAncestor(currLayer, ancestorLayer, locationInLayerCoords, adjustForColumns);
+    return locationInLayerCoords;
 }
 
-void RenderLayer::convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutRect& rect, ColumnOffsetAdjustment adjustForColumns) const
+LayoutRect RenderLayer::convertToLayerCoords(const RenderLayer* ancestorLayer, const LayoutRect& rect, ColumnOffsetAdjustment adjustForColumns) const
 {
-    LayoutPoint delta;
-    convertToLayerCoords(ancestorLayer, delta, adjustForColumns);
-    rect.move(-delta.x(), -delta.y());
+    LayoutPoint delta = convertToLayerCoords(ancestorLayer, LayoutPoint(), adjustForColumns);
+    LayoutRect rectInLayerCoords = rect;
+    rectInLayerCoords.move(-delta.x(), -delta.y());
+    return rectInLayerCoords;
 }
 
+LayoutSize RenderLayer::offsetFromAncestor(const RenderLayer* ancestorLayer) const
+{
+    return toLayoutSize(convertToLayerCoords(ancestorLayer, LayoutPoint()));
+}
+
 #if PLATFORM(IOS)
 bool RenderLayer::hasAcceleratedTouchScrolling() const
 {
@@ -3571,9 +3559,7 @@
     // containing block chain so we check that also.
     for (RenderLayer* layer = rule == IncludeSelfForBorderRadius ? this : parent(); layer; layer = layer->parent()) {
         if (layer->renderer().hasOverflowClip() && layer->renderer().style().hasBorderRadius() && inContainingBlockChain(this, layer)) {
-                LayoutPoint delta;
-                layer->convertToLayerCoords(rootLayer, delta);
-                context->clipRoundedRect(layer->renderer().style().getRoundedInnerBorderFor(LayoutRect(delta, layer->size())).pixelSnappedRoundedRectForPainting(deviceScaleFactor));
+            context->clipRoundedRect(layer->renderer().style().getRoundedInnerBorderFor(LayoutRect(toLayoutPoint(layer->offsetFromAncestor(rootLayer)), layer->size())).pixelSnappedRoundedRectForPainting(deviceScaleFactor));
         }
 
         if (layer == rootLayer)
@@ -3977,9 +3963,7 @@
         && renderer().fixedPositionedWithNamedFlowContainingBlock())
         return;
 
-    LayoutPoint offsetFromRoot;
-    convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot);
-
+    LayoutPoint offsetFromRoot = toLayoutPoint(offsetFromAncestor(paintingInfo.rootLayer));
     LayoutRect rootRelativeBounds;
     bool rootRelativeBoundsComputed = false;
 
@@ -4115,8 +4099,7 @@
     // This involves subtracting out the position of the layer in our current coordinate space, but preserving
     // the accumulated error for sub-pixel layout.
     float deviceScaleFactor = renderer().document().deviceScaleFactor();
-    LayoutPoint offsetFromParent;
-    convertToLayerCoords(paintingInfo.rootLayer, offsetFromParent);
+    LayoutPoint offsetFromParent = toLayoutPoint(offsetFromAncestor(paintingInfo.rootLayer));
     offsetFromParent.moveBy(translationOffset);
     TransformationMatrix transform(renderableTransform(paintingInfo.paintBehavior));
     FloatPoint devicePixelSnappedOffsetFromParent = roundedForPainting(offsetFromParent, deviceScaleFactor);
@@ -4196,8 +4179,7 @@
     }
     
     // Compute our offset within the enclosing pagination layer.
-    LayoutPoint offsetWithinPaginatedLayer;
-    convertToLayerCoords(paginationLayer, offsetWithinPaginatedLayer);
+    LayoutPoint offsetWithinPaginatedLayer = toLayoutPoint(offsetFromAncestor(paginationLayer));
     
     // Calculate clip rects relative to the enclosingPaginationLayer. The purpose of this call is to determine our bounds clipped to intermediate
     // layers between us and the pagination context. It's important to minimize the number of fragments we need to create and this helps with that.
@@ -4221,9 +4203,8 @@
         LayoutRect layerFragmentBoundingBoxInParentPaginationLayer = enclosingFlowThread.fragmentsBoundingBox(layerBoundingBoxInFlowThread);
         
         // Convert to be in the ancestor pagination context's coordinate space.
-        LayoutPoint offsetWithinParentPaginatedLayer;
-        paginationLayer->convertToLayerCoords(parentPaginationLayer, offsetWithinParentPaginatedLayer);
-        layerFragmentBoundingBoxInParentPaginationLayer.moveBy(offsetWithinParentPaginatedLayer);
+        LayoutSize offsetWithinParentPaginatedLayer = paginationLayer->offsetFromAncestor(parentPaginationLayer);
+        layerFragmentBoundingBoxInParentPaginationLayer.move(offsetWithinParentPaginatedLayer);
         
         // Now collect ancestor fragments.
         parentPaginationLayer->collectFragments(ancestorFragments, rootLayer, dirtyRect, inclusionMode, clipRectsType, inOverlayScrollbarSizeRelevancy, respectOverflowClip, nullptr, &layerFragmentBoundingBoxInParentPaginationLayer, ApplyRootOffsetToFragments);
@@ -4234,7 +4215,7 @@
         for (auto& ancestorFragment : ancestorFragments) {
             // Shift the dirty rect into flow thread coordinates.
             LayoutRect dirtyRectInFlowThread(dirtyRect);
-            dirtyRectInFlowThread.moveBy(-offsetWithinParentPaginatedLayer + -ancestorFragment.paginationOffset);
+            dirtyRectInFlowThread.move(toLayoutPoint(-offsetWithinParentPaginatedLayer) - ancestorFragment.paginationOffset);
             
             size_t oldSize = fragments.size();
             
@@ -4273,10 +4254,9 @@
     }
     
     // Shift the dirty rect into flow thread coordinates.
-    LayoutPoint offsetOfPaginationLayerFromRoot;
-    enclosingPaginationLayer(inclusionMode)->convertToLayerCoords(rootLayer, offsetOfPaginationLayerFromRoot);
+    LayoutSize offsetOfPaginationLayerFromRoot = enclosingPaginationLayer(inclusionMode)->offsetFromAncestor(rootLayer);
     LayoutRect dirtyRectInFlowThread(dirtyRect);
-    dirtyRectInFlowThread.moveBy(-offsetOfPaginationLayerFromRoot);
+    dirtyRectInFlowThread.move(-offsetOfPaginationLayerFromRoot);
 
     // Tell the flow thread to collect the fragments. We pass enough information to create a minimal number of fragments based off the pages/columns
     // that intersect the actual dirtyRect as well as the pages/columns that intersect our layer's bounding box.
@@ -4348,7 +4328,7 @@
         
         // Now compute the clips within a given fragment
         if (parent() != paginatedLayer) {
-            paginatedLayer->convertToLayerCoords(paintingInfo.rootLayer, offsetOfPaginationLayerFromRoot);
+            offsetOfPaginationLayerFromRoot = paginatedLayer->convertToLayerCoords(paintingInfo.rootLayer, offsetOfPaginationLayerFromRoot);
     
             ClipRectsContext clipRectsContext(paginatedLayer, (paintFlags & PaintLayerTemporaryClipRects) ? TemporaryClipRects : PaintingClipRects,
                 IgnoreOverlayScrollbarSize, (paintFlags & PaintLayerPaintingOverflowContents) ? IgnoreOverflowClip : RespectOverflowClip);
@@ -4600,26 +4580,26 @@
                                         const LayoutPoint& translationOffset) const
 {
     RefPtr<HitTestingTransformState> transformState;
-    LayoutPoint offset;
+    LayoutSize offset;
     if (containerTransformState) {
         // If we're already computing transform state, then it's relative to the container (which we know is non-null).
         transformState = HitTestingTransformState::create(*containerTransformState);
-        convertToLayerCoords(containerLayer, offset);
+        offset = offsetFromAncestor(containerLayer);
     } else {
         // If this is the first time we need to make transform state, then base it off of hitTestLocation,
         // which is relative to rootLayer.
         transformState = HitTestingTransformState::create(hitTestLocation.transformedPoint(), hitTestLocation.transformedRect(), FloatQuad(hitTestRect));
-        convertToLayerCoords(rootLayer, offset);
+        offset = offsetFromAncestor(rootLayer);
     }
-    offset.moveBy(translationOffset);
+    offset += toLayoutSize(translationOffset);
 
     RenderObject* containerRenderer = containerLayer ? &containerLayer->renderer() : 0;
     if (renderer().shouldUseTransformFromContainer(containerRenderer)) {
         TransformationMatrix containerTransform;
-        renderer().getTransformFromContainer(containerRenderer, toLayoutSize(offset), containerTransform);
+        renderer().getTransformFromContainer(containerRenderer, offset, containerTransform);
         transformState->applyTransform(containerTransform, HitTestingTransformState::AccumulateTransform);
     } else {
-        transformState->translate(offset.x(), offset.y(), HitTestingTransformState::AccumulateTransform);
+        transformState->translate(offset.width(), offset.height(), HitTestingTransformState::AccumulateTransform);
     }
     
     return transformState;
@@ -4947,7 +4927,7 @@
         
         // Now compute the clips within a given fragment
         if (parent() != paginatedLayer) {
-            paginatedLayer->convertToLayerCoords(rootLayer, offsetOfPaginationLayerFromRoot);
+            offsetOfPaginationLayerFromRoot = paginatedLayer->convertToLayerCoords(rootLayer, offsetOfPaginationLayerFromRoot);
     
             ClipRectsContext clipRectsContext(paginatedLayer, RootRelativeClipRects, IncludeOverlayScrollbarSize);
             LayoutRect parentClipRect = backgroundClipRect(clipRectsContext).rect();
@@ -5283,7 +5263,7 @@
     if (offsetFromRoot)
         offset = *offsetFromRoot;
     else
-        convertToLayerCoords(clipRectsContext.rootLayer, offset);
+        offset = toLayoutPoint(offsetFromAncestor(clipRectsContext.rootLayer));
 
     RenderNamedFlowFragment* namedFlowFragment = currentRenderNamedFlowFragment();
     // If the view is scrolled, the flow thread is not scrolled with it and we should
@@ -5414,10 +5394,8 @@
     // FIXME: border-radius not accounted for.
     // FIXME: Regions not accounted for.
     RenderLayer* clippingRootLayer = clippingRootForPainting();
+    LayoutPoint offsetFromRoot = toLayoutPoint(offsetFromAncestor(clippingRootLayer));
 
-    LayoutPoint offsetFromRoot;
-    convertToLayerCoords(clippingRootLayer, offsetFromRoot);
-
     LayoutRect layerBounds;
     ClipRect backgroundRect, foregroundRect, outlineRect;
     ClipRectsContext clipRectsContext(clippingRootLayer, PaintingClipRects);
@@ -5433,10 +5411,7 @@
         clipExceedsBounds = !clipRect.contains(cssClipRect);
     }
 
-    LayoutPoint clippingRootOffset;
-    convertToLayerCoords(clippingRootLayer, clippingRootOffset);
-    clipRect.moveBy(-clippingRootOffset);
-
+    clipRect.move(-offsetFromAncestor(clippingRootLayer));
     return clipRect;
 }
 
@@ -5572,9 +5547,7 @@
     while (paginationLayer) {
         // Split our box up into the actual fragment boxes that render in the columns/pages and unite those together to
         // get our true bounding box.
-        LayoutPoint offsetWithinPaginationLayer;
-        childLayer->convertToLayerCoords(paginationLayer, offsetWithinPaginationLayer);
-        result.moveBy(offsetWithinPaginationLayer);
+        result.move(childLayer->offsetFromAncestor(paginationLayer));
 
         RenderFlowThread& enclosingFlowThread = toRenderFlowThread(paginationLayer->renderer());
         result = enclosingFlowThread.fragmentsBoundingBox(result);
@@ -5584,19 +5557,17 @@
     }
 
     if (isPaginated) {
-        LayoutPoint delta;
-        childLayer->convertToLayerCoords(ancestorLayer, delta);
-        result.moveBy(delta);
+        result.move(childLayer->offsetFromAncestor(ancestorLayer));
         return result;
     }
     
-    LayoutPoint delta;
+    LayoutSize delta;
     if (offsetFromRoot)
-        delta = *offsetFromRoot;
+        delta = toLayoutSize(*offsetFromRoot);
     else
-        convertToLayerCoords(ancestorLayer, delta);
+        delta = offsetFromAncestor(ancestorLayer);
     
-    result.moveBy(delta);
+    result.move(delta);
     return result;
 }
 
@@ -5649,9 +5620,7 @@
             if ((flags & IncludeSelfTransform) && paintsWithTransform(PaintBehaviorNormal))
                 localClipRect = transform()->mapRect(localClipRect);
 
-            LayoutPoint ancestorRelOffset;
-            convertToLayerCoords(ancestorLayer, ancestorRelOffset);
-            localClipRect.moveBy(ancestorRelOffset);
+            localClipRect.move(offsetFromAncestor(ancestorLayer));
             return localClipRect;
         }
     }
@@ -5725,12 +5694,12 @@
         unionBounds = affineTrans->mapRect(unionBounds);
     }
 
-    LayoutPoint ancestorRelOffset;
+    LayoutSize ancestorRelOffset;
     if (offsetFromRoot)
-        ancestorRelOffset = *offsetFromRoot;
+        ancestorRelOffset = toLayoutSize(*offsetFromRoot);
     else
-        convertToLayerCoords(ancestorLayer, ancestorRelOffset);
-    unionBounds.moveBy(ancestorRelOffset);
+        ancestorRelOffset = offsetFromAncestor(ancestorLayer);
+    unionBounds.move(ancestorRelOffset);
     
     return unionBounds;
 }
@@ -5873,10 +5842,8 @@
         if (!childLayer->canUseConvertToLayerCoords())
             continue;
 
-        LayoutPoint childOffset;
         LayoutRect childLocalRect(localRect);
-        childLayer->convertToLayerCoords(this, childOffset);
-        childLocalRect.moveBy(-childOffset);
+        childLocalRect.move(-childLayer->offsetFromAncestor(this));
 
         if (childLayer->backgroundIsKnownToBeOpaqueInRect(childLocalRect))
             return true;
@@ -6122,9 +6089,7 @@
         // If we're trying to repaint the placeholder document layer, propagate the
         // repaint to the native view system.
         LayoutRect absRect(r);
-        LayoutPoint delta;
-        convertToLayerCoords(root(), delta);
-        absRect.moveBy(delta);
+        absRect.move(offsetFromAncestor(root()));
 
         renderer().view().repaintViewRectangle(absRect);
     } else
@@ -6711,11 +6676,8 @@
         // GraphicsLayer coordinates in which the fragment gets painted. So what is computed so far is enough.
         // If the layer of the flowFragment is not composited, then we change the coordinates to be relative to the flow
         // thread's layer.
-        if (!isComposited()) {
-            LayoutPoint regionOffsetFromRoot;
-            convertToLayerCoords(paintingInfo.rootLayer, regionOffsetFromRoot);
-            regionClipRect.moveBy(regionOffsetFromRoot);
-        }
+        if (!isComposited())
+            regionClipRect.move(offsetFromAncestor(paintingInfo.rootLayer));
     }
     
     for (size_t i = 0; i < fragments.size(); ++i) {
@@ -6737,7 +6699,7 @@
     }
 }
 
-RenderLayer* RenderLayer::hitTestFlowThreadIfRegionForFragments(const LayerFragments& fragments, RenderLayer* rootLayer, const HitTestRequest& request, HitTestResult& result, const LayoutRect& hitTestRect, 
+RenderLayer* RenderLayer::hitTestFlowThreadIfRegionForFragments(const LayerFragments& fragments, RenderLayer*, const HitTestRequest& request, HitTestResult& result, const LayoutRect& hitTestRect,
     const HitTestLocation& hitTestLocation,
     const HitTestingTransformState* transformState, 
     double* zOffsetForDescendants, double* zOffset,
@@ -6751,9 +6713,6 @@
         return 0;
 
     RenderFlowThread* flowThread = region->flowThread();
-    LayoutPoint regionOffsetFromRoot;
-    convertToLayerCoords(rootLayer, regionOffsetFromRoot);
-
     LayoutPoint portionLocation = region->flowThreadPortionRect().location();
     if (flowThread->style().isFlippedBlocksWritingMode()) {
         // The portion location coordinate must be translated into physical coordinates.

Modified: trunk/Source/WebCore/rendering/RenderLayer.h (170219 => 170220)


--- trunk/Source/WebCore/rendering/RenderLayer.h	2014-06-20 22:46:30 UTC (rev 170219)
+++ trunk/Source/WebCore/rendering/RenderLayer.h	2014-06-20 22:57:42 UTC (rev 170220)
@@ -646,9 +646,11 @@
     enum ColumnOffsetAdjustment { DontAdjustForColumns, AdjustForColumns };
     void convertToPixelSnappedLayerCoords(const RenderLayer* ancestorLayer, IntPoint& location, ColumnOffsetAdjustment adjustForColumns = DontAdjustForColumns) const;
     void convertToPixelSnappedLayerCoords(const RenderLayer* ancestorLayer, IntRect&, ColumnOffsetAdjustment adjustForColumns = DontAdjustForColumns) const;
-    void convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutPoint&, ColumnOffsetAdjustment adjustForColumns = DontAdjustForColumns) const;
-    void convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutRect&, ColumnOffsetAdjustment adjustForColumns = DontAdjustForColumns) const;
+    LayoutPoint convertToLayerCoords(const RenderLayer* ancestorLayer, const LayoutPoint&, ColumnOffsetAdjustment adjustForColumns = DontAdjustForColumns) const;
+    LayoutRect convertToLayerCoords(const RenderLayer* ancestorLayer, const LayoutRect&, ColumnOffsetAdjustment adjustForColumns = DontAdjustForColumns) const;
 
+    LayoutSize offsetFromAncestor(const RenderLayer*) const;
+
     int zIndex() const { return renderer().style().zIndex(); }
 
     enum PaintLayerFlag {

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (170219 => 170220)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2014-06-20 22:46:30 UTC (rev 170219)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2014-06-20 22:57:42 UTC (rev 170220)
@@ -458,8 +458,7 @@
         if (&m_owningLayer != rootLayer)
             clippingBounds.intersect(m_owningLayer.backgroundClipRect(RenderLayer::ClipRectsContext(rootLayer, AbsoluteClipRects)).rect()); // FIXME: Incorrect for CSS regions.
 
-        LayoutPoint delta;
-        m_owningLayer.convertToLayerCoords(rootLayer, delta, RenderLayer::AdjustForColumns);
+        LayoutPoint delta = m_owningLayer.convertToLayerCoords(rootLayer, LayoutPoint(), RenderLayer::AdjustForColumns);
         clippingBounds.move(-delta.x(), -delta.y());
 
         layerBounds.intersect(clippingBounds);
@@ -711,8 +710,7 @@
     LayoutRect localCompositingBounds = compositedBounds();
     LayoutRect relativeCompositingBounds(localCompositingBounds);
 
-    LayoutPoint offsetFromParent;
-    m_owningLayer.convertToLayerCoords(compAncestor, offsetFromParent, RenderLayer::AdjustForColumns);
+    LayoutPoint offsetFromParent = m_owningLayer.convertToLayerCoords(compAncestor, LayoutPoint(), RenderLayer::AdjustForColumns);
     // Device pixel fractions get accumulated through ancestor layers. Our painting offset is layout offset + parent's painting offset.
     offsetFromParent = offsetFromParent + (compAncestor ? compAncestor->backing()->devicePixelFractionFromRenderer() : LayoutSize());
     relativeCompositingBounds.moveBy(offsetFromParent);

Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (170219 => 170220)


--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2014-06-20 22:46:30 UTC (rev 170219)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2014-06-20 22:57:42 UTC (rev 170220)
@@ -958,13 +958,8 @@
     RenderLayer* compositedAncestor = layer.enclosingCompositingLayerForRepaint(ExcludeSelf);
     if (compositedAncestor) {
         ASSERT(compositedAncestor->backing());
-
-        LayoutPoint offset;
-        layer.convertToLayerCoords(compositedAncestor, offset);
-
         LayoutRect repaintRect = rect;
-        repaintRect.moveBy(offset);
-
+        repaintRect.move(layer.offsetFromAncestor(compositedAncestor));
         compositedAncestor->setBackingNeedsRepaintInRect(repaintRect);
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to