Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 1, 2025

This PR replaces the existing Rust-based CSS transform parser with a comprehensive C++ implementation that integrates with the existing CSS value tokenizer infrastructure and adds support for negative values.

Key Changes

New C++ Transform Parser

  • Complete C++ implementation - css_transform_parser.{hpp,cpp} supporting all CSS transform functions
  • Tokenizer integration - Uses existing CSSValueTokenizer for robust CSS value parsing
  • Full CSS specification support including:
    • Translation: translate(), translateX(), translateY(), translateZ(), translate3d()
    • Rotation: rotate(), rotateX(), rotateY(), rotateZ(), rotate3d()
    • Scaling: scale(), scaleX(), scaleY(), scaleZ(), scale3d()
    • Matrix: matrix(), matrix3d()
    • Skew: skew(), skewX(), skewY()
    • Perspective: perspective()
    • Special case: none keyword

Negative Value Support

The parser now correctly handles negative values as required by the CSS specification:

// All of these now parse correctly:
"translateX(-10px)"     // Negative length
"rotate(-45deg)"        // Negative angle  
"scale(-1)"             // Negative scale factor
"scaleX(-0.5)"          // Negative decimal values
"translate(-10px, -20px)" // Multiple negative values

The implementation works around tokenizer behavior where negative dimensions are parsed as identifier tokens rather than separate delimiter + dimension tokens, ensuring robust parsing of all negative value formats.

Dependency Removal

  • Eliminates Rust dependencies - Removes reliance on crates::css2::parsing::parseTransform()
  • Native C++ performance - No FFI overhead
  • Simplified maintenance - Pure C++ codebase

Comprehensive Testing

Added 47+ test cases covering all transform functions and edge cases including extensive negative value testing to ensure correctness and CSS specification compliance.

Benefits

  • Complete CSS compliance - Now supports the full CSS transform specification including negative values
  • Performance improvement - Native C++ implementation with no FFI overhead
  • Better maintainability - Pure C++ codebase easier to maintain and debug
  • API compatibility - Maintains full compatibility with existing transform processing pipeline

Fixes #175.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 3 commits August 1, 2025 05:38
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>
Copilot AI changed the title [WIP] Replace Rust CSS transform parser with C/C++ implementation and integrate with /src/client/cssom/values/ Replace Rust CSS transform parser with C/C++ implementation Aug 1, 2025
Copilot AI requested a review from yorkie August 1, 2025 05:48
Copilot AI and others added 2 commits August 1, 2025 12:19
Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
Copilot AI changed the title Replace Rust CSS transform parser with C/C++ implementation Replace Rust CSS transform parser with C/C++ implementation supporting negative values Aug 1, 2025
Copilot AI requested a review from yorkie August 1, 2025 12:21
Copy link
Member

@yorkie yorkie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert your changes on build directory.

Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Aug 1, 2025

Please revert your changes on build directory.

Done! I've reverted all the build directory changes - restored the .gitignore to its original state and brought back all the build artifacts that were previously committed. (8a02794)

Copilot AI requested a review from yorkie August 1, 2025 12:51
Copy link
Member

@yorkie yorkie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't submit the changes of the build directory.

Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Aug 1, 2025

Don't submit the changes of the build directory.

Removed all CMake build artifacts from git tracking and updated .gitignore to prevent CMake-generated files from being committed in the future. The build directory now only contains the original build scripts and configuration files as intended. (b150a2b)

Copilot AI requested a review from yorkie August 1, 2025 16:12
@yorkie yorkie marked this pull request as ready for review August 1, 2025 18:25
@yorkie yorkie merged commit 4902b98 into main Aug 1, 2025
2 checks passed
@yorkie yorkie deleted the copilot/fix-175 branch August 1, 2025 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace Rust CSS transform parser with C/C++ implementation and integrate with /src/client/cssom/values/

2 participants