From ae375e97eadd1507c6772d3437102ad65248b02a Mon Sep 17 00:00:00 2001 From: Bogdan Haidu Date: Mon, 3 Nov 2025 20:25:33 +0200 Subject: [PATCH] css: include support for image-set Closes #8343 --- .../css/editor/module/main/Bundle.properties | 1 + .../module/main/DefaultCssEditorModule.java | 1 + .../main/properties/image_values.properties | 2 +- .../main/properties/images_4.properties | 26 +++++++++++++++ .../css/editor/module/main/Images4Test.java | 33 +++++++++++++++++++ .../main/ListsAndCountersModuleTest.java | 4 +-- .../lib/api/properties/PropertyCategory.java | 1 + .../css/lib/api/properties/TokenAcceptor.java | 2 +- .../lib/api/properties/PropertyValueTest.java | 4 +-- 9 files changed, 68 insertions(+), 6 deletions(-) create mode 100644 ide/css.editor/src/org/netbeans/modules/css/editor/module/main/properties/images_4.properties create mode 100644 ide/css.editor/test/unit/src/org/netbeans/modules/css/editor/module/main/Images4Test.java diff --git a/ide/css.editor/src/org/netbeans/modules/css/editor/module/main/Bundle.properties b/ide/css.editor/src/org/netbeans/modules/css/editor/module/main/Bundle.properties index bd8485b6a000..b6b7b369e71a 100644 --- a/ide/css.editor/src/org/netbeans/modules/css/editor/module/main/Bundle.properties +++ b/ide/css.editor/src/org/netbeans/modules/css/editor/module/main/Bundle.properties @@ -60,6 +60,7 @@ css-module-displayname-logical=Logical properties and values css-module-displayname-overflow=Overflow css-module-displayname-filter_effects=Filter Effects css-module-displayname-scroll_snap=Scroll Snap +css-module-displayname-images_4=Images Module Level 4 completion-help-no-documentation-found=No documentation found diff --git a/ide/css.editor/src/org/netbeans/modules/css/editor/module/main/DefaultCssEditorModule.java b/ide/css.editor/src/org/netbeans/modules/css/editor/module/main/DefaultCssEditorModule.java index 50e9e4d9e6a4..05fa44c2f7ae 100644 --- a/ide/css.editor/src/org/netbeans/modules/css/editor/module/main/DefaultCssEditorModule.java +++ b/ide/css.editor/src/org/netbeans/modules/css/editor/module/main/DefaultCssEditorModule.java @@ -109,6 +109,7 @@ public class DefaultCssEditorModule extends CssEditorModule { module("positioning", "http://www.w3.org/TR/css-position-3"), //NOI18N module("overflow", "http://www.w3.org/TR/css-overflow-3"), //NOI18N module("scroll_snap", "http://www.w3.org/TR/css-scroll-snap-1"), //NOI18N + module("images_4", "http://www.w3.org/TR/css-images-4/"), //NOI18N module("sizing", "http://www.w3.org/TR/css-sizing-3"), //NOI18N module("contain", "http://www.w3.org/TR/css-contain-3"), //NOI18N module("other", null) //NOI18N diff --git a/ide/css.editor/src/org/netbeans/modules/css/editor/module/main/properties/image_values.properties b/ide/css.editor/src/org/netbeans/modules/css/editor/module/main/properties/image_values.properties index 6b1f49baf1db..4407992b9762 100644 --- a/ide/css.editor/src/org/netbeans/modules/css/editor/module/main/properties/image_values.properties +++ b/ide/css.editor/src/org/netbeans/modules/css/editor/module/main/properties/image_values.properties @@ -19,7 +19,7 @@ $category=images -@image= | | | | +@image= | | | | | @image-list=image ( [ [ [ , ]* [ ] ] | ] ) diff --git a/ide/css.editor/src/org/netbeans/modules/css/editor/module/main/properties/images_4.properties b/ide/css.editor/src/org/netbeans/modules/css/editor/module/main/properties/images_4.properties new file mode 100644 index 000000000000..2f63dadfab70 --- /dev/null +++ b/ide/css.editor/src/org/netbeans/modules/css/editor/module/main/properties/images_4.properties @@ -0,0 +1,26 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# CSS Images Module Level 4 + +$category=images_4 + +@image-set = image-set ( [, ]* ) + +@image-set-option = [ | ] [ | ]? + +@image-file-type = type ( ) \ No newline at end of file diff --git a/ide/css.editor/test/unit/src/org/netbeans/modules/css/editor/module/main/Images4Test.java b/ide/css.editor/test/unit/src/org/netbeans/modules/css/editor/module/main/Images4Test.java new file mode 100644 index 000000000000..0559e89c8cbf --- /dev/null +++ b/ide/css.editor/test/unit/src/org/netbeans/modules/css/editor/module/main/Images4Test.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.netbeans.modules.css.editor.module.main; + +public class Images4Test extends CssModuleTestBase { + + public Images4Test(String testName) { + super(testName); + } + + public void testImageSetProperty() { + assertPropertyDeclaration("background-image: image-set(\"picture.png\" 1x)"); + assertPropertyDeclaration("background-image: image-set(\"picture.png\" type(\"image/avif\"), \"foo.jpg\" type(\"image/jpeg\"))"); + assertPropertyDeclaration("background-image: image-set( linear-gradient(cornflowerblue, white) 1x, url(\"detailed-gradient.png\") 3x );"); + } + +} diff --git a/ide/css.editor/test/unit/src/org/netbeans/modules/css/editor/module/main/ListsAndCountersModuleTest.java b/ide/css.editor/test/unit/src/org/netbeans/modules/css/editor/module/main/ListsAndCountersModuleTest.java index 57dc6971ad91..d03a362f5be4 100644 --- a/ide/css.editor/test/unit/src/org/netbeans/modules/css/editor/module/main/ListsAndCountersModuleTest.java +++ b/ide/css.editor/test/unit/src/org/netbeans/modules/css/editor/module/main/ListsAndCountersModuleTest.java @@ -49,7 +49,7 @@ public void testListStyleCompletion() { "upper-roman","!uri","cross-fade","radial-gradient", "conic-gradient", "inside", "decimal-leading-zero","square", "circle","none", "symbols", "outside", "initial", "inherit", "unset", "revert", - "var"); + "image-set", "var"); } public void testListStyleType() { @@ -74,7 +74,7 @@ public void testListStyleTypeCompletion() { "repeating-linear-gradient", "element", "numeric", "linear-gradient", "!string", "alphabetic", "image", "symbolic", "repeating-radial-gradient", "!uri", "repeating", "cross-fade", "non-repeating", "radial-gradient", - "conic-gradient", "var"); + "conic-gradient", "image-set", "var"); } public void testListStyleImage() { diff --git a/ide/css.lib/src/org/netbeans/modules/css/lib/api/properties/PropertyCategory.java b/ide/css.lib/src/org/netbeans/modules/css/lib/api/properties/PropertyCategory.java index 4be707c74f65..17bbbbd7257f 100644 --- a/ide/css.lib/src/org/netbeans/modules/css/lib/api/properties/PropertyCategory.java +++ b/ide/css.lib/src/org/netbeans/modules/css/lib/api/properties/PropertyCategory.java @@ -51,6 +51,7 @@ public enum PropertyCategory { GRID, HYPERLINKS, IMAGES, + IMAGES_4, LINE, LISTS_AND_COUNTERS, LOGICAL, diff --git a/ide/css.lib/src/org/netbeans/modules/css/lib/api/properties/TokenAcceptor.java b/ide/css.lib/src/org/netbeans/modules/css/lib/api/properties/TokenAcceptor.java index e3d1c920be79..595648ae0e57 100644 --- a/ide/css.lib/src/org/netbeans/modules/css/lib/api/properties/TokenAcceptor.java +++ b/ide/css.lib/src/org/netbeans/modules/css/lib/api/properties/TokenAcceptor.java @@ -97,7 +97,7 @@ Collection getFixedImageTokens() { public static class Resolution extends NumberPostfixAcceptor { - private static final List POSTFIXES = Arrays.asList(new String[]{"dpi", "dppx", "dpcm"}); //NOI18N + private static final List POSTFIXES = Arrays.asList(new String[]{"dpi", "dppx", "dpcm", "x"}); //NOI18N public Resolution(String id) { super(id); diff --git a/ide/css.lib/test/unit/src/org/netbeans/modules/css/lib/api/properties/PropertyValueTest.java b/ide/css.lib/test/unit/src/org/netbeans/modules/css/lib/api/properties/PropertyValueTest.java index 58a237a4d8de..093762b85291 100644 --- a/ide/css.lib/test/unit/src/org/netbeans/modules/css/lib/api/properties/PropertyValueTest.java +++ b/ide/css.lib/test/unit/src/org/netbeans/modules/css/lib/api/properties/PropertyValueTest.java @@ -290,7 +290,7 @@ public void testTheBackgroundCase() { "repeat", "!length", "-", "repeating-radial-gradient", "space", "!percentage", "fixed", "border-box", "center", "no-repeat", "none", "left", "right", "top", "element", "scroll", "repeat-y", "linear-gradient", "repeat-x", - "image", "!uri", "cross-fade", "radial-gradient", "conic-gradient", "bottom", "local", + "image", "image-set", "!uri", "cross-fade", "radial-gradient", "conic-gradient", "bottom", "local", "calc", "var", "mod", "log", "cos", "sign", "atan", "min", "sqrt", "hypot", "sin", "pow", "rem", "exp", "clamp", "atan2", "tan", "max", "acos", "abs", "asin"); @@ -301,7 +301,7 @@ public void testTheBackgroundCase2() { assertResolve(p.getGrammar(), "aliceblue bottom / auto"); assertAlternatives(p.getGrammar(), "aliceblue bottom / auto", "repeating-linear-gradient", "element", "padding-box", "scroll", "" - + "content-box", "repeat-y", "linear-gradient", "repeat-x", "image", + + "content-box", "repeat-y", "linear-gradient", "repeat-x", "image", "image-set", "round", "!length", "-", "repeat", "repeating-radial-gradient", "space", "fixed", "!percentage", "!uri", "border-box", "cross-fade", "radial-gradient", "conic-gradient", "no-repeat", "auto", "none", "local", "calc",