Changeset 213446 in webkit
- Timestamp:
- Mar 6, 2017, 4:19:43 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r213443 r213446 1 2017-03-06 Antti Koivisto <antti@apple.com> 2 3 Allow render tree building before loading stylesheet elements 4 https://bugs.webkit.org/show_bug.cgi?id=169079 5 6 Reviewed by Andreas Kling. 7 8 Ensure that style is synchronized after adding a stylesheet dynamically by doing an additional test. 9 Otherwise the class/attr invalidation test may as we don't know about the new stylesheet yet. 10 This is functionally fine (future synchronization would invalidate the style) but messes up the test 11 trying to verify class/attr change invalidation specifically. 12 13 * fast/css/style-invalidation-attribute-change-descendants-expected.txt: 14 * fast/css/style-invalidation-attribute-change-descendants.html: 15 * fast/css/style-invalidation-class-change-descendants-expected.txt: 16 * fast/css/style-invalidation-class-change-descendants.html: 17 1 18 2017-03-05 Carlos Garcia Campos <cgarcia@igalia.com> 2 19 -
trunk/LayoutTests/fast/css/style-invalidation-attribute-change-descendants-expected.txt
r202104 r213446 171 171 PASS hasExpectedStyle is true 172 172 Inserting stylesheet '[myattr3] target { color:rgb(12, 0, 0); }' 173 PASS testStyleChangeType("root", "NoStyleChange") || testStyleChangeType("root", "InlineStyleChange") is true 174 PASS testStyleChangeType("target", "NoStyleChange") is true 175 PASS testStyleChangeType("inert", "NoStyleChange") is true 176 PASS hasExpectedStyle is true 173 177 Setting attribute 'myattr3' value '' 174 178 PASS testStyleChangeType("root", "NoStyleChange") || testStyleChangeType("root", "InlineStyleChange") is true -
trunk/LayoutTests/fast/css/style-invalidation-attribute-change-descendants.html
r202104 r213446 277 277 document.head.appendChild(dynamicSheet); 278 278 279 testStyleInvalidation("NoStyleChange"); 280 checkStyle(11); 281 279 282 setAttribute('myattr3', ''); 280 283 testStyleInvalidation("InlineStyleChange"); -
trunk/LayoutTests/fast/css/style-invalidation-class-change-descendants-expected.txt
r202104 r213446 74 74 PASS hasExpectedStyle is true 75 75 Inserting stylesheet 'root.dynamicStyle target { color:rgb(6, 6, 6); }' 76 PASS testStyleChangeType("root", "NoStyleChange") || testStyleChangeType("root", "InlineStyleChange") is true 77 PASS testStyleChangeType("target", "NoStyleChange") is true 78 PASS testStyleChangeType("inert", "NoStyleChange") is true 79 PASS hasExpectedStyle is true 76 80 Adding class dynamicStyle 77 81 PASS testStyleChangeType("root", "NoStyleChange") || testStyleChangeType("root", "InlineStyleChange") is true -
trunk/LayoutTests/fast/css/style-invalidation-class-change-descendants.html
r202104 r213446 168 168 removeClass('dynamicStyle'); 169 169 testStyleInvalidation("NoStyleChange"); 170 checkStyle(0) 170 checkStyle(0); 171 171 172 172 var dynamicSheet = document.createElement("style"); … … 174 174 debug("Inserting stylesheet '" + dynamicSheet.innerHTML + "'"); 175 175 document.head.appendChild(dynamicSheet); 176 177 testStyleInvalidation("NoStyleChange"); 178 checkStyle(0); 176 179 177 180 addClass('dynamicStyle'); -
trunk/Source/WebCore/ChangeLog
r213445 r213446 1 2017-03-06 Antti Koivisto <antti@apple.com> 2 3 Allow render tree building before loading stylesheet elements 4 https://bugs.webkit.org/show_bug.cgi?id=169079 5 <rdar://problem/30865709> 6 7 Reviewed by Andreas Kling. 8 9 Currently we don't resolve style or construct renderers if there are any pending 10 stylesheet loads. This patch enables style and renderer constuction up to the 11 first encountered loading style element. 12 13 This is a step toward allowing incremental rendering for in-body stylesheets. 14 15 * dom/Document.cpp: 16 (WebCore::Document::needsStyleRecalc): 17 18 Ensure scrolling to anchor eventually happens. 19 20 * dom/Document.h: 21 (WebCore::Document::isIgnoringPendingStylesheets): 22 * dom/InlineStyleSheetOwner.cpp: 23 (WebCore::InlineStyleSheetOwner::createSheet): 24 (WebCore::InlineStyleSheetOwner::sheetLoaded): 25 (WebCore::InlineStyleSheetOwner::startLoadingDynamicSheet): 26 * dom/ProcessingInstruction.cpp: 27 (WebCore::ProcessingInstruction::checkStyleSheet): 28 (WebCore::ProcessingInstruction::sheetLoaded): 29 (WebCore::ProcessingInstruction::removedFrom): 30 * html/HTMLLinkElement.cpp: 31 (WebCore::HTMLLinkElement::addPendingSheet): 32 (WebCore::HTMLLinkElement::removePendingSheet): 33 * style/StyleScope.cpp: 34 (WebCore::Style::Scope::addPendingSheet): 35 (WebCore::Style::Scope::removePendingSheet): 36 37 Track pending sheet nodes in a map so we can test if a given node has a pending sheet. 38 This is also more robust in general. 39 40 (WebCore::Style::Scope::hasProcessingInstructionWithPendingSheet): 41 (WebCore::Style::Scope::updateActiveStyleSheets): 42 * style/StyleScope.h: 43 (WebCore::Style::Scope::hasPendingSheet): 44 (WebCore::Style::Scope::hasPendingSheets): 45 (WebCore::Style::Scope::addPendingSheet): Deleted. 46 * style/StyleTreeResolver.cpp: 47 (WebCore::Style::TreeResolver::styleForElement): 48 49 Instead of global test for placeholder construction check the status of the pending sheet flag. 50 51 (WebCore::Style::hasLoadingStylesheet): 52 (WebCore::Style::TreeResolver::resolveComposedTree): 53 54 Set a flag when encountering a pending top level sheet during DOM traversal. 55 56 (WebCore::Style::TreeResolver::resolve): 57 * style/StyleTreeResolver.h: 58 * svg/graphics/SVGImage.cpp: 59 (WebCore::SVGImage::dataChanged): 60 61 Ensure SVG images have layout before getting the size. 62 1 63 2017-03-06 Vanessa Chipirrás Navalón <vchipirras@igalia.com> 2 64 -
trunk/Source/WebCore/dom/Document.cpp
r213355 r213446 1855 1855 return false; 1856 1856 1857 return m_pendingStyleRecalcShouldForce || childNeedsStyleRecalc() || styleScope().hasPendingUpdate(); 1857 if (m_pendingStyleRecalcShouldForce) 1858 return true; 1859 1860 if (childNeedsStyleRecalc()) 1861 return true; 1862 1863 if (styleScope().hasPendingUpdate()) 1864 return true; 1865 1866 // Ensure this happens eventually as it is currently in resolveStyle. This can be removed if the code moves. 1867 if (m_gotoAnchorNeededAfterStylesheetsLoad && !styleScope().hasPendingSheets()) 1868 return true; 1869 1870 return false; 1858 1871 } 1859 1872 -
trunk/Source/WebCore/dom/Document.h
r213266 r213446 485 485 486 486 WEBCORE_EXPORT bool haveStylesheetsLoaded() const; 487 bool isIgnoringPendingStylesheets() const { return m_ignorePendingStylesheets; } 487 488 488 489 WEBCORE_EXPORT StyleSheetList& styleSheets(); -
trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp
r211591 r213446 158 158 if (m_sheet) { 159 159 if (m_sheet->isLoading() && m_styleScope) 160 m_styleScope->removePendingSheet( );160 m_styleScope->removePendingSheet(element); 161 161 clearSheet(); 162 162 } … … 179 179 180 180 if (m_styleScope) 181 m_styleScope->addPendingSheet( );181 m_styleScope->addPendingSheet(element); 182 182 183 183 auto cacheKey = makeInlineStyleSheetCacheKey(text, element); … … 229 229 } 230 230 231 bool InlineStyleSheetOwner::sheetLoaded(Element& )231 bool InlineStyleSheetOwner::sheetLoaded(Element& element) 232 232 { 233 233 if (isLoading()) … … 235 235 236 236 if (m_styleScope) 237 m_styleScope->removePendingSheet( );237 m_styleScope->removePendingSheet(element); 238 238 239 239 return true; 240 240 } 241 241 242 void InlineStyleSheetOwner::startLoadingDynamicSheet(Element& )242 void InlineStyleSheetOwner::startLoadingDynamicSheet(Element& element) 243 243 { 244 244 if (m_styleScope) 245 m_styleScope->addPendingSheet( );245 m_styleScope->addPendingSheet(element); 246 246 } 247 247 -
trunk/Source/WebCore/dom/ProcessingInstruction.cpp
r211591 r213446 130 130 } 131 131 132 if (m_loading) { 133 m_loading = false; 134 document().styleScope().removePendingSheet(*this); 135 } 136 132 137 String url = document().completeURL(href).string(); 133 138 if (!dispatchBeforeLoadEvent(url)) … … 135 140 136 141 m_loading = true; 137 document().styleScope().addPendingSheet( );142 document().styleScope().addPendingSheet(*this); 138 143 139 144 #if ENABLE(XSLT) … … 155 160 // The request may have been denied if (for example) the stylesheet is local and the document is remote. 156 161 m_loading = false; 157 document().styleScope().removePendingSheet( );162 document().styleScope().removePendingSheet(*this); 158 163 #if ENABLE(XSLT) 159 164 if (m_isXSL) … … 177 182 { 178 183 if (!isLoading()) { 179 document().styleScope().removePendingSheet( );184 document().styleScope().removePendingSheet(*this); 180 185 #if ENABLE(XSLT) 181 186 if (m_isXSL) … … 277 282 if (m_loading) { 278 283 m_loading = false; 279 document().styleScope().removePendingSheet( );284 document().styleScope().removePendingSheet(*this); 280 285 } 281 286 -
trunk/Source/WebCore/html/HTMLLinkElement.cpp
r212614 r213446 552 552 return; 553 553 ASSERT(m_styleScope); 554 m_styleScope->addPendingSheet( );554 m_styleScope->addPendingSheet(*this); 555 555 } 556 556 … … 570 570 } 571 571 572 m_styleScope->removePendingSheet( );572 m_styleScope->removePendingSheet(*this); 573 573 } 574 574 -
trunk/Source/WebCore/style/StyleScope.cpp
r212828 r213446 73 73 Scope::~Scope() 74 74 { 75 ASSERT(m_nodesWithPendingSheets.isEmpty()); 75 76 } 76 77 … … 172 173 } 173 174 175 void Scope::addPendingSheet(const Node& node) 176 { 177 ASSERT(!m_nodesWithPendingSheets.contains(&node)); 178 179 m_nodesWithPendingSheets.add(&node); 180 } 181 174 182 // This method is called whenever a top-level stylesheet has finished loading. 175 void Scope::removePendingSheet() 176 { 177 // Make sure we knew this sheet was pending, and that our count isn't out of sync. 178 ASSERT(m_pendingStyleSheetCount > 0); 179 180 m_pendingStyleSheetCount--; 181 if (m_pendingStyleSheetCount) 183 void Scope::removePendingSheet(const Node& node) 184 { 185 ASSERT(m_nodesWithPendingSheets.contains(&node)); 186 187 m_nodesWithPendingSheets.remove(&node); 188 if (!m_nodesWithPendingSheets.isEmpty()) 182 189 return; 183 190 … … 186 193 if (!m_shadowRoot) 187 194 m_document.didRemoveAllPendingStylesheet(); 195 } 196 197 bool Scope::hasProcessingInstructionWithPendingSheet() 198 { 199 ASSERT(!m_shadowRoot); 200 201 for (auto* child = m_document.firstChild(); child; child = child->nextSibling()) { 202 if (is<Element>(*child)) 203 return false; 204 if (m_nodesWithPendingSheets.contains(child)) { 205 ASSERT(is<ProcessingInstruction>(*child)); 206 return true; 207 } 208 } 209 return false; 188 210 } 189 211 … … 395 417 // Don't bother updating, since we haven't loaded all our style info yet 396 418 // and haven't calculated the style resolver for the first time. 397 if (!m_shadowRoot && !m_didUpdateActiveStyleSheets && m_pendingStyleSheetCount) {419 if (!m_shadowRoot && !m_didUpdateActiveStyleSheets && hasPendingSheets()) { 398 420 clearResolver(); 399 421 return; -
trunk/Source/WebCore/style/StyleScope.h
r212828 r213446 32 32 #include <wtf/FastMalloc.h> 33 33 #include <wtf/HashMap.h> 34 #include <wtf/HashSet.h> 34 35 #include <wtf/ListHashSet.h> 35 36 #include <wtf/RefPtr.h> … … 82 83 void setSelectedStylesheetSetName(const String&); 83 84 84 void addPendingSheet() { m_pendingStyleSheetCount++; } 85 void removePendingSheet(); 86 87 bool hasPendingSheets() const { return m_pendingStyleSheetCount > 0; } 85 void addPendingSheet(const Node&); 86 void removePendingSheet(const Node&); 87 bool hasPendingSheet(const Node& node) const { return m_nodesWithPendingSheets.contains(&node); } 88 bool hasProcessingInstructionWithPendingSheet(); 89 bool hasPendingSheets() const { return !m_nodesWithPendingSheets.isEmpty(); } 88 90 89 91 bool usesStyleBasedEditability() { return m_usesStyleBasedEditability; } … … 142 144 Vector<RefPtr<CSSStyleSheet>> m_activeStyleSheets; 143 145 146 144 147 Timer m_pendingUpdateTimer; 145 148 146 149 mutable std::unique_ptr<HashSet<const CSSStyleSheet*>> m_weakCopyOfActiveStyleSheetListForFastLookup; 147 150 148 // Track the number ofcurrently loading top-level stylesheets needed for rendering.151 // Track the currently loading top-level stylesheets needed for rendering. 149 152 // Sheets loaded using the @import directive are not included in this count. 150 153 // We use this count of pending sheets to detect when we can begin attaching 151 154 // elements and when it is safe to execute scripts. 152 int m_pendingStyleSheetCount { 0 }; 155 HashSet<const Node*> m_nodesWithPendingSheets; 156 153 157 bool m_didUpdateActiveStyleSheets { false }; 154 158 -
trunk/Source/WebCore/style/StyleTreeResolver.cpp
r213266 r213446 127 127 std::unique_ptr<RenderStyle> TreeResolver::styleForElement(Element& element, const RenderStyle& inheritedStyle) 128 128 { 129 if ( !m_document.haveStylesheetsLoaded() && !element.renderer()) {129 if (m_didSeePendingStylesheet && !element.renderer() && !m_document.isIgnoringPendingStylesheets()) { 130 130 m_document.setHasNodesWithPlaceholderStyle(); 131 131 return makePlaceholderStyle(m_document); … … 360 360 } 361 361 362 static bool hasLoadingStylesheet(const Style::Scope& styleScope, const Element& element, bool checkDescendants) 363 { 364 if (!styleScope.hasPendingSheets()) 365 return false; 366 if (styleScope.hasPendingSheet(element)) 367 return true; 368 if (!checkDescendants) 369 return false; 370 for (auto& descendant : descendantsOfType<Element>(element)) { 371 if (styleScope.hasPendingSheet(descendant)) 372 return true; 373 }; 374 return false; 375 } 376 362 377 void TreeResolver::resolveComposedTree() 363 378 { … … 439 454 440 455 bool shouldIterateChildren = style && (element.childNeedsStyleRecalc() || change != NoChange); 456 457 if (!m_didSeePendingStylesheet) 458 m_didSeePendingStylesheet = hasLoadingStylesheet(m_document.styleScope(), element, !shouldIterateChildren); 459 441 460 if (!shouldIterateChildren) { 442 461 it.traverseNextSkippingChildren(); … … 463 482 if (!documentElement->childNeedsStyleRecalc() && !documentElement->needsStyleRecalc()) 464 483 return nullptr; 484 485 m_didSeePendingStylesheet = m_document.styleScope().hasProcessingInstructionWithPendingSheet(); 465 486 466 487 m_update = std::make_unique<Update>(m_document); -
trunk/Source/WebCore/style/StyleTreeResolver.h
r213266 r213446 103 103 Vector<Ref<Scope>, 4> m_scopeStack; 104 104 Vector<Parent, 32> m_parentStack; 105 bool m_didSeePendingStylesheet { false }; 105 106 106 107 std::unique_ptr<Update> m_update; -
trunk/Source/WebCore/svg/graphics/SVGImage.cpp
r211161 r213446 452 452 loader.activeDocumentLoader()->writer().end(); 453 453 454 frame.document()->updateLayoutIgnorePendingStylesheets(); 455 454 456 // Set the intrinsic size before a container size is available. 455 457 m_intrinsicSize = containerSize();
Note:
See TracChangeset
for help on using the changeset viewer.