OLD | NEW |
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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 { | 311 { |
312 // Slightly optimized version of m_localToParentTransform = AffineTransform:
:translation(x(), y()) * m_localToBorderBoxTransform; | 312 // Slightly optimized version of m_localToParentTransform = AffineTransform:
:translation(x(), y()) * m_localToBorderBoxTransform; |
313 m_localToParentTransform = m_localToBorderBoxTransform; | 313 m_localToParentTransform = m_localToBorderBoxTransform; |
314 if (location().x()) | 314 if (location().x()) |
315 m_localToParentTransform.setE(m_localToParentTransform.e() + roundToInt(
location().x())); | 315 m_localToParentTransform.setE(m_localToParentTransform.e() + roundToInt(
location().x())); |
316 if (location().y()) | 316 if (location().y()) |
317 m_localToParentTransform.setF(m_localToParentTransform.f() + roundToInt(
location().y())); | 317 m_localToParentTransform.setF(m_localToParentTransform.f() + roundToInt(
location().y())); |
318 return m_localToParentTransform; | 318 return m_localToParentTransform; |
319 } | 319 } |
320 | 320 |
321 LayoutRect LayoutSVGRoot::clippedOverflowRectForPaintInvalidation(const LayoutBo
xModelObject* paintInvalidationContainer, const PaintInvalidationState* paintInv
alidationState) const | 321 LayoutRect LayoutSVGRoot::localOverflowRectForPaintInvalidation() const |
322 { | 322 { |
323 // This is an open-coded aggregate of SVGLayoutSupport::clippedOverflowRectF
orPaintInvalidation, | 323 // This is an open-coded aggregate of SVGLayoutSupport::localOverflowRectFor
PaintInvalidation, |
324 // LayoutSVGRoot::mapToVisibleRectInAncestorSpace and LayoutReplaced::clippe
dOverflowRectForPaintInvalidation. | 324 // and LayoutReplaced::localOverflowRectForPaintInvalidation. |
325 // The reason for this is to optimize/minimize the paint invalidation rect w
hen the box is not "decorated" | 325 // The reason for this is to optimize/minimize the paint invalidation rect w
hen the box is not "decorated" |
326 // (does not have background/border/etc.) | 326 // (does not have background/border/etc.) |
| 327 // TODO(wangxianzhu): Verify if the optimization is still needed. |
327 | 328 |
328 // Return early for any cases where we don't actually paint. | 329 // Return early for any cases where we don't actually paint. |
329 if (style()->visibility() != VISIBLE && !enclosingLayer()->hasVisibleContent
()) | 330 if (style()->visibility() != VISIBLE && !enclosingLayer()->hasVisibleContent
()) |
330 return LayoutRect(); | 331 return LayoutRect(); |
331 | 332 |
332 // 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. |
333 FloatRect contentPaintInvalidationRect = paintInvalidationRectInLocalSVGCoor
dinates(); | 334 FloatRect contentPaintInvalidationRect = paintInvalidationRectInLocalSVGCoor
dinates(); |
334 contentPaintInvalidationRect = m_localToBorderBoxTransform.mapRect(contentPa
intInvalidationRect); | 335 contentPaintInvalidationRect = m_localToBorderBoxTransform.mapRect(contentPa
intInvalidationRect); |
335 | 336 |
336 // 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 |
337 // 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. |
338 contentPaintInvalidationRect.intersect(pixelSnappedBorderBoxRect()); | 339 contentPaintInvalidationRect.intersect(pixelSnappedBorderBoxRect()); |
339 | 340 |
340 LayoutRect paintInvalidationRect = enclosingLayoutRect(contentPaintInvalidat
ionRect); | 341 LayoutRect paintInvalidationRect = enclosingLayoutRect(contentPaintInvalidat
ionRect); |
341 // 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. |
342 if (m_hasBoxDecorationBackground || hasOverflowModel()) { | 343 if (m_hasBoxDecorationBackground || hasOverflowModel()) { |
343 // 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 |
344 // for paint invalidation to avoid selection painting glitches. | 345 // for paint invalidation to avoid selection painting glitches. |
345 LayoutRect decoratedPaintInvalidationRect = unionRect(localSelectionRect
(), visualOverflowRect()); | 346 LayoutRect decoratedPaintInvalidationRect = unionRect(localSelectionRect
(), visualOverflowRect()); |
346 paintInvalidationRect.unite(decoratedPaintInvalidationRect); | 347 paintInvalidationRect.unite(decoratedPaintInvalidationRect); |
347 } | 348 } |
348 | 349 |
349 // Compute the paint invalidation rect in the parent coordinate space. | 350 return LayoutRect(enclosingIntRect(paintInvalidationRect)); |
350 LayoutRect rect(enclosingIntRect(paintInvalidationRect)); | |
351 LayoutReplaced::mapToVisibleRectInAncestorSpace(paintInvalidationContainer,
rect, paintInvalidationState); | |
352 return rect; | |
353 } | 351 } |
354 | 352 |
355 bool LayoutSVGRoot::mapToVisibleRectInAncestorSpace(const LayoutBoxModelObject*
ancestor, LayoutRect& rect, const PaintInvalidationState* paintInvalidationState
, VisibleRectFlags visibleRectFlags) const | 353 bool LayoutSVGRoot::mapToVisibleRectInAncestorSpace(const LayoutBoxModelObject*
ancestor, LayoutRect& rect, VisibleRectFlags visibleRectFlags) const |
356 { | 354 { |
357 // Note that we don't apply the border-box transform here - it's assumed | 355 // Note that we don't apply the border-box transform here - it's assumed |
358 // that whoever called us has done that already. | 356 // that whoever called us has done that already. |
359 | 357 |
360 // Apply initial viewport clip | 358 // Apply initial viewport clip |
| 359 // TODO(crbug.com/597813): We should not apply clip on LayoutSVGRoot's own r
ect. This clip should |
| 360 // be applied in children's mapToVisibleRectInAncestorSpace(). |
361 if (shouldApplyViewportClip()) { | 361 if (shouldApplyViewportClip()) { |
362 if (visibleRectFlags & EdgeInclusive) { | 362 if (visibleRectFlags & EdgeInclusive) { |
363 if (!rect.inclusiveIntersect(LayoutRect(pixelSnappedBorderBoxRect())
)) | 363 if (!rect.inclusiveIntersect(LayoutRect(pixelSnappedBorderBoxRect())
)) |
364 return false; | 364 return false; |
365 } else { | 365 } else { |
366 rect.intersect(LayoutRect(pixelSnappedBorderBoxRect())); | 366 rect.intersect(LayoutRect(pixelSnappedBorderBoxRect())); |
367 } | 367 } |
368 } | 368 } |
369 | 369 |
370 return LayoutReplaced::mapToVisibleRectInAncestorSpace(ancestor, rect, paint
InvalidationState, visibleRectFlags); | 370 return LayoutReplaced::mapToVisibleRectInAncestorSpace(ancestor, rect, visib
leRectFlags); |
371 } | 371 } |
372 | 372 |
373 // This method expects local CSS box coordinates. | 373 // This method expects local CSS box coordinates. |
374 // Callers with local SVG viewport coordinates should first apply the localToBor
derBoxTransform | 374 // Callers with local SVG viewport coordinates should first apply the localToBor
derBoxTransform |
375 // to convert from SVG viewport coordinates to local CSS box coordinates. | 375 // to convert from SVG viewport coordinates to local CSS box coordinates. |
376 void LayoutSVGRoot::mapLocalToAncestor(const LayoutBoxModelObject* ancestor, Tra
nsformState& transformState, MapCoordinatesFlags mode, bool* wasFixed, const Pai
ntInvalidationState* paintInvalidationState) const | 376 void LayoutSVGRoot::mapLocalToAncestor(const LayoutBoxModelObject* ancestor, Tra
nsformState& transformState, MapCoordinatesFlags mode, bool* wasFixed) const |
377 { | 377 { |
378 ASSERT(!(mode & IsFixed)); // We should have no fixed content in the SVG lay
out tree. | 378 ASSERT(!(mode & IsFixed)); // We should have no fixed content in the SVG lay
out tree. |
379 | 379 |
380 LayoutReplaced::mapLocalToAncestor(ancestor, transformState, mode | ApplyCon
tainerFlip, wasFixed, paintInvalidationState); | 380 LayoutReplaced::mapLocalToAncestor(ancestor, transformState, mode | ApplyCon
tainerFlip, wasFixed); |
381 } | 381 } |
382 | 382 |
383 const LayoutObject* LayoutSVGRoot::pushMappingToContainer(const LayoutBoxModelOb
ject* ancestorToStopAt, LayoutGeometryMap& geometryMap) const | 383 const LayoutObject* LayoutSVGRoot::pushMappingToContainer(const LayoutBoxModelOb
ject* ancestorToStopAt, LayoutGeometryMap& geometryMap) const |
384 { | 384 { |
385 return LayoutReplaced::pushMappingToContainer(ancestorToStopAt, geometryMap)
; | 385 return LayoutReplaced::pushMappingToContainer(ancestorToStopAt, geometryMap)
; |
386 } | 386 } |
387 | 387 |
388 void LayoutSVGRoot::updateCachedBoundaries() | 388 void LayoutSVGRoot::updateCachedBoundaries() |
389 { | 389 { |
390 SVGLayoutSupport::computeContainerBoundingBoxes(this, m_objectBoundingBox, m
_objectBoundingBoxValid, m_strokeBoundingBox, m_paintInvalidationBoundingBox); | 390 SVGLayoutSupport::computeContainerBoundingBoxes(this, m_objectBoundingBox, m
_objectBoundingBoxValid, m_strokeBoundingBox, m_paintInvalidationBoundingBox); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 updateHitTestResult(result, pointInBorderBox); | 426 updateHitTestResult(result, pointInBorderBox); |
427 if (result.addNodeToListBasedTestResult(node(), locationInContainer,
boundsRect) == StopHitTesting) | 427 if (result.addNodeToListBasedTestResult(node(), locationInContainer,
boundsRect) == StopHitTesting) |
428 return true; | 428 return true; |
429 } | 429 } |
430 } | 430 } |
431 | 431 |
432 return false; | 432 return false; |
433 } | 433 } |
434 | 434 |
435 } // namespace blink | 435 } // namespace blink |
OLD | NEW |