Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: Source/core/layout/svg/LayoutSVGRoot.cpp

Issue 1127093002: Combine the three patches below for try bot testing: (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove now unused method Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « LayoutTests/svg/in-html/sizing/svg-inline-vertical.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // The intrinsic aspect ratio of the viewport of SVG content is necessary fo r example, when including SVG from an 'object' 67 // The intrinsic aspect ratio of the viewport of SVG content is necessary fo r example, when including SVG from an 'object'
68 // element in HTML styled with CSS. It is possible (indeed, common) for an S VG graphic to have an intrinsic aspect ratio but 68 // element in HTML styled with CSS. It is possible (indeed, common) for an S VG graphic to have an intrinsic aspect ratio but
69 // not to have an intrinsic width or height. The intrinsic aspect ratio must be calculated based upon the following rules: 69 // not to have an intrinsic width or height. The intrinsic aspect ratio must be calculated based upon the following rules:
70 // - The aspect ratio is calculated by dividing a width by a height. 70 // - The aspect ratio is calculated by dividing a width by a height.
71 // - If the 'width' and 'height' of the rootmost 'svg' element are both spec ified with unit identifiers (in, mm, cm, pt, pc, 71 // - If the 'width' and 'height' of the rootmost 'svg' element are both spec ified with unit identifiers (in, mm, cm, pt, pc,
72 // px, em, ex) or in user units, then the aspect ratio is calculated from the 'width' and 'height' attributes after 72 // px, em, ex) or in user units, then the aspect ratio is calculated from the 'width' and 'height' attributes after
73 // resolving both values to user units. 73 // resolving both values to user units.
74 intrinsicSize.setWidth(floatValueForLength(svg->intrinsicWidth(), 0)); 74 intrinsicSize.setWidth(floatValueForLength(svg->intrinsicWidth(), 0));
75 intrinsicSize.setHeight(floatValueForLength(svg->intrinsicHeight(), 0)); 75 intrinsicSize.setHeight(floatValueForLength(svg->intrinsicHeight(), 0));
76 76
77 if (!isHorizontalWritingMode())
78 intrinsicSize = intrinsicSize.transposedSize();
79
77 if (!intrinsicSize.isEmpty()) { 80 if (!intrinsicSize.isEmpty()) {
78 intrinsicRatio = intrinsicSize.width() / static_cast<double>(intrinsicSi ze.height()); 81 intrinsicRatio = intrinsicSize.width() / static_cast<double>(intrinsicSi ze.height());
79 } else { 82 } else {
80 // - If either/both of the 'width' and 'height' of the rootmost 'svg' el ement are in percentage units (or omitted), the 83 // - If either/both of the 'width' and 'height' of the rootmost 'svg' el ement are in percentage units (or omitted), the
81 // aspect ratio is calculated from the width and height values of the 'viewBox' specified for the current SVG document 84 // aspect ratio is calculated from the width and height values of the 'viewBox' specified for the current SVG document
82 // fragment. If the 'viewBox' is not correctly specified, or set to 'n one', the intrinsic aspect ratio cannot be 85 // fragment. If the 'viewBox' is not correctly specified, or set to 'n one', the intrinsic aspect ratio cannot be
83 // calculated and is considered unspecified. 86 // calculated and is considered unspecified.
84 FloatSize viewBoxSize = svg->viewBox()->currentValue()->value().size(); 87 FloatSize viewBoxSize = svg->viewBox()->currentValue()->value().size();
85 if (!viewBoxSize.isEmpty()) { 88 if (!viewBoxSize.isEmpty()) {
86 // The viewBox can only yield an intrinsic ratio, not an intrinsic s ize. 89 // The viewBox can only yield an intrinsic ratio, not an intrinsic s ize.
87 intrinsicRatio = viewBoxSize.width() / static_cast<double>(viewBoxSi ze.height()); 90 intrinsicRatio = viewBoxSize.width() / static_cast<double>(viewBoxSi ze.height());
91 if (!isHorizontalWritingMode())
92 intrinsicRatio = 1 / intrinsicRatio;
88 } 93 }
89 } 94 }
90 } 95 }
91 96
92 bool LayoutSVGRoot::isEmbeddedThroughSVGImage() const 97 bool LayoutSVGRoot::isEmbeddedThroughSVGImage() const
93 { 98 {
94 return SVGImage::isInSVGImage(toSVGSVGElement(node())); 99 return SVGImage::isInSVGImage(toSVGSVGElement(node()));
95 } 100 }
96 101
97 bool LayoutSVGRoot::isEmbeddedThroughFrameContainingSVGDocument() const 102 bool LayoutSVGRoot::isEmbeddedThroughFrameContainingSVGDocument() const
98 { 103 {
99 if (!node()) 104 if (!node())
100 return false; 105 return false;
101 106
102 LocalFrame* frame = node()->document().frame(); 107 LocalFrame* frame = node()->document().frame();
103 if (!frame) 108 if (!frame)
104 return false; 109 return false;
105 110
106 // 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,
107 // 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).
108 if (!frame->ownerLayoutObject() || !frame->ownerLayoutObject()->isEmbeddedOb ject()) 113 if (!frame->ownerLayoutObject() || !frame->ownerLayoutObject()->isEmbeddedOb ject())
109 return false; 114 return false;
110 return frame->document()->isSVGDocument(); 115 return frame->document()->isSVGDocument();
111 } 116 }
112 117
113 static inline LayoutUnit resolveLengthAttributeForSVG(const Length& length, floa t scale, float maxSize)
114 {
115 return static_cast<LayoutUnit>(valueForLength(length, maxSize) * (length.isF ixed() ? scale : 1));
116 }
117
118 LayoutUnit LayoutSVGRoot::computeReplacedLogicalWidth(ShouldComputePreferred sho uldComputePreferred) const 118 LayoutUnit LayoutSVGRoot::computeReplacedLogicalWidth(ShouldComputePreferred sho uldComputePreferred) const
119 { 119 {
120 SVGSVGElement* svg = toSVGSVGElement(node());
121 ASSERT(svg);
122
123 // 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.
124 if (!m_containerSize.isEmpty()) 121 if (!m_containerSize.isEmpty())
125 return m_containerSize.width(); 122 return m_containerSize.width();
126 123
127 if (isEmbeddedThroughFrameContainingSVGDocument()) 124 if (isEmbeddedThroughFrameContainingSVGDocument())
128 return containingBlock()->availableLogicalWidth(); 125 return containingBlock()->availableLogicalWidth();
129 126
130 if (style()->logicalWidth().isSpecified() || style()->logicalMaxWidth().isSp ecified()) 127 if (style()->logicalWidth().isSpecified() || style()->logicalMaxWidth().isSp ecified())
131 return LayoutReplaced::computeReplacedLogicalWidth(shouldComputePreferre d); 128 return LayoutReplaced::computeReplacedLogicalWidth(shouldComputePreferre d);
132 129
133 if (svg->hasIntrinsicWidth())
134 return resolveLengthAttributeForSVG(svg->intrinsicWidth(), style()->effe ctiveZoom(), containingBlock()->availableLogicalWidth().toFloat());
135
136 // 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.
137 return LayoutReplaced::computeReplacedLogicalWidth(shouldComputePreferred); 131 return LayoutReplaced::computeReplacedLogicalWidth(shouldComputePreferred);
138 } 132 }
139 133
140 LayoutUnit LayoutSVGRoot::computeReplacedLogicalHeight() const 134 LayoutUnit LayoutSVGRoot::computeReplacedLogicalHeight() const
141 { 135 {
142 SVGSVGElement* svg = toSVGSVGElement(node());
143 ASSERT(svg);
144
145 // 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.
146 if (!m_containerSize.isEmpty()) 137 if (!m_containerSize.isEmpty())
147 return m_containerSize.height(); 138 return m_containerSize.height();
148 139
149 if (isEmbeddedThroughFrameContainingSVGDocument()) 140 if (isEmbeddedThroughFrameContainingSVGDocument())
150 return containingBlock()->availableLogicalHeight(IncludeMarginBorderPadd ing); 141 return containingBlock()->availableLogicalHeight(IncludeMarginBorderPadd ing);
151 142
152 if (style()->logicalHeight().isSpecified() || style()->logicalMaxHeight().is Specified()) 143 if (style()->logicalHeight().isSpecified() || style()->logicalMaxHeight().is Specified())
153 return LayoutReplaced::computeReplacedLogicalHeight(); 144 return LayoutReplaced::computeReplacedLogicalHeight();
154 145
155 if (svg->hasIntrinsicHeight())
156 return resolveLengthAttributeForSVG(svg->intrinsicHeight(), style()->eff ectiveZoom(), containingBlock()->availableLogicalHeight(IncludeMarginBorderPaddi ng).toFloat());
157
158 // 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.
159 return LayoutReplaced::computeReplacedLogicalHeight(); 147 return LayoutReplaced::computeReplacedLogicalHeight();
160 } 148 }
161 149
162 void LayoutSVGRoot::layout() 150 void LayoutSVGRoot::layout()
163 { 151 {
164 ASSERT(needsLayout()); 152 ASSERT(needsLayout());
165 LayoutAnalyzer::Scope analyzer(*this); 153 LayoutAnalyzer::Scope analyzer(*this);
166 154
167 bool needsLayout = selfNeedsLayout(); 155 bool needsLayout = selfNeedsLayout();
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 updateHitTestResult(result, pointInBorderBox); 415 updateHitTestResult(result, pointInBorderBox);
428 if (!result.addNodeToListBasedTestResult(node(), locationInContainer , boundsRect)) 416 if (!result.addNodeToListBasedTestResult(node(), locationInContainer , boundsRect))
429 return true; 417 return true;
430 } 418 }
431 } 419 }
432 420
433 return false; 421 return false;
434 } 422 }
435 423
436 } 424 }
OLDNEW
« no previous file with comments | « LayoutTests/svg/in-html/sizing/svg-inline-vertical.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698