Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1019)

Unified Diff: Source/web/LinkHighlight.cpp

Issue 687313002: Fix LinkHighlight to position correctly w.r.t. squashed layers. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/web/LinkHighlight.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/LinkHighlight.cpp
diff --git a/Source/web/LinkHighlight.cpp b/Source/web/LinkHighlight.cpp
index bcbb4bac4414921d1998ffcdce03f97a2a894db9..1faa0c3de3f50be58eb141de83a6b030ed1614d6 100644
--- a/Source/web/LinkHighlight.cpp
+++ b/Source/web/LinkHighlight.cpp
@@ -106,30 +106,11 @@ void LinkHighlight::releaseResources()
m_node.clear();
}
-RenderLayer* LinkHighlight::computeEnclosingCompositingLayer()
+void LinkHighlight::attachLinkHighlightToCompositingLayer(const RenderLayerModelObject* paintInvalidationContainer)
{
- if (!m_node || !m_node->renderer())
- return 0;
-
- // Find the nearest enclosing composited layer and attach to it. We may need to cross frame boundaries
- // to find a suitable layer.
- RenderObject* renderer = m_node->renderer();
- RenderLayer* renderLayer;
- do {
- renderLayer = renderer->enclosingLayer()->enclosingLayerForPaintInvalidation();
- if (!renderLayer) {
- renderer = renderer->frame()->ownerRenderer();
- if (!renderer)
- return 0;
- }
- } while (!renderLayer);
-
- ASSERT(renderLayer->compositingState() != NotComposited);
-
- GraphicsLayer* newGraphicsLayer = renderLayer->graphicsLayerBacking();
- if (!newGraphicsLayer->drawsContent()) {
- newGraphicsLayer = renderLayer->graphicsLayerBackingForScrolling();
- }
+ GraphicsLayer* newGraphicsLayer = paintInvalidationContainer->layer()->graphicsLayerBacking();
trchen 2014/10/29 23:57:30 I think we need to do a null check here. Multicol
chrishtr 2014/10/30 00:01:17 RenderObject::containerForPaintInvalidation should
trchen 2014/10/30 00:08:58 No I meant newGraphicsLayer may be null.
chrishtr 2014/10/30 00:21:59 Oh, yuck. Thanks for pointing that out. Fixed.
+ if (!newGraphicsLayer->drawsContent())
+ newGraphicsLayer = paintInvalidationContainer->layer()->graphicsLayerBackingForScrolling();
m_clipLayer->setTransform(SkMatrix44(SkMatrix44::kIdentity_Constructor));
@@ -140,15 +121,12 @@ RenderLayer* LinkHighlight::computeEnclosingCompositingLayer()
m_currentGraphicsLayer = newGraphicsLayer;
m_currentGraphicsLayer->addLinkHighlight(this);
}
-
- return renderLayer;
}
-static void convertTargetSpaceQuadToCompositedLayer(const FloatQuad& targetSpaceQuad, RenderObject* targetRenderer, RenderObject* compositedRenderer, FloatQuad& compositedSpaceQuad)
+static void convertTargetSpaceQuadToCompositedLayer(const FloatQuad& targetSpaceQuad, RenderObject* targetRenderer, const RenderLayerModelObject* paintInvalidationContainer, FloatQuad& compositedSpaceQuad)
{
ASSERT(targetRenderer);
- ASSERT(compositedRenderer);
-
+ ASSERT(paintInvalidationContainer);
for (unsigned i = 0; i < 4; ++i) {
IntPoint point;
switch (i) {
@@ -158,9 +136,11 @@ static void convertTargetSpaceQuadToCompositedLayer(const FloatQuad& targetSpace
case 3: point = roundedIntPoint(targetSpaceQuad.p4()); break;
}
+ // FIXME: this does not need to be absolute, just in the paint invalidation container's space.
point = targetRenderer->frame()->view()->contentsToWindow(point);
- point = compositedRenderer->frame()->view()->windowToContents(point);
- FloatPoint floatPoint = compositedRenderer->absoluteToLocal(point, UseTransforms);
+ point = paintInvalidationContainer->frame()->view()->windowToContents(point);
+ FloatPoint floatPoint = paintInvalidationContainer->absoluteToLocal(point, UseTransforms);
+ RenderLayer::mapPointToPaintBackingCoordinates(paintInvalidationContainer, floatPoint);
switch (i) {
case 0: compositedSpaceQuad.setP1(floatPoint); break;
@@ -197,33 +177,28 @@ void LinkHighlight::computeQuads(const Node& node, Vector<FloatQuad>& outQuads)
for (Node* child = NodeRenderingTraversal::firstChild(&node); child; child = NodeRenderingTraversal::nextSibling(child))
computeQuads(*child, outQuads);
} else {
+ // FIXME: this does not need to be absolute, just in the paint invalidation container's space.
renderer->absoluteQuads(outQuads);
}
}
-bool LinkHighlight::computeHighlightLayerPathAndPosition(RenderLayer* compositingLayer)
+bool LinkHighlight::computeHighlightLayerPathAndPosition(const RenderLayerModelObject* paintInvalidationContainer)
{
if (!m_node || !m_node->renderer() || !m_currentGraphicsLayer)
return false;
-
- ASSERT(compositingLayer);
+ ASSERT(paintInvalidationContainer);
// Get quads for node in absolute coordinates.
Vector<FloatQuad> quads;
computeQuads(*m_node, quads);
ASSERT(quads.size());
-
- // Adjust for offset between target graphics layer and the node's renderer.
- FloatPoint positionAdjust = IntPoint(m_currentGraphicsLayer->offsetFromRenderer());
-
Path newPath;
for (size_t quadIndex = 0; quadIndex < quads.size(); ++quadIndex) {
FloatQuad absoluteQuad = quads[quadIndex];
- absoluteQuad.move(-positionAdjust.x(), -positionAdjust.y());
// Transform node quads in target absolute coords to local coordinates in the compositor layer.
FloatQuad transformedQuad;
- convertTargetSpaceQuadToCompositedLayer(absoluteQuad, m_node->renderer(), compositingLayer->renderer(), transformedQuad);
+ convertTargetSpaceQuadToCompositedLayer(absoluteQuad, m_node->renderer(), paintInvalidationContainer, transformedQuad);
// FIXME: for now, we'll only use rounded paths if we have a single node quad. The reason for this is that
// we may sometimes get a chain of adjacent boxes (e.g. for text nodes) which end up looking like sausage
@@ -331,10 +306,13 @@ void LinkHighlight::updateGeometry()
if (!m_geometryNeedsUpdate)
return;
- m_geometryNeedsUpdate = false;
+ if (!m_node || !m_node->renderer())
+ return;
- RenderLayer* compositingLayer = computeEnclosingCompositingLayer();
- if (compositingLayer && computeHighlightLayerPathAndPosition(compositingLayer)) {
+ m_geometryNeedsUpdate = false;
+ const RenderLayerModelObject* paintInvalidationContainer = m_node->renderer()->containerForPaintInvalidation();
+ attachLinkHighlightToCompositingLayer(paintInvalidationContainer);
+ if (paintInvalidationContainer && computeHighlightLayerPathAndPosition(paintInvalidationContainer)) {
// We only need to invalidate the layer if the highlight size has changed, otherwise
// we can just re-position the layer without needing to repaint.
m_contentLayer->layer()->invalidate();
« no previous file with comments | « Source/web/LinkHighlight.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698