source: webkit/trunk/Source/WebCore/css/CSSFontValue.h

Last change on this file was 214359, checked in by [email protected], 8 years ago

font-style needs a new CSSValue to make CSSRule.cssText work correctly
https://bugs.webkit.org/show_bug.cgi?id=169258

Reviewed by David Hyatt.

Source/WebCore:

With variation fonts, font-style's value can't be captured in a CSSPrimitiveValue (nor any other subclass
off CSSValue) any more. Instead, we need to create two new CSSValues which represent the grammar that font-
style and it's associated @font-face descriptor accept.

The grammar of the font-style property is "normal | italic | oblique [ <<angle>> ]?"
The grammar of the font-style descriptor is "normal | italic | oblique [ <<angle>> | <<angle>> <<angle>> ]?"

We currently still support numbers in place of the <<angle>> value (contrary to the spec). We will remove
this support in https://bugs.webkit.org/show_bug.cgi?id=169357.

Tests: fast/text/font-selection-font-face-parse.html:

fast/text/font-style-parse.html:

  • CMakeLists.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • css/CSSAllInOne.cpp:
  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::fontStyleFromStyle):
(WebCore::fontShorthandValueForSelectionProperties):

  • css/CSSFontFace.cpp:

(WebCore::calculateWeightRange):
(WebCore::calculateStretchRange):
(WebCore::calculateItalicRange):

  • css/CSSFontFaceSet.cpp:

(WebCore::computeFontSelectionRequest):
(WebCore::CSSFontFaceSet::matchingFaces):
(WebCore::calculateWeightValue): Deleted.
(WebCore::calculateStretchValue): Deleted.
(WebCore::calculateStyleValue): Deleted.

  • css/CSSFontFaceSet.h:
  • css/CSSFontSelector.cpp:

(WebCore::CSSFontSelector::addFontFaceRule):

  • css/CSSFontStyleRangeValue.cpp: Added.

(WebCore::CSSFontStyleRangeValue::customCSSText):
(WebCore::CSSFontStyleRangeValue::equals):

  • css/CSSFontStyleRangeValue.h: Added.
  • css/CSSFontStyleValue.cpp: Added.

(WebCore::CSSFontStyleValue::customCSSText):
(WebCore::CSSFontStyleValue::equals):

  • css/CSSFontStyleValue.h: Added.
  • css/CSSFontValue.cpp:

(WebCore::CSSFontValue::customCSSText):

  • css/CSSFontValue.h:
  • css/CSSValue.cpp:

(WebCore::CSSValue::equals):
(WebCore::CSSValue::cssText):
(WebCore::CSSValue::destroy):

  • css/CSSValue.h:

(WebCore::CSSValue::isFontStyleValue):
(WebCore::CSSValue::isFontStyleRangeValue):

  • css/FontFace.cpp:

(WebCore::FontFace::style):
(WebCore::FontFace::weight):
(WebCore::FontFace::stretch):

  • css/StyleBuilderConverter.h:

(WebCore::StyleBuilderConverter::convertFontWeightFromValue):
(WebCore::StyleBuilderConverter::convertFontStretchFromValue):
(WebCore::StyleBuilderConverter::convertFontStyleFromValue):
(WebCore::StyleBuilderConverter::convertFontWeight):
(WebCore::StyleBuilderConverter::convertFontStretch):
(WebCore::StyleBuilderConverter::convertFontStyle):

  • css/parser/CSSPropertyParser.cpp:

(WebCore::consumeFontStyle):
(WebCore::consumeFontStyleRange):
(WebCore::CSSPropertyParser::consumeSystemFont):
(WebCore::CSSPropertyParser::consumeFont):

  • svg/SVGFontFaceElement.cpp:

(WebCore::SVGFontFaceElement::parseAttribute):

LayoutTests:

Update tests' expected results.

  • fast/text/font-selection-font-face-parse-expected.txt:
  • fast/text/font-selection-font-face-parse.html:
  • fast/text/font-style-parse-expected.txt:
  • fast/text/font-style-parse.html:
  • platform/mac-elcapitan/fast/text/font-selection-font-face-parse-expected.txt:
  • svg/css/getComputedStyle-basic-expected.txt:
  • Property svn:eol-style set to native
File size: 1.7 KB
Line 
1/*
2 * (C) 1999-2003 Lars Knoll ([email protected])
3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21#pragma once
22
23#include "CSSFontStyleValue.h"
24#include "CSSValue.h"
25#include <wtf/RefPtr.h>
26
27namespace WebCore {
28
29class CSSPrimitiveValue;
30class CSSValueList;
31
32class CSSFontValue final : public CSSValue {
33public:
34 static Ref<CSSFontValue> create()
35 {
36 return adoptRef(*new CSSFontValue);
37 }
38
39 String customCSSText() const;
40
41 bool equals(const CSSFontValue&) const;
42
43 RefPtr<CSSFontStyleValue> style;
44 RefPtr<CSSPrimitiveValue> variant;
45 RefPtr<CSSPrimitiveValue> weight;
46 RefPtr<CSSPrimitiveValue> stretch;
47 RefPtr<CSSPrimitiveValue> size;
48 RefPtr<CSSPrimitiveValue> lineHeight;
49 RefPtr<CSSValueList> family;
50
51private:
52 CSSFontValue()
53 : CSSValue(FontClass)
54 {
55 }
56};
57
58} // namespace WebCore
59
60SPECIALIZE_TYPE_TRAITS_CSS_VALUE(CSSFontValue, isFontValue())
Note: See TracBrowser for help on using the repository browser.