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

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: Update LinkHighlight 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
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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 static void addQuadToPath(const FloatQuad& quad, Path& path) 173 static void addQuadToPath(const FloatQuad& quad, Path& path)
174 { 174 {
175 // FIXME: Make this create rounded quad-paths, just like the axis-aligned ca se. 175 // FIXME: Make this create rounded quad-paths, just like the axis-aligned ca se.
176 path.moveTo(quad.p1()); 176 path.moveTo(quad.p1());
177 path.addLineTo(quad.p2()); 177 path.addLineTo(quad.p2());
178 path.addLineTo(quad.p3()); 178 path.addLineTo(quad.p3());
179 path.addLineTo(quad.p4()); 179 path.addLineTo(quad.p4());
180 path.closeSubpath(); 180 path.closeSubpath();
181 } 181 }
182 182
183 void LinkHighlight::computeQuads(Node* node, Vector<FloatQuad>& outQuads) const 183 void LinkHighlight::computeQuads(RenderObject& renderer, Vector<FloatQuad>& outQ uads) const
184 { 184 {
185 if (!node || !node->renderer())
186 return;
187
188 RenderObject* renderer = node->renderer();
189
190 // For inline elements, absoluteQuads will return a line box based on the li ne-height 185 // For inline elements, absoluteQuads will return a line box based on the li ne-height
191 // and font metrics, which is technically incorrect as replaced elements lik e images 186 // and font metrics, which is technically incorrect as replaced elements lik e images
192 // should use their intristic height and expand the linebox as needed. To g et an 187 // should use their intristic height and expand the linebox as needed. To g et an
193 // appropriately sized highlight we descend into the children and have them add their 188 // appropriately sized highlight we descend into the children and have them add their
194 // boxes. 189 // boxes.
195 if (renderer->isRenderInline()) { 190 if (renderer.isRenderInline()) {
196 for (Node* child = node->firstChild(); child; child = child->nextSibling ()) 191 for (RenderObject* child = renderer.slowFirstChild(); child; child = chi ld->nextSibling())
197 computeQuads(child, outQuads); 192 computeQuads(*child, outQuads);
198 } else { 193 } else {
199 renderer->absoluteQuads(outQuads); 194 renderer.absoluteQuads(outQuads);
200 } 195 }
201
202 } 196 }
203 197
204 bool LinkHighlight::computeHighlightLayerPathAndPosition(RenderLayer* compositin gLayer) 198 bool LinkHighlight::computeHighlightLayerPathAndPosition(RenderLayer* compositin gLayer)
205 { 199 {
206 if (!m_node || !m_node->renderer() || !m_currentGraphicsLayer) 200 if (!m_node || !m_node->renderer() || !m_currentGraphicsLayer)
207 return false; 201 return false;
208 202
209 ASSERT(compositingLayer); 203 ASSERT(compositingLayer);
210 204
211 // Get quads for node in absolute coordinates. 205 // Get quads for node in absolute coordinates.
212 Vector<FloatQuad> quads; 206 Vector<FloatQuad> quads;
213 computeQuads(m_node.get(), quads); 207 computeQuads(*m_node->renderer(), quads);
214 ASSERT(quads.size()); 208 ASSERT(quads.size());
215 209
216 // Adjust for offset between target graphics layer and the node's renderer. 210 // Adjust for offset between target graphics layer and the node's renderer.
217 FloatPoint positionAdjust = IntPoint(m_currentGraphicsLayer->offsetFromRende rer()); 211 FloatPoint positionAdjust = IntPoint(m_currentGraphicsLayer->offsetFromRende rer());
218 212
219 Path newPath; 213 Path newPath;
220 for (size_t quadIndex = 0; quadIndex < quads.size(); ++quadIndex) { 214 for (size_t quadIndex = 0; quadIndex < quads.size(); ++quadIndex) {
221 FloatQuad absoluteQuad = quads[quadIndex]; 215 FloatQuad absoluteQuad = quads[quadIndex];
222 absoluteQuad.move(-positionAdjust.x(), -positionAdjust.y()); 216 absoluteQuad.move(-positionAdjust.x(), -positionAdjust.y());
223 217
(...skipping 128 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 WeKit 355 } // namespace WeKit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698