Skip to content

Commit 39844dd

Browse files
Merge pull request #8981 from haidubogdan/t_8343_css_support_image_set
CSS include support for image-set
2 parents d2e1813 + ae375e9 commit 39844dd

File tree

9 files changed

+68
-6
lines changed

9 files changed

+68
-6
lines changed

ide/css.editor/src/org/netbeans/modules/css/editor/module/main/Bundle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ css-module-displayname-logical=Logical properties and values
6060
css-module-displayname-overflow=Overflow
6161
css-module-displayname-filter_effects=Filter Effects
6262
css-module-displayname-scroll_snap=Scroll Snap
63+
css-module-displayname-images_4=Images Module Level 4
6364

6465
completion-help-no-documentation-found=No documentation found
6566

ide/css.editor/src/org/netbeans/modules/css/editor/module/main/DefaultCssEditorModule.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public class DefaultCssEditorModule extends CssEditorModule {
109109
module("positioning", "http://www.w3.org/TR/css-position-3"), //NOI18N
110110
module("overflow", "http://www.w3.org/TR/css-overflow-3"), //NOI18N
111111
module("scroll_snap", "http://www.w3.org/TR/css-scroll-snap-1"), //NOI18N
112+
module("images_4", "http://www.w3.org/TR/css-images-4/"), //NOI18N
112113
module("sizing", "http://www.w3.org/TR/css-sizing-3"), //NOI18N
113114
module("contain", "http://www.w3.org/TR/css-contain-3"), //NOI18N
114115
module("other", null) //NOI18N

ide/css.editor/src/org/netbeans/modules/css/editor/module/main/properties/image_values.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
$category=images
2121

22-
@image=<uri> | <image-list> | <element-reference> | <image-combination> | <gradient>
22+
@image=<uri> | <image-list> | <image-set> | <element-reference> | <image-combination> | <gradient>
2323

2424
@image-list=image ( [ [ [<image-decl> , ]* [ <image-decl>] ] | <color> ] )
2525

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
# CSS Images Module Level 4
19+
20+
$category=images_4
21+
22+
@image-set = image-set ( <image-set-option> [, <image-set-option> ]* )
23+
24+
@image-set-option = [<image> | <string>] [<resolution> | <image-file-type>]?
25+
26+
@image-file-type = type ( <string> )
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.netbeans.modules.css.editor.module.main;
20+
21+
public class Images4Test extends CssModuleTestBase {
22+
23+
public Images4Test(String testName) {
24+
super(testName);
25+
}
26+
27+
public void testImageSetProperty() {
28+
assertPropertyDeclaration("background-image: image-set(\"picture.png\" 1x)");
29+
assertPropertyDeclaration("background-image: image-set(\"picture.png\" type(\"image/avif\"), \"foo.jpg\" type(\"image/jpeg\"))");
30+
assertPropertyDeclaration("background-image: image-set( linear-gradient(cornflowerblue, white) 1x, url(\"detailed-gradient.png\") 3x );");
31+
}
32+
33+
}

ide/css.editor/test/unit/src/org/netbeans/modules/css/editor/module/main/ListsAndCountersModuleTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void testListStyleCompletion() {
4949
"upper-roman","!uri","cross-fade","radial-gradient", "conic-gradient",
5050
"inside", "decimal-leading-zero","square", "circle","none",
5151
"symbols", "outside", "initial", "inherit", "unset", "revert",
52-
"var");
52+
"image-set", "var");
5353
}
5454

5555
public void testListStyleType() {
@@ -74,7 +74,7 @@ public void testListStyleTypeCompletion() {
7474
"repeating-linear-gradient", "element", "numeric", "linear-gradient",
7575
"!string", "alphabetic", "image", "symbolic", "repeating-radial-gradient",
7676
"!uri", "repeating", "cross-fade", "non-repeating", "radial-gradient",
77-
"conic-gradient", "var");
77+
"conic-gradient", "image-set", "var");
7878
}
7979

8080
public void testListStyleImage() {

ide/css.lib/src/org/netbeans/modules/css/lib/api/properties/PropertyCategory.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public enum PropertyCategory {
5151
GRID,
5252
HYPERLINKS,
5353
IMAGES,
54+
IMAGES_4,
5455
LINE,
5556
LISTS_AND_COUNTERS,
5657
LOGICAL,

ide/css.lib/src/org/netbeans/modules/css/lib/api/properties/TokenAcceptor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Collection<String> getFixedImageTokens() {
9797

9898
public static class Resolution extends NumberPostfixAcceptor {
9999

100-
private static final List<String> POSTFIXES = Arrays.asList(new String[]{"dpi", "dppx", "dpcm"}); //NOI18N
100+
private static final List<String> POSTFIXES = Arrays.asList(new String[]{"dpi", "dppx", "dpcm", "x"}); //NOI18N
101101

102102
public Resolution(String id) {
103103
super(id);

ide/css.lib/test/unit/src/org/netbeans/modules/css/lib/api/properties/PropertyValueTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ public void testTheBackgroundCase() {
290290
"repeat", "!length", "-", "repeating-radial-gradient", "space", "!percentage",
291291
"fixed", "border-box", "center", "no-repeat", "none", "left", "right",
292292
"top", "element", "scroll", "repeat-y", "linear-gradient", "repeat-x",
293-
"image", "!uri", "cross-fade", "radial-gradient", "conic-gradient", "bottom", "local",
293+
"image", "image-set", "!uri", "cross-fade", "radial-gradient", "conic-gradient", "bottom", "local",
294294
"calc", "var", "mod", "log", "cos", "sign", "atan", "min", "sqrt",
295295
"hypot", "sin", "pow", "rem", "exp", "clamp", "atan2", "tan", "max",
296296
"acos", "abs", "asin");
@@ -301,7 +301,7 @@ public void testTheBackgroundCase2() {
301301
assertResolve(p.getGrammar(), "aliceblue bottom / auto");
302302
assertAlternatives(p.getGrammar(), "aliceblue bottom / auto",
303303
"repeating-linear-gradient", "element", "padding-box", "scroll", ""
304-
+ "content-box", "repeat-y", "linear-gradient", "repeat-x", "image",
304+
+ "content-box", "repeat-y", "linear-gradient", "repeat-x", "image", "image-set",
305305
"round", "!length", "-", "repeat", "repeating-radial-gradient", "space",
306306
"fixed", "!percentage", "!uri", "border-box", "cross-fade",
307307
"radial-gradient", "conic-gradient", "no-repeat", "auto", "none", "local", "calc",

0 commit comments

Comments
 (0)