| 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 |
| 11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
| 12 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
| 13 * | 13 * |
| 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY | 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
| 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY | 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
| 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 | 27 |
| 28 #include "LinkHighlight.h" | 28 #include "LinkHighlight.h" |
| 29 | 29 |
| 30 #include "NonCompositedContentHost.h" |
| 30 #include "SkMatrix44.h" | 31 #include "SkMatrix44.h" |
| 31 #include "WebFrameImpl.h" | 32 #include "WebFrameImpl.h" |
| 32 #include "WebKit.h" | 33 #include "WebKit.h" |
| 33 #include "WebViewImpl.h" | 34 #include "WebViewImpl.h" |
| 34 #include "core/dom/Node.h" | 35 #include "core/dom/Node.h" |
| 35 #include "core/page/Frame.h" | 36 #include "core/page/Frame.h" |
| 36 #include "core/page/FrameView.h" | 37 #include "core/page/FrameView.h" |
| 37 #include "core/platform/graphics/Color.h" | 38 #include "core/platform/graphics/Color.h" |
| 38 #include "core/rendering/RenderLayer.h" | 39 #include "core/rendering/RenderLayer.h" |
| 39 #include "core/rendering/RenderLayerBacking.h" | 40 #include "core/rendering/RenderLayerBacking.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 58 | 59 |
| 59 PassOwnPtr<LinkHighlight> LinkHighlight::create(Node* node, WebViewImpl* owningW
ebViewImpl) | 60 PassOwnPtr<LinkHighlight> LinkHighlight::create(Node* node, WebViewImpl* owningW
ebViewImpl) |
| 60 { | 61 { |
| 61 return adoptPtr(new LinkHighlight(node, owningWebViewImpl)); | 62 return adoptPtr(new LinkHighlight(node, owningWebViewImpl)); |
| 62 } | 63 } |
| 63 | 64 |
| 64 LinkHighlight::LinkHighlight(Node* node, WebViewImpl* owningWebViewImpl) | 65 LinkHighlight::LinkHighlight(Node* node, WebViewImpl* owningWebViewImpl) |
| 65 : m_node(node) | 66 : m_node(node) |
| 66 , m_owningWebViewImpl(owningWebViewImpl) | 67 , m_owningWebViewImpl(owningWebViewImpl) |
| 67 , m_currentGraphicsLayer(0) | 68 , m_currentGraphicsLayer(0) |
| 69 , m_usingNonCompositedContentHost(false) |
| 68 , m_geometryNeedsUpdate(false) | 70 , m_geometryNeedsUpdate(false) |
| 69 , m_isAnimating(false) | 71 , m_isAnimating(false) |
| 70 , m_startTime(monotonicallyIncreasingTime()) | 72 , m_startTime(monotonicallyIncreasingTime()) |
| 71 { | 73 { |
| 72 ASSERT(m_node); | 74 ASSERT(m_node); |
| 73 ASSERT(owningWebViewImpl); | 75 ASSERT(owningWebViewImpl); |
| 74 WebCompositorSupport* compositorSupport = Platform::current()->compositorSup
port(); | 76 WebCompositorSupport* compositorSupport = Platform::current()->compositorSup
port(); |
| 75 m_contentLayer = adoptPtr(compositorSupport->createContentLayer(this)); | 77 m_contentLayer = adoptPtr(compositorSupport->createContentLayer(this)); |
| 76 m_clipLayer = adoptPtr(compositorSupport->createLayer()); | 78 m_clipLayer = adoptPtr(compositorSupport->createLayer()); |
| 77 m_clipLayer->setAnchorPoint(WebFloatPoint()); | 79 m_clipLayer->setAnchorPoint(WebFloatPoint()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 if (!renderer) | 122 if (!renderer) |
| 121 return 0; | 123 return 0; |
| 122 } | 124 } |
| 123 } while (!repaintContainer); | 125 } while (!repaintContainer); |
| 124 RenderLayer* renderLayer = repaintContainer->layer(); | 126 RenderLayer* renderLayer = repaintContainer->layer(); |
| 125 | 127 |
| 126 if (!renderLayer || !renderLayer->isComposited()) | 128 if (!renderLayer || !renderLayer->isComposited()) |
| 127 return 0; | 129 return 0; |
| 128 | 130 |
| 129 GraphicsLayerChromium* newGraphicsLayer = static_cast<GraphicsLayerChromium*
>(renderLayer->backing()->graphicsLayer()); | 131 GraphicsLayerChromium* newGraphicsLayer = static_cast<GraphicsLayerChromium*
>(renderLayer->backing()->graphicsLayer()); |
| 132 m_clipLayer->setSublayerTransform(SkMatrix44()); |
| 133 m_usingNonCompositedContentHost = !newGraphicsLayer->drawsContent(); |
| 134 if (m_usingNonCompositedContentHost ) { |
| 135 m_clipLayer->setSublayerTransform(newGraphicsLayer->platformLayer()->tra
nsform()); |
| 136 newGraphicsLayer = static_cast<GraphicsLayerChromium*>(m_owningWebViewIm
pl->nonCompositedContentHost()->topLevelRootLayer()); |
| 137 } |
| 138 |
| 130 if (m_currentGraphicsLayer != newGraphicsLayer) { | 139 if (m_currentGraphicsLayer != newGraphicsLayer) { |
| 131 if (m_currentGraphicsLayer) | 140 if (m_currentGraphicsLayer) |
| 132 clearGraphicsLayerLinkHighlightPointer(); | 141 clearGraphicsLayerLinkHighlightPointer(); |
| 133 | 142 |
| 134 m_currentGraphicsLayer = newGraphicsLayer; | 143 m_currentGraphicsLayer = newGraphicsLayer; |
| 135 m_currentGraphicsLayer->setLinkHighlight(this); | 144 m_currentGraphicsLayer->setLinkHighlight(this); |
| 136 } | 145 } |
| 137 | 146 |
| 138 return renderLayer; | 147 return renderLayer; |
| 139 } | 148 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 return false; | 190 return false; |
| 182 | 191 |
| 183 ASSERT(compositingLayer); | 192 ASSERT(compositingLayer); |
| 184 | 193 |
| 185 // Get quads for node in absolute coordinates. | 194 // Get quads for node in absolute coordinates. |
| 186 Vector<FloatQuad> quads; | 195 Vector<FloatQuad> quads; |
| 187 m_node->renderer()->absoluteQuads(quads); | 196 m_node->renderer()->absoluteQuads(quads); |
| 188 ASSERT(quads.size()); | 197 ASSERT(quads.size()); |
| 189 | 198 |
| 190 FloatRect positionAdjust; | 199 FloatRect positionAdjust; |
| 191 const RenderStyle* style = m_node->renderer()->style(); | 200 if (!m_usingNonCompositedContentHost) { |
| 192 // If we have a box shadow, and are non-relative, then must manually adjust | 201 const RenderStyle* style = m_node->renderer()->style(); |
| 193 // for its size. | 202 // If we have a box shadow, and are non-relative, then must manually adj
ust |
| 194 if (const ShadowData* shadow = style->boxShadow()) { | 203 // for its size. |
| 195 int outlineSize = m_node->renderer()->outlineStyleForRepaint()->outlineS
ize(); | 204 if (const ShadowData* shadow = style->boxShadow()) { |
| 196 shadow->adjustRectForShadow(positionAdjust, outlineSize); | 205 int outlineSize = m_node->renderer()->outlineStyleForRepaint()->outl
ineSize(); |
| 197 } | 206 shadow->adjustRectForShadow(positionAdjust, outlineSize); |
| 207 } |
| 198 | 208 |
| 199 // If absolute or fixed, need to subtract out our fixed positioning. | 209 // If absolute or fixed, need to subtract out our fixed positioning. |
| 200 // FIXME: should we use RenderLayer::staticBlockPosition() here instead? | 210 // FIXME: should we use RenderLayer::staticBlockPosition() here instead? |
| 201 // Perhaps consider this if out-of-flow elements cause further problems. | 211 // Perhaps consider this if out-of-flow elements cause further problems. |
| 202 if (m_node->renderer()->isOutOfFlowPositioned()) { | 212 if (m_node->renderer()->isOutOfFlowPositioned()) { |
| 203 FloatPoint delta(style->left().getFloatValue(), style->top().getFloatVal
ue()); | 213 FloatPoint delta(style->left().getFloatValue(), style->top().getFloa
tValue()); |
| 204 positionAdjust.moveBy(delta); | 214 positionAdjust.moveBy(delta); |
| 215 } |
| 205 } | 216 } |
| 206 | 217 |
| 207 Path newPath; | 218 Path newPath; |
| 208 for (unsigned quadIndex = 0; quadIndex < quads.size(); ++quadIndex) { | 219 for (unsigned quadIndex = 0; quadIndex < quads.size(); ++quadIndex) { |
| 209 | 220 |
| 210 FloatQuad localQuad = m_node->renderer()->absoluteToLocalQuad(quads[quad
Index], UseTransforms); | 221 FloatQuad localQuad = m_node->renderer()->absoluteToLocalQuad(quads[quad
Index], UseTransforms); |
| 211 localQuad.move(-positionAdjust.location().x(), -positionAdjust.location(
).y()); | 222 localQuad.move(-positionAdjust.location().x(), -positionAdjust.location(
).y()); |
| 212 FloatQuad absoluteQuad = m_node->renderer()->localToAbsoluteQuad(localQu
ad, UseTransforms); | 223 FloatQuad absoluteQuad = m_node->renderer()->localToAbsoluteQuad(localQu
ad, UseTransforms); |
| 213 | 224 |
| 214 // Transform node quads in target absolute coords to local coordinates i
n the compositor layer. | 225 // Transform node quads in target absolute coords to local coordinates i
n the compositor layer. |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 // Make sure we update geometry on the next callback from WebViewImpl::layou
t(). | 351 // Make sure we update geometry on the next callback from WebViewImpl::layou
t(). |
| 341 m_geometryNeedsUpdate = true; | 352 m_geometryNeedsUpdate = true; |
| 342 } | 353 } |
| 343 | 354 |
| 344 WebLayer* LinkHighlight::layer() | 355 WebLayer* LinkHighlight::layer() |
| 345 { | 356 { |
| 346 return clipLayer(); | 357 return clipLayer(); |
| 347 } | 358 } |
| 348 | 359 |
| 349 } // namespace WeKit | 360 } // namespace WeKit |
| OLD | NEW |