Commit 8e036fa1 authored by chrishtr's avatar chrishtr Committed by Commit bot

Fix graphics layer backing and offset for composited selection handles.

This CL:

1. Moves the code out of LayoutObject.
2. Forces the GraphicsLayer to be m_graphicsLayer and not
m_scrollingContentsLayer.

TEST=manual testing
BUG=679674

Review-Url: https://codereview.chromium.org/2620383004
Cr-Commit-Position: refs/heads/master@{#443107}
parent 75298de7
......@@ -265,6 +265,41 @@ IntRect RenderedPosition::absoluteRect(
.enclosingBoundingBox();
}
// Convert a local point into the coordinate system of backing coordinates.
// Also returns the backing layer if needed.
FloatPoint RenderedPosition::localToInvalidationBackingPoint(
const LayoutPoint& localPoint,
GraphicsLayer** graphicsLayerBacking) const {
const LayoutBoxModelObject& paintInvalidationContainer =
m_layoutObject->containerForPaintInvalidation();
DCHECK(paintInvalidationContainer.layer());
FloatPoint containerPoint = m_layoutObject->localToAncestorPoint(
FloatPoint(localPoint), &paintInvalidationContainer,
TraverseDocumentBoundaries);
// A layoutObject can have no invalidation backing if it is from a detached
// frame, or when forced compositing is disabled.
if (paintInvalidationContainer.layer()->compositingState() == NotComposited)
return containerPoint;
PaintLayer::mapPointInPaintInvalidationContainerToBacking(
paintInvalidationContainer, containerPoint);
// Must not use the scrolling contents layer, so pass
// |paintInvalidationContainer|.
if (GraphicsLayer* graphicsLayer =
paintInvalidationContainer.layer()->graphicsLayerBacking(
&paintInvalidationContainer)) {
if (graphicsLayerBacking)
*graphicsLayerBacking = graphicsLayer;
containerPoint.move(-graphicsLayer->offsetFromLayoutObject());
}
return containerPoint;
}
void RenderedPosition::positionInGraphicsLayerBacking(
CompositedSelectionBound& bound,
bool selectionStart) const {
......@@ -275,17 +310,16 @@ void RenderedPosition::positionInGraphicsLayerBacking(
return;
LayoutRect rect = m_layoutObject->localCaretRect(m_inlineBox, m_offset);
PaintLayer* layer = nullptr;
if (m_layoutObject->style()->isHorizontalWritingMode()) {
bound.edgeTopInLayer = m_layoutObject->localToInvalidationBackingPoint(
rect.minXMinYCorner(), &layer);
bound.edgeBottomInLayer = m_layoutObject->localToInvalidationBackingPoint(
rect.minXMaxYCorner(), nullptr);
bound.edgeTopInLayer =
localToInvalidationBackingPoint(rect.minXMinYCorner(), &bound.layer);
bound.edgeBottomInLayer =
localToInvalidationBackingPoint(rect.minXMaxYCorner(), nullptr);
} else {
bound.edgeTopInLayer = m_layoutObject->localToInvalidationBackingPoint(
rect.minXMinYCorner(), &layer);
bound.edgeBottomInLayer = m_layoutObject->localToInvalidationBackingPoint(
rect.maxXMinYCorner(), nullptr);
bound.edgeTopInLayer =
localToInvalidationBackingPoint(rect.minXMinYCorner(), &bound.layer);
bound.edgeBottomInLayer =
localToInvalidationBackingPoint(rect.maxXMinYCorner(), nullptr);
// When text is vertical, it looks better for the start handle baseline to
// be at the starting edge, to enclose the selection fully between the
......@@ -299,8 +333,6 @@ void RenderedPosition::positionInGraphicsLayerBacking(
// Flipped blocks writing mode is not only vertical but also right to left.
bound.isTextDirectionRTL = m_layoutObject->hasFlippedBlocksWritingMode();
}
bound.layer = layer ? layer->graphicsLayerBacking() : nullptr;
}
bool layoutObjectContainsPosition(LayoutObject* target,
......
......@@ -38,6 +38,8 @@
namespace blink {
class GraphicsLayer;
class LayoutPoint;
class LayoutUnit;
class LayoutObject;
struct CompositedSelectionBound;
......@@ -102,6 +104,10 @@ class RenderedPosition {
bool atRightBoundaryOfBidiRun(ShouldMatchBidiLevel,
unsigned char bidiLevelOfRun) const;
FloatPoint localToInvalidationBackingPoint(
const LayoutPoint& localPoint,
GraphicsLayer** graphicsLayerBacking) const;
LayoutObject* m_layoutObject;
InlineBox* m_inlineBox;
int m_offset;
......
......@@ -2315,35 +2315,6 @@ TransformationMatrix LayoutObject::localToAncestorTransform(
return transformState.accumulatedTransform();
}
FloatPoint LayoutObject::localToInvalidationBackingPoint(
const LayoutPoint& localPoint,
PaintLayer** backingLayer) {
const LayoutBoxModelObject& paintInvalidationContainer =
containerForPaintInvalidation();
DCHECK(paintInvalidationContainer.layer());
if (backingLayer)
*backingLayer = paintInvalidationContainer.layer();
FloatPoint containerPoint =
localToAncestorPoint(FloatPoint(localPoint), &paintInvalidationContainer,
TraverseDocumentBoundaries);
// A layoutObject can have no invalidation backing if it is from a detached
// frame, or when forced compositing is disabled.
if (paintInvalidationContainer.layer()->compositingState() == NotComposited)
return containerPoint;
PaintLayer::mapPointInPaintInvalidationContainerToBacking(
paintInvalidationContainer, containerPoint);
if (GraphicsLayer* backingLayer =
paintInvalidationContainer.layer()->graphicsLayerBacking(this)) {
containerPoint.move(-backingLayer->offsetFromLayoutObject());
}
return containerPoint;
}
LayoutSize LayoutObject::offsetFromContainer(const LayoutObject* o) const {
ASSERT(o == container());
return o->hasOverflowClip()
......
......@@ -1204,12 +1204,6 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver,
return localToAncestorTransform(nullptr, mode);
}
// Convert a local point into the coordinate system of backing coordinates.
// Also returns the backing layer if needed.
FloatPoint localToInvalidationBackingPoint(
const LayoutPoint&,
PaintLayer** backingLayer = nullptr);
// Return the offset from the container() layoutObject (excluding transforms
// and multicol).
virtual LayoutSize offsetFromContainer(const LayoutObject*) const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment