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

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

Issue 1128093002: Return vertical writing mode aware intrinsic information for SVG (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase for landing 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-expected.txt ('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
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 updateHitTestResult(result, pointInBorderBox); 432 updateHitTestResult(result, pointInBorderBox);
428 if (!result.addNodeToListBasedTestResult(node(), locationInContainer , boundsRect)) 433 if (!result.addNodeToListBasedTestResult(node(), locationInContainer , boundsRect))
429 return true; 434 return true;
430 } 435 }
431 } 436 }
432 437
433 return false; 438 return false;
434 } 439 }
435 440
436 } 441 }
OLDNEW
« no previous file with comments | « LayoutTests/svg/in-html/sizing/svg-inline-vertical-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698