| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 | 27 |
| 28 #include "web/LinkHighlight.h" | 28 #include "web/LinkHighlight.h" |
| 29 | 29 |
| 30 #include "SkMatrix44.h" | 30 #include "SkMatrix44.h" |
| 31 #include "core/dom/Node.h" | 31 #include "core/dom/Node.h" |
| 32 #include "core/dom/NodeRenderingTraversal.h" | 32 #include "core/dom/NodeRenderingTraversal.h" |
| 33 #include "core/frame/FrameView.h" | 33 #include "core/frame/FrameView.h" |
| 34 #include "core/frame/LocalFrame.h" | 34 #include "core/frame/LocalFrame.h" |
| 35 #include "core/layout/Layer.h" | 35 #include "core/layout/Layer.h" |
| 36 #include "core/layout/LayoutLayerModelObject.h" | 36 #include "core/layout/LayoutBoxModelObject.h" |
| 37 #include "core/layout/LayoutObject.h" | 37 #include "core/layout/LayoutObject.h" |
| 38 #include "core/layout/compositing/CompositedLayerMapping.h" | 38 #include "core/layout/compositing/CompositedLayerMapping.h" |
| 39 #include "core/layout/style/ShadowData.h" | 39 #include "core/layout/style/ShadowData.h" |
| 40 #include "core/rendering/RenderView.h" | 40 #include "core/rendering/RenderView.h" |
| 41 #include "platform/graphics/Color.h" | 41 #include "platform/graphics/Color.h" |
| 42 #include "platform/graphics/paint/DisplayItemList.h" | 42 #include "platform/graphics/paint/DisplayItemList.h" |
| 43 #include "platform/graphics/paint/DrawingRecorder.h" | 43 #include "platform/graphics/paint/DrawingRecorder.h" |
| 44 #include "public/platform/Platform.h" | 44 #include "public/platform/Platform.h" |
| 45 #include "public/platform/WebCompositorAnimationCurve.h" | 45 #include "public/platform/WebCompositorAnimationCurve.h" |
| 46 #include "public/platform/WebCompositorSupport.h" | 46 #include "public/platform/WebCompositorSupport.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 WebLayer* LinkHighlight::clipLayer() | 99 WebLayer* LinkHighlight::clipLayer() |
| 100 { | 100 { |
| 101 return m_clipLayer.get(); | 101 return m_clipLayer.get(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 void LinkHighlight::releaseResources() | 104 void LinkHighlight::releaseResources() |
| 105 { | 105 { |
| 106 m_node.clear(); | 106 m_node.clear(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 void LinkHighlight::attachLinkHighlightToCompositingLayer(const LayoutLayerModel
Object* paintInvalidationContainer) | 109 void LinkHighlight::attachLinkHighlightToCompositingLayer(const LayoutBoxModelOb
ject* paintInvalidationContainer) |
| 110 { | 110 { |
| 111 GraphicsLayer* newGraphicsLayer = paintInvalidationContainer->layer()->graph
icsLayerBacking(); | 111 GraphicsLayer* newGraphicsLayer = paintInvalidationContainer->layer()->graph
icsLayerBacking(); |
| 112 // FIXME: There should always be a GraphicsLayer. See crbug.com/431961. | 112 // FIXME: There should always be a GraphicsLayer. See crbug.com/431961. |
| 113 if (newGraphicsLayer && !newGraphicsLayer->drawsContent()) | 113 if (newGraphicsLayer && !newGraphicsLayer->drawsContent()) |
| 114 newGraphicsLayer = paintInvalidationContainer->layer()->graphicsLayerBac
kingForScrolling(); | 114 newGraphicsLayer = paintInvalidationContainer->layer()->graphicsLayerBac
kingForScrolling(); |
| 115 if (!newGraphicsLayer) | 115 if (!newGraphicsLayer) |
| 116 return; | 116 return; |
| 117 | 117 |
| 118 m_clipLayer->setTransform(SkMatrix44(SkMatrix44::kIdentity_Constructor)); | 118 m_clipLayer->setTransform(SkMatrix44(SkMatrix44::kIdentity_Constructor)); |
| 119 | 119 |
| 120 if (m_currentGraphicsLayer != newGraphicsLayer) { | 120 if (m_currentGraphicsLayer != newGraphicsLayer) { |
| 121 if (m_currentGraphicsLayer) | 121 if (m_currentGraphicsLayer) |
| 122 clearGraphicsLayerLinkHighlightPointer(); | 122 clearGraphicsLayerLinkHighlightPointer(); |
| 123 | 123 |
| 124 m_currentGraphicsLayer = newGraphicsLayer; | 124 m_currentGraphicsLayer = newGraphicsLayer; |
| 125 m_currentGraphicsLayer->addLinkHighlight(this); | 125 m_currentGraphicsLayer->addLinkHighlight(this); |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 | 128 |
| 129 static void convertTargetSpaceQuadToCompositedLayer(const FloatQuad& targetSpace
Quad, LayoutObject* targetRenderer, const LayoutLayerModelObject* paintInvalidat
ionContainer, FloatQuad& compositedSpaceQuad) | 129 static void convertTargetSpaceQuadToCompositedLayer(const FloatQuad& targetSpace
Quad, LayoutObject* targetRenderer, const LayoutBoxModelObject* paintInvalidatio
nContainer, FloatQuad& compositedSpaceQuad) |
| 130 { | 130 { |
| 131 ASSERT(targetRenderer); | 131 ASSERT(targetRenderer); |
| 132 ASSERT(paintInvalidationContainer); | 132 ASSERT(paintInvalidationContainer); |
| 133 for (unsigned i = 0; i < 4; ++i) { | 133 for (unsigned i = 0; i < 4; ++i) { |
| 134 IntPoint point; | 134 IntPoint point; |
| 135 switch (i) { | 135 switch (i) { |
| 136 case 0: point = roundedIntPoint(targetSpaceQuad.p1()); break; | 136 case 0: point = roundedIntPoint(targetSpaceQuad.p1()); break; |
| 137 case 1: point = roundedIntPoint(targetSpaceQuad.p2()); break; | 137 case 1: point = roundedIntPoint(targetSpaceQuad.p2()); break; |
| 138 case 2: point = roundedIntPoint(targetSpaceQuad.p3()); break; | 138 case 2: point = roundedIntPoint(targetSpaceQuad.p3()); break; |
| 139 case 3: point = roundedIntPoint(targetSpaceQuad.p4()); break; | 139 case 3: point = roundedIntPoint(targetSpaceQuad.p4()); break; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 // boxes. | 178 // boxes. |
| 179 if (renderer->isRenderInline()) { | 179 if (renderer->isRenderInline()) { |
| 180 for (Node* child = NodeRenderingTraversal::firstChild(node); child; chil
d = NodeRenderingTraversal::nextSibling(*child)) | 180 for (Node* child = NodeRenderingTraversal::firstChild(node); child; chil
d = NodeRenderingTraversal::nextSibling(*child)) |
| 181 computeQuads(*child, outQuads); | 181 computeQuads(*child, outQuads); |
| 182 } else { | 182 } else { |
| 183 // FIXME: this does not need to be absolute, just in the paint invalidat
ion container's space. | 183 // FIXME: this does not need to be absolute, just in the paint invalidat
ion container's space. |
| 184 renderer->absoluteQuads(outQuads); | 184 renderer->absoluteQuads(outQuads); |
| 185 } | 185 } |
| 186 } | 186 } |
| 187 | 187 |
| 188 bool LinkHighlight::computeHighlightLayerPathAndPosition(const LayoutLayerModelO
bject* paintInvalidationContainer) | 188 bool LinkHighlight::computeHighlightLayerPathAndPosition(const LayoutBoxModelObj
ect* paintInvalidationContainer) |
| 189 { | 189 { |
| 190 if (!m_node || !m_node->renderer() || !m_currentGraphicsLayer) | 190 if (!m_node || !m_node->renderer() || !m_currentGraphicsLayer) |
| 191 return false; | 191 return false; |
| 192 ASSERT(paintInvalidationContainer); | 192 ASSERT(paintInvalidationContainer); |
| 193 | 193 |
| 194 // FIXME: This is defensive code to avoid crashes such as those described in | 194 // FIXME: This is defensive code to avoid crashes such as those described in |
| 195 // crbug.com/440887. This should be cleaned up once we fix the root cause of | 195 // crbug.com/440887. This should be cleaned up once we fix the root cause of |
| 196 // of the paint invalidation container not being composited. | 196 // of the paint invalidation container not being composited. |
| 197 if (!paintInvalidationContainer->layer()->compositedLayerMapping() && !paint
InvalidationContainer->layer()->groupedMapping()) | 197 if (!paintInvalidationContainer->layer()->compositedLayerMapping() && !paint
InvalidationContainer->layer()->groupedMapping()) |
| 198 return false; | 198 return false; |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 void LinkHighlight::updateGeometry() | 333 void LinkHighlight::updateGeometry() |
| 334 { | 334 { |
| 335 // To avoid unnecessary updates (e.g. other entities have requested animatio
ns from our WebViewImpl), | 335 // To avoid unnecessary updates (e.g. other entities have requested animatio
ns from our WebViewImpl), |
| 336 // only proceed if we actually requested an update. | 336 // only proceed if we actually requested an update. |
| 337 if (!m_geometryNeedsUpdate) | 337 if (!m_geometryNeedsUpdate) |
| 338 return; | 338 return; |
| 339 | 339 |
| 340 m_geometryNeedsUpdate = false; | 340 m_geometryNeedsUpdate = false; |
| 341 | 341 |
| 342 bool hasRenderer = m_node && m_node->renderer(); | 342 bool hasRenderer = m_node && m_node->renderer(); |
| 343 const LayoutLayerModelObject* paintInvalidationContainer = hasRenderer ? m_n
ode->renderer()->containerForPaintInvalidation() : 0; | 343 const LayoutBoxModelObject* paintInvalidationContainer = hasRenderer ? m_nod
e->renderer()->containerForPaintInvalidation() : 0; |
| 344 if (paintInvalidationContainer) | 344 if (paintInvalidationContainer) |
| 345 attachLinkHighlightToCompositingLayer(paintInvalidationContainer); | 345 attachLinkHighlightToCompositingLayer(paintInvalidationContainer); |
| 346 if (paintInvalidationContainer && computeHighlightLayerPathAndPosition(paint
InvalidationContainer)) { | 346 if (paintInvalidationContainer && computeHighlightLayerPathAndPosition(paint
InvalidationContainer)) { |
| 347 // We only need to invalidate the layer if the highlight size has change
d, otherwise | 347 // We only need to invalidate the layer if the highlight size has change
d, otherwise |
| 348 // we can just re-position the layer without needing to repaint. | 348 // we can just re-position the layer without needing to repaint. |
| 349 m_contentLayer->layer()->invalidate(); | 349 m_contentLayer->layer()->invalidate(); |
| 350 | 350 |
| 351 if (m_currentGraphicsLayer) | 351 if (m_currentGraphicsLayer) |
| 352 m_currentGraphicsLayer->addRepaintRect(FloatRect(layer()->position()
.x, layer()->position().y, layer()->bounds().width, layer()->bounds().height)); | 352 m_currentGraphicsLayer->addRepaintRect(FloatRect(layer()->position()
.x, layer()->position().y, layer()->bounds().width, layer()->bounds().height)); |
| 353 } else if (!hasRenderer) { | 353 } else if (!hasRenderer) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 367 // Make sure we update geometry on the next callback from WebViewImpl::layou
t(). | 367 // Make sure we update geometry on the next callback from WebViewImpl::layou
t(). |
| 368 m_geometryNeedsUpdate = true; | 368 m_geometryNeedsUpdate = true; |
| 369 } | 369 } |
| 370 | 370 |
| 371 WebLayer* LinkHighlight::layer() | 371 WebLayer* LinkHighlight::layer() |
| 372 { | 372 { |
| 373 return clipLayer(); | 373 return clipLayer(); |
| 374 } | 374 } |
| 375 | 375 |
| 376 } // namespace blink | 376 } // namespace blink |
| OLD | NEW |