[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

hausmann at webkit.org hausmann at webkit.org
Wed Dec 22 13:21:12 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 287804d63c60546c0841df323a0257aae55a7cc1
Author: hausmann at webkit.org <hausmann at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sun Sep 12 18:12:27 2010 +0000

    [Qt] Add PlatformBridge for V8 build.
    
    Reviewed by Andreas Kling.
    
    Add the minimalisting platform bridge with the two
    methods needed by NPV8Object.cpp.
    
    * WebCore.pro:
    * platform/qt/PlatformBridge.h: Added.
    * platform/qt/PlatformBridgeQt.cpp: Added.
    (WebCore::PlatformBridge::popupsAllowed):
    (WebCore::PlatformBridge::pluginScriptableObject):
    * plugins/PluginView.cpp: Refactor the plugin object
    retrieval code into a separate function, called by
    bindingInstance() and PlatformBridge.
    (WebCore::PluginView::npObject):
    (WebCore::PluginView::bindingInstance):
    * plugins/PluginView.h:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67333 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index c873e31..a897aae 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,24 @@
+2010-09-12  Simon Hausmann  <simon.hausmann at nokia.com>
+
+        Reviewed by Andreas Kling.
+
+        [Qt] Add PlatformBridge for V8 build.
+
+        Add the minimalisting platform bridge with the two
+        methods needed by NPV8Object.cpp.
+
+        * WebCore.pro:
+        * platform/qt/PlatformBridge.h: Added.
+        * platform/qt/PlatformBridgeQt.cpp: Added.
+        (WebCore::PlatformBridge::popupsAllowed):
+        (WebCore::PlatformBridge::pluginScriptableObject):
+        * plugins/PluginView.cpp: Refactor the plugin object
+        retrieval code into a separate function, called by
+        bindingInstance() and PlatformBridge.
+        (WebCore::PluginView::npObject):
+        (WebCore::PluginView::bindingInstance):
+        * plugins/PluginView.h:
+
 2010-09-11  Jer Noble  <jer.noble at apple.com>
 
         Reviewed by Eric Carlson.
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index 714b810..da2d5e9 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -2517,7 +2517,7 @@ HEADERS += \
 
 v8 {
     SOURCES += \
-       platform/qt/PlatformBridge.cpp \
+       platform/qt/PlatformBridgeQt.cpp \
        bridge/qt/v8/qt_instancev8.cpp \
        bridge/qt/v8/qt_pixmapruntimev8.cpp \
        bridge/qt/v8/qt_runtimev8.cpp
diff --git a/WebCore/platform/qt/PlatformBridge.h b/WebCore/platform/qt/PlatformBridge.h
new file mode 100644
index 0000000..918e139
--- /dev/null
+++ b/WebCore/platform/qt/PlatformBridge.h
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2009, 2010, The Android Open Source Project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * 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 THE COPYRIGHT HOLDERS ``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 THE COPYRIGHT OWNER OR
+ * 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 PlatformBridge_h
+#define PlatformBridge_h
+
+#include "KURL.h"
+#include "npapi.h"
+#include "PlatformString.h"
+
+#include <wtf/Vector.h>
+
+// V8 bindings use the ARRAYSIZE_UNSAFE macro. This macro was copied
+// from http://src.chromium.org/viewvc/chrome/trunk/src/base/basictypes.h
+//
+// ARRAYSIZE_UNSAFE performs essentially the same calculation as arraysize,
+// but can be used on anonymous types or types defined inside
+// functions. It's less safe than arraysize as it accepts some
+// (although not all) pointers. Therefore, you should use arraysize
+// whenever possible.
+//
+// The expression ARRAYSIZE_UNSAFE(a) is a compile-time constant of type
+// size_t.
+//
+// ARRAYSIZE_UNSAFE catches a few type errors. If you see a compiler error
+//
+//   "warning: division by zero in ..."
+//
+// when using ARRAYSIZE_UNSAFE, you are (wrongfully) giving it a pointer.
+// You should only use ARRAYSIZE_UNSAFE on statically allocated arrays.
+//
+// The following comments are on the implementation details, and can
+// be ignored by the users.
+//
+// ARRAYSIZE_UNSAFE(arr) works by inspecting sizeof(arr) (the # of bytes in
+// the array) and sizeof(*(arr)) (the # of bytes in one array
+// element). If the former is divisible by the latter, perhaps arr is
+// indeed an array, in which case the division result is the # of
+// elements in the array. Otherwise, arr cannot possibly be an array,
+// and we generate a compiler error to prevent the code from
+// compiling.
+//
+// Since the size of bool is implementation-defined, we need to cast
+// !(sizeof(a) & sizeof(*(a))) to size_t in order to ensure the final
+// result has type size_t.
+//
+// This macro is not perfect as it wrongfully accepts certain
+// pointers, namely where the pointer size is divisible by the pointee
+// size. Since all our code has to go through a 32-bit compiler,
+// where a pointer is 4 bytes, this means all pointers to a type whose
+// size is 3 or greater than 4 will be (righteously) rejected.
+
+#define ARRAYSIZE_UNSAFE(a) \
+  ((sizeof(a) / sizeof(*(a))) / \
+   static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
+
+
+class NPObject;
+
+namespace WebCore {
+
+class Widget;
+
+// An interface to the embedding layer, which has the ability to answer
+// questions about the system and so on...
+// This is very similar to ChromiumBridge and the two are likely to converge
+// in the future.
+class PlatformBridge {
+public:
+    static bool popupsAllowed(NPP npp);
+    // Plugin
+    static NPObject* pluginScriptableObject(Widget*);
+};
+
+}
+#endif // PlatformBridge_h
diff --git a/WebCore/platform/qt/PlatformBridgeQt.cpp b/WebCore/platform/qt/PlatformBridgeQt.cpp
new file mode 100644
index 0000000..62065d7
--- /dev/null
+++ b/WebCore/platform/qt/PlatformBridgeQt.cpp
@@ -0,0 +1,51 @@
+/*
+ * This file is part of the WebKit project.
+ *
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+#include "config.h"
+#include "PlatformBridge.h"
+
+#include "Frame.h"
+#include "PluginView.h"
+#include "Widget.h"
+
+namespace WebCore {
+
+bool PlatformBridge::popupsAllowed(NPP npp)
+{
+    if (npp && npp->ndata)
+        return static_cast<PluginView*>(npp->ndata)->arePopupsAllowed();
+
+    return false;
+}
+
+NPObject* PlatformBridge::pluginScriptableObject(Widget* widget)
+{
+    if (!widget)
+        return 0;
+
+    if (!widget->isPluginView())
+        return 0;
+
+    PluginView* pluginView = static_cast<PluginView*>(widget);
+    return pluginView->npObject();
+}
+
+}
diff --git a/WebCore/plugins/PluginView.cpp b/WebCore/plugins/PluginView.cpp
index 306fdb8..9d13ff6 100644
--- a/WebCore/plugins/PluginView.cpp
+++ b/WebCore/plugins/PluginView.cpp
@@ -730,8 +730,7 @@ void PluginView::setJavaScriptPaused(bool paused)
         m_requestTimer.startOneShot(0);
 }
 
-#if USE(JSC)
-PassRefPtr<JSC::Bindings::Instance> PluginView::bindingInstance()
+NPObject* PluginView::npObject()
 {
 #if ENABLE(NETSCAPE_PLUGIN_API)
     NPObject* object = 0;
@@ -756,6 +755,19 @@ PassRefPtr<JSC::Bindings::Instance> PluginView::bindingInstance()
         PluginView::setCurrentPluginView(0);
     }
 
+    return object;
+#else
+    return 0;
+#endif
+}
+
+#if USE(JSC)
+PassRefPtr<JSC::Bindings::Instance> PluginView::bindingInstance()
+{
+    NPObject* object = npObject();
+    if (!object)
+        return 0;
+
     if (hasOneRef()) {
         // The renderer for the PluginView was destroyed during the above call, and
         // the PluginView will be destroyed when this function returns, so we
@@ -772,9 +784,6 @@ PassRefPtr<JSC::Bindings::Instance> PluginView::bindingInstance()
     _NPN_ReleaseObject(object);
 
     return instance.release();
-#else
-    return 0;
-#endif
 }
 #endif
 
diff --git a/WebCore/plugins/PluginView.h b/WebCore/plugins/PluginView.h
index a1e7524..fdaae25 100644
--- a/WebCore/plugins/PluginView.h
+++ b/WebCore/plugins/PluginView.h
@@ -139,6 +139,7 @@ namespace WebCore {
         void setNPWindowRect(const IntRect&);
         static PluginView* currentPluginView();
 
+        NPObject* npObject();
 #if USE(JSC)
         PassRefPtr<JSC::Bindings::Instance> bindingInstance();
 #endif

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list