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

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

Issue 2748103015: Replace ASSERT with DCHECK in core/layout/<sub dirs> (Closed)
Patch Set: Rebase with latest Created 3 years, 8 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
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 10 matching lines...) Expand all
21 21
22 #include "core/style/SVGComputedStyle.h" 22 #include "core/style/SVGComputedStyle.h"
23 #include "core/svg/SVGLengthContext.h" 23 #include "core/svg/SVGLengthContext.h"
24 #include "platform/fonts/Font.h" 24 #include "platform/fonts/Font.h"
25 25
26 namespace blink { 26 namespace blink {
27 27
28 SVGTextLayoutEngineBaseline::SVGTextLayoutEngineBaseline(const Font& font, 28 SVGTextLayoutEngineBaseline::SVGTextLayoutEngineBaseline(const Font& font,
29 float effectiveZoom) 29 float effectiveZoom)
30 : m_font(font), m_effectiveZoom(effectiveZoom) { 30 : m_font(font), m_effectiveZoom(effectiveZoom) {
31 ASSERT(m_effectiveZoom); 31 DCHECK(m_effectiveZoom);
32 } 32 }
33 33
34 float SVGTextLayoutEngineBaseline::calculateBaselineShift( 34 float SVGTextLayoutEngineBaseline::calculateBaselineShift(
35 const ComputedStyle& style) const { 35 const ComputedStyle& style) const {
36 const SVGComputedStyle& svgStyle = style.svgStyle(); 36 const SVGComputedStyle& svgStyle = style.svgStyle();
37 const SimpleFontData* fontData = m_font.primaryFont(); 37 const SimpleFontData* fontData = m_font.primaryFont();
38 DCHECK(fontData); 38 DCHECK(fontData);
39 if (!fontData) 39 if (!fontData)
40 return 0; 40 return 0;
41 41
(...skipping 10 matching lines...) Expand all
52 default: 52 default:
53 NOTREACHED(); 53 NOTREACHED();
54 return 0; 54 return 0;
55 } 55 }
56 } 56 }
57 57
58 EAlignmentBaseline 58 EAlignmentBaseline
59 SVGTextLayoutEngineBaseline::dominantBaselineToAlignmentBaseline( 59 SVGTextLayoutEngineBaseline::dominantBaselineToAlignmentBaseline(
60 bool isVerticalText, 60 bool isVerticalText,
61 LineLayoutItem textLineLayout) const { 61 LineLayoutItem textLineLayout) const {
62 ASSERT(textLineLayout); 62 DCHECK(textLineLayout);
63 ASSERT(textLineLayout.style()); 63 DCHECK(textLineLayout.style());
64 64
65 const SVGComputedStyle& style = textLineLayout.style()->svgStyle(); 65 const SVGComputedStyle& style = textLineLayout.style()->svgStyle();
66 66
67 EDominantBaseline baseline = style.dominantBaseline(); 67 EDominantBaseline baseline = style.dominantBaseline();
68 if (baseline == DB_AUTO) { 68 if (baseline == DB_AUTO) {
69 if (isVerticalText) 69 if (isVerticalText)
70 baseline = DB_CENTRAL; 70 baseline = DB_CENTRAL;
71 else 71 else
72 baseline = DB_ALPHABETIC; 72 baseline = DB_ALPHABETIC;
73 } 73 }
74 74
75 switch (baseline) { 75 switch (baseline) {
76 case DB_USE_SCRIPT: 76 case DB_USE_SCRIPT:
77 // TODO(fs): The dominant-baseline and the baseline-table components 77 // TODO(fs): The dominant-baseline and the baseline-table components
78 // are set by determining the predominant script of the character data 78 // are set by determining the predominant script of the character data
79 // content. 79 // content.
80 return AB_ALPHABETIC; 80 return AB_ALPHABETIC;
81 case DB_NO_CHANGE: 81 case DB_NO_CHANGE:
82 ASSERT(textLineLayout.parent()); 82 DCHECK(textLineLayout.parent());
83 return dominantBaselineToAlignmentBaseline(isVerticalText, 83 return dominantBaselineToAlignmentBaseline(isVerticalText,
84 textLineLayout.parent()); 84 textLineLayout.parent());
85 case DB_RESET_SIZE: 85 case DB_RESET_SIZE:
86 ASSERT(textLineLayout.parent()); 86 DCHECK(textLineLayout.parent());
87 return dominantBaselineToAlignmentBaseline(isVerticalText, 87 return dominantBaselineToAlignmentBaseline(isVerticalText,
88 textLineLayout.parent()); 88 textLineLayout.parent());
89 case DB_IDEOGRAPHIC: 89 case DB_IDEOGRAPHIC:
90 return AB_IDEOGRAPHIC; 90 return AB_IDEOGRAPHIC;
91 case DB_ALPHABETIC: 91 case DB_ALPHABETIC:
92 return AB_ALPHABETIC; 92 return AB_ALPHABETIC;
93 case DB_HANGING: 93 case DB_HANGING:
94 return AB_HANGING; 94 return AB_HANGING;
95 case DB_MATHEMATICAL: 95 case DB_MATHEMATICAL:
96 return AB_MATHEMATICAL; 96 return AB_MATHEMATICAL;
97 case DB_CENTRAL: 97 case DB_CENTRAL:
98 return AB_CENTRAL; 98 return AB_CENTRAL;
99 case DB_MIDDLE: 99 case DB_MIDDLE:
100 return AB_MIDDLE; 100 return AB_MIDDLE;
101 case DB_TEXT_AFTER_EDGE: 101 case DB_TEXT_AFTER_EDGE:
102 return AB_TEXT_AFTER_EDGE; 102 return AB_TEXT_AFTER_EDGE;
103 case DB_TEXT_BEFORE_EDGE: 103 case DB_TEXT_BEFORE_EDGE:
104 return AB_TEXT_BEFORE_EDGE; 104 return AB_TEXT_BEFORE_EDGE;
105 default: 105 default:
106 NOTREACHED(); 106 NOTREACHED();
107 return AB_AUTO; 107 return AB_AUTO;
108 } 108 }
109 } 109 }
110 110
111 float SVGTextLayoutEngineBaseline::calculateAlignmentBaselineShift( 111 float SVGTextLayoutEngineBaseline::calculateAlignmentBaselineShift(
112 bool isVerticalText, 112 bool isVerticalText,
113 LineLayoutItem textLineLayout) const { 113 LineLayoutItem textLineLayout) const {
114 ASSERT(textLineLayout); 114 DCHECK(textLineLayout);
115 ASSERT(textLineLayout.style()); 115 DCHECK(textLineLayout.style());
116 ASSERT(textLineLayout.parent()); 116 DCHECK(textLineLayout.parent());
117 117
118 LineLayoutItem textLineLayoutParent = textLineLayout.parent(); 118 LineLayoutItem textLineLayoutParent = textLineLayout.parent();
119 ASSERT(textLineLayoutParent); 119 DCHECK(textLineLayoutParent);
120 120
121 EAlignmentBaseline baseline = 121 EAlignmentBaseline baseline =
122 textLineLayout.style()->svgStyle().alignmentBaseline(); 122 textLineLayout.style()->svgStyle().alignmentBaseline();
123 if (baseline == AB_AUTO || baseline == AB_BASELINE) { 123 if (baseline == AB_AUTO || baseline == AB_BASELINE) {
124 baseline = dominantBaselineToAlignmentBaseline(isVerticalText, 124 baseline = dominantBaselineToAlignmentBaseline(isVerticalText,
125 textLineLayoutParent); 125 textLineLayoutParent);
126 ASSERT(baseline != AB_AUTO && baseline != AB_BASELINE); 126 DCHECK_NE(baseline, AB_AUTO);
127 DCHECK_NE(baseline, AB_BASELINE);
127 } 128 }
128 129
129 const SimpleFontData* fontData = m_font.primaryFont(); 130 const SimpleFontData* fontData = m_font.primaryFont();
130 DCHECK(fontData); 131 DCHECK(fontData);
131 if (!fontData) 132 if (!fontData)
132 return 0; 133 return 0;
133 134
134 const FontMetrics& fontMetrics = fontData->getFontMetrics(); 135 const FontMetrics& fontMetrics = fontData->getFontMetrics();
135 float ascent = fontMetrics.floatAscent() / m_effectiveZoom; 136 float ascent = fontMetrics.floatAscent() / m_effectiveZoom;
136 float descent = fontMetrics.floatDescent() / m_effectiveZoom; 137 float descent = fontMetrics.floatDescent() / m_effectiveZoom;
(...skipping 19 matching lines...) Expand all
156 case AB_MATHEMATICAL: 157 case AB_MATHEMATICAL:
157 return ascent / 2; 158 return ascent / 2;
158 case AB_BASELINE: 159 case AB_BASELINE:
159 default: 160 default:
160 NOTREACHED(); 161 NOTREACHED();
161 return 0; 162 return 0;
162 } 163 }
163 } 164 }
164 165
165 } // namespace blink 166 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698