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 11 matching lines...) Expand all Loading... | |
22 */ | 22 */ |
23 | 23 |
24 #include "config.h" | 24 #include "config.h" |
25 | 25 |
26 #include "core/rendering/svg/RenderSVGRoot.h" | 26 #include "core/rendering/svg/RenderSVGRoot.h" |
27 | 27 |
28 #include "core/frame/LocalFrame.h" | 28 #include "core/frame/LocalFrame.h" |
29 #include "core/rendering/HitTestResult.h" | 29 #include "core/rendering/HitTestResult.h" |
30 #include "core/rendering/LayoutRectRecorder.h" | 30 #include "core/rendering/LayoutRectRecorder.h" |
31 #include "core/rendering/LayoutRepainter.h" | 31 #include "core/rendering/LayoutRepainter.h" |
32 #include "core/rendering/RenderLayer.h" | |
32 #include "core/rendering/RenderPart.h" | 33 #include "core/rendering/RenderPart.h" |
33 #include "core/rendering/RenderView.h" | 34 #include "core/rendering/RenderView.h" |
34 #include "core/rendering/svg/RenderSVGResourceContainer.h" | 35 #include "core/rendering/svg/RenderSVGResourceContainer.h" |
35 #include "core/rendering/svg/SVGRenderingContext.h" | 36 #include "core/rendering/svg/SVGRenderingContext.h" |
36 #include "core/rendering/svg/SVGResources.h" | 37 #include "core/rendering/svg/SVGResources.h" |
37 #include "core/rendering/svg/SVGResourcesCache.h" | 38 #include "core/rendering/svg/SVGResourcesCache.h" |
38 #include "core/svg/SVGElement.h" | 39 #include "core/svg/SVGElement.h" |
39 #include "core/svg/SVGSVGElement.h" | 40 #include "core/svg/SVGSVGElement.h" |
40 #include "core/svg/graphics/SVGImage.h" | 41 #include "core/svg/graphics/SVGImage.h" |
41 #include "platform/LengthFunctions.h" | 42 #include "platform/LengthFunctions.h" |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
214 m_isLayoutSizeChanged = needsLayout || (svg->hasRelativeLengths() && oldSize != size()); | 215 m_isLayoutSizeChanged = needsLayout || (svg->hasRelativeLengths() && oldSize != size()); |
215 SVGRenderSupport::layoutChildren(this, needsLayout || SVGRenderSupport::filt ersForceContainerLayout(this)); | 216 SVGRenderSupport::layoutChildren(this, needsLayout || SVGRenderSupport::filt ersForceContainerLayout(this)); |
216 | 217 |
217 // At this point LayoutRepainter already grabbed the old bounds, | 218 // At this point LayoutRepainter already grabbed the old bounds, |
218 // recalculate them now so repaintAfterLayout() uses the new bounds. | 219 // recalculate them now so repaintAfterLayout() uses the new bounds. |
219 if (m_needsBoundariesOrTransformUpdate) { | 220 if (m_needsBoundariesOrTransformUpdate) { |
220 updateCachedBoundaries(); | 221 updateCachedBoundaries(); |
221 m_needsBoundariesOrTransformUpdate = false; | 222 m_needsBoundariesOrTransformUpdate = false; |
222 } | 223 } |
223 | 224 |
225 m_overflow.clear(); | |
f(malita)
2014/04/02 20:45:48
Not the fault of this CL I think, but poking at th
fs
2014/04/03 07:58:59
Yes, this pattern seemed to be used in a few place
| |
226 addVisualEffectOverflow(); | |
224 updateLayerTransform(); | 227 updateLayerTransform(); |
228 invalidateBackgroundObscurationStatus(); | |
225 | 229 |
226 repainter.repaintAfterLayout(); | 230 repainter.repaintAfterLayout(); |
227 | |
228 clearNeedsLayout(); | 231 clearNeedsLayout(); |
229 } | 232 } |
230 | 233 |
231 void RenderSVGRoot::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paint Offset) | 234 void RenderSVGRoot::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paint Offset) |
232 { | 235 { |
233 // An empty viewport disables rendering. | 236 // An empty viewport disables rendering. |
234 if (pixelSnappedBorderBoxRect().isEmpty()) | 237 if (pixelSnappedBorderBoxRect().isEmpty()) |
235 return; | 238 return; |
236 | 239 |
237 // Don't paint, if the context explicitly disabled it. | 240 // Don't paint, if the context explicitly disabled it. |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
346 { | 349 { |
347 // Slightly optimized version of m_localToParentTransform = AffineTransform: :translation(x(), y()) * m_localToBorderBoxTransform; | 350 // Slightly optimized version of m_localToParentTransform = AffineTransform: :translation(x(), y()) * m_localToBorderBoxTransform; |
348 m_localToParentTransform = m_localToBorderBoxTransform; | 351 m_localToParentTransform = m_localToBorderBoxTransform; |
349 if (x()) | 352 if (x()) |
350 m_localToParentTransform.setE(m_localToParentTransform.e() + roundToInt( x())); | 353 m_localToParentTransform.setE(m_localToParentTransform.e() + roundToInt( x())); |
351 if (y()) | 354 if (y()) |
352 m_localToParentTransform.setF(m_localToParentTransform.f() + roundToInt( y())); | 355 m_localToParentTransform.setF(m_localToParentTransform.f() + roundToInt( y())); |
353 return m_localToParentTransform; | 356 return m_localToParentTransform; |
354 } | 357 } |
355 | 358 |
359 bool RenderSVGRoot::needToRepaintBorderBox() const | |
360 { | |
361 // Check if the box has any overflow defined (includes outline and | |
362 // box-shadow for instance.) | |
363 if (hasRenderOverflow()) | |
364 return true; | |
365 // If it's the document root, then include the border-box in the repaint | |
366 // rect if it's got a background or a border specified. The reason for not | |
367 // using the flag in this case is because said flag is unconditionally set | |
368 // to 'true' for the document root. | |
369 if (isRoot()) | |
370 return calculateHasBoxDecorations(); | |
371 // Otherwise, consider all box decorations. | |
372 return hasBoxDecorations(); | |
373 } | |
374 | |
356 LayoutRect RenderSVGRoot::clippedOverflowRectForRepaint(const RenderLayerModelOb ject* repaintContainer) const | 375 LayoutRect RenderSVGRoot::clippedOverflowRectForRepaint(const RenderLayerModelOb ject* repaintContainer) const |
357 { | 376 { |
358 return SVGRenderSupport::clippedOverflowRectForRepaint(this, repaintContaine r); | 377 // This is an open-coded aggregate of SVGRenderSupport::clippedOverflowRectF orRepaint, |
378 // RenderSVGRoot::computeFloatRectForRepaint and RenderReplaced::clippedOver flowRectForRepaint. | |
379 // The reason for this is to optimize/minimize the repaint rect when the box is not "decorated" | |
380 // (does not have background/border/etc.) | |
381 | |
382 // Return early for any cases where we don't actually paint. | |
383 if (style()->visibility() != VISIBLE && !enclosingLayer()->hasVisibleContent ()) | |
384 return LayoutRect(); | |
385 | |
386 // Compute the repaint rect of the content of the SVG in the border-box coor dinate space. | |
387 FloatRect contentRepaintRect = repaintRectInLocalCoordinates(); | |
388 contentRepaintRect = m_localToBorderBoxTransform.mapRect(contentRepaintRect) ; | |
389 | |
390 // Apply initial viewport clip - not affected by overflow settings | |
391 contentRepaintRect.intersect(pixelSnappedBorderBoxRect()); | |
392 | |
393 LayoutRect repaintRect = enclosingLayoutRect(contentRepaintRect); | |
394 // If the box is decorated, extend it to include the border-box. | |
395 if (needToRepaintBorderBox()) { | |
396 // The selectionRect can project outside of the overflowRect, so take th eir union | |
397 // for repainting to avoid selection painting glitches. | |
398 LayoutRect decoratedRepaintRect = unionRect(localSelectionRect(false), v isualOverflowRect()); | |
399 repaintRect.unite(decoratedRepaintRect); | |
400 } | |
401 | |
402 // Compute the repaint rect in the parent coordinate space. | |
403 LayoutRect rect = enclosingIntRect(repaintRect); | |
404 RenderReplaced::computeRectForRepaint(repaintContainer, rect); | |
405 return rect; | |
359 } | 406 } |
360 | 407 |
361 void RenderSVGRoot::computeFloatRectForRepaint(const RenderLayerModelObject* rep aintContainer, FloatRect& repaintRect, bool fixed) const | 408 void RenderSVGRoot::computeFloatRectForRepaint(const RenderLayerModelObject* rep aintContainer, FloatRect& repaintRect, bool fixed) const |
362 { | 409 { |
363 // Apply our local transforms (except for x/y translation), then our shadow, | 410 // Apply our local transforms (except for x/y translation), then our shadow, |
364 // and then call RenderBox's method to handle all the normal CSS Box model b its | 411 // and then call RenderBox's method to handle all the normal CSS Box model b its |
365 repaintRect = m_localToBorderBoxTransform.mapRect(repaintRect); | 412 repaintRect = m_localToBorderBoxTransform.mapRect(repaintRect); |
366 | 413 |
367 // Apply initial viewport clip - not affected by overflow settings | 414 // Apply initial viewport clip - not affected by overflow settings |
368 repaintRect.intersect(pixelSnappedBorderBoxRect()); | 415 repaintRect.intersect(pixelSnappedBorderBoxRect()); |
(...skipping 16 matching lines...) Expand all Loading... | |
385 | 432 |
386 const RenderObject* RenderSVGRoot::pushMappingToContainer(const RenderLayerModel Object* ancestorToStopAt, RenderGeometryMap& geometryMap) const | 433 const RenderObject* RenderSVGRoot::pushMappingToContainer(const RenderLayerModel Object* ancestorToStopAt, RenderGeometryMap& geometryMap) const |
387 { | 434 { |
388 return RenderReplaced::pushMappingToContainer(ancestorToStopAt, geometryMap) ; | 435 return RenderReplaced::pushMappingToContainer(ancestorToStopAt, geometryMap) ; |
389 } | 436 } |
390 | 437 |
391 void RenderSVGRoot::updateCachedBoundaries() | 438 void RenderSVGRoot::updateCachedBoundaries() |
392 { | 439 { |
393 SVGRenderSupport::computeContainerBoundingBoxes(this, m_objectBoundingBox, m _objectBoundingBoxValid, m_strokeBoundingBox, m_repaintBoundingBox); | 440 SVGRenderSupport::computeContainerBoundingBoxes(this, m_objectBoundingBox, m _objectBoundingBoxValid, m_strokeBoundingBox, m_repaintBoundingBox); |
394 SVGRenderSupport::intersectRepaintRectWithResources(this, m_repaintBoundingB ox); | 441 SVGRenderSupport::intersectRepaintRectWithResources(this, m_repaintBoundingB ox); |
395 m_repaintBoundingBox.inflate(borderAndPaddingWidth().toFloat()); | |
396 } | 442 } |
397 | 443 |
398 bool RenderSVGRoot::nodeAtPoint(const HitTestRequest& request, HitTestResult& re sult, const HitTestLocation& locationInContainer, const LayoutPoint& accumulated Offset, HitTestAction hitTestAction) | 444 bool RenderSVGRoot::nodeAtPoint(const HitTestRequest& request, HitTestResult& re sult, const HitTestLocation& locationInContainer, const LayoutPoint& accumulated Offset, HitTestAction hitTestAction) |
399 { | 445 { |
400 LayoutPoint pointInParent = locationInContainer.point() - toLayoutSize(accum ulatedOffset); | 446 LayoutPoint pointInParent = locationInContainer.point() - toLayoutSize(accum ulatedOffset); |
401 LayoutPoint pointInBorderBox = pointInParent - toLayoutSize(location()); | 447 LayoutPoint pointInBorderBox = pointInParent - toLayoutSize(location()); |
402 | 448 |
403 // Only test SVG content if the point is in our content box. | 449 // Only test SVG content if the point is in our content box. |
404 // FIXME: This should be an intersection when rect-based hit tests are suppo rted by nodeAtFloatPoint. | 450 // FIXME: This should be an intersection when rect-based hit tests are suppo rted by nodeAtFloatPoint. |
405 if (contentBoxRect().contains(pointInBorderBox)) { | 451 if (contentBoxRect().contains(pointInBorderBox)) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
441 | 487 |
442 bool RenderSVGRoot::hasRelativeLogicalHeight() const | 488 bool RenderSVGRoot::hasRelativeLogicalHeight() const |
443 { | 489 { |
444 SVGSVGElement* svg = toSVGSVGElement(node()); | 490 SVGSVGElement* svg = toSVGSVGElement(node()); |
445 ASSERT(svg); | 491 ASSERT(svg); |
446 | 492 |
447 return svg->intrinsicHeight(SVGSVGElement::IgnoreCSSProperties).isPercent(); | 493 return svg->intrinsicHeight(SVGSVGElement::IgnoreCSSProperties).isPercent(); |
448 } | 494 } |
449 | 495 |
450 } | 496 } |
OLD | NEW |