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 11 matching lines...) Expand all Loading... |
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 "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/frame/FrameView.h" | 33 #include "core/frame/FrameView.h" |
33 #include "core/frame/LocalFrame.h" | 34 #include "core/frame/LocalFrame.h" |
34 #include "core/rendering/RenderLayer.h" | 35 #include "core/rendering/RenderLayer.h" |
35 #include "core/rendering/RenderLayerModelObject.h" | 36 #include "core/rendering/RenderLayerModelObject.h" |
36 #include "core/rendering/RenderObject.h" | 37 #include "core/rendering/RenderObject.h" |
37 #include "core/rendering/RenderPart.h" | 38 #include "core/rendering/RenderPart.h" |
38 #include "core/rendering/RenderView.h" | 39 #include "core/rendering/RenderView.h" |
39 #include "core/rendering/compositing/CompositedLayerMapping.h" | 40 #include "core/rendering/compositing/CompositedLayerMapping.h" |
40 #include "core/rendering/style/ShadowData.h" | 41 #include "core/rendering/style/ShadowData.h" |
41 #include "platform/graphics/Color.h" | 42 #include "platform/graphics/Color.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 static void addQuadToPath(const FloatQuad& quad, Path& path) | 174 static void addQuadToPath(const FloatQuad& quad, Path& path) |
174 { | 175 { |
175 // FIXME: Make this create rounded quad-paths, just like the axis-aligned ca
se. | 176 // FIXME: Make this create rounded quad-paths, just like the axis-aligned ca
se. |
176 path.moveTo(quad.p1()); | 177 path.moveTo(quad.p1()); |
177 path.addLineTo(quad.p2()); | 178 path.addLineTo(quad.p2()); |
178 path.addLineTo(quad.p3()); | 179 path.addLineTo(quad.p3()); |
179 path.addLineTo(quad.p4()); | 180 path.addLineTo(quad.p4()); |
180 path.closeSubpath(); | 181 path.closeSubpath(); |
181 } | 182 } |
182 | 183 |
183 void LinkHighlight::computeQuads(RenderObject& renderer, Vector<FloatQuad>& outQ
uads) const | 184 void LinkHighlight::computeQuads(const Node& node, Vector<FloatQuad>& outQuads)
const |
184 { | 185 { |
| 186 if (!node.renderer()) |
| 187 return; |
| 188 |
| 189 RenderObject* renderer = node.renderer(); |
| 190 |
185 // For inline elements, absoluteQuads will return a line box based on the li
ne-height | 191 // For inline elements, absoluteQuads will return a line box based on the li
ne-height |
186 // and font metrics, which is technically incorrect as replaced elements lik
e images | 192 // and font metrics, which is technically incorrect as replaced elements lik
e images |
187 // should use their intristic height and expand the linebox as needed. To g
et an | 193 // should use their intristic height and expand the linebox as needed. To g
et an |
188 // appropriately sized highlight we descend into the children and have them
add their | 194 // appropriately sized highlight we descend into the children and have them
add their |
189 // boxes. | 195 // boxes. |
190 if (renderer.isRenderInline()) { | 196 if (renderer->isRenderInline()) { |
191 for (RenderObject* child = renderer.slowFirstChild(); child; child = chi
ld->nextSibling()) | 197 for (Node* child = NodeRenderingTraversal::firstChild(&node); child; chi
ld = NodeRenderingTraversal::nextSibling(child)) |
192 computeQuads(*child, outQuads); | 198 computeQuads(*child, outQuads); |
193 } else { | 199 } else { |
194 renderer.absoluteQuads(outQuads); | 200 renderer->absoluteQuads(outQuads); |
195 } | 201 } |
196 } | 202 } |
197 | 203 |
198 bool LinkHighlight::computeHighlightLayerPathAndPosition(RenderLayer* compositin
gLayer) | 204 bool LinkHighlight::computeHighlightLayerPathAndPosition(RenderLayer* compositin
gLayer) |
199 { | 205 { |
200 if (!m_node || !m_node->renderer() || !m_currentGraphicsLayer) | 206 if (!m_node || !m_node->renderer() || !m_currentGraphicsLayer) |
201 return false; | 207 return false; |
202 | 208 |
203 ASSERT(compositingLayer); | 209 ASSERT(compositingLayer); |
204 | 210 |
205 // Get quads for node in absolute coordinates. | 211 // Get quads for node in absolute coordinates. |
206 Vector<FloatQuad> quads; | 212 Vector<FloatQuad> quads; |
207 computeQuads(*m_node->renderer(), quads); | 213 computeQuads(*m_node, quads); |
208 ASSERT(quads.size()); | 214 ASSERT(quads.size()); |
209 | 215 |
210 // Adjust for offset between target graphics layer and the node's renderer. | 216 // Adjust for offset between target graphics layer and the node's renderer. |
211 FloatPoint positionAdjust = IntPoint(m_currentGraphicsLayer->offsetFromRende
rer()); | 217 FloatPoint positionAdjust = IntPoint(m_currentGraphicsLayer->offsetFromRende
rer()); |
212 | 218 |
213 Path newPath; | 219 Path newPath; |
214 for (size_t quadIndex = 0; quadIndex < quads.size(); ++quadIndex) { | 220 for (size_t quadIndex = 0; quadIndex < quads.size(); ++quadIndex) { |
215 FloatQuad absoluteQuad = quads[quadIndex]; | 221 FloatQuad absoluteQuad = quads[quadIndex]; |
216 absoluteQuad.move(-positionAdjust.x(), -positionAdjust.y()); | 222 absoluteQuad.move(-positionAdjust.x(), -positionAdjust.y()); |
217 | 223 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 // Make sure we update geometry on the next callback from WebViewImpl::layou
t(). | 358 // Make sure we update geometry on the next callback from WebViewImpl::layou
t(). |
353 m_geometryNeedsUpdate = true; | 359 m_geometryNeedsUpdate = true; |
354 } | 360 } |
355 | 361 |
356 WebLayer* LinkHighlight::layer() | 362 WebLayer* LinkHighlight::layer() |
357 { | 363 { |
358 return clipLayer(); | 364 return clipLayer(); |
359 } | 365 } |
360 | 366 |
361 } // namespace blink | 367 } // namespace blink |
OLD | NEW |