diff options
author | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2013-11-20 16:18:11 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-21 13:21:19 +0100 |
commit | b69da78438492af157bb03d5d76a701538db5470 (patch) | |
tree | 05e36a9ca84a86400897400a3c10e27648a675c1 /lib | |
parent | 4874b4c0cff423aae073d8bf15d726cbb92061e4 (diff) |
Get rid of the intermediate "shared" static library.
It is not necessary anymore since QtWebEngineProcess dynamically
links to the core library which will now contain those symbols.
Change-Id: I3475347bab41a00b943f934a5e341326c66dc726
Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/browser_context_qt.h | 3 | ||||
-rw-r--r-- | lib/chromium_overrides.cpp | 115 | ||||
-rw-r--r-- | lib/chromium_overrides.h | 54 | ||||
-rw-r--r-- | lib/download_manager_delegate_qt.cpp | 2 | ||||
-rw-r--r-- | lib/lib.pro | 5 | ||||
-rw-r--r-- | lib/qtwebenginecoreglobal.h | 8 | ||||
-rw-r--r-- | lib/render_widget_host_view_qt.cpp | 3 | ||||
-rw-r--r-- | lib/render_widget_host_view_qt.h | 1 | ||||
-rw-r--r-- | lib/resource_bundle_qt.cpp | 170 | ||||
-rw-r--r-- | lib/web_engine_context.cpp | 1 |
10 files changed, 354 insertions, 8 deletions
diff --git a/lib/browser_context_qt.h b/lib/browser_context_qt.h index 88bba1e9e..382b08ff3 100644 --- a/lib/browser_context_qt.h +++ b/lib/browser_context_qt.h @@ -46,8 +46,6 @@ #include "base/files/scoped_temp_dir.h" -#include "shared/shared_globals.h" - #include "base/time/time.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/content_browser_client.h" @@ -65,6 +63,7 @@ #include <QStringBuilder> #include "download_manager_delegate_qt.h" +#include "qtwebenginecoreglobal.h" #include "resource_context_qt.h" #include "type_conversion.h" #include "url_request_context_getter_qt.h" diff --git a/lib/chromium_overrides.cpp b/lib/chromium_overrides.cpp new file mode 100644 index 000000000..383fc6587 --- /dev/null +++ b/lib/chromium_overrides.cpp @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "chromium_overrides.h" + +#include "base/message_loop/message_pump_gtk.h" +#include "content/browser/renderer_host/render_widget_host_view_base.h" + +#include <QGuiApplication> +#include <QScreen> +#include <QWindow> +#include <qpa/qplatformnativeinterface.h> + +#if defined(USE_X11) +#include <X11/Xlib.h> +#endif + +void GetScreenInfoFromNativeWindow(QWindow* window, WebKit::WebScreenInfo* results) +{ + QScreen* screen = window->screen(); + + WebKit::WebScreenInfo r; + r.deviceScaleFactor = screen->devicePixelRatio(); + r.depthPerComponent = 8; + r.depth = screen->depth(); + r.isMonochrome = (r.depth == 1); + + QRect screenGeometry = screen->geometry(); + r.rect = WebKit::WebRect(screenGeometry.x(), screenGeometry.y(), screenGeometry.width(), screenGeometry.height()); + QRect available = screen->availableGeometry(); + r.availableRect = WebKit::WebRect(available.x(), available.y(), available.width(), available.height()); + *results = r; +} + +namespace base { + +#if defined(USE_X11) +Display* MessagePumpGtk::GetDefaultXDisplay() { + static void *display = qApp->platformNativeInterface()->nativeResourceForScreen(QByteArrayLiteral("display"), qApp->primaryScreen()); + if (!display) { + // XLib isn't available or has not been initialized, which is a decision we wish to + // support, for example for the GPU process. + static Display* xdisplay = XOpenDisplay(NULL); + return xdisplay; + } + return static_cast<Display*>(display); +} +#endif + +} + +namespace content { +class WebContentsImpl; +class WebContentsViewPort; +class WebContentsViewDelegate; +class RenderViewHostDelegateView; + +WebContentsViewPort* CreateWebContentsView(WebContentsImpl*, + WebContentsViewDelegate*, + RenderViewHostDelegateView**) +{ + return 0; +} + +RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost*) { + // WebContentsViewQt should take care of this directly. + Q_UNREACHABLE(); + return NULL; +} + +// static +void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebKit::WebScreenInfo* results) { + QWindow dummy; + GetScreenInfoFromNativeWindow(&dummy, results); +} + +} diff --git a/lib/chromium_overrides.h b/lib/chromium_overrides.h new file mode 100644 index 000000000..cda4d7e66 --- /dev/null +++ b/lib/chromium_overrides.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CHROMIUM_OVERRIDES_H +#define CHROMIUM_OVERRIDES_H + +#include "third_party/WebKit/public/platform/WebScreenInfo.h" +#include <QtGlobal> + +QT_BEGIN_NAMESPACE +class QWindow; +QT_END_NAMESPACE + +void GetScreenInfoFromNativeWindow(QWindow* window, WebKit::WebScreenInfo* results); + +#endif diff --git a/lib/download_manager_delegate_qt.cpp b/lib/download_manager_delegate_qt.cpp index 633d203ae..27b61b1c9 100644 --- a/lib/download_manager_delegate_qt.cpp +++ b/lib/download_manager_delegate_qt.cpp @@ -44,7 +44,6 @@ #include "content/public/browser/download_item.h" #include "content/public/browser/save_page_type.h" #include "content/public/browser/web_contents.h" -#include "shared/shared_globals.h" #include <QDir> #include <QFile> @@ -53,6 +52,7 @@ #include <QStandardPaths> #include "type_conversion.h" +#include "qtwebenginecoreglobal.h" // Helper class to track currently ongoing downloads to prevent file name // clashes / overwriting of files. diff --git a/lib/lib.pro b/lib/lib.pro index 9e51b3c58..c1266626b 100644 --- a/lib/lib.pro +++ b/lib/lib.pro @@ -2,7 +2,7 @@ # We want the gyp generation step to happen after all the other config steps. For that we need to prepend # our gyp_generator.prf feature to the CONFIG variable since it is processed backwards CONFIG = gyp_generator $$CONFIG -GYPDEPENDENCIES += ../shared/shared.gyp:qtwebengine_shared <(chromium_src_dir)/content/browser/devtools/devtools_resources.gyp:devtools_resources +GYPDEPENDENCIES += <(chromium_src_dir)/content/browser/devtools/devtools_resources.gyp:devtools_resources GYPINCLUDES += ../qtwebengine.gypi TEMPLATE = lib @@ -40,6 +40,7 @@ INCLUDEPATH += $$[QT_INSTALL_HEADERS] SOURCES = \ backing_store_qt.cpp \ + chromium_overrides.cpp \ content_client_qt.cpp \ content_browser_client_qt.cpp \ delegated_frame_node.cpp \ @@ -49,6 +50,7 @@ SOURCES = \ javascript_dialog_manager_qt.cpp \ process_main.cpp \ render_widget_host_view_qt.cpp \ + resource_bundle_qt.cpp \ resource_context_qt.cpp \ url_request_context_getter_qt.cpp \ web_contents_adapter.cpp \ @@ -61,6 +63,7 @@ SOURCES = \ HEADERS = \ backing_store_qt.h \ browser_context_qt.h \ + chromium_overrides.h \ content_client_qt.h \ content_browser_client_qt.h \ delegated_frame_node.h \ diff --git a/lib/qtwebenginecoreglobal.h b/lib/qtwebenginecoreglobal.h index 3ad62b4b9..b84c321d0 100644 --- a/lib/qtwebenginecoreglobal.h +++ b/lib/qtwebenginecoreglobal.h @@ -43,6 +43,14 @@ #include <QtCore/qglobal.h> +#ifdef QT_WEBENGINE_LOGGING +#define QT_NOT_YET_IMPLEMENTED fprintf(stderr, "function %s not implemented! - %s:%d\n", __func__, __FILE__, __LINE__); +#define QT_NOT_USED fprintf(stderr, "# function %s should not be used! - %s:%d\n", __func__, __FILE__, __LINE__); Q_UNREACHABLE(); +#else +#define QT_NOT_YET_IMPLEMENTED qt_noop(); +#define QT_NOT_USED Q_UNREACHABLE(); // This will assert in debug. +#endif + #ifndef QT_STATIC # if defined(BUILDING_CHROMIUM) # define QWEBENGINE_EXPORT Q_DECL_EXPORT diff --git a/lib/render_widget_host_view_qt.cpp b/lib/render_widget_host_view_qt.cpp index 84192bef0..91e9ab585 100644 --- a/lib/render_widget_host_view_qt.cpp +++ b/lib/render_widget_host_view_qt.cpp @@ -42,13 +42,12 @@ #include "render_widget_host_view_qt.h" #include "backing_store_qt.h" +#include "chromium_overrides.h" #include "delegated_frame_node.h" #include "render_widget_host_view_qt_delegate.h" #include "type_conversion.h" #include "web_event_factory.h" -#include "shared/shared_globals.h" - #include "cc/output/compositor_frame_ack.h" #include "content/browser/renderer_host/render_view_host_impl.h" #include "content/browser/renderer_host/ui_events_helper.h" diff --git a/lib/render_widget_host_view_qt.h b/lib/render_widget_host_view_qt.h index bf29938c6..c6ca93657 100644 --- a/lib/render_widget_host_view_qt.h +++ b/lib/render_widget_host_view_qt.h @@ -43,7 +43,6 @@ #define RENDER_WIDGET_HOST_VIEW_QT_H #include "render_widget_host_view_qt_delegate.h" -#include "shared/shared_globals.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" diff --git a/lib/resource_bundle_qt.cpp b/lib/resource_bundle_qt.cpp new file mode 100644 index 000000000..044d00511 --- /dev/null +++ b/lib/resource_bundle_qt.cpp @@ -0,0 +1,170 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "ui/base/resource/resource_bundle.h" +#include "ui/base/resource/data_pack.h" + +#include <QFile> +#include <QStringList> + +namespace ui { + +// ********************* data_pack.cc ********************* +// This is duplicated code originating from data_pack.cc. +// It should instead be moved to a header file and be included +// in both places. + +static const uint32 kFileFormatVersion = 4; +static const size_t kHeaderLength = 2 * sizeof(uint32) + sizeof(uint8); + +#pragma pack(push,2) +struct DataPackEntry { + uint16 resource_id; + uint32 file_offset; + + static int CompareById(const void* void_key, const void* void_entry) { + uint16 key = *reinterpret_cast<const uint16*>(void_key); + const DataPackEntry* entry = + reinterpret_cast<const DataPackEntry*>(void_entry); + if (key < entry->resource_id) { + return -1; + } else if (key > entry->resource_id) { + return 1; + } else { + return 0; + } + } +}; +#pragma pack(pop) +// ******************* data_pack.cc end ******************* + +class UI_EXPORT DataPackQt : public DataPack { + public: + DataPackQt(ui::ScaleFactor scale_factor) + : DataPack(scale_factor) + , m_data(NULL) + , m_resourceCount(0) { } + + virtual ~DataPackQt() { } + + bool LoadFromByteArray(const QByteArray& data) + { + m_data = data; + + if (kHeaderLength > static_cast<size_t>(m_data.size())) + return false; + + const uint32* ptr = reinterpret_cast<const uint32*>(m_data.data()); + uint32 version = ptr[0]; + if (version != kFileFormatVersion) { + LOG(ERROR) << "Bad data pack version: got " << version << ", expected " << kFileFormatVersion; + return false; + } + + m_resourceCount = ptr[1]; + return true; + } + + virtual bool HasResource(uint16 resource_id) const OVERRIDE + { + return !!bsearch(&resource_id, m_data.data() + kHeaderLength, m_resourceCount, sizeof(DataPackEntry), DataPackEntry::CompareById); + } + + virtual bool GetStringPiece(uint16 resource_id, base::StringPiece* data) const OVERRIDE + { + #if defined(__BYTE_ORDER) // Linux check + COMPILE_ASSERT(__BYTE_ORDER == __LITTLE_ENDIAN, datapack_assumes_little_endian); + #elif defined(__BIG_ENDIAN__) // Mac check + #error DataPack assumes little endian + #endif + + const DataPackEntry* target = reinterpret_cast<const DataPackEntry*>(bsearch(&resource_id, m_data.data() + kHeaderLength, m_resourceCount, sizeof(DataPackEntry), DataPackEntry::CompareById)); + if (!target) + return false; + + const DataPackEntry* next_entry = target + 1; + size_t length = next_entry->file_offset - target->file_offset; + + data->set(m_data.data() + target->file_offset, length); + return true; + } + + private: + QByteArray m_data; + size_t m_resourceCount; + DISALLOW_COPY_AND_ASSIGN(DataPackQt); +}; + + +void ResourceBundle::LoadCommonResources() +{ + QStringList resources; + resources << ":/data/resources.pak" << ":/data/devtools.pak"; + Q_FOREACH (const QString& pak, resources) { + QFile pak_file(pak); + if (!pak_file.open(QIODevice::ReadOnly)) { + qWarning("Resource file %s not loaded", qPrintable(pak)); + continue; + } + + scoped_ptr<DataPackQt> data_pack(new DataPackQt(SCALE_FACTOR_100P)); + if (data_pack->LoadFromByteArray(pak_file.readAll())) + AddDataPack(data_pack.release()); + } +} + +// As GetLocaleFilePath is excluded for Mac in resource_bundle.cc, +// we have to add a replacement for it using the inverted logic. +#if defined(OS_MACOSX) +base::FilePath ResourceBundle::GetLocaleFilePath(const std::string& /*app_locale*/, bool /*test_file_exists*/) +{ + return base::FilePath(); +} +#endif + +gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) +{ + LOG(WARNING) << "Unable to load image with id " << resource_id; + NOTREACHED(); // Want to assert in debug mode. + return GetEmptyImage(); +} + +} // namespace ui diff --git a/lib/web_engine_context.cpp b/lib/web_engine_context.cpp index fe557b86c..e26027207 100644 --- a/lib/web_engine_context.cpp +++ b/lib/web_engine_context.cpp @@ -41,7 +41,6 @@ #include "web_engine_context.h" -#include "shared/shared_globals.h" #include <math.h> #include "base/command_line.h" |