| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 170 |
| 171 if (m_needsBoundariesOrTransformUpdate) { | 171 if (m_needsBoundariesOrTransformUpdate) { |
| 172 updateCachedBoundaries(); | 172 updateCachedBoundaries(); |
| 173 m_needsBoundariesOrTransformUpdate = false; | 173 m_needsBoundariesOrTransformUpdate = false; |
| 174 } | 174 } |
| 175 | 175 |
| 176 m_overflow.reset(); | 176 m_overflow.reset(); |
| 177 addVisualEffectOverflow(); | 177 addVisualEffectOverflow(); |
| 178 | 178 |
| 179 if (!shouldApplyViewportClip()) { | 179 if (!shouldApplyViewportClip()) { |
| 180 FloatRect contentPaintInvalidationRect = | 180 FloatRect contentVisualRect = visualRectInLocalSVGCoordinates(); |
| 181 paintInvalidationRectInLocalSVGCoordinates(); | 181 contentVisualRect = m_localToBorderBoxTransform.mapRect(contentVisualRect); |
| 182 contentPaintInvalidationRect = | 182 addContentsVisualOverflow(enclosingLayoutRect(contentVisualRect)); |
| 183 m_localToBorderBoxTransform.mapRect(contentPaintInvalidationRect); | |
| 184 addContentsVisualOverflow( | |
| 185 enclosingLayoutRect(contentPaintInvalidationRect)); | |
| 186 } | 183 } |
| 187 | 184 |
| 188 updateLayerTransformAfterLayout(); | 185 updateLayerTransformAfterLayout(); |
| 189 m_hasBoxDecorationBackground = isDocumentElement() | 186 m_hasBoxDecorationBackground = isDocumentElement() |
| 190 ? styleRef().hasBoxDecorationBackground() | 187 ? styleRef().hasBoxDecorationBackground() |
| 191 : hasBoxDecorationBackground(); | 188 : hasBoxDecorationBackground(); |
| 192 invalidateBackgroundObscurationStatus(); | 189 invalidateBackgroundObscurationStatus(); |
| 193 | 190 |
| 194 clearNeedsLayout(); | 191 clearNeedsLayout(); |
| 195 } | 192 } |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 m_localToParentTransform = m_localToBorderBoxTransform; | 348 m_localToParentTransform = m_localToBorderBoxTransform; |
| 352 if (location().x()) | 349 if (location().x()) |
| 353 m_localToParentTransform.setE(m_localToParentTransform.e() + | 350 m_localToParentTransform.setE(m_localToParentTransform.e() + |
| 354 roundToInt(location().x())); | 351 roundToInt(location().x())); |
| 355 if (location().y()) | 352 if (location().y()) |
| 356 m_localToParentTransform.setF(m_localToParentTransform.f() + | 353 m_localToParentTransform.setF(m_localToParentTransform.f() + |
| 357 roundToInt(location().y())); | 354 roundToInt(location().y())); |
| 358 return m_localToParentTransform; | 355 return m_localToParentTransform; |
| 359 } | 356 } |
| 360 | 357 |
| 361 LayoutRect LayoutSVGRoot::localOverflowRectForPaintInvalidation() const { | 358 LayoutRect LayoutSVGRoot::localVisualRect() const { |
| 362 // This is an open-coded aggregate of SVGLayoutSupport:: | 359 // This is an open-coded aggregate of SVGLayoutSupport::localVisualRect |
| 363 // localOverflowRectForPaintInvalidation, and LayoutReplaced:: | 360 // and LayoutReplaced::localVisualRect. The reason for this is to optimize/ |
| 364 // localOverflowRectForPaintInvalidation. | 361 // minimize the visual rect when the box is not "decorated" (does not have |
| 365 // The reason for this is to optimize/minimize the paint invalidation rect | 362 // background/border/etc., see |
| 366 // when the box is not "decorated" (does not have background/border/etc., see | 363 // LayoutSVGRootTest.VisualRectMappingWithViewportClipWithoutBorder). |
| 367 // LayoutSVGRootTest.OverflowRectMappingWithViewportClipWithoutBorder). | |
| 368 | 364 |
| 369 // Return early for any cases where we don't actually paint. | 365 // Return early for any cases where we don't actually paint. |
| 370 if (style()->visibility() != EVisibility::Visible && | 366 if (style()->visibility() != EVisibility::Visible && |
| 371 !enclosingLayer()->hasVisibleContent()) | 367 !enclosingLayer()->hasVisibleContent()) |
| 372 return LayoutRect(); | 368 return LayoutRect(); |
| 373 | 369 |
| 374 // Compute the paint invalidation rect of the content of the SVG in the | 370 // Compute the visual rect of the content of the SVG in the border-box |
| 375 // border-box coordinate space. | 371 // coordinate space. |
| 376 FloatRect contentPaintInvalidationRect = | 372 FloatRect contentVisualRect = visualRectInLocalSVGCoordinates(); |
| 377 paintInvalidationRectInLocalSVGCoordinates(); | 373 contentVisualRect = m_localToBorderBoxTransform.mapRect(contentVisualRect); |
| 378 contentPaintInvalidationRect = | |
| 379 m_localToBorderBoxTransform.mapRect(contentPaintInvalidationRect); | |
| 380 | 374 |
| 381 // Apply initial viewport clip, overflow:visible content is added to | 375 // Apply initial viewport clip, overflow:visible content is added to |
| 382 // visualOverflow but the most common case is that overflow is hidden, so | 376 // visualOverflow but the most common case is that overflow is hidden, so |
| 383 // always intersect. | 377 // always intersect. |
| 384 contentPaintInvalidationRect.intersect(pixelSnappedBorderBoxRect()); | 378 contentVisualRect.intersect(pixelSnappedBorderBoxRect()); |
| 385 | 379 |
| 386 LayoutRect paintInvalidationRect = | 380 LayoutRect visualRect = enclosingLayoutRect(contentVisualRect); |
| 387 enclosingLayoutRect(contentPaintInvalidationRect); | |
| 388 // If the box is decorated or is overflowing, extend it to include the | 381 // If the box is decorated or is overflowing, extend it to include the |
| 389 // border-box and overflow. | 382 // border-box and overflow. |
| 390 if (m_hasBoxDecorationBackground || hasOverflowModel()) { | 383 if (m_hasBoxDecorationBackground || hasOverflowModel()) { |
| 391 // The selectionRect can project outside of the overflowRect, so take their | 384 // The selectionRect can project outside of the overflowRect, so take their |
| 392 // union for paint invalidation to avoid selection painting glitches. | 385 // union for paint invalidation to avoid selection painting glitches. |
| 393 LayoutRect decoratedPaintInvalidationRect = | 386 LayoutRect decoratedVisualRect = |
| 394 unionRect(localSelectionRect(), visualOverflowRect()); | 387 unionRect(localSelectionRect(), visualOverflowRect()); |
| 395 paintInvalidationRect.unite(decoratedPaintInvalidationRect); | 388 visualRect.unite(decoratedVisualRect); |
| 396 } | 389 } |
| 397 | 390 |
| 398 return LayoutRect(enclosingIntRect(paintInvalidationRect)); | 391 return LayoutRect(enclosingIntRect(visualRect)); |
| 399 } | 392 } |
| 400 | 393 |
| 401 // This method expects local CSS box coordinates. | 394 // This method expects local CSS box coordinates. |
| 402 // Callers with local SVG viewport coordinates should first apply the | 395 // Callers with local SVG viewport coordinates should first apply the |
| 403 // localToBorderBoxTransform to convert from SVG viewport coordinates to local | 396 // localToBorderBoxTransform to convert from SVG viewport coordinates to local |
| 404 // CSS box coordinates. | 397 // CSS box coordinates. |
| 405 void LayoutSVGRoot::mapLocalToAncestor(const LayoutBoxModelObject* ancestor, | 398 void LayoutSVGRoot::mapLocalToAncestor(const LayoutBoxModelObject* ancestor, |
| 406 TransformState& transformState, | 399 TransformState& transformState, |
| 407 MapCoordinatesFlags mode) const { | 400 MapCoordinatesFlags mode) const { |
| 408 LayoutReplaced::mapLocalToAncestor(ancestor, transformState, | 401 LayoutReplaced::mapLocalToAncestor(ancestor, transformState, |
| 409 mode | ApplyContainerFlip); | 402 mode | ApplyContainerFlip); |
| 410 } | 403 } |
| 411 | 404 |
| 412 const LayoutObject* LayoutSVGRoot::pushMappingToContainer( | 405 const LayoutObject* LayoutSVGRoot::pushMappingToContainer( |
| 413 const LayoutBoxModelObject* ancestorToStopAt, | 406 const LayoutBoxModelObject* ancestorToStopAt, |
| 414 LayoutGeometryMap& geometryMap) const { | 407 LayoutGeometryMap& geometryMap) const { |
| 415 return LayoutReplaced::pushMappingToContainer(ancestorToStopAt, geometryMap); | 408 return LayoutReplaced::pushMappingToContainer(ancestorToStopAt, geometryMap); |
| 416 } | 409 } |
| 417 | 410 |
| 418 void LayoutSVGRoot::updateCachedBoundaries() { | 411 void LayoutSVGRoot::updateCachedBoundaries() { |
| 419 SVGLayoutSupport::computeContainerBoundingBoxes( | 412 SVGLayoutSupport::computeContainerBoundingBoxes( |
| 420 this, m_objectBoundingBox, m_objectBoundingBoxValid, m_strokeBoundingBox, | 413 this, m_objectBoundingBox, m_objectBoundingBoxValid, m_strokeBoundingBox, |
| 421 m_paintInvalidationBoundingBox); | 414 m_visualRectInLocalSVGCoordinates); |
| 422 SVGLayoutSupport::intersectPaintInvalidationRectWithResources( | |
| 423 this, m_paintInvalidationBoundingBox); | |
| 424 } | 415 } |
| 425 | 416 |
| 426 bool LayoutSVGRoot::nodeAtPoint(HitTestResult& result, | 417 bool LayoutSVGRoot::nodeAtPoint(HitTestResult& result, |
| 427 const HitTestLocation& locationInContainer, | 418 const HitTestLocation& locationInContainer, |
| 428 const LayoutPoint& accumulatedOffset, | 419 const LayoutPoint& accumulatedOffset, |
| 429 HitTestAction hitTestAction) { | 420 HitTestAction hitTestAction) { |
| 430 LayoutPoint pointInParent = | 421 LayoutPoint pointInParent = |
| 431 locationInContainer.point() - toLayoutSize(accumulatedOffset); | 422 locationInContainer.point() - toLayoutSize(accumulatedOffset); |
| 432 LayoutPoint pointInBorderBox = pointInParent - toLayoutSize(location()); | 423 LayoutPoint pointInBorderBox = pointInParent - toLayoutSize(location()); |
| 433 | 424 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 if (result.addNodeToListBasedTestResult(node(), locationInContainer, | 467 if (result.addNodeToListBasedTestResult(node(), locationInContainer, |
| 477 boundsRect) == StopHitTesting) | 468 boundsRect) == StopHitTesting) |
| 478 return true; | 469 return true; |
| 479 } | 470 } |
| 480 } | 471 } |
| 481 | 472 |
| 482 return false; | 473 return false; |
| 483 } | 474 } |
| 484 | 475 |
| 485 } // namespace blink | 476 } // namespace blink |
| OLD | NEW |