Title: [164618] trunk/Source/WebKit
Revision
164618
Author
[email protected]
Date
2014-02-24 17:41:39 -0800 (Mon, 24 Feb 2014)

Log Message

Add WebViewGroup
https://bugs.webkit.org/show_bug.cgi?id=129280

Reviewed by Dan Bernstein.

Source/WebKit:

Add new files.

* WebKit.xcodeproj/project.pbxproj:

Source/WebKit/mac:

This is a first step towards getting rid of page groups in WebCore. The idea is that
everything that is per page group in WebCore will be per page. In order to retain WebKit1 compatibility
WebViewGroup is going to take over more and more responsibility from WebCore::PageGroup.

* WebCoreSupport/WebViewGroup.h: Added.
* WebCoreSupport/WebViewGroup.mm: Added.
(webViewGroups):
(WebViewGroup::getOrCreate):
(WebViewGroup::WebViewGroup):
(WebViewGroup::~WebViewGroup):
(WebViewGroup::addWebView):
(WebViewGroup::removeWebView):
* WebView/WebView.mm:
(-[WebView initSimpleHTMLDocumentWithStyle:frame:preferences:groupName:]):
(-[WebView _close]):
(-[WebView setGroupName:]):
* WebView/WebViewData.h:
* WebView/WebViewData.mm:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (164617 => 164618)


--- trunk/Source/WebKit/ChangeLog	2014-02-25 00:40:06 UTC (rev 164617)
+++ trunk/Source/WebKit/ChangeLog	2014-02-25 01:41:39 UTC (rev 164618)
@@ -1,3 +1,14 @@
+2014-02-24  Anders Carlsson  <[email protected]>
+
+        Add WebViewGroup
+        https://bugs.webkit.org/show_bug.cgi?id=129280
+
+        Reviewed by Dan Bernstein.
+
+        Add new files.
+
+        * WebKit.xcodeproj/project.pbxproj:
+
 2014-02-24  Roger Fong  <[email protected]>
 
         [WinCairo] Disable ANGLE build on WinCairo port.

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (164617 => 164618)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2014-02-25 00:40:06 UTC (rev 164617)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2014-02-25 01:41:39 UTC (rev 164618)
@@ -58,6 +58,8 @@
 		1AAF5D0F0EDDE7A7008D883D /* WebKitPluginAgent.defs in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF588A0EDCCEA3008D883D /* WebKitPluginAgent.defs */; };
 		1AAF5FBF0EDE3A92008D883D /* WebHostedNetscapePluginView.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AAF5FBD0EDE3A92008D883D /* WebHostedNetscapePluginView.h */; };
 		1AAF5FC00EDE3A92008D883D /* WebHostedNetscapePluginView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5FBE0EDE3A92008D883D /* WebHostedNetscapePluginView.mm */; };
+		1AB1DAC118BC0232004B6A9F /* WebViewGroup.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AB1DABF18BC0232004B6A9F /* WebViewGroup.mm */; };
+		1AB1DAC218BC0232004B6A9F /* WebViewGroup.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AB1DAC018BC0232004B6A9F /* WebViewGroup.h */; };
 		1AEA66D40DC6B1FF003D12BF /* WebNetscapePluginEventHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEA66D20DC6B1FF003D12BF /* WebNetscapePluginEventHandler.h */; };
 		1AEA66D50DC6B1FF003D12BF /* WebNetscapePluginEventHandler.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AEA66D30DC6B1FF003D12BF /* WebNetscapePluginEventHandler.mm */; };
 		1AEA66D80DC6B209003D12BF /* WebNetscapePluginEventHandlerCarbon.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEA66D60DC6B209003D12BF /* WebNetscapePluginEventHandlerCarbon.h */; };
@@ -498,6 +500,8 @@
 		1AAF5D080EDDE71D008D883D /* WebKitPluginHostTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitPluginHostTypes.h; sourceTree = "<group>"; };
 		1AAF5FBD0EDE3A92008D883D /* WebHostedNetscapePluginView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebHostedNetscapePluginView.h; sourceTree = "<group>"; };
 		1AAF5FBE0EDE3A92008D883D /* WebHostedNetscapePluginView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebHostedNetscapePluginView.mm; sourceTree = "<group>"; };
+		1AB1DABF18BC0232004B6A9F /* WebViewGroup.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebViewGroup.mm; sourceTree = "<group>"; };
+		1AB1DAC018BC0232004B6A9F /* WebViewGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewGroup.h; sourceTree = "<group>"; };
 		1AEA66D20DC6B1FF003D12BF /* WebNetscapePluginEventHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebNetscapePluginEventHandler.h; sourceTree = "<group>"; };
 		1AEA66D30DC6B1FF003D12BF /* WebNetscapePluginEventHandler.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebNetscapePluginEventHandler.mm; sourceTree = "<group>"; };
 		1AEA66D60DC6B209003D12BF /* WebNetscapePluginEventHandlerCarbon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebNetscapePluginEventHandlerCarbon.h; sourceTree = "<group>"; };
@@ -1568,6 +1572,8 @@
 				A5DEFC0911D5331C00885273 /* WebSecurityOriginPrivate.h */,
 				93EB178E09F88D510091F8FF /* WebSystemInterface.h */,
 				93EB178C09F88D460091F8FF /* WebSystemInterface.mm */,
+				1AB1DAC018BC0232004B6A9F /* WebViewGroup.h */,
+				1AB1DABF18BC0232004B6A9F /* WebViewGroup.mm */,
 			);
 			name = WebCoreSupport;
 			path = mac/WebCoreSupport;
@@ -1704,6 +1710,7 @@
 				939810490824BF01008DF038 /* WebClipView.h in Headers */,
 				065AD5A30B0C32C7005A2B1D /* WebContextMenuClient.h in Headers */,
 				939810160824BF01008DF038 /* WebCoreStatistics.h in Headers */,
+				1AB1DAC218BC0232004B6A9F /* WebViewGroup.h in Headers */,
 				93E2A1A4123B0B3C009FE12A /* WebDashboardRegion.h in Headers */,
 				511F3FD70CECC88F00852565 /* WebDatabaseManagerClient.h in Headers */,
 				51AEDEF10CECF45700854328 /* WebDatabaseManagerInternal.h in Headers */,
@@ -2333,6 +2340,7 @@
 				A10C1D1D18202F9C0036883A /* WebDefaultResourceLoadDelegate.m in Sources */,
 				939810BE0824BF01008DF038 /* WebURLsWithTitles.m in Sources */,
 				C0C5B3EF1177A4A0002B0AEF /* WebUserContentURLPattern.mm in Sources */,
+				1AB1DAC118BC0232004B6A9F /* WebViewGroup.mm in Sources */,
 				939811070824BF01008DF038 /* WebView.mm in Sources */,
 				BC2E464E0FD8A96800A9D9DE /* WebViewData.mm in Sources */,
 			);

Modified: trunk/Source/WebKit/mac/ChangeLog (164617 => 164618)


--- trunk/Source/WebKit/mac/ChangeLog	2014-02-25 00:40:06 UTC (rev 164617)
+++ trunk/Source/WebKit/mac/ChangeLog	2014-02-25 01:41:39 UTC (rev 164618)
@@ -1,3 +1,29 @@
+2014-02-24  Anders Carlsson  <[email protected]>
+
+        Add WebViewGroup
+        https://bugs.webkit.org/show_bug.cgi?id=129280
+
+        Reviewed by Dan Bernstein.
+
+        This is a first step towards getting rid of page groups in WebCore. The idea is that
+        everything that is per page group in WebCore will be per page. In order to retain WebKit1 compatibility
+        WebViewGroup is going to take over more and more responsibility from WebCore::PageGroup.
+
+        * WebCoreSupport/WebViewGroup.h: Added.
+        * WebCoreSupport/WebViewGroup.mm: Added.
+        (webViewGroups):
+        (WebViewGroup::getOrCreate):
+        (WebViewGroup::WebViewGroup):
+        (WebViewGroup::~WebViewGroup):
+        (WebViewGroup::addWebView):
+        (WebViewGroup::removeWebView):
+        * WebView/WebView.mm:
+        (-[WebView initSimpleHTMLDocumentWithStyle:frame:preferences:groupName:]):
+        (-[WebView _close]):
+        (-[WebView setGroupName:]):
+        * WebView/WebViewData.h:
+        * WebView/WebViewData.mm:
+
 2014-02-24  Tamas Gergely  <[email protected]>
 
         Code cleanup: remove leftover ENABLE(WORKERS) macros and support.

Added: trunk/Source/WebKit/mac/WebCoreSupport/WebViewGroup.h (0 => 164618)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebViewGroup.h	                        (rev 0)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebViewGroup.h	2014-02-25 01:41:39 UTC (rev 164618)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <wtf/HashSet.h>
+#import <wtf/RefCounted.h>
+#import <wtf/PassRefPtr.h>
+#import <wtf/text/WTFString.h>
+
+@class WebView;
+
+class WebViewGroup : public RefCounted<WebViewGroup> {
+public:
+    static PassRefPtr<WebViewGroup> getOrCreate(const String& name);
+    ~WebViewGroup();
+
+    void addWebView(WebView *);
+    void removeWebView(WebView *);
+    
+private:
+    WebViewGroup(const String& name);
+
+    String m_name;
+    HashSet<WebView *> m_webViews;
+};

Added: trunk/Source/WebKit/mac/WebCoreSupport/WebViewGroup.mm (0 => 164618)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebViewGroup.mm	                        (rev 0)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebViewGroup.mm	2014-02-25 01:41:39 UTC (rev 164618)
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "WebViewGroup.h"
+
+#import "WebView.h"
+#import <wtf/HashMap.h>
+#import <wtf/NeverDestroyed.h>
+#import <wtf/RefPtr.h>
+#import <wtf/text/StringHash.h>
+
+// Any named groups will live for the lifetime of the process, thanks to the reference held by the RefPtr.
+static HashMap<String, RefPtr<WebViewGroup>>& webViewGroups()
+{
+    static NeverDestroyed<HashMap<String, RefPtr<WebViewGroup>>> webViewGroups;
+
+    return webViewGroups;
+}
+
+PassRefPtr<WebViewGroup> WebViewGroup::getOrCreate(const String& name)
+{
+    if (name.isEmpty())
+        return adoptRef(new WebViewGroup(String()));
+
+    auto& webViewGroup = webViewGroups().add(name, nullptr).iterator->value;
+    if (!webViewGroup)
+        webViewGroup = adoptRef(new WebViewGroup(name));
+
+    return webViewGroup;
+}
+
+WebViewGroup::WebViewGroup(const String& name)
+    : m_name(name)
+{
+}
+
+WebViewGroup::~WebViewGroup()
+{
+    ASSERT(m_name.isEmpty());
+    ASSERT(m_webViews.isEmpty());
+}
+
+void WebViewGroup::addWebView(WebView *webView)
+{
+    ASSERT(!m_webViews.contains(webView));
+
+    m_webViews.add(webView);
+}
+
+void WebViewGroup::removeWebView(WebView *webView)
+{
+    ASSERT(m_webViews.contains(webView));
+
+    m_webViews.remove(webView);
+}

Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (164617 => 164618)


--- trunk/Source/WebKit/mac/WebView/WebView.mm	2014-02-25 00:40:06 UTC (rev 164617)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm	2014-02-25 01:41:39 UTC (rev 164618)
@@ -104,6 +104,7 @@
 #import "WebUIDelegate.h"
 #import "WebUIDelegatePrivate.h"
 #import "WebUserMediaClient.h"
+#import "WebViewGroup.h"
 #import <CoreFoundation/CFSet.h>
 #import <Foundation/NSURLConnection.h>
 #import <_javascript_Core/APICast.h>
@@ -1181,7 +1182,7 @@
     // FIXME: this is a workaround for <rdar://problem/11820090> Quoted text changes in size when replying to certain email
     _private->page->settings().setMinimumFontSize([_private->preferences minimumFontSize]);
 
-    _private->page->setGroupName(groupName);
+    [self setGroupName:groupName];
 
 #if ENABLE(REMOTE_INSPECTOR)
     // Production installs always disallow debugging simple HTML documents.
@@ -1732,7 +1733,9 @@
     [self removeDragCaret];
 #endif
 
-    // Deleteing the WebCore::Page will clear the page cache so we call destroy on 
+    _private->group->removeWebView(self);
+
+    // Deleteing the WebCore::Page will clear the page cache so we call destroy on
     // all the plug-ins in the page cache to break any retain cycles.
     // See comment in HistoryItem::releaseAllPendingPageCaches() for more information.
     Page* page = _private->page;
@@ -6123,6 +6126,12 @@
 
 - (void)setGroupName:(NSString *)groupName
 {
+    if (_private->group)
+        _private->group->removeWebView(self);
+
+    _private->group = WebViewGroup::getOrCreate(groupName);
+    _private->group->addWebView(self);
+
     if (!_private->page)
         return;
     _private->page->setGroupName(groupName);

Modified: trunk/Source/WebKit/mac/WebView/WebViewData.h (164617 => 164618)


--- trunk/Source/WebKit/mac/WebView/WebViewData.h	2014-02-25 00:40:06 UTC (rev 164617)
+++ trunk/Source/WebKit/mac/WebView/WebViewData.h	2014-02-25 01:41:39 UTC (rev 164618)
@@ -81,6 +81,7 @@
 extern int pluginDatabaseClientCount;
 
 class LayerFlushController;
+class WebViewGroup;
 
 class WebViewLayerFlushScheduler : public WebCore::LayerFlushScheduler {
 public:
@@ -120,7 +121,8 @@
 @interface WebViewPrivate : NSObject {
 @public
     WebCore::Page* page;
-    
+    RefPtr<WebViewGroup> group;
+
     id UIDelegate;
     id UIDelegateForwarder;
     id resourceProgressDelegate;

Modified: trunk/Source/WebKit/mac/WebView/WebViewData.mm (164617 => 164618)


--- trunk/Source/WebKit/mac/WebView/WebViewData.mm	2014-02-25 00:40:06 UTC (rev 164617)
+++ trunk/Source/WebKit/mac/WebView/WebViewData.mm	2014-02-25 01:41:39 UTC (rev 164618)
@@ -31,6 +31,7 @@
 
 #import "WebKitLogging.h"
 #import "WebPreferenceKeysPrivate.h"
+#import "WebViewGroup.h"
 #import <WebCore/AlternativeTextUIController.h>
 #import <WebCore/WebCoreObjCExtras.h>
 #import <WebCore/HistoryItem.h>
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to