Changeset 197831 in webkit
- Timestamp:
- Mar 8, 2016, 8:39:49 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
-
ChangeLog (modified) (1 diff)
-
dom/ExtensionStyleSheets.cpp (modified) (1 diff)
-
page/CaptionUserPreferences.cpp (modified) (1 diff)
-
page/Page.cpp (modified) (3 diffs)
-
page/Page.h (modified) (3 diffs)
-
page/UserContentController.cpp (modified) (4 diffs)
-
page/UserContentController.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r197827 r197831 1 2016-03-08 Sam Weinig <sam@webkit.org> 2 3 Stop using the UserContentController for injecting the override style sheet from CaptionUserPreferences 4 https://bugs.webkit.org/show_bug.cgi?id=155211 5 6 Reviewed by Dan Bernstein. 7 8 The UserContentController is going to become read only from WebCore's perspective. The CaptionUserPreferences 9 was relying on being able to set a UserStyleSheet on it, but this was really unnecessary complexity. Simplify 10 things by storing the style sheet's source directly on the Page and teaching ExtensionStyleSheets about it 11 explicitly. 12 13 * dom/ExtensionStyleSheets.cpp: 14 (WebCore::ExtensionStyleSheets::updateInjectedStyleSheetCache): 15 If there is a captionUserPreferencesStyleSheet on the page, inject it. 16 17 * page/CaptionUserPreferences.cpp: 18 (WebCore::CaptionUserPreferences::updateCaptionStyleSheetOveride): 19 Greatly simplify the code. Now, all this does is set the style sheet on each page. 20 21 * page/Page.cpp: 22 (WebCore::Page::invalidateInjectedStyleSheetCacheInAllFrames): 23 Extract this out from UserContentController. 24 25 (WebCore::Page::setUserContentController): 26 Call the newly extracted invalidateInjectedStyleSheetCacheInAllFrames(). 27 28 (WebCore::Page::captionUserPreferencesStyleSheet): 29 (WebCore::Page::setCaptionUserPreferencesStyleSheet): 30 Add getter/setter. When setting, invalidate the style sheet cache. 31 32 * page/Page.h: 33 Add new members and functions. 34 35 * page/UserContentController.cpp: 36 (WebCore::UserContentController::addUserStyleSheet): 37 (WebCore::UserContentController::removeUserStyleSheet): 38 (WebCore::UserContentController::removeUserStyleSheets): 39 (WebCore::UserContentController::removeAllUserContent): 40 Switch to calling invalidateInjectedStyleSheetCacheInAllFramesInAllPages(). 41 42 (WebCore::UserContentController::invalidateInjectedStyleSheetCacheInAllFramesInAllPages): 43 Rename and implement in terms of Page::invalidateInjectedStyleSheetCacheInAllFrames(). 44 45 * page/UserContentController.h: 46 Rename function. 47 1 48 2016-03-08 Joseph Pecoraro <pecoraro@apple.com> 2 49 -
trunk/Source/WebCore/dom/ExtensionStyleSheets.cpp
r195088 r197831 118 118 return; 119 119 120 if (!owningPage->captionUserPreferencesStyleSheet().isEmpty()) { 121 // Identify our override style sheet with a unique URL - a new scheme and a UUID. 122 static NeverDestroyed<URL> captionsStyleSheetURL(ParsedURLString, "user-captions-override:01F6AF12-C3B0-4F70-AF5E-A3E00234DC23"); 123 124 RefPtr<CSSStyleSheet> sheet = CSSStyleSheet::createInline(const_cast<Document&>(m_document), captionsStyleSheetURL.get()); 125 m_injectedAuthorStyleSheets.append(sheet); 126 127 sheet->contents().setIsUserStyleSheet(false); 128 sheet->contents().parseString(owningPage->captionUserPreferencesStyleSheet()); 129 } 130 120 131 const auto* userContentController = owningPage->userContentController(); 121 132 if (!userContentController) -
trunk/Source/WebCore/page/CaptionUserPreferences.cpp
r196010 r197831 299 299 void CaptionUserPreferences::updateCaptionStyleSheetOveride() 300 300 { 301 // Identify our override style sheet with a unique URL - a new scheme and a UUID.302 static NeverDestroyed<URL> captionsStyleSheetURL(ParsedURLString, "user-captions-override:01F6AF12-C3B0-4F70-AF5E-A3E00234DC23");303 304 auto& pages = m_pageGroup.pages();305 for (auto& page : pages) {306 if (auto* pageUserContentController = page->userContentController())307 pageUserContentController->removeUserStyleSheet(mainThreadNormalWorld(), captionsStyleSheetURL);308 }309 310 301 String captionsOverrideStyleSheet = captionsStyleSheetOverride(); 311 if (captionsOverrideStyleSheet.isEmpty()) 312 return; 313 314 for (auto& page : pages) { 315 if (auto* pageUserContentController = page->userContentController()) { 316 auto userStyleSheet = std::make_unique<UserStyleSheet>(captionsOverrideStyleSheet, captionsStyleSheetURL, Vector<String>(), Vector<String>(), InjectInAllFrames, UserStyleAuthorLevel); 317 pageUserContentController->addUserStyleSheet(mainThreadNormalWorld(), WTFMove(userStyleSheet), InjectInExistingDocuments); 318 } 319 } 302 for (auto& page : m_pageGroup.pages()) 303 page->setCaptionUserPreferencesStyleSheet(captionsOverrideStyleSheet); 320 304 } 321 305 -
trunk/Source/WebCore/page/Page.cpp
r197728 r197831 1127 1127 } 1128 1128 1129 void Page::invalidateInjectedStyleSheetCacheInAllFrames() 1130 { 1131 for (Frame* frame = m_mainFrame.get(); frame; frame = frame->tree().traverseNext()) { 1132 Document* document = frame->document(); 1133 if (!document) 1134 continue; 1135 document->extensionStyleSheets().invalidateInjectedStyleSheetCache(); 1136 document->styleResolverChanged(DeferRecalcStyle); 1137 } 1138 } 1139 1129 1140 void Page::setDebugger(JSC::Debugger* debugger) 1130 1141 { … … 1819 1830 m_userContentController->addPage(*this); 1820 1831 1821 for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) { 1822 if (Document *document = frame->document()) { 1823 document->extensionStyleSheets().invalidateInjectedStyleSheetCache(); 1824 document->styleResolverChanged(DeferRecalcStyle); 1825 } 1826 } 1832 invalidateInjectedStyleSheetCacheInAllFrames(); 1827 1833 } 1828 1834 … … 2009 2015 } 2010 2016 2017 String Page::captionUserPreferencesStyleSheet() 2018 { 2019 return m_captionUserPreferencesStyleSheet; 2020 } 2021 2022 void Page::setCaptionUserPreferencesStyleSheet(const String& styleSheet) 2023 { 2024 if (m_captionUserPreferencesStyleSheet == styleSheet) 2025 return; 2026 2027 m_captionUserPreferencesStyleSheet = styleSheet; 2028 2029 invalidateInjectedStyleSheetCacheInAllFrames(); 2030 } 2031 2011 2032 } // namespace WebCore -
trunk/Source/WebCore/page/Page.h
r197728 r197831 358 358 WEBCORE_EXPORT void invalidateStylesForLink(LinkHash); 359 359 360 void invalidateInjectedStyleSheetCacheInAllFrames(); 361 360 362 StorageNamespace* sessionStorage(bool optionalCreate = true); 361 363 void setSessionStorage(RefPtr<StorageNamespace>&&); … … 510 512 bool isAlwaysOnLoggingAllowed() const; 511 513 514 String captionUserPreferencesStyleSheet(); 515 void setCaptionUserPreferencesStyleSheet(const String&); 516 512 517 private: 513 518 WEBCORE_EXPORT void initGroup(); … … 609 614 mutable bool m_didLoadUserStyleSheet; 610 615 mutable time_t m_userStyleSheetModificationTime; 616 617 String m_captionUserPreferencesStyleSheet; 611 618 612 619 std::unique_ptr<PageGroup> m_singlePageGroup; -
trunk/Source/WebCore/page/UserContentController.cpp
r194496 r197831 124 124 125 125 if (injectionTime == InjectInExistingDocuments) 126 invalidateInjectedStyleSheetCacheInAllFrames ();126 invalidateInjectedStyleSheetCacheInAllFramesInAllPages(); 127 127 } 128 128 … … 152 152 m_userStyleSheets->remove(it); 153 153 154 invalidateInjectedStyleSheetCacheInAllFrames ();154 invalidateInjectedStyleSheetCacheInAllFramesInAllPages(); 155 155 } 156 156 … … 163 163 return; 164 164 165 invalidateInjectedStyleSheetCacheInAllFrames ();165 invalidateInjectedStyleSheetCacheInAllFramesInAllPages(); 166 166 } 167 167 … … 250 250 if (m_userStyleSheets) { 251 251 m_userStyleSheets = nullptr; 252 invalidateInjectedStyleSheetCacheInAllFrames(); 253 } 254 } 255 256 void UserContentController::invalidateInjectedStyleSheetCacheInAllFrames() 257 { 258 for (auto& page : m_pages) { 259 for (Frame* frame = &page->mainFrame(); frame; frame = frame->tree().traverseNext()) { 260 frame->document()->extensionStyleSheets().invalidateInjectedStyleSheetCache(); 261 frame->document()->styleResolverChanged(DeferRecalcStyle); 262 } 263 } 252 invalidateInjectedStyleSheetCacheInAllFramesInAllPages(); 253 } 254 } 255 256 void UserContentController::invalidateInjectedStyleSheetCacheInAllFramesInAllPages() 257 { 258 for (auto& page : m_pages) 259 page->invalidateInjectedStyleSheetCacheInAllFrames(); 264 260 } 265 261 -
trunk/Source/WebCore/page/UserContentController.h
r191266 r197831 104 104 UserContentController(); 105 105 106 void invalidateInjectedStyleSheetCacheInAllFrames ();106 void invalidateInjectedStyleSheetCacheInAllFramesInAllPages(); 107 107 108 108 HashSet<Page*> m_pages;
Note:
See TracChangeset
for help on using the changeset viewer.