Changeset 130948 in webkit
- Timestamp:
- Oct 10, 2012, 1:28:30 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/CMakeLists.txt
r130316 r130948 153 153 Shared/SurfaceUpdateInfo.cpp 154 154 Shared/UpdateInfo.cpp 155 Shared/UserContentContainer.cpp 155 156 Shared/VisitedLinkTable.cpp 156 157 Shared/WebBackForwardListItem.cpp -
trunk/Source/WebKit2/ChangeLog
r130939 r130948 1 2012-10-04 Andy Estes <aestes@apple.com> 2 3 [WebKit2] Create an API for adding and removing user stylesheets from a page group 4 https://bugs.webkit.org/show_bug.cgi?id=98432 5 6 Reviewed by Sam Weinig. 7 8 This patch adds the following API to WKBrowsingContextGroup: 9 10 - (void)addUserStyleSheet:(NSString *)source baseURL:(NSURL *)baseURL whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist mainFrameOnly:(BOOL)mainFrameOnly; 11 - (void)removeAllUserStyleSheets; 12 13 Sheets added via this API are sent to all processes that contain a page 14 in the given page group. Sheets are also cached in the UI process in a 15 new object called UserContentContainer, which is a property of each 16 group's WebPageGroupData and is sent to new web processes during page 17 initialization. 18 19 This is less than ideal, since new pages added to a pre-existing 20 process / page group combination will send redundant user stylesheet 21 strings over the wire. To avoid this we'd have to keep track track of 22 the groups that currently exist in each process and only send user 23 content during page creation if it is the first time a process has seen 24 the page's group. I decided to not add this complexity for the time 25 being, but we might need to consider it if we find that the current 26 approach impacts performance for clients that heavily utilize user 27 content. 28 29 * Shared/API/c/WKArray.cpp: 30 (WKArrayCreateAdoptingValues): Add a WKArray creation function that 31 adopts the incoming WKTypeRefs rather than refing them. 32 * Shared/API/c/WKArray.h: 33 * Shared/API/c/WKBase.h: Move WKUserContentInjectedFrames out of 34 WKBundlePrivate.h so it can be used in WKPageGroup, too. 35 * Shared/API/c/cf/WKURLCF.cpp: 36 (WKURLCreateWithCFURL): Return 0 for null CFURLRefs instead of crashing 37 inside CFURLGetString(). 38 * Shared/ImmutableArray.cpp: 39 (WebKit::ImmutableArray::ImmutableArray): Add a tag to differentiate 40 between the adopting and refing ctors. 41 * Shared/ImmutableArray.h: 42 (WebKit::ImmutableArray::create): Call the refing ctor. 43 (WebKit::ImmutableArray::adopt): Call the adopting ctor. 44 * Shared/UserContentContainer.cpp: Added. 45 (UserContentItemMessageEncoder): Create a UserMessageEncoder for 46 serializing UserContentContainer::Item's APIObjects. 47 (WebKit::UserContentItemMessageEncoder::UserContentItemMessageEncoder): 48 (WebKit::UserContentItemMessageEncoder::encode): 49 (UserContentItemMessageDecoder): Create a UserMessageEncoder for 50 deserializing UserContentContainer::Item's APIObjects. 51 (WebKit::UserContentItemMessageDecoder::UserContentItemMessageDecoder): 52 (WebKit::UserContentItemMessageDecoder::decode): 53 (WebKit::UserContentContainer::Item::Item): 54 (WebKit::encodeStringArray): Add a helper function for encoding 55 ImmutableArrays of WebStrings. 56 (WebKit::UserContentContainer::Item::encode): Encode the item's 57 properties using UserContentItemMessageEncoder. 58 (WebKit::decodeStringArray): Add a helper function for decoding 59 ImmutableArrays of WebStrings. 60 (WebKit::UserContentContainer::Item::decode): Decode the item's 61 properties using UserContentItemMessageDecoder. 62 (WebKit::toStringVector): Add a helper function for converting an 63 ImmutableArray of WebStrings to a Vector of Strings. 64 (WebKit::UserContentContainer::Item::whitelist): Use toStringVector(). 65 (WebKit::UserContentContainer::Item::blacklist): Ditto. 66 (WebKit::UserContentContainer::encode): Encode the Vector of UserContentContainer::Items. 67 (WebKit::UserContentContainer::decode): Decode the Vector of UserContentContainer::Items. 68 * Shared/UserContentContainer.h: Added. 69 * Shared/WebPageGroupData.cpp: 70 (WebKit::WebPageGroupData::encode): Include userStyleSheets when encoding. 71 (WebKit::WebPageGroupData::decode): Include userStyleSheets when decoding. 72 * Shared/WebPageGroupData.h: 73 (WebPageGroupData): Add a UserContentContainer called userStyleSheets 74 to WebPageGroupData. 75 * UIProcess/API/C/WKPageGroup.cpp: Add the C SPI version of the Objective-C API. 76 (WKPageGroupAddUserStyleSheet): 77 (WKPageGroupRemoveAllUserStyleSheets): 78 * UIProcess/API/C/WKPageGroup.h: 79 * UIProcess/API/mac/WKBrowsingContextGroup.h: Add the Objective-C API. 80 * UIProcess/API/mac/WKBrowsingContextGroup.mm: 81 (createWKArray): Add a helper function that converts an NSArray of NSStrings to a WKArray of WKStrings. 82 (-[WKBrowsingContextGroup addUserStyleSheet:baseURL:whitelist:blacklist:mainFrameOnly:]): 83 Implement the Objective-C API in terms of the C SPI. 84 (-[WKBrowsingContextGroup removeAllUserStyleSheets]): Ditto. 85 * UIProcess/WebPageGroup.cpp: 86 (WebKit::WebPageGroup::addUserStyleSheet): Add the new sheet to the 87 group's WebPageGroupData, which ensures that the group's sheets are 88 sent to new web processes. 89 (WebKit::WebPageGroup::removeAllUserStyleSheets): Ditto for removal. 90 * UIProcess/WebPageGroup.h: 91 (WebKit::WebPageGroup::sendToAllProcessesInGroup): Add a helper message 92 that sends a message to all processes that have a page in the current 93 group. This is used to add new user sheets to already-initialized page 94 groups in the UI processes. 95 * WebKit2.xcodeproj/project.pbxproj: 96 * WebProcess/InjectedBundle/API/c/WKBundlePrivate.h: Moved 97 WKUserContentInjectedFrames from here to WKBase.h. 98 * WebProcess/WebPage/WebPageGroupProxy.cpp: 99 (WebKit::WebPageGroupProxy::WebPageGroupProxy): Add each sheet in the 100 WebPageGroupData to WebCore's page group. 101 (WebKit::WebPageGroupProxy::addUserStyleSheet): Add the sheet received 102 from the UI process to WebCore's page group. 103 (WebKit::WebPageGroupProxy::removeAllUserStyleSheets): Remove all 104 sheets from WebCore's page group. 105 * WebProcess/WebPage/WebPageGroupProxy.h: 106 * WebProcess/WebPage/WebPageGroupProxy.messages.in: Define 107 AddUserStyleSheet and RemoveAllUserStyleSheets, two messages sent from 108 the UI process to a web process's WebPageGroupProxy. 109 1 110 2012-10-10 Sam Weinig <sam@webkit.org> 2 111 -
trunk/Source/WebKit2/GNUmakefile.list.am
r130316 r130948 442 442 Source/WebKit2/Shared/UpdateInfo.cpp \ 443 443 Source/WebKit2/Shared/UpdateInfo.h \ 444 Source/WebKit2/Shared/UserContentContainer.cpp \ 445 Source/WebKit2/Shared/UserContentContainer.h \ 444 446 Source/WebKit2/Shared/VisitedLinkTable.cpp \ 445 447 Source/WebKit2/Shared/VisitedLinkTable.h \ -
trunk/Source/WebKit2/Shared/API/c/WKArray.cpp
r99239 r130948 43 43 } 44 44 45 WKArrayRef WKArrayCreateAdoptingValues(WKTypeRef* values, size_t numberOfValues) 46 { 47 RefPtr<ImmutableArray> array = ImmutableArray::adopt(reinterpret_cast<APIObject**>(const_cast<void**>(values)), numberOfValues); 48 return toAPI(array.release().leakRef()); 49 } 50 45 51 WKTypeRef WKArrayGetItemAtIndex(WKArrayRef arrayRef, size_t index) 46 52 { -
trunk/Source/WebKit2/Shared/API/c/WKArray.h
r95901 r130948 38 38 39 39 WK_EXPORT WKArrayRef WKArrayCreate(WKTypeRef* values, size_t numberOfValues); 40 WK_EXPORT WKArrayRef WKArrayCreateAdoptingValues(WKTypeRef* values, size_t numberOfValues); 40 41 41 42 WK_EXPORT WKTypeRef WKArrayGetItemAtIndex(WKArrayRef array, size_t index); -
trunk/Source/WebKit2/Shared/API/c/WKBase.h
r128553 r130948 79 79 typedef const struct OpaqueWKURLResponse* WKURLResponseRef; 80 80 typedef const struct OpaqueWKUserContentURLPattern* WKUserContentURLPatternRef; 81 82 enum WKUserContentInjectedFrames { 83 kWKInjectInAllFrames, 84 kWKInjectInTopFrameOnly 85 }; 86 typedef enum WKUserContentInjectedFrames WKUserContentInjectedFrames; 81 87 82 88 /* WebKit2 main API types */ -
trunk/Source/WebKit2/Shared/API/c/cf/WKURLCF.cpp
r95901 r130948 39 39 WKURLRef WKURLCreateWithCFURL(CFURLRef cfURL) 40 40 { 41 if (!cfURL) 42 return 0; 43 41 44 String urlString(CFURLGetString(cfURL)); 42 45 return toCopiedURLAPI(urlString); -
trunk/Source/WebKit2/Shared/ImmutableArray.cpp
r95901 r130948 33 33 } 34 34 35 ImmutableArray::ImmutableArray(AdoptTag, APIObject** entries, size_t size) 36 : m_entries(size) 37 { 38 for (size_t i = 0; i < size; ++i) 39 m_entries[i] = adoptRef(entries[i]); 40 } 41 35 42 ImmutableArray::ImmutableArray(APIObject** entries, size_t size) 36 43 : m_entries(size) -
trunk/Source/WebKit2/Shared/ImmutableArray.h
r95901 r130948 39 39 public: 40 40 static const Type APIType = TypeArray; 41 enum AdoptTag { Adopt }; 41 42 42 43 static PassRefPtr<ImmutableArray> create() … … 47 48 { 48 49 return adoptRef(new ImmutableArray(entries, size)); 50 } 51 static PassRefPtr<ImmutableArray> adopt(APIObject** entries, size_t size) 52 { 53 return adoptRef(new ImmutableArray(Adopt, entries, size)); 49 54 } 50 55 static PassRefPtr<ImmutableArray> adopt(Vector<RefPtr<APIObject> >& entries) … … 65 70 protected: 66 71 ImmutableArray(); 67 ImmutableArray(APIObject** entries, size_t size); 72 ImmutableArray(AdoptTag, APIObject** entries, size_t); 73 ImmutableArray(APIObject** entries, size_t); 68 74 ImmutableArray(Vector<RefPtr<APIObject> >& entries); 69 75 -
trunk/Source/WebKit2/Shared/WebPageGroupData.cpp
r95901 r130948 34 34 void WebPageGroupData::encode(CoreIPC::ArgumentEncoder* encoder) const 35 35 { 36 return encoder->encode(CoreIPC::In(identifer, pageGroupID, visibleToInjectedBundle, visibleToHistoryClient ));36 return encoder->encode(CoreIPC::In(identifer, pageGroupID, visibleToInjectedBundle, visibleToHistoryClient, userStyleSheets)); 37 37 } 38 38 39 39 bool WebPageGroupData::decode(CoreIPC::ArgumentDecoder* decoder, WebPageGroupData& data) 40 40 { 41 return decoder->decode(CoreIPC::Out(data.identifer, data.pageGroupID, data.visibleToInjectedBundle, data.visibleToHistoryClient ));41 return decoder->decode(CoreIPC::Out(data.identifer, data.pageGroupID, data.visibleToInjectedBundle, data.visibleToHistoryClient, data.userStyleSheets)); 42 42 } 43 43 -
trunk/Source/WebKit2/Shared/WebPageGroupData.h
r95901 r130948 27 27 #define WebPageGroupData_h 28 28 29 #include "UserContentContainer.h" 30 #include <wtf/Vector.h> 29 31 #include <wtf/text/WTFString.h> 30 32 … … 44 46 bool visibleToInjectedBundle; 45 47 bool visibleToHistoryClient; 48 UserContentContainer userStyleSheets; 46 49 }; 47 50 -
trunk/Source/WebKit2/Target.pri
r130207 r130948 97 97 Shared/SurfaceUpdateInfo.h \ 98 98 Shared/UpdateInfo.h \ 99 Shared/UserContentContainer.h \ 99 100 Shared/UserMessageCoders.h \ 100 101 Shared/VisitedLinkTable.h \ … … 453 454 Shared/SurfaceUpdateInfo.cpp \ 454 455 Shared/UpdateInfo.cpp \ 456 Shared/UserContentContainer.cpp \ 455 457 Shared/VisitedLinkTable.cpp \ 456 458 Shared/WebBackForwardListItem.cpp \ -
trunk/Source/WebKit2/UIProcess/API/C/WKPageGroup.cpp
r95901 r130948 58 58 return toAPI(toImpl(pageGroupRef)->preferences()); 59 59 } 60 61 void WKPageGroupAddUserStyleSheet(WKPageGroupRef pageGroupRef, WKStringRef sourceRef, WKURLRef baseURL, WKArrayRef whitelist, WKArrayRef blacklist, WKUserContentInjectedFrames injectedFrames) 62 { 63 if (!sourceRef) 64 return; 65 66 toImpl(pageGroupRef)->addUserStyleSheet(UserContentContainer::Item(toImpl(sourceRef), toImpl(baseURL), toImpl(whitelist), toImpl(blacklist), static_cast<UserContentContainer::Item::InjectedFrames>(injectedFrames), UserContentContainer::Item::TypeStylesheet)); 67 } 68 69 void WKPageGroupRemoveAllUserStyleSheets(WKPageGroupRef pageGroupRef) 70 { 71 toImpl(pageGroupRef)->removeAllUserStyleSheets(); 72 } -
trunk/Source/WebKit2/UIProcess/API/C/WKPageGroup.h
r95901 r130948 41 41 WK_EXPORT void WKPageGroupSetPreferences(WKPageGroupRef pageGroup, WKPreferencesRef preferences); 42 42 WK_EXPORT WKPreferencesRef WKPageGroupGetPreferences(WKPageGroupRef pageGroup); 43 44 WK_EXPORT void WKPageGroupAddUserStyleSheet(WKPageGroupRef pageGroup, WKStringRef source, WKURLRef baseURL, WKArrayRef whitelist, WKArrayRef blacklist, WKUserContentInjectedFrames); 45 WK_EXPORT void WKPageGroupRemoveAllUserStyleSheets(WKPageGroupRef pageGroup); 43 46 44 47 #ifdef __cplusplus -
trunk/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextGroup.h
r98622 r130948 37 37 - (id)initWithIdentifier:(NSString *)identifier; 38 38 39 /* User Content */ 40 41 - (void)addUserStyleSheet:(NSString *)source baseURL:(NSURL *)baseURL whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist mainFrameOnly:(BOOL)mainFrameOnly; 42 - (void)removeAllUserStyleSheets; 43 39 44 40 45 /* Settings */ -
trunk/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextGroup.mm
r102633 r130948 28 28 #import "WKBrowsingContextGroupInternal.h" 29 29 30 #import "WKArray.h" 30 31 #import "WKPageGroup.h" 31 32 #import "WKPreferences.h" 32 33 #import "WKRetainPtr.h" 33 34 #import "WKStringCF.h" 35 #import "WKURL.h" 36 #import "WKURLCF.h" 37 #import <wtf/Vector.h> 34 38 35 39 @interface WKBrowsingContextGroupData : NSObject { … … 82 86 } 83 87 88 static WKArrayRef createWKArray(NSArray *array) 89 { 90 NSUInteger count = [array count]; 91 if (count == 0) 92 return WKArrayRef(); 93 94 Vector<WKTypeRef> stringVector; 95 stringVector.reserveInitialCapacity(count); 96 for (NSUInteger i = 0; i < count; ++i) { 97 id entry = [array objectAtIndex:i]; 98 if ([entry isKindOfClass:[NSString class]]) 99 stringVector.uncheckedAppend(WKStringCreateWithCFString((CFStringRef)entry)); 100 101 } 102 103 return WKArrayCreateAdoptingValues(stringVector.data(), stringVector.size()); 104 } 105 106 -(void)addUserStyleSheet:(NSString *)source baseURL:(NSURL *)baseURL whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist mainFrameOnly:(BOOL)mainFrameOnly 107 { 108 if (!source) 109 return; 110 111 WKRetainPtr<WKStringRef> wkSource = adoptWK(WKStringCreateWithCFString((CFStringRef)source)); 112 WKRetainPtr<WKURLRef> wkBaseURL = adoptWK(WKURLCreateWithCFURL((CFURLRef)baseURL)); 113 WKRetainPtr<WKArrayRef> wkWhitelist = adoptWK(createWKArray(whitelist)); 114 WKRetainPtr<WKArrayRef> wkBlacklist = adoptWK(createWKArray(blacklist)); 115 WKUserContentInjectedFrames injectedFrames = mainFrameOnly ? kWKInjectInTopFrameOnly : kWKInjectInAllFrames; 116 117 WKPageGroupAddUserStyleSheet(self._pageGroupRef, wkSource.get(), wkBaseURL.get(), wkWhitelist.get(), wkBlacklist.get(), injectedFrames); 118 } 119 120 - (void)removeAllUserStyleSheets 121 { 122 WKPageGroupRemoveAllUserStyleSheets(self._pageGroupRef); 123 } 124 84 125 @end 85 126 -
trunk/Source/WebKit2/UIProcess/WebPageGroup.cpp
r95901 r130948 27 27 #include "WebPageGroup.h" 28 28 29 #include "WebPageGroupProxyMessages.h" 29 30 #include "WebPageProxy.h" 30 31 #include "WebPreferences.h" … … 128 129 } 129 130 } 131 132 void WebPageGroup::addUserStyleSheet(const UserContentContainer::Item& styleSheet) 133 { 134 m_data.userStyleSheets.addItem(styleSheet); 135 sendToAllProcessesInGroup(Messages::WebPageGroupProxy::AddUserStyleSheet(styleSheet), m_data.pageGroupID); 136 } 137 138 void WebPageGroup::removeAllUserStyleSheets() 139 { 140 m_data.userStyleSheets.removeAllItems(); 141 sendToAllProcessesInGroup(Messages::WebPageGroupProxy::RemoveAllUserStyleSheets(), m_data.pageGroupID); 142 } 130 143 131 144 } // namespace WebKit -
trunk/Source/WebKit2/UIProcess/WebPageGroup.h
r95901 r130948 29 29 #include "APIObject.h" 30 30 #include "WebPageGroupData.h" 31 #include "WebPageProxy.h" 32 #include "WebProcessProxy.h" 31 33 #include <wtf/Forward.h> 32 34 #include <wtf/HashSet.h> … … 57 59 WebPreferences* preferences() const; 58 60 void preferencesDidChange(); 61 62 void addUserStyleSheet(const UserContentContainer::Item& styleSheet); 63 void removeAllUserStyleSheets(); 59 64 60 65 private: … … 62 67 63 68 virtual Type type() const { return APIType; } 69 70 template<typename MessageType> void sendToAllProcessesInGroup(const MessageType&, uint64_t destinationID); 64 71 65 72 WebPageGroupData m_data; … … 67 74 HashSet<WebPageProxy*> m_pages; 68 75 }; 76 77 template<typename MessageType> inline void WebPageGroup::sendToAllProcessesInGroup(const MessageType& message, uint64_t destinationID) 78 { 79 HashSet<WebProcessProxy*> processesSeen; 80 for (HashSet<WebPageProxy*>::const_iterator it = m_pages.begin(), end = m_pages.end(); it != end; ++it) { 81 WebProcessProxy* webProcessProxy = (*it)->process(); 82 ASSERT(webProcessProxy); 83 if (!processesSeen.add(webProcessProxy).isNewEntry) 84 continue; 85 if (webProcessProxy->canSendMessage()) 86 webProcessProxy->send(message, destinationID); 87 } 88 } 69 89 70 90 } // namespace WebKit -
trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
r130316 r130948 251 251 1CA8B946127C882A00576C2B /* WebInspectorProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CA8B944127C882A00576C2B /* WebInspectorProxyMessages.h */; }; 252 252 1CA8B954127C891500576C2B /* WebInspectorMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C8E2DAD1278C5B200BC7BD0 /* WebInspectorMac.mm */; }; 253 29121707161CE7360057D451 /* UserContentContainer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29121705161CE7360057D451 /* UserContentContainer.cpp */; }; 254 29121708161CE7360057D451 /* UserContentContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = 29121706161CE7360057D451 /* UserContentContainer.h */; }; 253 255 296BD85D15019BC30071F424 /* StringUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 296BD85B15019BC30071F424 /* StringUtilities.h */; }; 254 256 296BD85E15019BC30071F424 /* StringUtilities.mm in Sources */ = {isa = PBXBuildFile; fileRef = 296BD85C15019BC30071F424 /* StringUtilities.mm */; }; … … 1312 1314 1CA8B943127C882A00576C2B /* WebInspectorProxyMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebInspectorProxyMessageReceiver.cpp; sourceTree = "<group>"; }; 1313 1315 1CA8B944127C882A00576C2B /* WebInspectorProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebInspectorProxyMessages.h; sourceTree = "<group>"; }; 1316 29121705161CE7360057D451 /* UserContentContainer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserContentContainer.cpp; sourceTree = "<group>"; }; 1317 29121706161CE7360057D451 /* UserContentContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserContentContainer.h; sourceTree = "<group>"; }; 1314 1318 296BD85B15019BC30071F424 /* StringUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringUtilities.h; sourceTree = "<group>"; }; 1315 1319 296BD85C15019BC30071F424 /* StringUtilities.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StringUtilities.mm; sourceTree = "<group>"; }; … … 1317 1321 29CD55A9128E294F00133C85 /* WKAccessibilityWebPageObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKAccessibilityWebPageObject.mm; sourceTree = "<group>"; }; 1318 1322 29D55DEE161BF8780031A2E3 /* WebPageGroupProxy.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebPageGroupProxy.messages.in; sourceTree = "<group>"; }; 1319 29D55DEF161BF9F10031A2E3 /* WebPageGroupProxyMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebPageGroupProxyMessageReceiver.cpp;path = WebPageGroupProxyMessageReceiver.cpp; sourceTree = "<group>"; };1320 29D55DF0161BF9F10031A2E3 /* WebPageGroupProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebPageGroupProxyMessages.h;path = WebPageGroupProxyMessages.h; sourceTree = "<group>"; };1323 29D55DEF161BF9F10031A2E3 /* WebPageGroupProxyMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebPageGroupProxyMessageReceiver.cpp; sourceTree = "<group>"; }; 1324 29D55DF0161BF9F10031A2E3 /* WebPageGroupProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPageGroupProxyMessages.h; sourceTree = "<group>"; }; 1321 1325 31099968146C71F50029DEB9 /* WebNotificationClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebNotificationClient.h; sourceTree = "<group>"; }; 1322 1326 31099971146C759B0029DEB9 /* WebNotificationClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebNotificationClient.cpp; sourceTree = "<group>"; }; … … 2555 2559 F6113E24126CE1820057D0A7 /* WebUserContentURLPattern.h */, 2556 2560 C0337DD0127A2980008FF4F4 /* WebWheelEvent.cpp */, 2561 29121705161CE7360057D451 /* UserContentContainer.cpp */, 2562 29121706161CE7360057D451 /* UserContentContainer.h */, 2557 2563 ); 2558 2564 path = Shared; … … 4339 4345 1A3EED12161A53D600AEB4F5 /* MessageReceiver.h in Headers */, 4340 4346 29D55DF2161BF9F10031A2E3 /* WebPageGroupProxyMessages.h in Headers */, 4347 29121708161CE7360057D451 /* UserContentContainer.h in Headers */, 4341 4348 ); 4342 4349 runOnlyForDeploymentPostprocessing = 0; … … 5198 5205 1A3EED0E161A535400AEB4F5 /* MessageReceiverMap.cpp in Sources */, 5199 5206 29D55DF1161BF9F10031A2E3 /* WebPageGroupProxyMessageReceiver.cpp in Sources */, 5207 29121707161CE7360057D451 /* UserContentContainer.cpp in Sources */, 5200 5208 ); 5201 5209 runOnlyForDeploymentPostprocessing = 0; -
trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h
r130662 r130948 42 42 }; 43 43 typedef enum WKUserScriptInjectionTime WKUserScriptInjectionTime; 44 45 enum WKUserContentInjectedFrames {46 kWKInjectInAllFrames,47 kWKInjectInTopFrameOnly48 };49 typedef enum WKUserContentInjectedFrames WKUserContentInjectedFrames;50 44 51 45 // TestRunner only SPI -
trunk/Source/WebKit2/WebProcess/WebPage/WebPageGroupProxy.cpp
r130316 r130948 29 29 #include "WebProcess.h" 30 30 #include "InjectedBundle.h" 31 #include <WebCore/DOMWrapperWorld.h> 32 #include <WebCore/PageGroup.h> 31 33 32 34 namespace WebKit { … … 50 52 didReceiveWebPageGroupProxyMessage(connection, messageID, arguments); 51 53 } 54 55 WebPageGroupProxy::WebPageGroupProxy(const WebPageGroupData& data) 56 : m_data(data) 57 , m_pageGroup(WebCore::PageGroup::pageGroup(m_data.identifer)) 58 { 59 for (size_t i = 0; i < data.userStyleSheets.size(); ++i) 60 addUserStyleSheet(data.userStyleSheets.at(i)); 61 } 52 62 53 void WebPageGroupProxy:: didReceiveWebPageGroupProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*)63 void WebPageGroupProxy::addUserStyleSheet(const UserContentContainer::Item& styleSheet) 54 64 { 55 // FIXME: Remove this once WebPageGroupProxy.messages.in contains messages, 56 // in which case this method will be auto-generated. 65 m_pageGroup->addUserStyleSheetToWorld(WebCore::mainThreadNormalWorld(), styleSheet.source(), styleSheet.url(), styleSheet.whitelist(), styleSheet.blacklist(), static_cast<WebCore::UserContentInjectedFrames>(styleSheet.injectedFrames())); 66 } 67 68 void WebPageGroupProxy::removeAllUserStyleSheets() 69 { 70 m_pageGroup->removeUserStyleSheetsFromWorld(WebCore::mainThreadNormalWorld()); 57 71 } 58 72 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPageGroupProxy.h
r130316 r130948 37 37 } 38 38 39 namespace WebCore { 40 class PageGroup; 41 } 42 39 43 namespace WebKit { 40 44 … … 54 58 55 59 private: 56 WebPageGroupProxy(const WebPageGroupData& data) 57 : m_data(data) 58 { 59 } 60 WebPageGroupProxy(const WebPageGroupData&); 60 61 61 62 virtual Type type() const { return APIType; } 62 63 63 64 void didReceiveWebPageGroupProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); 65 66 void addUserStyleSheet(const UserContentContainer::Item& styleSheet); 67 void removeAllUserStyleSheets(); 64 68 65 69 WebPageGroupData m_data; 70 WebCore::PageGroup* m_pageGroup; 66 71 }; 67 72 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPageGroupProxy.messages.in
r130316 r130948 22 22 23 23 messages -> WebPageGroupProxy { 24 AddUserStyleSheet(WebKit::UserContentContainer::Item styleSheet); 25 RemoveAllUserStyleSheets(); 24 26 } -
trunk/Source/WebKit2/win/WebKit2.vcproj
r130316 r130948 588 588 </File> 589 589 <File 590 RelativePath="..\Shared\UserContentContainer.cpp" 591 > 592 </File> 593 <File 594 RelativePath="..\Shared\UserContentContainer.h" 595 > 596 </File> 597 <File 590 598 RelativePath="..\Shared\UserMessageCoders.h" 591 599 > -
trunk/Tools/ChangeLog
r130924 r130948 1 2012-10-04 Andy Estes <aestes@apple.com> 2 3 [WebKit2] Create an API for adding and removing user stylesheets from a page group 4 https://bugs.webkit.org/show_bug.cgi?id=98432 5 6 Reviewed by Sam Weinig. 7 8 Add three new API tests: 9 10 - Test adding a user stylesheet before a page is created. This tests 11 the code path where the sheet is sent to the web process as part of 12 the new page's WebPageCreationParameters. 13 - Test adding a user stylesheet after a page is created. This tests the 14 code patch where the sheet is sent as a separate message to all 15 processes containing the given page group. 16 - Test removing all user stylesheets. 17 18 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 19 * TestWebKitAPI/Tests/WebKit2ObjC/UserContentTest.mm: Added. 20 (-[UserContentTestLoadDelegate initWithBlockToRunOnLoad:]): 21 (-[UserContentTestLoadDelegate browsingContextControllerDidFinishLoad:]): 22 (expectScriptValue): 23 * TestWebKitAPI/Tests/WebKit2ObjC/WKBrowsingContextGroupTest.mm: 24 1 25 2012-10-10 Dan Bernstein <mitz@apple.com> 2 26 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r129545 r130948 32 32 26F1B44415CA434F00D1E4BF /* AtomicString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F1B44215CA434F00D1E4BF /* AtomicString.cpp */; }; 33 33 26F1B44515CA434F00D1E4BF /* StringImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F1B44315CA434F00D1E4BF /* StringImpl.cpp */; }; 34 2943BE86161DFEB800999E3D /* UserContentTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2943BE84161DFEB800999E3D /* UserContentTest.mm */; }; 34 35 333B9CE21277F23100FEFCE3 /* PreventEmptyUserAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 333B9CE11277F23100FEFCE3 /* PreventEmptyUserAgent.cpp */; }; 35 36 33BE5AF5137B5A6C00705813 /* MouseMoveAfterCrash.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33BE5AF4137B5A6C00705813 /* MouseMoveAfterCrash.cpp */; }; … … 267 268 26F1B44215CA434F00D1E4BF /* AtomicString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AtomicString.cpp; path = WTF/AtomicString.cpp; sourceTree = "<group>"; }; 268 269 26F1B44315CA434F00D1E4BF /* StringImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringImpl.cpp; path = WTF/StringImpl.cpp; sourceTree = "<group>"; }; 270 2943BE84161DFEB800999E3D /* UserContentTest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = UserContentTest.mm; path = WebKit2ObjC/UserContentTest.mm; sourceTree = "<group>"; }; 269 271 333B9CE11277F23100FEFCE3 /* PreventEmptyUserAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PreventEmptyUserAgent.cpp; sourceTree = "<group>"; }; 270 272 33BE5AF4137B5A6C00705813 /* MouseMoveAfterCrash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MouseMoveAfterCrash.cpp; sourceTree = "<group>"; }; … … 530 532 isa = PBXGroup; 531 533 children = ( 534 2943BE84161DFEB800999E3D /* UserContentTest.mm */, 532 535 BC3C4C7D14587AA60025FB62 /* WKBrowsingContextGroupTest.mm */, 533 536 BC3C4C7014575B6A0025FB62 /* WKBrowsingContextLoadDelegateTest.mm */, … … 988 991 265AF55015D1E48A00B0CB4A /* WTFString.cpp in Sources */, 989 992 9318778915EEC57700A9CCE3 /* NewFirstVisuallyNonEmptyLayoutForImages.cpp in Sources */, 993 2943BE86161DFEB800999E3D /* UserContentTest.mm in Sources */, 990 994 ); 991 995 runOnlyForDeploymentPostprocessing = 0;
Note:
See TracChangeset
for help on using the changeset viewer.