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

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

Issue 977113003: Rename renderer() to layoutObject(). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 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/FrameLoaderClientImpl.cpp ('k') | Source/web/PopupMenuTest.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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 // FIXME: Make this create rounded quad-paths, just like the axis-aligned ca se. 159 // FIXME: Make this create rounded quad-paths, just like the axis-aligned ca se.
160 path.moveTo(quad.p1()); 160 path.moveTo(quad.p1());
161 path.addLineTo(quad.p2()); 161 path.addLineTo(quad.p2());
162 path.addLineTo(quad.p3()); 162 path.addLineTo(quad.p3());
163 path.addLineTo(quad.p4()); 163 path.addLineTo(quad.p4());
164 path.closeSubpath(); 164 path.closeSubpath();
165 } 165 }
166 166
167 void LinkHighlight::computeQuads(const Node& node, Vector<FloatQuad>& outQuads) const 167 void LinkHighlight::computeQuads(const Node& node, Vector<FloatQuad>& outQuads) const
168 { 168 {
169 if (!node.renderer()) 169 if (!node.layoutObject())
170 return; 170 return;
171 171
172 LayoutObject* renderer = node.renderer(); 172 LayoutObject* renderer = node.layoutObject();
173 173
174 // For inline elements, absoluteQuads will return a line box based on the li ne-height 174 // For inline elements, absoluteQuads will return a line box based on the li ne-height
175 // and font metrics, which is technically incorrect as replaced elements lik e images 175 // and font metrics, which is technically incorrect as replaced elements lik e images
176 // should use their intristic height and expand the linebox as needed. To g et an 176 // should use their intristic height and expand the linebox as needed. To g et an
177 // appropriately sized highlight we descend into the children and have them add their 177 // appropriately sized highlight we descend into the children and have them add their
178 // boxes. 178 // boxes.
179 if (renderer->isLayoutInline()) { 179 if (renderer->isLayoutInline()) {
180 for (Node* child = NodeRenderingTraversal::firstChild(node); child; chil d = NodeRenderingTraversal::nextSibling(*child)) 180 for (Node* child = NodeRenderingTraversal::firstChild(node); child; chil d = NodeRenderingTraversal::nextSibling(*child))
181 computeQuads(*child, outQuads); 181 computeQuads(*child, outQuads);
182 } else { 182 } else {
183 // FIXME: this does not need to be absolute, just in the paint invalidat ion container's space. 183 // FIXME: this does not need to be absolute, just in the paint invalidat ion container's space.
184 renderer->absoluteQuads(outQuads); 184 renderer->absoluteQuads(outQuads);
185 } 185 }
186 } 186 }
187 187
188 bool LinkHighlight::computeHighlightLayerPathAndPosition(const LayoutBoxModelObj ect* paintInvalidationContainer) 188 bool LinkHighlight::computeHighlightLayerPathAndPosition(const LayoutBoxModelObj ect* paintInvalidationContainer)
189 { 189 {
190 if (!m_node || !m_node->renderer() || !m_currentGraphicsLayer) 190 if (!m_node || !m_node->layoutObject() || !m_currentGraphicsLayer)
191 return false; 191 return false;
192 ASSERT(paintInvalidationContainer); 192 ASSERT(paintInvalidationContainer);
193 193
194 // FIXME: This is defensive code to avoid crashes such as those described in 194 // FIXME: This is defensive code to avoid crashes such as those described in
195 // crbug.com/440887. This should be cleaned up once we fix the root cause of 195 // crbug.com/440887. This should be cleaned up once we fix the root cause of
196 // of the paint invalidation container not being composited. 196 // of the paint invalidation container not being composited.
197 if (!paintInvalidationContainer->layer()->compositedLayerMapping() && !paint InvalidationContainer->layer()->groupedMapping()) 197 if (!paintInvalidationContainer->layer()->compositedLayerMapping() && !paint InvalidationContainer->layer()->groupedMapping())
198 return false; 198 return false;
199 199
200 // Get quads for node in absolute coordinates. 200 // Get quads for node in absolute coordinates.
201 Vector<FloatQuad> quads; 201 Vector<FloatQuad> quads;
202 computeQuads(*m_node, quads); 202 computeQuads(*m_node, quads);
203 ASSERT(quads.size()); 203 ASSERT(quads.size());
204 Path newPath; 204 Path newPath;
205 205
206 FloatPoint positionAdjustForCompositedScrolling = IntPoint(m_currentGraphics Layer->offsetFromRenderer()); 206 FloatPoint positionAdjustForCompositedScrolling = IntPoint(m_currentGraphics Layer->offsetFromRenderer());
207 207
208 for (size_t quadIndex = 0; quadIndex < quads.size(); ++quadIndex) { 208 for (size_t quadIndex = 0; quadIndex < quads.size(); ++quadIndex) {
209 FloatQuad absoluteQuad = quads[quadIndex]; 209 FloatQuad absoluteQuad = quads[quadIndex];
210 210
211 // FIXME: this hack should not be necessary. It's a consequence of the f act that composited layers for scrolling are represented 211 // FIXME: this hack should not be necessary. It's a consequence of the f act that composited layers for scrolling are represented
212 // differently in Blink than other composited layers. 212 // differently in Blink than other composited layers.
213 if (paintInvalidationContainer->layer()->needsCompositedScrolling() && m _node->renderer() != paintInvalidationContainer) 213 if (paintInvalidationContainer->layer()->needsCompositedScrolling() && m _node->layoutObject() != paintInvalidationContainer)
214 absoluteQuad.move(-positionAdjustForCompositedScrolling.x(), -positi onAdjustForCompositedScrolling.y()); 214 absoluteQuad.move(-positionAdjustForCompositedScrolling.x(), -positi onAdjustForCompositedScrolling.y());
215 215
216 // Transform node quads in target absolute coords to local coordinates i n the compositor layer. 216 // Transform node quads in target absolute coords to local coordinates i n the compositor layer.
217 FloatQuad transformedQuad; 217 FloatQuad transformedQuad;
218 convertTargetSpaceQuadToCompositedLayer(absoluteQuad, m_node->renderer() , paintInvalidationContainer, transformedQuad); 218 convertTargetSpaceQuadToCompositedLayer(absoluteQuad, m_node->layoutObje ct(), paintInvalidationContainer, transformedQuad);
219 219
220 // FIXME: for now, we'll only use rounded paths if we have a single node quad. The reason for this is that 220 // FIXME: for now, we'll only use rounded paths if we have a single node quad. The reason for this is that
221 // we may sometimes get a chain of adjacent boxes (e.g. for text nodes) which end up looking like sausage 221 // we may sometimes get a chain of adjacent boxes (e.g. for text nodes) which end up looking like sausage
222 // links: these should ideally be merged into a single rect before creat ing the path, but that's 222 // links: these should ideally be merged into a single rect before creat ing the path, but that's
223 // another CL. 223 // another CL.
224 if (quads.size() == 1 && transformedQuad.isRectilinear() 224 if (quads.size() == 1 && transformedQuad.isRectilinear()
225 && !m_owningWebViewImpl->settingsImpl()->mockGestureTapHighlightsEna bled()) { 225 && !m_owningWebViewImpl->settingsImpl()->mockGestureTapHighlightsEna bled()) {
226 FloatSize rectRoundingRadii(3, 3); 226 FloatSize rectRoundingRadii(3, 3);
227 newPath.addRoundedRect(transformedQuad.boundingBox(), rectRoundingRa dii); 227 newPath.addRoundedRect(transformedQuad.boundingBox(), rectRoundingRa dii);
228 } else 228 } else
229 addQuadToPath(transformedQuad, newPath); 229 addQuadToPath(transformedQuad, newPath);
230 } 230 }
231 231
232 FloatRect boundingRect = newPath.boundingRect(); 232 FloatRect boundingRect = newPath.boundingRect();
233 newPath.translate(-toFloatSize(boundingRect.location())); 233 newPath.translate(-toFloatSize(boundingRect.location()));
234 234
235 bool pathHasChanged = !(newPath == m_path); 235 bool pathHasChanged = !(newPath == m_path);
236 if (pathHasChanged) { 236 if (pathHasChanged) {
237 m_path = newPath; 237 m_path = newPath;
238 m_contentLayer->layer()->setBounds(enclosingIntRect(boundingRect).size() ); 238 m_contentLayer->layer()->setBounds(enclosingIntRect(boundingRect).size() );
239 } 239 }
240 240
241 m_contentLayer->layer()->setPosition(boundingRect.location()); 241 m_contentLayer->layer()->setPosition(boundingRect.location());
242 242
243 return pathHasChanged; 243 return pathHasChanged;
244 } 244 }
245 245
246 void LinkHighlight::paintContents(WebCanvas* canvas, const WebRect& webClipRect, WebContentLayerClient::PaintingControlSetting paintingControl) 246 void LinkHighlight::paintContents(WebCanvas* canvas, const WebRect& webClipRect, WebContentLayerClient::PaintingControlSetting paintingControl)
247 { 247 {
248 if (!m_node || !m_node->renderer()) 248 if (!m_node || !m_node->layoutObject())
249 return; 249 return;
250 250
251 GraphicsContext::DisabledMode disabledMode = GraphicsContext::NothingDisable d; 251 GraphicsContext::DisabledMode disabledMode = GraphicsContext::NothingDisable d;
252 if (paintingControl == WebContentLayerClient::DisplayListConstructionDisable d) 252 if (paintingControl == WebContentLayerClient::DisplayListConstructionDisable d)
253 disabledMode = GraphicsContext::FullyDisabled; 253 disabledMode = GraphicsContext::FullyDisabled;
254 254
255 OwnPtr<GraphicsContext> graphicsContext; 255 OwnPtr<GraphicsContext> graphicsContext;
256 OwnPtr<DisplayItemList> displayItemList; 256 OwnPtr<DisplayItemList> displayItemList;
257 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { 257 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
258 displayItemList = DisplayItemList::create(); 258 displayItemList = DisplayItemList::create();
259 graphicsContext = adoptPtr(new GraphicsContext(nullptr, displayItemList. get(), disabledMode)); 259 graphicsContext = adoptPtr(new GraphicsContext(nullptr, displayItemList. get(), disabledMode));
260 } else { 260 } else {
261 graphicsContext = adoptPtr(new GraphicsContext(canvas, nullptr, disabled Mode)); 261 graphicsContext = adoptPtr(new GraphicsContext(canvas, nullptr, disabled Mode));
262 } 262 }
263 263
264 IntRect clipRect(IntPoint(webClipRect.x, webClipRect.y), IntSize(webClipRect .width, webClipRect.height)); 264 IntRect clipRect(IntPoint(webClipRect.x, webClipRect.y), IntSize(webClipRect .width, webClipRect.height));
265 { 265 {
266 DrawingRecorder drawingRecorder(graphicsContext.get(), displayItemClient (), DisplayItem::LinkHighlight, clipRect); 266 DrawingRecorder drawingRecorder(graphicsContext.get(), displayItemClient (), DisplayItem::LinkHighlight, clipRect);
267 267
268 graphicsContext->clip(clipRect); 268 graphicsContext->clip(clipRect);
269 graphicsContext->setFillColor(m_node->renderer()->style()->tapHighlightC olor()); 269 graphicsContext->setFillColor(m_node->layoutObject()->style()->tapHighli ghtColor());
270 graphicsContext->fillPath(m_path); 270 graphicsContext->fillPath(m_path);
271 } 271 }
272 272
273 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { 273 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
274 GraphicsContext canvasGraphicsContext(canvas, nullptr, disabledMode); 274 GraphicsContext canvasGraphicsContext(canvas, nullptr, disabledMode);
275 displayItemList->replay(&canvasGraphicsContext); 275 displayItemList->replay(&canvasGraphicsContext);
276 } 276 }
277 } 277 }
278 278
279 void LinkHighlight::startHighlightAnimationIfNeeded() 279 void LinkHighlight::startHighlightAnimationIfNeeded()
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 332
333 void LinkHighlight::updateGeometry() 333 void LinkHighlight::updateGeometry()
334 { 334 {
335 // To avoid unnecessary updates (e.g. other entities have requested animatio ns from our WebViewImpl), 335 // To avoid unnecessary updates (e.g. other entities have requested animatio ns from our WebViewImpl),
336 // only proceed if we actually requested an update. 336 // only proceed if we actually requested an update.
337 if (!m_geometryNeedsUpdate) 337 if (!m_geometryNeedsUpdate)
338 return; 338 return;
339 339
340 m_geometryNeedsUpdate = false; 340 m_geometryNeedsUpdate = false;
341 341
342 bool hasRenderer = m_node && m_node->renderer(); 342 bool hasRenderer = m_node && m_node->layoutObject();
343 const LayoutBoxModelObject* paintInvalidationContainer = hasRenderer ? m_nod e->renderer()->containerForPaintInvalidation() : 0; 343 const LayoutBoxModelObject* paintInvalidationContainer = hasRenderer ? m_nod e->layoutObject()->containerForPaintInvalidation() : 0;
344 if (paintInvalidationContainer) 344 if (paintInvalidationContainer)
345 attachLinkHighlightToCompositingLayer(paintInvalidationContainer); 345 attachLinkHighlightToCompositingLayer(paintInvalidationContainer);
346 if (paintInvalidationContainer && computeHighlightLayerPathAndPosition(paint InvalidationContainer)) { 346 if (paintInvalidationContainer && computeHighlightLayerPathAndPosition(paint InvalidationContainer)) {
347 // We only need to invalidate the layer if the highlight size has change d, otherwise 347 // We only need to invalidate the layer if the highlight size has change d, otherwise
348 // we can just re-position the layer without needing to repaint. 348 // we can just re-position the layer without needing to repaint.
349 m_contentLayer->layer()->invalidate(); 349 m_contentLayer->layer()->invalidate();
350 350
351 if (m_currentGraphicsLayer) 351 if (m_currentGraphicsLayer)
352 m_currentGraphicsLayer->addRepaintRect(FloatRect(layer()->position() .x, layer()->position().y, layer()->bounds().width, layer()->bounds().height)); 352 m_currentGraphicsLayer->addRepaintRect(FloatRect(layer()->position() .x, layer()->position().y, layer()->bounds().width, layer()->bounds().height));
353 } else if (!hasRenderer) { 353 } else if (!hasRenderer) {
(...skipping 13 matching lines...) Expand all
367 // Make sure we update geometry on the next callback from WebViewImpl::layou t(). 367 // Make sure we update geometry on the next callback from WebViewImpl::layou t().
368 m_geometryNeedsUpdate = true; 368 m_geometryNeedsUpdate = true;
369 } 369 }
370 370
371 WebLayer* LinkHighlight::layer() 371 WebLayer* LinkHighlight::layer()
372 { 372 {
373 return clipLayer(); 373 return clipLayer();
374 } 374 }
375 375
376 } // namespace blink 376 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/FrameLoaderClientImpl.cpp ('k') | Source/web/PopupMenuTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698