<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[177866] trunk/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/177866">177866</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2015-01-02 11:53:38 -0800 (Fri, 02 Jan 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Move 'font-size' CSS property to the new StyleBuilder
https://bugs.webkit.org/show_bug.cgi?id=140010
Reviewed by Darin Adler.
Move 'font-size' CSS property to the new StyleBuilder by using custom
code.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecssCSSComputedStyleDeclarationcpp">trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp</a></li>
<li><a href="#trunkSourceWebCorecssCSSPropertyNamesin">trunk/Source/WebCore/css/CSSPropertyNames.in</a></li>
<li><a href="#trunkSourceWebCorecssDeprecatedStyleBuildercpp">trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp</a></li>
<li><a href="#trunkSourceWebCorecssStyleBuilderCustomh">trunk/Source/WebCore/css/StyleBuilderCustom.h</a></li>
<li><a href="#trunkSourceWebCorecssStyleResolvercpp">trunk/Source/WebCore/css/StyleResolver.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFontDescriptionh">trunk/Source/WebCore/platform/graphics/FontDescription.h</a></li>
<li><a href="#trunkSourceWebCorestyleStyleResolveForDocumentcpp">trunk/Source/WebCore/style/StyleResolveForDocument.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (177865 => 177866)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-01-02 18:32:38 UTC (rev 177865)
+++ trunk/Source/WebCore/ChangeLog        2015-01-02 19:53:38 UTC (rev 177866)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2015-01-02 Chris Dumez <cdumez@apple.com>
+
+ Move 'font-size' CSS property to the new StyleBuilder
+ https://bugs.webkit.org/show_bug.cgi?id=140010
+
+ Reviewed by Darin Adler.
+
+ Move 'font-size' CSS property to the new StyleBuilder by using custom
+ code.
+
</ins><span class="cx"> 2015-01-02 Darin Adler <darin@apple.com>
</span><span class="cx">
</span><span class="cx"> Pass Document instead of ScriptExecutionContext to non-worker constructors
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSComputedStyleDeclarationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (177865 => 177866)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp        2015-01-02 18:32:38 UTC (rev 177865)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp        2015-01-02 19:53:38 UTC (rev 177866)
</span><span class="lines">@@ -1282,13 +1282,6 @@
</span><span class="cx"> ec = NO_MODIFICATION_ALLOWED_ERR;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static CSSValueID cssIdentifierForFontSizeKeyword(int keywordSize)
-{
- ASSERT_ARG(keywordSize, keywordSize);
- ASSERT_ARG(keywordSize, keywordSize <= 8);
- return static_cast<CSSValueID>(CSSValueXxSmall + keywordSize - 1);
-}
-
</del><span class="cx"> PassRefPtr<CSSPrimitiveValue> ComputedStyleExtractor::getFontSizeCSSValuePreferringKeyword() const
</span><span class="cx"> {
</span><span class="cx"> if (!m_node)
</span><span class="lines">@@ -1300,8 +1293,8 @@
</span><span class="cx"> if (!style)
</span><span class="cx"> return nullptr;
</span><span class="cx">
</span><del>- if (int keywordSize = style->fontDescription().keywordSize())
- return cssValuePool().createIdentifierValue(cssIdentifierForFontSizeKeyword(keywordSize));
</del><ins>+ if (CSSValueID sizeIdentifier = style->fontDescription().keywordSizeAsIdentifier())
+ return cssValuePool().createIdentifierValue(sizeIdentifier);
</ins><span class="cx">
</span><span class="cx"> return zoomAdjustedPixelValue(style->fontDescription().computedPixelSize(), style.get());
</span><span class="cx"> }
</span><span class="lines">@@ -3241,12 +3234,12 @@
</span><span class="cx"> {
</span><span class="cx"> if (propertyID == CSSPropertyFontSize && is<CSSPrimitiveValue>(*value) && m_node) {
</span><span class="cx"> m_node->document().updateLayoutIgnorePendingStylesheets();
</span><del>- RenderStyle* style = m_node->computedStyle(m_pseudoElementSpecifier);
- if (style && style->fontDescription().keywordSize()) {
- CSSValueID sizeValue = cssIdentifierForFontSizeKeyword(style->fontDescription().keywordSize());
- const CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
- if (primitiveValue.isValueID() && primitiveValue.getValueID() == sizeValue)
- return true;
</del><ins>+ if (RenderStyle* style = m_node->computedStyle(m_pseudoElementSpecifier)) {
+ if (CSSValueID sizeIdentifier = style->fontDescription().keywordSizeAsIdentifier()) {
+ auto& primitiveValue = downcast<CSSPrimitiveValue>(*value);
+ if (primitiveValue.isValueID() && primitiveValue.getValueID() == sizeIdentifier)
+ return true;
+ }
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> RefPtr<CSSValue> computedValue = propertyValue(propertyID);
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSPropertyNamesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSPropertyNames.in (177865 => 177866)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSPropertyNames.in        2015-01-02 18:32:38 UTC (rev 177865)
+++ trunk/Source/WebCore/css/CSSPropertyNames.in        2015-01-02 19:53:38 UTC (rev 177866)
</span><span class="lines">@@ -89,7 +89,7 @@
</span><span class="cx"> display [Custom=Inherit|Value]
</span><span class="cx"> font [Inherited, LegacyStyleBuilder]
</span><span class="cx"> font-family [Inherited, Custom=All]
</span><del>-font-size [Inherited, LegacyStyleBuilder]
</del><ins>+font-size [Inherited, Custom=All]
</ins><span class="cx"> font-style [Inherited, FontProperty, TypeName=FontItalic, NameForMethods=Italic]
</span><span class="cx"> font-variant [Inherited, FontProperty, TypeName=FontSmallCaps, NameForMethods=SmallCaps]
</span><span class="cx"> font-weight [Inherited, Custom=All]
</span></span></pre></div>
<a id="trunkSourceWebCorecssDeprecatedStyleBuildercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp (177865 => 177866)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp        2015-01-02 18:32:38 UTC (rev 177865)
+++ trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp        2015-01-02 19:53:38 UTC (rev 177866)
</span><span class="lines">@@ -34,13 +34,10 @@
</span><span class="cx"> #include "CSSValueList.h"
</span><span class="cx"> #include "HTMLElement.h"
</span><span class="cx"> #include "RenderStyle.h"
</span><del>-#include "StyleFontSizeFunctions.h"
</del><span class="cx"> #include "StyleResolver.h"
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-using namespace HTMLNames;
-
</del><span class="cx"> template <typename T>
</span><span class="cx"> struct FillLayerAccessorTypes {
</span><span class="cx"> typedef T Setter;
</span><span class="lines">@@ -141,148 +138,6 @@
</span><span class="cx"> static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
</span><span class="cx"> };
</span><span class="cx">
</span><del>-class ApplyPropertyFontSize {
-private:
- // When the CSS keyword "larger" is used, this function will attempt to match within the keyword
- // table, and failing that, will simply multiply by 1.2.
- static float largerFontSize(float size)
- {
- // FIXME: Figure out where we fall in the size ranges (xx-small to xxx-large) and scale up to
- // the next size level.
- return size * 1.2f;
- }
-
- // Like the previous function, but for the keyword "smaller".
- static float smallerFontSize(float size)
- {
- // FIXME: Figure out where we fall in the size ranges (xx-small to xxx-large) and scale down to
- // the next size level.
- return size / 1.2f;
- }
-public:
- static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver)
- {
- float size = styleResolver->parentStyle()->fontDescription().specifiedSize();
-
- if (size < 0)
- return;
-
- FontDescription fontDescription = styleResolver->style()->fontDescription();
- fontDescription.setKeywordSize(styleResolver->parentStyle()->fontDescription().keywordSize());
- styleResolver->setFontSize(fontDescription, size);
- styleResolver->setFontDescription(fontDescription);
- return;
- }
-
- static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver)
- {
- FontDescription fontDescription = styleResolver->style()->fontDescription();
- float size = Style::fontSizeForKeyword(CSSValueMedium, fontDescription.useFixedDefaultSize(), styleResolver->document());
-
- if (size < 0)
- return;
-
- fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1);
- styleResolver->setFontSize(fontDescription, size);
- styleResolver->setFontDescription(fontDescription);
- return;
- }
-
- static float determineRubyTextSizeMultiplier(StyleResolver* styleResolver)
- {
- if (styleResolver->style()->rubyPosition() != RubyPositionInterCharacter)
- return 0.5f;
-
- Element* element = styleResolver->state().element();
- if (element == nullptr)
- return 0.25f;
-
- // FIXME: This hack is to ensure tone marks are the same size as
- // the bopomofo. This code will go away if we make a special renderer
- // for the tone marks eventually.
- for (const Element* currElement = element->parentElement(); currElement; currElement = currElement->parentElement()) {
- if (currElement->hasTagName(rtTag))
- return 1.0f;
- }
- return 0.25f;
- }
-
- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
- {
- if (!is<CSSPrimitiveValue>(*value))
- return;
-
- CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
-
- FontDescription fontDescription = styleResolver->style()->fontDescription();
- fontDescription.setKeywordSize(0);
- float parentSize = 0;
- bool parentIsAbsoluteSize = false;
- float size = 0;
-
- if (styleResolver->parentStyle()) {
- parentSize = styleResolver->parentStyle()->fontDescription().specifiedSize();
- parentIsAbsoluteSize = styleResolver->parentStyle()->fontDescription().isAbsoluteSize();
- }
-
- if (CSSValueID ident = primitiveValue.getValueID()) {
- // Keywords are being used.
- switch (ident) {
- case CSSValueXxSmall:
- case CSSValueXSmall:
- case CSSValueSmall:
- case CSSValueMedium:
- case CSSValueLarge:
- case CSSValueXLarge:
- case CSSValueXxLarge:
- case CSSValueWebkitXxxLarge:
- size = Style::fontSizeForKeyword(ident, fontDescription.useFixedDefaultSize(), styleResolver->document());
- fontDescription.setKeywordSize(ident - CSSValueXxSmall + 1);
- break;
- case CSSValueLarger:
- size = largerFontSize(parentSize);
- break;
- case CSSValueSmaller:
- size = smallerFontSize(parentSize);
- break;
- case CSSValueWebkitRubyText: {
- float rubyTextSizeMultiplier = determineRubyTextSizeMultiplier(styleResolver);
- size = rubyTextSizeMultiplier * parentSize;
- break;
- } default:
- return;
- }
-
- fontDescription.setIsAbsoluteSize(parentIsAbsoluteSize && (ident == CSSValueLarger || ident == CSSValueSmaller || ident == CSSValueWebkitRubyText));
- } else {
- fontDescription.setIsAbsoluteSize(parentIsAbsoluteSize || !(primitiveValue.isPercentage() || primitiveValue.isFontRelativeLength()));
- if (primitiveValue.isLength()) {
- size = primitiveValue.computeLength<float>(CSSToLengthConversionData(styleResolver->parentStyle(), styleResolver->rootElementStyle(), styleResolver->document().renderView(), 1.0f, true));
- styleResolver->state().setFontSizeHasViewportUnits(primitiveValue.isViewportPercentageLength());
- } else if (primitiveValue.isPercentage())
- size = (primitiveValue.getFloatValue() * parentSize) / 100.0f;
- else if (primitiveValue.isCalculatedPercentageWithLength()) {
- Ref<CalculationValue> calculationValue { primitiveValue.cssCalcValue()->createCalculationValue(styleResolver->state().cssToLengthConversionData().copyWithAdjustedZoom(1.0f)) };
- size = calculationValue->evaluate(parentSize);
- } else
- return;
- }
-
- if (size < 0)
- return;
-
- // Overly large font sizes will cause crashes on some platforms (such as Windows).
- // Cap font size here to make sure that doesn't happen.
- size = std::min(maximumAllowedFontSize, size);
-
- styleResolver->setFontSize(fontDescription, size);
- styleResolver->setFontDescription(fontDescription);
- return;
- }
-
- static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
-};
-
</del><span class="cx"> const DeprecatedStyleBuilder& DeprecatedStyleBuilder::sharedStyleBuilder()
</span><span class="cx"> {
</span><span class="cx"> static NeverDestroyed<DeprecatedStyleBuilder> styleBuilderInstance;
</span><span class="lines">@@ -305,8 +160,6 @@
</span><span class="cx"> setPropertyHandler(CSSPropertyBackgroundRepeatX, ApplyPropertyFillLayer<EFillRepeat, CSSPropertyBackgroundRepeatX, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isRepeatXSet, &FillLayer::repeatX, &FillLayer::setRepeatX, &FillLayer::clearRepeatX, &FillLayer::initialFillRepeatX, &CSSToStyleMap::mapFillRepeatX>::createHandler());
</span><span class="cx"> setPropertyHandler(CSSPropertyBackgroundRepeatY, ApplyPropertyFillLayer<EFillRepeat, CSSPropertyBackgroundRepeatY, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isRepeatYSet, &FillLayer::repeatY, &FillLayer::setRepeatY, &FillLayer::clearRepeatY, &FillLayer::initialFillRepeatY, &CSSToStyleMap::mapFillRepeatY>::createHandler());
</span><span class="cx"> setPropertyHandler(CSSPropertyBackgroundSize, ApplyPropertyFillLayer<FillSize, CSSPropertyBackgroundSize, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isSizeSet, &FillLayer::size, &FillLayer::setSize, &FillLayer::clearSize, &FillLayer::initialFillSize, &CSSToStyleMap::mapFillSize>::createHandler());
</span><del>- setPropertyHandler(CSSPropertyFontSize, ApplyPropertyFontSize::createHandler());
-
</del><span class="cx"> setPropertyHandler(CSSPropertyWebkitBackgroundClip, CSSPropertyBackgroundClip);
</span><span class="cx"> setPropertyHandler(CSSPropertyWebkitBackgroundComposite, ApplyPropertyFillLayer<CompositeOperator, CSSPropertyWebkitBackgroundComposite, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isCompositeSet, &FillLayer::composite, &FillLayer::setComposite, &FillLayer::clearComposite, &FillLayer::initialFillComposite, &CSSToStyleMap::mapFillComposite>::createHandler());
</span><span class="cx"> setPropertyHandler(CSSPropertyWebkitBackgroundOrigin, CSSPropertyBackgroundOrigin);
</span></span></pre></div>
<a id="trunkSourceWebCorecssStyleBuilderCustomh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/StyleBuilderCustom.h (177865 => 177866)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/StyleBuilderCustom.h        2015-01-02 18:32:38 UTC (rev 177865)
+++ trunk/Source/WebCore/css/StyleBuilderCustom.h        2015-01-02 19:53:38 UTC (rev 177866)
</span><span class="lines">@@ -31,7 +31,9 @@
</span><span class="cx"> #include "CSSCursorImageValue.h"
</span><span class="cx"> #include "CSSShadowValue.h"
</span><span class="cx"> #include "CursorList.h"
</span><ins>+#include "ElementAncestorIterator.h"
</ins><span class="cx"> #include "Frame.h"
</span><ins>+#include "HTMLElement.h"
</ins><span class="cx"> #include "LocaleToScriptMapping.h"
</span><span class="cx"> #include "Rect.h"
</span><span class="cx"> #include "SVGElement.h"
</span><span class="lines">@@ -61,6 +63,7 @@
</span><span class="cx"> DECLARE_PROPERTY_CUSTOM_HANDLERS(CounterReset);
</span><span class="cx"> DECLARE_PROPERTY_CUSTOM_HANDLERS(Cursor);
</span><span class="cx"> DECLARE_PROPERTY_CUSTOM_HANDLERS(FontFamily);
</span><ins>+ DECLARE_PROPERTY_CUSTOM_HANDLERS(FontSize);
</ins><span class="cx"> DECLARE_PROPERTY_CUSTOM_HANDLERS(FontWeight);
</span><span class="cx"> #if ENABLE(CSS_IMAGE_RESOLUTION)
</span><span class="cx"> DECLARE_PROPERTY_CUSTOM_HANDLERS(ImageResolution);
</span><span class="lines">@@ -118,6 +121,10 @@
</span><span class="cx"> static void applyInheritCounter(StyleResolver&);
</span><span class="cx"> template <CounterBehavior counterBehavior>
</span><span class="cx"> static void applyValueCounter(StyleResolver&, CSSValue&);
</span><ins>+
+ static float largerFontSize(float size);
+ static float smallerFontSize(float size);
+ static float determineRubyTextSizeMultiplier(StyleResolver&);
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> inline void StyleBuilderCustom::applyValueWebkitMarqueeIncrement(StyleResolver& styleResolver, CSSValue& value)
</span><span class="lines">@@ -842,8 +849,10 @@
</span><span class="cx"> FontDescription initialDesc = FontDescription();
</span><span class="cx">
</span><span class="cx"> // We need to adjust the size to account for the generic family change from monospace to non-monospace.
</span><del>- if (fontDescription.keywordSize() && fontDescription.useFixedDefaultSize())
- styleResolver.setFontSize(fontDescription, Style::fontSizeForKeyword(CSSValueXxSmall + fontDescription.keywordSize() - 1, false, styleResolver.document()));
</del><ins>+ if (fontDescription.useFixedDefaultSize()) {
+ if (CSSValueID sizeIdentifier = fontDescription.keywordSizeAsIdentifier())
+ styleResolver.setFontSize(fontDescription, Style::fontSizeForKeyword(sizeIdentifier, false, styleResolver.document()));
+ }
</ins><span class="cx"> if (!initialDesc.firstFamily().isEmpty())
</span><span class="cx"> fontDescription.setFamilies(initialDesc.families());
</span><span class="cx">
</span><span class="lines">@@ -923,8 +932,10 @@
</span><span class="cx"> return;
</span><span class="cx"> fontDescription.setFamilies(families);
</span><span class="cx">
</span><del>- if (fontDescription.keywordSize() && fontDescription.useFixedDefaultSize() != oldFamilyUsedFixedDefaultSize)
- styleResolver.setFontSize(fontDescription, Style::fontSizeForKeyword(CSSValueXxSmall + fontDescription.keywordSize() - 1, !oldFamilyUsedFixedDefaultSize, styleResolver.document()));
</del><ins>+ if (fontDescription.useFixedDefaultSize() != oldFamilyUsedFixedDefaultSize) {
+ if (CSSValueID sizeIdentifier = fontDescription.keywordSizeAsIdentifier())
+ styleResolver.setFontSize(fontDescription, Style::fontSizeForKeyword(sizeIdentifier, !oldFamilyUsedFixedDefaultSize, styleResolver.document()));
+ }
</ins><span class="cx">
</span><span class="cx"> styleResolver.setFontDescription(fontDescription);
</span><span class="cx"> }
</span><span class="lines">@@ -1268,6 +1279,129 @@
</span><span class="cx"> styleResolver.setFontDescription(fontDescription);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+inline void StyleBuilderCustom::applyInitialFontSize(StyleResolver& styleResolver)
+{
+ FontDescription fontDescription = styleResolver.style()->fontDescription();
+ float size = Style::fontSizeForKeyword(CSSValueMedium, fontDescription.useFixedDefaultSize(), styleResolver.document());
+
+ if (size < 0)
+ return;
+
+ fontDescription.setKeywordSizeFromIdentifier(CSSValueMedium);
+ styleResolver.setFontSize(fontDescription, size);
+ styleResolver.setFontDescription(fontDescription);
+}
+
+inline void StyleBuilderCustom::applyInheritFontSize(StyleResolver& styleResolver)
+{
+ const FontDescription& parentFontDescription = styleResolver.parentStyle()->fontDescription();
+ float size = parentFontDescription.specifiedSize();
+
+ if (size < 0)
+ return;
+
+ FontDescription fontDescription = styleResolver.style()->fontDescription();
+ fontDescription.setKeywordSize(parentFontDescription.keywordSize());
+ styleResolver.setFontSize(fontDescription, size);
+ styleResolver.setFontDescription(fontDescription);
+}
+
+// When the CSS keyword "larger" is used, this function will attempt to match within the keyword
+// table, and failing that, will simply multiply by 1.2.
+inline float StyleBuilderCustom::largerFontSize(float size)
+{
+ // FIXME: Figure out where we fall in the size ranges (xx-small to xxx-large) and scale up to
+ // the next size level.
+ return size * 1.2f;
+}
+
+// Like the previous function, but for the keyword "smaller".
+inline float StyleBuilderCustom::smallerFontSize(float size)
+{
+ // FIXME: Figure out where we fall in the size ranges (xx-small to xxx-large) and scale down to
+ // the next size level.
+ return size / 1.2f;
+}
+
+inline float StyleBuilderCustom::determineRubyTextSizeMultiplier(StyleResolver& styleResolver)
+{
+ if (styleResolver.style()->rubyPosition() != RubyPositionInterCharacter)
+ return 0.5f;
+
+ // FIXME: This hack is to ensure tone marks are the same size as
+ // the bopomofo. This code will go away if we make a special renderer
+ // for the tone marks eventually.
+ if (auto* element = styleResolver.state().element()) {
+ for (auto& ancestor : ancestorsOfType<HTMLElement>(*element)) {
+ if (ancestor.hasTagName(HTMLNames::rtTag))
+ return 1.0f;
+ }
+ }
+ return 0.25f;
+}
+
+inline void StyleBuilderCustom::applyValueFontSize(StyleResolver& styleResolver, CSSValue& value)
+{
+ FontDescription fontDescription = styleResolver.style()->fontDescription();
+ fontDescription.setKeywordSizeFromIdentifier(CSSValueInvalid);
+
+ float parentSize = 0;
+ bool parentIsAbsoluteSize = false;
+ if (auto* parentStyle = styleResolver.parentStyle()) {
+ parentSize = parentStyle->fontDescription().specifiedSize();
+ parentIsAbsoluteSize = parentStyle->fontDescription().isAbsoluteSize();
+ }
+
+ auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
+ float size;
+ if (CSSValueID ident = primitiveValue.getValueID()) {
+ fontDescription.setIsAbsoluteSize(parentIsAbsoluteSize && (ident == CSSValueLarger || ident == CSSValueSmaller || ident == CSSValueWebkitRubyText));
+
+ // Keywords are being used.
+ switch (ident) {
+ case CSSValueXxSmall:
+ case CSSValueXSmall:
+ case CSSValueSmall:
+ case CSSValueMedium:
+ case CSSValueLarge:
+ case CSSValueXLarge:
+ case CSSValueXxLarge:
+ case CSSValueWebkitXxxLarge:
+ size = Style::fontSizeForKeyword(ident, fontDescription.useFixedDefaultSize(), styleResolver.document());
+ fontDescription.setKeywordSizeFromIdentifier(ident);
+ break;
+ case CSSValueLarger:
+ size = largerFontSize(parentSize);
+ break;
+ case CSSValueSmaller:
+ size = smallerFontSize(parentSize);
+ break;
+ case CSSValueWebkitRubyText:
+ size = determineRubyTextSizeMultiplier(styleResolver) * parentSize;
+ break;
+ default:
+ return;
+ }
+ } else {
+ fontDescription.setIsAbsoluteSize(parentIsAbsoluteSize || !(primitiveValue.isPercentage() || primitiveValue.isFontRelativeLength()));
+ if (primitiveValue.isLength()) {
+ size = primitiveValue.computeLength<float>(CSSToLengthConversionData(styleResolver.parentStyle(), styleResolver.rootElementStyle(), styleResolver.document().renderView(), 1.0f, true));
+ styleResolver.state().setFontSizeHasViewportUnits(primitiveValue.isViewportPercentageLength());
+ } else if (primitiveValue.isPercentage())
+ size = (primitiveValue.getFloatValue() * parentSize) / 100.0f;
+ else if (primitiveValue.isCalculatedPercentageWithLength())
+ size = primitiveValue.cssCalcValue()->createCalculationValue(styleResolver.state().cssToLengthConversionData().copyWithAdjustedZoom(1.0f))->evaluate(parentSize);
+ else
+ return;
+ }
+
+ if (size < 0)
+ return;
+
+ styleResolver.setFontSize(fontDescription, std::min(maximumAllowedFontSize, size));
+ styleResolver.setFontDescription(fontDescription);
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx">
</span><span class="cx"> #endif // StyleBuilderCustom_h
</span></span></pre></div>
<a id="trunkSourceWebCorecssStyleResolvercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/StyleResolver.cpp (177865 => 177866)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/StyleResolver.cpp        2015-01-02 18:32:38 UTC (rev 177865)
+++ trunk/Source/WebCore/css/StyleResolver.cpp        2015-01-02 19:53:38 UTC (rev 177866)
</span><span class="lines">@@ -3215,8 +3215,8 @@
</span><span class="cx"> // If the font uses a keyword size, then we refetch from the table rather than
</span><span class="cx"> // multiplying by our scale factor.
</span><span class="cx"> float size;
</span><del>- if (childFont.keywordSize())
- size = Style::fontSizeForKeyword(CSSValueXxSmall + childFont.keywordSize() - 1, childFont.useFixedDefaultSize(), document());
</del><ins>+ if (CSSValueID sizeIdentifier = childFont.keywordSizeAsIdentifier())
+ size = Style::fontSizeForKeyword(sizeIdentifier, childFont.useFixedDefaultSize(), document());
</ins><span class="cx"> else {
</span><span class="cx"> Settings* settings = documentSettings();
</span><span class="cx"> float fixedScaleFactor = (settings && settings->defaultFixedFontSize() && settings->defaultFontSize())
</span><span class="lines">@@ -3238,7 +3238,7 @@
</span><span class="cx"> fontDescription.setRenderingMode(settings->fontRenderingMode());
</span><span class="cx"> fontDescription.setUsePrinterFont(document().printing() || !settings->screenFontSubstitutionEnabled());
</span><span class="cx"> fontDescription.setOneFamily(standardFamily);
</span><del>- fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1);
</del><ins>+ fontDescription.setKeywordSizeFromIdentifier(CSSValueMedium);
</ins><span class="cx"> setFontSize(fontDescription, Style::fontSizeForKeyword(CSSValueMedium, false, document()));
</span><span class="cx"> m_state.style()->setLineHeight(RenderStyle::initialLineHeight());
</span><span class="cx"> m_state.setLineHeightValue(0);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontDescriptionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/FontDescription.h (177865 => 177866)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FontDescription.h        2015-01-02 18:32:38 UTC (rev 177865)
+++ trunk/Source/WebCore/platform/graphics/FontDescription.h        2015-01-02 19:53:38 UTC (rev 177866)
</span><span class="lines">@@ -25,6 +25,7 @@
</span><span class="cx"> #ifndef FontDescription_h
</span><span class="cx"> #define FontDescription_h
</span><span class="cx">
</span><ins>+#include "CSSValueKeywords.h"
</ins><span class="cx"> #include "FontFeatureSettings.h"
</span><span class="cx"> #include "FontOrientation.h"
</span><span class="cx"> #include "FontRenderingMode.h"
</span><span class="lines">@@ -124,6 +125,12 @@
</span><span class="cx"> LigaturesState discretionaryLigaturesState() const { return static_cast<LigaturesState>(m_discretionaryLigaturesState); }
</span><span class="cx"> LigaturesState historicalLigaturesState() const { return static_cast<LigaturesState>(m_historicalLigaturesState); }
</span><span class="cx"> unsigned keywordSize() const { return m_keywordSize; }
</span><ins>+ CSSValueID keywordSizeAsIdentifier() const
+ {
+ CSSValueID identifier = m_keywordSize ? static_cast<CSSValueID>(CSSValueXxSmall + m_keywordSize - 1) : CSSValueInvalid;
+ ASSERT(identifier == CSSValueInvalid || (identifier >= CSSValueXxSmall && identifier <= CSSValueWebkitXxxLarge));
+ return identifier;
+ }
</ins><span class="cx"> FontSmoothingMode fontSmoothing() const { return static_cast<FontSmoothingMode>(m_fontSmoothing); }
</span><span class="cx"> TextRenderingMode textRenderingMode() const { return static_cast<TextRenderingMode>(m_textRendering); }
</span><span class="cx"> UScriptCode script() const { return static_cast<UScriptCode>(m_script); }
</span><span class="lines">@@ -153,7 +160,19 @@
</span><span class="cx"> void setCommonLigaturesState(LigaturesState commonLigaturesState) { m_commonLigaturesState = commonLigaturesState; }
</span><span class="cx"> void setDiscretionaryLigaturesState(LigaturesState discretionaryLigaturesState) { m_discretionaryLigaturesState = discretionaryLigaturesState; }
</span><span class="cx"> void setHistoricalLigaturesState(LigaturesState historicalLigaturesState) { m_historicalLigaturesState = historicalLigaturesState; }
</span><del>- void setKeywordSize(unsigned s) { m_keywordSize = s; }
</del><ins>+ void setKeywordSize(unsigned size)
+ {
+ ASSERT(size <= 8);
+ m_keywordSize = size;
+ ASSERT(m_keywordSize == size); // Make sure it fits in the bitfield.
+ }
+ void setKeywordSizeFromIdentifier(CSSValueID identifier)
+ {
+ ASSERT(!identifier || (identifier >= CSSValueXxSmall && identifier <= CSSValueWebkitXxxLarge));
+ static_assert(CSSValueWebkitXxxLarge - CSSValueXxSmall + 1 == 8, "Maximum keyword size should be 8.");
+ setKeywordSize(identifier ? identifier - CSSValueXxSmall + 1 : 0);
+ }
+
</ins><span class="cx"> void setFontSmoothing(FontSmoothingMode smoothing) { m_fontSmoothing = smoothing; }
</span><span class="cx"> void setTextRenderingMode(TextRenderingMode rendering) { m_textRendering = rendering; }
</span><span class="cx"> void setIsSpecifiedFont(bool isSpecifiedFont) { m_isSpecifiedFont = isSpecifiedFont; }
</span></span></pre></div>
<a id="trunkSourceWebCorestyleStyleResolveForDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/StyleResolveForDocument.cpp (177865 => 177866)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/StyleResolveForDocument.cpp        2015-01-02 18:32:38 UTC (rev 177865)
+++ trunk/Source/WebCore/style/StyleResolveForDocument.cpp        2015-01-02 19:53:38 UTC (rev 177866)
</span><span class="lines">@@ -101,7 +101,7 @@
</span><span class="cx"> fontDescription.setRenderingMode(settings.fontRenderingMode());
</span><span class="cx"> fontDescription.setOneFamily(standardFamily);
</span><span class="cx">
</span><del>- fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1);
</del><ins>+ fontDescription.setKeywordSizeFromIdentifier(CSSValueMedium);
</ins><span class="cx"> int size = fontSizeForKeyword(CSSValueMedium, false, document);
</span><span class="cx"> fontDescription.setSpecifiedSize(size);
</span><span class="cx"> bool useSVGZoomRules = document.isSVGDocument();
</span></span></pre>
</div>
</div>
</body>
</html>