Skip to content

Internal: Create centralized place for rendering styles - take 2 [ED-19458]#31784

Merged
ronros-elementor merged 191 commits intoelementor:mainfrom
ronros-elementor:feature/ED-19458
Jul 14, 2025
Merged

Internal: Create centralized place for rendering styles - take 2 [ED-19458]#31784
ronros-elementor merged 191 commits intoelementor:mainfrom
ronros-elementor:feature/ED-19458

Conversation

@ronros-elementor
Copy link
Copy Markdown
Contributor

@ronros-elementor ronros-elementor commented Jul 9, 2025

✨ PR Description

Purpose: Add centralized rendering system for atomic widget styles with caching and breakpoint support

Main changes:

  • Created Atomic_Styles_Manager to handle style rendering across multiple breakpoints with efficient caching
  • Added Cache_Validity system to manage invalidation of cached styles by component and breakpoint
  • Implemented post-specific style rendering through new action hooks in the rendering pipeline
  • Moved global classes styles from CSS file injection to the new centralized rendering system

Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using. We'd love your feedback! 🚀

@ronros-elementor ronros-elementor marked this pull request as ready for review July 10, 2025 23:25
$this->enqueue_fonts();
}

private function initialize_styles( array $styles_by_key ) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why is it called initialize_styles and initialize_style ?
do we have some more stuff we're going to add here other than the fonts?

$style_file->get_media()
);

$this->add_fonts_to_enqueue( $style_key );
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can't we merge it with what we're doing in initialize_styles ?
it feels a bit decoupled when we first initialize and then running this here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The initialize part is actually to clear all collected fonts under a given style key, in case cache is invalid.

The latter guarantees we're enqueuing all fonts after we executed all the relevant "render_css" callbacks of all breakpoints, because before the css file generations - we have no clue which fonts are used in which style definition, and if we'd clean out the fonts after we ran over all breakpoints - we'll reset the fonts after them being added as part of the css rendering execution

So the steps are:
If cache is invalid -

  1. Empty recorded fonts
  2. Populate fonts as part of render_css
  3. Enqueue all recorded fonts

If cache is valid -

  1. Enqueue all recorded fonts

@@ -0,0 +1 @@
.test-style-grow-only{flex:2;}.test-style-grow-shrink{flex:1 2;}.test-style-basis-only{flex:0 1 100px;} No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is it ok?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I assume so, as it corresponds to the prior tests/phpunit/elementor/modules/atomic-widgets/styles/__snapshots__/Test_Atomic_Styles__test_parse_atomic_widget_styles__append_css_of_styles_with_flex_partial_values__1.txt, but with one difference due to the test structure (without the .elementor prefix)

@ronros-elementor ronros-elementor merged commit 1b99458 into elementor:main Jul 14, 2025
55 of 57 checks passed
github-merge-queue bot pushed a commit that referenced this pull request Nov 17, 2025
…es [ED-21536] (#33455)

- Moved cache invalidation to occur from within the
`Atomic_Styles_Manager`, instead of directly invalidating each caching
flag from its corresponding "styles provider" class.
- Changed the atomic styles manager's API a bit, to not use the
`$style_key` argument, which is essentially just an `implode` of the
`$cache_keys` array - instead will only use the `$cache_keys`.
- Added back an accidentally removed tests file (removed at
[ED-19458](#31784))

[ED-19458]:
https://elementor.atlassian.net/browse/ED-19458?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
<!--start_gitstream_placeholder-->
### ✨ PR Description
Purpose: Refactor style registration and cache invalidation system to
improve CSS file management and deletion of invalidated styles.
Main changes:
- Replaced string keys with path arrays for better hierarchy
organization of style definitions
- Added file deletion mechanism when invalidating cached styles via new
clear_styles method
- Implemented get_node method in Cache_Validity to traverse cache
structure for targeted invalidation

_Generated by LinearB AI and added by gitStream._
<sub>AI-generated content may contain inaccuracies. Please verify before
using.
💡 **Tip:** You can customize your AI Description using **Guidelines**
[Learn
how](https://docs.gitstream.cm/automation-actions/#describe-changes)</sub>
<!--end_gitstream_placeholder-->

---------

Co-authored-by: ElementorBot <48412871+elementorbot@users.noreply.github.com>
Co-authored-by: Omer Israeli <94297319+Omerisra6@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants