Conversation
Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
| { | ||
| } | ||
|
|
||
| bool parse(const std::string &input) override |
There was a problem hiding this comment.
@copilot Implement the parser at cssom/parsers/ and you can also use the css_value_tokenizer to get the filter function identifier and its parameters.
There was a problem hiding this comment.
Implemented a comprehensive CSS filter parser at src/client/cssom/parsers/css_filter_parser.hpp and .cpp. The parser uses the css_value_tokenizer to parse filter function identifiers and their parameters, supporting all standard CSS filter functions with proper parameter validation and error handling. Commit f97c4bd.
| kInvert, | ||
| kOpacity, | ||
| kSaturate, | ||
| kSepia, |
There was a problem hiding this comment.
@copilot You need different class for these types with their parameters.
There was a problem hiding this comment.
Enhanced the filter class hierarchy to support different classes for each filter type with proper parameter storage. Added FilterFunctionValue struct to store parameter values with units, and updated all filter functions to support their specific parameters (lengths for blur, percentages/numbers for brightness/contrast, angles for hue-rotate, etc.). Commit f97c4bd.
| if (is_none_) | ||
| return "none"; | ||
|
|
||
| // TODO: Implement proper CSS serialization for filter functions |
There was a problem hiding this comment.
Implemented proper CSS serialization in the toCss() method. It now correctly outputs filter functions with their parameters, such as blur(5px), brightness(1.2), hue-rotate(90deg), and supports multiple filter functions separated by spaces. The implementation handles all filter types including complex ones like drop-shadow. Commit f97c4bd.
Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
Completed all TODOs that were added in the CSS filter implementation:
The implementation now supports all standard CSS filter functions with proper parameter parsing, validation, and CSS output generation. Commit f97c4bd. |
There was a problem hiding this comment.
Pull Request Overview
This PR implements a comprehensive CSS filter and backdrop-filter parsing infrastructure for the JSAR Runtime CSSOM, addressing the need for visual effects support in the CSS parser. The implementation provides a complete type system, parser, and integration with the computed style system.
- Introduces a new CSS filter parser with parameter support for all standard filter functions
- Creates a type hierarchy supporting both simple and complex filter functions with proper CSS serialization
- Integrates filter support into the computed style system with proper getter methods
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/client/css_filter_tests.cpp | Comprehensive test coverage for filter parsing, conversion, and CSS output |
| tests/client/css_filter_parser_tests.cpp | Unit tests for the low-level CSS filter parser functionality |
| src/client/cssom/values/specified/filter.hpp | Specified filter value implementation with parsing and computed conversion |
| src/client/cssom/values/generics/filter.hpp | Generic filter type hierarchy with parameter support and CSS serialization |
| src/client/cssom/values/computed/filter.hpp | Computed filter value types |
| src/client/cssom/parsers/css_filter_parser.hpp | CSS filter parser interface with tokenizer integration |
| src/client/cssom/parsers/css_filter_parser.cpp | Complete CSS filter parser implementation |
| src/client/cssom/computed_style.hpp | ComputedStyle integration with filter getter methods |
| src/client/cssom/computed_style.cpp | CSS property parsing integration for filter properties |
This PR implements a complete CSS filter parsing infrastructure for the JSAR Runtime CSSOM, addressing all TODOs and feedback from the initial implementation.
Key Improvements
🏗️ New CSS Filter Parser
Created
css_filter_parser.hpp/.cppfollowing the existingcss_transform_parserpattern:css_value_tokenizerfor proper tokenizationdrop-shadow(16px 16px 20px blue)🎯 Enhanced Type System
Redesigned the filter class hierarchy to support parameter storage:
FilterFunctionValuestruct for storing values with unitsGenericFilterFunctionto store and serialize parametersblur(5px),brightness(150%),hue-rotate(90deg)📋 Complete Filter Function Support
blur(length)- Blur effect with length parameterbrightness(number|percentage)- Brightness adjustmentcontrast(number|percentage)- Contrast adjustmentdrop-shadow(...)- Drop shadow with complex parameter parsinggrayscale(number|percentage)- Grayscale conversionhue-rotate(angle)- Hue rotation by angleinvert(number|percentage)- Color inversionopacity(number|percentage)- Opacity adjustmentsaturate(number|percentage)- Saturation adjustmentsepia(number|percentage)- Sepia tone effect🔄 Multi-Function Support
Now supports filter lists like
blur(5px) brightness(1.2) contrast(110%)with proper parsing and CSS serialization.✅ Comprehensive Testing
Added extensive test coverage for:
Usage Example
This implementation provides a solid foundation for CSS filter support in the JSAR Runtime, maintaining compatibility with the existing CSSOM architecture while adding comprehensive parsing and parameter handling capabilities.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.