Sfoglia il codice sorgente

LibWeb: Invalidate styles after CSSImportRule loads

This replicates the behavior of StyleSheetList::add_sheet, making sure
the rules added by the imported style sheet are applied.
Simon Wanner 3 anni fa
parent
commit
1f9d76c7b8

+ 1 - 0
Base/res/html/misc/css-import-relative/css-import-4a.css

@@ -0,0 +1 @@
+@import "css-import-4b.css";

+ 1 - 0
Base/res/html/misc/css-import-relative/css-import-4b.css

@@ -0,0 +1 @@
+p.fourth { background-color: lime; }

+ 2 - 0
Base/res/html/misc/css-import.html

@@ -5,6 +5,7 @@
 @import "css-import-1.css";
 @import url("css-import-2.css");
 @import url(css-import-3.css);
+@import "css-import-relative/css-import-4a.css";
 </style>
 </head>
 <body>
@@ -12,6 +13,7 @@
     <p class="first">If this is green, <code>@import "string";</code> works!</p>
     <p class="second">If this is green, <code>@import url("string");</code> works!</p>
     <p class="third">If this is green, <code>@import url(unquoted-string);</code> works!</p>
+    <p class="fourth">If this is green, relative <code>@import</code> resolves correctly!</p>
 </div>
 </body>
 </html>

+ 3 - 0
Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp

@@ -84,6 +84,9 @@ void CSSImportRule::resource_did_load()
     }
 
     m_style_sheet = move(sheet);
+
+    m_document->style_sheets().bump_generation();
+    m_document->invalidate_style();
 }
 
 }