| Index: Source/core/rendering/RenderLayer.cpp
 | 
| diff --git a/Source/core/rendering/RenderLayer.cpp b/Source/core/rendering/RenderLayer.cpp
 | 
| index 0eef2763bebe2734f6a1a5304ccb42bf5c01374b..8edbc8630eeedec3d09686cf47ae61af9c468d31 100644
 | 
| --- a/Source/core/rendering/RenderLayer.cpp
 | 
| +++ b/Source/core/rendering/RenderLayer.cpp
 | 
| @@ -2016,7 +2016,10 @@ void RenderLayer::paintLayerContents(GraphicsContext* context, const LayerPainti
 | 
|      LayoutPoint offsetFromRoot;
 | 
|      convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot);
 | 
|  
 | 
| -    IntRect rootRelativeBounds;
 | 
| +    if (compositingState() == PaintsIntoOwnBacking)
 | 
| +        offsetFromRoot.move(m_compositedLayerMapping->subpixelAccumulation());
 | 
| +
 | 
| +    LayoutRect rootRelativeBounds;
 | 
|      bool rootRelativeBoundsComputed = false;
 | 
|  
 | 
|      // Apply clip-path to context.
 | 
| @@ -2138,7 +2141,7 @@ void RenderLayer::paintLayerContents(GraphicsContext* context, const LayerPainti
 | 
|          // fragment should paint.
 | 
|          collectFragments(layerFragments, localPaintingInfo.rootLayer, localPaintingInfo.region, localPaintingInfo.paintDirtyRect,
 | 
|              (paintFlags & PaintLayerTemporaryClipRects) ? TemporaryClipRects : PaintingClipRects, IgnoreOverlayScrollbarSize,
 | 
| -            (isPaintingOverflowContents) ? IgnoreOverflowClip : RespectOverflowClip, &offsetFromRoot);
 | 
| +            (isPaintingOverflowContents) ? IgnoreOverflowClip : RespectOverflowClip, &offsetFromRoot, localPaintingInfo.subPixelAccumulation);
 | 
|          updatePaintingInfoForFragments(layerFragments, localPaintingInfo, paintFlags, shouldPaintContent, &offsetFromRoot);
 | 
|      }
 | 
|  
 | 
| @@ -2244,12 +2247,12 @@ void RenderLayer::paintChildren(unsigned childrenToVisit, GraphicsContext* conte
 | 
|  
 | 
|  void RenderLayer::collectFragments(LayerFragments& fragments, const RenderLayer* rootLayer, RenderRegion* region, const LayoutRect& dirtyRect,
 | 
|      ClipRectsType clipRectsType, OverlayScrollbarSizeRelevancy inOverlayScrollbarSizeRelevancy, ShouldRespectOverflowClip respectOverflowClip, const LayoutPoint* offsetFromRoot,
 | 
| -    const LayoutRect* layerBoundingBox)
 | 
| +    const LayoutSize& subPixelAccumulation, const LayoutRect* layerBoundingBox)
 | 
|  {
 | 
|      if (!enclosingPaginationLayer() || hasTransform()) {
 | 
|          // For unpaginated layers, there is only one fragment.
 | 
|          LayerFragment fragment;
 | 
| -        ClipRectsContext clipRectsContext(rootLayer, region, clipRectsType, inOverlayScrollbarSizeRelevancy, respectOverflowClip);
 | 
| +        ClipRectsContext clipRectsContext(rootLayer, region, clipRectsType, inOverlayScrollbarSizeRelevancy, respectOverflowClip, subPixelAccumulation);
 | 
|          clipper().calculateRects(clipRectsContext, dirtyRect, fragment.layerBounds, fragment.backgroundRect, fragment.foregroundRect, fragment.outlineRect, offsetFromRoot);
 | 
|          fragments.append(fragment);
 | 
|          return;
 | 
| @@ -2335,7 +2338,7 @@ void RenderLayer::paintTransformedLayerIntoFragments(GraphicsContext* context, c
 | 
|      LayoutRect transformedExtent = transparencyClipBox(this, enclosingPaginationLayer(), PaintingTransparencyClipBox, RootOfTransparencyClipBox, paintingInfo.paintBehavior);
 | 
|      enclosingPaginationLayer()->collectFragments(enclosingPaginationFragments, paintingInfo.rootLayer, paintingInfo.region, paintingInfo.paintDirtyRect,
 | 
|          (paintFlags & PaintLayerTemporaryClipRects) ? TemporaryClipRects : PaintingClipRects, IgnoreOverlayScrollbarSize,
 | 
| -        (paintFlags & PaintLayerPaintingOverflowContents) ? IgnoreOverflowClip : RespectOverflowClip, &offsetOfPaginationLayerFromRoot, &transformedExtent);
 | 
| +        (paintFlags & PaintLayerPaintingOverflowContents) ? IgnoreOverflowClip : RespectOverflowClip, &offsetOfPaginationLayerFromRoot, paintingInfo.subPixelAccumulation, &transformedExtent);
 | 
|  
 | 
|      for (size_t i = 0; i < enclosingPaginationFragments.size(); ++i) {
 | 
|          const LayerFragment& fragment = enclosingPaginationFragments.at(i);
 | 
| @@ -2361,6 +2364,15 @@ void RenderLayer::paintTransformedLayerIntoFragments(GraphicsContext* context, c
 | 
|      }
 | 
|  }
 | 
|  
 | 
| +static inline LayoutSize subPixelAccumulationIfNeeded(const LayoutSize& subPixelAccumulation, CompositingState compositingState)
 | 
| +{
 | 
| +    // Only apply the sub-pixel accumulation if we don't paint into our own backing layer, otherwise the position
 | 
| +    // of the renderer already includes any sub-pixel offset.
 | 
| +    if (compositingState == PaintsIntoOwnBacking)
 | 
| +        return LayoutSize();
 | 
| +    return subPixelAccumulation;
 | 
| +}
 | 
| +
 | 
|  void RenderLayer::paintBackgroundForFragments(const LayerFragments& layerFragments, GraphicsContext* context, GraphicsContext* transparencyLayerContext,
 | 
|      const LayoutRect& transparencyPaintDirtyRect, bool haveTransparency, const LayerPaintingInfo& localPaintingInfo, PaintBehavior paintBehavior,
 | 
|      RenderObject* paintingRootForRenderer)
 | 
| @@ -2383,7 +2395,7 @@ void RenderLayer::paintBackgroundForFragments(const LayerFragments& layerFragmen
 | 
|          // Paint the background.
 | 
|          // FIXME: Eventually we will collect the region from the fragment itself instead of just from the paint info.
 | 
|          PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.backgroundRect.rect()), PaintPhaseBlockBackground, paintBehavior, paintingRootForRenderer, localPaintingInfo.region, 0, 0, localPaintingInfo.rootLayer->renderer());
 | 
| -        renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - renderBoxLocation() + localPaintingInfo.subPixelAccumulation));
 | 
| +        renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - renderBoxLocation() + subPixelAccumulationIfNeeded(localPaintingInfo.subPixelAccumulation, compositingState())));
 | 
|  
 | 
|          if (localPaintingInfo.clipToDirtyRect)
 | 
|              restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.backgroundRect);
 | 
| @@ -2443,7 +2455,7 @@ void RenderLayer::paintForegroundForFragmentsWithPhase(PaintPhase phase, const L
 | 
|          PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.foregroundRect.rect()), phase, paintBehavior, paintingRootForRenderer, localPaintingInfo.region, 0, 0, localPaintingInfo.rootLayer->renderer());
 | 
|          if (phase == PaintPhaseForeground)
 | 
|              paintInfo.overlapTestRequests = localPaintingInfo.overlapTestRequests;
 | 
| -        renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - renderBoxLocation() + localPaintingInfo.subPixelAccumulation));
 | 
| +        renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - renderBoxLocation() + subPixelAccumulationIfNeeded(localPaintingInfo.subPixelAccumulation, compositingState())));
 | 
|  
 | 
|          if (shouldClip)
 | 
|              restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.foregroundRect);
 | 
| @@ -2461,7 +2473,7 @@ void RenderLayer::paintOutlineForFragments(const LayerFragments& layerFragments,
 | 
|          // Paint our own outline
 | 
|          PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.outlineRect.rect()), PaintPhaseSelfOutline, paintBehavior, paintingRootForRenderer, localPaintingInfo.region, 0, 0, localPaintingInfo.rootLayer->renderer());
 | 
|          clipToRect(localPaintingInfo.rootLayer, context, localPaintingInfo.paintDirtyRect, fragment.outlineRect, DoNotIncludeSelfForBorderRadius);
 | 
| -        renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - renderBoxLocation() + localPaintingInfo.subPixelAccumulation));
 | 
| +        renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - renderBoxLocation() + subPixelAccumulationIfNeeded(localPaintingInfo.subPixelAccumulation, compositingState())));
 | 
|          restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.outlineRect);
 | 
|      }
 | 
|  }
 | 
| @@ -2480,7 +2492,7 @@ void RenderLayer::paintMaskForFragments(const LayerFragments& layerFragments, Gr
 | 
|          // Paint the mask.
 | 
|          // FIXME: Eventually we will collect the region from the fragment itself instead of just from the paint info.
 | 
|          PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.backgroundRect.rect()), PaintPhaseMask, PaintBehaviorNormal, paintingRootForRenderer, localPaintingInfo.region, 0, 0, localPaintingInfo.rootLayer->renderer());
 | 
| -        renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - renderBoxLocation() + localPaintingInfo.subPixelAccumulation));
 | 
| +        renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - renderBoxLocation() + subPixelAccumulationIfNeeded(localPaintingInfo.subPixelAccumulation, compositingState())));
 | 
|  
 | 
|          if (localPaintingInfo.clipToDirtyRect)
 | 
|              restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.backgroundRect);
 | 
| @@ -2500,7 +2512,7 @@ void RenderLayer::paintChildClippingMaskForFragments(const LayerFragments& layer
 | 
|  
 | 
|          // Paint the the clipped mask.
 | 
|          PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.backgroundRect.rect()), PaintPhaseClippingMask, PaintBehaviorNormal, paintingRootForRenderer, localPaintingInfo.region, 0, 0, localPaintingInfo.rootLayer->renderer());
 | 
| -        renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - renderBoxLocation() + localPaintingInfo.subPixelAccumulation));
 | 
| +        renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - renderBoxLocation() + subPixelAccumulationIfNeeded(localPaintingInfo.subPixelAccumulation, compositingState())));
 | 
|  
 | 
|          if (localPaintingInfo.clipToDirtyRect)
 | 
|              restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.foregroundRect);
 | 
| @@ -2513,7 +2525,7 @@ void RenderLayer::paintOverflowControlsForFragments(const LayerFragments& layerF
 | 
|          const LayerFragment& fragment = layerFragments.at(i);
 | 
|          clipToRect(localPaintingInfo.rootLayer, context, localPaintingInfo.paintDirtyRect, fragment.backgroundRect);
 | 
|          if (RenderLayerScrollableArea* scrollableArea = this->scrollableArea())
 | 
| -            scrollableArea->paintOverflowControls(context, roundedIntPoint(toPoint(fragment.layerBounds.location() - renderBoxLocation() + localPaintingInfo.subPixelAccumulation)), pixelSnappedIntRect(fragment.backgroundRect.rect()), true);
 | 
| +            scrollableArea->paintOverflowControls(context, roundedIntPoint(toPoint(fragment.layerBounds.location() - renderBoxLocation() + subPixelAccumulationIfNeeded(localPaintingInfo.subPixelAccumulation, compositingState()))), pixelSnappedIntRect(fragment.backgroundRect.rect()), true);
 | 
|          restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.backgroundRect);
 | 
|      }
 | 
|  }
 | 
| @@ -2974,7 +2986,7 @@ RenderLayer* RenderLayer::hitTestTransformedLayerInFragments(RenderLayer* rootLa
 | 
|      LayoutPoint offsetOfPaginationLayerFromRoot;
 | 
|      LayoutRect transformedExtent = transparencyClipBox(this, enclosingPaginationLayer(), HitTestingTransparencyClipBox, RootOfTransparencyClipBox);
 | 
|      enclosingPaginationLayer()->collectFragments(enclosingPaginationFragments, rootLayer, hitTestLocation.region(), hitTestRect,
 | 
| -        RootRelativeClipRects, IncludeOverlayScrollbarSize, RespectOverflowClip, &offsetOfPaginationLayerFromRoot, &transformedExtent);
 | 
| +        RootRelativeClipRects, IncludeOverlayScrollbarSize, RespectOverflowClip, &offsetOfPaginationLayerFromRoot, LayoutSize(), &transformedExtent);
 | 
|  
 | 
|      for (int i = enclosingPaginationFragments.size() - 1; i >= 0; --i) {
 | 
|          const LayerFragment& fragment = enclosingPaginationFragments.at(i);
 | 
| @@ -3421,14 +3433,14 @@ IntRect RenderLayer::absoluteBoundingBox() const
 | 
|      return pixelSnappedIntRect(boundingBox(root()));
 | 
|  }
 | 
|  
 | 
| -IntRect RenderLayer::calculateLayerBounds(const RenderLayer* ancestorLayer, const LayoutPoint* offsetFromRoot, CalculateLayerBoundsFlags flags) const
 | 
| +LayoutRect RenderLayer::calculateLayerBounds(const RenderLayer* ancestorLayer, const LayoutPoint* offsetFromRoot, CalculateLayerBoundsFlags flags) const
 | 
|  {
 | 
|      if (!isSelfPaintingLayer())
 | 
| -        return IntRect();
 | 
| +        return LayoutRect();
 | 
|  
 | 
|      // FIXME: This could be improved to do a check like hasVisibleNonCompositingDescendantLayers() (bug 92580).
 | 
|      if ((flags & ExcludeHiddenDescendants) && this != ancestorLayer && !hasVisibleContent() && !hasVisibleDescendant())
 | 
| -        return IntRect();
 | 
| +        return LayoutRect();
 | 
|  
 | 
|      RenderLayerModelObject* renderer = this->renderer();
 | 
|  
 | 
| @@ -3469,7 +3481,7 @@ IntRect RenderLayer::calculateLayerBounds(const RenderLayer* ancestorLayer, cons
 | 
|              LayoutPoint ancestorRelOffset;
 | 
|              convertToLayerCoords(ancestorLayer, ancestorRelOffset);
 | 
|              localClipRect.moveBy(ancestorRelOffset);
 | 
| -            return pixelSnappedIntRect(localClipRect);
 | 
| +            return localClipRect;
 | 
|          }
 | 
|      }
 | 
|  
 | 
| @@ -3481,7 +3493,7 @@ IntRect RenderLayer::calculateLayerBounds(const RenderLayer* ancestorLayer, cons
 | 
|      if (m_reflectionInfo) {
 | 
|          RenderLayer* reflectionLayer = m_reflectionInfo->reflectionLayer();
 | 
|          if (!reflectionLayer->hasCompositedLayerMapping()) {
 | 
| -            IntRect childUnionBounds = reflectionLayer->calculateLayerBounds(this, 0, descendantFlags);
 | 
| +            LayoutRect childUnionBounds = reflectionLayer->calculateLayerBounds(this, 0, descendantFlags);
 | 
|              unionBounds.unite(childUnionBounds);
 | 
|          }
 | 
|      }
 | 
| @@ -3506,7 +3518,7 @@ IntRect RenderLayer::calculateLayerBounds(const RenderLayer* ancestorLayer, cons
 | 
|          }
 | 
|  
 | 
|          if (flags & IncludeCompositedDescendants || !node->layer()->hasCompositedLayerMapping()) {
 | 
| -            IntRect childUnionBounds = node->layer()->calculateLayerBounds(this, 0, descendantFlags);
 | 
| +            LayoutRect childUnionBounds = node->layer()->calculateLayerBounds(this, 0, descendantFlags);
 | 
|              unionBounds.unite(childUnionBounds);
 | 
|          }
 | 
|      }
 | 
| @@ -3530,7 +3542,7 @@ IntRect RenderLayer::calculateLayerBounds(const RenderLayer* ancestorLayer, cons
 | 
|          convertToLayerCoords(ancestorLayer, ancestorRelOffset);
 | 
|      unionBounds.moveBy(ancestorRelOffset);
 | 
|  
 | 
| -    return pixelSnappedIntRect(unionBounds);
 | 
| +    return unionBounds;
 | 
|  }
 | 
|  
 | 
|  CompositingState RenderLayer::compositingState() const
 | 
| 
 |