https://bugs.webkit.org/show_bug.cgi?id=85755
Patch by Lamarque V. Souza <Lamarque.Souza@basyskom.com> on 2013-02-14
Reviewed by David Hyatt.
Original patch by Sumedha Widyadharma <sumedha.widyadharma@basyskom.com>.
Source/WebCore:
Test: fast/css/css3-ch-unit.html
* css/CSSCalculationValue.cpp:
(WebCore::unitCategory):
* css/CSSGrammar.y.in:
* css/CSSParser.cpp:
(WebCore::CSSParser::validUnit):
(WebCore::CSSParser::createPrimitiveNumericValue):
(WebCore::CSSParser::parseValidPrimitive):
(WebCore::CSSParser::detectNumberToken):
* css/CSSParserValues.cpp:
(WebCore::CSSParserValue::createCSSValue):
* css/CSSPrimitiveValue.cpp:
(WebCore::isValidCSSUnitTypeForDoubleConversion):
(WebCore::CSSPrimitiveValue::cleanup):
(WebCore::CSSPrimitiveValue::computeLengthDouble):
(WebCore::CSSPrimitiveValue::customCssText):
(WebCore::CSSPrimitiveValue::cloneForCSSOM):
* css/CSSPrimitiveValue.h:
(WebCore::CSSPrimitiveValue::isFontRelativeLength):
(WebCore::CSSPrimitiveValue::isLength):
* platform/graphics/FontMetrics.h:
(WebCore::FontMetrics::FontMetrics):
(WebCore::FontMetrics::zeroWidth):
(WebCore::FontMetrics::setZeroWidth):
(FontMetrics):
(WebCore::FontMetrics::hasZeroWidth):
(WebCore::FontMetrics::setHasZeroWidth):
* platform/graphics/SimpleFontData.cpp:
(WebCore::SimpleFontData::platformGlyphInit):
* platform/graphics/SimpleFontData.h:
(WebCore::SimpleFontData::zeroGlyph):
(WebCore::SimpleFontData::setZeroGlyph):
(SimpleFontData):
* platform/graphics/qt/SimpleFontDataQt.cpp:
(WebCore::SimpleFontData::platformInit):
LayoutTests:
* fast/css/css3-ch-unit-expected.txt: Added.
* fast/css/css3-ch-unit.html: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@142904
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2013-02-14 Lamarque V. Souza <Lamarque.Souza@basyskom.com>
+
+ Support the ch unit from css3-values
+ https://bugs.webkit.org/show_bug.cgi?id=85755
+
+ Reviewed by David Hyatt.
+
+ Original patch by Sumedha Widyadharma <sumedha.widyadharma@basyskom.com>.
+
+ * fast/css/css3-ch-unit-expected.txt: Added.
+ * fast/css/css3-ch-unit.html: Added.
+
2013-02-14 Philip Rogers <pdr@google.com>
Prevent inconsistent firstChild during document destruction
--- /dev/null
+This is a test to make sure ch units work as intended.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.getElementById("box_mono_zero").clientWidth is 0
+PASS document.getElementById("box_mono_four1").clientWidth is document.getElementById("box_mono_four2").clientWidth
+PASS document.getElementById("box_monofallthrough_four1").clientWidth is document.getElementById("box_monofallthrough_four2").clientWidth
+PASS document.getElementById("mono_box_alphalen1").clientWidth is document.getElementById("mono_box_alphalen2").clientWidth
+PASS document.getElementById("box_one").clientWidth * 26 is document.getElementById("box_alphalen").clientWidth
+PASS document.getElementById("arial_box_one").clientWidth * 26 is document.getElementById("arial_box_alphalen").clientWidth
+PASS document.getElementById("helvetica_box_one").clientWidth * 26 is document.getElementById("helvetica_box_alphalen").clientWidth
+PASS document.getElementById("times_box_one").clientWidth * 4 is document.getElementById("box_times_four").clientWidth
+PASS document.getElementById("arial_box_one").clientWidth * 4 is document.getElementById("box_arial_four").clientWidth
+PASS document.getElementById("helvetica_box_one").clientWidth * 4 is document.getElementById("box_helvetica_four").clientWidth
+PASS document.getElementById("ref_box_arial_one").clientWidth is >= document.getElementById("box_arial_one").clientWidth
+PASS document.getElementById("ref_box_times_one").clientWidth is >= document.getElementById("box_times_one").clientWidth
+PASS document.getElementById("ref_box_sansserif_one").clientWidth is >= document.getElementById("box_sansserif_one").clientWidth
+PASS w1 !== w2 || h1 !== h2 is false
+PASS ps1h > ps2h && ps1h > ps3h is true
+PASS document.getElementById("box_mono_one").clientWidth is document.getElementById("box_mono").clientWidth
+PASS successfullyParsed is true
+
+TEST COMPLETE
+This is a test to make sure ch units work as intended. You should not see anything red on this page.
+
+Only 'PASS' should be visible:
+PASS
+PASS
+PASS
+PASS
+The whole lower case alphabet should be readable:
+abcdefghijklmnopqrstuvwxyz
+abcdefghijklmnopqrstuvwxyz
+abcdefghijklmnopqrstuvwxyz
+abcdefghijklmnopqrstuvwxyz
+abcdefghijklmnopqrstuvwxyz
+Four zeroes should be visible, nothing else:
+0000
+0000
+0000 There should be more than one green '|' visible (non-monospaced fonts):
+|||0|||
+|||0|||
+|||0|||
+This box has a 20px font size. The last two '0's should be the same size.
+0
+0
+0
+I'm a pseudo selected first line, I should be bigger than the rest.
+I'm the second line.
+Last in line. But one day... the throne will be mine!
+0
--- /dev/null
+<!doctype html>
+<html>
+<head>
+<style type="text/css" title="teste">
+ .box {
+ margin: 0px;
+ padding: 0px;
+ overflow: hidden;
+ }
+ .border { border:1px solid black; }
+
+ /* font family classes */
+ .mono { font-family: monospace; }
+ .monofallthrough { font-family: nonexistant, monospace; }
+ .serif { font-family: serif; }
+ .sans-serif { font-family: sans-serif; }
+ .courier { font-family: courier; }
+ .arial { font-family: arial; }
+ .times { font-family: times; }
+ .helvetica { font-family: helvetica; }
+
+ /* ch-length containers */
+ .one { width: 1ch; }
+ .four { width: 4ch; }
+ .zero { width: 0ch; }
+ .alphalen { width: 26ch; }
+
+ /* font sizes for the relative size test */
+ .large { font-size:20px; }
+ .relative { font-size:1ch; }
+
+ /* pass/fail colors */
+ .pass { color: green; }
+ .fail { color: red; }
+
+ /* pseudo-elements */
+ #pseudo{
+ font-size:2ch;
+ }
+ #pseudo:first-line {
+ font-size:3ch;
+ }
+ #pseudo span:last-child {
+ font-size:1ch;
+ }
+</style>
+<script src="../js/resources/js-test-pre.js"></script>
+<script type="text/javascript">
+</script>
+</head>
+<body id="body">
+ <p>This is a test to make sure ch units work as intended. You should not see <b>anything</b> red on this page.</p>
+ Only 'PASS' should be visible:
+ <div id="box_mono_zero" class="box mono zero"></div>
+ <script type="text/javascript">
+ description("This is a test to make sure ch units work as intended.")
+ shouldEvaluateTo('document.getElementById("box_mono_zero").clientWidth', "0");
+ </script>
+
+ <div id="box_mono_four1" class="box mono four"><span class="pass">PASS</span><span class="fail">FAIL</span></div>
+ <div id="box_mono_four2" class="box mono four"><span class="pass">PASS</span></div>
+ <script type="text/javascript">
+ shouldEvaluateTo('document.getElementById("box_mono_four1").clientWidth', 'document.getElementById("box_mono_four2").clientWidth');
+ </script>
+
+ <div id="box_monofallthrough_four1" class="box monofallthrough four"><span class="pass">PASS</span><span class="fail">FAIL</span></div>
+ <div id="box_monofallthrough_four2" class="box monofallthrough four"><span class="pass">PASS</span></div>
+ <script type="text/javascript">
+ shouldEvaluateTo('document.getElementById("box_monofallthrough_four1").clientWidth', 'document.getElementById("box_monofallthrough_four2").clientWidth');
+ </script>
+
+ The whole lower case alphabet should be readable:
+ <div id="mono_box_alphalen1" class="mono box alphalen"><span class="pass">abcdefghijklmnopqrstuvwxyz</span><span class="fail">FAIL</span></div>
+ <div id="mono_box_alphalen2" class="mono box alphalen"><span class="pass">abcdefghijklmnopqrstuvwxyz</span></div>
+ <script type="text/javascript">
+ shouldEvaluateTo('document.getElementById("mono_box_alphalen1").clientWidth', 'document.getElementById("mono_box_alphalen2").clientWidth');
+ </script>
+
+ <div id="box_one" class="box one"></div>
+ <div id="box_alphalen" class="box alphalen"><span class="pass">abcdefghijklmnopqrstuvwxyz</span></div>
+ <script type="text/javascript">
+ shouldEvaluateTo('document.getElementById("box_one").clientWidth * 26', 'document.getElementById("box_alphalen").clientWidth');
+ </script>
+
+ <div id="arial_box_one" class="arial box one"></div>
+ <div id="arial_box_alphalen" class="arial box alphalen"><span class="pass">abcdefghijklmnopqrstuvwxyz</span></div>
+ <script type="text/javascript">
+ shouldEvaluateTo('document.getElementById("arial_box_one").clientWidth * 26', 'document.getElementById("arial_box_alphalen").clientWidth');
+ </script>
+
+ <div id="helvetica_box_one" class="helvetica box one"></div>
+ <div id="helvetica_box_alphalen" class="helvetica box alphalen"><span class="pass">abcdefghijklmnopqrstuvwxyz</span></div>
+ <script type="text/javascript">
+ shouldEvaluateTo('document.getElementById("helvetica_box_one").clientWidth * 26', 'document.getElementById("helvetica_box_alphalen").clientWidth');
+ </script>
+
+ Four zeroes should be visible, nothing else:
+ <div id="times_box_one" class="times box one"></div>
+ <div id="box_times_four" class="box times four"><span class="pass">0000</span><span class="fail">FAIL</span></div>
+ <script type="text/javascript">
+ shouldEvaluateTo('document.getElementById("times_box_one").clientWidth * 4', 'document.getElementById("box_times_four").clientWidth');
+ </script>
+
+ <div id="box_arial_four" class="box arial four"><span class="pass">0000</span><span class="fail">FAIL</span></div>
+ <script type="text/javascript">
+ shouldEvaluateTo('document.getElementById("arial_box_one").clientWidth * 4', 'document.getElementById("box_arial_four").clientWidth');
+ </script>
+
+ <div id="box_helvetica_four" class="box helvetica four"><span class="pass">0000</span><span class="fail">FAIL</span></div>
+ <script type="text/javascript">
+ shouldEvaluateTo('document.getElementById("helvetica_box_one").clientWidth * 4', 'document.getElementById("box_helvetica_four").clientWidth');
+ </script>
+
+ There should be more than one green '|' visible (non-monospaced fonts):
+ <div id="box_arial_one" class="box arial one"><span class="pass">|</span><span class="pass">||0</span><span class="fail">||||</span></div>
+ <div id="ref_box_arial_one" class="box arial" style="display:inline-block"><span class="pass">|</span><span class="pass">||</span></div>
+ <script type="text/javascript">
+ shouldBeGreaterThanOrEqual('document.getElementById("ref_box_arial_one").clientWidth', 'document.getElementById("box_arial_one").clientWidth');
+ </script>
+
+ <div id="box_times_one" class="box times one"><span class="pass">|</span><span class="pass">||0</span><span class="fail">||||</span></div>
+ <div id="ref_box_times_one" class="box times" style="display:inline-block"><span class="pass">|</span><span class="pass">||</span></div>
+ <script type="text/javascript">
+ shouldBeGreaterThanOrEqual('document.getElementById("ref_box_times_one").clientWidth', 'document.getElementById("box_times_one").clientWidth');
+ </script>
+
+ <div id="box_sansserif_one" class="box sansserif one"><span class="pass">|</span><span class="pass">||0</span><span class="fail">||||</span></div>
+ <div id="ref_box_sansserif_one" class="box times" style="display:inline-block"><span class="pass">|</span><span class="pass">||</span></div>
+ <script type="text/javascript">
+ shouldBeGreaterThanOrEqual('document.getElementById("ref_box_sansserif_one").clientWidth', 'document.getElementById("box_sansserif_one").clientWidth');
+ </script>
+
+ <div class="border">
+ This box has a 20px font size.
+ The last two '0's should be the same size.
+ <div class="large pass">
+ <div id="reference" class="one">0</div>
+ <div id="forcedsmall" class="box one">0</div>
+ <div id="chsmall" class="box one relative">0</div>
+ </div>
+ <script type="text/javascript">
+ var ref = document.getElementById("reference");
+ var refWidth = ref.clientWidth;
+ var small = document.getElementById("forcedsmall");
+ small.style.fontSize = refWidth +"px";
+ var w1 = small.clientWidth;
+ var h1 = small.clientHeight;
+ var chsmall = document.getElementById("chsmall");
+ var w2 = chsmall.clientWidth;
+ var h2 = chsmall.clientHeight;
+ shouldBeFalse("w1 !== w2 || h1 !== h2");
+ </script>
+ </div>
+ <div id="pseudo">
+ <span id="ps1">I'm a pseudo selected first line, I should be bigger than the rest.</span><br>
+ <span id="ps2">I'm the second line.</span><br>
+ <span id="ps3">Last in line. But one day... the throne will be mine!</span>
+ </div>
+ <script>
+ var ps1h = document.getElementById('ps1').offsetHeight;
+ var ps2h = document.getElementById('ps2').offsetHeight;
+ var ps3h = document.getElementById('ps3').offsetHeight;
+ shouldBeTrue("ps1h > ps2h && ps1h > ps3h");
+ </script>
+
+ <div id="box_mono_one" class="box mono one"></div>
+ <div id="box_mono" class="box mono" style="display:inline-block">0</div>
+ <script type="text/javascript">
+ shouldEvaluateTo('document.getElementById("box_mono_one").clientWidth', 'document.getElementById("box_mono").clientWidth');
+ </script>
+ <script src="../js/resources/js-test-post.js"></script>
+ <script>
+ // Text with '<span class="fail">' must not appear in DumpRenderTree's output, only when opening this file in a web browser.
+ if (window.testRunner) {
+ var CSSRules = 'rules';
+ for (var i = 0; i < document.styleSheets[0][CSSRules].length; ++i)
+ if (document.styleSheets[0][CSSRules][i].selectorText === ".fail") {
+ document.styleSheets[0][CSSRules][i].style['display'] = 'none';
+ break;
+ }
+ }
+ </script>
+</body>
+</html>
+2013-02-14 Lamarque V. Souza <Lamarque.Souza@basyskom.com>
+
+ Support the ch unit from css3-values
+ https://bugs.webkit.org/show_bug.cgi?id=85755
+
+ Reviewed by David Hyatt.
+
+ Original patch by Sumedha Widyadharma <sumedha.widyadharma@basyskom.com>.
+
+ Test: fast/css/css3-ch-unit.html
+
+ * css/CSSCalculationValue.cpp:
+ (WebCore::unitCategory):
+ * css/CSSGrammar.y.in:
+ * css/CSSParser.cpp:
+ (WebCore::CSSParser::validUnit):
+ (WebCore::CSSParser::createPrimitiveNumericValue):
+ (WebCore::CSSParser::parseValidPrimitive):
+ (WebCore::CSSParser::detectNumberToken):
+ * css/CSSParserValues.cpp:
+ (WebCore::CSSParserValue::createCSSValue):
+ * css/CSSPrimitiveValue.cpp:
+ (WebCore::isValidCSSUnitTypeForDoubleConversion):
+ (WebCore::CSSPrimitiveValue::cleanup):
+ (WebCore::CSSPrimitiveValue::computeLengthDouble):
+ (WebCore::CSSPrimitiveValue::customCssText):
+ (WebCore::CSSPrimitiveValue::cloneForCSSOM):
+ * css/CSSPrimitiveValue.h:
+ (WebCore::CSSPrimitiveValue::isFontRelativeLength):
+ (WebCore::CSSPrimitiveValue::isLength):
+ * platform/graphics/FontMetrics.h:
+ (WebCore::FontMetrics::FontMetrics):
+ (WebCore::FontMetrics::zeroWidth):
+ (WebCore::FontMetrics::setZeroWidth):
+ (FontMetrics):
+ (WebCore::FontMetrics::hasZeroWidth):
+ (WebCore::FontMetrics::setHasZeroWidth):
+ * platform/graphics/SimpleFontData.cpp:
+ (WebCore::SimpleFontData::platformGlyphInit):
+ * platform/graphics/SimpleFontData.h:
+ (WebCore::SimpleFontData::zeroGlyph):
+ (WebCore::SimpleFontData::setZeroGlyph):
+ (SimpleFontData):
+ * platform/graphics/qt/SimpleFontDataQt.cpp:
+ (WebCore::SimpleFontData::platformInit):
+
2013-02-14 David Kilzer <ddkilzer@apple.com>
[Mac] Clean up WARNING_CFLAGS
case CSSPrimitiveValue::CSS_PT:
case CSSPrimitiveValue::CSS_PC:
case CSSPrimitiveValue::CSS_REMS:
+ case CSSPrimitiveValue::CSS_CHS:
return CalcLength;
#if ENABLE(CSS_VARIABLES)
case CSSPrimitiveValue::CSS_VARIABLE_NAME:
%}
#if ENABLE_SHADOW_DOM
-%expect 67
+%expect 68
#else
-%expect 66
+%expect 67
#endif
%nonassoc LOWEST_PREC
#endif
%token <number> REMS
+%token <number> CHS
%token <number> QEMS
%token <number> EMS
%token <number> EXS
if (parser->m_styleSheet)
parser->m_styleSheet->parserSetUsesRemUnits(true);
}
+ | CHS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_CHS; }
| VW maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_VW; }
| VH maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_VH; }
| VMIN maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_VMIN; }
case CSSParserValue::Q_EMS:
case CSSPrimitiveValue::CSS_EMS:
case CSSPrimitiveValue::CSS_REMS:
+ case CSSPrimitiveValue::CSS_CHS:
case CSSPrimitiveValue::CSS_EXS:
case CSSPrimitiveValue::CSS_PX:
case CSSPrimitiveValue::CSS_CM:
#if ENABLE(CSS_IMAGE_RESOLUTION) || ENABLE(RESOLUTION_MEDIA_QUERY)
ASSERT((value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ)
- || (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiveValue::CSS_REMS)
+ || (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiveValue::CSS_CHS)
|| (value->unit >= CSSPrimitiveValue::CSS_VW && value->unit <= CSSPrimitiveValue::CSS_VMAX)
|| (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrimitiveValue::CSS_DPCM));
#else
ASSERT((value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ)
- || (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiveValue::CSS_REMS)
+ || (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiveValue::CSS_CHS)
|| (value->unit >= CSSPrimitiveValue::CSS_VW && value->unit <= CSSPrimitiveValue::CSS_VMAX));
#endif
return cssValuePool().createValue(value->fValue, static_cast<CSSPrimitiveValue::UnitTypes>(value->unit));
return createPrimitiveStringValue(value);
if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ)
return createPrimitiveNumericValue(value);
- if (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiveValue::CSS_REMS)
+ if (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiveValue::CSS_CHS)
return createPrimitiveNumericValue(value);
if (value->unit >= CSSPrimitiveValue::CSS_VW && value->unit <= CSSPrimitiveValue::CSS_VMAX)
return createPrimitiveNumericValue(value);
case 'c':
if (length == 2 && isASCIIAlphaCaselessEqual(type[1], 'm'))
m_token = CMS;
+ else if (length == 2 && isASCIIAlphaCaselessEqual(type[1], 'h'))
+ m_token = CHS;
return;
case 'd':
case CSSPrimitiveValue::CSS_VMAX:
case CSSPrimitiveValue::CSS_TURN:
case CSSPrimitiveValue::CSS_REMS:
+ case CSSPrimitiveValue::CSS_CHS:
return CSSPrimitiveValue::create(fValue, primitiveUnit);
case CSSPrimitiveValue::CSS_UNKNOWN:
case CSSPrimitiveValue::CSS_DIMENSION:
case CSSPrimitiveValue::CSS_PX:
case CSSPrimitiveValue::CSS_RAD:
case CSSPrimitiveValue::CSS_REMS:
+ case CSSPrimitiveValue::CSS_CHS:
case CSSPrimitiveValue::CSS_S:
case CSSPrimitiveValue::CSS_TURN:
case CSSPrimitiveValue::CSS_VW:
case CSS_EMS:
case CSS_EXS:
case CSS_REMS:
+ case CSS_CHS:
case CSS_PX:
case CSS_CM:
case CSS_MM:
else
factor = 1.0;
break;
+ case CSS_CHS:
+ factor = style->fontMetrics().zeroWidth();
+ break;
case CSS_PX:
factor = 1.0;
break;
case CSS_REMS:
text = formatNumber(m_value.num, "rem");
break;
+ case CSS_CHS:
+ text = formatNumber(m_value.num, "ch");
+ break;
case CSS_PX:
text = formatNumber(m_value.num, "px");
break;
case CSS_EMS:
case CSS_EXS:
case CSS_REMS:
+ case CSS_CHS:
case CSS_PX:
case CSS_CM:
case CSS_MM:
// These are from CSS3 Values and Units, but that isn't a finished standard yet
CSS_TURN = 107,
CSS_REMS = 108,
+ CSS_CHS = 109,
// This is used internally for counter names (as opposed to counter values)
- CSS_COUNTER_NAME = 109,
+ CSS_COUNTER_NAME = 110,
// This is used by the CSS Exclusions draft
- CSS_SHAPE = 110,
+ CSS_SHAPE = 111,
// Used by border images.
- CSS_QUAD = 111,
+ CSS_QUAD = 112,
- CSS_CALC = 112,
- CSS_CALC_PERCENTAGE_WITH_NUMBER = 113,
- CSS_CALC_PERCENTAGE_WITH_LENGTH = 114,
+ CSS_CALC = 113,
+ CSS_CALC_PERCENTAGE_WITH_NUMBER = 114,
+ CSS_CALC_PERCENTAGE_WITH_LENGTH = 115,
#if ENABLE(CSS_VARIABLES)
- CSS_VARIABLE_NAME = 115,
+ CSS_VARIABLE_NAME = 116,
#endif
};
bool isFontIndependentLength() const { return m_primitiveUnitType >= CSS_PX && m_primitiveUnitType <= CSS_PC; }
bool isFontRelativeLength() const
{
- return m_primitiveUnitType == CSS_EMS || m_primitiveUnitType == CSS_EXS || m_primitiveUnitType == CSS_REMS;
+ return m_primitiveUnitType == CSS_EMS
+ || m_primitiveUnitType == CSS_EXS
+ || m_primitiveUnitType == CSS_REMS
+ || m_primitiveUnitType == CSS_CHS;
}
bool isIdent() const { return m_primitiveUnitType == CSS_IDENT; }
bool isLength() const
{
unsigned short type = primitiveType();
- return (type >= CSS_EMS && type <= CSS_PC) || type == CSS_REMS;
+ return (type >= CSS_EMS && type <= CSS_PC) || type == CSS_REMS || type == CSS_CHS;
}
bool isNumber() const { return primitiveType() == CSS_NUMBER; }
bool isPercentage() const { return primitiveType() == CSS_PERCENTAGE; }
, m_lineGap(0)
, m_lineSpacing(0)
, m_xHeight(0)
+ , m_zeroWidth(0)
, m_hasXHeight(false)
+ , m_hasZeroWidth(false)
{
}
return ascent() == other.ascent() && descent() == other.descent() && lineGap() == other.lineGap();
}
+ float zeroWidth() const { return m_zeroWidth; }
+ void setZeroWidth(float zeroWidth)
+ {
+ m_zeroWidth = zeroWidth;
+ m_hasZeroWidth = true;
+ }
+
+ bool hasZeroWidth() const { return m_hasZeroWidth; }
+ void setHasZeroWidth(bool hasZeroWidth) { m_hasZeroWidth = hasZeroWidth; }
+
private:
friend class SimpleFontData;
float m_lineGap;
float m_lineSpacing;
float m_xHeight;
+ float m_zeroWidth;
bool m_hasXHeight;
+ bool m_hasZeroWidth;
};
static inline float scaleEmToUnits(float x, unsigned unitsPerEm)
LOG_ERROR("Failed to get glyph page zero.");
m_spaceGlyph = 0;
m_spaceWidth = 0;
+ m_zeroGlyph = 0;
m_adjustedSpaceWidth = 0;
determinePitch();
m_zeroWidthSpaceGlyph = 0;
m_spaceGlyph = glyphPageZero->glyphDataForCharacter(' ').glyph;
float width = widthForGlyph(m_spaceGlyph);
m_spaceWidth = width;
+ m_zeroGlyph = glyphPageZero->glyphDataForCharacter('0').glyph;
+ m_fontMetrics.setZeroWidth(widthForGlyph(m_zeroGlyph));
determinePitch();
m_adjustedSpaceWidth = m_treatAsFixedPitch ? ceilf(width) : roundf(width);
Glyph zeroWidthSpaceGlyph() const { return m_zeroWidthSpaceGlyph; }
void setZeroWidthSpaceGlyph(Glyph spaceGlyph) { m_zeroWidthSpaceGlyph = spaceGlyph; }
bool isZeroWidthSpaceGlyph(Glyph glyph) const { return glyph == m_zeroWidthSpaceGlyph && glyph; }
+ Glyph zeroGlyph() const { return m_zeroGlyph; }
+ void setZeroGlyph(Glyph zeroGlyph) { m_zeroGlyph = zeroGlyph; }
virtual const SimpleFontData* fontDataForCharacter(UChar32) const;
virtual bool containsCharacters(const UChar*, int length) const;
Glyph m_spaceGlyph;
float m_spaceWidth;
+ Glyph m_zeroGlyph;
float m_adjustedSpaceWidth;
Glyph m_zeroWidthSpaceGlyph;
QVector<QPointF> advances = rawFont.advancesForGlyphIndexes(indexes);
float spaceWidth = advances.at(0).x();
+ indexes = rawFont.glyphIndexesForString(QLatin1String("0"));
+ advances = rawFont.advancesForGlyphIndexes(indexes);
+ float zeroWidth = advances.at(0).x();
+
// The line spacing should always be >= (ascent + descent), but this
// may be false in some cases due to misbehaving platform libraries.
// Workaround from SimpleFontPango.cpp and SimpleFontFreeType.cpp
m_fontMetrics.setLineSpacing(lineSpacing);
m_fontMetrics.setXHeight(xHeight);
m_fontMetrics.setLineGap(lineGap);
+ m_fontMetrics.setZeroWidth(zeroWidth);
m_spaceWidth = spaceWidth;
}