Repository navigation
Commit 92b56ef
Re-evaluate @media when the viewport changes
The media context was built once, while generating the CSS tree, so a resize
never re-ran the cascade: a `@media (min-width: …)` rule picked at load time
stayed picked no matter how the window was resized afterwards.
HtmlContainerInt now keeps the html and base stylesheet it was given, and
PerformLayout re-runs the cascade when the current viewport would evaluate a
@media condition differently than the one the cascade was computed against.
The test is deliberately narrow, since PerformLayout runs on every layout pass.
CssData collects the distinct @media chains its rules are nested under while
indexing (one entry per @media block), and MediaOutcomeChanged evaluates just
those against the old and new device. A document with no viewport-dependent
@media - the common case - costs one empty loop, and a resize that stays within
the same breakpoint costs a handful of comparisons and rebuilds nothing.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>1 parent 2740184 commit 92b56ef
2 files changed
Lines changed: 88 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| 127 | + | |
127 | 128 | | |
128 | 129 | | |
129 | 130 | | |
130 | 131 | | |
131 | 132 | | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
132 | 183 | | |
133 | 184 | | |
134 | 185 | | |
| |||
180 | 231 | | |
181 | 232 | | |
182 | 233 | | |
| 234 | + | |
183 | 235 | | |
184 | 236 | | |
185 | 237 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
129 | 142 | | |
130 | 143 | | |
131 | 144 | | |
| |||
507 | 520 | | |
508 | 521 | | |
509 | 522 | | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
510 | 526 | | |
511 | 527 | | |
512 | 528 | | |
513 | 529 | | |
514 | 530 | | |
515 | 531 | | |
516 | 532 | | |
| 533 | + | |
517 | 534 | | |
518 | 535 | | |
519 | 536 | | |
| |||
522 | 539 | | |
523 | 540 | | |
524 | 541 | | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
525 | 559 | | |
526 | 560 | | |
527 | 561 | | |
| |||
632 | 666 | | |
633 | 667 | | |
634 | 668 | | |
| 669 | + | |
| 670 | + | |
635 | 671 | | |
636 | 672 | | |
637 | 673 | | |
| |||
0 commit comments