Diff
Modified: trunk/Source/WebKit2/ChangeLog (176848 => 176849)
--- trunk/Source/WebKit2/ChangeLog 2014-12-05 18:23:52 UTC (rev 176848)
+++ trunk/Source/WebKit2/ChangeLog 2014-12-05 18:30:14 UTC (rev 176849)
@@ -1,3 +1,25 @@
+2014-12-05 Sam Weinig <[email protected]>
+
+ WKBundleCSSStyleDeclarationRef needs to be a real API::Object
+ https://bugs.webkit.org/show_bug.cgi?id=139291
+
+ Reviewed by Dan Bernstein.
+
+ Change WKBundleCSSStyleDeclarationRef from being a WebCore::CSSStyleDeclaration, to
+ being a real API::Object. WKRetain and WKRelease require this.
+
+ * Shared/APIObject.h:
+ * WebKit2.xcodeproj/project.pbxproj:
+ * WebProcess/InjectedBundle/API/c/WKBundleAPICast.h:
+ * WebProcess/InjectedBundle/DOM/InjectedBundleCSSStyleDeclarationHandle.cpp: Added.
+ (WebKit::domHandleCache):
+ (WebKit::InjectedBundleCSSStyleDeclarationHandle::getOrCreate):
+ (WebKit::InjectedBundleCSSStyleDeclarationHandle::InjectedBundleCSSStyleDeclarationHandle):
+ (WebKit::InjectedBundleCSSStyleDeclarationHandle::~InjectedBundleCSSStyleDeclarationHandle):
+ * WebProcess/InjectedBundle/DOM/InjectedBundleCSSStyleDeclarationHandle.h: Added.
+ * WebProcess/InjectedBundle/InjectedBundlePageEditorClient.cpp:
+ (WebKit::InjectedBundlePageEditorClient::shouldApplyStyle):
+
2014-12-05 Anders Carlsson <[email protected]>
Oops, didn't mean to commit this.
Modified: trunk/Source/WebKit2/Shared/APIObject.h (176848 => 176849)
--- trunk/Source/WebKit2/Shared/APIObject.h 2014-12-05 18:23:52 UTC (rev 176848)
+++ trunk/Source/WebKit2/Shared/APIObject.h 2014-12-05 18:30:14 UTC (rev 176849)
@@ -141,6 +141,7 @@
Bundle,
BundleBackForwardList,
BundleBackForwardListItem,
+ BundleCSSStyleDeclarationHandle,
BundleDOMWindowExtension,
BundleFrame,
BundleHitTestResult,
Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (176848 => 176849)
--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2014-12-05 18:23:52 UTC (rev 176848)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2014-12-05 18:30:14 UTC (rev 176849)
@@ -252,6 +252,7 @@
1A4D664C18A3030E00D82E21 /* WKFrameInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A4D664A18A3030E00D82E21 /* WKFrameInfo.h */; settings = {ATTRIBUTES = (Public, ); }; };
1A4D664E18A3031B00D82E21 /* WKFrameInfoInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A4D664D18A3031B00D82E21 /* WKFrameInfoInternal.h */; };
1A50DB66110A3D57000D3FE5 /* WebProcess.app in Copy Files */ = {isa = PBXBuildFile; fileRef = 1A50DB1E110A3BDC000D3FE5 /* WebProcess.app */; };
+ 1A53C2A21A323004004E8C70 /* InjectedBundleCSSStyleDeclarationHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C4ED3261A3119D90079BD49 /* InjectedBundleCSSStyleDeclarationHandle.cpp */; };
1A5B1C501898606F004FCF9B /* WKNavigation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A5B1C4E1898606F004FCF9B /* WKNavigation.mm */; };
1A5B1C511898606F004FCF9B /* WKNavigation.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5B1C4F1898606F004FCF9B /* WKNavigation.h */; settings = {ATTRIBUTES = (Public, ); }; };
1A5B1C5418987EDF004FCF9B /* WebDocumentLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5B1C5218987EDF004FCF9B /* WebDocumentLoader.cpp */; };
@@ -1046,6 +1047,7 @@
7C387434172F5615001BD88A /* PageBanner.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C387433172F5615001BD88A /* PageBanner.cpp */; };
7C3F8C90173AF52D007B7F39 /* PluginInformation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C3F8C8E173AF52D007B7F39 /* PluginInformation.cpp */; };
7C3F8C91173AF52D007B7F39 /* PluginInformation.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C3F8C8F173AF52D007B7F39 /* PluginInformation.h */; };
+ 7C4ED3291A3119D90079BD49 /* InjectedBundleCSSStyleDeclarationHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C4ED3271A3119D90079BD49 /* InjectedBundleCSSStyleDeclarationHandle.h */; };
7C6D37FC172F555F009D2847 /* PageBannerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7C6D37FA172F555F009D2847 /* PageBannerMac.mm */; };
7C6E70FB18B2DC7A00F24E2E /* WebProcessCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7C6E70F918B2D4A000F24E2E /* WebProcessCocoa.mm */; };
7C85FD7C193415A8000177C4 /* WebPreferencesDefinitions.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C85FD7B193415A8000177C4 /* WebPreferencesDefinitions.h */; };
@@ -3119,6 +3121,8 @@
7C387433172F5615001BD88A /* PageBanner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageBanner.cpp; sourceTree = "<group>"; };
7C3F8C8E173AF52D007B7F39 /* PluginInformation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PluginInformation.cpp; sourceTree = "<group>"; };
7C3F8C8F173AF52D007B7F39 /* PluginInformation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginInformation.h; sourceTree = "<group>"; };
+ 7C4ED3261A3119D90079BD49 /* InjectedBundleCSSStyleDeclarationHandle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleCSSStyleDeclarationHandle.cpp; sourceTree = "<group>"; };
+ 7C4ED3271A3119D90079BD49 /* InjectedBundleCSSStyleDeclarationHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundleCSSStyleDeclarationHandle.h; sourceTree = "<group>"; };
7C6D37FA172F555F009D2847 /* PageBannerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PageBannerMac.mm; sourceTree = "<group>"; };
7C6E70F918B2D4A000F24E2E /* WebProcessCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebProcessCocoa.mm; sourceTree = "<group>"; };
7C85FD7B193415A8000177C4 /* WebPreferencesDefinitions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPreferencesDefinitions.h; sourceTree = "<group>"; };
@@ -6393,6 +6397,8 @@
BC4BEE96120A091700FBA0C7 /* DOM */ = {
isa = PBXGroup;
children = (
+ 7C4ED3261A3119D90079BD49 /* InjectedBundleCSSStyleDeclarationHandle.cpp */,
+ 7C4ED3271A3119D90079BD49 /* InjectedBundleCSSStyleDeclarationHandle.h */,
BC4BEEAA120A0A5F00FBA0C7 /* InjectedBundleNodeHandle.cpp */,
BC4BEEA9120A0A5E00FBA0C7 /* InjectedBundleNodeHandle.h */,
BC33E0D012408E8600360F3F /* InjectedBundleRangeHandle.cpp */,
@@ -7094,6 +7100,7 @@
1AF459321946559500F9D4A2 /* WKError.h in Headers */,
E19BDA8A193686A400B97F57 /* SandboxUtilities.h in Headers */,
1A7284471959ED100007BCE5 /* SessionStateConversion.h in Headers */,
+ 7C4ED3291A3119D90079BD49 /* InjectedBundleCSSStyleDeclarationHandle.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -9122,6 +9129,7 @@
0F3C725C196F605200AEDD0C /* WKInspectorHighlightView.mm in Sources */,
1F7506AF1859162800EC0FF7 /* WKWebProcessPlugInNodeHandle.mm in Sources */,
51217460164C20E30037A5C1 /* ShareableResource.cpp in Sources */,
+ 1A53C2A21A323004004E8C70 /* InjectedBundleCSSStyleDeclarationHandle.cpp in Sources */,
1A24BF3A120896A600FBB059 /* SharedMemoryMac.cpp in Sources */,
1A60224C18C16B9F00C3E8C9 /* VisitedLinkProviderMessageReceiver.cpp in Sources */,
5272B28A1406985D0096A5D0 /* StatisticsData.cpp in Sources */,
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h (176848 => 176849)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h 2014-12-05 18:23:52 UTC (rev 176848)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h 2014-12-05 18:30:14 UTC (rev 176849)
@@ -33,15 +33,12 @@
#include <WebCore/EditorInsertAction.h>
#include <WebCore/TextAffinity.h>
-namespace WebCore {
- class CSSStyleDeclaration;
-}
-
namespace WebKit {
class InjectedBundle;
class InjectedBundleBackForwardList;
class InjectedBundleBackForwardListItem;
+class InjectedBundleCSSStyleDeclarationHandle;
class InjectedBundleDOMWindowExtension;
class InjectedBundleHitTestResult;
class InjectedBundleNavigationAction;
@@ -57,7 +54,7 @@
WK_ADD_API_MAPPING(WKBundleBackForwardListItemRef, InjectedBundleBackForwardListItem)
WK_ADD_API_MAPPING(WKBundleBackForwardListRef, InjectedBundleBackForwardList)
-WK_ADD_API_MAPPING(WKBundleCSSStyleDeclarationRef, WebCore::CSSStyleDeclaration)
+WK_ADD_API_MAPPING(WKBundleCSSStyleDeclarationRef, InjectedBundleCSSStyleDeclarationHandle)
WK_ADD_API_MAPPING(WKBundleDOMWindowExtensionRef, InjectedBundleDOMWindowExtension)
WK_ADD_API_MAPPING(WKBundleFrameRef, WebFrame)
WK_ADD_API_MAPPING(WKBundleHitTestResultRef, InjectedBundleHitTestResult)
Added: trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleCSSStyleDeclarationHandle.cpp (0 => 176849)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleCSSStyleDeclarationHandle.cpp (rev 0)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleCSSStyleDeclarationHandle.cpp 2014-12-05 18:30:14 UTC (rev 176849)
@@ -0,0 +1,69 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "InjectedBundleCSSStyleDeclarationHandle.h"
+
+#include <WebCore/CSSStyleDeclaration.h>
+#include <wtf/HashMap.h>
+#include <wtf/NeverDestroyed.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+typedef HashMap<CSSStyleDeclaration*, InjectedBundleCSSStyleDeclarationHandle*> DOMHandleCache;
+
+static DOMHandleCache& domHandleCache()
+{
+ static NeverDestroyed<DOMHandleCache> cache;
+ return cache;
+}
+
+PassRefPtr<InjectedBundleCSSStyleDeclarationHandle> InjectedBundleCSSStyleDeclarationHandle::getOrCreate(CSSStyleDeclaration* styleDeclaration)
+{
+ if (!styleDeclaration)
+ return nullptr;
+
+ DOMHandleCache::AddResult result = domHandleCache().add(styleDeclaration, nullptr);
+ if (!result.isNewEntry)
+ return PassRefPtr<InjectedBundleCSSStyleDeclarationHandle>(result.iterator->value);
+
+ RefPtr<InjectedBundleCSSStyleDeclarationHandle> styleDeclarationHandle = adoptRef(new InjectedBundleCSSStyleDeclarationHandle(*styleDeclaration));
+ result.iterator->value = styleDeclarationHandle.get();
+ return styleDeclarationHandle.release();
+}
+
+InjectedBundleCSSStyleDeclarationHandle::InjectedBundleCSSStyleDeclarationHandle(CSSStyleDeclaration& styleDeclaration)
+ : m_styleDeclaration(styleDeclaration)
+{
+}
+
+InjectedBundleCSSStyleDeclarationHandle::~InjectedBundleCSSStyleDeclarationHandle()
+{
+ domHandleCache().remove(m_styleDeclaration.ptr());
+}
+
+} // namespace WebKit
Added: trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleCSSStyleDeclarationHandle.h (0 => 176849)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleCSSStyleDeclarationHandle.h (rev 0)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleCSSStyleDeclarationHandle.h 2014-12-05 18:30:14 UTC (rev 176849)
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+#ifndef InjectedBundleCSSStyleDeclarationHandle_h
+#define InjectedBundleCSSStyleDeclarationHandle_h
+
+#include "APIObject.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/Ref.h>
+
+namespace WebCore {
+class CSSStyleDeclaration;
+}
+
+namespace WebKit {
+
+class InjectedBundleCSSStyleDeclarationHandle : public API::ObjectImpl<API::Object::Type::BundleCSSStyleDeclarationHandle> {
+public:
+ static PassRefPtr<InjectedBundleCSSStyleDeclarationHandle> getOrCreate(WebCore::CSSStyleDeclaration*);
+ virtual ~InjectedBundleCSSStyleDeclarationHandle();
+
+private:
+ InjectedBundleCSSStyleDeclarationHandle(WebCore::CSSStyleDeclaration&);
+
+ Ref<WebCore::CSSStyleDeclaration> m_styleDeclaration;
+};
+
+} // namespace WebKit
+
+#endif // InjectedBundleCSSStyleDeclarationHandle_h
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageEditorClient.cpp (176848 => 176849)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageEditorClient.cpp 2014-12-05 18:23:52 UTC (rev 176848)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageEditorClient.cpp 2014-12-05 18:30:14 UTC (rev 176849)
@@ -28,6 +28,7 @@
#include "APIArray.h"
#include "APIData.h"
+#include "InjectedBundleCSSStyleDeclarationHandle.h"
#include "InjectedBundleNodeHandle.h"
#include "InjectedBundleRangeHandle.h"
#include "WKAPICast.h"
@@ -98,8 +99,9 @@
bool InjectedBundlePageEditorClient::shouldApplyStyle(WebPage* page, CSSStyleDeclaration* style, Range* range)
{
if (m_client.shouldApplyStyle) {
+ RefPtr<InjectedBundleCSSStyleDeclarationHandle> styleHandle = InjectedBundleCSSStyleDeclarationHandle::getOrCreate(style);
RefPtr<InjectedBundleRangeHandle> rangeHandle = InjectedBundleRangeHandle::getOrCreate(range);
- return m_client.shouldApplyStyle(toAPI(page), toAPI(style), toAPI(rangeHandle.get()), m_client.base.clientInfo);
+ return m_client.shouldApplyStyle(toAPI(page), toAPI(styleHandle.get()), toAPI(rangeHandle.get()), m_client.base.clientInfo);
}
return true;
}