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

Side by Side Diff: third_party/WebKit/Source/core/layout/svg/SVGTextLayoutEngineBaseline.cpp

Issue 1411123014: [Line Layout API] Convert SVGTextLayoutEngine and SVGTextLayoutEngineBaseline to line Layout API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 case BS_SUB: 46 case BS_SUB:
47 return -m_font.fontMetrics().floatHeight() / 2 / m_effectiveZoom; 47 return -m_font.fontMetrics().floatHeight() / 2 / m_effectiveZoom;
48 case BS_SUPER: 48 case BS_SUPER:
49 return m_font.fontMetrics().floatHeight() / 2 / m_effectiveZoom; 49 return m_font.fontMetrics().floatHeight() / 2 / m_effectiveZoom;
50 default: 50 default:
51 ASSERT_NOT_REACHED(); 51 ASSERT_NOT_REACHED();
52 return 0; 52 return 0;
53 } 53 }
54 } 54 }
55 55
56 EAlignmentBaseline SVGTextLayoutEngineBaseline::dominantBaselineToAlignmentBasel ine(bool isVerticalText, const LayoutObject* textLayoutObject) const 56 EAlignmentBaseline SVGTextLayoutEngineBaseline::dominantBaselineToAlignmentBasel ine(bool isVerticalText, LineLayoutItem textLineLayout) const
57 { 57 {
58 ASSERT(textLayoutObject); 58 ASSERT(textLineLayout);
59 ASSERT(textLayoutObject->style()); 59 ASSERT(textLineLayout.style());
60 60
61 const SVGComputedStyle& style = textLayoutObject->style()->svgStyle(); 61 const SVGComputedStyle& style = textLineLayout.style()->svgStyle();
62 62
63 EDominantBaseline baseline = style.dominantBaseline(); 63 EDominantBaseline baseline = style.dominantBaseline();
64 if (baseline == DB_AUTO) { 64 if (baseline == DB_AUTO) {
65 if (isVerticalText) 65 if (isVerticalText)
66 baseline = DB_CENTRAL; 66 baseline = DB_CENTRAL;
67 else 67 else
68 baseline = DB_ALPHABETIC; 68 baseline = DB_ALPHABETIC;
69 } 69 }
70 70
71 switch (baseline) { 71 switch (baseline) {
72 case DB_USE_SCRIPT: 72 case DB_USE_SCRIPT:
73 // TODO(fs): The dominant-baseline and the baseline-table components 73 // TODO(fs): The dominant-baseline and the baseline-table components
74 // are set by determining the predominant script of the character data 74 // are set by determining the predominant script of the character data
75 // content. 75 // content.
76 return AB_ALPHABETIC; 76 return AB_ALPHABETIC;
77 case DB_NO_CHANGE: 77 case DB_NO_CHANGE:
78 ASSERT(textLayoutObject->parent()); 78 ASSERT(textLineLayout.parent());
79 return dominantBaselineToAlignmentBaseline(isVerticalText, textLayoutObj ect->parent()); 79 return dominantBaselineToAlignmentBaseline(isVerticalText, textLineLayou t.parent());
80 case DB_RESET_SIZE: 80 case DB_RESET_SIZE:
81 ASSERT(textLayoutObject->parent()); 81 ASSERT(textLineLayout.parent());
82 return dominantBaselineToAlignmentBaseline(isVerticalText, textLayoutObj ect->parent()); 82 return dominantBaselineToAlignmentBaseline(isVerticalText, textLineLayou t.parent());
83 case DB_IDEOGRAPHIC: 83 case DB_IDEOGRAPHIC:
84 return AB_IDEOGRAPHIC; 84 return AB_IDEOGRAPHIC;
85 case DB_ALPHABETIC: 85 case DB_ALPHABETIC:
86 return AB_ALPHABETIC; 86 return AB_ALPHABETIC;
87 case DB_HANGING: 87 case DB_HANGING:
88 return AB_HANGING; 88 return AB_HANGING;
89 case DB_MATHEMATICAL: 89 case DB_MATHEMATICAL:
90 return AB_MATHEMATICAL; 90 return AB_MATHEMATICAL;
91 case DB_CENTRAL: 91 case DB_CENTRAL:
92 return AB_CENTRAL; 92 return AB_CENTRAL;
93 case DB_MIDDLE: 93 case DB_MIDDLE:
94 return AB_MIDDLE; 94 return AB_MIDDLE;
95 case DB_TEXT_AFTER_EDGE: 95 case DB_TEXT_AFTER_EDGE:
96 return AB_TEXT_AFTER_EDGE; 96 return AB_TEXT_AFTER_EDGE;
97 case DB_TEXT_BEFORE_EDGE: 97 case DB_TEXT_BEFORE_EDGE:
98 return AB_TEXT_BEFORE_EDGE; 98 return AB_TEXT_BEFORE_EDGE;
99 default: 99 default:
100 ASSERT_NOT_REACHED(); 100 ASSERT_NOT_REACHED();
101 return AB_AUTO; 101 return AB_AUTO;
102 } 102 }
103 } 103 }
104 104
105 float SVGTextLayoutEngineBaseline::calculateAlignmentBaselineShift(bool isVertic alText, const LayoutObject* textLayoutObject) const 105 float SVGTextLayoutEngineBaseline::calculateAlignmentBaselineShift(bool isVertic alText, LineLayoutItem textLineLayout) const
106 { 106 {
107 ASSERT(textLayoutObject); 107 ASSERT(textLineLayout);
108 ASSERT(textLayoutObject->style()); 108 ASSERT(textLineLayout.style());
109 ASSERT(textLayoutObject->parent()); 109 ASSERT(textLineLayout.parent());
110 110
111 const LayoutObject* textLayoutObjectParent = textLayoutObject->parent(); 111 LineLayoutItem textLineLayoutParent = textLineLayout.parent();
112 ASSERT(textLayoutObjectParent); 112 ASSERT(textLineLayoutParent);
113 113
114 EAlignmentBaseline baseline = textLayoutObject->style()->svgStyle().alignmen tBaseline(); 114 EAlignmentBaseline baseline = textLineLayout.style()->svgStyle().alignmentBa seline();
115 if (baseline == AB_AUTO || baseline == AB_BASELINE) { 115 if (baseline == AB_AUTO || baseline == AB_BASELINE) {
116 baseline = dominantBaselineToAlignmentBaseline(isVerticalText, textLayou tObjectParent); 116 baseline = dominantBaselineToAlignmentBaseline(isVerticalText, textLineL ayoutParent);
117 ASSERT(baseline != AB_AUTO && baseline != AB_BASELINE); 117 ASSERT(baseline != AB_AUTO && baseline != AB_BASELINE);
118 } 118 }
119 119
120 const FontMetrics& fontMetrics = m_font.fontMetrics(); 120 const FontMetrics& fontMetrics = m_font.fontMetrics();
121 float ascent = fontMetrics.floatAscent() / m_effectiveZoom; 121 float ascent = fontMetrics.floatAscent() / m_effectiveZoom;
122 float descent = fontMetrics.floatDescent() / m_effectiveZoom; 122 float descent = fontMetrics.floatDescent() / m_effectiveZoom;
123 float xheight = fontMetrics.xHeight() / m_effectiveZoom; 123 float xheight = fontMetrics.xHeight() / m_effectiveZoom;
124 124
125 // Note: http://wiki.apache.org/xmlgraphics-fop/LineLayout/AlignmentHandling 125 // Note: http://wiki.apache.org/xmlgraphics-fop/LineLayout/AlignmentHandling
126 switch (baseline) { 126 switch (baseline) {
(...skipping 15 matching lines...) Expand all
142 case AB_MATHEMATICAL: 142 case AB_MATHEMATICAL:
143 return ascent / 2; 143 return ascent / 2;
144 case AB_BASELINE: 144 case AB_BASELINE:
145 default: 145 default:
146 ASSERT_NOT_REACHED(); 146 ASSERT_NOT_REACHED();
147 return 0; 147 return 0;
148 } 148 }
149 } 149 }
150 150
151 } 151 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698