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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "core/rendering/style/ShadowData.h" | 42 #include "core/rendering/style/ShadowData.h" |
43 #include "platform/graphics/Color.h" | 43 #include "platform/graphics/Color.h" |
44 #include "public/platform/Platform.h" | 44 #include "public/platform/Platform.h" |
45 #include "public/platform/WebAnimationCurve.h" | 45 #include "public/platform/WebAnimationCurve.h" |
46 #include "public/platform/WebCompositorSupport.h" | 46 #include "public/platform/WebCompositorSupport.h" |
47 #include "public/platform/WebFloatAnimationCurve.h" | 47 #include "public/platform/WebFloatAnimationCurve.h" |
48 #include "public/platform/WebFloatPoint.h" | 48 #include "public/platform/WebFloatPoint.h" |
49 #include "public/platform/WebRect.h" | 49 #include "public/platform/WebRect.h" |
50 #include "public/platform/WebSize.h" | 50 #include "public/platform/WebSize.h" |
51 #include "wtf/CurrentTime.h" | 51 #include "wtf/CurrentTime.h" |
| 52 #include "wtf/Vector.h" |
52 | 53 |
53 using namespace WebCore; | 54 using namespace WebCore; |
54 | 55 |
55 namespace blink { | 56 namespace blink { |
56 | 57 |
57 class WebViewImpl; | 58 class WebViewImpl; |
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)); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 static void addQuadToPath(const FloatQuad& quad, Path& path) | 178 static void addQuadToPath(const FloatQuad& quad, Path& path) |
178 { | 179 { |
179 // FIXME: Make this create rounded quad-paths, just like the axis-aligned ca
se. | 180 // FIXME: Make this create rounded quad-paths, just like the axis-aligned ca
se. |
180 path.moveTo(quad.p1()); | 181 path.moveTo(quad.p1()); |
181 path.addLineTo(quad.p2()); | 182 path.addLineTo(quad.p2()); |
182 path.addLineTo(quad.p3()); | 183 path.addLineTo(quad.p3()); |
183 path.addLineTo(quad.p4()); | 184 path.addLineTo(quad.p4()); |
184 path.closeSubpath(); | 185 path.closeSubpath(); |
185 } | 186 } |
186 | 187 |
| 188 void LinkHighlight::computeQuads(Node* node, Vector<FloatQuad>& outQuads) const |
| 189 { |
| 190 if (!node || !node->renderer()) |
| 191 return; |
| 192 |
| 193 RenderObject* renderer = node->renderer(); |
| 194 |
| 195 // For inline elements, absoluteQuads will return a line box based on the li
ne-height |
| 196 // and font metrics, which is technically incorrect as replaced elements lik
e images |
| 197 // should use their intristic height and expand the linebox as needed. To g
et an |
| 198 // appropriately sized highlight we descend into the children and have them
add their |
| 199 // boxes. |
| 200 if (renderer->isRenderInline()) { |
| 201 for (Node* child = node->firstChild(); child; child = child->nextSibling
()) |
| 202 computeQuads(child, outQuads); |
| 203 } else { |
| 204 renderer->absoluteQuads(outQuads); |
| 205 } |
| 206 |
| 207 } |
| 208 |
187 bool LinkHighlight::computeHighlightLayerPathAndPosition(RenderLayer* compositin
gLayer) | 209 bool LinkHighlight::computeHighlightLayerPathAndPosition(RenderLayer* compositin
gLayer) |
188 { | 210 { |
189 if (!m_node || !m_node->renderer() || !m_currentGraphicsLayer) | 211 if (!m_node || !m_node->renderer() || !m_currentGraphicsLayer) |
190 return false; | 212 return false; |
191 | 213 |
192 ASSERT(compositingLayer); | 214 ASSERT(compositingLayer); |
193 | 215 |
194 // Get quads for node in absolute coordinates. | 216 // Get quads for node in absolute coordinates. |
195 Vector<FloatQuad> quads; | 217 Vector<FloatQuad> quads; |
196 m_node->renderer()->absoluteQuads(quads); | 218 computeQuads(m_node.get(), quads); |
197 ASSERT(quads.size()); | 219 ASSERT(quads.size()); |
198 | 220 |
199 // Adjust for offset between target graphics layer and the node's renderer. | 221 // Adjust for offset between target graphics layer and the node's renderer. |
200 FloatPoint positionAdjust = IntPoint(m_currentGraphicsLayer->offsetFromRende
rer()); | 222 FloatPoint positionAdjust = IntPoint(m_currentGraphicsLayer->offsetFromRende
rer()); |
201 | 223 |
202 Path newPath; | 224 Path newPath; |
203 for (unsigned quadIndex = 0; quadIndex < quads.size(); ++quadIndex) { | 225 for (size_t quadIndex = 0; quadIndex < quads.size(); ++quadIndex) { |
204 FloatQuad absoluteQuad = quads[quadIndex]; | 226 FloatQuad absoluteQuad = quads[quadIndex]; |
205 absoluteQuad.move(-positionAdjust.x(), -positionAdjust.y()); | 227 absoluteQuad.move(-positionAdjust.x(), -positionAdjust.y()); |
206 | 228 |
207 // Transform node quads in target absolute coords to local coordinates i
n the compositor layer. | 229 // Transform node quads in target absolute coords to local coordinates i
n the compositor layer. |
208 FloatQuad transformedQuad; | 230 FloatQuad transformedQuad; |
209 convertTargetSpaceQuadToCompositedLayer(absoluteQuad, m_node->renderer()
, compositingLayer->renderer(), transformedQuad); | 231 convertTargetSpaceQuadToCompositedLayer(absoluteQuad, m_node->renderer()
, compositingLayer->renderer(), transformedQuad); |
210 | 232 |
211 // FIXME: for now, we'll only use rounded paths if we have a single node
quad. The reason for this is that | 233 // FIXME: for now, we'll only use rounded paths if we have a single node
quad. The reason for this is that |
212 // we may sometimes get a chain of adjacent boxes (e.g. for text nodes)
which end up looking like sausage | 234 // we may sometimes get a chain of adjacent boxes (e.g. for text nodes)
which end up looking like sausage |
213 // links: these should ideally be merged into a single rect before creat
ing the path, but that's | 235 // links: these should ideally be merged into a single rect before creat
ing the path, but that's |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 // Make sure we update geometry on the next callback from WebViewImpl::layou
t(). | 355 // Make sure we update geometry on the next callback from WebViewImpl::layou
t(). |
334 m_geometryNeedsUpdate = true; | 356 m_geometryNeedsUpdate = true; |
335 } | 357 } |
336 | 358 |
337 WebLayer* LinkHighlight::layer() | 359 WebLayer* LinkHighlight::layer() |
338 { | 360 { |
339 return clipLayer(); | 361 return clipLayer(); |
340 } | 362 } |
341 | 363 |
342 } // namespace WeKit | 364 } // namespace WeKit |
OLD | NEW |