Chromium Code Reviews| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 if (!frame) | 108 if (!frame) |
| 109 return false; | 109 return false; |
| 110 | 110 |
| 111 // If our frame has an owner layoutObject, we're embedded through eg. object /embed/iframe, | 111 // If our frame has an owner layoutObject, we're embedded through eg. object /embed/iframe, |
| 112 // but we only negotiate if we're in an SVG document inside a embedded objec t (object/embed). | 112 // but we only negotiate if we're in an SVG document inside a embedded objec t (object/embed). |
| 113 if (!frame->ownerLayoutObject() || !frame->ownerLayoutObject()->isEmbeddedOb ject()) | 113 if (!frame->ownerLayoutObject() || !frame->ownerLayoutObject()->isEmbeddedOb ject()) |
| 114 return false; | 114 return false; |
| 115 return frame->document()->isSVGDocument(); | 115 return frame->document()->isSVGDocument(); |
| 116 } | 116 } |
| 117 | 117 |
| 118 static inline LayoutUnit resolveLengthAttributeForSVG(const Length& length, floa t scale, float maxSize) | |
| 119 { | |
| 120 return static_cast<LayoutUnit>(valueForLength(length, maxSize) * (length.isF ixed() ? scale : 1)); | |
| 121 } | |
| 122 | |
| 123 LayoutUnit LayoutSVGRoot::computeReplacedLogicalWidth(ShouldComputePreferred sho uldComputePreferred) const | 118 LayoutUnit LayoutSVGRoot::computeReplacedLogicalWidth(ShouldComputePreferred sho uldComputePreferred) const |
| 124 { | 119 { |
| 125 SVGSVGElement* svg = toSVGSVGElement(node()); | |
| 126 ASSERT(svg); | |
| 127 | |
| 128 // When we're embedded through SVGImage (border-image/background-image/<html :img>/...) we're forced to resize to a specific size. | 120 // When we're embedded through SVGImage (border-image/background-image/<html :img>/...) we're forced to resize to a specific size. |
| 129 if (!m_containerSize.isEmpty()) | 121 if (!m_containerSize.isEmpty()) |
| 130 return m_containerSize.width(); | 122 return m_containerSize.width(); |
| 131 | 123 |
| 132 if (isEmbeddedThroughFrameContainingSVGDocument()) | 124 if (isEmbeddedThroughFrameContainingSVGDocument()) |
| 133 return containingBlock()->availableLogicalWidth(); | 125 return containingBlock()->availableLogicalWidth(); |
| 134 | 126 |
| 135 if (style()->logicalWidth().isSpecified() || style()->logicalMaxWidth().isSp ecified()) | 127 if (style()->logicalWidth().isSpecified() || style()->logicalMaxWidth().isSp ecified()) |
|
fs
2015/05/07 11:02:36
Looks like this will be made redundant (too)
| |
| 136 return LayoutReplaced::computeReplacedLogicalWidth(shouldComputePreferre d); | 128 return LayoutReplaced::computeReplacedLogicalWidth(shouldComputePreferre d); |
| 137 | 129 |
| 138 if (svg->hasIntrinsicWidth()) | |
| 139 return resolveLengthAttributeForSVG(svg->intrinsicWidth(), style()->effe ctiveZoom(), containingBlock()->availableLogicalWidth().toFloat()); | |
| 140 | |
| 141 // SVG embedded via SVGImage (background-image/border-image/etc) / Inline SV G. | 130 // SVG embedded via SVGImage (background-image/border-image/etc) / Inline SV G. |
| 142 return LayoutReplaced::computeReplacedLogicalWidth(shouldComputePreferred); | 131 return LayoutReplaced::computeReplacedLogicalWidth(shouldComputePreferred); |
| 143 } | 132 } |
| 144 | 133 |
| 145 LayoutUnit LayoutSVGRoot::computeReplacedLogicalHeight() const | 134 LayoutUnit LayoutSVGRoot::computeReplacedLogicalHeight() const |
| 146 { | 135 { |
| 147 SVGSVGElement* svg = toSVGSVGElement(node()); | |
| 148 ASSERT(svg); | |
| 149 | |
| 150 // When we're embedded through SVGImage (border-image/background-image/<html :img>/...) we're forced to resize to a specific size. | 136 // When we're embedded through SVGImage (border-image/background-image/<html :img>/...) we're forced to resize to a specific size. |
| 151 if (!m_containerSize.isEmpty()) | 137 if (!m_containerSize.isEmpty()) |
| 152 return m_containerSize.height(); | 138 return m_containerSize.height(); |
| 153 | 139 |
| 154 if (isEmbeddedThroughFrameContainingSVGDocument()) | 140 if (isEmbeddedThroughFrameContainingSVGDocument()) |
| 155 return containingBlock()->availableLogicalHeight(IncludeMarginBorderPadd ing); | 141 return containingBlock()->availableLogicalHeight(IncludeMarginBorderPadd ing); |
| 156 | 142 |
| 157 if (style()->logicalHeight().isSpecified() || style()->logicalMaxHeight().is Specified()) | 143 if (style()->logicalHeight().isSpecified() || style()->logicalMaxHeight().is Specified()) |
|
fs
2015/05/07 11:02:36
Ditto.
| |
| 158 return LayoutReplaced::computeReplacedLogicalHeight(); | 144 return LayoutReplaced::computeReplacedLogicalHeight(); |
| 159 | 145 |
| 160 if (svg->hasIntrinsicHeight()) | |
| 161 return resolveLengthAttributeForSVG(svg->intrinsicHeight(), style()->eff ectiveZoom(), containingBlock()->availableLogicalHeight(IncludeMarginBorderPaddi ng).toFloat()); | |
| 162 | |
| 163 // SVG embedded via SVGImage (background-image/border-image/etc) / Inline SV G. | 146 // SVG embedded via SVGImage (background-image/border-image/etc) / Inline SV G. |
| 164 return LayoutReplaced::computeReplacedLogicalHeight(); | 147 return LayoutReplaced::computeReplacedLogicalHeight(); |
| 165 } | 148 } |
| 166 | 149 |
| 167 void LayoutSVGRoot::layout() | 150 void LayoutSVGRoot::layout() |
| 168 { | 151 { |
| 169 ASSERT(needsLayout()); | 152 ASSERT(needsLayout()); |
| 170 LayoutAnalyzer::Scope analyzer(*this); | 153 LayoutAnalyzer::Scope analyzer(*this); |
| 171 | 154 |
| 172 bool needsLayout = selfNeedsLayout(); | 155 bool needsLayout = selfNeedsLayout(); |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 432 updateHitTestResult(result, pointInBorderBox); | 415 updateHitTestResult(result, pointInBorderBox); |
| 433 if (!result.addNodeToListBasedTestResult(node(), locationInContainer , boundsRect)) | 416 if (!result.addNodeToListBasedTestResult(node(), locationInContainer , boundsRect)) |
| 434 return true; | 417 return true; |
| 435 } | 418 } |
| 436 } | 419 } |
| 437 | 420 |
| 438 return false; | 421 return false; |
| 439 } | 422 } |
| 440 | 423 |
| 441 } | 424 } |
| OLD | NEW |