Skip to content

Conversation

@CGQAQ
Copy link
Contributor

@CGQAQ CGQAQ commented Jan 23, 2026

Summary

Fixes CSS !important precedence inconsistencies across cascade/inline style paths and improves first-paint style synchronization (Blink) to avoid stale getComputedStyle()/visual mismatches.

Key Changes

  • Align !important semantics across cascade merge (track origin + priority; preserve correct precedence between inline vs stylesheet).
  • Propagate inline-style importance through UICommand payloads + legacy parsing to keep native/Dart/bridge paths consistent.
  • Add Blink first-paint style sync barrier; defer style-related UI commands until first style update completes; sync newly-mounted subtrees.
  • Add ExecutingContext::MaybeCommitFirstPaintStyleSync and wire Document::UpdateStyle() to clear first-paint barriers after synchronous updates.
  • CSS additions/fixes: support text-wrap + white-space-collapse; ignore invalid gap values to preserve layout.
  • Refactors/perf/stability: rename ElementInlineStyleDeclarationElementCascadedStyleDeclaration; gate pseudo emissions; stabilize style export traversal; treat kLocalStyleChange as element-only; reorganize mutex locking in UICommandPackageRingBuffer::Reset.
  • Tests: new integration/unit tests for important precedence and first-paint barrier sync flush; snapshot updates where needed.

How To Test

  • node scripts/run_bridge_unit_test.js
  • cd webf && flutter test
  • cd integration_tests && npm run integration

@vercel
Copy link

vercel bot commented Jan 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
use-case Ready Ready Preview, Comment Jan 28, 2026 1:45pm
vue_usecase Ready Ready Preview, Comment Jan 28, 2026 1:45pm

Request Review

CGQAQ and others added 15 commits January 28, 2026 21:40
- Track origin (inline vs sheet) and priority during merges
- Propagate inline style importance through UICommand payloads and legacy parsing
- Add integration/unit tests for important precedence

# Conflicts:
#	webf/lib/src/dom/element.dart
RuleFeatureSet now tracks usage of ::before/::after/::first-letter alongside
::first-line.

StyleEngine consults the global RuleFeatureSet to avoid emitting/sending pseudo
style payloads for pseudos that cannot match, and stops descending into
display:none subtrees during subtree style recalculation.
StyleEngine::RecalcStyleForSubtree/RecalcStyleForElementOnly now:
- Guard against missing ExecutingContext.
- Cache StyleResolver/UICommandBuffer for the whole operation.
- Switch subtree traversal to an explicit stack and drop unused inherited-state plumbing.
- Detect display:none via CSSValueID when possible (fallback to string compare).
- Reuse pseudo selector atoms and avoid redundant UTF-8 conversions for href payloads.

integration_tests: wait a frame before asserting scrollWidth/clientWidth in translate transform spec.

Tests: not run (not requested)
StyleEngine::RecalcStyle previously handled any dirty element that wasn't\nkInlineIndependentStyleChange by calling RecalcStyleForSubtree(*element).\nThis made self-only invalidations (InvalidatesSelf), style="" mutations,\nand animation marks using kLocalStyleChange trigger expensive subtree rule\nmatching and UI style export.\n\nHandle kLocalStyleChange via RecalcStyleForElementOnly and clear the dirty\nbit. Subtree recalcs are now reserved for kSubtreeStyleChange and the\nexplicit ForceRecalcDescendants path.\n\nThis keeps semantics while avoiding unnecessary DOM subtree traversal.
…perties

- Introduced `text-wrap` shorthand and its longhands: `text-wrap-mode`, `text-wrap-style`.
- Added `white-space-collapse` as a `white-space` longhand.
- Enhanced rendering logic to resolve shorthand and longhand properties.
- Updated tests to validate property application and inheritance behaviors.
…adedStyleDeclaration`

- Updated all instances and references across `style_declaration.dart`, `element.dart`, and related tests.
- Enhances clarity by aligning the name with its broader styling role.
…-space-collapse`

- Verify `white-space` computation based on the `white-space-collapse` and `text-wrap` properties.
- Ensure correct parsing and shorthand/longhand behavior for `text-wrap`.
- Test layout effects of toggling `text-wrap-mode`.
- Validate behavior of `white-space-collapse: preserve-breaks` preserving line breaks in layout.
@CGQAQ CGQAQ force-pushed the fix/css-important-semantics branch from 332723e to 96d4ed8 Compare January 28, 2026 13:44
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.

3 participants