Diff
Modified: trunk/LayoutTests/ChangeLog (100272 => 100273)
--- trunk/LayoutTests/ChangeLog 2011-11-15 14:06:38 UTC (rev 100272)
+++ trunk/LayoutTests/ChangeLog 2011-11-15 14:12:43 UTC (rev 100273)
@@ -1,3 +1,15 @@
+2011-11-15 Alexander Pavlov <[email protected]>
+
+ font property does not show up as "shorthand" in inspector
+ https://bugs.webkit.org/show_bug.cgi?id=15598
+
+ Reviewed by Nikolas Zimmermann.
+
+ * fast/css/font-shorthand-expected.txt: Added.
+ * fast/css/font-shorthand.html: Added.
+ * fast/inspector-support/style-expected.txt:
+ * fast/inspector-support/style.html:
+
2011-11-15 Philippe Normand <[email protected]>
REGRESSION (r100158-r100162): 5 fast tests failing on GTK Linux 64-bit Debug
Added: trunk/LayoutTests/fast/css/font-shorthand-expected.txt (0 => 100273)
--- trunk/LayoutTests/fast/css/font-shorthand-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/css/font-shorthand-expected.txt 2011-11-15 14:12:43 UTC (rev 100273)
@@ -0,0 +1,80 @@
+Test
+Font for '12px monospace':
+font-family: monospace (original property was font)
+font-size: 12px (original property was font)
+font-style: normal (original property was font and property was implicitly set.)
+font-variant: normal (original property was font and property was implicitly set.)
+font-weight: normal (original property was font and property was implicitly set.)
+line-height: normal (original property was font and property was implicitly set.)
+
+Font for '12px/24px serif':
+font-family: serif (original property was font)
+font-size: 12px (original property was font)
+font-style: normal (original property was font and property was implicitly set.)
+font-variant: normal (original property was font and property was implicitly set.)
+font-weight: normal (original property was font and property was implicitly set.)
+line-height: 24px (original property was font)
+
+Font for 'normal 12px serif':
+font-family: serif (original property was font)
+font-size: 12px (original property was font)
+font-style: normal (original property was font)
+font-variant: normal (original property was font and property was implicitly set.)
+font-weight: normal (original property was font and property was implicitly set.)
+line-height: normal (original property was font and property was implicitly set.)
+
+Font for 'normal normal 12px serif':
+font-family: serif (original property was font)
+font-size: 12px (original property was font)
+font-style: normal (original property was font)
+font-variant: normal (original property was font)
+font-weight: normal (original property was font and property was implicitly set.)
+line-height: normal (original property was font and property was implicitly set.)
+
+Font for 'normal normal normal 12px serif':
+font-family: serif (original property was font)
+font-size: 12px (original property was font)
+font-style: normal (original property was font)
+font-variant: normal (original property was font)
+font-weight: normal (original property was font)
+line-height: normal (original property was font and property was implicitly set.)
+
+Font for 'italic small-caps 12px/24px serif':
+font-family: serif (original property was font)
+font-size: 12px (original property was font)
+font-style: italic (original property was font)
+font-variant: small-caps (original property was font)
+font-weight: normal (original property was font and property was implicitly set.)
+line-height: 24px (original property was font)
+
+Font for 'italic bold 12px/24px serif':
+font-family: serif (original property was font)
+font-size: 12px (original property was font)
+font-style: italic (original property was font)
+font-variant: normal (original property was font and property was implicitly set.)
+font-weight: bold (original property was font)
+line-height: 24px (original property was font)
+
+Font for 'small-caps bold 14px/28px Arial, sans-serif':
+font-family: Arial, sans-serif (original property was font)
+font-size: 14px (original property was font)
+font-style: normal (original property was font and property was implicitly set.)
+font-variant: small-caps (original property was font)
+font-weight: bold (original property was font)
+line-height: 28px (original property was font)
+
+Font for 'italic small-caps bold 14px/28px Arial, sans-serif':
+font-family: Arial, sans-serif (original property was font)
+font-size: 14px (original property was font)
+font-style: italic (original property was font)
+font-variant: small-caps (original property was font)
+font-weight: bold (original property was font)
+line-height: 28px (original property was font)
+
+Font for 'italic small-caps bold 12px/24px':
+
+Font for 'italic small-caps bold 12px':
+
+Font for 'italic small-caps bold /12px serif':
+
+
Property changes on: trunk/LayoutTests/fast/css/font-shorthand-expected.txt
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/fast/css/font-shorthand.html (0 => 100273)
--- trunk/LayoutTests/fast/css/font-shorthand.html (rev 0)
+++ trunk/LayoutTests/fast/css/font-shorthand.html 2011-11-15 14:12:43 UTC (rev 100273)
@@ -0,0 +1,46 @@
+<html>
+<head>
+<script>
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+</script>
+</head>
+<body>
+<div id="foo">Test</div>
+<script>
+function testFontValue(value)
+{
+ document.write("Font for '" + value + "':<br>");
+ var element = document.getElementById("foo");
+ var decl = element.style;
+ decl.font = "";
+ decl.font = value;
+ for (var i = 0; i < decl.length; i++) {
+ var shorthand = decl.getPropertyShorthand(decl[i]);
+ document.write(decl[i] + ": " + decl.getPropertyValue(decl[i]));
+ if (shorthand) {
+ document.write(" (original property was " + shorthand
+ + (decl.isPropertyImplicit(decl[i]) ? " and property was implicitly set.)" : ")"));
+ }
+ document.write("<br>");
+ }
+ document.write("<br>");
+}
+
+testFontValue("12px monospace");
+testFontValue("12px/24px serif");
+testFontValue("normal 12px serif");
+testFontValue("normal normal 12px serif");
+testFontValue("normal normal normal 12px serif");
+testFontValue("italic small-caps 12px/24px serif");
+testFontValue("italic bold 12px/24px serif");
+testFontValue("small-caps bold 14px/28px Arial, sans-serif");
+testFontValue("italic small-caps bold 14px/28px Arial, sans-serif");
+
+// Invalid values should yield no longhands.
+testFontValue("italic small-caps bold 12px/24px");
+testFontValue("italic small-caps bold 12px");
+testFontValue("italic small-caps bold /12px serif");
+</script>
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/css/font-shorthand.html
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/LayoutTests/fast/inspector-support/style-expected.txt (100272 => 100273)
--- trunk/LayoutTests/fast/inspector-support/style-expected.txt 2011-11-15 14:06:38 UTC (rev 100272)
+++ trunk/LayoutTests/fast/inspector-support/style-expected.txt 2011-11-15 14:12:43 UTC (rev 100273)
@@ -1,4 +1,4 @@
-Note that background and font are both buggy right now!
+Note that background is buggy right now!
Test
background-image: initial (original property was background)
background-repeat-x: initial (original property was background)
@@ -14,5 +14,10 @@
margin-bottom: 1em (original property was margin and property was implicitly set.)
margin-left: 1em (original property was margin and property was implicitly set.)
color: white
-font: normal normal normal 24px/normal 'Lucida Grande'
+font-family: 'Lucida Grande' (original property was font)
+font-size: 24px (original property was font)
+font-style: normal (original property was font and property was implicitly set.)
+font-variant: normal (original property was font and property was implicitly set.)
+font-weight: normal (original property was font and property was implicitly set.)
+line-height: normal (original property was font and property was implicitly set.)
Modified: trunk/LayoutTests/fast/inspector-support/style.html (100272 => 100273)
--- trunk/LayoutTests/fast/inspector-support/style.html 2011-11-15 14:06:38 UTC (rev 100272)
+++ trunk/LayoutTests/fast/inspector-support/style.html 2011-11-15 14:12:43 UTC (rev 100273)
@@ -9,7 +9,7 @@
</style>
</head>
<body>
-Note that background and font are both buggy right now!
+Note that background is buggy right now!
<div id="foo">Test</div>
<script>
var ruleList = document.defaultView.getMatchedCSSRules(document.getElementById('foo'), '');
Modified: trunk/Source/WebCore/ChangeLog (100272 => 100273)
--- trunk/Source/WebCore/ChangeLog 2011-11-15 14:06:38 UTC (rev 100272)
+++ trunk/Source/WebCore/ChangeLog 2011-11-15 14:12:43 UTC (rev 100273)
@@ -1,3 +1,39 @@
+2011-11-15 Alexander Pavlov <[email protected]>
+
+ font property does not show up as "shorthand" in inspector
+ https://bugs.webkit.org/show_bug.cgi?id=15598
+
+ Reviewed by Nikolas Zimmermann.
+
+ The "font" CSS property is turned into a real shorthand, as its longhands used to float around
+ in the resulting style declaration without any reference to their underlying "font" property.
+
+ Test: fast/css/font-shorthand.html
+
+ * css/CSSMutableStyleDeclaration.cpp:
+ (WebCore::CSSMutableStyleDeclaration::getPropertyValue): Extracted the "font" value building into fontValue().
+ (WebCore::CSSMutableStyleDeclaration::appendFontLonghandValueIfExplicit): Added
+ (WebCore::CSSMutableStyleDeclaration::fontValue): Build the "font" value from longhands.
+ * css/CSSMutableStyleDeclaration.h:
+ * css/CSSParser.cpp:
+ (WebCore::CSSParser::addProperty): Added optional "implicit" parameter.
+ (WebCore::CSSParser::parseFont): Build respective longhands instead of the shorthand "font" property.
+ * css/CSSParser.h: Added optional "implicit" parameter to addProperty().
+ * css/CSSPropertyLonghand.cpp:
+ (WebCore::initShorthandMap): Added "font" shorthand map entry.
+ * css/CSSStyleSelector.cpp:
+ (WebCore::CSSStyleSelector::applyPropertyToStyle): Separated the property application from the instance setup.
+ (WebCore::CSSStyleSelector::applyPropertyToCurrentStyle): Added.
+ * css/CSSStyleSelector.h: Made updateFont() public.
+ * css/FontValue.cpp:
+ (WebCore::FontValue::customCssText): Made use of StringBuilder.
+ * html/canvas/CanvasRenderingContext2D.cpp:
+ (WebCore::CanvasRenderingContext2D::setFont): Apply "font" longhands rather than the (non-existent) "font" property.
+ * inspector/front-end/StylesSidebarPane.js:
+ (WebInspector.StylesSidebarPane.prototype._markUsedProperties): Removed a workaround for "font" not being a shorthand.
+ * page/animation/AnimationBase.cpp:
+ (WebCore::addShorthandProperties): Removed a workaround for "font" not being a shorthand.
+
2011-11-15 Pierre Rossi <[email protected]>
[Qt] Clean up the remaining duplicate code after the RenderThemeQt refactoring.
Modified: trunk/Source/WebCore/css/CSSMutableStyleDeclaration.cpp (100272 => 100273)
--- trunk/Source/WebCore/css/CSSMutableStyleDeclaration.cpp 2011-11-15 14:06:38 UTC (rev 100272)
+++ trunk/Source/WebCore/css/CSSMutableStyleDeclaration.cpp 2011-11-15 14:12:43 UTC (rev 100273)
@@ -34,6 +34,7 @@
#include "ExceptionCode.h"
#include "InspectorInstrumentation.h"
#include "StyledElement.h"
+#include <wtf/text/StringBuilder.h>
#include <wtf/text/WTFString.h>
using namespace std;
@@ -193,6 +194,8 @@
CSSPropertyBorderBottomStyle, CSSPropertyBorderLeftStyle };
return get4Values(properties);
}
+ case CSSPropertyFont:
+ return fontValue();
case CSSPropertyMargin: {
const int properties[4] = { CSSPropertyMarginTop, CSSPropertyMarginRight,
CSSPropertyMarginBottom, CSSPropertyMarginLeft };
@@ -272,6 +275,62 @@
return horizontalValueCSSText + ' ' + verticalValueCSSText;
}
+bool CSSMutableStyleDeclaration::appendFontLonghandValueIfExplicit(int propertyId, StringBuilder& result) const
+{
+ const CSSProperty* property = findPropertyWithId(propertyId);
+ if (!property)
+ return false; // All longhands must have at least implicit values if "font" is specified.
+ if (property->isImplicit())
+ return true;
+
+ char prefix = '\0';
+ switch (propertyId) {
+ case CSSPropertyFontStyle:
+ break; // No prefix.
+ case CSSPropertyFontFamily:
+ case CSSPropertyFontVariant:
+ case CSSPropertyFontWeight:
+ prefix = ' ';
+ break;
+ case CSSPropertyLineHeight:
+ prefix = '/';
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+
+ if (prefix && !result.isEmpty())
+ result.append(prefix);
+ result.append(property->value()->cssText());
+
+ return true;
+}
+
+String CSSMutableStyleDeclaration::fontValue() const
+{
+ const CSSProperty* fontSizeProperty = findPropertyWithId(CSSPropertyFontSize);
+ if (!fontSizeProperty || fontSizeProperty->isImplicit())
+ return emptyString();
+
+ StringBuilder result;
+ bool success = true;
+ success &= appendFontLonghandValueIfExplicit(CSSPropertyFontStyle, result);
+ success &= appendFontLonghandValueIfExplicit(CSSPropertyFontVariant, result);
+ success &= appendFontLonghandValueIfExplicit(CSSPropertyFontWeight, result);
+ if (!result.isEmpty())
+ result.append(' ');
+ result.append(fontSizeProperty->value()->cssText());
+ success &= appendFontLonghandValueIfExplicit(CSSPropertyLineHeight, result);
+ success &= appendFontLonghandValueIfExplicit(CSSPropertyFontFamily, result);
+ if (!success) {
+ // An invalid "font" value has been built (should never happen, as at least implicit values
+ // for mandatory longhands are always found in the style), report empty value instead.
+ ASSERT_NOT_REACHED();
+ return emptyString();
+ }
+ return result.toString();
+}
+
String CSSMutableStyleDeclaration::get4Values(const int* properties) const
{
// Assume the properties are in the usual order top, right, bottom, left.
Modified: trunk/Source/WebCore/css/CSSMutableStyleDeclaration.h (100272 => 100273)
--- trunk/Source/WebCore/css/CSSMutableStyleDeclaration.h 2011-11-15 14:06:38 UTC (rev 100272)
+++ trunk/Source/WebCore/css/CSSMutableStyleDeclaration.h 2011-11-15 14:12:43 UTC (rev 100273)
@@ -158,6 +158,8 @@
String getLayeredShorthandValue(const int* properties, size_t) const;
String get4Values(const int* properties) const;
String borderSpacingValue(const int properties[2]) const;
+ String fontValue() const;
+ bool appendFontLonghandValueIfExplicit(int propertyID, StringBuilder& result) const;
template<size_t size> String getShorthandValue(const int (&properties)[size]) const { return getShorthandValue(properties, size); }
template<size_t size> String getCommonValue(const int (&properties)[size]) const { return getCommonValue(properties, size); }
Modified: trunk/Source/WebCore/css/CSSParser.cpp (100272 => 100273)
--- trunk/Source/WebCore/css/CSSParser.cpp 2011-11-15 14:06:38 UTC (rev 100272)
+++ trunk/Source/WebCore/css/CSSParser.cpp 2011-11-15 14:12:43 UTC (rev 100273)
@@ -623,9 +623,9 @@
return ok;
}
-void CSSParser::addProperty(int propId, PassRefPtr<CSSValue> value, bool important)
+void CSSParser::addProperty(int propId, PassRefPtr<CSSValue> value, bool important, bool implicit)
{
- OwnPtr<CSSProperty> prop(adoptPtr(new CSSProperty(propId, value, important, m_currentShorthand, m_implicitShorthand)));
+ OwnPtr<CSSProperty> prop(adoptPtr(new CSSProperty(propId, value, important, m_currentShorthand, m_implicitShorthand || implicit)));
if (m_numParsedProperties >= m_maxParsedProperties) {
if (m_numParsedProperties > (UINT_MAX / sizeof(CSSProperty*)) - 32)
CRASH(); // Avoid inconsistencies with rollbackLastProperties.
@@ -3962,29 +3962,48 @@
bool CSSParser::parseFont(bool important)
{
bool valid = true;
+ bool styleImplicit = true;
+ bool variantImplicit = true;
+ bool weightImplicit = true;
+ bool lineHeightImplicit = true;
+ int valueOrdinal = 0;
+
CSSParserValue *value = m_valueList->current();
RefPtr<FontValue> font = FontValue::create();
- // optional font-style, font-variant and font-weight
+ // Optional font-style, font-variant and font-weight.
while (value) {
int id = value->id;
if (id) {
if (id == CSSValueNormal) {
- // do nothing, it's the inital value for all three
+ // It's the initial value for all three, so mark the corresponding longhand as explicit.
+ switch (valueOrdinal) {
+ case 0:
+ styleImplicit = false;
+ break;
+ case 1:
+ variantImplicit = false;
+ break;
+ case 2:
+ weightImplicit = false;
+ break;
+ }
} else if (id == CSSValueItalic || id == CSSValueOblique) {
if (font->style)
return false;
font->style = primitiveValueCache()->createIdentifierValue(id);
+ styleImplicit = false;
} else if (id == CSSValueSmallCaps) {
if (font->variant)
return false;
font->variant = primitiveValueCache()->createIdentifierValue(id);
+ variantImplicit = false;
} else if (id >= CSSValueBold && id <= CSSValueLighter) {
if (font->weight)
return false;
font->weight = primitiveValueCache()->createIdentifierValue(id);
- } else {
+ weightImplicit = false;
+ } else
valid = false;
- }
} else if (!font->weight && validUnit(value, FInteger | FNonNeg, true)) {
int weight = static_cast<int>(value->fValue);
int val = 0;
@@ -4007,9 +4026,10 @@
else if (weight == 900)
val = CSSValue900;
- if (val)
+ if (val) {
font->weight = primitiveValueCache()->createIdentifierValue(val);
- else
+ weightImplicit = false;
+ } else
valid = false;
} else {
valid = false;
@@ -4017,11 +4037,12 @@
if (!valid)
break;
value = m_valueList->next();
+ ++valueOrdinal;
}
if (!value)
return false;
- // set undefined values to default
+ // Set undefined values to default.
if (!font->style)
font->style = primitiveValueCache()->createIdentifierValue(CSSValueNormal);
if (!font->variant)
@@ -4029,7 +4050,7 @@
if (!font->weight)
font->weight = primitiveValueCache()->createIdentifierValue(CSSValueNormal);
- // now a font size _must_ come
+ // Now a font size _must_ come.
// <absolute-size> | <relative-size> | <length> | <percentage> | inherit
if (value->id >= CSSValueXxSmall && value->id <= CSSValueLarger)
font->size = primitiveValueCache()->createIdentifierValue(value->id);
@@ -4040,15 +4061,17 @@
return false;
if (value->unit == CSSParserValue::Operator && value->iValue == '/') {
- // line-height
+ // The line-height property.
value = m_valueList->next();
if (!value)
return false;
if (value->id == CSSValueNormal) {
- // default value, nothing to do
- } else if (validUnit(value, FNumber | FLength | FPercent | FNonNeg, m_strict))
+ // Default value, just mark the property as explicit.
+ lineHeightImplicit = false;
+ } else if (validUnit(value, FNumber | FLength | FPercent | FNonNeg, m_strict)) {
font->lineHeight = createPrimitiveNumericValue(value);
- else
+ lineHeightImplicit = false;
+ } else
return false;
value = m_valueList->next();
if (!value)
@@ -4058,13 +4081,24 @@
if (!font->lineHeight)
font->lineHeight = primitiveValueCache()->createIdentifierValue(CSSValueNormal);
- // font family must come now
+ // Font family must come now.
font->family = parseFontFamily();
if (m_valueList->current() || !font->family)
return false;
- addProperty(CSSPropertyFont, font.release(), important);
+ ShorthandScope scope(this, CSSPropertyFont);
+ addProperty(CSSPropertyFontFamily, font->family, important);
+ addProperty(CSSPropertyFontSize, font->size, important);
+ addProperty(CSSPropertyFontStyle, font->style, important, styleImplicit);
+ addProperty(CSSPropertyFontVariant, font->variant, important, variantImplicit);
+ addProperty(CSSPropertyFontWeight, font->weight, important, weightImplicit);
+ addProperty(CSSPropertyLineHeight, font->lineHeight, important, lineHeightImplicit);
+
+ // FIXME: http://www.w3.org/TR/2011/WD-css3-fonts-20110324/#font-prop requires that
+ // "font-stretch", "font-size-adjust", and "font-kerning" be reset to their initial values
+ // but we don't seem to support them at the moment. They should also be added here once implemented.
+
return true;
}
Modified: trunk/Source/WebCore/css/CSSParser.h (100272 => 100273)
--- trunk/Source/WebCore/css/CSSParser.h 2011-11-15 14:06:38 UTC (rev 100272)
+++ trunk/Source/WebCore/css/CSSParser.h 2011-11-15 14:12:43 UTC (rev 100273)
@@ -77,7 +77,7 @@
CSSPrimitiveValueCache* primitiveValueCache() const { return m_primitiveValueCache.get(); }
- void addProperty(int propId, PassRefPtr<CSSValue>, bool important);
+ void addProperty(int propId, PassRefPtr<CSSValue>, bool important, bool implicit = false);
void rollbackLastProperties(int num);
bool hasProperties() const { return m_numParsedProperties > 0; }
Modified: trunk/Source/WebCore/css/CSSPropertyLonghand.cpp (100272 => 100273)
--- trunk/Source/WebCore/css/CSSPropertyLonghand.cpp 2011-11-15 14:06:38 UTC (rev 100272)
+++ trunk/Source/WebCore/css/CSSPropertyLonghand.cpp 2011-11-15 14:12:43 UTC (rev 100273)
@@ -34,7 +34,15 @@
#define SET_SHORTHAND_MAP_ENTRY(map, propID, array) \
map.set(propID, CSSPropertyLonghand(array, WTF_ARRAY_LENGTH(array)))
- // FIXME: The 'font' property has "shorthand nature" but is not parsed as a shorthand.
+ static const int fontProperties[] = {
+ CSSPropertyFontFamily,
+ CSSPropertyFontSize,
+ CSSPropertyFontStyle,
+ CSSPropertyFontVariant,
+ CSSPropertyFontWeight,
+ CSSPropertyLineHeight
+ };
+ SET_SHORTHAND_MAP_ENTRY(shorthandMap, CSSPropertyFont, fontProperties);
// Do not change the order of the following four shorthands, and keep them together.
static const int borderProperties[4][3] = {
Modified: trunk/Source/WebCore/css/CSSStyleSelector.cpp (100272 => 100273)
--- trunk/Source/WebCore/css/CSSStyleSelector.cpp 2011-11-15 14:06:38 UTC (rev 100272)
+++ trunk/Source/WebCore/css/CSSStyleSelector.cpp 2011-11-15 14:12:43 UTC (rev 100273)
@@ -2385,11 +2385,16 @@
return "";
}
-void CSSStyleSelector::applyPropertyToStyle(int id, CSSValue *value, RenderStyle* style)
+void CSSStyleSelector::applyPropertyToStyle(int id, CSSValue* value, RenderStyle* style)
{
initElement(0);
initForStyleResolve(0, style);
m_style = style;
+ applyPropertyToCurrentStyle(id, value);
+}
+
+void CSSStyleSelector::applyPropertyToCurrentStyle(int id, CSSValue* value)
+{
if (value)
applyProperty(id, value);
}
Modified: trunk/Source/WebCore/css/CSSStyleSelector.h (100272 => 100273)
--- trunk/Source/WebCore/css/CSSStyleSelector.h 2011-11-15 14:06:38 UTC (rev 100272)
+++ trunk/Source/WebCore/css/CSSStyleSelector.h 2011-11-15 14:12:43 UTC (rev 100273)
@@ -164,6 +164,10 @@
void applyPropertyToStyle(int id, CSSValue*, RenderStyle*);
+ void applyPropertyToCurrentStyle(int id, CSSValue*);
+
+ void updateFont();
+
static float getComputedSizeFromSpecifiedSize(Document*, float zoomFactor, bool isAbsoluteSize, float specifiedSize, ESmartMinimumForFontSize = UseSmartMinimumForFontFize);
private:
@@ -287,7 +291,6 @@
private:
static RenderStyle* s_styleNotYetAvailable;
- void updateFont();
void cacheBorderAndBackground();
void mapFillAttachment(CSSPropertyID, FillLayer*, CSSValue*);
Modified: trunk/Source/WebCore/css/FontValue.cpp (100272 => 100273)
--- trunk/Source/WebCore/css/FontValue.cpp 2011-11-15 14:06:38 UTC (rev 100272)
+++ trunk/Source/WebCore/css/FontValue.cpp 2011-11-15 14:12:43 UTC (rev 100273)
@@ -23,6 +23,7 @@
#include "CSSValueList.h"
#include "CSSPrimitiveValue.h"
#include "PlatformString.h"
+#include <wtf/text/StringBuilder.h>
namespace WebCore {
@@ -30,38 +31,38 @@
{
// font variant weight size / line-height family
- String result("");
+ StringBuilder result;
if (style)
- result += style->cssText();
+ result.append(style->cssText());
if (variant) {
if (!result.isEmpty())
- result += " ";
- result += variant->cssText();
+ result.append(' ');
+ result.append(variant->cssText());
}
if (weight) {
if (!result.isEmpty())
- result += " ";
- result += weight->cssText();
+ result.append(' ');
+ result.append(weight->cssText());
}
if (size) {
if (!result.isEmpty())
- result += " ";
- result += size->cssText();
+ result.append(' ');
+ result.append(size->cssText());
}
if (lineHeight) {
if (!size)
- result += " ";
- result += "/";
- result += lineHeight->cssText();
+ result.append(' ');
+ result.append('/');
+ result.append(lineHeight->cssText());
}
if (family) {
if (!result.isEmpty())
- result += " ";
- result += family->cssText();
+ result.append(' ');
+ result.append(family->cssText());
}
- return result;
+ return result.toString();
}
}
Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (100272 => 100273)
--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp 2011-11-15 14:06:38 UTC (rev 100272)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp 2011-11-15 14:12:43 UTC (rev 100273)
@@ -1987,10 +1987,20 @@
newStyle->setFontDescription(computedStyle->fontDescription());
newStyle->font().update(newStyle->font().fontSelector());
- // Now map the font property into the style.
+ // Now map the font property longhands into the style.
CSSStyleSelector* styleSelector = canvas()->styleSelector();
- styleSelector->applyPropertyToStyle(CSSPropertyFont, tempDecl->getPropertyCSSValue(CSSPropertyFont).get(), newStyle.get());
+ styleSelector->applyPropertyToStyle(CSSPropertyFontFamily, tempDecl->getPropertyCSSValue(CSSPropertyFontFamily).get(), newStyle.get());
+ styleSelector->applyPropertyToCurrentStyle(CSSPropertyFontStyle, tempDecl->getPropertyCSSValue(CSSPropertyFontStyle).get());
+ styleSelector->applyPropertyToCurrentStyle(CSSPropertyFontVariant, tempDecl->getPropertyCSSValue(CSSPropertyFontVariant).get());
+ styleSelector->applyPropertyToCurrentStyle(CSSPropertyFontWeight, tempDecl->getPropertyCSSValue(CSSPropertyFontWeight).get());
+ // As described in BUG66291, setting font-size on a font may entail a CSSPrimitiveValue::computeLengthDouble call,
+ // which assumes the fontMetrics are available for the affected font, otherwise a crash occurs (see http://trac.webkit.org/changeset/96122).
+ // The updateFont() call below updates the fontMetrics and ensures the proper setting of font-size.
+ styleSelector->updateFont();
+ styleSelector->applyPropertyToCurrentStyle(CSSPropertyFontSize, tempDecl->getPropertyCSSValue(CSSPropertyFontSize).get());
+ styleSelector->applyPropertyToCurrentStyle(CSSPropertyLineHeight, tempDecl->getPropertyCSSValue(CSSPropertyLineHeight).get());
+
state().m_font = newStyle->font();
state().m_font.update(styleSelector->fontSelector());
state().m_realizedFont = true;
Modified: trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js (100272 => 100273)
--- trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js 2011-11-15 14:06:38 UTC (rev 100272)
+++ trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js 2011-11-15 14:12:43 UTC (rev 100273)
@@ -489,18 +489,6 @@
// property is overloaded, so don't add it to the rule's usedProperties.
if (!(name in usedProperties))
styleRule.usedProperties[name] = true;
-
- if (name === "font") {
- // The font property is not reported as a shorthand. Report finding the individual
- // properties so they are visible in computed style.
- // FIXME: remove this when http://bugs.webkit.org/show_bug.cgi?id=15598 is fixed.
- styleRule.usedProperties["font-family"] = true;
- styleRule.usedProperties["font-size"] = true;
- styleRule.usedProperties["font-style"] = true;
- styleRule.usedProperties["font-variant"] = true;
- styleRule.usedProperties["font-weight"] = true;
- styleRule.usedProperties["line-height"] = true;
- }
}
// Add all the properties found in this style to the used properties list.
Modified: trunk/Source/WebCore/page/animation/AnimationBase.cpp (100272 => 100273)
--- trunk/Source/WebCore/page/animation/AnimationBase.cpp 2011-11-15 14:06:38 UTC (rev 100272)
+++ trunk/Source/WebCore/page/animation/AnimationBase.cpp 2011-11-15 14:12:43 UTC (rev 100273)
@@ -898,6 +898,7 @@
static const int animatableShorthandProperties[] = {
CSSPropertyBackground, // for background-color, background-position
CSSPropertyBackgroundPosition,
+ CSSPropertyFont, // for font-size, font-weight
CSSPropertyWebkitMask, // for mask-position
CSSPropertyWebkitMaskPosition,
CSSPropertyBorderTop, CSSPropertyBorderRight, CSSPropertyBorderBottom, CSSPropertyBorderLeft,
@@ -921,15 +922,6 @@
if (longhand.length() > 0)
addPropertyWrapper(propertyID, new ShorthandPropertyWrapper(propertyID, longhand));
}
-
- // 'font' is not in the shorthand map.
- static const int animatableFontProperties[] = {
- CSSPropertyFontSize,
- CSSPropertyFontWeight
- };
-
- CSSPropertyLonghand fontLonghand(animatableFontProperties, WTF_ARRAY_LENGTH(animatableFontProperties));
- addPropertyWrapper(CSSPropertyFont, new ShorthandPropertyWrapper(CSSPropertyFont, fontLonghand));
}
static PropertyWrapperBase* wrapperForProperty(int propertyID)