Merge last PGO-green changeset from mozilla-inbound to mozilla-central

This commit is contained in:
Ed Morley 2011-12-21 12:11:14 +00:00
Родитель 82231be752 338d1ef2af
Коммит 52dc30d629
82 изменённых файлов: 1475 добавлений и 412 удалений

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

@ -219,6 +219,7 @@
@BINPATH@/components/pref.xpt
@BINPATH@/components/prefetch.xpt
@BINPATH@/components/profile.xpt
@BINPATH@/components/profiler.xpt
@BINPATH@/components/proxyObject.xpt
@BINPATH@/components/rdf.xpt
@BINPATH@/components/satchel.xpt

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

@ -313,7 +313,7 @@ if test -n "$gonkdir" ; then
STLPORT_CPPFLAGS="-I$gonkdir/ndk/sources/cxx-stl/stlport/stlport/"
STLPORT_LIBS="-lstlport"
CPPFLAGS="-DANDROID -I$gonkdir/bionic/libc/include/ -I$gonkdir/bionic/libc/kernel/common -I$gonkdir/bionic/libc/arch-arm/include -I$gonkdir/bionic/libc/kernel/arch-arm -I$gonkdir/bionic/libm/include -I$gonkdir/frameworks/base/opengl/include -I$gonkdir/frameworks/base/native/include -I$gonkdir/hardware/libhardware/include -I$gonkdir/system/core/include -I$gonkdir/bionic -I$gonkdir/frameworks/base/include $STLPORT_CPPFLAGS $CPPFLAGS"
CPPFLAGS="-DANDROID -I$gonkdir/bionic/libc/include/ -I$gonkdir/bionic/libc/kernel/common -I$gonkdir/bionic/libc/arch-arm/include -I$gonkdir/bionic/libc/kernel/arch-arm -I$gonkdir/bionic/libm/include -I$gonkdir/frameworks/base/opengl/include -I$gonkdir/frameworks/base/native/include -I$gonkdir/hardware/libhardware/include -I$gonkdir/hardware/libhardware_legacy/include -I$gonkdir/system/core/include -I$gonkdir/bionic -I$gonkdir/frameworks/base/include $STLPORT_CPPFLAGS $CPPFLAGS"
CFLAGS="-mandroid -fno-short-enums -fno-exceptions $CFLAGS"
CXXFLAGS="-mandroid -fno-short-enums -fno-exceptions $CXXFLAGS"
LIBS="$LIBS $STLPORT_LIBS"

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

@ -120,7 +120,7 @@ public:
nsString mScriptText; // Holds script for loaded scripts
PRUint32 mJSVersion;
nsCOMPtr<nsIURI> mURI;
nsCOMPtr<nsIURI> mFinalURI;
nsCOMPtr<nsIPrincipal> mOriginPrincipal;
PRInt32 mLineNo;
};
@ -882,8 +882,6 @@ nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest,
return NS_ERROR_FAILURE;
}
nsIURI* uri = aRequest->mFinalURI ? aRequest->mFinalURI : aRequest->mURI;
bool oldProcessingScriptTag = context->GetProcessingScriptTag();
context->SetProcessingScriptTag(true);
@ -891,14 +889,17 @@ nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest,
nsCOMPtr<nsIScriptElement> oldCurrent = mCurrentScript;
mCurrentScript = aRequest->mElement;
// It's very important to use aRequest->mURI, not the final URI of the channel
// aRequest ended up getting script data from, as the script filename.
nsCAutoString url;
nsContentUtils::GetWrapperSafeScriptFilename(mDocument, uri, url);
nsContentUtils::GetWrapperSafeScriptFilename(mDocument, aRequest->mURI, url);
bool isUndefined;
rv = context->EvaluateString(aScript, globalObject->GetGlobalJSObject(),
mDocument->NodePrincipal(), url.get(),
aRequest->mLineNo, aRequest->mJSVersion, nsnull,
&isUndefined);
mDocument->NodePrincipal(),
aRequest->mOriginPrincipal,
url.get(), aRequest->mLineNo,
aRequest->mJSVersion, nsnull, &isUndefined);
// Put the old script back in case it wants to do anything else.
mCurrentScript = oldCurrent;
@ -1213,7 +1214,10 @@ nsScriptLoader::PrepareLoadedRequest(nsScriptLoadRequest* aRequest,
}
nsCOMPtr<nsIChannel> channel = do_QueryInterface(req);
NS_GetFinalChannelURI(channel, getter_AddRefs(aRequest->mFinalURI));
rv = nsContentUtils::GetSecurityManager()->
GetChannelPrincipal(channel, getter_AddRefs(aRequest->mOriginPrincipal));
NS_ENSURE_SUCCESS(rv, rv);
if (aStringLen) {
// Check the charset attribute to determine script charset.
nsAutoString hintCharset;

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

@ -19,7 +19,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=461735
var errorFired = false;
window.onerror = function(message, uri, line) {
is(message, "Script error.", "Should have empty error message");
is(uri, "", "Should have empty error location URI");
is(uri,
"http://mochi.test:8888/tests/content/base/test/bug461735-redirect1.sjs",
"Should have pre-redirect error location URI");
is(line, 0, "Shouldn't have a line here");
errorFired = true;
}
@ -32,7 +34,9 @@ window.onerror = function(message, uri, line) {
<script type="application/javascript">
window.onerror = function(message, uri, line) {
is(message, "c is not defined", "Should have correct error message");
is(uri, "http://mochi.test:8888/tests/content/base/test/bug461735-post-redirect.js", "Unexpected error location URI");
is(uri,
"http://mochi.test:8888/tests/content/base/test/bug461735-redirect2.sjs",
"Unexpected error location URI");
is(line, 3, "Should have a line here");
errorFired = true;
}

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

@ -9261,7 +9261,8 @@ nsGlobalWindow::RunTimeout(nsTimeout *aTimeout)
bool is_undefined;
scx->EvaluateString(nsDependentString(script), FastGetGlobalJSObject(),
timeout->mPrincipal, filename, lineNo,
timeout->mPrincipal, timeout->mPrincipal,
filename, lineNo,
handler->GetScriptVersion(), nsnull,
&is_undefined);
} else {

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

@ -74,8 +74,8 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIScriptContextPrincipal,
NS_ISCRIPTCONTEXTPRINCIPAL_IID)
#define NS_ISCRIPTCONTEXT_IID \
{ 0xb36103bd, 0x304e, 0x4ef2, \
{ 0x81, 0x12, 0x83, 0x42, 0xe5, 0xbd, 0xf3, 0xd4 } }
{ 0xf3840057, 0x4fe5, 0x4f92, \
{ 0xa3, 0xb8, 0x27, 0xd7, 0x44, 0x6f, 0x72, 0x4d } }
/* This MUST match JSVERSION_DEFAULT. This version stuff if we don't
know what language we have is a little silly... */
@ -99,7 +99,9 @@ public:
* @param aScript a string representing the script to be executed
* @param aScopeObject a script object for the scope to execute in, or
* nsnull to use a default scope
* @param aPrincipal the principal that produced the script
* @param aPrincipal the principal the script should be evaluated with
* @param aOriginPrincipal the principal the script originates from. If null,
* aPrincipal is used.
* @param aURL the URL or filename for error messages
* @param aLineNo the starting line number of the script for error messages
* @param aVersion the script language version to use when executing
@ -115,6 +117,7 @@ public:
virtual nsresult EvaluateString(const nsAString& aScript,
JSObject* aScopeObject,
nsIPrincipal *aPrincipal,
nsIPrincipal *aOriginPrincipal,
const char *aURL,
PRUint32 aLineNo,
PRUint32 aVersion,

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

@ -89,6 +89,8 @@
#include "nsGlobalWindow.h"
#include "nsScriptNameSpaceManager.h"
#include "nsJSPrincipals.h"
#ifdef XP_MACOSX
// AssertMacros.h defines 'check' and conflicts with AccessCheck.h
#undef check
@ -283,13 +285,15 @@ class ScriptErrorEvent : public nsRunnable
{
public:
ScriptErrorEvent(nsIScriptGlobalObject* aScriptGlobal,
nsIPrincipal* aScriptOriginPrincipal,
PRUint32 aLineNr, PRUint32 aColumn, PRUint32 aFlags,
const nsAString& aErrorMsg,
const nsAString& aFileName,
const nsAString& aSourceLine,
bool aDispatchEvent,
PRUint64 aInnerWindowID)
: mScriptGlobal(aScriptGlobal), mLineNr(aLineNr), mColumn(aColumn),
: mScriptGlobal(aScriptGlobal), mOriginPrincipal(aScriptOriginPrincipal),
mLineNr(aLineNr), mColumn(aColumn),
mFlags(aFlags), mErrorMsg(aErrorMsg), mFileName(aFileName),
mSourceLine(aSourceLine), mDispatchEvent(aDispatchEvent),
mInnerWindowID(aInnerWindowID)
@ -320,17 +324,11 @@ public:
nsIPrincipal* p = sop->GetPrincipal();
NS_ENSURE_STATE(p);
bool sameOrigin = mFileName.IsVoid();
bool sameOrigin = !mOriginPrincipal;
if (p && !sameOrigin) {
nsCOMPtr<nsIURI> errorURI;
NS_NewURI(getter_AddRefs(errorURI), mFileName);
if (errorURI) {
// FIXME: Once error reports contain the origin of the
// error (principals) we should change this to do the
// security check based on the principals and not
// URIs. See bug 387476.
sameOrigin = NS_SUCCEEDED(p->CheckMayLoad(errorURI, false));
if (NS_FAILED(p->Subsumes(mOriginPrincipal, &sameOrigin))) {
sameOrigin = false;
}
}
@ -342,13 +340,6 @@ public:
NS_WARNING("Not same origin error!");
errorevent.errorMsg = xoriginMsg.get();
errorevent.lineNr = 0;
// FIXME: once the principal of the script is not tied to
// the filename, we can stop using the post-redirect
// filename if we want and remove this line. Note that
// apparently we can't handle null filenames in the error
// event dispatching code.
static PRUnichar nullFilename[] = { PRUnichar(0) };
errorevent.fileName = nullFilename;
}
nsEventDispatcher::Dispatch(win, presContext, &errorevent, nsnull,
@ -407,6 +398,7 @@ public:
nsCOMPtr<nsIScriptGlobalObject> mScriptGlobal;
nsCOMPtr<nsIPrincipal> mOriginPrincipal;
PRUint32 mLineNr;
PRUint32 mColumn;
PRUint32 mFlags;
@ -502,8 +494,11 @@ NS_ScriptErrorReporter(JSContext *cx,
innerWindowID = innerWin->WindowID();
}
}
JSPrincipals *prin = report->originPrincipals;
nsIPrincipal *principal =
prin ? static_cast<nsJSPrincipals*>(prin)->nsIPrincipalPtr : nsnull;
nsContentUtils::AddScriptRunner(
new ScriptErrorEvent(globalObject, report->lineno,
new ScriptErrorEvent(globalObject, principal, report->lineno,
report->uctokenptr - report->uclinebuf,
report->flags, msg, fileName, sourceLine,
report->errorNumber != JSMSG_OUT_OF_MEMORY,
@ -1389,6 +1384,7 @@ nsresult
nsJSContext::EvaluateString(const nsAString& aScript,
JSObject* aScopeObject,
nsIPrincipal *aPrincipal,
nsIPrincipal *aOriginPrincipal,
const char *aURL,
PRUint32 aLineNo,
PRUint32 aVersion,
@ -1436,6 +1432,13 @@ nsJSContext::EvaluateString(const nsAString& aScript,
principal->GetJSPrincipals(mContext, &jsprin);
}
JSPrincipals *originJSprin;
if (aOriginPrincipal) {
aOriginPrincipal->GetJSPrincipals(mContext, &originJSprin);
} else {
originJSprin = nsnull;
}
// From here on, we must JSPRINCIPALS_DROP(jsprin) before returning...
bool ok = false;
@ -1443,6 +1446,9 @@ nsJSContext::EvaluateString(const nsAString& aScript,
nsresult rv = sSecurityManager->CanExecuteScripts(mContext, principal, &ok);
if (NS_FAILED(rv)) {
JSPRINCIPALS_DROP(mContext, jsprin);
if (originJSprin) {
JSPRINCIPALS_DROP(mContext, originJSprin);
}
return NS_ERROR_FAILURE;
}
@ -1454,6 +1460,9 @@ nsJSContext::EvaluateString(const nsAString& aScript,
do_GetService("@mozilla.org/js/xpc/ContextStack;1", &rv);
if (NS_FAILED(rv) || NS_FAILED(stack->Push(mContext))) {
JSPRINCIPALS_DROP(mContext, jsprin);
if (originJSprin) {
JSPRINCIPALS_DROP(mContext, originJSprin);
}
return NS_ERROR_FAILURE;
}
@ -1479,11 +1488,14 @@ nsJSContext::EvaluateString(const nsAString& aScript,
if (!ac.enter(mContext, aScopeObject)) {
stack->Pop(nsnull);
JSPRINCIPALS_DROP(mContext, jsprin);
if (originJSprin) {
JSPRINCIPALS_DROP(mContext, originJSprin);
}
return NS_ERROR_FAILURE;
}
ok = JS_EvaluateUCScriptForPrincipalsVersion(
mContext, aScopeObject, jsprin,
ok = JS_EvaluateUCScriptForPrincipalsVersionOrigin(
mContext, aScopeObject, jsprin, originJSprin,
static_cast<const jschar*>(PromiseFlatString(aScript).get()),
aScript.Length(), aURL, aLineNo, vp, JSVersion(aVersion));
@ -1498,6 +1510,9 @@ nsJSContext::EvaluateString(const nsAString& aScript,
// Whew! Finally done with these manually ref-counted things.
JSPRINCIPALS_DROP(mContext, jsprin);
if (originJSprin) {
JSPRINCIPALS_DROP(mContext, originJSprin);
}
// If all went well, convert val to a string if one is wanted.
if (ok) {

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

@ -75,6 +75,7 @@ public:
virtual nsresult EvaluateString(const nsAString& aScript,
JSObject* aScopeObject,
nsIPrincipal *principal,
nsIPrincipal *originPrincipal,
const char *aURL,
PRUint32 aLineNo,
PRUint32 aVersion,

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

@ -360,6 +360,7 @@ nsresult nsJSThunk::EvaluateScript(nsIChannel *aChannel,
rv = scriptContext->EvaluateString(NS_ConvertUTF8toUTF16(script),
globalJSObject, // obj
principal,
principal,
mURL.get(), // url
1, // line no
nsnull,

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

@ -41,6 +41,7 @@ srcdir = @srcdir@
VPATH = \
$(srcdir) \
$(srcdir)/android \
$(srcdir)/gonk \
$(srcdir)/fallback \
$(srcdir)/sandbox \
$(srcdir)/linux \
@ -70,6 +71,8 @@ CPPSRCS = \
ifeq (android,$(MOZ_WIDGET_TOOLKIT))
CPPSRCS += AndroidHal.cpp
else ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
CPPSRCS += GonkHal.cpp
else ifeq (Linux,$(OS_TARGET))
CPPSRCS += LinuxHal.cpp
ifdef MOZ_ENABLE_DBUS

273
hal/gonk/GonkHal.cpp Normal file
Просмотреть файл

@ -0,0 +1,273 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=8 et ft=cpp : */
/* ***** 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 Mozilla Code.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Chris Jones <jones.chris.g@gmail.com>
* Michael Wu <mwu@mozilla.com>
* Justin Lebar <justin.lebar@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 "hardware_legacy/uevent.h"
#include "Hal.h"
#include "mozilla/dom/battery/Constants.h"
#include "mozilla/FileUtils.h"
#include "nsAlgorithm.h"
#include "nsThreadUtils.h"
#include <stdio.h>
#include <math.h>
#include <fcntl.h>
#include <errno.h>
using mozilla::hal::WindowIdentifier;
namespace mozilla {
namespace hal_impl {
void
Vibrate(const nsTArray<uint32>& pattern, const WindowIdentifier &)
{}
void
CancelVibrate(const WindowIdentifier &)
{}
namespace {
class BatteryUpdater : public nsRunnable {
public:
NS_IMETHOD Run()
{
hal::BatteryInformation info;
hal_impl::GetCurrentBatteryInformation(&info);
hal::NotifyBatteryChange(info);
return NS_OK;
}
};
class UEventWatcher : public nsRunnable {
public:
UEventWatcher()
: mUpdater(new BatteryUpdater())
, mRunning(false)
{
}
NS_IMETHOD Run()
{
while (mRunning) {
char buf[1024];
int count = uevent_next_event(buf, sizeof(buf) - 1);
if (!count) {
NS_WARNING("uevent_next_event() returned 0!");
continue;
}
buf[sizeof(buf) - 1] = 0;
if (strstr(buf, "battery"))
NS_DispatchToMainThread(mUpdater);
}
return NS_OK;
}
bool mRunning;
private:
nsRefPtr<BatteryUpdater> mUpdater;
};
} // anonymous namespace
static bool sUEventInitialized = false;
static UEventWatcher *sWatcher = NULL;
static nsIThread *sWatcherThread = NULL;
void
EnableBatteryNotifications()
{
if (!sUEventInitialized)
sUEventInitialized = uevent_init();
if (!sUEventInitialized) {
NS_WARNING("uevent_init() failed!");
return;
}
if (!sWatcher)
sWatcher = new UEventWatcher();
NS_ADDREF(sWatcher);
sWatcher->mRunning = true;
nsresult rv = NS_NewThread(&sWatcherThread, sWatcher);
if (NS_FAILED(rv))
NS_WARNING("Failed to get new thread for uevent watching");
}
void
DisableBatteryNotifications()
{
sWatcher->mRunning = false;
sWatcherThread->Shutdown();
NS_IF_RELEASE(sWatcherThread);
delete sWatcher;
}
void
GetCurrentBatteryInformation(hal::BatteryInformation* aBatteryInfo)
{
FILE *capacityFile = fopen("/sys/class/power_supply/battery/capacity", "r");
double capacity = dom::battery::kDefaultLevel * 100;
if (capacityFile)
fscanf(capacityFile, "%lf", &capacity);
fclose(capacityFile);
FILE *chargingFile = fopen("/sys/class/power_supply/battery/charging_source", "r");
int chargingSrc = 1;
if (chargingFile)
fscanf(chargingFile, "%d", &chargingSrc);
fclose(chargingFile);
aBatteryInfo->level() = capacity / 100;
aBatteryInfo->charging() = chargingSrc == 1;
aBatteryInfo->remainingTime() = dom::battery::kUnknownRemainingTime;
}
namespace {
/**
* RAII class to help us remember to close file descriptors.
*/
const char *screenEnabledFilename = "/sys/power/state";
const char *screenBrightnessFilename = "/sys/class/backlight/pwm-backlight/brightness";
template<ssize_t n>
bool ReadFromFile(const char *filename, char (&buf)[n])
{
int fd = open(filename, O_RDONLY);
ScopedClose autoClose(fd);
if (fd < 0) {
HAL_LOG(("Unable to open file %s.", filename));
return false;
}
ssize_t numRead = read(fd, buf, n);
if (numRead < 0) {
HAL_LOG(("Error reading from file %s.", filename));
return false;
}
buf[PR_MIN(numRead, n - 1)] = '\0';
return true;
}
void WriteToFile(const char *filename, const char *toWrite)
{
int fd = open(filename, O_WRONLY);
ScopedClose autoClose(fd);
if (fd < 0) {
HAL_LOG(("Unable to open file %s.", filename));
return;
}
if (write(fd, toWrite, strlen(toWrite)) < 0) {
HAL_LOG(("Unable to write to file %s.", filename));
return;
}
}
// We can write to screenEnabledFilename to enable/disable the screen, but when
// we read, we always get "mem"! So we have to keep track ourselves whether
// the screen is on or not.
bool sScreenEnabled = true;
} // anonymous namespace
bool
GetScreenEnabled()
{
return sScreenEnabled;
}
void
SetScreenEnabled(bool enabled)
{
WriteToFile(screenEnabledFilename, enabled ? "on" : "mem");
sScreenEnabled = enabled;
}
double
GetScreenBrightness()
{
char buf[32];
ReadFromFile(screenBrightnessFilename, buf);
errno = 0;
unsigned long val = strtoul(buf, NULL, 10);
if (errno) {
HAL_LOG(("Cannot parse contents of %s; expected an unsigned "
"int, but contains \"%s\".",
screenBrightnessFilename, buf));
return 1;
}
if (val > 255) {
HAL_LOG(("Got out-of-range brightness %d, truncating to 1.0", val));
val = 255;
}
return val / 255.0;
}
void
SetScreenBrightness(double brightness)
{
// Don't use De Morgan's law to push the ! into this expression; we want to
// catch NaN too.
if (!(0 <= brightness && brightness <= 1)) {
HAL_LOG(("SetScreenBrightness: Dropping illegal brightness %f.",
brightness));
return;
}
// Convert the value in [0, 1] to an int between 0 and 255, then write to a
// string.
int val = static_cast<int>(round(brightness * 255));
char str[4];
DebugOnly<int> numChars = snprintf(str, sizeof(str), "%d", val);
MOZ_ASSERT(numChars < static_cast<int>(sizeof(str)));
WriteToFile(screenBrightnessFilename, str);
}
} // hal_impl
} // mozilla

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

@ -37,18 +37,6 @@
#ifndef ubase_h__
#define ubase_h__
#ifdef _WIN32
#ifndef NS_WIN32
#define NS_WIN32 1
#endif
#endif
#if defined(__unix)
#ifndef NS_UNIX
#define NS_UNIX 1
#endif
#endif
#include "prtypes.h"
#define PRIVATE

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

@ -97,7 +97,10 @@ BumpChunk::tryAllocUnaligned(size_t n)
if (newBump > limit)
return NULL;
JS_ASSERT(canAllocUnaligned(n));
if (JS_UNLIKELY(newBump < oldBump))
return NULL;
JS_ASSERT(canAllocUnaligned(n)); /* Ensure consistency between "can" and "try". */
setBump(newBump);
return oldBump;
}

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

@ -695,6 +695,9 @@ JS_XDRFunctionObject(JSXDRState *xdr, JSObject **objp)
fstate.filename = fun->script()->filename;
}
if (!JS_XDRCStringOrNull(xdr, (char **) &fstate.filename))
return false;
return js_XDRFunctionObject(xdr, objp);
}

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

@ -9,6 +9,7 @@ script regress-576828.js
script regress-613820-1.js
script regress-613820-2.js
script regress-613820-3.js
script regress-429241.js
silentfail skip-if(!xulRuntime.shell&&(Android||xulRuntime.OS=="WINNT")) script regress-617935.js
script instance-property-storage-introspection.js
script regexp-space-character-class.js

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

@ -0,0 +1,233 @@
/* ***** 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 JavaScript Engine testing utilities.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* <x00000000@freenet.de>
*
* 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 ***** */
var gTestfile = 'regress-429241.js';
var BUGNUMBER = 429241;
var summary = '\\x or \\u followed by too few hex digits';
var r;
reportCompare(
"x",
(r = /[\x]+/.exec("\\x\0")) && r[0],
"Section 1"
);
reportCompare(
"xy",
(r = /[\xy]+/.exec("\\xy\0")) && r[0],
"Section 2"
);
reportCompare(
"x0",
(r = /[\x0]+/.exec("\\x0\0")) && r[0],
"Section 3"
);
reportCompare(
"x0y",
(r = /[\x0y]+/.exec("\\x0y\0")) && r[0],
"Section 4"
);
reportCompare(
"\0",
(r = /[\x00]+/.exec("\\x\0")) && r[0],
"Section 5"
);
reportCompare(
"0\0",
(r = /[\x000]+/.exec("0\0")) && r[0],
"Section 6"
);
reportCompare(
"x",
(r = /^\x$/.exec("x")) && r[0],
"Section 7"
);
reportCompare(
"xy",
(r = /^\xy$/.exec("xy")) && r[0],
"Section 8"
);
reportCompare(
"x0",
(r = /^\x0$/.exec("x0")) && r[0],
"Section 9"
);
reportCompare(
"x0y",
(r = /^\x0y$/.exec("x0y")) && r[0],
"Section 10"
);
reportCompare(
null,
/^\x00$/.exec("\0" + "0"),
"Section 11"
);
reportCompare(
"\0" + "0",
(r = /^\x000$/.exec("\0" + "0")) && r[0],
"Section 12"
);
reportCompare(
"u",
(r = /[\u]+/.exec("\\u\0")) && r[0],
"Section 13"
);
reportCompare(
"uy",
(r = /[\uy]+/.exec("\\uy\0")) && r[0],
"Section 14"
);
reportCompare(
"u0",
(r = /[\u0]+/.exec("\\u0\0")) && r[0],
"Section 15"
);
reportCompare(
"u0",
(r = /[\u00]+/.exec("\\u0\0")) && r[0],
"Section 16"
);
reportCompare(
"u0",
(r = /[\u000]+/.exec("\\u0\0")) && r[0],
"Section 17"
);
reportCompare(
"u0y",
(r = /[\u0y]+/.exec("\\u0y\0")) && r[0],
"Section 18"
);
reportCompare(
"u0y",
(r = /[\u00y]+/.exec("\\u0y\0")) && r[0],
"Section 19"
);
reportCompare(
"u0y",
(r = /[\u000y]+/.exec("\\u0y\0")) && r[0],
"Section 20"
);
reportCompare(
"\0",
(r = /[\u0000]+/.exec("\\u\0")) && r[0],
"Section 21"
);
reportCompare(
"0\0",
(r = /[\u00000]+/.exec("0\0")) && r[0],
"Section 22"
);
reportCompare(
"u",
(r = /^\u$/.exec("u")) && r[0],
"Section 23"
);
reportCompare(
"uy",
(r = /^\uy$/.exec("uy")) && r[0],
"Section 24"
);
reportCompare(
"u0",
(r = /^\u0$/.exec("u0")) && r[0],
"Section 25"
);
reportCompare(
"u00",
(r = /^\u00$/.exec("u00")) && r[0],
"Section 26"
);
reportCompare(
"u000",
(r = /^\u000$/.exec("u000")) && r[0],
"Section 27"
);
reportCompare(
"u0y",
(r = /^\u0y$/.exec("u0y")) && r[0],
"Section 28"
);
reportCompare(
"u00y",
(r = /^\u00y$/.exec("u00y")) && r[0],
"Section 29"
);
reportCompare(
"u000y",
(r = /^\u000y$/.exec("u000y")) && r[0],
"Section 30"
);
reportCompare(
null,
/^\u0000$/.exec("\0" + "0"),
"Section 31"
);
reportCompare(
"\0" + "0",
(r = /^\u00000$/.exec("\0" + "0")) && r[0],
"Section 32"
);

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

@ -149,7 +149,7 @@ script regress-326453.js
script regress-326467.js
script regress-328012.js
script regress-328664.js
script regress-328897.js
fails-if(browserIsRemote) script regress-328897.js
script regress-329383.js
skip-if(Android) script regress-329530.js
skip-if(Android) script regress-330352.js

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

@ -51,7 +51,7 @@ if (typeof window == 'undefined')
}
else
{
expect = /(Script error.|uncaught exception: Permission denied to get property UnnamedClass.classes)/;
expect = /(Script error.|Permission denied for <file:\/\/> to get property XPCComponents.classes)/;
window._onerror = window.onerror;
window.onerror = (function (msg, page, line) {

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

@ -628,7 +628,12 @@ XPC_WN_NoHelper_Finalize(JSContext *cx, JSObject *obj)
nsWrapperCache* cache;
CallQueryInterface(p, &cache);
cache->ClearWrapper();
NS_RELEASE(p);
XPCJSRuntime *rt = nsXPConnect::GetRuntimeInstance();
if(rt)
rt->DeferredRelease(p);
else
NS_RELEASE(p);
return;
}

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

@ -3771,13 +3771,9 @@ DocumentViewerImpl::PrintPreviewNavigate(PRInt16 aType, PRInt32 aPageNum)
// Now, locate the current page we are on and
// and the page of the page number
nscoord gap = 0;
nsIFrame* pageFrame = seqFrame->GetFirstPrincipalChild();
while (pageFrame != nsnull) {
nsRect pageRect = pageFrame->GetRect();
if (pageNum == 1) {
gap = pageRect.y;
}
if (pageRect.Contains(pageRect.x, pt.y)) {
currentPage = pageFrame;
}

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

@ -4227,7 +4227,7 @@ nsLayoutUtils::GetFontFacesForFrames(nsIFrame* aFrame,
while (aFrame) {
nsIFrame::ChildListID childLists[] = { nsIFrame::kPrincipalList,
nsIFrame::kPopupList };
for (int i = 0; i < ArrayLength(childLists); ++i) {
for (size_t i = 0; i < ArrayLength(childLists); ++i) {
nsFrameList children(aFrame->GetChildList(childLists[i]));
for (nsFrameList::Enumerator e(children); !e.AtEnd(); e.Next()) {
nsIFrame* child = e.get();
@ -4506,9 +4506,14 @@ MinimumFontSizeFor(nsPresContext* aPresContext, nscoord aContainerWidth)
if (sFontSizeInflationEmPerLine == 0 && sFontSizeInflationMinTwips == 0) {
return 0;
}
// Clamp the container width to the device dimensions
nscoord iFrameWidth = aPresContext->GetVisibleArea().width;
nscoord effectiveContainerWidth = NS_MIN(iFrameWidth, aContainerWidth);
nscoord byLine = 0, byInch = 0;
if (sFontSizeInflationEmPerLine != 0) {
byLine = aContainerWidth / sFontSizeInflationEmPerLine;
byLine = effectiveContainerWidth / sFontSizeInflationEmPerLine;
}
if (sFontSizeInflationMinTwips != 0) {
// REVIEW: Is this giving us app units and sizes *not* counting
@ -4518,7 +4523,7 @@ MinimumFontSizeFor(nsPresContext* aPresContext, nscoord aContainerWidth)
dx->GetClientRect(clientRect); // FIXME: GetClientRect looks expensive
float deviceWidthInches =
float(clientRect.width) / float(dx->AppUnitsPerPhysicalInch());
byInch = NSToCoordRound(aContainerWidth /
byInch = NSToCoordRound(effectiveContainerWidth /
(deviceWidthInches * 1440 /
sFontSizeInflationMinTwips ));
}

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

@ -491,22 +491,24 @@ nsPresContext::GetFontPreferences()
mMinimumFontSizePref = CSSPointsToAppUnits(size);
}
nsFont* fontTypes[] = {
&mDefaultVariableFont,
&mDefaultFixedFont,
&mDefaultSerifFont,
&mDefaultSansSerifFont,
&mDefaultMonospaceFont,
&mDefaultCursiveFont,
&mDefaultFantasyFont
};
PR_STATIC_ASSERT(NS_ARRAY_LENGTH(fontTypes) == eDefaultFont_COUNT);
// get attributes specific to each generic font
nsCAutoString generic_dot_langGroup;
for (PRInt32 eType = eDefaultFont_Variable; eType < eDefaultFont_COUNT; ++eType) {
for (PRUint32 eType = 0; eType < ArrayLength(fontTypes); ++eType) {
generic_dot_langGroup.Assign(kGenericFont[eType]);
generic_dot_langGroup.Append(langGroup);
nsFont* font;
switch (eType) {
case eDefaultFont_Variable: font = &mDefaultVariableFont; break;
case eDefaultFont_Fixed: font = &mDefaultFixedFont; break;
case eDefaultFont_Serif: font = &mDefaultSerifFont; break;
case eDefaultFont_SansSerif: font = &mDefaultSansSerifFont; break;
case eDefaultFont_Monospace: font = &mDefaultMonospaceFont; break;
case eDefaultFont_Cursive: font = &mDefaultCursiveFont; break;
case eDefaultFont_Fantasy: font = &mDefaultFantasyFont; break;
}
nsFont* font = fontTypes[eType];
// set the default variable font (the other fonts are seen as 'generic' fonts
// in GFX and will be queried there when hunting for alternative fonts)

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

@ -619,6 +619,7 @@ TestPage(const char *pagelabel, uintptr_t pageaddr, int should_succeed)
case 2: *(volatile unsigned char *)opaddr = 0; break;
default: abort();
}
(void)scratch;
_exit(0);
} else {
int status;

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

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

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

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

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

@ -0,0 +1,15 @@
<!DOCTYPE HTML>
<style>
div { background: yellow }
div { font-size: 20px; line-height: 1.0; width: 450px }
</style>
<!--
Without the patch for bug 707855, we have a 450px container, and the minimum font size
at 15em per line is 30px. This means we map 0px-45px into 30px-45px, so 12px gets mapped
to 34px.
With the patch, then we have a 240px container, so the minimum font size
at 15 em per line is 16px. So, we map 0px-24px into 16px-24px, so 12px gets
mapped to 20px.
-->
<div>Test to see if too large of a container causes a giant escalation of the font size when font inflation is enabled.</div>

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

@ -0,0 +1,15 @@
<!DOCTYPE HTML>
<style>
div { background: yellow }
div { font-size: 12px; line-height: 1.0; width: 450px }
</style>
<!--
Without the patch for bug 707855, we have a 450px container, and the minimum font size
at 15em per line is 30px. This means we map 0px-45px into 30px-45px, so 12px gets mapped
to 34px.
With the patch, then we have a 240px container, so the minimum font size
at 15 em per line is 16px. So, we map 0px-24px into 16px-24px, so 12px gets
mapped to 20px.
-->
<div>Test to see if too large of a container causes a giant escalation of the font size when font inflation is enabled.</div>

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

@ -0,0 +1,16 @@
<!DOCTYPE HTML>
<style>
div { background: yellow }
div { font-size: 12px; line-height: 1.0; width: 1200px }
</style>
<!--
Without the patch for bug 707855, we have a 450px container, and the minimum font size
at 15em per line is 30px. This means we map 0px-45px into 30px-45px, so 12px gets mapped
to 34px.
With the patch, then we have a 240px container, so the minimum font size
at 15 em per line is 16px. So, we map 0px-24px into 16px-24px, so 12px gets
mapped to 20px.
-->
<iframe src="container-with-clamping-innerFrame-ref.html" width="240" height="400">
</iframe>

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

@ -0,0 +1,12 @@
<!DOCTYPE HTML>
<!--
Without the patch for bug 707855, we have a 450px container, and the minimum font size
at 15em per line is 30px. This means we map 0px-45px into 30px-45px, so 12px gets mapped
to 34px.
With the patch, then we have a 240px container, so the minimum font size
at 15 em per line is 16px. So, we map 0px-24px into 16px-24px, so 12px gets
mapped to 20px.
-->
<iframe src="container-with-clamping-innerFrame.html" width="240" height="400">
</iframe>

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

@ -45,6 +45,7 @@ var gTests = [
"== textarea-3.html textarea-3-ref.html",
"== css-transform-1.html css-transform-1-ref.html",
"== css-transform-2.html css-transform-2-ref.html",
"== container-with-clamping.html container-with-clamping-ref.html",
];
// Maintain a reference count of how many things we're waiting for until

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

@ -410,7 +410,7 @@ nsBlockFrame::List(FILE* out, PRInt32 aIndent) const
// Output the rect and state
fprintf(out, " {%d,%d,%d,%d}", mRect.x, mRect.y, mRect.width, mRect.height);
if (0 != mState) {
fprintf(out, " [state=%016llx]", mState);
fprintf(out, " [state=%016llx]", (unsigned long long)mState);
}
nsBlockFrame* f = const_cast<nsBlockFrame*>(this);
if (f->HasOverflowAreas()) {
@ -7077,16 +7077,12 @@ nsBlockFrame::VerifyLines(bool aFinalCheckOK)
// Add up the counts on each line. Also validate that IsFirstLine is
// set properly.
PRInt32 count = 0;
bool seenBlock = false;
line_iterator line, line_end;
for (line = begin_lines(), line_end = end_lines();
line != line_end;
++line) {
if (aFinalCheckOK) {
NS_ABORT_IF_FALSE(line->GetChildCount(), "empty line");
if (line->IsBlock()) {
seenBlock = true;
}
if (line->IsBlock()) {
NS_ASSERTION(1 == line->GetChildCount(), "bad first line");
}

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

@ -1743,7 +1743,7 @@ nsContainerFrame::List(FILE* out, PRInt32 aIndent) const
}
fprintf(out, " {%d,%d,%d,%d}", mRect.x, mRect.y, mRect.width, mRect.height);
if (0 != mState) {
fprintf(out, " [state=%016llx]", mState);
fprintf(out, " [state=%016llx]", (unsigned long long)mState);
}
fprintf(out, " [content=%p]", static_cast<void*>(mContent));
nsContainerFrame* f = const_cast<nsContainerFrame*>(this);

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

@ -5054,7 +5054,7 @@ nsFrame::List(FILE* out, PRInt32 aIndent) const
}
fprintf(out, " {%d,%d,%d,%d}", mRect.x, mRect.y, mRect.width, mRect.height);
if (0 != mState) {
fprintf(out, " [state=%016llx]", mState);
fprintf(out, " [state=%016llx]", (unsigned long long)mState);
}
nsIFrame* prevInFlow = GetPrevInFlow();
nsIFrame* nextInFlow = GetNextInFlow();
@ -5276,7 +5276,7 @@ nsFrame::DumpRegressionData(nsPresContext* aPresContext, FILE* out, PRInt32 aInd
XMLQuote(name);
fputs(NS_LossyConvertUTF16toASCII(name).get(), out);
fprintf(out, "\" state=\"%016llx\" parent=\"%ld\">\n",
GetDebugStateBits(), PRUptrdiff(mParent));
(unsigned long long)GetDebugStateBits(), PRUptrdiff(mParent));
aIndent++;
DumpBaseRegressionData(aPresContext, out, aIndent);

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

@ -844,7 +844,6 @@ nsHTMLScrollFrame::Reflow(nsPresContext* aPresContext,
state.mStyles.mHorizontal = NS_STYLE_OVERFLOW_HIDDEN;
//------------ Handle Incremental Reflow -----------------
bool reflowContents = true; // XXX Ignored
bool reflowHScrollbar = true;
bool reflowVScrollbar = true;
bool reflowScrollCorner = true;
@ -852,7 +851,6 @@ nsHTMLScrollFrame::Reflow(nsPresContext* aPresContext,
#define NEEDS_REFLOW(frame_) \
((frame_) && NS_SUBTREE_DIRTY(frame_))
reflowContents = NEEDS_REFLOW(mInner.mScrolledFrame);
reflowHScrollbar = NEEDS_REFLOW(mInner.mHScrollbarBox);
reflowVScrollbar = NEEDS_REFLOW(mInner.mVScrollbarBox);
reflowScrollCorner = NEEDS_REFLOW(mInner.mScrollCornerBox) ||
@ -1638,7 +1636,8 @@ CanScrollWithBlitting(nsIFrame* aFrame)
return false;
}
nsIScrollableFrame* sf = do_QueryFrame(f);
if (sf && nsLayoutUtils::HasNonZeroCorner(f->GetStyleBorder()->mBorderRadius))
if ((sf || f->IsFrameOfType(nsIFrame::eReplaced)) &&
nsLayoutUtils::HasNonZeroCorner(f->GetStyleBorder()->mBorderRadius))
return false;
if (nsLayoutUtils::IsPopup(f))
break;

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

@ -1684,7 +1684,7 @@ nsImageFrame::List(FILE* out, PRInt32 aIndent) const
}
fprintf(out, " {%d,%d,%d,%d}", mRect.x, mRect.y, mRect.width, mRect.height);
if (0 != mState) {
fprintf(out, " [state=%016llx]", mState);
fprintf(out, " [state=%016llx]", (unsigned long long)mState);
}
fprintf(out, " [content=%p]", (void*)mContent);
fprintf(out, " [sc=%p]", static_cast<void*>(mStyleContext));

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

@ -1801,20 +1801,17 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd)
// Compute the logical height of the frame
nscoord logicalHeight;
nscoord topLeading;
PerSpanData* frameSpan = pfd->mSpan;
if (frameSpan) {
// For span frames the logical-height and top-leading was
// pre-computed when the span was reflowed.
logicalHeight = frameSpan->mLogicalHeight;
topLeading = frameSpan->mTopLeading;
}
else {
// For other elements the logical height is the same as the
// frames height plus its margins.
logicalHeight = pfd->mBounds.height + pfd->mMargin.top +
pfd->mMargin.bottom;
topLeading = 0;
}
// Get vertical-align property
@ -2042,7 +2039,7 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd)
pfd->mAscent, pfd->mBounds.height,
pfd->mBorderPadding.top, pfd->mBorderPadding.bottom,
logicalHeight,
pfd->mSpan ? topLeading : 0,
frameSpan ? frameSpan->mTopLeading : 0,
pfd->mBounds.y, minY, maxY);
#endif
}

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

@ -1420,6 +1420,8 @@ nsObjectFrame::PrintPlugin(nsRenderingContext& aRenderingContext,
/* XXX this just flat-out doesn't work in a thebes world --
* RenderEPS is a no-op. So don't bother to do any work here.
*/
(void)window;
(void)npprint;
#elif defined(XP_OS2)
void *hps = GetPSFromRC(aRenderingContext);

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

@ -260,7 +260,7 @@ nsPlaceholderFrame::List(FILE* out, PRInt32 aIndent) const
}
fprintf(out, " {%d,%d,%d,%d}", mRect.x, mRect.y, mRect.width, mRect.height);
if (0 != mState) {
fprintf(out, " [state=%016llx]", mState);
fprintf(out, " [state=%016llx]", (unsigned long long)mState);
}
nsIFrame* prevInFlow = GetPrevInFlow();
nsIFrame* nextInFlow = GetNextInFlow();

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

@ -4691,10 +4691,8 @@ nsTypedSelection::DoAutoScroll(nsIFrame *aFrame, nsPoint& aPoint)
{
NS_PRECONDITION(aFrame, "Need a frame");
nsresult result = NS_OK;
if (mAutoScrollTimer)
result = mAutoScrollTimer->Stop();
(void)mAutoScrollTimer->Stop();
nsPresContext* presContext = aFrame->PresContext();
nsRootPresContext* rootPC = presContext->GetRootPresContext();

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

@ -1755,7 +1755,6 @@ BuildTextRunsScanner::BuildTextRunForFrames(void* aTextBuffer)
const void* textPtr = aTextBuffer;
bool anySmallcapsStyle = false;
bool anyTextTransformStyle = false;
PRInt32 endOfLastContent = 0;
PRUint32 textFlags = nsTextFrameUtils::TEXT_NO_BREAKS;
if (mCurrentRunContextInfo & nsTextFrameUtils::INCOMING_WHITESPACE) {
@ -1874,8 +1873,6 @@ BuildTextRunsScanner::BuildTextRunForFrames(void* aTextBuffer)
currentTransformedTextOffset =
(static_cast<const PRUint8*>(aTextBuffer) - static_cast<const PRUint8*>(textPtr)) >> mDoubleByteText;
endOfLastContent = contentEnd;
}
// Check for out-of-memory in gfxSkipCharsBuilder
@ -7053,7 +7050,7 @@ class NS_STACK_CLASS ReflowTextA11yNotifier
{
public:
ReflowTextA11yNotifier(nsPresContext* aPresContext, nsIContent* aContent) :
mPresContext(aPresContext), mContent(aContent)
mContent(aContent), mPresContext(aPresContext)
{
}
~ReflowTextA11yNotifier()
@ -7947,7 +7944,7 @@ nsTextFrame::List(FILE* out, PRInt32 aIndent) const
// Output the rect and state
fprintf(out, " {%d,%d,%d,%d}", mRect.x, mRect.y, mRect.width, mRect.height);
fprintf(out, " [state=%016llx]", mState);
fprintf(out, " [state=%016llx]", (unsigned long long)mState);
if (IsSelected()) {
fprintf(out, " SELECTED");
}

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

@ -0,0 +1,13 @@
<!DOCTYPE HTML>
<html>
<body onload="doTest()">
<iframe src="data:text/html,<body style='font-size:100px; overflow:hidden'><p>Hello<p>Kitty<p>Hello<p>Kitty<p>Hello<p>Kitty<p>Hello<p>Kitty<p>Hello<p>Kitty<p>Hello<p>Kitty"
id="f" style="width:500px; height:500px; border-radius:100px; border:none;"></iframe>
<script>
var f = document.getElementById("f");
function doTest() {
f.contentWindow.scrollTo(0, 80);
}
</script>
</body>
</html>

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

@ -0,0 +1,21 @@
<!DOCTYPE HTML>
<html class="reftest-wait">
<body>
<iframe src="data:text/html,<body style='font-size:100px; overflow:hidden'><p>Hello<p>Kitty<p>Hello<p>Kitty<p>Hello<p>Kitty<p>Hello<p>Kitty<p>Hello<p>Kitty<p>Hello<p>Kitty"
id="f" style="width:500px; height:500px; border-radius:100px; border:none;"></iframe>
<script>
var f = document.getElementById("f");
var count = 0;
function doTest() {
++count;
f.contentWindow.scrollTo(0, count*20);
if (count == 4) {
document.documentElement.removeAttribute("class");
} else {
setTimeout(doTest, 20);
}
}
document.addEventListener("MozReftestInvalidate", doTest, false);
</script>
</body>
</html>

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

@ -3,6 +3,7 @@ HTTP == fixed-opacity-1.html fixed-opacity-1.html?ref
HTTP == fixed-opacity-2.html fixed-opacity-2.html?ref
HTTP == fixed-text-1.html fixed-text-1.html?ref
HTTP == fixed-text-2.html fixed-text-2.html?ref
== iframe-border-radius.html iframe-border-radius-ref.html
HTTP == opacity-mixed-scrolling-1.html opacity-mixed-scrolling-1.html?ref
random-if(cocoaWidget) HTTP == opacity-mixed-scrolling-2.html opacity-mixed-scrolling-2.html?ref # see bug 625357
HTTP == simple-1.html simple-1.html?ref

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

@ -463,6 +463,7 @@ nsStyleAnimation::ComputeDistance(nsCSSProperty aProperty,
break;
}
case eCSSUnit_Null:
diffsquared = 0;
break;
default:
NS_ABORT_IF_FALSE(false, "unexpected unit");

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

@ -2586,13 +2586,10 @@ void nsCellMap::Dump(bool aIsBorderCollapse) const
if (cd->IsOrig()) {
printf("C%d,%d ", rowIndex, colIndex);
} else {
nsTableCellFrame* cell = nsnull;
if (cd->IsRowSpan()) {
cell = GetCellFrame(rowIndex, colIndex, *cd, true);
printf("R ");
}
if (cd->IsColSpan()) {
cell = GetCellFrame(rowIndex, colIndex, *cd, false);
printf("C ");
}
if (!(cd->IsRowSpan() && cd->IsColSpan())) {

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

@ -5544,7 +5544,6 @@ nsTableFrame::CalcBCBorders()
BCMapCellIterator iter(this, damageArea);
for (iter.First(info); !iter.mAtEnd; iter.Next(info)) {
bool bottomRowSpan = false;
// see if lastTopBorder, lastBottomBorder need to be reset
if (iter.IsNewRow()) {
gotRowBorder = false;
@ -5561,7 +5560,6 @@ nsTableFrame::CalcBCBorders()
if (lastBottomBorder.rowIndex > (info.GetCellEndRowIndex() + 1)) {
// the bottom border's left edge butts against the middle of a rowspan
lastBottomBorder.Reset(info.GetCellEndRowIndex() + 1, info.mRowSpan);
bottomRowSpan = true;
}
}
@ -7058,8 +7056,9 @@ BCPaintBorderIterator::VerticalSegmentOwnsCorner()
{
mozilla::css::Side cornerOwnerSide = NS_SIDE_TOP;
bool bevel = false;
nscoord cornerSubWidth;
cornerSubWidth = (mBCData) ? mBCData->GetCorner(cornerOwnerSide, bevel) : 0;
if (mBCData) {
mBCData->GetCorner(cornerOwnerSide, bevel);
}
// unitialized ownerside, bevel
return (NS_SIDE_TOP == cornerOwnerSide) ||
(NS_SIDE_BOTTOM == cornerOwnerSide);

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

@ -52,6 +52,11 @@ ifdef XPI_NAME
NO_JS_MANIFEST = 1
DIST_FILES = install.rdf
ifeq ($(MOZ_BUILD_APP),mobile/android)
DEFINES += -DBOOTSTRAP
DIST_FILES += bootstrap.js
endif
# Used in install.rdf
USE_EXTENSION_MANIFEST=1
else

80
layout/tools/reftest/bootstrap.js поставляемый Normal file
Просмотреть файл

@ -0,0 +1,80 @@
Components.utils.import("resource://gre/modules/FileUtils.jsm");
function loadIntoWindow(window) {}
function unloadFromWindow(window) {}
function setDefaultPrefs() {
// This code sets the preferences for extension-based reftest; for
// command-line based reftest they are set in function handler_handle in
// reftest-cmdline.js. These two locations should stay in sync.
//
// FIXME: These should be in only one place.
var prefs = Components.classes["@mozilla.org/preferences-service;1"].
getService(Components.interfaces.nsIPrefService);
var branch = prefs.getDefaultBranch("");
branch.setBoolPref("gfx.color_management.force_srgb", true);
branch.setBoolPref("browser.dom.window.dump.enabled", true);
branch.setIntPref("ui.caretBlinkTime", -1);
branch.setBoolPref("dom.send_after_paint_to_content", true);
// no slow script dialogs
branch.setIntPref("dom.max_script_run_time", 0);
branch.setIntPref("dom.max_chrome_script_run_time", 0);
branch.setIntPref("hangmonitor.timeout", 0);
}
var windowListener = {
onOpenWindow: function(aWindow) {
let domWindow = aWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMWindowInternal || Components.interfaces.nsIDOMWindow);
domWindow.addEventListener("load", function() {
domWindow.removeEventListener("load", arguments.callee, false);
let wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator);
// Load into any existing windows
let enumerator = wm.getEnumerator("navigator:browser");
while (enumerator.hasMoreElements()) {
let win = enumerator.getNext().QueryInterface(Components.interfaces.nsIDOMWindow);
setDefaultPrefs();
Components.utils.import("chrome://reftest/content/reftest.jsm");
win.addEventListener("UIReady", function() {OnRefTestLoad(win);});
break;
}
}, false);
},
onCloseWindow: function(aWindow){ },
onWindowTitleChange: function(){ },
};
function startup(aData, aReason) {
let wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
getService (Components.interfaces.nsIWindowMediator);
Components.manager.addBootstrappedManifestLocation(aData.installPath);
// Load into any new windows
wm.addListener(windowListener);
}
function shutdown(aData, aReason) {
// When the application is shutting down we normally don't have to clean up any UI changes
if (aReason == APP_SHUTDOWN)
return;
let wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
getService(Components.interfaces.nsIWindowMediator);
// Stop watching for new windows
wm.removeListener(windowListener);
// Unload from any existing windows
let enumerator = wm.getEnumerator("navigator:browser");
while (enumerator.hasMoreElements()) {
let win = enumerator.getNext().QueryInterface(Components.interfaces.nsIDOMWindow);
unloadFromWindow(win);
}
}
function install(aData, aReason) { }
function uninstall(aData, aReason) { }

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

@ -4,6 +4,10 @@
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>reftest@mozilla.org</em:id>
#ifdef BOOTSTRAP
<em:type>2</em:type>
<em:bootstrap>true</em:bootstrap>
#endif
<em:version>1.0</em:version>
<em:targetApplication>
<Description>

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

@ -1,10 +1,14 @@
reftest.jar:
% content reftest %content/
* content/reftest.js (reftest.js)
content/reftest-content.js (reftest-content.js)
#ifdef BOOTSTRAP
* content/reftest.jsm (reftest.js)
#else
* content/reftest.js (reftest.js)
content/reftest.xul (reftest.xul)
#ifdef XPI_NAME
% component {32530271-8c1b-4b7d-a812-218e42c6bb23} components/reftest-cmdline.js
% contract @mozilla.org/commandlinehandler/general-startup;1?type=reftest {32530271-8c1b-4b7d-a812-218e42c6bb23}
% category command-line-handler m-reftest @mozilla.org/commandlinehandler/general-startup;1?type=reftest
#endif
#endif

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

@ -100,6 +100,12 @@ RefTestCmdLineHandler.prototype =
* We want to do this here rather than in reftest.js because it's
* important to force sRGB as an output profile for color management
* before we load a window.
*
* If you change these, please adjust them in the bootstrap.js function
* setDefaultPrefs(). These are duplicated there so we can have a
* restartless addon for reftest on native Android.
*
* FIXME: These should be in only one place.
*/
var prefs = Components.classes["@mozilla.org/preferences-service;1"].
getService(Components.interfaces.nsIPrefService);

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

@ -36,6 +36,11 @@
*
* ***** END LICENSE BLOCK ***** */
#if BOOTSTRAP
var EXPORTED_SYMBOLS = ["OnRefTestLoad"];
#endif
const CC = Components.classes;
const CI = Components.interfaces;
const CR = Components.results;
@ -219,7 +224,7 @@ function IDForEventTarget(event)
}
}
function OnRefTestLoad()
function OnRefTestLoad(win)
{
gCrashDumpDir = CC[NS_DIRECTORY_SERVICE_CONTRACTID]
.getService(CI.nsIProperties)
@ -238,8 +243,11 @@ function OnRefTestLoad()
gBrowserIsRemote = false;
}
if (gContainingWindow == null && window != null) {
gContainingWindow = window;
if (win === undefined || win == null) {
win = window;
}
if (gContainingWindow == null && win != null) {
gContainingWindow = win;
}
gBrowser = gContainingWindow.document.createElementNS(XUL_NS, "xul:browser");
@ -250,7 +258,15 @@ function OnRefTestLoad()
// what size our window is
gBrowser.setAttribute("style", "min-width: 800px; min-height: 1000px; max-width: 800px; max-height: 1000px");
#if BOOTSTRAP
var doc = gContainingWindow.document.getElementById('main-window');
while (doc.hasChildNodes()) {
doc.removeChild(doc.firstChild);
}
doc.appendChild(gBrowser);
#else
document.getElementById("reftest-window").appendChild(gBrowser);
#endif
gBrowserMessageManager = gBrowser.QueryInterface(CI.nsIFrameLoaderOwner)
.frameLoader.messageManager;
@ -285,7 +301,11 @@ function InitAndStartRefTests()
var mfl = FileUtils.openFileOutputStream(f, FileUtils.MODE_WRONLY | FileUtils.MODE_CREATE);
// Set to mirror to stdout as well as the file
gDumpLog = function (msg) {
#if BOOTSTRAP
//NOTE: on android-xul, we have a libc crash if we do a dump with %7s in the string
#else
dump(msg);
#endif
mfl.write(msg, msg.length);
};
}
@ -373,6 +393,38 @@ function StartHTTPServer()
function StartTests()
{
#if BOOTSTRAP
/* These prefs are optional, so we don't need to spit an error to the log */
try {
var prefs = Components.classes["@mozilla.org/preferences-service;1"].
getService(Components.interfaces.nsIPrefBranch2);
} catch(e) {
gDumpLog("REFTEST TEST-UNEXPECTED-FAIL | | EXCEPTION: " + e + "\n");
}
try {
gNoCanvasCache = prefs.getIntPref("reftest.nocache");
} catch(e) {
gNoCanvasCache = false;
}
try {
gRunSlowTests = prefs.getIntPref("reftest.skipslowtests");
} catch(e) {
gRunSlowTests = false;
}
try {
uri = prefs.getCharPref("reftest.uri");
} catch(e) {
uri = "";
}
if (uri == "") {
gDumpLog("REFTEST TEST-UNEXPECTED-FAIL | | Unable to find reftest.uri pref. Please ensure your profile is setup properly\n");
DoneTests();
}
#else
try {
// Need to read the manifest once we have the final HTTP_SERVER_PORT.
var args = window.arguments[0].wrappedJSObject;
@ -383,16 +435,25 @@ function StartTests()
if ("skipslowtests" in args && args.skipslowtests)
gRunSlowTests = false;
ReadTopManifest(args.uri);
uri = args.uri;
} catch (e) {
++gTestResults.Exception;
gDumpLog("REFTEST TEST-UNEXPECTED-FAIL | | EXCEPTION: " + ex + "\n");
DoneTests();
}
#endif
try {
ReadTopManifest(uri);
BuildUseCounts();
if (gTotalChunks > 0 && gThisChunk > 0) {
var testsPerChunk = gURLs.length / gTotalChunks;
var start = Math.round((gThisChunk-1) * testsPerChunk);
var end = Math.round(gThisChunk * testsPerChunk);
gURLs = gURLs.slice(start, end);
gDumpLog("REFTEST INFO | Running chunk " + gThisChunk + " out of " + gTotalChunks + " chunks. ")
gDumpLog("tests " + (start+1) + "-" + end + "/" + gURLs.length + "\n");
var testsPerChunk = gURLs.length / gTotalChunks;
var start = Math.round((gThisChunk-1) * testsPerChunk);
var end = Math.round(gThisChunk * testsPerChunk);
gURLs = gURLs.slice(start, end);
gDumpLog("REFTEST INFO | Running chunk " + gThisChunk + " out of " + gTotalChunks + " chunks. ")
gDumpLog("tests " + (start+1) + "-" + end + "/" + gURLs.length + "\n");
}
gTotalTests = gURLs.length;
@ -417,17 +478,17 @@ function OnRefTestUnload()
// as a string.
function getStreamContent(inputStream)
{
var streamBuf = "";
var sis = CC["@mozilla.org/scriptableinputstream;1"].
createInstance(CI.nsIScriptableInputStream);
sis.init(inputStream);
var streamBuf = "";
var sis = CC["@mozilla.org/scriptableinputstream;1"].
createInstance(CI.nsIScriptableInputStream);
sis.init(inputStream);
var available;
while ((available = sis.available()) != 0) {
streamBuf += sis.read(available);
}
return streamBuf;
var available;
while ((available = sis.available()) != 0) {
streamBuf += sis.read(available);
}
return streamBuf;
}
// Build the sandbox for fails-if(), etc., condition evaluation.
@ -440,16 +501,16 @@ function BuildConditionSandbox(aURL) {
// xr.XPCOMABI throws exception for configurations without full ABI
// support (mobile builds on ARM)
try {
sandbox.xulRuntime.XPCOMABI = xr.XPCOMABI;
sandbox.xulRuntime.XPCOMABI = xr.XPCOMABI;
} catch(e) {
sandbox.xulRuntime.XPCOMABI = "";
sandbox.xulRuntime.XPCOMABI = "";
}
try {
// nsIGfxInfo is currently only implemented on Windows
sandbox.d2d = (NS_GFXINFO_CONTRACTID in CC) && CC[NS_GFXINFO_CONTRACTID].getService(CI.nsIGfxInfo).D2DEnabled;
// nsIGfxInfo is currently only implemented on Windows
sandbox.d2d = (NS_GFXINFO_CONTRACTID in CC) && CC[NS_GFXINFO_CONTRACTID].getService(CI.nsIGfxInfo).D2DEnabled;
} catch(e) {
sandbox.d2d = false;
sandbox.d2d = false;
}
sandbox.layersGPUAccelerated =
@ -515,7 +576,7 @@ function BuildConditionSandbox(aURL) {
sandbox.testPluginIsOOP = function () {
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
} catch (ex) {}
var prefservice = Components.classes["@mozilla.org/preferences-service;1"]
@ -566,7 +627,7 @@ function ReadTopManifest(aFileURL)
gURLs = new Array();
var url = gIOService.newURI(aFileURL, null, null);
if (!url)
throw "Expected a file or http URL for the manifest.";
throw "Expected a file or http URL for the manifest.";
ReadManifest(url, EXPECTED_PASS);
}

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

@ -111,6 +111,10 @@ class RemoteOptions(ReftestOptions):
help = "name of the pidfile to generate")
defaults["pidFile"] = ""
self.add_option("--bootstrap", action="store_true", dest = "bootstrap",
help = "test with a bootstrap addon required for native Fennec")
defaults["bootstrap"] = False
self.add_option("--dm_trans", action="store",
type = "string", dest = "dm_trans",
help = "the transport to use to communicate with device: [adb|sut]; default=sut")
@ -290,13 +294,13 @@ class RemoteReftest(RefTest):
localAutomation.UNIXISH = False
hostos = sys.platform
if (hostos == 'mac' or hostos == 'darwin'):
localAutomation.IS_MAC = True
localAutomation.IS_MAC = True
elif (hostos == 'linux' or hostos == 'linux2'):
localAutomation.IS_LINUX = True
localAutomation.UNIXISH = True
localAutomation.IS_LINUX = True
localAutomation.UNIXISH = True
elif (hostos == 'win32' or hostos == 'win64'):
localAutomation.BIN_SUFFIX = ".exe"
localAutomation.IS_WIN32 = True
localAutomation.BIN_SUFFIX = ".exe"
localAutomation.IS_WIN32 = True
paths = [options.xrePath, localAutomation.DIST_BIN, self.automation._product, os.path.join('..', self.automation._product)]
options.xrePath = self.findPath(paths)
@ -328,8 +332,8 @@ class RemoteReftest(RefTest):
def stopWebServer(self, options):
self.server.stop()
def createReftestProfile(self, options, profileDir):
RefTest.createReftestProfile(self, options, profileDir, server=options.remoteWebServer)
def createReftestProfile(self, options, profileDir, reftestlist):
RefTest.createReftestProfile(self, options, profileDir, reftestlist, server=options.remoteWebServer)
# Turn off the locale picker screen
fhandle = open(os.path.join(profileDir, "user.js"), 'a')
@ -337,11 +341,14 @@ class RemoteReftest(RefTest):
user_pref("browser.firstrun.show.localepicker", false);
user_pref("font.size.inflation.emPerLine", 0);
user_pref("font.size.inflation.minTwips", 0);
""")
user_pref("reftest.remote", true);
user_pref("toolkit.telemetry.prompted", true);
user_pref("reftest.uri", "%s");
""" % reftestlist)
#workaround for jsreftests.
if options.enablePrivilege:
fhandle.write("""
fhandle.write("""
user_pref("capability.principal.codebase.p2.granted", "UniversalPreferencesWrite UniversalXPConnect UniversalBrowserWrite UniversalPreferencesRead UniversalBrowserRead");
user_pref("capability.principal.codebase.p2.id", "http://%s:%s");
""" % (options.remoteWebServer, options.httpPort))
@ -349,7 +356,6 @@ user_pref("capability.principal.codebase.p2.id", "http://%s:%s");
# Close the file
fhandle.close()
if (self._devicemanager.pushDir(profileDir, options.remoteProfile) == None):
raise devicemanager.FileError("Failed to copy profiledir to device")
@ -359,6 +365,9 @@ user_pref("capability.principal.codebase.p2.id", "http://%s:%s");
raise devicemanager.FileError("Failed to copy extra files to device")
def registerExtension(self, browserEnv, options, profileDir, extraArgs = ['-silent'] ):
if options.bootstrap:
return
self.automation.log.info("REFTEST INFO | runreftest.py | Performing extension manager registration: start.\n")
# Because our startProcess code doesn't return until fennec starts we just give it
# a maxTime of 20 secs before timing it out and ensuring it is dead.
@ -449,18 +458,22 @@ def main():
procName = options.app.split('/')[-1]
if (dm.processExist(procName)):
dm.killProcess(procName)
dm.killProcess(procName)
#an example manifest name to use on the cli
# manifest = "http://" + options.remoteWebServer + "/reftests/layout/reftests/reftest-sanity/reftest.list"
try:
reftest.runTests(manifest, options)
cmdlineArgs = ["-reftest", manifest]
if options.bootstrap:
cmdlineArgs = []
reftest.runTests(manifest, options, cmdlineArgs)
except:
print "TEST-UNEXPECTED-FAIL | | exception while running reftests"
reftest.stopWebServer(options)
sys.exit(1)
print "TEST-UNEXPECTED-FAIL | | exception while running reftests"
reftest.stopWebServer(options)
sys.exit(1)
reftest.stopWebServer(options)
if __name__ == "__main__":
main()

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

@ -1,4 +1,3 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
@ -74,8 +73,13 @@ class RefTest(object):
path = defaultManifestPath
return path
def createReftestProfile(self, options, profileDir, server='localhost'):
"Sets up a profile for reftest."
def createReftestProfile(self, options, profileDir, manifest, server='localhost'):
"""
Sets up a profile for reftest.
'manifest' is the path to the reftest.list file we want to test with. This is used in
the remote subclass in remotereftest.py so we can write it to a preference for the
bootstrap extension.
"""
self.automation.setupPermissionsDatabase(profileDir,
{'allowXULXBL': [(server, True), ('<file>', True)]})
@ -141,15 +145,18 @@ class RefTest(object):
if profileDir:
shutil.rmtree(profileDir, True)
def runTests(self, testPath, options):
def runTests(self, testPath, options, cmdlineArgs = None):
debuggerInfo = getDebuggerInfo(self.oldcwd, options.debugger, options.debuggerArgs,
options.debuggerInteractive);
profileDir = None
try:
reftestlist = self.getManifestPath(testPath)
if cmdlineArgs == None:
cmdlineArgs = ['-reftest', reftestlist]
profileDir = mkdtemp()
self.copyExtraFilesToProfile(options, profileDir)
self.createReftestProfile(options, profileDir)
self.createReftestProfile(options, profileDir, reftestlist)
self.installExtensionsToProfile(options, profileDir)
# browser environment
@ -159,9 +166,8 @@ class RefTest(object):
# then again to actually run reftest
self.automation.log.info("REFTEST INFO | runreftest.py | Running tests: start.\n")
reftestlist = self.getManifestPath(testPath)
status = self.automation.runApp(None, browserEnv, options.app, profileDir,
["-reftest", reftestlist],
cmdlineArgs,
utilityPath = options.utilityPath,
xrePath=options.xrePath,
debuggerInfo=debuggerInfo,

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

@ -262,7 +262,7 @@ nsGridRowLeafLayout::ComputeChildSizes(nsIBox* aBox,
// go up the parent chain looking for scrollframes
nscoord diff = 0;
nsIBox* parentBox;
nsIGridPart* parent = GetParentGridPart(aBox, &parentBox);
(void)GetParentGridPart(aBox, &parentBox);
while (parentBox) {
nsIBox* scrollbox = nsGrid::GetScrollBox(parentBox);
nsIScrollableFrame *scrollable = do_QueryFrame(scrollbox);
@ -280,7 +280,7 @@ nsGridRowLeafLayout::ComputeChildSizes(nsIBox* aBox,
}
}
parent = GetParentGridPart(parentBox, &parentBox);
(void)GetParentGridPart(parentBox, &parentBox);
}
if (diff > 0) {

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

@ -207,7 +207,7 @@ nsPopupSetFrame::List(FILE* out, PRInt32 aIndent) const
}
fprintf(out, " {%d,%d,%d,%d}", mRect.x, mRect.y, mRect.width, mRect.height);
if (0 != mState) {
fprintf(out, " [state=%016llx]", mState);
fprintf(out, " [state=%016llx]", (unsigned long long)mState);
}
fprintf(out, " [content=%p]", static_cast<void*>(mContent));
nsPopupSetFrame* f = const_cast<nsPopupSetFrame*>(this);

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

@ -112,7 +112,7 @@ protected:
// various constants for tooltips
enum {
kTooltipMouseMoveTolerance = 7, // 7 pixel tolerance for mousemove event
kTooltipMouseMoveTolerance = 7 // 7 pixel tolerance for mousemove event
};
// flag specifying if the tooltip has already been displayed by a MouseMove

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

@ -70,6 +70,9 @@ pref("zoom.minPercent", 20);
pref("zoom.maxPercent", 400);
pref("toolkit.zoomManager.zoomValues", ".2,.3,.5,.67,.8,.9,1,1.1,1.2,1.33,1.5,1.7,2,2.4,3,4");
// Mobile will use faster, less durable mode.
pref("toolkit.storage.synchronous", 0);
// Device pixel to CSS px ratio, in percent. Set to -1 to calculate based on display density.
pref("browser.viewport.scaleRatio", -1);
pref("browser.viewport.desktopWidth", 980);

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

@ -221,64 +221,59 @@ public class AboutHomeContent extends ScrollView {
super.onConfigurationChanged(newConfig);
}
InputStream getProfileRecommendedAddonsStream() {
try {
File profileDir = GeckoApp.mAppContext.getProfileDir();
if (profileDir == null)
return null;
File recommendedAddonsFile = new File(profileDir, "recommended-addons.json");
if (!recommendedAddonsFile.exists())
return null;
return new FileInputStream(recommendedAddonsFile);
} catch (FileNotFoundException fnfe) {
// ignore
}
return null;
}
InputStream getRecommendedAddonsStream(Activity activity) throws Exception{
InputStream is = getProfileRecommendedAddonsStream();
if (is != null)
return is;
File applicationPackage = new File(activity.getApplication().getPackageResourcePath());
ZipFile zip = null;
try {
zip = new ZipFile(applicationPackage);
if (zip == null)
return null;
ZipEntry fileEntry = zip.getEntry("recommended-addons.json");
if (fileEntry == null)
return null;
return zip.getInputStream(fileEntry);
} finally {
if (zip != null)
zip.close();
}
}
void readRecommendedAddons(final Activity activity) {
GeckoAppShell.getHandler().post(new Runnable() {
public void run() {
byte[] buf = new byte[32768];
InputStream fileStream = null;
ZipFile zip = null;
StringBuffer jsonString = null;
File profileDir = GeckoApp.mAppContext.getProfileDir();
try {
byte[] buf = new byte[32768];
InputStream fileStream = getRecommendedAddonsStream(activity);
if (profileDir != null) {
try {
File recommendedAddonsFile = new File(profileDir, "recommended-addons.json");
if (recommendedAddonsFile.exists()) {
fileStream = new FileInputStream(recommendedAddonsFile);
}
} catch (FileNotFoundException fnfe) {}
}
if (fileStream == null) {
Log.i("Addons", "filestream is null");
File applicationPackage = new File(activity.getApplication().getPackageResourcePath());
zip = new ZipFile(applicationPackage);
if (zip == null)
return;
ZipEntry fileEntry = zip.getEntry("recommended-addons.json");
if (fileEntry == null)
return;
fileStream = zip.getInputStream(fileEntry);
}
if (fileStream == null)
return;
StringBuffer jsonString = new StringBuffer();
try {
int read = 0;
while ((read = fileStream.read(buf, 0, 32768)) != -1) {
jsonString.append(new String(buf, 0, read));
}
} finally {
try {
fileStream.close();
} catch (IOException ioe) {
// catch this here because we can continue even if the
// close failed
Log.i(LOGTAG, "error closing json file", ioe);
}
jsonString = new StringBuffer();
int read = 0;
while ((read = fileStream.read(buf, 0, 32768)) != -1) {
jsonString.append(new String(buf, 0, read));
}
} catch (IOException ioe) {
Log.i(LOGTAG, "error reading recommended addons file", ioe);
} finally {
try {
if (fileStream != null)
fileStream.close();
if (zip != null)
zip.close();
} catch (IOException ioe) {
// catch this here because we can continue even if the
// close failed
Log.i(LOGTAG, "error closing json file", ioe);
}
}
if (jsonString == null)
return;
try {
final JSONArray array = new JSONObject(jsonString.toString()).getJSONArray("addons");
GeckoApp.mAppContext.mMainHandler.post(new Runnable() {
public void run() {

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

@ -163,6 +163,11 @@ public class AwesomeBar extends Activity implements GeckoEventListener {
InputMethodManager imm =
(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN) {
submitAndFinish(mText.getText().toString());
return true;
}
// If input method is in fullscreen mode, we want to dismiss
// it instead of closing awesomebar straight away.
if (!imm.isFullscreenMode() && keyCode == KeyEvent.KEYCODE_BACK) {

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

@ -376,11 +376,17 @@ public class GeckoInputConnection
GeckoAppShell.sendEventToGecko(
new GeckoEvent(GeckoEvent.IME_DELETE_TEXT, 0, 0));
} else {
GeckoAppShell.sendEventToGecko(
new GeckoEvent(GeckoEvent.IME_COMPOSITION_BEGIN, 0, 0));
GeckoAppShell.sendEventToGecko(
new GeckoEvent(0, count,
GeckoEvent.IME_RANGE_RAWINPUT, 0, 0, 0,
s.subSequence(start, start + count).toString()));
GeckoAppShell.sendEventToGecko(
new GeckoEvent(GeckoEvent.IME_COMPOSITION_END, 0, 0));
GeckoAppShell.sendEventToGecko(
new GeckoEvent(GeckoEvent.IME_SET_SELECTION, start + count, 0));
}

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

@ -92,15 +92,15 @@ public class Tab {
}
public Tab() {
this(-1, "", false, -1);
this(-1, "", false, -1, "");
}
public Tab(int id, String url, boolean external, int parentId) {
public Tab(int id, String url, boolean external, int parentId, String title) {
mId = id;
mUrl = url;
mExternal = external;
mParentId = parentId;
mTitle = "";
mTitle = title;
mFavicon = null;
mFaviconUrl = null;
mSecurityMode = "unknown";

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

@ -76,8 +76,9 @@ public class Tabs implements GeckoEventListener {
String url = params.getString("uri");
Boolean external = params.getBoolean("external");
int parentId = params.getInt("parentId");
String title = params.getString("title");
Tab tab = new Tab(id, url, external, parentId);
Tab tab = new Tab(id, url, external, parentId, title);
tabs.put(id, tab);
order.add(tab);
Log.i(LOGTAG, "Added a tab with id: " + id + ", url: " + url);

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

@ -133,7 +133,6 @@ public class GeckoSoftwareLayerClient extends LayerClient implements GeckoEventL
layerController.setRoot(mTileLayer);
if (mGeckoViewport != null) {
layerController.setViewportMetrics(mGeckoViewport);
layerController.notifyPanZoomControllerOfGeometryChange(false);
}
GeckoAppShell.registerGeckoEventListener("Viewport:Update", this);
@ -171,7 +170,7 @@ public class GeckoSoftwareLayerClient extends LayerClient implements GeckoEventL
} else {
Log.d(LOGTAG, "Received viewport update from gecko");
controller.setViewportMetrics(mGeckoViewport);
controller.notifyPanZoomControllerOfGeometryChange(true);
controller.abortPanZoomAnimation();
}
}
} catch (JSONException e) {
@ -203,6 +202,8 @@ public class GeckoSoftwareLayerClient extends LayerClient implements GeckoEventL
}
public Bitmap getBitmap() {
if (mBufferSize.width <= 0 || mBufferSize.height <= 0)
return null;
try {
Bitmap b = Bitmap.createBitmap(mBufferSize.width, mBufferSize.height,
CairoUtils.cairoFormatTobitmapConfig(mFormat));

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

@ -174,7 +174,7 @@ public class LayerController {
mLayerClient.viewportSizeChanged();
notifyLayerClientOfGeometryChange();
mPanZoomController.geometryChanged(true);
mPanZoomController.abortAnimation();
mView.requestRender();
}
@ -183,7 +183,6 @@ public class LayerController {
mViewportMetrics.setOrigin(point);
Log.d(LOGTAG, "scrollTo: " + mViewportMetrics);
notifyLayerClientOfGeometryChange();
mPanZoomController.geometryChanged(false);
GeckoApp.mAppContext.repositionPluginViews(false);
mView.requestRender();
}
@ -196,7 +195,6 @@ public class LayerController {
Log.d(LOGTAG, "scrollBy: " + mViewportMetrics);
notifyLayerClientOfGeometryChange();
mPanZoomController.geometryChanged(false);
GeckoApp.mAppContext.repositionPluginViews(false);
mView.requestRender();
}
@ -206,7 +204,6 @@ public class LayerController {
mViewportMetrics.setViewport(viewport);
Log.d(LOGTAG, "setViewport: " + mViewportMetrics);
notifyLayerClientOfGeometryChange();
mPanZoomController.geometryChanged(false);
GeckoApp.mAppContext.repositionPluginViews(false);
mView.requestRender();
}
@ -221,7 +218,6 @@ public class LayerController {
// Page size is owned by the LayerClient, so no need to notify it of
// this change.
mPanZoomController.geometryChanged(false);
mView.requestRender();
}
@ -283,10 +279,15 @@ public class LayerController {
mLayerClient.geometryChanged();
}
/** Informs the pan/zoom controller that the viewport metrics changed. */
public void notifyPanZoomControllerOfGeometryChange(boolean abortAnimation) {
if (mPanZoomController != null)
mPanZoomController.geometryChanged(abortAnimation);
/** Aborts any pan/zoom animation that is currently in progress. */
public void abortPanZoomAnimation() {
if (mPanZoomController != null) {
mView.post(new Runnable() {
public void run() {
mPanZoomController.abortAnimation();
}
});
}
}
/**

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

@ -153,7 +153,6 @@ public class PlaceholderLayerClient extends LayerClient {
if (mViewportUnknown)
mViewport.setViewport(layerController.getViewport());
layerController.setViewportMetrics(mViewport);
layerController.notifyPanZoomControllerOfGeometryChange(false);
BufferedCairoImage image = new BufferedCairoImage(mBuffer, mWidth, mHeight, mFormat);
SingleTileLayer tileLayer = new SingleTileLayer(image);

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

@ -248,25 +248,24 @@ public class PanZoomController
}
}
public void geometryChanged(boolean abortAnimation) {
if (abortAnimation) {
// this happens when gecko changes the viewport on us or if the device is rotated.
// if that's the case, abort any animation in progress and re-zoom so that the page
// snaps to edges. for other cases (where the user's finger(s) are down) don't do
// anything special.
switch (mState) {
case FLING:
mX.velocity = mY.velocity = 0.0f;
mState = PanZoomState.NOTHING;
// fall through
case ANIMATED_ZOOM:
// the zoom that's in progress likely makes no sense any more (such as if
// the screen orientation changed) so abort it and start a new one to
// ensure the viewport doesn't contain out-of-bounds areas
case NOTHING:
bounce();
break;
}
/** This function must be called from the UI thread. */
public void abortAnimation() {
// this happens when gecko changes the viewport on us or if the device is rotated.
// if that's the case, abort any animation in progress and re-zoom so that the page
// snaps to edges. for other cases (where the user's finger(s) are down) don't do
// anything special.
switch (mState) {
case FLING:
mX.velocity = mY.velocity = 0.0f;
mState = PanZoomState.NOTHING;
// fall through
case ANIMATED_ZOOM:
// the zoom that's in progress likely makes no sense any more (such as if
// the screen orientation changed) so abort it and start a new one to
// ensure the viewport doesn't contain out-of-bounds areas
case NOTHING:
bounce();
break;
}
}
@ -618,6 +617,7 @@ public class PanZoomController
/* Finally, if there's nothing else to do, complete the animation and go to sleep. */
finishBounce();
finishAnimation();
mState = PanZoomState.NOTHING;
}
/* Performs one frame of a bounce animation. */
@ -685,16 +685,17 @@ public class PanZoomController
*/
boolean overscrolledX = mX.getOverscroll() != Axis.Overscroll.NONE;
boolean overscrolledY = mY.getOverscroll() != Axis.Overscroll.NONE;
if (!mOverridePanning && (overscrolledX || overscrolledY))
if (!mOverridePanning && (overscrolledX || overscrolledY)) {
bounce();
else
} else {
finishAnimation();
mState = PanZoomState.NOTHING;
}
}
}
private void finishAnimation() {
Log.d(LOGTAG, "Finishing animation at " + mController.getViewportMetrics());
mState = PanZoomState.NOTHING;
stopAnimationTimer();
// Force a viewport synchronisation
@ -916,7 +917,13 @@ public class PanZoomController
if (mState == PanZoomState.ANIMATED_ZOOM)
return false;
float spanRatio = detector.getCurrentSpan() / detector.getPreviousSpan();
float prevSpan = detector.getPreviousSpan();
if (FloatUtils.fuzzyEquals(prevSpan, 0.0f)) {
// let's eat this one to avoid setting the new zoom to infinity (bug 711453)
return true;
}
float spanRatio = detector.getCurrentSpan() / prevSpan;
/*
* Apply edge resistance if we're zoomed out smaller than the page size by scaling the zoom
@ -1066,7 +1073,7 @@ public class PanZoomController
return true;
}
public boolean animatedZoomTo(RectF zoomToRect) {
private boolean animatedZoomTo(RectF zoomToRect) {
GeckoApp.mAppContext.hidePluginViews();
mState = PanZoomState.ANIMATED_ZOOM;

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

@ -226,13 +226,19 @@ var BrowserApp = {
// XXX maybe we don't do this if the launch was kicked off from external
Services.io.offline = false;
let newTab = this.addTab(uri);
// Broadcast a UIReady message so add-ons know we are finished with startup
let event = document.createEvent("Events");
event.initEvent("UIReady", true, false);
window.dispatchEvent(event);
// restore the previous session
let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
if (ss.shouldRestore())
ss.restoreLastSession(true);
else
this.addTab(uri);
// notify java that gecko has loaded
sendMessageToJava({
gecko: {
@ -377,6 +383,10 @@ var BrowserApp = {
if ("selected" in aParams && aParams.selected)
newTab.active = true;
let evt = document.createEvent("UIEvents");
evt.initUIEvent("TabOpen", true, false, window, null);
newTab.browser.dispatchEvent(evt);
return newTab;
},
@ -384,6 +394,10 @@ var BrowserApp = {
if (aTab == this.selectedTab)
this.selectedTab = null;
let evt = document.createEvent("UIEvents");
evt.initUIEvent("TabClose", true, false, window, null);
aTab.browser.dispatchEvent(evt);
aTab.destroy();
this._tabs.splice(this._tabs.indexOf(aTab), 1);
},
@ -399,6 +413,10 @@ var BrowserApp = {
}
};
let evt = document.createEvent("UIEvents");
evt.initUIEvent("TabSelect", true, false, window, null);
aTab.browser.dispatchEvent(evt);
sendMessageToJava(message);
}
},
@ -1127,7 +1145,8 @@ Tab.prototype = {
uri: aURL,
parentId: ("parentId" in aParams) ? aParams.parentId : -1,
external: ("external" in aParams) ? aParams.external : false,
selected: ("selected" in aParams) ? aParams.selected : true
selected: ("selected" in aParams) ? aParams.selected : true,
title: aParams.title || ""
}
};
sendMessageToJava(message);
@ -1147,24 +1166,26 @@ Tab.prototype = {
Services.obs.addObserver(this, "http-on-modify-request", false);
let flags = "flags" in aParams ? aParams.flags : Ci.nsIWebNavigation.LOAD_FLAGS_NONE;
let postData = ("postData" in aParams && aParams.postData) ? aParams.postData.value : null;
let referrerURI = "referrerURI" in aParams ? aParams.referrerURI : null;
let charset = "charset" in aParams ? aParams.charset : null;
if (!aParams.delayLoad) {
let flags = "flags" in aParams ? aParams.flags : Ci.nsIWebNavigation.LOAD_FLAGS_NONE;
let postData = ("postData" in aParams && aParams.postData) ? aParams.postData.value : null;
let referrerURI = "referrerURI" in aParams ? aParams.referrerURI : null;
let charset = "charset" in aParams ? aParams.charset : null;
try {
this.browser.loadURIWithFlags(aURL, flags, referrerURI, charset, postData);
} catch(e) {
let message = {
gecko: {
type: "Content:LoadError",
tabID: this.id,
uri: this.browser.currentURI.spec,
title: this.browser.contentTitle
}
};
sendMessageToJava(message);
dump("Handled load error: " + e)
try {
this.browser.loadURIWithFlags(aURL, flags, referrerURI, charset, postData);
} catch(e) {
let message = {
gecko: {
type: "Content:LoadError",
tabID: this.id,
uri: this.browser.currentURI.spec,
title: this.browser.contentTitle
}
};
sendMessageToJava(message);
dump("Handled load error: " + e)
}
}
},
@ -1202,7 +1223,13 @@ Tab.prototype = {
this.browser.removeEventListener("scroll", this, true);
this.browser.removeEventListener("PluginClickToPlay", this, true);
this.browser.removeEventListener("pagehide", this, true);
// Make sure the previously selected panel remains selected. The selected panel of a deck is
// not stable when panels are removed.
let selectedPanel = BrowserApp.deck.selectedPanel;
BrowserApp.deck.removeChild(this.vbox);
BrowserApp.deck.selectedPanel = selectedPanel;
Services.obs.removeObserver(this, "http-on-modify-request", false);
this.browser = null;
this.vbox = null;
@ -1457,7 +1484,7 @@ Tab.prototype = {
let plugin = aEvent.target;
// Keep track of all the plugins on the current page
this._pluginsToPlay.push(plugin);
let overlay = plugin.ownerDocument.getAnonymousElementByAttribute(plugin, "class", "mainBox");
if (!overlay)
return;
@ -1476,9 +1503,12 @@ Tab.prototype = {
}
case "pagehide": {
// Reset plugin state when we leave the page
this._pluginsToPlay = [];
this._pluginOverlayShowing = false;
// Check to make sure it's top-level pagehide
if (aEvent.target.defaultView == this.browser.contentWindow) {
// Reset plugin state when we leave the page
this._pluginsToPlay = [];
this._pluginOverlayShowing = false;
}
break;
}
}
@ -1748,7 +1778,6 @@ Tab.prototype = {
])
};
var BrowserEventHandler = {
init: function init() {
Services.obs.addObserver(this, "Gesture:SingleTap", false);
@ -3264,7 +3293,7 @@ var PluginHelper = {
// XXX just doing (callback)(arg) was giving a same-origin error. bug?
let self = this;
let callbackArgs = Array.prototype.slice.call(arguments).slice(2);
plugin.addEventListener("click", function(evt) {
plugin.addEventListener("click", function(evt) {
if (!evt.isTrusted)
return;
evt.preventDefault();

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

@ -46,10 +46,9 @@ include $(DEPTH)/config/autoconf.mk
MODULE = MobileComponents
XPIDL_MODULE = MobileComponents
# disabled (bug 696203)
#XPIDLSRCS = \
# SessionStore.idl \
# $(NULL)
XPIDLSRCS = \
SessionStore.idl \
$(NULL)
EXTRA_PP_COMPONENTS = \
MobileComponents.manifest \
@ -58,7 +57,7 @@ EXTRA_PP_COMPONENTS = \
DirectoryProvider.js\
HelperAppDialog.js \
Sidebar.js \
$(NULL SessionStore.js is disabled - bug 696203) \
SessionStore.js \
$(NULL)
EXTRA_COMPONENTS = \

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

@ -23,10 +23,10 @@ category JavaScript-global-property sidebar @mozilla.org/sidebar;1
category JavaScript-global-property external @mozilla.org/sidebar;1
category wakeup-request Sidebar @mozilla.org/sidebar;1,nsISidebarExternal,getService,Sidebar:AddSearchProvider
# SessionStore.js - temporarily disabled (bug 696203)
# component {8c1f07d6-cba3-4226-a315-8bd43d67d032} SessionStore.js
# contract @mozilla.org/browser/sessionstore;1 {8c1f07d6-cba3-4226-a315-8bd43d67d032}
# category app-startup SessionStore service,@mozilla.org/browser/sessionstore;1
# SessionStore.js
component {8c1f07d6-cba3-4226-a315-8bd43d67d032} SessionStore.js
contract @mozilla.org/browser/sessionstore;1 {8c1f07d6-cba3-4226-a315-8bd43d67d032}
category app-startup SessionStore service,@mozilla.org/browser/sessionstore;1
# stylesheets
category agent-style-sheets browser-content-stylesheet chrome://browser/skin/content.css

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

@ -52,6 +52,10 @@ XPCOMUtils.defineLazyGetter(this, "NetUtil", function() {
return NetUtil;
});
function dump(a) {
Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService).logStringMessage(a);
}
// -----------------------------------------------------------------------
// Session Store
// -----------------------------------------------------------------------
@ -144,7 +148,7 @@ SessionStore.prototype = {
// First, let's get a list of files we think should be active
let activeFiles = [];
this._forEachBrowserWindow(function(aWindow) {
let tabs = aWindow.Browser.tabs;
let tabs = aWindow.BrowserApp.tabs;
for (let i = 0; i < tabs.length; i++) {
let browser = tabs[i].browser;
if (browser.__SS_extdata && "thumbnail" in browser.__SS_extdata)
@ -282,31 +286,30 @@ SessionStore.prototype = {
handleEvent: function ss_handleEvent(aEvent) {
let window = aEvent.currentTarget.ownerDocument.defaultView;
switch (aEvent.type) {
case "TabOpen":
case "TabClose": {
let browser = aEvent.originalTarget.linkedBrowser;
if (aEvent.type == "TabOpen") {
this.onTabAdd(window, browser);
}
else {
this.onTabClose(window, browser);
this.onTabRemove(window, browser);
}
case "TabOpen": {
let browser = aEvent.target;
this.onTabAdd(window, browser);
break;
}
}
case "TabClose": {
let browser = aEvent.target;
this.onTabClose(window, browser);
this.onTabRemove(window, browser);
break;
}
case "TabSelect": {
let browser = aEvent.originalTarget.linkedBrowser;
let browser = aEvent.target;
this.onTabSelect(window, browser);
break;
}
case "pageshow": {
let browser = aEvent.currentTarget;
this.onTabLoad(window, browser, aEvent.persisted);
break;
}
}
},
receiveMessage: function ss_receiveMessage(aMessage) {
let window = aMessage.target.ownerDocument.defaultView;
this.onTabLoad(window, aMessage.target, aMessage);
},
onWindowOpen: function ss_onWindowOpen(aWindow) {
// Return if window has already been initialized
if (aWindow && aWindow.__SSID && this._windows[aWindow.__SSID])
@ -333,15 +336,15 @@ SessionStore.prototype = {
}
// Add tab change listeners to all already existing tabs
let tabs = aWindow.Browser.tabs;
let tabs = aWindow.BrowserApp.tabs;
for (let i = 0; i < tabs.length; i++)
this.onTabAdd(aWindow, tabs[i].browser, true);
// Notification of tab add/remove/selection
let tabContainer = aWindow.document.getElementById("tabs");
tabContainer.addEventListener("TabOpen", this, true);
tabContainer.addEventListener("TabClose", this, true);
tabContainer.addEventListener("TabSelect", this, true);
let browsers = aWindow.document.getElementById("browsers");
browsers.addEventListener("TabOpen", this, true);
browsers.addEventListener("TabClose", this, true);
browsers.addEventListener("TabSelect", this, true);
},
onWindowClose: function ss_onWindowClose(aWindow) {
@ -349,10 +352,10 @@ SessionStore.prototype = {
if (!aWindow.__SSID || !this._windows[aWindow.__SSID])
return;
let tabContainer = aWindow.document.getElementById("tabs");
tabContainer.removeEventListener("TabOpen", this, true);
tabContainer.removeEventListener("TabClose", this, true);
tabContainer.removeEventListener("TabSelect", this, true);
let browsers = aWindow.document.getElementById("browsers");
browsers.removeEventListener("TabOpen", this, true);
browsers.removeEventListener("TabClose", this, true);
browsers.removeEventListener("TabSelect", this, true);
if (this._loadState == STATE_RUNNING) {
// Update all window data for a last time
@ -365,7 +368,7 @@ SessionStore.prototype = {
this.saveStateDelayed();
}
let tabs = aWindow.Browser.tabs;
let tabs = aWindow.BrowserApp.tabs;
for (let i = 0; i < tabs.length; i++)
this.onTabRemove(aWindow, tabs[i].browser, true);
@ -373,17 +376,14 @@ SessionStore.prototype = {
},
onTabAdd: function ss_onTabAdd(aWindow, aBrowser, aNoNotification) {
aBrowser.messageManager.addMessageListener("pageshow", this);
aBrowser.messageManager.addMessageListener("Content:SessionHistory", this);
aBrowser.addEventListener("pageshow", this, true);
if (!aNoNotification)
this.saveStateDelayed();
this._updateCrashReportURL(aWindow);
},
onTabRemove: function ss_onTabRemove(aWindow, aBrowser, aNoNotification) {
aBrowser.messageManager.removeMessageListener("pageshow", this);
aBrowser.messageManager.removeMessageListener("Content:SessionHistory", this);
aBrowser.removeEventListener("pageshow", this, true);
// If this browser is being restored, skip any session save activity
if (aBrowser.__SS_restore)
@ -399,7 +399,7 @@ SessionStore.prototype = {
if (this._maxTabsUndo == 0)
return;
if (aWindow.Browser.tabs.length > 0) {
if (aWindow.BrowserApp.tabs.length > 0) {
// Bundle this browser's data and extra data and save in the closedTabs
// window property
let data = aBrowser.__SS_data;
@ -412,7 +412,7 @@ SessionStore.prototype = {
}
},
onTabLoad: function ss_onTabLoad(aWindow, aBrowser, aMessage) {
onTabLoad: function ss_onTabLoad(aWindow, aBrowser, aPersisted) {
// If this browser is being restored, skip any session save activity
if (aBrowser.__SS_restore)
return;
@ -421,14 +421,26 @@ SessionStore.prototype = {
if (!aBrowser.canGoBack && aBrowser.currentURI.spec == "about:blank")
return;
if (aMessage.name == "Content:SessionHistory") {
delete aBrowser.__SS_data;
this._collectTabData(aBrowser, aMessage.json);
}
let history = aBrowser.sessionHistory;
// Save out the state as quickly as possible
if (aMessage.name == "pageshow")
if (aPersisted && aBrowser.__SS_data) {
// Loading from the cache; just update the index
aBrowser.__SS_data.index = history.index + 1;
this.saveStateDelayed();
} else {
// Serialize the tab data
let entries = [];
for (let i = 0; i < history.count; i++) {
let entry = this._serializeHistoryEntry(history.getEntryAtIndex(i, false));
entries.push(entry);
}
let index = history.index + 1;
let data = { entries: entries, index: index };
delete aBrowser.__SS_data;
this._collectTabData(aBrowser, data);
this.saveStateNow();
}
this._updateCrashReportURL(aWindow);
},
@ -437,25 +449,20 @@ SessionStore.prototype = {
if (this._loadState != STATE_RUNNING)
return;
let index = aWindow.Elements.browsers.selectedIndex;
let browsers = aWindow.document.getElementById("browsers");
let index = browsers.selectedIndex;
this._windows[aWindow.__SSID].selected = parseInt(index) + 1; // 1-based
// Restore the resurrected browser
if (aBrowser.__SS_restore) {
let data = aBrowser.__SS_data;
if (data.entries.length > 0) {
let json = {
uri: data.entries[data.index - 1].url,
flags: null,
entries: data.entries,
index: data.index
};
aBrowser.messageManager.sendAsyncMessage("WebNavigation:LoadURI", json);
}
if (data.entries.length > 0)
aBrowser.loadURI(data.entries[data.index - 1].url);
delete aBrowser.__SS_restore;
}
this.saveStateDelayed();
this._updateCrashReportURL(aWindow);
},
@ -527,10 +534,11 @@ SessionStore.prototype = {
let winData = this._windows[aWindow.__SSID];
winData.tabs = [];
let index = aWindow.Elements.browsers.selectedIndex;
let browsers = aWindow.document.getElementById("browsers");
let index = browsers.selectedIndex;
winData.selected = parseInt(index) + 1; // 1-based
let tabs = aWindow.Browser.tabs;
let tabs = aWindow.BrowserApp.tabs;
for (let i = 0; i < tabs.length; i++) {
let browser = tabs[i].browser;
if (browser.__SS_data) {
@ -579,8 +587,11 @@ SessionStore.prototype = {
_updateCrashReportURL: function ss_updateCrashReportURL(aWindow) {
#ifdef MOZ_CRASHREPORTER
if (!aWindow.BrowserApp.selectedBrowser)
return;
try {
let currentURI = aWindow.Browser.selectedBrowser.currentURI.clone();
let currentURI = aWindow.BrowserApp.selectedBrowser.currentURI.clone();
// if the current URI contains a username/password, remove it
try {
currentURI.userPass = "";
@ -597,13 +608,215 @@ SessionStore.prototype = {
#endif
},
_serializeHistoryEntry: function _serializeHistoryEntry(aEntry) {
let entry = { url: aEntry.URI.spec };
if (aEntry.title && aEntry.title != entry.url)
entry.title = aEntry.title;
if (!(aEntry instanceof Ci.nsISHEntry))
return entry;
let cacheKey = aEntry.cacheKey;
if (cacheKey && cacheKey instanceof Ci.nsISupportsPRUint32 && cacheKey.data != 0)
entry.cacheKey = cacheKey.data;
entry.ID = aEntry.ID;
entry.docshellID = aEntry.docshellID;
if (aEntry.referrerURI)
entry.referrer = aEntry.referrerURI.spec;
if (aEntry.contentType)
entry.contentType = aEntry.contentType;
let x = {}, y = {};
aEntry.getScrollPosition(x, y);
if (x.value != 0 || y.value != 0)
entry.scroll = x.value + "," + y.value;
if (aEntry.owner) {
try {
let binaryStream = Cc["@mozilla.org/binaryoutputstream;1"].createInstance(Ci.nsIObjectOutputStream);
let pipe = Cc["@mozilla.org/pipe;1"].createInstance(Ci.nsIPipe);
pipe.init(false, false, 0, 0xffffffff, null);
binaryStream.setOutputStream(pipe.outputStream);
binaryStream.writeCompoundObject(aEntry.owner, Ci.nsISupports, true);
binaryStream.close();
// Now we want to read the data from the pipe's input end and encode it.
let scriptableStream = Cc["@mozilla.org/binaryinputstream;1"].createInstance(Ci.nsIBinaryInputStream);
scriptableStream.setInputStream(pipe.inputStream);
let ownerBytes = scriptableStream.readByteArray(scriptableStream.available());
// We can stop doing base64 encoding once our serialization into JSON
// is guaranteed to handle all chars in strings, including embedded
// nulls.
entry.owner_b64 = btoa(String.fromCharCode.apply(null, ownerBytes));
} catch (e) { dump(e); }
}
entry.docIdentifier = aEntry.BFCacheEntry.ID;
if (aEntry.stateData != null) {
entry.structuredCloneState = aEntry.stateData.getDataAsBase64();
entry.structuredCloneVersion = aEntry.stateData.formatVersion;
}
if (!(aEntry instanceof Ci.nsISHContainer))
return entry;
if (aEntry.childCount > 0) {
entry.children = [];
for (let i = 0; i < aEntry.childCount; i++) {
let child = aEntry.GetChildAt(i);
if (child)
entry.children.push(this._serializeHistoryEntry(child));
else // to maintain the correct frame order, insert a dummy entry
entry.children.push({ url: "about:blank" });
// don't try to restore framesets containing wyciwyg URLs (cf. bug 424689 and bug 450595)
if (/^wyciwyg:\/\//.test(entry.children[i].url)) {
delete entry.children;
break;
}
}
}
return entry;
},
_deserializeHistoryEntry: function _deserializeHistoryEntry(aEntry, aIdMap, aDocIdentMap) {
let shEntry = Cc["@mozilla.org/browser/session-history-entry;1"].createInstance(Ci.nsISHEntry);
shEntry.setURI(Services.io.newURI(aEntry.url, null, null));
shEntry.setTitle(aEntry.title || aEntry.url);
if (aEntry.subframe)
shEntry.setIsSubFrame(aEntry.subframe || false);
shEntry.loadType = Ci.nsIDocShellLoadInfo.loadHistory;
if (aEntry.contentType)
shEntry.contentType = aEntry.contentType;
if (aEntry.referrer)
shEntry.referrerURI = Services.io.newURI(aEntry.referrer, null, null);
if (aEntry.cacheKey) {
let cacheKey = Cc["@mozilla.org/supports-PRUint32;1"].createInstance(Ci.nsISupportsPRUint32);
cacheKey.data = aEntry.cacheKey;
shEntry.cacheKey = cacheKey;
}
if (aEntry.ID) {
// get a new unique ID for this frame (since the one from the last
// start might already be in use)
let id = aIdMap[aEntry.ID] || 0;
if (!id) {
for (id = Date.now(); id in aIdMap.used; id++);
aIdMap[aEntry.ID] = id;
aIdMap.used[id] = true;
}
shEntry.ID = id;
}
if (aEntry.docshellID)
shEntry.docshellID = aEntry.docshellID;
if (aEntry.structuredCloneState && aEntry.structuredCloneVersion) {
shEntry.stateData =
Cc["@mozilla.org/docshell/structured-clone-container;1"].
createInstance(Ci.nsIStructuredCloneContainer);
shEntry.stateData.initFromBase64(aEntry.structuredCloneState, aEntry.structuredCloneVersion);
}
if (aEntry.scroll) {
let scrollPos = aEntry.scroll.split(",");
scrollPos = [parseInt(scrollPos[0]) || 0, parseInt(scrollPos[1]) || 0];
shEntry.setScrollPosition(scrollPos[0], scrollPos[1]);
}
let childDocIdents = {};
if (aEntry.docIdentifier) {
// If we have a serialized document identifier, try to find an SHEntry
// which matches that doc identifier and adopt that SHEntry's
// BFCacheEntry. If we don't find a match, insert shEntry as the match
// for the document identifier.
let matchingEntry = aDocIdentMap[aEntry.docIdentifier];
if (!matchingEntry) {
matchingEntry = {shEntry: shEntry, childDocIdents: childDocIdents};
aDocIdentMap[aEntry.docIdentifier] = matchingEntry;
} else {
shEntry.adoptBFCacheEntry(matchingEntry);
childDocIdents = matchingEntry.childDocIdents;
}
}
if (aEntry.owner_b64) {
let ownerInput = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(Ci.nsIStringInputStream);
let binaryData = atob(aEntry.owner_b64);
ownerInput.setData(binaryData, binaryData.length);
let binaryStream = Cc["@mozilla.org/binaryinputstream;1"].createInstance(Ci.nsIObjectInputStream);
binaryStream.setInputStream(ownerInput);
try { // Catch possible deserialization exceptions
shEntry.owner = binaryStream.readObject(true);
} catch (ex) { dump(ex); }
}
if (aEntry.children && shEntry instanceof Ci.nsISHContainer) {
for (let i = 0; i < aEntry.children.length; i++) {
if (!aEntry.children[i].url)
continue;
// We're getting sessionrestore.js files with a cycle in the
// doc-identifier graph, likely due to bug 698656. (That is, we have
// an entry where doc identifier A is an ancestor of doc identifier B,
// and another entry where doc identifier B is an ancestor of A.)
//
// If we were to respect these doc identifiers, we'd create a cycle in
// the SHEntries themselves, which causes the docshell to loop forever
// when it looks for the root SHEntry.
//
// So as a hack to fix this, we restrict the scope of a doc identifier
// to be a node's siblings and cousins, and pass childDocIdents, not
// aDocIdents, to _deserializeHistoryEntry. That is, we say that two
// SHEntries with the same doc identifier have the same document iff
// they have the same parent or their parents have the same document.
shEntry.AddChild(this._deserializeHistoryEntry(aEntry.children[i], aIdMap, childDocIdents), i);
}
}
return shEntry;
},
_restoreHistory: function _restoreHistory(aTabData, aHistory) {
if (aHistory.count > 0)
aHistory.PurgeHistory(aHistory.count);
aHistory.QueryInterface(Ci.nsISHistoryInternal);
// helper hashes for ensuring unique frame IDs and unique document
// identifiers.
let idMap = { used: {} };
let docIdentMap = {};
for (let i = 0; i < aTabData.entries.length; i++) {
if (!aTabData.entries[i].url)
continue;
aHistory.addEntry(this._deserializeHistoryEntry(aTabData.entries[i], idMap, docIdentMap), true);
}
// We need to force set the active history item and cause it to reload since
// we stop the load above
let activeIndex = (aTabData.index || aTabData.entries.length) - 1;
aHistory.getEntryAtIndex(activeIndex, true);
aHistory.QueryInterface(Ci.nsISHistory).reloadCurrentEntry();
},
getBrowserState: function ss_getBrowserState() {
let data = this._getCurrentState();
return JSON.stringify(data);
},
getClosedTabCount: function ss_getClosedTabCount(aWindow) {
if (!aWindow || !aWindow.__SSID)
if (!aWindow || !aWindow.__SSID || !this._windows[aWindow.__SSID])
return 0; // not a browser window, or not otherwise tracked by SS.
return this._windows[aWindow.__SSID].closedTabs.length;
@ -633,19 +846,14 @@ SessionStore.prototype = {
let closedTab = closedTabs.splice(aIndex, 1).shift();
// create a new tab and bring to front
let tab = aWindow.Browser.addTab(closedTab.entries[closedTab.index - 1].url, true);
tab.browser.messageManager.sendAsyncMessage("WebNavigation:LoadURI", {
uri: closedTab.entries[closedTab.index - 1].url,
flags: null,
entries: closedTab.entries,
index: closedTab.index
});
let params = { selected: true };
let tab = aWindow.BrowserApp.addTab(closedTab.entries[closedTab.index - 1].url, params);
this._restoreHistory(closedTab, tab.browser.sessionHistory);
// Put back the extra data
tab.browser.__SS_extdata = closedTab.extData;
return tab.chromeTab;
return tab.browser;
},
forgetClosedTab: function ss_forgetClosedTab(aWindow, aIndex) {
@ -757,50 +965,23 @@ SessionStore.prototype = {
for (let i=0; i<tabs.length; i++) {
let tabData = tabs[i];
let isSelected = i + 1 == selected;
let entry = tabData.entries[tabData.index - 1];
// Add a tab, but don't load the URL until we need to
let params = { getAttention: false, delayLoad: true };
let params = { selected: isSelected, delayLoad: !isSelected, title: entry.title };
let tab = window.BrowserApp.addTab(entry.url, params);
// We must have selected tabs as soon as possible, so we let all tabs be selected
// until we get the real selected tab. Then we stop selecting tabs. The end result
// is that the right tab is selected, but we also don't get a bunch of errors
let bringToFront = (i + 1 <= selected) && aBringToFront;
let tab = window.Browser.addTab(tabData.entries[tabData.index - 1].url, bringToFront, null, params);
// Start a real load for the selected tab
if (i + 1 == selected) {
let json = {
uri: tabData.entries[tabData.index - 1].url,
flags: null,
entries: tabData.entries,
index: tabData.index
};
tab.browser.messageManager.sendAsyncMessage("WebNavigation:LoadURI", json);
} else {
if (!isSelected) {
// Make sure the browser has its session data for the delay reload
tab.browser.__SS_data = tabData;
tab.browser.__SS_restore = true;
// Restore current title
tab.chromeTab.updateTitle(tabData.entries[tabData.index - 1].title);
// Recreate the thumbnail if we are delay loading the tab
let canvas = tab.chromeTab.thumbnail;
canvas.setAttribute("restored", "true");
canvas.removeAttribute("empty");
let image = new window.Image();
image.onload = function() {
if (canvas) {
canvas.getContext("2d").drawImage(image, 0, 0);
}
};
image.src = tabData.extData.thumbnail;
}
tab.browser.__SS_extdata = tabData.extData;
self._restoreHistory(tabData, tab.browser.sessionHistory);
}
notifyObservers();
});
} catch (ex) {

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

@ -608,7 +608,7 @@ bin/components/@DLL_PREFIX@nkgnomevfs@DLL_SUFFIX@
@BINPATH@/components/MobileComponents.manifest
@BINPATH@/components/MobileComponents.xpt
@BINPATH@/components/PromptService.js
; disabled (bug 696203) @BINPATH@/components/SessionStore.js
@BINPATH@/components/SessionStore.js
@BINPATH@/components/Sidebar.js
@BINPATH@/components/OpenWebapps.js
#ifdef MOZ_SAFE_BROWSING

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

@ -144,12 +144,12 @@ toolbarbutton.urlbar-button {
-moz-box-flex: 1;
-moz-box-align: center;
-moz-box-pack: center;
background: @color_background_inverse@ url("chrome://browser/skin/images/endcap-default-bg.png") bottom center;
background: @color_background_inverse@ url("chrome://browser/skin/images/endcap-default-bg.png") bottom center repeat-x;
}
.urlbar-cap-button[open="true"],
.urlbar-cap-button:not([disabled="true"]):hover:active {
background: #a5aab2 url("chrome://browser/skin/images/endcap-active-bg.png") bottom center;
background: #ddd url("chrome://browser/skin/images/endcap-active-bg.png") top center repeat-x;
}
/* left cap button --------------------------------------------------------- */
@ -164,22 +164,24 @@ toolbarbutton.urlbar-button {
/* add special color */
#identity-box[mode="verifiedIdentity"] {
background-color: #89d715;
background-color: #c9ea80;
background-image: url("chrome://browser/skin/images/endcap-ev-default-bg.png");
}
#identity-box[mode="verifiedIdentity"][open="true"],
#identity-box[mode="verifiedIdentity"]:hover:active {
background-color: #b9d880;
background-image: url("chrome://browser/skin/images/endcap-ev-active-bg.png");
}
#identity-box[mode="verifiedDomain"] {
background-color: #6579e3;
background-color: #b2bcf1;
background-image: url("chrome://browser/skin/images/endcap-ssl-default-bg.png");
}
#identity-box[mode="verifiedDomain"][open="true"],
#identity-box[mode="verifiedDomain"]:hover:active {
background-color: #a7b2ef;
background-image: url("chrome://browser/skin/images/endcap-ssl-active-bg.png");
}

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

@ -304,6 +304,16 @@ nsSocketInputStream::Available(PRUint32 *avail)
// mistakenly try to re-enter this code.)
PRInt32 n = PR_Available(fd);
// PSM does not implement PR_Available() so do a best approximation of it
// with MSG_PEEK
if ((n == -1) && (PR_GetError() == PR_NOT_IMPLEMENTED_ERROR)) {
char c;
n = PR_Recv(fd, &c, 1, PR_MSG_PEEK, 0);
SOCKET_LOG(("nsSocketInputStream::Available [this=%x] "
"using PEEK backup n=%d]\n", this, n));
}
nsresult rv;
{
MutexAutoLock lock(mTransport->mLock);

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

@ -458,11 +458,10 @@ nsHttpConnection::CanReuse()
// An idle persistent connection should not have data waiting to be read
// before a request is sent. Data here is likely a 408 timeout response
// which we would deal with later on through the restart logic, but that
// path is more expensive than just closing the socket now. SSL check can
// be removed with fixing of 631801
// path is more expensive than just closing the socket now.
PRUint32 dataSize;
if (canReuse && mSocketIn && !mConnInfo->UsingSSL() && !mUsingSpdy &&
if (canReuse && mSocketIn && !mUsingSpdy &&
NS_SUCCEEDED(mSocketIn->Available(&dataSize)) && dataSize) {
LOG(("nsHttpConnection::CanReuse %p %s"
"Socket not reusable because read data pending (%d) on it.\n",

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

@ -2249,6 +2249,20 @@ static PRStatus PR_CALLBACK PSMConnectcontinue(PRFileDesc *fd, PRInt16 out_flags
return fd->lower->methods->connectcontinue(fd, out_flags);
}
static PRIntn PSMAvailable(void)
{
// This is called through PR_Available(), but is not implemented in PSM
PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
return -1;
}
static PRInt64 PSMAvailable64(void)
{
// This is called through PR_Available(), but is not implemented in PSM
PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
return -1;
}
nsresult nsSSLIOLayerHelpers::Init()
{
if (!nsSSLIOLayerInitialized) {
@ -2256,8 +2270,8 @@ nsresult nsSSLIOLayerHelpers::Init()
nsSSLIOLayerIdentity = PR_GetUniqueIdentity("NSS layer");
nsSSLIOLayerMethods = *PR_GetDefaultIOMethods();
nsSSLIOLayerMethods.available = (PRAvailableFN)_PSM_InvalidInt;
nsSSLIOLayerMethods.available64 = (PRAvailable64FN)_PSM_InvalidInt64;
nsSSLIOLayerMethods.available = (PRAvailableFN)PSMAvailable;
nsSSLIOLayerMethods.available64 = (PRAvailable64FN)PSMAvailable64;
nsSSLIOLayerMethods.fsync = (PRFsyncFN)_PSM_InvalidStatus;
nsSSLIOLayerMethods.seek = (PRSeekFN)_PSM_InvalidInt;
nsSSLIOLayerMethods.seek64 = (PRSeek64FN)_PSM_InvalidInt64;

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

@ -223,7 +223,7 @@ LoginManagerStorage_mozStorage.prototype = {
* necessary. Most of the work is done in _deferredInit.
*/
init : function () {
this._dbStmts = [];
this._dbStmts = {};
// Connect to the correct preferences branch.
this._prefBranch = Services.prefs.getBranch("signon.");
@ -1299,9 +1299,19 @@ LoginManagerStorage_mozStorage.prototype = {
this._dbCleanup(true);
throw e;
}
Services.obs.addObserver(this, "profile-before-change", false);
return isFirstRun;
},
observe: function (subject, topic, data) {
switch (topic) {
case "profile-before-change":
Services.obs.removeObserver(this, "profile-before-change");
this._dbClose();
break;
}
},
_dbCreate: function () {
this.log("Creating Database");
@ -1617,6 +1627,23 @@ LoginManagerStorage_mozStorage.prototype = {
}
},
_dbClose : function () {
this.log("Closing the DB connection.");
// Finalize all statements to free memory, avoid errors later
for each (let stmt in this._dbStmts) {
stmt.finalize();
}
this._dbStmts = {};
if (this._dbConnection !== null) {
try {
this._dbConnection.close();
} catch (e) {
Components.utils.reportError(e);
}
}
this._dbConnection = null;
},
/*
* _dbCleanup
@ -1633,14 +1660,7 @@ LoginManagerStorage_mozStorage.prototype = {
this._storageService.backupDatabaseFile(this._signonsFile, backupFile);
}
// Finalize all statements to free memory, avoid errors later
for each (let stmt in this._dbStmts)
stmt.finalize();
this._dbStmts = [];
// Close the connection, ignore 'already closed' error
try { this._dbConnection.close() } catch(e) {}
this._dbConnection = null;
this._dbClose();
this._signonsFile.remove(false);
}

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

@ -424,6 +424,7 @@ ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
OS_LIBS += \
-lui \
-lmedia \
-lhardware_legacy \
$(NULL)
endif

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

@ -66,18 +66,6 @@ typedef size_t(*nsMallocSizeOfFun)(const void *p, size_t computedSize);
/* Core XPCOM declarations. */
/**
* Macros defining the target platform...
*/
#ifdef _WIN32
#define NS_WIN32 1
#elif defined(__unix)
#define NS_UNIX 1
#elif defined(XP_OS2)
#define NS_OS2 1
#endif
/*----------------------------------------------------------------------*/
/* Import/export defines */
@ -171,7 +159,7 @@ typedef size_t(*nsMallocSizeOfFun)(const void *p, size_t computedSize);
#define NS_CONSTRUCTOR_FASTCALL
#endif
#ifdef NS_WIN32
#ifdef XP_WIN
#define NS_IMPORT __declspec(dllimport)
#define NS_IMPORT_(type) __declspec(dllimport) type __stdcall
@ -395,7 +383,7 @@ typedef PRUint32 nsrefcnt;
* commercial build. When this is fixed there will be no need for the
* |reinterpret_cast| in nsLiteralString.h either.
*/
#if defined(HAVE_CPP_2BYTE_WCHAR_T) && defined(NS_WIN32)
#if defined(HAVE_CPP_2BYTE_WCHAR_T) && defined(XP_WIN)
typedef wchar_t PRUnichar;
#else
typedef PRUint16 PRUnichar;

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

@ -45,7 +45,7 @@
#include "nsCRT.h"
#include "nsUTF8Utils.h"
#include <fcntl.h>
#if defined(NS_WIN32)
#if defined(XP_WIN)
#include <io.h>
#else
#include <unistd.h>