Changeset 135773 in webkit
- Timestamp:
- Nov 26, 2012, 3:01:24 PM (12 years ago)
- Location:
- branches/chromium/1312
- Files:
-
- 10 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/chromium/1312/LayoutTests/ChangeLog
r133258 r135773 1 2012-11-18 Antti Koivisto <antti@apple.com> 2 3 REGRESSION(r129644): User StyleSheet not applying 4 https://bugs.webkit.org/show_bug.cgi?id=102110 5 6 Reviewed by Andreas Kling. 7 8 * inspector/timeline/timeline-script-tag-1-expected.txt: 9 10 Update the test result. The style invalidation log is slightly different. 11 12 * userscripts/user-stylesheet-invalidate-expected.txt: Added. 13 * userscripts/user-stylesheet-invalidate.html: Added. 14 1 15 2012-10-30 Keishi Hattori <keishi@webkit.org> 2 16 -
branches/chromium/1312/LayoutTests/inspector/timeline/timeline-script-tag-1-expected.txt
r128057 r135773 4 4 5 5 ParseHTML 6 ----> ScheduleStyleRecalculation 6 7 ----> InvalidateLayout 7 8 ParseHTML 9 ----> ScheduleStyleRecalculation 8 10 ----> EvaluateScript 9 11 --------> TimeStamp : SCRIPT TAG -
branches/chromium/1312/Source/WebCore/ChangeLog
r134985 r135773 1 2012-11-18 Antti Koivisto <antti@apple.com> 2 3 REGRESSION(r129644): User StyleSheet not applying 4 https://bugs.webkit.org/show_bug.cgi?id=102110 5 6 Reviewed by Andreas Kling. 7 8 Injected stylesheets added as UserStyleAuthorLevel fail to apply. r129644 implicitly assumed that 9 such things don't exists but on Chromium addUserStyleSheet() confusingly uses them. 10 11 The patch adds injected author stylesheets to DocumentStyleSheetCollection::activeStyleSheets(). 12 It also generally cleans up the code around injected and user stylesheets. 13 14 Tests: userscripts/user-script-and-stylesheet.html 15 userscripts/user-stylesheet-invalidate.html 16 17 * css/StyleResolver.cpp: 18 (WebCore::StyleResolver::StyleResolver): 19 (WebCore::StyleResolver::collectRulesFromUserStyleSheets): 20 (WebCore::collectCSSOMWrappers): 21 * css/StyleResolver.h: 22 (StyleResolver): 23 * dom/Document.cpp: 24 (WebCore::Document::setCompatibilityMode): 25 * dom/DocumentStyleSheetCollection.cpp: 26 (WebCore::DocumentStyleSheetCollection::DocumentStyleSheetCollection): 27 (WebCore::DocumentStyleSheetCollection::~DocumentStyleSheetCollection): 28 (WebCore::DocumentStyleSheetCollection::injectedUserStyleSheets): 29 (WebCore): 30 (WebCore::DocumentStyleSheetCollection::injectedAuthorStyleSheets): 31 (WebCore::DocumentStyleSheetCollection::updateInjectedStyleSheetCache): 32 (WebCore::DocumentStyleSheetCollection::invalidateInjectedStyleSheetCache): 33 (WebCore::DocumentStyleSheetCollection::addUserSheet): 34 (WebCore::DocumentStyleSheetCollection::updateActiveStyleSheets): 35 (WebCore::DocumentStyleSheetCollection::reportMemoryUsage): 36 * dom/DocumentStyleSheetCollection.h: 37 (WebCore::DocumentStyleSheetCollection::documentUserStyleSheets): 38 (DocumentStyleSheetCollection): 39 * page/PageGroup.cpp: 40 (WebCore::PageGroup::addUserStyleSheetToWorld): 41 (WebCore::PageGroup::removeUserStyleSheetFromWorld): 42 (WebCore::PageGroup::removeUserStyleSheetsFromWorld): 43 (WebCore::PageGroup::removeAllUserContent): 44 (WebCore::PageGroup::invalidatedInjectedStyleSheetCacheInAllFrames): 45 * page/PageGroup.h: 46 (PageGroup): 47 1 48 2012-11-14 Nico Weber <thakis@chromium.org> 2 49 -
branches/chromium/1312/Source/WebCore/css/StyleResolver.cpp
r132787 r135773 313 313 314 314 DocumentStyleSheetCollection* styleSheetCollection = document->styleSheetCollection(); 315 // FIXME: This sucks! The user sheet is reparsed every time!316 315 OwnPtr<RuleSet> tempUserStyle = RuleSet::create(); 317 316 if (CSSStyleSheet* pageUserSheet = styleSheetCollection->pageUserSheet()) 318 317 tempUserStyle->addRulesFromSheet(pageUserSheet->contents(), *m_medium, this); 319 addAuthorRulesAndCollectUserRulesFromSheets(styleSheetCollection->pageGroupUserSheets(), *tempUserStyle);320 addAuthorRulesAndCollectUserRulesFromSheets(styleSheetCollection->documentUserSheets(), *tempUserStyle);318 collectRulesFromUserStyleSheets(styleSheetCollection->injectedUserStyleSheets(), *tempUserStyle); 319 collectRulesFromUserStyleSheets(styleSheetCollection->documentUserStyleSheets(), *tempUserStyle); 321 320 if (tempUserStyle->m_ruleCount > 0 || tempUserStyle->m_pageRules.size() > 0) 322 321 m_userStyle = tempUserStyle.release(); … … 334 333 } 335 334 336 void StyleResolver::addAuthorRulesAndCollectUserRulesFromSheets(const Vector<RefPtr<CSSStyleSheet> >* userSheets, RuleSet& userStyle) 337 { 338 if (!userSheets) 339 return; 340 341 unsigned length = userSheets->size(); 342 for (unsigned i = 0; i < length; i++) { 343 StyleSheetContents* sheet = userSheets->at(i)->contents(); 344 if (sheet->isUserStyleSheet()) 345 userStyle.addRulesFromSheet(sheet, *m_medium, this); 346 else 347 m_authorStyle->addRulesFromSheet(sheet, *m_medium, this); 335 void StyleResolver::collectRulesFromUserStyleSheets(const Vector<RefPtr<CSSStyleSheet> >& userSheets, RuleSet& userStyle) 336 { 337 for (unsigned i = 0; i < userSheets.size(); ++i) { 338 ASSERT(userSheets[i]->contents()->isUserStyleSheet()); 339 userStyle.addRulesFromSheet(userSheets[i]->contents(), *m_medium, this); 348 340 } 349 341 } … … 2578 2570 } 2579 2571 2572 static void collectCSSOMWrappers(HashMap<StyleRule*, RefPtr<CSSStyleRule> >& wrapperMap, const Vector<RefPtr<CSSStyleSheet> >& sheets) 2573 { 2574 for (unsigned i = 0; i < sheets.size(); ++i) 2575 collectCSSOMWrappers(wrapperMap, sheets[i].get()); 2576 } 2577 2580 2578 static void collectCSSOMWrappers(HashMap<StyleRule*, RefPtr<CSSStyleRule> >& wrapperMap, DocumentStyleSheetCollection* styleSheetCollection) 2581 2579 { 2582 const Vector<RefPtr<CSSStyleSheet> >& styleSheets = styleSheetCollection->activeAuthorStyleSheets(); 2583 for (unsigned i = 0; i < styleSheets.size(); ++i) 2584 collectCSSOMWrappers(wrapperMap, styleSheets[i].get()); 2585 2580 collectCSSOMWrappers(wrapperMap, styleSheetCollection->activeAuthorStyleSheets()); 2586 2581 collectCSSOMWrappers(wrapperMap, styleSheetCollection->pageUserSheet()); 2587 { 2588 const Vector<RefPtr<CSSStyleSheet> >* pageGroupUserSheets = styleSheetCollection->pageGroupUserSheets(); 2589 if (pageGroupUserSheets) { 2590 for (size_t i = 0, size = pageGroupUserSheets->size(); i < size; ++i) 2591 collectCSSOMWrappers(wrapperMap, pageGroupUserSheets->at(i).get()); 2592 } 2593 } 2594 { 2595 const Vector<RefPtr<CSSStyleSheet> >* documentUserSheets = styleSheetCollection->documentUserSheets(); 2596 if (documentUserSheets) { 2597 for (size_t i = 0, size = documentUserSheets->size(); i < size; ++i) 2598 collectCSSOMWrappers(wrapperMap, documentUserSheets->at(i).get()); 2599 } 2600 } 2582 collectCSSOMWrappers(wrapperMap, styleSheetCollection->injectedUserStyleSheets()); 2583 collectCSSOMWrappers(wrapperMap, styleSheetCollection->documentUserStyleSheets()); 2601 2584 } 2602 2585 -
branches/chromium/1312/Source/WebCore/css/StyleResolver.h
r132808 r135773 421 421 static RenderStyle* s_styleNotYetAvailable; 422 422 423 void addAuthorRulesAndCollectUserRulesFromSheets(const Vector<RefPtr<CSSStyleSheet> >*, RuleSet& userStyle);423 void collectRulesFromUserStyleSheets(const Vector<RefPtr<CSSStyleSheet> >&, RuleSet& userStyle); 424 424 425 425 void cacheBorderAndBackground(); -
branches/chromium/1312/Source/WebCore/dom/Document.cpp
r135747 r135773 795 795 if (m_compatibilityModeLocked || mode == m_compatibilityMode) 796 796 return; 797 ASSERT(m_styleSheetCollection->activeAuthorStyleSheets().isEmpty());798 797 bool wasInQuirksMode = inQuirksMode(); 799 798 m_compatibilityMode = mode; … … 802 801 // All user stylesheets have to reparse using the different mode. 803 802 m_styleSheetCollection->clearPageUserSheet(); 804 m_styleSheetCollection-> clearPageGroupUserSheets();803 m_styleSheetCollection->invalidateInjectedStyleSheetCache(); 805 804 } 806 805 } -
branches/chromium/1312/Source/WebCore/dom/DocumentStyleSheetCollection.cpp
r132787 r135773 59 59 : m_document(document) 60 60 , m_pendingStylesheets(0) 61 , m_ pageGroupUserSheetCacheValid(false)61 , m_injectedStyleSheetCacheValid(false) 62 62 , m_hadActiveLoadingStylesheet(false) 63 63 , m_needsUpdateActiveStylesheetsOnStyleRecalc(false) … … 76 76 if (m_pageUserSheet) 77 77 m_pageUserSheet->clearOwnerNode(); 78 if (m_pageGroupUserSheets) { 79 for (size_t i = 0; i < m_pageGroupUserSheets->size(); ++i) 80 (*m_pageGroupUserSheets)[i]->clearOwnerNode(); 81 } 82 if (m_userSheets) { 83 for (size_t i = 0; i < m_userSheets->size(); ++i) 84 (*m_userSheets)[i]->clearOwnerNode(); 85 } 78 for (unsigned i = 0; i < m_injectedUserStyleSheets.size(); ++i) 79 m_injectedUserStyleSheets[i]->clearOwnerNode(); 80 for (unsigned i = 0; i < m_injectedAuthorStyleSheets.size(); ++i) 81 m_injectedAuthorStyleSheets[i]->clearOwnerNode(); 82 for (unsigned i = 0; i < m_userStyleSheets.size(); ++i) 83 m_userStyleSheets[i]->clearOwnerNode(); 86 84 } 87 85 … … 138 136 } 139 137 140 const Vector<RefPtr<CSSStyleSheet> >* DocumentStyleSheetCollection::pageGroupUserSheets() const 141 { 142 if (m_pageGroupUserSheetCacheValid) 143 return m_pageGroupUserSheets.get(); 144 145 m_pageGroupUserSheetCacheValid = true; 146 138 const Vector<RefPtr<CSSStyleSheet> >& DocumentStyleSheetCollection::injectedUserStyleSheets() const 139 { 140 updateInjectedStyleSheetCache(); 141 return m_injectedUserStyleSheets; 142 } 143 144 const Vector<RefPtr<CSSStyleSheet> >& DocumentStyleSheetCollection::injectedAuthorStyleSheets() const 145 { 146 updateInjectedStyleSheetCache(); 147 return m_injectedAuthorStyleSheets; 148 } 149 150 void DocumentStyleSheetCollection::updateInjectedStyleSheetCache() const 151 { 152 if (m_injectedStyleSheetCacheValid) 153 return; 154 m_injectedStyleSheetCacheValid = true; 155 m_injectedUserStyleSheets.clear(); 156 m_injectedAuthorStyleSheets.clear(); 157 147 158 Page* owningPage = m_document->page(); 148 159 if (!owningPage) 149 return 0;160 return; 150 161 151 162 const PageGroup& pageGroup = owningPage->group(); 152 163 const UserStyleSheetMap* sheetsMap = pageGroup.userStyleSheets(); 153 164 if (!sheetsMap) 154 return 0;165 return; 155 166 156 167 UserStyleSheetMap::const_iterator end = sheetsMap->end(); … … 164 175 continue; 165 176 RefPtr<CSSStyleSheet> groupSheet = CSSStyleSheet::createInline(const_cast<Document*>(m_document), sheet->url()); 166 if (!m_pageGroupUserSheets) 167 m_pageGroupUserSheets = adoptPtr(new Vector<RefPtr<CSSStyleSheet> >); 168 m_pageGroupUserSheets->append(groupSheet); 169 groupSheet->contents()->setIsUserStyleSheet(sheet->level() == UserStyleUserLevel); 177 bool isUserStyleSheet = sheet->level() == UserStyleUserLevel; 178 if (isUserStyleSheet) 179 m_injectedUserStyleSheets.append(groupSheet); 180 else 181 m_injectedAuthorStyleSheets.append(groupSheet); 182 groupSheet->contents()->setIsUserStyleSheet(isUserStyleSheet); 170 183 groupSheet->contents()->parseString(sheet->source()); 171 184 } 172 185 } 173 174 return m_pageGroupUserSheets.get(); 175 } 176 177 void DocumentStyleSheetCollection::clearPageGroupUserSheets() 178 { 179 m_pageGroupUserSheetCacheValid = false; 180 if (m_pageGroupUserSheets && m_pageGroupUserSheets->size()) { 181 m_pageGroupUserSheets->clear(); 182 m_document->styleResolverChanged(DeferRecalcStyle); 183 } 184 } 185 186 void DocumentStyleSheetCollection::updatePageGroupUserSheets() 187 { 188 clearPageGroupUserSheets(); 189 if (pageGroupUserSheets() && pageGroupUserSheets()->size()) 190 m_document->styleResolverChanged(RecalcStyleImmediately); 186 } 187 188 void DocumentStyleSheetCollection::invalidateInjectedStyleSheetCache() 189 { 190 m_injectedStyleSheetCacheValid = false; 191 m_document->styleResolverChanged(DeferRecalcStyle); 191 192 } 192 193 193 194 void DocumentStyleSheetCollection::addUserSheet(PassRefPtr<StyleSheetContents> userSheet) 194 195 { 195 if (!m_userSheets) 196 m_userSheets = adoptPtr(new Vector<RefPtr<CSSStyleSheet> >); 197 m_userSheets->append(CSSStyleSheet::create(userSheet, m_document)); 196 m_userStyleSheets.append(CSSStyleSheet::create(userSheet, m_document)); 198 197 m_document->styleResolverChanged(RecalcStyleImmediately); 199 198 } … … 456 455 457 456 Vector<RefPtr<CSSStyleSheet> > activeCSSStyleSheets; 457 activeCSSStyleSheets.append(injectedAuthorStyleSheets()); 458 458 collectActiveCSSStyleSheetsFromSeamlessParents(activeCSSStyleSheets, m_document); 459 459 filterEnabledCSSStyleSheets(activeCSSStyleSheets, activeStyleSheets); … … 491 491 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM); 492 492 info.addMember(m_pageUserSheet); 493 info.addMember(m_pageGroupUserSheets); 494 info.addMember(m_userSheets); 493 info.addMember(m_injectedUserStyleSheets); 494 info.addMember(m_injectedAuthorStyleSheets); 495 info.addMember(m_userStyleSheets); 495 496 info.addMember(m_activeAuthorStyleSheets); 496 497 info.addMember(m_styleSheetsForStyleSheetList); -
branches/chromium/1312/Source/WebCore/dom/DocumentStyleSheetCollection.h
r132787 r135773 56 56 57 57 CSSStyleSheet* pageUserSheet(); 58 const Vector<RefPtr<CSSStyleSheet> >* pageGroupUserSheets() const; 59 const Vector<RefPtr<CSSStyleSheet> >* documentUserSheets() const { return m_userSheets.get(); } 58 const Vector<RefPtr<CSSStyleSheet> >& documentUserStyleSheets() const { return m_userStyleSheets; } 59 const Vector<RefPtr<CSSStyleSheet> >& injectedUserStyleSheets() const; 60 const Vector<RefPtr<CSSStyleSheet> >& injectedAuthorStyleSheets() const; 60 61 61 62 void addStyleSheetCandidateNode(Node*, bool createdByParser); … … 64 65 void clearPageUserSheet(); 65 66 void updatePageUserSheet(); 66 void clearPageGroupUserSheets();67 void update PageGroupUserSheets();67 void invalidateInjectedStyleSheetCache(); 68 void updateInjectedStyleSheetCache() const; 68 69 69 70 void addUserSheet(PassRefPtr<StyleSheetContents> userSheet); … … 126 127 127 128 RefPtr<CSSStyleSheet> m_pageUserSheet; 128 mutable OwnPtr<Vector<RefPtr<CSSStyleSheet> > > m_pageGroupUserSheets; 129 OwnPtr<Vector<RefPtr<CSSStyleSheet> > > m_userSheets; 130 mutable bool m_pageGroupUserSheetCacheValid; 129 130 mutable Vector<RefPtr<CSSStyleSheet> > m_injectedUserStyleSheets; 131 mutable Vector<RefPtr<CSSStyleSheet> > m_injectedAuthorStyleSheets; 132 mutable bool m_injectedStyleSheetCacheValid; 133 134 Vector<RefPtr<CSSStyleSheet> > m_userStyleSheets; 131 135 132 136 bool m_hadActiveLoadingStylesheet; -
branches/chromium/1312/Source/WebCore/page/PageGroup.cpp
r132349 r135773 302 302 303 303 if (injectionTime == InjectInExistingDocuments) 304 resetUserStyleCacheInAllFrames();304 invalidatedInjectedStyleSheetCacheInAllFrames(); 305 305 } 306 306 … … 352 352 m_userStyleSheets->remove(it); 353 353 354 resetUserStyleCacheInAllFrames();354 invalidatedInjectedStyleSheetCacheInAllFrames(); 355 355 } 356 356 … … 382 382 m_userStyleSheets->remove(it); 383 383 384 resetUserStyleCacheInAllFrames();384 invalidatedInjectedStyleSheetCacheInAllFrames(); 385 385 } 386 386 … … 391 391 if (m_userStyleSheets) { 392 392 m_userStyleSheets.clear(); 393 resetUserStyleCacheInAllFrames();394 } 395 } 396 397 void PageGroup:: resetUserStyleCacheInAllFrames()393 invalidatedInjectedStyleSheetCacheInAllFrames(); 394 } 395 } 396 397 void PageGroup::invalidatedInjectedStyleSheetCacheInAllFrames() 398 398 { 399 399 // Clear our cached sheets and have them just reparse. … … 401 401 for (HashSet<Page*>::const_iterator it = m_pages.begin(); it != end; ++it) { 402 402 for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()->traverseNext()) 403 frame->document()->styleSheetCollection()-> updatePageGroupUserSheets();403 frame->document()->styleSheetCollection()->invalidateInjectedStyleSheetCache(); 404 404 } 405 405 } -
branches/chromium/1312/Source/WebCore/page/PageGroup.h
r132349 r135773 120 120 121 121 void addVisitedLink(LinkHash stringHash); 122 void resetUserStyleCacheInAllFrames();122 void invalidatedInjectedStyleSheetCacheInAllFrames(); 123 123 124 124 #if ENABLE(VIDEO_TRACK)
Note:
See TracChangeset
for help on using the changeset viewer.