Merge mozilla-central and mozilla-inbound

This commit is contained in:
Ed Morley 2011-10-29 02:40:36 +01:00
Родитель c3254938fb 943c9325f7
Коммит 2fb62e349c
20 изменённых файлов: 672 добавлений и 182 удалений

Просмотреть файл

@ -3275,48 +3275,31 @@ SessionStoreService.prototype = {
if (!node)
continue;
let eventType;
let value = aData[key];
if (typeof value == "string" && node.type != "file") {
if (node.value == value)
continue; // don't dispatch an input event for no change
node.value = value;
eventType = "input";
}
else if (typeof value == "boolean") {
if (node.checked == value)
continue; // don't dispatch a change event for no change
node.checked = value;
eventType = "change";
let event = aDocument.createEvent("UIEvents");
event.initUIEvent("input", true, true, aDocument.defaultView, 0);
node.dispatchEvent(event);
}
else if (typeof value == "number") {
else if (typeof value == "boolean")
node.checked = value;
else if (typeof value == "number")
try {
node.selectedIndex = value;
eventType = "change";
} catch (ex) { /* throws for invalid indices */ }
}
else if (value && value.fileList && value.type == "file" && node.type == "file") {
else if (value && value.fileList && value.type == "file" && node.type == "file")
node.mozSetFileNameArray(value.fileList, value.fileList.length);
eventType = "input";
}
else if (value && typeof value.indexOf == "function" && node.options) {
Array.forEach(node.options, function(aOpt, aIx) {
aOpt.selected = value.indexOf(aIx) > -1;
// Only fire the event here if this wasn't selected by default
if (!aOpt.defaultSelected)
eventType = "change";
});
}
// Fire events for this node if applicable
if (eventType) {
let event = aDocument.createEvent("UIEvents");
event.initUIEvent(eventType, true, true, aDocument.defaultView, 0);
node.dispatchEvent(event);
}
// NB: dispatching "change" events might have unintended side-effects
}
}

Просмотреть файл

@ -50,8 +50,6 @@ include $(topsrcdir)/config/rules.mk
_BROWSER_TEST_FILES = \
head.js \
browser_form_restore_events.js \
browser_form_restore_events_sample.html \
browser_248970_a.js \
browser_248970_b.js \
browser_248970_b_sample.html \
@ -100,6 +98,8 @@ _BROWSER_TEST_FILES = \
browser_465223.js \
browser_466937.js \
browser_466937_sample.html \
browser_476161.js \
browser_476161_sample.html \
browser_477657.js \
browser_480148.js \
browser_480893.js \

Просмотреть файл

@ -35,64 +35,33 @@
* ***** END LICENSE BLOCK ***** */
function test() {
/** Originally a test for Bug 476161, but then expanded to include all input types in bug 640136 **/
/** Test for Bug 476161 **/
waitForExplicitFinish();
let file = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties)
.get("TmpD", Components.interfaces.nsIFile);
let testURL = "http://mochi.test:8888/browser/" +
"browser/components/sessionstore/test/browser/browser_form_restore_events_sample.html";
"browser/components/sessionstore/test/browser/browser_476161_sample.html";
let tab = gBrowser.addTab(testURL);
tab.linkedBrowser.addEventListener("load", function(aEvent) {
tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
let doc = tab.linkedBrowser.contentDocument;
// text fields
doc.getElementById("modify01").value += Math.random();
doc.getElementById("modify02").value += " " + Date.now();
// textareas
doc.getElementById("modify03").value += Math.random();
doc.getElementById("modify04").value += " " + Date.now();
// file
doc.getElementById("modify05").value = file.path;
// select
doc.getElementById("modify06").selectedIndex = 1;
var multipleChange = doc.getElementById("modify07");
Array.forEach(multipleChange.options, function(option) option.selected = true);
// checkbox
doc.getElementById("modify08").checked = true;
doc.getElementById("modify09").checked = false;
// radio
// select one then another in the same group - only last one should get event on restore
doc.getElementById("modify10").checked = true;
doc.getElementById("modify11").checked = true;
doc.getElementById("modify1").value += Math.random();
doc.getElementById("modify2").value += " " + Date.now();
let tab2 = gBrowser.duplicateTab(tab);
tab2.linkedBrowser.addEventListener("load", function(aEvent) {
tab2.linkedBrowser.removeEventListener("load", arguments.callee, true);
let doc = tab2.linkedBrowser.contentDocument;
let inputFired = doc.getElementById("inputFired").textContent.trim().split();
let changeFired = doc.getElementById("changeFired").textContent.trim().split();
is(inputFired.sort().join(" "), "modify01 modify02 modify03 modify04 modify05",
"input events were only dispatched for modified input, textarea fields");
is(changeFired.sort().join(" "), "modify06 unchanged06 modify07 modify08 modify09 modify11",
"change events were only dispatched for modified select, checkbox, radio fields");
let changed = doc.getElementById("changed").textContent.trim().split();
is(changed.sort().join(" "), "modify1 modify2",
"input events were only dispatched for modified text fields");
// clean up
gBrowser.removeTab(tab2);
gBrowser.removeTab(tab);
finish();
}, true);
}, true);

Просмотреть файл

@ -0,0 +1,24 @@
<!DOCTYPE html>
<title>Test for bug 476161</title>
<script>
document.addEventListener("input", function(aEvent) {
var inputEl = aEvent.originalTarget;
var changedEl = document.getElementById("changed");
changedEl.textContent += " " + inputEl.id;
}, false);
</script>
<h3>Text fields with changed text</h3>
<input type="text" id="modify1">
<input type="text" id="modify2" value="preset value">
<h3>Text fields with unchanged text</h3>
<input type="text" id="unchanged1">
<input type="text" id="unchanged2" value="preset value">
<h3>Changed field IDs</h3>
<div id="changed"></div>

Просмотреть файл

@ -1,98 +0,0 @@
<!DOCTYPE html>
<title>Test for form restore events (originally bug 476161)</title>
<script>
document.addEventListener("input", function(aEvent) {
var inputEl = aEvent.originalTarget;
var changedEl = document.getElementById("inputFired");
changedEl.textContent += " " + inputEl.id;
}, false);
document.addEventListener("change", function(aEvent) {
var inputEl = aEvent.originalTarget;
var changedEl = document.getElementById("changeFired");
changedEl.textContent += " " + inputEl.id;
}, false);
</script>
<!-- input events -->
<h3>Text fields with changed text</h3>
<input type="text" id="modify1">
<input type="text" id="modify2" value="preset value">
<input type="text" id="modify01">
<input type="text" id="modify02" value="preset value">
<h3>Text fields with unchanged text</h3>
<input type="text" id="unchanged1">
<input type="text" id="unchanged2" value="preset value">
<input type="text" id="unchanged01">
<input type="text" id="unchanged02" value="preset value">
<h3>Textarea with changed text</h3>
<textarea id="modify03"></textarea>
<textarea id="modify04">preset value</textarea>
<h3>Textarea with unchanged text</h3>
<textarea id="unchanged03"></textarea>
<textarea id="unchanged04">preset value</textarea>
<h3>file field with changed value</h3>
<input type="file" id="modify05">
<h3>file field with unchanged value</h3>
<input type="file" id="unchanged05">
<!-- change events -->
<h3>Select menu with changed selection</h3>
<select id="modify06">
<option value="one">one</option>
<option value="two">two</option>
<option value="three">three</option>
</select>
<h3>Select menu with unchanged selection (change event still fires)</h3>
<select id="unchanged06">
<option value="one">one</option>
<option value="two" selected>two</option>
<option value="three">three</option>
</select>
<h3>Multiple Select menu with changed selection</h3>
<select id="modify07" multiple>
<option value="one">one</option>
<option value="two" selected>two</option>
<option value="three">three</option>
</select>
<h3>Select menu with unchanged selection</h3>
<select id="unchanged07" multiple>
<option value="one">one</option>
<option value="two" selected>two</option>
<option value="three" selected>three</option>
</select>
<h3>checkbox with changed value</h3>
<input type="checkbox" id="modify08">
<input type="checkbox" id="modify09" checked>
<h3>checkbox with unchanged value</h3>
<input type="checkbox" id="unchanged08">
<input type="checkbox" id="unchanged09" checked>
<h3>radio with changed value</h3>
<input type="radio" id="modify10" name="group">Radio 1</input>
<input type="radio" id="modify11" name="group">Radio 2</input>
<input type="radio" id="modify12" name="group" checked>Radio 3</input>
<h3>radio with unchanged value</h3>
<input type="radio" id="unchanged10" name="group2">Radio 4</input>
<input type="radio" id="unchanged11" name="group2">Radio 5</input>
<input type="radio" id="unchanged12" name="group2" checked>Radio 6</input>
<h3>Changed field IDs</h3>
<div id="changed"></div>
<div id="inputFired"></div>
<div id="changeFired"></div>

Просмотреть файл

@ -15,7 +15,7 @@ if sys.platform=='win32':
_log = logging.getLogger('pymake.process')
_escapednewlines = re.compile(r'\\\n')
_blacklist = re.compile(r'[$><;[{~`|&]')
_blacklist = re.compile(r'[$><;[{~`|&()]')
_needsglob = re.compile(r'[\*\?]')
def clinetoargv(cline):
"""

Просмотреть файл

@ -41,7 +41,9 @@
#ifndef mozilla_${HEADER}_h
#define mozilla_${HEADER}_h
#if __EXCEPTIONS
// For some reason, Apple's GCC refuses to honor -fno-exceptions when
// compiling ObjC.
#if __EXCEPTIONS && !(__OBJC__ && __GNUC__ && XP_IOS)
# error "STL code can only be used with -fno-exceptions"
#endif

Просмотреть файл

@ -65,6 +65,14 @@ LIBS += \
$(XPCOM_STANDALONE_GLUE_LDOPTS) \
$(NULL)
ifeq ($(MOZ_PLATFORM_MAEMO),6)
LIBS += \
$(LIBXUL_DIST)/../widget/src/qt/faststartupqt/$(LIB_PREFIX)faststartupqt.$(LIB_SUFFIX) \
$(MOZ_QT_LIBS) \
$(NULL)
LOCAL_INCLUDES += -I$(topsrcdir)/widget/src/qt/faststartupqt $(TK_CFLAGS)
endif
ifeq ($(OS_ARCH),WINNT)
OS_LIBS += $(call EXPAND_LIBNAME,version)
endif
@ -178,6 +186,11 @@ ifdef LIBXUL_SDK
endif
endif # SKIP_COPY_XULRUNNER
ifeq ($(MOZ_PLATFORM_MAEMO),6)
$(NSINSTALL) -D $(DIST)/bin/res/drawable
cp $(topsrcdir)/mobile/app/maemo/* $(DIST)/bin/res/drawable/
cp $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)/content/favicon32.png $(DIST)/bin/res/drawable/
endif
$(NSINSTALL) -D $(DIST)/bin/chrome/icons/default
ifeq ($(OS_ARCH),WINNT)

Двоичные данные
mobile/app/maemo/toolbar_splash.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.9 KiB

Просмотреть файл

@ -69,6 +69,13 @@
#include "nsXPCOMPrivate.h" // for MAXPATHLEN and XPCOM_DLL
#include "mozilla/Telemetry.h"
#if MOZ_PLATFORM_MAEMO == 6
#include "nsFastStartupQt.h"
// this used by nsQAppInstance, but defined only in nsAppRunner
// FastStartupQt using gArgc/v so we need to define it here
int gArgc;
char **gArgv;
#endif
static void Output(const char *fmt, ... )
{
@ -200,6 +207,25 @@ static int do_main(const char *exePath, int argc, char* argv[])
return result;
}
#if MOZ_PLATFORM_MAEMO == 6
static bool
GeckoPreLoader(const char* execPath)
{
nsresult rv = XPCOMGlueStartup(execPath);
if (NS_FAILED(rv)) {
Output("Couldn't load XPCOM.\n");
return false;
}
rv = XPCOMGlueLoadXULFunctions(kXULFuncs);
if (NS_FAILED(rv)) {
Output("Couldn't load XRE functions.\n");
return false;
}
return true;
}
#endif
int main(int argc, char* argv[])
{
char exePath[MAXPATHLEN];
@ -234,7 +260,10 @@ int main(int argc, char* argv[])
XPCOMGlueEnablePreload();
}
#if MOZ_PLATFORM_MAEMO == 6
nsFastStartup startup;
startup.CreateFastStartup(argc, argv, exePath, GeckoPreLoader);
#else
rv = XPCOMGlueStartup(exePath);
if (NS_FAILED(rv)) {
Output("Couldn't load XPCOM.\n");
@ -246,6 +275,7 @@ int main(int argc, char* argv[])
Output("Couldn't load XRE functions.\n");
return 255;
}
#endif
#ifdef XRE_HAS_DLL_BLOCKLIST
XRE_SetupDllBlocklist();

Просмотреть файл

@ -89,6 +89,10 @@
@BINPATH@/res/layout
#endif
#ifdef MOZ_PLATFORM_MAEMO
@BINPATH@/res/drawable
#endif
[browser]
; [Base Browser Files]
#ifndef XP_UNIX

Просмотреть файл

@ -199,6 +199,7 @@ endif
ifeq (qt,$(MOZ_WIDGET_TOOLKIT))
EXTRA_DSO_LDOPTS += $(XLDFLAGS) $(XLIBS) $(XT_LIBS) $(MOZ_QT_LIBS) -lgthread-2.0
EXTRA_DSO_LDOPTS += $(FT2_LIBS) $(MOZ_PANGO_LIBS)
EXTRA_DSO_LDOPTS += $(LIBXUL_DIST)/../widget/src/qt/faststartupqt/$(LIB_PREFIX)faststartupqt.$(LIB_SUFFIX)
endif
ifdef MOZ_TREE_FREETYPE

Просмотреть файл

@ -104,7 +104,6 @@ CPPSRCS += nsNativeAppSupportUnix.cpp
else
ifeq ($(MOZ_WIDGET_TOOLKIT),qt)
MOCSRCS += moc_nsNativeAppSupportQt.cpp
$(NULL)
CPPSRCS += $(MOCSRCS)
CPPSRCS += nsNativeAppSupportQt.cpp
CPPSRCS += nsQAppInstance.cpp

Просмотреть файл

@ -105,6 +105,8 @@ ifneq (qt,$(MOZ_WIDGET_TOOLKIT))
INACTIVE_COMPONENT = 1
endif
DIRS += faststartupqt
include $(topsrcdir)/config/config.mk
include $(topsrcdir)/ipc/chromium/chromium-config.mk
include $(topsrcdir)/config/rules.mk
@ -131,6 +133,7 @@ endif
LOCAL_INCLUDES += \
-I$(topsrcdir)/widget/src/xpwidgets \
-I$(topsrcdir)/widget/src/qt/faststartupqt \
-I$(srcdir) \
$(NULL)
ifdef MOZ_X11

Просмотреть файл

@ -0,0 +1,83 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Novell code.
#
# The Initial Developer of the Original Code is Nokia, Inc
# Portions created by the Initial Developer are Copyright (C) 2011
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Oleg Romashin <romaxa@gmail.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = faststartupqt
LIBRARY_NAME = faststartupqt
DIST_INSTALL = 1
FORCE_STATIC_LIB = 1
FORCE_USE_PIC = 1
STL_FLAGS=
EXTRA_DSO_LDOPTS = \
$(XPCOM_GLUE_LDOPTS) \
$(XPCOM_FROZEN_LDOPTS) \
$(MOZ_QT_LIBS) \
$(NULL)
LOCAL_INCLUDES += -I$(topsrcdir)/xpcom/build
GARBAGE += moziqwidget.h nsQAppInstance.h nsQAppInstance.cpp
export:: $(topsrcdir)/widget/src/qt/moziqwidget.h $(topsrcdir)/toolkit/xre/nsQAppInstance.h $(topsrcdir)/toolkit/xre/nsQAppInstance.cpp
$(INSTALL) $^ .
MOCSRCS = \
moc_moziqwidget.cpp \
moc_nsFastStartupQt.cpp \
$(NULL)
LOCAL_INCLUDES += \
$(MOZ_QT_CFLAGS) \
$(MOZ_PLATFORM_MAEMO_CFLAGS) \
$(NULL)
CPPSRCS += \
$(MOCSRCS) \
mozqwidgetfast.cpp \
nsFastStartupQt.cpp \
nsQAppInstance.cpp \
$(NULL)
DEFINES += -DLIBRARY_FILENAME="$(SHARED_LIBRARY)" -DMOZ_NO_MOZALLOC -DXPCOM_GLUE
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -0,0 +1,136 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim: set ts=4 et sw=4 tw=80: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Nokia.
*
* The Initial Developer of the Original Code is Nokia Corporation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Oleg Romashin <romaxa@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <QtCore/QUrl>
#include "mozqwidgetfast.h"
#include "nsFastStartupQt.h"
#include "nsILocalFile.h"
#include "BinaryPath.h"
#define TOOLBAR_SPLASH "toolbar_splash.png"
#define FAVICON_SPLASH "favicon32.png"
#define DRAWABLE_PATH "res/drawable/"
MozQWidgetFast::MozQWidgetFast(nsWindow* aReceiver, QGraphicsItem* aParent)
{
setParentItem(aParent);
char exePath[MAXPATHLEN];
QStringList arguments = qApp->arguments();
nsresult rv =
mozilla::BinaryPath::Get(arguments.at(0).toLocal8Bit().constData(),
exePath);
if (NS_FAILED(rv)) {
printf("Cannot read default path\n");
return;
}
char *lastSlash = strrchr(exePath, XPCOM_FILE_PATH_SEPARATOR[0]);
if (!lastSlash ||
(lastSlash - exePath > int(MAXPATHLEN - sizeof(XPCOM_DLL) - 1))) {
return;
}
strcpy(++lastSlash, "/");
QString resourcePath(QString((const char*)&exePath) + DRAWABLE_PATH);
mToolbar.load(resourcePath + TOOLBAR_SPLASH);
mIcon.load(resourcePath + FAVICON_SPLASH);
for (int i = 1; i < arguments.size(); i++) {
QUrl url = QUrl::fromUserInput(arguments.at(i));
if (url.isValid()) {
mUrl = url.toString();
}
}
}
void MozQWidgetFast::paint(QPainter* aPainter,
const QStyleOptionGraphicsItem*,
QWidget*)
{
// toolbar height
int toolbarHeight = 80;
// Offset of favicon starting from left toolbar edge
int faviconOffset = 25;
// favicon size
int faviconSize = 32;
// width of left and right TOOLBAR_SPLASH part
// |------------------------------|
// |LeftPart|tile...part|RightPart|
float toolbarPartWidth = 77;
// width of TOOLBAR_SPLASH part after toolbarPartWidth,
// that can be used for tiled toolbar area
int tileWidth = 2;
// Paint left toolbar part
aPainter->drawPixmap(QRect(0, 0, toolbarPartWidth, toolbarHeight),
mToolbar, QRect(0, 0, toolbarPartWidth, toolbarHeight));
// Paint Tile pixmap of middle toolbar part
QPixmap tile(tileWidth, toolbarHeight);
QPainter p(&tile);
p.drawPixmap(QRect(0, 0, tileWidth, toolbarHeight), mToolbar,
QRect(toolbarPartWidth, 0, tileWidth, toolbarHeight));
aPainter->drawTiledPixmap(QRect(toolbarPartWidth, 0, rect().width() - toolbarPartWidth * 2,
toolbarHeight),
tile);
// Paint Favicon
aPainter->drawPixmap(QRect(faviconOffset, faviconOffset,
faviconSize, faviconSize),
mIcon);
if (!mUrl.isEmpty()) {
// Height or URL string (font height)
float urlHeight = 24.0f;
// Start point of URL string, relative to window 0,0
int urlOffsetX = 80;
int urlOffsetY = 48;
QFont font = aPainter->font();
font.setPixelSize(urlHeight);
font.setFamily(QString("Nokia Sans"));
font.setKerning(true);
aPainter->setFont(font);
aPainter->setRenderHint(QPainter::TextAntialiasing, true);
aPainter->drawText(urlOffsetX, urlOffsetY,
aPainter->fontMetrics().elidedText(mUrl, Qt::ElideRight, rect().width() - urlOffsetX * 2));
}
// Paint Right toolbar part
aPainter->drawPixmap(QRect(rect().width() - toolbarPartWidth,
0, toolbarPartWidth,
toolbarHeight),
mToolbar,
QRect(mToolbar.width() - toolbarPartWidth, 0,
toolbarPartWidth, toolbarHeight));
nsFastStartup::GetSingleton()->painted();
}

Просмотреть файл

@ -0,0 +1,60 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim: set ts=4 et sw=4 tw=80: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Nokia.
*
* The Initial Developer of the Original Code is Nokia Corporation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Oleg Romashin <romaxa@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef MOZQWIDGETFAST_H
#define MOZQWIDGETFAST_H
#include <QtCore/QObject>
#include "moziqwidget.h"
class MozQWidgetFast : public IMozQWidget
{
public:
MozQWidgetFast(nsWindow* aReceiver, QGraphicsItem *aParent);
~MozQWidgetFast() {}
protected:
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*);
private:
QPixmap mToolbar;
QPixmap mIcon;
QString mUrl;
};
#endif

Просмотреть файл

@ -0,0 +1,165 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim: set ts=4 et sw=4 tw=80: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Nokia.
*
* The Initial Developer of the Original Code is Nokia Corporation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Oleg Romashin <romaxa@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <QtGui/QApplication>
#include "nsQAppInstance.h"
#include <QtOpenGL/QGLWidget>
#include <QThread>
#if defined MOZ_ENABLE_MEEGOTOUCH
#include <MScene>
#endif
#include "moziqwidget.h"
#include "mozqwidgetfast.h"
#include "nsFastStartupQt.h"
#include "nsXPCOMGlue.h"
#include "nsXULAppAPI.h"
static nsFastStartup* sFastStartup = NULL;
void
GeckoThread::run()
{
emit symbolsLoadingFinished(mFunc(mExecPath));
}
void
nsFastStartup::symbolsLoadingFinished(bool preloaded)
{
mSymbolsLoaded = preloaded;
if (mWidgetPainted && mSymbolsLoaded) {
qApp->quit();
}
}
void nsFastStartup::painted()
{
mWidgetPainted = true;
if (mWidgetPainted && mSymbolsLoaded) {
qApp->quit();
}
}
MozGraphicsView*
nsFastStartup::GetStartupGraphicsView(QWidget* parentWidget, IMozQWidget* aTopChild)
{
MozGraphicsView* view = NULL;
if (sFastStartup && sFastStartup->mGraphicsView) {
view = sFastStartup->mGraphicsView;
} else {
view = new MozGraphicsView(parentWidget);
Qt::WindowFlags flags = Qt::Widget;
view->setWindowFlags(flags);
#if MOZ_PLATFORM_MAEMO == 6
view->setViewport(new QGLWidget());
#endif
}
view->SetTopLevel(aTopChild, parentWidget);
return view;
}
nsFastStartup*
nsFastStartup::GetSingleton()
{
return sFastStartup;
}
nsFastStartup::nsFastStartup()
: mGraphicsView(0)
, mFakeWidget(0)
, mSymbolsLoaded(false)
, mWidgetPainted(false)
, mThread(0)
{
sFastStartup = this;
}
nsFastStartup::~nsFastStartup()
{
nsQAppInstance::Release();
sFastStartup = 0;
}
void
nsFastStartup::RemoveFakeLayout()
{
if (mFakeWidget && mGraphicsView) {
mGraphicsView->scene()->removeItem(mFakeWidget);
mFakeWidget->deleteLater();
mFakeWidget = 0;
// Forget GraphicsView, ownership moved to nsIWidget
mGraphicsView = 0;
}
}
bool
nsFastStartup::CreateFastStartup(int& argc, char ** argv,
const char* execPath,
GeckoLoaderFunc aFunc)
{
gArgc = argc;
gArgv = argv;
// Create main QApplication instance
nsQAppInstance::AddRef(argc, argv, true);
// Create symbols loading thread
mThread = new GeckoThread();
// Setup thread loading finished callbacks
connect(mThread, SIGNAL(symbolsLoadingFinished(bool)),
this, SLOT(symbolsLoadingFinished(bool)));
mThread->SetLoader(aFunc, execPath);
// Create Static UI widget and view
IMozQWidget* fakeWidget = new MozQWidgetFast(NULL, NULL);
mGraphicsView = GetStartupGraphicsView(NULL, fakeWidget);
mFakeWidget = fakeWidget;
mThread->start();
#ifdef MOZ_PLATFORM_MAEMO
mGraphicsView->showFullScreen();
#else
mGraphicsView->showNormal();
#endif
// Start native loop in order to get view opened and painted once
// Will block CreateFastStartup function and
// exit when symbols are loaded and Static UI shown
qApp->exec();
return true;
}

Просмотреть файл

@ -0,0 +1,111 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim: set ts=4 et sw=4 tw=80: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Nokia.
*
* The Initial Developer of the Original Code is Nokia Corporation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Oleg Romashin <romaxa@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef FAST_STARTUP_H
#define FAST_STARTUP_H
#include <QObject>
#include "nscore.h"
#include <QThread>
#include <sys/time.h>
class QGraphicsView;
class MozMGraphicsView;
class MozQGraphicsView;
class QGraphicsWidget;
class IMozQWidget;
class QWidget;
#if defined MOZ_ENABLE_MEEGOTOUCH
typedef MozMGraphicsView MozGraphicsView;
#else
typedef MozQGraphicsView MozGraphicsView;
#endif
class nsFastStartup;
typedef bool (*GeckoLoaderFunc)(const char* execPath);
class GeckoThread : public QThread
{
Q_OBJECT
public:
void run();
void SetLoader(GeckoLoaderFunc aFunc, const char* execPath)
{
mExecPath = execPath;
mFunc = aFunc;
}
Q_SIGNALS:
void symbolsLoadingFinished(bool);
private:
const char* mExecPath;
GeckoLoaderFunc mFunc;
};
class NS_EXPORT nsFastStartup : public QObject
{
Q_OBJECT
public:
static nsFastStartup* GetSingleton();
// Create new or get QGraphicsView which could have been created for Static UI
static MozGraphicsView* GetStartupGraphicsView(QWidget* parentWidget, IMozQWidget* aTopChild);
nsFastStartup();
virtual ~nsFastStartup();
virtual bool CreateFastStartup(int& argc, char ** argv,
const char* execPath,
GeckoLoaderFunc aFunc);
// Called when first real mozilla paint happend
void RemoveFakeLayout();
// Final notification that Static UI show and painted
void painted();
protected slots:
void symbolsLoadingFinished(bool);
private:
MozGraphicsView* mGraphicsView;
QGraphicsWidget* mFakeWidget;
bool mSymbolsLoaded;
bool mWidgetPainted;
GeckoThread* mThread;
};
#endif

Просмотреть файл

@ -143,6 +143,7 @@ static Atom sPluginIMEAtom = nsnull;
#define GLdouble_defined 1
#include "Layers.h"
#include "LayerManagerOGL.h"
#include "nsFastStartupQt.h"
// If embedding clients want to create widget without real parent window
// then nsIBaseWindow->Init() should have parent argument equal to PARENTLESS_WIDGET
@ -1075,6 +1076,11 @@ nsWindow::DoPaint(QPainter* aPainter, const QStyleOptionGraphicsItem* aOption, Q
nsEventStatus status;
nsIntRect rect(r.x(), r.y(), r.width(), r.height());
nsFastStartup* startup = nsFastStartup::GetSingleton();
if (startup) {
startup->RemoveFakeLayout();
}
if (GetLayerManager(nsnull)->GetBackendType() == LayerManager::LAYERS_OPENGL) {
nsPaintEvent event(true, NS_PAINT, this);
event.refPoint.x = r.x();
@ -2684,21 +2690,20 @@ nsWindow::createQWidget(MozQWidget *parent,
// create a QGraphicsView if this is a new toplevel window
if (mIsTopLevel) {
#if defined MOZ_ENABLE_MEEGOTOUCH
MozMGraphicsView* newView = new MozMGraphicsView(parentWidget);
#else
MozQGraphicsView* newView = new MozQGraphicsView(parentWidget);
#endif
QGraphicsView* newView =
nsFastStartup::GetStartupGraphicsView(parentWidget, widget);
newView->SetTopLevel(widget, parentWidget);
newView->setWindowFlags(flags);
if (mWindowType == eWindowType_dialog) {
newView->setWindowModality(Qt::WindowModal);
}
#ifdef MOZ_PLATFORM_MAEMO
if (GetShouldAccelerate()) {
newView->setViewport(new QGLWidget());
// Only create new OGL widget if it is not yet installed
QGLWidget *glWidget = qobject_cast<QGLWidget*>(newView->viewport());
if (!glWidget) {
newView->setViewport(new QGLWidget());
}
}
#endif