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

Side by Side Diff: third_party/WebKit/Source/core/layout/svg/LayoutSVGRoot.cpp

Issue 1852183002: Don't apply svg viewport clip when mapping a LayoutSVGRoot's own rect (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CORE_EXPORT LayoutSVGRoot Created 4 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2007, 2008, 2009 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2007, 2008, 2009 Rob Buis <buis@kde.org>
4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
5 * Copyright (C) 2009 Google, Inc. 5 * Copyright (C) 2009 Google, Inc.
6 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 if (location().y()) 317 if (location().y())
318 m_localToParentTransform.setF(m_localToParentTransform.f() + roundToInt( location().y())); 318 m_localToParentTransform.setF(m_localToParentTransform.f() + roundToInt( location().y()));
319 return m_localToParentTransform; 319 return m_localToParentTransform;
320 } 320 }
321 321
322 LayoutRect LayoutSVGRoot::localOverflowRectForPaintInvalidation() const 322 LayoutRect LayoutSVGRoot::localOverflowRectForPaintInvalidation() const
323 { 323 {
324 // This is an open-coded aggregate of SVGLayoutSupport::localOverflowRectFor PaintInvalidation, 324 // This is an open-coded aggregate of SVGLayoutSupport::localOverflowRectFor PaintInvalidation,
325 // and LayoutReplaced::localOverflowRectForPaintInvalidation. 325 // and LayoutReplaced::localOverflowRectForPaintInvalidation.
326 // The reason for this is to optimize/minimize the paint invalidation rect w hen the box is not "decorated" 326 // The reason for this is to optimize/minimize the paint invalidation rect w hen the box is not "decorated"
327 // (does not have background/border/etc.) 327 // (does not have background/border/etc., see LayoutSVGRootTest.OverflowRect MappingWithViewportClipWithoutBorder).
328 // TODO(wangxianzhu): Verify if the optimization is still needed.
329 328
330 // Return early for any cases where we don't actually paint. 329 // Return early for any cases where we don't actually paint.
331 if (style()->visibility() != VISIBLE && !enclosingLayer()->hasVisibleContent ()) 330 if (style()->visibility() != VISIBLE && !enclosingLayer()->hasVisibleContent ())
332 return LayoutRect(); 331 return LayoutRect();
333 332
334 // Compute the paint invalidation rect of the content of the SVG in the bord er-box coordinate space. 333 // Compute the paint invalidation rect of the content of the SVG in the bord er-box coordinate space.
335 FloatRect contentPaintInvalidationRect = paintInvalidationRectInLocalSVGCoor dinates(); 334 FloatRect contentPaintInvalidationRect = paintInvalidationRectInLocalSVGCoor dinates();
336 contentPaintInvalidationRect = m_localToBorderBoxTransform.mapRect(contentPa intInvalidationRect); 335 contentPaintInvalidationRect = m_localToBorderBoxTransform.mapRect(contentPa intInvalidationRect);
337 336
338 // Apply initial viewport clip, overflow:visible content is added to visualO verflow 337 // Apply initial viewport clip, overflow:visible content is added to visualO verflow
339 // but the most common case is that overflow is hidden, so always intersect. 338 // but the most common case is that overflow is hidden, so always intersect.
340 contentPaintInvalidationRect.intersect(pixelSnappedBorderBoxRect()); 339 contentPaintInvalidationRect.intersect(pixelSnappedBorderBoxRect());
341 340
342 LayoutRect paintInvalidationRect = enclosingLayoutRect(contentPaintInvalidat ionRect); 341 LayoutRect paintInvalidationRect = enclosingLayoutRect(contentPaintInvalidat ionRect);
343 // If the box is decorated or is overflowing, extend it to include the borde r-box and overflow. 342 // If the box is decorated or is overflowing, extend it to include the borde r-box and overflow.
344 if (m_hasBoxDecorationBackground || hasOverflowModel()) { 343 if (m_hasBoxDecorationBackground || hasOverflowModel()) {
345 // The selectionRect can project outside of the overflowRect, so take th eir union 344 // The selectionRect can project outside of the overflowRect, so take th eir union
346 // for paint invalidation to avoid selection painting glitches. 345 // for paint invalidation to avoid selection painting glitches.
347 LayoutRect decoratedPaintInvalidationRect = unionRect(localSelectionRect (), visualOverflowRect()); 346 LayoutRect decoratedPaintInvalidationRect = unionRect(localSelectionRect (), visualOverflowRect());
348 paintInvalidationRect.unite(decoratedPaintInvalidationRect); 347 paintInvalidationRect.unite(decoratedPaintInvalidationRect);
349 } 348 }
350 349
351 return LayoutRect(enclosingIntRect(paintInvalidationRect)); 350 return LayoutRect(enclosingIntRect(paintInvalidationRect));
352 } 351 }
353 352
354 bool LayoutSVGRoot::mapToVisualRectInAncestorSpace(const LayoutBoxModelObject* a ncestor, LayoutRect& rect, VisualRectFlags visualRectFlags) const
355 {
356 // Note that we don't apply the border-box transform here - it's assumed
357 // that whoever called us has done that already.
358
359 // Apply initial viewport clip
360 // TODO(crbug.com/597813): We should not apply clip on LayoutSVGRoot's own r ect. This clip should
361 // be applied in children's mapToVisualRectInAncestorSpace().
362 if (shouldApplyViewportClip()) {
363 if (visualRectFlags & EdgeInclusive) {
364 if (!rect.inclusiveIntersect(LayoutRect(pixelSnappedBorderBoxRect()) ))
365 return false;
366 } else {
367 rect.intersect(LayoutRect(pixelSnappedBorderBoxRect()));
368 }
369 }
370
371 return LayoutReplaced::mapToVisualRectInAncestorSpace(ancestor, rect, visual RectFlags);
372 }
373
374 // This method expects local CSS box coordinates. 353 // This method expects local CSS box coordinates.
375 // Callers with local SVG viewport coordinates should first apply the localToBor derBoxTransform 354 // Callers with local SVG viewport coordinates should first apply the localToBor derBoxTransform
376 // to convert from SVG viewport coordinates to local CSS box coordinates. 355 // to convert from SVG viewport coordinates to local CSS box coordinates.
377 void LayoutSVGRoot::mapLocalToAncestor(const LayoutBoxModelObject* ancestor, Tra nsformState& transformState, MapCoordinatesFlags mode) const 356 void LayoutSVGRoot::mapLocalToAncestor(const LayoutBoxModelObject* ancestor, Tra nsformState& transformState, MapCoordinatesFlags mode) const
378 { 357 {
379 LayoutReplaced::mapLocalToAncestor(ancestor, transformState, mode | ApplyCon tainerFlip); 358 LayoutReplaced::mapLocalToAncestor(ancestor, transformState, mode | ApplyCon tainerFlip);
380 } 359 }
381 360
382 const LayoutObject* LayoutSVGRoot::pushMappingToContainer(const LayoutBoxModelOb ject* ancestorToStopAt, LayoutGeometryMap& geometryMap) const 361 const LayoutObject* LayoutSVGRoot::pushMappingToContainer(const LayoutBoxModelOb ject* ancestorToStopAt, LayoutGeometryMap& geometryMap) const
383 { 362 {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 updateHitTestResult(result, pointInBorderBox); 404 updateHitTestResult(result, pointInBorderBox);
426 if (result.addNodeToListBasedTestResult(node(), locationInContainer, boundsRect) == StopHitTesting) 405 if (result.addNodeToListBasedTestResult(node(), locationInContainer, boundsRect) == StopHitTesting)
427 return true; 406 return true;
428 } 407 }
429 } 408 }
430 409
431 return false; 410 return false;
432 } 411 }
433 412
434 } // namespace blink 413 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698