| 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()); |
| 52 if (!intrinsicSize.width()) |
| 53 intrinsicSize.setWidth(defaultWidth); |
| 54 if (!intrinsicSize.height()) |
| 55 intrinsicSize.setHeight(defaultHeight); |
| 56 setIntrinsicSize(intrinsicSize); |
| 51 } | 57 } |
| 52 | 58 |
| 53 LayoutSVGRoot::~LayoutSVGRoot() | 59 LayoutSVGRoot::~LayoutSVGRoot() |
| 54 { | 60 { |
| 55 } | 61 } |
| 56 | 62 |
| 57 void LayoutSVGRoot::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, d
ouble& intrinsicRatio) const | 63 FloatSize LayoutSVGRoot::calculateIntrinsicSize() const |
| 58 { | 64 { |
| 59 // Spec: http://www.w3.org/TR/SVG/coords.html#IntrinsicSizing | |
| 60 // SVG needs to specify how to calculate some intrinsic sizing properties to
enable inclusion within other languages. | |
| 61 // The intrinsic width and height of the viewport of SVG content must be det
ermined from the 'width' and 'height' attributes. | |
| 62 SVGSVGElement* svg = toSVGSVGElement(node()); | 65 SVGSVGElement* svg = toSVGSVGElement(node()); |
| 63 ASSERT(svg); | 66 ASSERT(svg); |
| 64 | 67 |
| 65 // The intrinsic aspect ratio of the viewport of SVG content is necessary fo
r example, when including SVG from an 'object' | 68 return FloatSize(floatValueForLength(svg->intrinsicWidth(), 0), floatValueFo
rLength(svg->intrinsicHeight(), 0)); |
| 66 // element in HTML styled with CSS. It is possible (indeed, common) for an S
VG graphic to have an intrinsic aspect ratio but | 69 } |
| 67 // not to have an intrinsic width or height. The intrinsic aspect ratio must
be calculated based upon the following rules: | 70 |
| 68 // - The aspect ratio is calculated by dividing a width by a height. | 71 void LayoutSVGRoot::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, d
ouble& intrinsicRatio) const |
| 69 // - If the 'width' and 'height' of the rootmost 'svg' element are both spec
ified with unit identifiers (in, mm, cm, pt, pc, | 72 { |
| 70 // px, em, ex) or in user units, then the aspect ratio is calculated from
the 'width' and 'height' attributes after | 73 // https://www.w3.org/TR/SVG/coords.html#IntrinsicSizing |
| 71 // resolving both values to user units. | 74 intrinsicSize = calculateIntrinsicSize(); |
| 72 intrinsicSize.setWidth(floatValueForLength(svg->intrinsicWidth(), 0)); | |
| 73 intrinsicSize.setHeight(floatValueForLength(svg->intrinsicHeight(), 0)); | |
| 74 | 75 |
| 75 if (!isHorizontalWritingMode()) | 76 if (!isHorizontalWritingMode()) |
| 76 intrinsicSize = intrinsicSize.transposedSize(); | 77 intrinsicSize = intrinsicSize.transposedSize(); |
| 77 | 78 |
| 78 if (!intrinsicSize.isEmpty()) { | 79 if (!intrinsicSize.isEmpty()) { |
| 79 intrinsicRatio = intrinsicSize.width() / static_cast<double>(intrinsicSi
ze.height()); | 80 intrinsicRatio = intrinsicSize.width() / static_cast<double>(intrinsicSi
ze.height()); |
| 80 } else { | 81 } else { |
| 81 // - If either/both of the 'width' and 'height' of the rootmost 'svg' el
ement are in percentage units (or omitted), the | 82 SVGSVGElement* svg = toSVGSVGElement(node()); |
| 82 // aspect ratio is calculated from the width and height values of the
'viewBox' specified for the current SVG document | 83 ASSERT(svg); |
| 83 // fragment. If the 'viewBox' is not correctly specified, or set to 'n
one', the intrinsic aspect ratio cannot be | 84 |
| 84 // calculated and is considered unspecified. | |
| 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 intrinsicRatio = viewBoxSize.width() / static_cast<double>(viewBoxSi
ze.height()); | 88 intrinsicRatio = viewBoxSize.width() / static_cast<double>(viewBoxSi
ze.height()); |
| 89 if (!isHorizontalWritingMode()) | 89 if (!isHorizontalWritingMode()) |
| 90 intrinsicRatio = 1 / intrinsicRatio; | 90 intrinsicRatio = 1 / intrinsicRatio; |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 } | 93 } |
| 94 | 94 |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 updateHitTestResult(result, pointInBorderBox); | 409 updateHitTestResult(result, pointInBorderBox); |
| 410 if (!result.addNodeToListBasedTestResult(node(), locationInContainer
, boundsRect)) | 410 if (!result.addNodeToListBasedTestResult(node(), locationInContainer
, boundsRect)) |
| 411 return true; | 411 return true; |
| 412 } | 412 } |
| 413 } | 413 } |
| 414 | 414 |
| 415 return false; | 415 return false; |
| 416 } | 416 } |
| 417 | 417 |
| 418 } | 418 } |
| OLD | NEW |