| 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" | |
| 31 #include "SkMatrix44.h" | 30 #include "SkMatrix44.h" |
| 32 #include "WebFrameImpl.h" | 31 #include "WebFrameImpl.h" |
| 33 #include "WebKit.h" | 32 #include "WebKit.h" |
| 34 #include "WebViewImpl.h" | 33 #include "WebViewImpl.h" |
| 35 #include "core/dom/Node.h" | 34 #include "core/dom/Node.h" |
| 36 #include "core/page/Frame.h" | 35 #include "core/page/Frame.h" |
| 37 #include "core/page/FrameView.h" | 36 #include "core/page/FrameView.h" |
| 38 #include "core/platform/graphics/Color.h" | 37 #include "core/platform/graphics/Color.h" |
| 39 #include "core/rendering/RenderLayer.h" | 38 #include "core/rendering/RenderLayer.h" |
| 40 #include "core/rendering/RenderLayerBacking.h" | 39 #include "core/rendering/RenderLayerBacking.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 59 | 58 |
| 60 PassOwnPtr<LinkHighlight> LinkHighlight::create(Node* node, WebViewImpl* owningW
ebViewImpl) | 59 PassOwnPtr<LinkHighlight> LinkHighlight::create(Node* node, WebViewImpl* owningW
ebViewImpl) |
| 61 { | 60 { |
| 62 return adoptPtr(new LinkHighlight(node, owningWebViewImpl)); | 61 return adoptPtr(new LinkHighlight(node, owningWebViewImpl)); |
| 63 } | 62 } |
| 64 | 63 |
| 65 LinkHighlight::LinkHighlight(Node* node, WebViewImpl* owningWebViewImpl) | 64 LinkHighlight::LinkHighlight(Node* node, WebViewImpl* owningWebViewImpl) |
| 66 : m_node(node) | 65 : m_node(node) |
| 67 , m_owningWebViewImpl(owningWebViewImpl) | 66 , m_owningWebViewImpl(owningWebViewImpl) |
| 68 , m_currentGraphicsLayer(0) | 67 , m_currentGraphicsLayer(0) |
| 69 , m_usingNonCompositedContentHost(false) | |
| 70 , m_geometryNeedsUpdate(false) | 68 , m_geometryNeedsUpdate(false) |
| 71 , m_isAnimating(false) | 69 , m_isAnimating(false) |
| 72 , m_startTime(monotonicallyIncreasingTime()) | 70 , m_startTime(monotonicallyIncreasingTime()) |
| 73 { | 71 { |
| 74 ASSERT(m_node); | 72 ASSERT(m_node); |
| 75 ASSERT(owningWebViewImpl); | 73 ASSERT(owningWebViewImpl); |
| 76 WebCompositorSupport* compositorSupport = Platform::current()->compositorSup
port(); | 74 WebCompositorSupport* compositorSupport = Platform::current()->compositorSup
port(); |
| 77 m_contentLayer = adoptPtr(compositorSupport->createContentLayer(this)); | 75 m_contentLayer = adoptPtr(compositorSupport->createContentLayer(this)); |
| 78 m_clipLayer = adoptPtr(compositorSupport->createLayer()); | 76 m_clipLayer = adoptPtr(compositorSupport->createLayer()); |
| 79 m_clipLayer->setAnchorPoint(WebFloatPoint()); | 77 m_clipLayer->setAnchorPoint(WebFloatPoint()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 if (!renderer) | 120 if (!renderer) |
| 123 return 0; | 121 return 0; |
| 124 } | 122 } |
| 125 } while (!repaintContainer); | 123 } while (!repaintContainer); |
| 126 RenderLayer* renderLayer = repaintContainer->layer(); | 124 RenderLayer* renderLayer = repaintContainer->layer(); |
| 127 | 125 |
| 128 if (!renderLayer || !renderLayer->isComposited()) | 126 if (!renderLayer || !renderLayer->isComposited()) |
| 129 return 0; | 127 return 0; |
| 130 | 128 |
| 131 GraphicsLayerChromium* newGraphicsLayer = static_cast<GraphicsLayerChromium*
>(renderLayer->backing()->graphicsLayer()); | 129 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 | |
| 139 if (m_currentGraphicsLayer != newGraphicsLayer) { | 130 if (m_currentGraphicsLayer != newGraphicsLayer) { |
| 140 if (m_currentGraphicsLayer) | 131 if (m_currentGraphicsLayer) |
| 141 clearGraphicsLayerLinkHighlightPointer(); | 132 clearGraphicsLayerLinkHighlightPointer(); |
| 142 | 133 |
| 143 m_currentGraphicsLayer = newGraphicsLayer; | 134 m_currentGraphicsLayer = newGraphicsLayer; |
| 144 m_currentGraphicsLayer->setLinkHighlight(this); | 135 m_currentGraphicsLayer->setLinkHighlight(this); |
| 145 } | 136 } |
| 146 | 137 |
| 147 return renderLayer; | 138 return renderLayer; |
| 148 } | 139 } |
| 149 | 140 |
| 150 static void convertTargetSpaceQuadToCompositedLayer(const FloatQuad& targetSpace
Quad, RenderObject* targetRenderer, RenderObject* compositedRenderer, FloatQuad&
compositedSpaceQuad) | 141 static void convertTargetSpaceQuadToCompositedLayer(const FloatQuad& targetSpace
Quad, RenderObject* targetRenderer, RenderLayer* compositedLayer, FloatQuad& com
positedSpaceQuad) |
| 151 { | 142 { |
| 152 ASSERT(targetRenderer); | 143 ASSERT(targetRenderer); |
| 153 ASSERT(compositedRenderer); | 144 ASSERT(compositedLayer); |
| 145 RenderLayerModelObject* compositedRenderer = compositedLayer->renderer(); |
| 154 | 146 |
| 155 for (unsigned i = 0; i < 4; ++i) { | 147 for (unsigned i = 0; i < 4; ++i) { |
| 156 IntPoint point; | 148 IntPoint point; |
| 157 switch (i) { | 149 switch (i) { |
| 158 case 0: point = roundedIntPoint(targetSpaceQuad.p1()); break; | 150 case 0: point = roundedIntPoint(targetSpaceQuad.p1()); break; |
| 159 case 1: point = roundedIntPoint(targetSpaceQuad.p2()); break; | 151 case 1: point = roundedIntPoint(targetSpaceQuad.p2()); break; |
| 160 case 2: point = roundedIntPoint(targetSpaceQuad.p3()); break; | 152 case 2: point = roundedIntPoint(targetSpaceQuad.p3()); break; |
| 161 case 3: point = roundedIntPoint(targetSpaceQuad.p4()); break; | 153 case 3: point = roundedIntPoint(targetSpaceQuad.p4()); break; |
| 162 } | 154 } |
| 163 | 155 |
| 164 point = targetRenderer->frame()->view()->contentsToWindow(point); | 156 point = targetRenderer->frame()->view()->contentsToWindow(point); |
| 165 point = compositedRenderer->frame()->view()->windowToContents(point); | 157 point = compositedRenderer->frame()->view()->windowToContents(point); |
| 166 FloatPoint floatPoint = compositedRenderer->absoluteToLocal(point, UseTr
ansforms); | 158 FloatPoint floatPoint = compositedRenderer->absoluteToLocal(point, UseTr
ansforms); |
| 159 floatPoint.moveBy(-compositedLayer->backing()->compositedBounds().locati
on()); |
| 167 | 160 |
| 168 switch (i) { | 161 switch (i) { |
| 169 case 0: compositedSpaceQuad.setP1(floatPoint); break; | 162 case 0: compositedSpaceQuad.setP1(floatPoint); break; |
| 170 case 1: compositedSpaceQuad.setP2(floatPoint); break; | 163 case 1: compositedSpaceQuad.setP2(floatPoint); break; |
| 171 case 2: compositedSpaceQuad.setP3(floatPoint); break; | 164 case 2: compositedSpaceQuad.setP3(floatPoint); break; |
| 172 case 3: compositedSpaceQuad.setP4(floatPoint); break; | 165 case 3: compositedSpaceQuad.setP4(floatPoint); break; |
| 173 } | 166 } |
| 174 } | 167 } |
| 175 } | 168 } |
| 176 | 169 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 189 if (!m_node || !m_node->renderer()) | 182 if (!m_node || !m_node->renderer()) |
| 190 return false; | 183 return false; |
| 191 | 184 |
| 192 ASSERT(compositingLayer); | 185 ASSERT(compositingLayer); |
| 193 | 186 |
| 194 // Get quads for node in absolute coordinates. | 187 // Get quads for node in absolute coordinates. |
| 195 Vector<FloatQuad> quads; | 188 Vector<FloatQuad> quads; |
| 196 m_node->renderer()->absoluteQuads(quads); | 189 m_node->renderer()->absoluteQuads(quads); |
| 197 ASSERT(quads.size()); | 190 ASSERT(quads.size()); |
| 198 | 191 |
| 199 FloatRect positionAdjust; | |
| 200 if (!m_usingNonCompositedContentHost) { | |
| 201 const RenderStyle* style = m_node->renderer()->style(); | |
| 202 // If we have a box shadow, and are non-relative, then must manually adj
ust | |
| 203 // for its size. | |
| 204 if (const ShadowData* shadow = style->boxShadow()) { | |
| 205 int outlineSize = m_node->renderer()->outlineStyleForRepaint()->outl
ineSize(); | |
| 206 shadow->adjustRectForShadow(positionAdjust, outlineSize); | |
| 207 } | |
| 208 | |
| 209 // If absolute or fixed, need to subtract out our fixed positioning. | |
| 210 // FIXME: should we use RenderLayer::staticBlockPosition() here instead? | |
| 211 // Perhaps consider this if out-of-flow elements cause further problems. | |
| 212 if (m_node->renderer()->isOutOfFlowPositioned()) { | |
| 213 FloatPoint delta(style->left().getFloatValue(), style->top().getFloa
tValue()); | |
| 214 positionAdjust.moveBy(delta); | |
| 215 } | |
| 216 } | |
| 217 | |
| 218 Path newPath; | 192 Path newPath; |
| 219 for (unsigned quadIndex = 0; quadIndex < quads.size(); ++quadIndex) { | 193 for (unsigned quadIndex = 0; quadIndex < quads.size(); ++quadIndex) { |
| 220 | |
| 221 FloatQuad localQuad = m_node->renderer()->absoluteToLocalQuad(quads[quad
Index], UseTransforms); | |
| 222 localQuad.move(-positionAdjust.location().x(), -positionAdjust.location(
).y()); | |
| 223 FloatQuad absoluteQuad = m_node->renderer()->localToAbsoluteQuad(localQu
ad, UseTransforms); | |
| 224 | |
| 225 // Transform node quads in target absolute coords to local coordinates i
n the compositor layer. | 194 // Transform node quads in target absolute coords to local coordinates i
n the compositor layer. |
| 226 FloatQuad transformedQuad; | 195 FloatQuad transformedQuad; |
| 227 convertTargetSpaceQuadToCompositedLayer(absoluteQuad, m_node->renderer()
, compositingLayer->renderer(), transformedQuad); | 196 convertTargetSpaceQuadToCompositedLayer(quads[quadIndex], m_node->render
er(), compositingLayer, transformedQuad); |
| 228 | 197 |
| 229 // FIXME: for now, we'll only use rounded paths if we have a single node
quad. The reason for this is that | 198 // FIXME: for now, we'll only use rounded paths if we have a single node
quad. The reason for this is that |
| 230 // we may sometimes get a chain of adjacent boxes (e.g. for text nodes)
which end up looking like sausage | 199 // we may sometimes get a chain of adjacent boxes (e.g. for text nodes)
which end up looking like sausage |
| 231 // links: these should ideally be merged into a single rect before creat
ing the path, but that's | 200 // links: these should ideally be merged into a single rect before creat
ing the path, but that's |
| 232 // another CL. | 201 // another CL. |
| 233 if (quads.size() == 1 && transformedQuad.isRectilinear()) { | 202 if (quads.size() == 1 && transformedQuad.isRectilinear()) { |
| 234 FloatSize rectRoundingRadii(3, 3); | 203 FloatSize rectRoundingRadii(3, 3); |
| 235 newPath.addRoundedRect(transformedQuad.boundingBox(), rectRoundingRa
dii); | 204 newPath.addRoundedRect(transformedQuad.boundingBox(), rectRoundingRa
dii); |
| 236 } else | 205 } else |
| 237 addQuadToPath(transformedQuad, newPath); | 206 addQuadToPath(transformedQuad, newPath); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 // Make sure we update geometry on the next callback from WebViewImpl::layou
t(). | 320 // Make sure we update geometry on the next callback from WebViewImpl::layou
t(). |
| 352 m_geometryNeedsUpdate = true; | 321 m_geometryNeedsUpdate = true; |
| 353 } | 322 } |
| 354 | 323 |
| 355 WebLayer* LinkHighlight::layer() | 324 WebLayer* LinkHighlight::layer() |
| 356 { | 325 { |
| 357 return clipLayer(); | 326 return clipLayer(); |
| 358 } | 327 } |
| 359 | 328 |
| 360 } // namespace WeKit | 329 } // namespace WeKit |
| OLD | NEW |