Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(678)

Side by Side Diff: Source/web/LinkHighlight.cpp

Issue 448593002: Make Gesture Tap be aware of Shadow DOM. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Use useMockHighlight() Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/web/LinkHighlight.h ('k') | Source/web/WebViewImpl.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 static void addQuadToPath(const FloatQuad& quad, Path& path) 172 static void addQuadToPath(const FloatQuad& quad, Path& path)
173 { 173 {
174 // FIXME: Make this create rounded quad-paths, just like the axis-aligned ca se. 174 // FIXME: Make this create rounded quad-paths, just like the axis-aligned ca se.
175 path.moveTo(quad.p1()); 175 path.moveTo(quad.p1());
176 path.addLineTo(quad.p2()); 176 path.addLineTo(quad.p2());
177 path.addLineTo(quad.p3()); 177 path.addLineTo(quad.p3());
178 path.addLineTo(quad.p4()); 178 path.addLineTo(quad.p4());
179 path.closeSubpath(); 179 path.closeSubpath();
180 } 180 }
181 181
182 void LinkHighlight::computeQuads(Node* node, Vector<FloatQuad>& outQuads) const 182 void LinkHighlight::computeQuads(RenderObject& renderer, Vector<FloatQuad>& outQ uads) const
183 { 183 {
184 if (!node || !node->renderer())
185 return;
186
187 RenderObject* renderer = node->renderer();
188
189 // For inline elements, absoluteQuads will return a line box based on the li ne-height 184 // For inline elements, absoluteQuads will return a line box based on the li ne-height
190 // and font metrics, which is technically incorrect as replaced elements lik e images 185 // and font metrics, which is technically incorrect as replaced elements lik e images
191 // should use their intristic height and expand the linebox as needed. To g et an 186 // should use their intristic height and expand the linebox as needed. To g et an
192 // appropriately sized highlight we descend into the children and have them add their 187 // appropriately sized highlight we descend into the children and have them add their
193 // boxes. 188 // boxes.
194 if (renderer->isRenderInline()) { 189 if (renderer.isRenderInline()) {
195 for (Node* child = node->firstChild(); child; child = child->nextSibling ()) 190 for (RenderObject* child = renderer.slowFirstChild(); child; child = chi ld->nextSibling())
196 computeQuads(child, outQuads); 191 computeQuads(*child, outQuads);
197 } else { 192 } else {
198 renderer->absoluteQuads(outQuads); 193 renderer.absoluteQuads(outQuads);
199 } 194 }
200
201 } 195 }
202 196
203 bool LinkHighlight::computeHighlightLayerPathAndPosition(RenderLayer* compositin gLayer) 197 bool LinkHighlight::computeHighlightLayerPathAndPosition(RenderLayer* compositin gLayer)
204 { 198 {
205 if (!m_node || !m_node->renderer() || !m_currentGraphicsLayer) 199 if (!m_node || !m_node->renderer() || !m_currentGraphicsLayer)
206 return false; 200 return false;
207 201
208 ASSERT(compositingLayer); 202 ASSERT(compositingLayer);
209 203
210 // Get quads for node in absolute coordinates. 204 // Get quads for node in absolute coordinates.
211 Vector<FloatQuad> quads; 205 Vector<FloatQuad> quads;
212 computeQuads(m_node.get(), quads); 206 computeQuads(*m_node->renderer(), quads);
213 ASSERT(quads.size()); 207 ASSERT(quads.size());
214 208
215 // Adjust for offset between target graphics layer and the node's renderer. 209 // Adjust for offset between target graphics layer and the node's renderer.
216 FloatPoint positionAdjust = IntPoint(m_currentGraphicsLayer->offsetFromRende rer()); 210 FloatPoint positionAdjust = IntPoint(m_currentGraphicsLayer->offsetFromRende rer());
217 211
218 Path newPath; 212 Path newPath;
219 for (size_t quadIndex = 0; quadIndex < quads.size(); ++quadIndex) { 213 for (size_t quadIndex = 0; quadIndex < quads.size(); ++quadIndex) {
220 FloatQuad absoluteQuad = quads[quadIndex]; 214 FloatQuad absoluteQuad = quads[quadIndex];
221 absoluteQuad.move(-positionAdjust.x(), -positionAdjust.y()); 215 absoluteQuad.move(-positionAdjust.x(), -positionAdjust.y());
222 216
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 // Make sure we update geometry on the next callback from WebViewImpl::layou t(). 346 // Make sure we update geometry on the next callback from WebViewImpl::layou t().
353 m_geometryNeedsUpdate = true; 347 m_geometryNeedsUpdate = true;
354 } 348 }
355 349
356 WebLayer* LinkHighlight::layer() 350 WebLayer* LinkHighlight::layer()
357 { 351 {
358 return clipLayer(); 352 return clipLayer();
359 } 353 }
360 354
361 } // namespace blink 355 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/LinkHighlight.h ('k') | Source/web/WebViewImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698