source: webkit/trunk/Source/WebCore/css/CSSUnicodeRangeValue.cpp

Last change on this file was 251655, checked in by Simon Fraser, 6 years ago

Can't change @font-face descriptors from fontFaceRule.style.setProperty()
https://bugs.webkit.org/show_bug.cgi?id=177975
<rdar://problem/56648761>

Reviewed by Antti Koivisto.

LayoutTests/imported/w3c:

More passing subtests.

  • web-platform-tests/css/css-syntax/urange-parsing-expected.txt:

Source/WebCore:

When parsing properties via PropertySetCSSStyleDeclaration::setProperty() (called from
script as rule.style.setProperty()), CSSPropertyParser::parseValue() needs to know if
we're parsing properties in a @font-face or @viewport rule, since some properties are
only allowed in these contexts.

Achieve this by adding to CSSParserContext an Optional<enclosingRuleType>, which gets set
for font-face and viewport rules. This gets set by StyleRuleCSSStyleDeclaration::cssParserContext()
based on the type of the parent rule.

Moved StyleRule::Type to its own header so CSSParserContext can use it. Added compile-time asserts
that the values match CSSRule::Type (fixing one of them).

Also fix <urange> serialization when start and end values are the same.

Test: web-platform-tests/css/css-syntax/urange-parsing.html

  • Headers.cmake:
  • WebCore.xcodeproj/project.pbxproj:
  • css/CSSKeyframeRule.cpp:

(WebCore::StyleRuleKeyframe::StyleRuleKeyframe):

  • css/CSSKeyframesRule.cpp:

(WebCore::StyleRuleKeyframes::StyleRuleKeyframes):

  • css/CSSPropertySourceData.h:

(WebCore::CSSRuleSourceData::create):
(WebCore::CSSRuleSourceData::createUnknown):
(WebCore::CSSRuleSourceData::CSSRuleSourceData):

  • css/CSSRule.cpp:
  • css/CSSUnicodeRangeValue.cpp:

(WebCore::CSSUnicodeRangeValue::customCSSText const):

  • css/PropertySetCSSStyleDeclaration.cpp:

(WebCore::StyleRuleCSSStyleDeclaration::cssParserContext const):

  • css/StyleRule.cpp:

(WebCore::StyleRuleBase::destroy):
(WebCore::StyleRuleBase::copy const):
(WebCore::StyleRuleBase::createCSSOMWrapper const):
(WebCore::StyleRule::StyleRule):
(WebCore::StyleRulePage::StyleRulePage):
(WebCore::StyleRuleFontFace::StyleRuleFontFace):
(WebCore::StyleRuleGroup::StyleRuleGroup):
(WebCore::StyleRuleMedia::StyleRuleMedia):
(WebCore::StyleRuleSupports::StyleRuleSupports):
(WebCore::StyleRuleViewport::StyleRuleViewport):
(WebCore::StyleRuleCharset::StyleRuleCharset):
(WebCore::StyleRuleNamespace::StyleRuleNamespace):

  • css/StyleRule.h:

(WebCore::StyleRuleBase::type const):
(WebCore::StyleRuleBase::isCharsetRule const):
(WebCore::StyleRuleBase::isFontFaceRule const):
(WebCore::StyleRuleBase::isKeyframesRule const):
(WebCore::StyleRuleBase::isKeyframeRule const):
(WebCore::StyleRuleBase::isNamespaceRule const):
(WebCore::StyleRuleBase::isMediaRule const):
(WebCore::StyleRuleBase::isPageRule const):
(WebCore::StyleRuleBase::isStyleRule const):
(WebCore::StyleRuleBase::isSupportsRule const):
(WebCore::StyleRuleBase::isViewportRule const):
(WebCore::StyleRuleBase::isImportRule const):
(WebCore::StyleRuleBase::StyleRuleBase):

  • css/StyleRuleImport.cpp:

(WebCore::StyleRuleImport::StyleRuleImport):

  • css/StyleRuleImport.h:
  • css/StyleRuleType.h: Copied from Source/WebCore/css/CSSUnicodeRangeValue.cpp.
  • css/StyleSheetContents.cpp:

(WebCore::traverseRulesInVector):
(WebCore::StyleSheetContents::traverseSubresources const):

  • css/parser/CSSParser.cpp:

(WebCore::CSSParser::parseValueWithVariableReferences):

  • css/parser/CSSParserContext.h:
  • css/parser/CSSParserImpl.cpp:

(WebCore::CSSParserImpl::parseValue):
(WebCore::CSSParserImpl::parseInlineStyleDeclaration):
(WebCore::CSSParserImpl::parseDeferredDeclaration):
(WebCore::CSSParserImpl::parseDeclarationList):
(WebCore::CSSParserImpl::supportsDeclaration):
(WebCore::CSSParserImpl::parseDeclarationListForInspector):
(WebCore::CSSParserImpl::consumeImportRule):
(WebCore::CSSParserImpl::consumeMediaRule):
(WebCore::CSSParserImpl::consumeSupportsRule):
(WebCore::CSSParserImpl::consumeViewportRule):
(WebCore::CSSParserImpl::consumeFontFaceRule):
(WebCore::CSSParserImpl::consumeKeyframesRule):
(WebCore::CSSParserImpl::consumePageRule):
(WebCore::CSSParserImpl::consumeKeyframeStyleRule):
(WebCore::observeSelectors):
(WebCore::CSSParserImpl::consumeStyleRule):
(WebCore::CSSParserImpl::consumeDeclarationList):
(WebCore::CSSParserImpl::consumeDeclaration):
(WebCore::CSSParserImpl::consumeDeclarationValue):

  • css/parser/CSSParserImpl.h:
  • css/parser/CSSParserObserver.h:
  • css/parser/CSSPropertyParser.cpp:

(WebCore::CSSPropertyParser::parseValue):

  • css/parser/CSSPropertyParser.h:
  • css/parser/CSSTokenizer.cpp:

(WebCore::CSSTokenizer::letterU):

  • inspector/InspectorStyleSheet.cpp:

(flattenSourceData):
(WebCore::StyleSheetHandler::startRuleHeader):
(WebCore::InspectorStyleSheetForInlineStyle::ruleSourceData const):

LayoutTests:

Fix tests for the urange serialization fix.

  • fast/text/font-face-javascript-expected.txt:
  • fast/text/font-face-javascript.html:
  • fast/text/unicode-range-javascript-expected.txt:
  • fast/text/unicode-range-javascript.html:
  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1/*
2 * Copyright (C) 2008 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include "config.h"
27#include "CSSUnicodeRangeValue.h"
28
29#include <wtf/HexNumber.h>
30
31namespace WebCore {
32
33String CSSUnicodeRangeValue::customCSSText() const
34{
35 if (m_from == m_to)
36 return makeString("U+", hex(m_from, Lowercase));
37
38 return makeString("U+", hex(m_from, Lowercase), '-', hex(m_to, Lowercase));
39}
40
41bool CSSUnicodeRangeValue::equals(const CSSUnicodeRangeValue& other) const
42{
43 return m_from == other.m_from && m_to == other.m_to;
44}
45
46}
Note: See TracBrowser for help on using the repository browser.