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 30 matching lines...) Expand all Loading... |
41 | 41 |
42 LayoutSVGRoot::LayoutSVGRoot(SVGElement* node) | 42 LayoutSVGRoot::LayoutSVGRoot(SVGElement* node) |
43 : LayoutReplaced(node) | 43 : LayoutReplaced(node) |
44 , m_objectBoundingBoxValid(false) | 44 , m_objectBoundingBoxValid(false) |
45 , m_isLayoutSizeChanged(false) | 45 , m_isLayoutSizeChanged(false) |
46 , m_needsBoundariesOrTransformUpdate(true) | 46 , m_needsBoundariesOrTransformUpdate(true) |
47 , m_hasBoxDecorationBackground(false) | 47 , m_hasBoxDecorationBackground(false) |
48 , m_hasNonIsolatedBlendingDescendants(false) | 48 , m_hasNonIsolatedBlendingDescendants(false) |
49 , m_hasNonIsolatedBlendingDescendantsDirty(false) | 49 , m_hasNonIsolatedBlendingDescendantsDirty(false) |
50 { | 50 { |
51 LayoutSize intrinsicSize(calculateIntrinsicSize()); | 51 SVGSVGElement* svg = toSVGSVGElement(node); |
52 if (!intrinsicSize.width()) | 52 ASSERT(svg); |
| 53 |
| 54 LayoutSize intrinsicSize(calculateIntrinsicSize(svg)); |
| 55 if (!svg->hasIntrinsicWidth()) |
53 intrinsicSize.setWidth(LayoutUnit(defaultWidth)); | 56 intrinsicSize.setWidth(LayoutUnit(defaultWidth)); |
54 if (!intrinsicSize.height()) | 57 if (!svg->hasIntrinsicHeight()) |
55 intrinsicSize.setHeight(LayoutUnit(defaultHeight)); | 58 intrinsicSize.setHeight(LayoutUnit(defaultHeight)); |
56 setIntrinsicSize(intrinsicSize); | 59 setIntrinsicSize(intrinsicSize); |
57 } | 60 } |
58 | 61 |
59 LayoutSVGRoot::~LayoutSVGRoot() | 62 LayoutSVGRoot::~LayoutSVGRoot() |
60 { | 63 { |
61 } | 64 } |
62 | 65 |
63 FloatSize LayoutSVGRoot::calculateIntrinsicSize() const | 66 FloatSize LayoutSVGRoot::calculateIntrinsicSize(SVGSVGElement* svg) |
64 { | 67 { |
65 SVGSVGElement* svg = toSVGSVGElement(node()); | |
66 ASSERT(svg); | |
67 | |
68 return FloatSize(floatValueForLength(svg->intrinsicWidth(), 0), floatValueFo
rLength(svg->intrinsicHeight(), 0)); | 68 return FloatSize(floatValueForLength(svg->intrinsicWidth(), 0), floatValueFo
rLength(svg->intrinsicHeight(), 0)); |
69 } | 69 } |
70 | 70 |
71 void LayoutSVGRoot::computeIntrinsicSizingInfo(IntrinsicSizingInfo& intrinsicSiz
ingInfo) const | 71 void LayoutSVGRoot::computeIntrinsicSizingInfo(IntrinsicSizingInfo& intrinsicSiz
ingInfo) const |
72 { | 72 { |
73 // https://www.w3.org/TR/SVG/coords.html#IntrinsicSizing | 73 // https://www.w3.org/TR/SVG/coords.html#IntrinsicSizing |
74 intrinsicSizingInfo.size = calculateIntrinsicSize(); | |
75 | 74 |
76 if (!isHorizontalWritingMode()) | 75 SVGSVGElement* svg = toSVGSVGElement(node()); |
77 intrinsicSizingInfo.size = intrinsicSizingInfo.size.transposedSize(); | 76 ASSERT(svg); |
| 77 |
| 78 intrinsicSizingInfo.size = calculateIntrinsicSize(svg); |
| 79 intrinsicSizingInfo.emptyWidth = !svg->hasIntrinsicWidth(); |
| 80 intrinsicSizingInfo.emptyHeight = !svg->hasIntrinsicHeight(); |
78 | 81 |
79 if (!intrinsicSizingInfo.size.isEmpty()) { | 82 if (!intrinsicSizingInfo.size.isEmpty()) { |
80 intrinsicSizingInfo.aspectRatio = intrinsicSizingInfo.size.width() / sta
tic_cast<double>(intrinsicSizingInfo.size.height()); | 83 intrinsicSizingInfo.aspectRatio = intrinsicSizingInfo.size.width() / sta
tic_cast<double>(intrinsicSizingInfo.size.height()); |
81 } else { | 84 } else { |
82 SVGSVGElement* svg = toSVGSVGElement(node()); | |
83 ASSERT(svg); | |
84 | |
85 FloatSize viewBoxSize = svg->viewBox()->currentValue()->value().size(); | 85 FloatSize viewBoxSize = svg->viewBox()->currentValue()->value().size(); |
86 if (!viewBoxSize.isEmpty()) { | 86 if (!viewBoxSize.isEmpty()) { |
87 // The viewBox can only yield an intrinsic ratio, not an intrinsic s
ize. | 87 // The viewBox can only yield an intrinsic ratio, not an intrinsic s
ize. |
88 intrinsicSizingInfo.aspectRatio = viewBoxSize.width() / static_cast<
double>(viewBoxSize.height()); | 88 intrinsicSizingInfo.aspectRatio = viewBoxSize.width() / static_cast<
double>(viewBoxSize.height()); |
89 if (!isHorizontalWritingMode()) | |
90 intrinsicSizingInfo.aspectRatio = 1 / intrinsicSizingInfo.aspect
Ratio; | |
91 } | 89 } |
92 } | 90 } |
| 91 |
| 92 if (!isHorizontalWritingMode()) |
| 93 intrinsicSizingInfo.transpose(); |
93 } | 94 } |
94 | 95 |
95 bool LayoutSVGRoot::isEmbeddedThroughSVGImage() const | 96 bool LayoutSVGRoot::isEmbeddedThroughSVGImage() const |
96 { | 97 { |
97 return SVGImage::isInSVGImage(toSVGSVGElement(node())); | 98 return SVGImage::isInSVGImage(toSVGSVGElement(node())); |
98 } | 99 } |
99 | 100 |
100 bool LayoutSVGRoot::isEmbeddedThroughFrameContainingSVGDocument() const | 101 bool LayoutSVGRoot::isEmbeddedThroughFrameContainingSVGDocument() const |
101 { | 102 { |
102 if (!node()) | 103 if (!node()) |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 updateHitTestResult(result, pointInBorderBox); | 400 updateHitTestResult(result, pointInBorderBox); |
400 if (result.addNodeToListBasedTestResult(node(), locationInContainer,
boundsRect) == StopHitTesting) | 401 if (result.addNodeToListBasedTestResult(node(), locationInContainer,
boundsRect) == StopHitTesting) |
401 return true; | 402 return true; |
402 } | 403 } |
403 } | 404 } |
404 | 405 |
405 return false; | 406 return false; |
406 } | 407 } |
407 | 408 |
408 } // namespace blink | 409 } // namespace blink |
OLD | NEW |