Changeset 181876 in webkit
- Timestamp:
- Mar 23, 2015, 3:34:53 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 18 edited
- 1 copied
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/http/tests/contentextensions/css-display-none-expected.txt (modified) (1 diff)
-
LayoutTests/http/tests/contentextensions/css-display-none.html (modified) (1 diff)
-
LayoutTests/http/tests/contentextensions/css-display-none.html.json (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/WebCore.xcodeproj/project.pbxproj (modified) (6 diffs)
-
Source/WebCore/contentextensions/ContentExtension.cpp (added)
-
Source/WebCore/contentextensions/ContentExtension.h (copied) (copied from trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.h ) (3 diffs)
-
Source/WebCore/contentextensions/ContentExtensionsBackend.cpp (modified) (4 diffs)
-
Source/WebCore/contentextensions/ContentExtensionsBackend.h (modified) (2 diffs)
-
Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp (modified) (1 diff)
-
Source/WebCore/dom/DocumentStyleSheetCollection.cpp (modified) (1 diff)
-
Source/WebCore/dom/DocumentStyleSheetCollection.h (modified) (3 diffs)
-
Source/WebCore/loader/DocumentLoader.cpp (modified) (3 diffs)
-
Source/WebCore/loader/DocumentLoader.h (modified) (3 diffs)
-
Source/WebCore/loader/cache/CachedResourceLoader.cpp (modified) (4 diffs)
-
Source/WebCore/loader/cache/CachedResourceRequest.cpp (modified) (1 diff)
-
Source/WebCore/loader/cache/CachedResourceRequest.h (modified) (3 diffs)
-
Source/WebCore/page/UserContentController.cpp (modified) (2 diffs)
-
Source/WebCore/page/UserContentController.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r181871 r181876 1 2015-03-23 Brady Eidson <beidson@apple.com> 2 3 Content extensions should apply css selectors 4 https://bugs.webkit.org/show_bug.cgi?id=142604 5 6 Reviewed by Alex Christensen. 7 8 * http/tests/contentextensions/css-display-none-expected.txt: 9 * http/tests/contentextensions/css-display-none.html: 10 * http/tests/contentextensions/css-display-none.html.json: 11 1 12 2015-03-23 Dean Jackson <dino@apple.com> 2 13 -
trunk/LayoutTests/http/tests/contentextensions/css-display-none-expected.txt
r181031 r181876 5 5 RenderBody {BODY} at (8,8) size 784x576 6 6 RenderBlock {P} at (0,0) size 784x18 7 RenderText {#text} at (0,0) size 492x188 text run at (0,0) width 492: "This text should not be visible once the css selector is applied (not done yet)."9 RenderBlock {P} at (0,34) size 784x1810 RenderText {#text} at (0,0) size 522x1811 text run at (0,0) width 522: "This text should also not be visible once the css selector is applied (not done yet)."12 RenderBlock {P} at (0,68) size 784x1813 7 RenderText {#text} at (0,0) size 173x18 14 8 text run at (0,0) width 173: "This text should be visible." -
trunk/LayoutTests/http/tests/contentextensions/css-display-none.html
r181031 r181876 1 <head> 2 <meta charset="UTF-8"></meta> 3 </head> 1 4 <body> 2 <p class="hidden">This text should not be visible once the css selector is applied (not done yet).</p> 3 <p class="hidden_Ž">This text should also not be visible once the css selector is applied (not done yet).</p> 5 <p class="hidden_global">This text should not be visible once the global css selector is applied.</p> 6 <p class="hidden">This text should not be visible once the particular css selector is applied.</p> 7 <p class="hidden_Ž">This text should not be visible once the particular css selector with non-ascii characters is applied.</p> 4 8 <p class="not_hidden">This text should be visible.</p> 5 9 </body> -
trunk/LayoutTests/http/tests/contentextensions/css-display-none.html.json
r181031 r181876 17 17 "url-filter": ".*css-display-none.html" 18 18 } 19 }, 20 { 21 "action": { 22 "type": "css-display-none", 23 "selector": ".hidden_global" 24 }, 25 "trigger": { 26 "url-filter": ".*" 27 } 19 28 } 20 29 ] -
trunk/Source/WebCore/ChangeLog
r181875 r181876 1 2015-03-23 Brady Eidson <beidson@apple.com> 2 3 Content extensions should apply css selectors 4 https://bugs.webkit.org/show_bug.cgi?id=142604 5 6 Reviewed by Alex Christensen. 7 8 Tests: http/tests/contentextensions/css-display-none.html 9 10 * WebCore.xcodeproj/project.pbxproj: 11 12 * contentextensions/ContentExtension.cpp: 13 (WebCore::ContentExtensions::ContentExtension::create): 14 (WebCore::ContentExtensions::ContentExtension::ContentExtension): 15 (WebCore::ContentExtensions::ContentExtension::globalDisplayNoneStyleSheet): 16 * contentextensions/ContentExtension.h: 17 (WebCore::ContentExtensions::ContentExtension::identifier): 18 (WebCore::ContentExtensions::ContentExtension::compiledExtension): 19 20 * contentextensions/ContentExtensionsBackend.cpp: 21 (WebCore::ContentExtensions::ContentExtensionsBackend::addContentExtension): 22 (WebCore::ContentExtensions::ContentExtensionsBackend::actionsForResourceLoad): 23 (WebCore::ContentExtensions::ContentExtensionsBackend::globalDisplayNoneStyleSheet): 24 * contentextensions/ContentExtensionsBackend.h: 25 26 * contentextensions/DFABytecodeInterpreter.cpp: 27 (WebCore::ContentExtensions::DFABytecodeInterpreter::interpret): 28 29 * dom/DocumentStyleSheetCollection.cpp: 30 (WebCore::DocumentStyleSheetCollection::maybeAddContentExtensionSheet): 31 * dom/DocumentStyleSheetCollection.h: 32 33 * loader/DocumentLoader.cpp: 34 (WebCore::DocumentLoader::commitData): 35 (WebCore::DocumentLoader::startLoadingMainResource): 36 (WebCore::DocumentLoader::addPendingContentExtensionSheet): 37 * loader/DocumentLoader.h: 38 39 * loader/cache/CachedResourceLoader.cpp: 40 (WebCore::CachedResourceLoader::requestResource): 41 42 * loader/cache/CachedResourceRequest.cpp: 43 (WebCore::CachedResourceRequest::setInitiator): 44 * loader/cache/CachedResourceRequest.h: 45 (WebCore::CachedResourceRequest::initiatingDocumentLoader): 46 47 * page/UserContentController.cpp: 48 (WebCore::UserContentController::globalDisplayNoneStyleSheet): 49 (WebCore::UserContentController::displayNoneCSSRule): 50 * page/UserContentController.h: 51 1 52 2015-03-23 Anders Carlsson <andersca@apple.com> 2 53 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r181781 r181876 1989 1989 51B07A441823248B00AA8D1A /* IDBPendingDeleteCall.h in Headers */ = {isa = PBXBuildFile; fileRef = 51B07A431823248B00AA8D1A /* IDBPendingDeleteCall.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1990 1990 51B2417B0D931F3F00E83F5C /* LegacyWebArchiveMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51B2417A0D931F3F00E83F5C /* LegacyWebArchiveMac.mm */; }; 1991 51B45D201AB8D1E200117CD2 /* ContentExtension.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51B45D1E1AB8D1E200117CD2 /* ContentExtension.cpp */; }; 1992 51B45D211AB8D1E200117CD2 /* ContentExtension.h in Headers */ = {isa = PBXBuildFile; fileRef = 51B45D1F1AB8D1E200117CD2 /* ContentExtension.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1991 1993 51B58FD4195A964D002990B0 /* PlatformGamepad.h in Headers */ = {isa = PBXBuildFile; fileRef = 515E5FEF195101470086CA5E /* PlatformGamepad.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1992 1994 51BE37E00DAEE00E001085FC /* StorageArea.h in Headers */ = {isa = PBXBuildFile; fileRef = 51BE37DE0DAEE00E001085FC /* StorageArea.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 6308 6310 E4E9B11D1814569C003ACCDF /* SimpleLineLayoutFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = E4E9B11C1814569C003ACCDF /* SimpleLineLayoutFunctions.h */; }; 6309 6311 E4F9EEF2156D9FFA00D23E7E /* StyleSheetContents.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4F9EEF0156D84C400D23E7E /* StyleSheetContents.cpp */; }; 6310 E4F9EEF3156DA00700D23E7E /* StyleSheetContents.h in Headers */ = {isa = PBXBuildFile; fileRef = E4F9EEF1156D84C400D23E7E /* StyleSheetContents.h */; };6312 E4F9EEF3156DA00700D23E7E /* StyleSheetContents.h in Headers */ = {isa = PBXBuildFile; fileRef = E4F9EEF1156D84C400D23E7E /* StyleSheetContents.h */; settings = {ATTRIBUTES = (Private, ); }; }; 6311 6313 E51A81DF17298D7700BFCA61 /* JSPerformance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E51A81DE17298D7700BFCA61 /* JSPerformance.cpp */; }; 6312 6314 E526AF3F1727F8F200E41781 /* Performance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E526AF3E1727F8F200E41781 /* Performance.cpp */; }; … … 9157 9159 51B07A431823248B00AA8D1A /* IDBPendingDeleteCall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBPendingDeleteCall.h; sourceTree = "<group>"; }; 9158 9160 51B2417A0D931F3F00E83F5C /* LegacyWebArchiveMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LegacyWebArchiveMac.mm; sourceTree = "<group>"; }; 9161 51B45D1E1AB8D1E200117CD2 /* ContentExtension.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContentExtension.cpp; sourceTree = "<group>"; }; 9162 51B45D1F1AB8D1E200117CD2 /* ContentExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContentExtension.h; sourceTree = "<group>"; }; 9159 9163 51BE37DE0DAEE00E001085FC /* StorageArea.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StorageArea.h; sourceTree = "<group>"; }; 9160 9164 51C0AA380F2AA10A001648C2 /* CachedFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedFrame.h; sourceTree = "<group>"; }; … … 15484 15488 isa = PBXGroup; 15485 15489 children = ( 15490 51B45D1E1AB8D1E200117CD2 /* ContentExtension.cpp */, 15491 51B45D1F1AB8D1E200117CD2 /* ContentExtension.h */, 15486 15492 7C93F3471AA6BA5E00A98BAB /* CompiledContentExtension.cpp */, 15487 15493 7C93F3481AA6BA5E00A98BAB /* CompiledContentExtension.h */, … … 25903 25909 97059978107D975200A50A7C /* PolicyCallback.h in Headers */, 25904 25910 9705997A107D975200A50A7C /* PolicyChecker.h in Headers */, 25911 51B45D211AB8D1E200117CD2 /* ContentExtension.h in Headers */, 25905 25912 FD45A957175D414C00C21EC8 /* PolygonShape.h in Headers */, 25906 25913 5174E20A10A1F44F00F95E6F /* PopStateEvent.h in Headers */, … … 30303 30310 97AABD2C14FA09D5007457AE /* WorkerThreadableWebSocketChannel.cpp in Sources */, 30304 30311 93309E23099E64920056E581 /* WrapContentsInDummySpanCommand.cpp in Sources */, 30312 51B45D201AB8D1E200117CD2 /* ContentExtension.cpp in Sources */, 30305 30313 A833C7CC0A2CF07400D57664 /* XLinkNames.cpp in Sources */, 30306 30314 00B9318713BA8DB30035A948 /* XMLDocumentParser.cpp in Sources */, -
trunk/Source/WebCore/contentextensions/ContentExtension.h
r181875 r181876 1 1 /* 2 * Copyright (C) 201 4, 2015 Apple Inc. All rights reserved.2 * Copyright (C) 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #ifndef ContentExtensionsBackend_h 27 #define ContentExtensionsBackend_h 26 #ifndef ContentExtension_h 27 #define ContentExtension_h 28 29 #include <wtf/Ref.h> 30 #include <wtf/RefCounted.h> 31 #include <wtf/RefPtr.h> 28 32 29 33 #if ENABLE(CONTENT_EXTENSIONS) 30 34 31 #include "ContentExtensionRule.h" 32 #include <wtf/HashMap.h> 33 #include <wtf/text/StringHash.h> 34 #include <wtf/text/WTFString.h> 35 #include "StyleSheetContents.h" 35 36 36 37 namespace WebCore { 37 38 class URL;39 40 struct ResourceLoadInfo;41 38 42 39 namespace ContentExtensions { … … 44 41 class CompiledContentExtension; 45 42 46 // The ContentExtensionsBackend is the internal model of all the content extensions. 47 // 48 // It provides two services: 49 // 1) It stores the rules for each content extension. 50 // 2) It provides APIs for the WebCore interfaces to use those rules efficiently. 51 class ContentExtensionsBackend { 43 class ContentExtension : public RefCounted<ContentExtension> { 52 44 public: 53 // - Rule management interface. This can be used by upper layer.45 static RefPtr<ContentExtension> create(const String& identifier, Ref<CompiledContentExtension>&&); 54 46 55 // Set a list of rules for a given name. If there were existing rules for the name, they are overriden. 56 // The identifier cannot be empty. 57 WEBCORE_EXPORT void addContentExtension(const String& identifier, RefPtr<CompiledContentExtension>); 58 WEBCORE_EXPORT void removeContentExtension(const String& identifier); 59 WEBCORE_EXPORT void removeAllContentExtensions(); 60 61 // - Internal WebCore Interface. 62 WEBCORE_EXPORT Vector<Action> actionsForResourceLoad(const ResourceLoadInfo&) const; 47 const String& identifier() const { return m_identifier; } 48 const CompiledContentExtension& compiledExtension() const { return m_compiledExtension.get(); } 49 StyleSheetContents* globalDisplayNoneStyleSheet(); 63 50 64 51 private: 65 HashMap<String, RefPtr<CompiledContentExtension>> m_contentExtensions; 52 ContentExtension(const String& identifier, Ref<CompiledContentExtension>&&); 53 54 String m_identifier; 55 Ref<CompiledContentExtension> m_compiledExtension; 56 RefPtr<StyleSheetContents> m_globalDisplayNoneStyleSheet; 57 bool m_parsedGlobalDisplayNoneStyleSheet; 66 58 }; 67 59 68 60 } // namespace ContentExtensions 69 70 61 } // namespace WebCore 71 62 72 63 #endif // ENABLE(CONTENT_EXTENSIONS) 73 74 #endif // ContentExtensionsBackend_h 64 #endif // ContentExtension_h -
trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp
r181754 r181876 30 30 31 31 #include "CompiledContentExtension.h" 32 #include "ContentExtension.h" 32 33 #include "DFABytecodeInterpreter.h" 33 34 #include "ResourceLoadInfo.h" … … 50 51 } 51 52 52 m_contentExtensions.set(identifier, compiledContentExtension); 53 RefPtr<ContentExtension> extension = ContentExtension::create(identifier, adoptRef(*compiledContentExtension.leakRef())); 54 m_contentExtensions.set(identifier, WTF::move(extension)); 53 55 } 54 56 … … 71 73 Vector<Action> finalActions; 72 74 ResourceFlags flags = resourceLoadInfo.getResourceFlags(); 73 for (auto& compiledContentExtension : m_contentExtensions) { 74 DFABytecodeInterpreter interpreter(compiledContentExtension.value->bytecode(), compiledContentExtension.value->bytecodeLength()); 75 for (auto& contentExtension : m_contentExtensions.values()) { 76 const CompiledContentExtension& compiledExtension = contentExtension->compiledExtension(); 77 DFABytecodeInterpreter interpreter(compiledExtension.bytecode(), compiledExtension.bytecodeLength()); 75 78 DFABytecodeInterpreter::Actions triggeredActions = interpreter.interpret(urlCString, flags); 76 79 77 const SerializedActionByte* actions = compiled ContentExtension.value->actions();78 const unsigned actionsLength = compiled ContentExtension.value->actionsLength();80 const SerializedActionByte* actions = compiledExtension.actions(); 81 const unsigned actionsLength = compiledExtension.actionsLength(); 79 82 80 83 if (!triggeredActions.isEmpty()) { … … 97 100 } 98 101 99 if (!sawIgnorePreviousRules )100 finalActions.append(Action(ActionType::CSSDisplayNoneStyleSheet, co mpiledContentExtension.key));102 if (!sawIgnorePreviousRules && contentExtension->globalDisplayNoneStyleSheet()) 103 finalActions.append(Action(ActionType::CSSDisplayNoneStyleSheet, contentExtension->identifier())); 101 104 } 102 105 } 103 106 return finalActions; 107 } 108 109 StyleSheetContents* ContentExtensionsBackend::globalDisplayNoneStyleSheet(const String& identifier) const 110 { 111 const auto& contentExtension = m_contentExtensions.get(identifier); 112 return contentExtension ? contentExtension->globalDisplayNoneStyleSheet() : nullptr; 104 113 } 105 114 -
trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.h
r181421 r181876 29 29 #if ENABLE(CONTENT_EXTENSIONS) 30 30 31 #include "ContentExtension.h" 31 32 #include "ContentExtensionRule.h" 32 33 #include <wtf/HashMap.h> … … 61 62 // - Internal WebCore Interface. 62 63 WEBCORE_EXPORT Vector<Action> actionsForResourceLoad(const ResourceLoadInfo&) const; 64 StyleSheetContents* globalDisplayNoneStyleSheet(const String& identifier) const; 63 65 64 66 private: 65 HashMap<String, RefPtr<Co mpiledContentExtension>> m_contentExtensions;67 HashMap<String, RefPtr<ContentExtension>> m_contentExtensions; 66 68 }; 67 69 -
trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp
r181726 r181876 63 63 Actions actions; 64 64 65 // FIXME: Skip the actions from the root once they are used through actionsFromDFARoot. Change AppendAction to AppendActions to make this faster. 66 65 while (static_cast<DFABytecodeInstruction>(m_bytecode[programCounter]) == DFABytecodeInstruction::AppendAction) 66 programCounter += instructionSizeWithArguments(DFABytecodeInstruction::AppendAction); 67 67 68 // This should always terminate if interpreting correctly compiled bytecode. 68 69 while (true) { -
trunk/Source/WebCore/dom/DocumentStyleSheetCollection.cpp
r180867 r181876 190 190 m_userStyleSheets.append(CSSStyleSheet::create(WTF::move(userSheet), &m_document)); 191 191 m_document.styleResolverChanged(RecalcStyleImmediately); 192 } 193 194 void DocumentStyleSheetCollection::maybeAddContentExtensionSheet(const String& identifier, StyleSheetContents& sheet) 195 { 196 ASSERT(sheet.isUserStyleSheet()); 197 198 if (m_contentExtensionSheets.contains(identifier)) 199 return; 200 201 Ref<CSSStyleSheet> cssSheet = CSSStyleSheet::create(sheet, &m_document); 202 m_contentExtensionSheets.set(identifier, &cssSheet.get()); 203 m_userStyleSheets.append(adoptRef(cssSheet.leakRef())); 192 204 } 193 205 -
trunk/Source/WebCore/dom/DocumentStyleSheetCollection.h
r180867 r181876 31 31 #include <memory> 32 32 #include <wtf/FastMalloc.h> 33 #include <wtf/HashMap.h> 33 34 #include <wtf/ListHashSet.h> 34 35 #include <wtf/RefPtr.h> … … 70 71 WEBCORE_EXPORT void addAuthorSheet(Ref<StyleSheetContents>&& authorSheet); 71 72 WEBCORE_EXPORT void addUserSheet(Ref<StyleSheetContents>&& userSheet); 73 void maybeAddContentExtensionSheet(const String& identifier, StyleSheetContents&); 72 74 73 75 enum UpdateFlag { NoUpdate = 0, OptimizedUpdate, FullUpdate }; … … 147 149 Vector<RefPtr<CSSStyleSheet>> m_userStyleSheets; 148 150 Vector<RefPtr<CSSStyleSheet>> m_authorStyleSheets; 151 HashMap<String, RefPtr<CSSStyleSheet>> m_contentExtensionSheets; 149 152 150 153 bool m_hadActiveLoadingStylesheet; -
trunk/Source/WebCore/loader/DocumentLoader.cpp
r181791 r181876 841 841 m_writer.setEncoding(encoding, userChosen); 842 842 } 843 844 #if ENABLE(CONTENT_EXTENSIONS) 845 DocumentStyleSheetCollection& styleSheetCollection = m_frame->document()->styleSheetCollection(); 846 847 for (auto& pendingStyleSheet : m_pendingNamedContentExtensionStyleSheets) 848 styleSheetCollection.maybeAddContentExtensionSheet(pendingStyleSheet.key, *pendingStyleSheet.value); 849 for (auto& pendingStyleSheet : m_pendingUnnamedContentExtensionStyleSheets) 850 styleSheetCollection.addUserSheet(*pendingStyleSheet); 851 852 m_pendingNamedContentExtensionStyleSheets.clear(); 853 m_pendingUnnamedContentExtensionStyleSheets.clear(); 854 #endif 855 843 856 ASSERT(m_frame->document()->parsing()); 844 857 m_writer.addData(bytes, length); … … 1442 1455 static NeverDestroyed<ResourceLoaderOptions> mainResourceLoadOptions(SendCallbacks, SniffContent, BufferData, AllowStoredCredentials, AskClientForAllCredentials, SkipSecurityCheck, UseDefaultOriginRestrictionsForType, IncludeCertificateInfo); 1443 1456 CachedResourceRequest cachedResourceRequest(request, mainResourceLoadOptions); 1457 cachedResourceRequest.setInitiator(*this); 1444 1458 m_mainResource = m_cachedResourceLoader->requestMainResource(cachedResourceRequest); 1445 1459 if (!m_mainResource) { … … 1573 1587 } 1574 1588 1589 #if ENABLE(CONTENT_EXTENSIONS) 1590 void DocumentLoader::addPendingContentExtensionSheet(const String& identifier, StyleSheetContents& sheet) 1591 { 1592 ASSERT(!m_gotFirstByte); 1593 m_pendingNamedContentExtensionStyleSheets.set(identifier, &sheet); 1594 } 1595 1596 void DocumentLoader::addPendingContentExtensionSheet(StyleSheetContents& sheet) 1597 { 1598 ASSERT(!m_gotFirstByte); 1599 m_pendingUnnamedContentExtensionStyleSheets.add(&sheet); 1600 } 1601 #endif 1602 1575 1603 } // namespace WebCore -
trunk/Source/WebCore/loader/DocumentLoader.h
r178859 r181876 42 42 #include "ResourceResponse.h" 43 43 #include "StringWithDirection.h" 44 #include "StyleSheetContents.h" 44 45 #include "SubstituteData.h" 45 46 #include "Timer.h" … … 268 269 #endif 269 270 271 #if ENABLE(CONTENT_EXTENSIONS) 272 void addPendingContentExtensionSheet(const String& identifier, StyleSheetContents&); 273 void addPendingContentExtensionSheet(StyleSheetContents&); 274 #endif 275 270 276 protected: 271 277 WEBCORE_EXPORT DocumentLoader(const ResourceRequest&, const SubstituteData&); … … 425 431 std::unique_ptr<QuickLookHandle> m_quickLookHandle; 426 432 #endif 433 434 #if ENABLE(CONTENT_EXTENSIONS) 435 HashMap<String, RefPtr<StyleSheetContents>> m_pendingNamedContentExtensionStyleSheets; 436 HashSet<RefPtr<StyleSheetContents>> m_pendingUnnamedContentExtensionStyleSheets; 437 #endif 438 427 439 }; 428 440 -
trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp
r181754 r181876 65 65 #include "SessionID.h" 66 66 #include "Settings.h" 67 #include "StyleSheetContents.h" 67 68 #include "UserContentController.h" 69 #include "UserStyleSheet.h" 68 70 #include <wtf/text/CString.h> 69 71 #include <wtf/text/WTFString.h> … … 507 509 508 510 #if ENABLE(CONTENT_EXTENSIONS) 509 Vector<ContentExtensions::Action> actions;510 511 511 URL mainDocumentURL; 512 512 if (frame() && frame()->mainFrame().document()) 513 513 mainDocumentURL = frame()->mainFrame().document()->url(); 514 514 515 515 ResourceLoadInfo resourceLoadInfo = { url, mainDocumentURL, toResourceType(type) }; 516 517 if (frame() && frame()->mainFrame().page() && frame()->mainFrame().page()->userContentController()) 518 actions = frame()->mainFrame().page()->userContentController()->actionsForResourceLoad(resourceLoadInfo); 519 516 517 Vector<ContentExtensions::Action> actions; 518 UserContentController* userContentController = nullptr; 519 if (frame() && frame()->mainFrame().page()) 520 userContentController = frame()->mainFrame().page()->userContentController(); 521 522 if (userContentController) 523 actions = userContentController->actionsForResourceLoad(resourceLoadInfo); 524 525 StringBuilder css; 520 526 bool willBlockLoad = false; 521 527 for (const auto& action : actions) { … … 528 534 break; 529 535 case ContentExtensions::ActionType::CSSDisplayNoneSelector: 530 // action.cssSelector() is the css to use here.531 // FIXME: That css selector should be used to apply display:none.536 css.append(action.stringArgument()); 537 css.append(UserContentController::displayNoneCSSRule()); 532 538 break; 533 case ContentExtensions::ActionType::CSSDisplayNoneStyleSheet: 534 // FIXME: Apply cached stylesheet here 539 case ContentExtensions::ActionType::CSSDisplayNoneStyleSheet: { 540 StyleSheetContents* styleSheetContents = userContentController->globalDisplayNoneStyleSheet(action.stringArgument()); 541 RELEASE_ASSERT(styleSheetContents); 542 543 if (type == CachedResource::MainResource && request.initiatingDocumentLoader()) 544 request.initiatingDocumentLoader()->addPendingContentExtensionSheet(action.stringArgument(), *styleSheetContents); 545 else if (m_document) 546 m_document->styleSheetCollection().maybeAddContentExtensionSheet(action.stringArgument(), *styleSheetContents); 547 535 548 break; 549 } 536 550 case ContentExtensions::ActionType::IgnorePreviousRules: 537 551 case ContentExtensions::ActionType::InvalidAction: … … 539 553 } 540 554 } 555 556 if (css.length()) { 557 Ref<StyleSheetContents> styleSheet = StyleSheetContents::create(); 558 styleSheet->setIsUserStyleSheet(true); 559 560 if (styleSheet->parseString(css.toString())) { 561 if (type == CachedResource::MainResource && request.initiatingDocumentLoader()) 562 request.initiatingDocumentLoader()->addPendingContentExtensionSheet(styleSheet); 563 else if (m_document) 564 m_document->styleSheetCollection().addUserSheet(WTF::move(styleSheet)); 565 } 566 } 567 541 568 if (willBlockLoad) 542 569 return nullptr; -
trunk/Source/WebCore/loader/cache/CachedResourceRequest.cpp
r179584 r181876 76 76 } 77 77 78 void CachedResourceRequest::setInitiator(DocumentLoader& documentLoader) 79 { 80 m_initiatingDocumentLoader = &documentLoader; 81 } 82 78 83 const AtomicString& CachedResourceRequest::initiatorName() const 79 84 { -
trunk/Source/WebCore/loader/cache/CachedResourceRequest.h
r179584 r181876 27 27 #define CachedResourceRequest_h 28 28 29 #include "DocumentLoader.h" 29 30 #include "Element.h" 30 31 #include "ResourceLoadPriority.h" … … 61 62 const AtomicString& initiatorName() const; 62 63 64 void setInitiator(DocumentLoader&); 65 DocumentLoader* initiatingDocumentLoader() const { return m_initiatingDocumentLoader.get(); } 66 63 67 private: 64 68 ResourceRequest m_resourceRequest; … … 70 74 RefPtr<Element> m_initiatorElement; 71 75 AtomicString m_initiatorName; 76 RefPtr<DocumentLoader> m_initiatingDocumentLoader; 72 77 }; 73 78 -
trunk/Source/WebCore/page/UserContentController.cpp
r181421 r181876 34 34 #include "UserScript.h" 35 35 #include "UserStyleSheet.h" 36 #include <wtf/NeverDestroyed.h> 36 37 37 38 #if ENABLE(USER_MESSAGE_HANDLERS) … … 213 214 } 214 215 216 StyleSheetContents* UserContentController::globalDisplayNoneStyleSheet(const String& identifier) const 217 { 218 if (!m_contentExtensionBackend) 219 return nullptr; 220 221 return m_contentExtensionBackend->globalDisplayNoneStyleSheet(identifier); 222 } 223 224 const String& UserContentController::displayNoneCSSRule() 225 { 226 static NeverDestroyed<const String> rule(ASCIILiteral("{display:none !important;}\n")); 227 return rule; 228 } 229 215 230 #endif 216 231 -
trunk/Source/WebCore/page/UserContentController.h
r181421 r181876 41 41 class DOMWrapperWorld; 42 42 class Page; 43 class StyleSheetContents; 43 44 class URL; 44 45 class UserScript; … … 88 89 89 90 Vector<ContentExtensions::Action> actionsForResourceLoad(const ResourceLoadInfo&); 91 StyleSheetContents* globalDisplayNoneStyleSheet(const String& identifier) const; 92 static const String& displayNoneCSSRule(); 90 93 #endif 91 94
Note:
See TracChangeset
for help on using the changeset viewer.