forked from WebKit/WebKit-http
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CSS Cascade Layers] Add CSSOM interface
https://bugs.webkit.org/show_bug.cgi?id=230882 Reviewed by Simon Fraser. LayoutTests/imported/w3c: * web-platform-tests/css/css-cascade/parsing/layer-expected.txt: Added. Source/WebCore: Add a minimal CSSLayerRule interface. This is yet unspecified (w3c/csswg-drafts#6576) but the final version likely won't differ much or at all. This also matches Firefox. This makes parsing and serialization WPT tests work. * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * css/CSSLayerRule.cpp: Added. (WebCore::CSSLayerRule::CSSLayerRule): (WebCore::CSSLayerRule::create): (WebCore::CSSLayerRule::cssText const): The only available functionality is getting the cssText. * css/CSSLayerRule.h: Added. * css/CSSLayerRule.idl: Added. * css/CSSRule.h: * css/StyleRule.cpp: (WebCore::StyleRuleBase::createCSSOMWrapper const): Make the wrapper. * css/StyleRuleType.h: Update the type constant to match Firefox (this is not specified). * css/StyleSheetContents.cpp: (WebCore::StyleSheetContents::wrapperInsertRule): Remember the return after succesful insert. LayoutTests: * TestExpectations: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@283170 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
antti@apple.com
committed
Sep 28, 2021
1 parent
5d21ae0
commit 24b9b5d
Showing
18 changed files
with
271 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/parsing/layer-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
PASS @layer A; should be a valid rule | ||
PASS @layer A, B, C; should be a valid rule | ||
PASS @layer A.A; should be a valid rule | ||
PASS @layer A, B.C.D, C; should be a valid rule | ||
PASS @layer; should be an invalid rule | ||
PASS @layer A . A; should be an invalid rule | ||
PASS @layer { | ||
} should be a valid rule | ||
PASS @layer A { | ||
} should be a valid rule | ||
PASS @layer A.B { | ||
} should be a valid rule | ||
PASS @layer A . B { | ||
} should be an invalid rule | ||
PASS @layer A, B, C { | ||
} should be an invalid rule | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* Copyright (C) 2021 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* 1. Redistributions of source code must retain the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer in the documentation and/or other materials | ||
* provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY | ||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, | ||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | ||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF | ||
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
* SUCH DAMAGE. | ||
*/ | ||
|
||
#include "config.h" | ||
#include "CSSLayerRule.h" | ||
|
||
#include "CSSStyleSheet.h" | ||
#include "StyleRule.h" | ||
#include <wtf/text/StringBuilder.h> | ||
|
||
namespace WebCore { | ||
|
||
CSSLayerRule::CSSLayerRule(StyleRuleLayer& rule, CSSStyleSheet* parent) | ||
: CSSGroupingRule(rule, parent) | ||
{ | ||
} | ||
|
||
Ref<CSSLayerRule> CSSLayerRule::create(StyleRuleLayer& rule, CSSStyleSheet* parent) | ||
{ | ||
return adoptRef(*new CSSLayerRule(rule, parent)); | ||
} | ||
|
||
String CSSLayerRule::cssText() const | ||
{ | ||
auto& layer = downcast<StyleRuleLayer>(groupRule()); | ||
|
||
StringBuilder result; | ||
|
||
auto appendLayerName = [&](auto& name) { | ||
for (auto& segment : name) { | ||
result.append(segment); | ||
if (&segment != &name.last()) | ||
result.append('.'); | ||
} | ||
}; | ||
|
||
if (layer.isStatement()) { | ||
result.append("@layer "); | ||
for (auto& name : layer.nameList()) { | ||
appendLayerName(name); | ||
if (&name != &layer.nameList().last()) | ||
result.append(", "); | ||
} | ||
result.append(';'); | ||
return result.toString(); | ||
} | ||
|
||
result.append("@layer "); | ||
if (!layer.name().isEmpty()) { | ||
appendLayerName(layer.name()); | ||
result.append(' '); | ||
} | ||
result.append("{\n"); | ||
appendCSSTextForItems(result); | ||
result.append('}'); | ||
return result.toString(); | ||
} | ||
|
||
} // namespace WebCore | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (C) 2021 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* 1. Redistributions of source code must retain the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer in the documentation and/or other materials | ||
* provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY | ||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, | ||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | ||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF | ||
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
* SUCH DAMAGE. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "CSSGroupingRule.h" | ||
|
||
namespace WebCore { | ||
|
||
class StyleRuleLayer; | ||
|
||
class CSSLayerRule final : public CSSGroupingRule { | ||
public: | ||
static Ref<CSSLayerRule> create(StyleRuleLayer&, CSSStyleSheet* parent); | ||
|
||
String cssText() const final; | ||
|
||
private: | ||
CSSLayerRule(StyleRuleLayer&, CSSStyleSheet*); | ||
CSSRule::Type type() const final { return LAYER_RULE; } | ||
}; | ||
|
||
} // namespace WebCore | ||
|
||
SPECIALIZE_TYPE_TRAITS_CSS_RULE(CSSLayerRule, CSSRule::LAYER_RULE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (C) 2021 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* 1. Redistributions of source code must retain the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer in the documentation and/or other materials | ||
* provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY | ||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, | ||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | ||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF | ||
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
* SUCH DAMAGE. | ||
*/ | ||
|
||
[ | ||
Exposed=Window | ||
] interface CSSLayerRule : CSSGroupingRule { | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.