Merge last green PGO from inbound to central

This commit is contained in:
Marco Bonardo 2012-04-04 13:36:36 +02:00
Родитель 13bc64ad52 3668e4363c
Коммит 00f79a5e3a
152 изменённых файлов: 4890 добавлений и 1564 удалений

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

@ -330,12 +330,14 @@ ToNSString(id aValue)
return (lineNumber >= 0) ? [NSNumber numberWithInt:lineNumber] : nil;
}
- (void)setText:(NSString*)newString
- (void)setText:(NSString*)aNewString
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
if (mGeckoEditableTextAccessible) {
mGeckoEditableTextAccessible->SetTextContents(NS_ConvertUTF8toUTF16([newString UTF8String]));
nsString text;
nsCocoaUtils::GetStringForNSString(aNewString, text);
mGeckoEditableTextAccessible->SetTextContents(text);
}
NS_OBJC_END_TRY_ABORT_BLOCK;
@ -347,12 +349,11 @@ ToNSString(id aValue)
return nil;
nsAutoString text;
nsresult rv =
mGeckoTextAccessible->GetText(0, nsIAccessibleText::TEXT_OFFSET_END_OF_TEXT,
text);
NS_ENSURE_SUCCESS(rv, nil);
nsresult rv = mGeckoTextAccessible->
GetText(0, nsIAccessibleText::TEXT_OFFSET_END_OF_TEXT, text);
NS_ENSURE_SUCCESS(rv, @"");
return text.IsEmpty() ? nil : nsCocoaUtils::ToNSString(text);
return nsCocoaUtils::ToNSString(text);
}
- (long)textLength
@ -392,7 +393,7 @@ ToNSString(id aValue)
if (start != end) {
nsAutoString selText;
mGeckoTextAccessible->GetText(start, end, selText);
return selText.IsEmpty() ? nil : [NSString stringWithCharacters:selText.BeginReading() length:selText.Length()];
return nsCocoaUtils::ToNSString(selText);
}
}
return nil;

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

@ -412,11 +412,6 @@ pref("security.fileuri.strict_origin_policy", false);
// compositing isn't default disabled in widget/android.
pref("layers.acceleration.force-enabled", true);
// screen.enabled and screen.brightness properties.
pref("dom.screenEnabledProperty.enabled", true);
pref("dom.screenBrightnessProperty.enabled", true);
pref("dom.mozScreenWhitelist", "http://homescreen.gaiamobile.org,http://settings.gaiamobile.org");
// handle links targeting new windows
// 1=current window/tab, 2=new window, 3=new tab in most recent window
pref("browser.link.open_newwindow", 3);

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

@ -285,7 +285,7 @@ var shell = {
let idleHandler = function idleHandler(subject, topic, time) {
if (topic === "idle") {
if (power.getWakeLockState("screen") != "locked-foreground") {
screen.mozEnabled = false;
navigator.mozPower.screenEnabled = false;
}
}
}
@ -298,10 +298,10 @@ var shell = {
if (topic == "screen") {
if (state != "locked-foreground") {
if (Services.idle.idleTime > idleTimeout*1000) {
screen.mozEnabled = false;
navigator.mozPower.screenEnabled = false;
}
} else {
screen.mozEnabled = true;
navigator.mozPower.screenEnabled = true;
}
}
}

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

@ -56,6 +56,7 @@ _BROWSER_TEST_FILES = \
browser_privatebrowsing_geoprompt.js \
browser_privatebrowsing_geoprompt_page.html \
browser_privatebrowsing_import.js \
browser_privatebrowsing_lastpbcontextexited.js \
browser_privatebrowsing_localStorage.js \
browser_privatebrowsing_localStorage_page1.html \
browser_privatebrowsing_localStorage_page2.html \

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

@ -0,0 +1,66 @@
/* ***** 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 Private Browsing Tests.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2012
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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 ***** */
function test() {
// We need to open a new window for this so that its docshell would get destroyed
// when clearing the PB mode flag.
let newWin = window.openDialog("chrome://browser/content/", "_blank", "chrome,all,dialog=no");
waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
let notificationCount = 0;
let observer = {
observe: function(aSubject, aTopic, aData) {
is(aTopic, "last-pb-context-exited", "Correct topic should be dispatched");
++notificationCount;
}
};
Services.obs.addObserver(observer, "last-pb-context-exited", false);
newWin.gPrivateBrowsingUI.privateWindow = true;
SimpleTest.is(notificationCount, 0, "last-pb-context-exited should not be fired yet");
newWin.gPrivateBrowsingUI.privateWindow = false;
newWin.close();
newWin = null;
window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils)
.garbageCollect(); // Make sure that the docshell is destroyed
SimpleTest.is(notificationCount, 1, "last-pb-context-exited should be fired once");
Services.obs.removeObserver(observer, "last-pb-context-exited", false);
// cleanup
gPrefService.clearUserPref("browser.privatebrowsing.keep_current_session");
finish();
}, newWin);
}

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

@ -82,3 +82,49 @@ if test "$GNU_CC" -a "$GCC_USE_GNU_LD" -a -n "$MOZ_DEBUG_FLAGS"; then
fi
])
dnl GCC and clang will fail if given an unknown warning option like -Wfoobar.
dnl But later versions won't fail if given an unknown negated warning option
dnl like -Wno-foobar. So when we are check for support of negated warning
dnl options, we actually test the positive form, but add the negated form to
dnl the flags variable.
AC_DEFUN([MOZ_C_SUPPORTS_WARNING],
[
AC_CACHE_CHECK(whether the C compiler supports $1$2, $3,
[
AC_LANG_SAVE
AC_LANG_C
_SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Werror -W$2"
AC_TRY_COMPILE([],
[return(0);],
$3="yes",
$3="no")
CFLAGS="$_SAVE_CFLAGS"
AC_LANG_RESTORE
])
if test "${$3}" = "yes"; then
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} $1$2"
fi
])
AC_DEFUN([MOZ_CXX_SUPPORTS_WARNING],
[
AC_CACHE_CHECK(whether the C++ compiler supports $1$2, $3,
[
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
_SAVE_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -Werror -W$2"
AC_TRY_COMPILE([],
[return(0);],
$3="yes",
$3="no")
CXXFLAGS="$_SAVE_CXXFLAGS"
AC_LANG_RESTORE
])
if test "${$3}" = "yes"; then
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} $1$2"
fi
])

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

@ -199,17 +199,17 @@ class DeviceManagerSUT(DeviceManager):
if self.debug >= 1:
print "reconnecting socket"
self._sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
except:
except socket.error, msg:
self._sock = None
raise AgentError("unable to create socket")
raise AgentError("unable to create socket: "+str(msg))
try:
self._sock.connect((self.host, int(self.port)))
self._sock.recv(1024)
except:
except socket.error, msg:
self._sock.close()
self._sock = None
raise AgentError("unable to connect socket")
raise AgentError("unable to connect socket: "+str(msg))
for cmd in cmdlist:
if newline: cmd += '\r\n'
@ -220,9 +220,11 @@ class DeviceManagerSUT(DeviceManager):
raise AgentError("ERROR: our cmd was %s bytes and we only sent %s" % (len(cmd),
numbytes))
if (self.debug >= 4): print "send cmd: " + str(cmd)
except:
except socket.error, msg:
self._sock.close()
self._sock = None
if self.debug >= 1:
print "Error sending data to socket. cmd="+str(cmd)+"; err="+str(msg)
return False
# Check if the command should close the socket
@ -242,10 +244,10 @@ class DeviceManagerSUT(DeviceManager):
try:
temp = self._sock.recv(1024)
if (self.debug >= 4): print "response: " + str(temp)
except:
except socket.error, msg:
self._sock.close()
self._sock = None
raise AgentError("Error receiving data from socket")
raise AgentError("Error receiving data from socket. cmd="+str(cmd)+"; err="+str(msg))
data += temp

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

@ -1707,15 +1707,27 @@ if test "$GNU_CC"; then
_MOZ_RTTI_FLAGS_ON=-frtti
_MOZ_RTTI_FLAGS_OFF=-fno-rtti
# Turn on GNU specific features
# -Wall - turn on all warnings
# -pedantic - make compiler warn about non-ANSI stuff, and
# be a little bit stricter
# Turn on GNU-specific warnings:
# -Wall - turn on a lot of warnings
# -pedantic - this is turned on below
# -Wpointer-arith - enabled with -pedantic, but good to have even if not
# -Wdeclaration-after-statement - MSVC doesn't like these
# Warnings slamm took out for now (these were giving more noise than help):
# -Wbad-function-cast - warns when casting a function to a new return type
# -Wshadow - removed because it generates more noise than help --pete
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall -W -Wno-unused -Wpointer-arith -Wdeclaration-after-statement"
# -Werror=return-type - catches missing returns, zero false positives
# -Wtype-limits - catches overflow bugs, few false positives
# -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
#
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall -Wpointer-arith -Wdeclaration-after-statement"
MOZ_C_SUPPORTS_WARNING(-W, error=return-type, ac_c_has_werror_return_type)
MOZ_C_SUPPORTS_WARNING(-W, type-limits, ac_c_has_wtype_limits)
MOZ_C_SUPPORTS_WARNING(-W, empty-body, ac_c_has_wempty_body)
# Turn off the following warnings that -Wall/-pedantic turn on:
# -Wno-unused - lots of violations in third-party code
# -Wno-overlength-strings - we exceed the minimum maximum length frequently
#
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wno-unused"
MOZ_C_SUPPORTS_WARNING(-Wno-, overlength-strings, ac_c_has_wno_overlength_strings)
if test -z "$INTEL_CC" -a -z "$CLANG_CC"; then
# Don't use -Wcast-align with ICC or clang
case "$CPU_ARCH" in
@ -1731,12 +1743,9 @@ if test "$GNU_CC"; then
dnl Turn pedantic on but disable the warnings for long long
_PEDANTIC=1
if test -z "$INTEL_CC"; then
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -W"
fi
_DEFINES_CFLAGS='-include $(DEPTH)/mozilla-config.h -DMOZILLA_CLIENT'
_USE_CPP_INCLUDE_FLAG=1
elif test "$SOLARIS_SUNPRO_CC"; then
DSO_CFLAGS=''
if test "$CPU_ARCH" = "sparc"; then
@ -1764,8 +1773,32 @@ fi
if test "$GNU_CXX"; then
# FIXME: Let us build with strict aliasing. bug 414641.
CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-strict-aliasing"
# Turn on GNU specific features
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall -Wpointer-arith -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor"
# Turn on GNU-specific warnings:
# -Wall - turn on a lot of warnings
# -pedantic - this is turned on below
# -Wpointer-arith - enabled with -pedantic, but good to have even if not
# -Woverloaded-virtual - ???
# -Werror=return-type - catches missing returns, zero false positives
# -Wtype-limits - catches overflow bugs, few false positives
# -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
#
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall -Wpointer-arith -Woverloaded-virtual"
MOZ_CXX_SUPPORTS_WARNING(-W, error=return-type, ac_cxx_has_werror_return_type)
MOZ_CXX_SUPPORTS_WARNING(-W, type-limits, ac_cxx_has_wtype_limits)
MOZ_CXX_SUPPORTS_WARNING(-W, empty-body, ac_cxx_has_wempty_body)
# Turn off the following warnings that -Wall/-pedantic turn on:
# -Wno-ctor-dtor-privacy - ???
# -Wno-overlength-strings - we exceed the minimum maximum length frequently
# -Wno-invalid-offsetof - we use offsetof on non-POD types frequently
# -Wno-variadic-macros - ???
#
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-ctor-dtor-privacy"
MOZ_CXX_SUPPORTS_WARNING(-Wno-, overlength-strings, ac_cxx_has_wno_overlength_strings)
MOZ_CXX_SUPPORTS_WARNING(-Wno-, invalid-offsetof, ac_cxx_has_wno_invalid_offsetof)
MOZ_CXX_SUPPORTS_WARNING(-Wno-, variadic-macros, ac_cxx_has_wno_variadic_macros)
if test -z "$INTEL_CXX" -a -z "$CLANG_CXX"; then
# Don't use -Wcast-align with ICC or clang
case "$CPU_ARCH" in
@ -1789,81 +1822,7 @@ if test "$GNU_CXX"; then
# deleted function syntax.
if test "$CLANG_CXX"; then
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-c++0x-extensions"
fi
AC_CACHE_CHECK(whether the compiler supports -Wno-extended-offsetof,
ac_has_wno_extended_offsetof,
[
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
_SAVE_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -Wno-extended-offsetof"
AC_TRY_COMPILE([$configure_static_assert_macros
#ifndef __has_warning
#define __has_warning(x) 0
#endif],
[CONFIGURE_STATIC_ASSERT(__has_warning("-Wextended-offsetof"))],
ac_has_wno_extended_offsetof="yes",
ac_has_wno_extended_offsetof="no")
CXXFLAGS="$_SAVE_CXXFLAGS"
AC_LANG_RESTORE
])
if test "$ac_has_wno_extended_offsetof" = "yes"; then
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-extended-offsetof"
fi
AC_CACHE_CHECK(whether the compiler supports -Wno-invalid-offsetof,
ac_has_wno_invalid_offsetof,
[
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
_SAVE_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -Wno-invalid-offsetof"
AC_TRY_COMPILE([],
[return(0);],
ac_has_wno_invalid_offsetof="yes",
ac_has_wno_invalid_offsetof="no")
CXXFLAGS="$_SAVE_CXXFLAGS"
AC_LANG_RESTORE
])
if test "$ac_has_wno_invalid_offsetof" = "yes"; then
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-invalid-offsetof"
fi
AC_CACHE_CHECK(whether the compiler supports -Wno-variadic-macros,
ac_has_wno_variadic_macros,
[
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
_SAVE_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -Wno-variadic-macros"
AC_TRY_COMPILE([],
[return(0);],
ac_has_wno_variadic_macros="yes",
ac_has_wno_variadic_macros="no")
CXXFLAGS="$_SAVE_CXXFLAGS"
AC_LANG_RESTORE
])
if test "$ac_has_wno_variadic_macros" = "yes"; then
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-variadic-macros"
fi
AC_CACHE_CHECK(whether the compiler supports -Werror=return-type,
ac_has_werror_return_type,
[
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
_SAVE_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -Werror=return-type"
AC_TRY_COMPILE([],
[return(0);],
ac_has_werror_return_type="yes",
ac_has_werror_return_type="no")
CXXFLAGS="$_SAVE_CXXFLAGS"
AC_LANG_RESTORE
])
if test "$ac_has_werror_return_type" = "yes"; then
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=return-type"
MOZ_CXX_SUPPORTS_WARNING(-Wno-, extended-offsetof, ac_cxx_has_wno_extended_offsetof)
fi
else

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

@ -61,24 +61,11 @@ nsScriptElement::ScriptAvailable(nsresult aResult,
nsCOMPtr<nsIContent> cont =
do_QueryInterface((nsIScriptElement*) this);
nsRefPtr<nsPresContext> presContext =
nsContentUtils::GetContextForContent(cont);
nsEventStatus status = nsEventStatus_eIgnore;
nsScriptErrorEvent event(true, NS_LOAD_ERROR);
event.lineNr = aLineNo;
NS_NAMED_LITERAL_STRING(errorString, "Error loading script");
event.errorMsg = errorString.get();
nsCAutoString spec;
aURI->GetSpec(spec);
NS_ConvertUTF8toUTF16 fileName(spec);
event.fileName = fileName.get();
nsEventDispatcher::Dispatch(cont, presContext, &event, nsnull, &status);
return nsContentUtils::DispatchTrustedEvent(cont->OwnerDoc(),
cont,
NS_LITERAL_STRING("error"),
false /* bubbles */,
false /* cancelable */);
}
return NS_OK;

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

@ -576,6 +576,7 @@ _TEST_FILES2 = \
file_bug650386_content.sjs \
file_bug650386_report.sjs \
test_bug719533.html \
test_bug737087.html \
$(NULL)
_CHROME_FILES = \

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

@ -63,6 +63,22 @@ ok(false, "NOT REACHED");
ok(true, "an undefined options member should throw");
}
/** Test for dictionary initialization order **/
(function() {
var o = {};
var p = {type: "text/plain", endings: "transparent"};
var called = [];
function add_to_called(n) {
called.push(n);
return p[n];
}
["type", "endings"].forEach(function(n) {
Object.defineProperty(o, n, { get: add_to_called.bind(null, n) });
});
var b = new Blob([], o);
is(JSON.stringify(called), JSON.stringify(["endings", "type"]), "dictionary members should be get in lexicographical order");
})();
let blob1 = Blob(["squiggle"]);
ok(blob1 instanceof Blob, "Blob constructor should produce Blobs");
ok(!(blob1 instanceof File), "Blob constructor should not produce Files");

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

@ -56,14 +56,14 @@ window.onerror = function(message, uri, line) {
<script type="application/javascript">
errorFired = false;
global = "";
window.onerror = function(message, uri, line) {
is(message, "Error loading script", "Should have correct error message");
is(uri,
"http://example.com/tests/content/base/test/bug696301-script-2.js",
"Should still have correct script URI even when failing CORS");
is(line, 1, "Load failures seem to count as line 1");
window.addEventListener("error", function(e) {
is(Object.getPrototypeOf(e), Event.prototype,
"Object prototype should be Event");
var externalScripts = document.querySelectorAll("script[src]");
is(e.target, externalScripts[externalScripts.length - 1],
"Event's target should be the right <script>");
errorFired = true;
}
}, true);
</script>
<script src="http://example.com/tests/content/base/test/bug696301-script-2.js"
crossorigin></script>

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

@ -58,14 +58,14 @@ window.onerror = function(message, uri, line) {
<script type="application/javascript">
errorFired = false;
global = "";
window.onerror = function(message, uri, line) {
is(message, "Error loading script", "Should have correct error message");
is(uri,
"http://example.com/tests/content/base/test/bug696301-script-2.js",
"Should still have correct script URI even when failing CORS");
is(line, 1, "Load failures seem to count as line 1");
window.addEventListener("error", function(e) {
is(Object.getPrototypeOf(e), Event.prototype,
"Object prototype should be Event");
var scripts = document.querySelectorAll("script");
is(e.target, scripts[scripts.length - 1],
"Event's target should be the right &lt;script>");
errorFired = true;
}
}, true);
</script>
<script xlink:href="http://example.com/tests/content/base/test/bug696301-script-2.js"
crossorigin></script>

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

@ -0,0 +1,37 @@
<!DOCTYPE HTML>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=737087
-->
<title>Test for Bug 737087</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=737087">Mozilla Bug 737087</a>
<script>
/** Test for Bug 737087 **/
SimpleTest.waitForExplicitFinish();
var bubbled = false;
var capturedEvent = null;
var inlineFiredEvent = null;
addEventListener("error", function() { bubbled = true });
addEventListener("error", function(e) {
capturedEvent = e;
is(typeof e, "object", "Error event must be object");
is(Object.getPrototypeOf(e), Event.prototype, "Error event must be Event");
is(e.bubbles, false, "e.bubbles must be false");
is(e.cancelable, false, "e.cancelable must be false");
}, true);
addLoadEvent(function() {
is(bubbled, false, "Error event must not bubble");
isnot(capturedEvent, null, "Error event must be captured");
isnot(inlineFiredEvent, null, "Inline error handler must fire");
is(capturedEvent, inlineFiredEvent,
"Same event must be handled by both handlers");
SimpleTest.finish();
});
</script>
<script src=nonexistent
onerror="inlineFiredEvent = event"></script>

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

@ -127,9 +127,10 @@ struct WebGLTexelPremultiplicationOp {
int GetWebGLTexelFormat(GLenum format, GLenum type);
// Zero is not an integer power of two.
inline bool is_pot_assuming_nonnegative(WebGLsizei x)
{
return (x & (x-1)) == 0;
return x && (x & (x-1)) == 0;
}
/* Each WebGL object class WebGLFoo wants to:
@ -585,6 +586,7 @@ public:
nsresult ErrorOutOfMemory(const char *fmt = 0, ...);
const char *ErrorName(GLenum error);
bool IsTextureFormatCompressed(GLenum format);
nsresult DummyFramebufferOperation(const char *info);
@ -1247,14 +1249,26 @@ public:
class ImageInfo : public WebGLRectangleObject {
public:
ImageInfo() : mFormat(0), mType(0), mIsDefined(false) {}
ImageInfo()
: mFormat(0)
, mType(0)
, mIsDefined(false)
{}
ImageInfo(WebGLsizei width, WebGLsizei height,
WebGLenum format, WebGLenum type)
: WebGLRectangleObject(width, height), mFormat(format), mType(type), mIsDefined(true) {}
: WebGLRectangleObject(width, height)
, mFormat(format)
, mType(type)
, mIsDefined(true)
{}
bool operator==(const ImageInfo& a) const {
return mWidth == a.mWidth && mHeight == a.mHeight &&
mFormat == a.mFormat && mType == a.mType;
return mIsDefined == a.mIsDefined &&
mWidth == a.mWidth &&
mHeight == a.mHeight &&
mFormat == a.mFormat &&
mType == a.mType;
}
bool operator!=(const ImageInfo& a) const {
return !(*this == a);

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

@ -1911,15 +1911,20 @@ WebGLContext::GenerateMipmap(WebGLenum target)
WebGLTexture *tex = activeBoundTextureForTarget(target);
if (!tex)
return ErrorInvalidOperation("generateMipmap: no texture is bound to this target");
return ErrorInvalidOperation("generateMipmap: No texture is bound to this target.");
if (!tex->IsFirstImagePowerOfTwo()) {
return ErrorInvalidOperation("generateMipmap: the width or height of this texture is not a power of two");
}
if (!tex->HasImageInfoAt(0, 0))
return ErrorInvalidOperation("generateMipmap: Level zero of texture is not defined.");
if (!tex->AreAllLevel0ImageInfosEqual()) {
return ErrorInvalidOperation("generateMipmap: the six faces of this cube map have different dimensions, format, or type.");
}
if (!tex->IsFirstImagePowerOfTwo())
return ErrorInvalidOperation("generateMipmap: Level zero of texture does not have power-of-two width and height.");
GLenum format = tex->ImageInfoAt(0, 0).Format();
if (IsTextureFormatCompressed(format))
return ErrorInvalidOperation("generateMipmap: Texture data at level zero is compressed.");
if (!tex->AreAllLevel0ImageInfosEqual())
return ErrorInvalidOperation("generateMipmap: The six faces of this cube map have different dimensions, format, or type.");
tex->SetGeneratedMipmap();

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

@ -239,4 +239,27 @@ WebGLContext::ErrorName(GLenum error)
NS_ABORT();
return "[unknown WebGL error!]";
}
};
}
bool
WebGLContext::IsTextureFormatCompressed(GLenum format)
{
switch(format) {
case LOCAL_GL_RGB:
case LOCAL_GL_RGBA:
case LOCAL_GL_ALPHA:
case LOCAL_GL_LUMINANCE:
case LOCAL_GL_LUMINANCE_ALPHA:
return false;
case LOCAL_GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
case LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
case LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
return true;
}
NS_NOTREACHED("Invalid WebGL texture format?");
NS_ABORT();
return false;
}

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

@ -0,0 +1,9 @@
<input form="f" id="x" xmlns="http://www.w3.org/1999/xhtml">
<form id="f"></form>
<script>
window.addEventListener("load", function() {
var x = document.getElementById("x");
x.appendChild(x.cloneNode(true));
}, false);
</script>
</input>

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

@ -34,3 +34,4 @@ load 682058.xhtml
load 682460.html
load 673853.html
load 738744.xhtml
load 741250.xhtml

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

@ -2366,7 +2366,10 @@ nsFormControlList::AddElementToTable(nsGenericHTMLFormElement* aChild,
// the list in the hash
nsSimpleContentList *list = new nsSimpleContentList(mForm);
NS_ASSERTION(content->GetParent(), "Item in list without parent");
// If an element has a @form, we can assume it *might* be able to not have
// a parent and still be in the form.
NS_ASSERTION(content->HasAttr(kNameSpaceID_None, nsGkAtoms::form) ||
content->GetParent(), "Item in list without parent");
// Determine the ordering between the new and old element.
bool newFirst = nsContentUtils::PositionIsBefore(aChild, content);

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

@ -90,7 +90,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=408231
["removeformat", "exception"],
["selectall", "exception"],
["strikethrough", "false"],
["styleWithCSS", "exception"],
["styleWithCSS", "false"],
["subscript", "false"],
["superscript", "false"],
["underline", "false"],
@ -130,7 +130,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=408231
["removeformat", ""],
["selectall", ""],
["strikethrough", ""],
["styleWithCSS", "exception"],
["styleWithCSS", ""],
["subscript", ""],
["superscript", ""],
["underline", ""],

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

@ -3233,6 +3233,13 @@ nsHTMLDocument::QueryCommandState(const nsAString & commandID, bool *_retval)
if (!window)
return NS_ERROR_FAILURE;
if (commandID.LowerCaseEqualsLiteral("usecss")) {
// Per spec, state is supported for styleWithCSS but not useCSS, so we just
// return false always.
*_retval = false;
return NS_OK;
}
nsCAutoString cmdToDispatch, paramToCheck;
bool dummy, dummy2;
if (!ConvertToMidasInternalCommand(commandID, commandID,

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

@ -671,7 +671,7 @@ nsSMILAnimationFunction::ScaleSimpleProgress(double aProgress,
return aProgress;
PRUint32 i = 0;
for (; i < numTimes - 2 && aProgress >= mKeyTimes[i+1]; ++i);
for (; i < numTimes - 2 && aProgress >= mKeyTimes[i+1]; ++i) { }
if (aCalcMode == CALC_DISCRETE) {
// discrete calcMode behaviour differs in that each keyTime defines the time

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

@ -1767,7 +1767,7 @@ nsSMILTimedElement::GetNextGreater(const InstanceTimeList& aList,
{
nsSMILInstanceTime* result = nsnull;
while ((result = GetNextGreaterOrEqual(aList, aBase, aPosition)) &&
result->Time() == aBase);
result->Time() == aBase) { }
return result;
}

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

@ -102,8 +102,7 @@ protected:
const txExpandedName key()
{
NS_ASSERTION(mCurrentPos >= 0 &&
mCurrentPos < mMap.mItems.Length(),
NS_ASSERTION(mCurrentPos < mMap.mItems.Length(),
"invalid position in txExpandedNameMap::iterator");
return txExpandedName(mMap.mItems[mCurrentPos].mNamespaceID,
mMap.mItems[mCurrentPos].mLocalName);
@ -112,8 +111,7 @@ protected:
protected:
void* itemValue()
{
NS_ASSERTION(mCurrentPos >= 0 &&
mCurrentPos < mMap.mItems.Length(),
NS_ASSERTION(mCurrentPos < mMap.mItems.Length(),
"invalid position in txExpandedNameMap::iterator");
return mMap.mItems[mCurrentPos].mValue;
}

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

@ -218,6 +218,23 @@ nsXULTemplateBuilder::InitGlobals()
return mPool.Init("nsXULTemplateBuilder", bucketsizes, 1, 256);
}
void
nsXULTemplateBuilder::CleanUp(bool aIsFinal)
{
for (PRInt32 q = mQuerySets.Length() - 1; q >= 0; q--) {
nsTemplateQuerySet* qs = mQuerySets[q];
delete qs;
}
mQuerySets.Clear();
mMatchMap.Enumerate(DestroyMatchList, &mPool);
// Setting mQueryProcessor to null will close connections. This would be
// handled by the cycle collector, but we want to close them earlier.
if (aIsFinal)
mQueryProcessor = nsnull;
}
void
nsXULTemplateBuilder::Uninit(bool aIsFinal)
@ -232,14 +249,7 @@ nsXULTemplateBuilder::Uninit(bool aIsFinal)
if (mQueryProcessor)
mQueryProcessor->Done();
for (PRInt32 q = mQuerySets.Length() - 1; q >= 0; q--) {
nsTemplateQuerySet* qs = mQuerySets[q];
delete qs;
}
mQuerySets.Clear();
mMatchMap.Enumerate(DestroyMatchList, &mPool);
CleanUp(aIsFinal);
mRootResult = nsnull;
mRefVariable = nsnull;
@ -1188,6 +1198,8 @@ nsXULTemplateBuilder::ContentRemoved(nsIDocument* aDocument,
if (xulcontent)
xulcontent->ClearTemplateGenerated();
CleanUp(true);
mDB = nsnull;
mCompDB = nsnull;
mDataSource = nsnull;

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

@ -81,6 +81,8 @@ class nsXULTemplateBuilder : public nsIXULTemplateBuilder,
public nsIObserver,
public nsStubDocumentObserver
{
void CleanUp(bool aIsFinal);
public:
nsXULTemplateBuilder();
virtual ~nsXULTemplateBuilder();

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

@ -1919,6 +1919,9 @@ nsXULTreeBuilder::CompareResults(nsIXULTemplateResult* aLeft, nsIXULTemplateResu
}
PRInt32 sortorder;
if (!mQueryProcessor)
return 0;
mQueryProcessor->CompareResults(aLeft, aRight, mSortVariable, mSortHints, &sortorder);
if (sortorder)

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

@ -148,7 +148,6 @@
#include "nsIJSContextStack.h"
#include "nsIJSRuntimeService.h"
#include "nsIMarkupDocumentViewer.h"
#include "nsIPrefBranch.h"
#include "nsIPresShell.h"
#include "nsIPrivateDOMEvent.h"
#include "nsIProgrammingLanguage.h"

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

@ -42,20 +42,13 @@
#include "nsPresContext.h"
#include "nsCOMPtr.h"
#include "nsDOMClassInfoID.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIDocShellTreeItem.h"
#include "nsLayoutUtils.h"
#include "nsContentUtils.h"
#include "mozilla/Preferences.h"
#include "nsDOMEvent.h"
using namespace mozilla;
using namespace mozilla::dom;
/* static */ bool nsScreen::sInitialized = false;
/* static */ bool nsScreen::sAllowScreenEnabledProperty = false;
/* static */ bool nsScreen::sAllowScreenBrightnessProperty = false;
namespace {
bool
@ -73,26 +66,11 @@ IsChromeType(nsIDocShell *aDocShell)
} // anonymous namespace
/* static */ void
nsScreen::Initialize()
{
MOZ_ASSERT(!sInitialized);
sInitialized = true;
Preferences::AddBoolVarCache(&sAllowScreenEnabledProperty,
"dom.screenEnabledProperty.enabled");
Preferences::AddBoolVarCache(&sAllowScreenBrightnessProperty,
"dom.screenBrightnessProperty.enabled");
}
/* static */ already_AddRefed<nsScreen>
nsScreen::Create(nsPIDOMWindow* aWindow)
{
MOZ_ASSERT(aWindow);
if (!sInitialized) {
Initialize();
}
if (!aWindow->GetDocShell()) {
return nsnull;
}
@ -103,7 +81,6 @@ nsScreen::Create(nsPIDOMWindow* aWindow)
nsRefPtr<nsScreen> screen = new nsScreen();
screen->BindToOwner(aWindow);
screen->mIsChrome = IsChromeType(aWindow->GetDocShell());
hal::RegisterScreenOrientationObserver(screen);
hal::GetCurrentScreenOrientation(&(screen->mOrientation));
@ -148,28 +125,6 @@ NS_IMPL_RELEASE_INHERITED(nsScreen, nsDOMEventTargetHelper)
NS_IMPL_EVENT_HANDLER(nsScreen, mozorientationchange)
bool
nsScreen::IsWhiteListed() {
if (mIsChrome) {
return true;
}
if (!GetOwner()) {
return false;
}
nsCOMPtr<nsIDocument> doc = do_GetInterface(GetOwner()->GetDocShell());
if (!doc) {
return false;
}
nsIPrincipal *principal = doc->NodePrincipal();
nsCOMPtr<nsIURI> principalURI;
principal->GetURI(getter_AddRefs(principalURI));
return nsContentUtils::URIIsChromeOrInPref(principalURI,
"dom.mozScreenWhitelist");
}
NS_IMETHODIMP
nsScreen::GetTop(PRInt32* aTop)
{
@ -329,55 +284,6 @@ nsScreen::GetAvailRect(nsRect& aRect)
return NS_OK;
}
nsresult
nsScreen::GetMozEnabled(bool *aEnabled)
{
if (!sAllowScreenEnabledProperty || !IsWhiteListed()) {
*aEnabled = true;
return NS_OK;
}
*aEnabled = hal::GetScreenEnabled();
return NS_OK;
}
nsresult
nsScreen::SetMozEnabled(bool aEnabled)
{
if (!sAllowScreenEnabledProperty || !IsWhiteListed()) {
return NS_OK;
}
// TODO bug 707589: When the screen's state changes, all visible windows
// should fire a visibility change event.
hal::SetScreenEnabled(aEnabled);
return NS_OK;
}
nsresult
nsScreen::GetMozBrightness(double *aBrightness)
{
if (!sAllowScreenEnabledProperty || !IsWhiteListed()) {
*aBrightness = 1;
return NS_OK;
}
*aBrightness = hal::GetScreenBrightness();
return NS_OK;
}
nsresult
nsScreen::SetMozBrightness(double aBrightness)
{
if (!sAllowScreenEnabledProperty || !IsWhiteListed()) {
return NS_OK;
}
NS_ENSURE_TRUE(0 <= aBrightness && aBrightness <= 1, NS_ERROR_INVALID_ARG);
hal::SetScreenBrightness(aBrightness);
return NS_OK;
}
void
nsScreen::Notify(const ScreenOrientationWrapper& aOrientation)
{

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

@ -74,8 +74,6 @@ protected:
nsresult GetRect(nsRect& aRect);
nsresult GetAvailRect(nsRect& aRect);
bool mIsChrome;
mozilla::dom::ScreenOrientation mOrientation;
private:
@ -91,14 +89,6 @@ private:
nsScreen();
virtual ~nsScreen();
static bool sInitialized;
static bool sAllowScreenEnabledProperty;
static bool sAllowScreenBrightnessProperty;
static void Initialize();
bool IsWhiteListed();
nsRefPtr<FullScreenEventListener> mEventListener;
NS_DECL_EVENT_HANDLER(mozorientationchange)

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

@ -39,7 +39,7 @@
#include "nsIDOMEventTarget.idl"
[scriptable, uuid(8a66b30c-9a32-4b17-ab4e-ca8b7b588243)]
[scriptable, uuid(9b978f58-5bfe-409d-aa3f-946ca934e51d)]
interface nsIDOMScreen : nsIDOMEventTarget
{
readonly attribute long top;
@ -53,29 +53,6 @@ interface nsIDOMScreen : nsIDOMEventTarget
readonly attribute long availLeft;
readonly attribute long availTop;
/**
* Is the device's screen currently enabled? This attribute controls the
* device's screen, so setting it to false will turn off the screen.
*/
attribute boolean mozEnabled;
/**
* How bright is the screen's backlight, on a scale from 0 (very dim) to 1
* (full brightness)? Setting this attribute modifies the screen's
* brightness.
*
* You can read and write this attribute even when the screen is disabled,
* but the backlight is off while the screen is disabled.
*
* If you write a value of X into this attribute, the attribute may not have
* the same value X when you later read it. Most screens don't support as
* many different brightness levels as there are doubles between 0 and 1, so
* we may reduce the value's precision before storing it.
*
* @throw NS_ERROR_INVALID_ARG if brightness is not in the range [0, 1].
*/
attribute double mozBrightness;
/**
* Returns the current screen orientation.
* Can be: landscape-primary, landscape-secondary,

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

@ -49,8 +49,6 @@
#include "nsIFilePicker.h"
#include "nsIWindowWatcher.h"
#include "nsIDOMWindow.h"
#include "nsIPrefBranch.h"
#include "nsIPrefLocalizedString.h"
#include "nsIObserverService.h"
#include "nsContentUtils.h"
#include "nsAutoPtr.h"
@ -216,10 +214,7 @@ ContentParent::Init()
obs->AddObserver(this, "a11y-init-or-shutdown", false);
#endif
}
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefs) {
prefs->AddObserver("", this, false);
}
Preferences::AddStrongObserver(this, "");
nsCOMPtr<nsIThreadInternal>
threadInt(do_QueryInterface(NS_GetCurrentThread()));
if (threadInt) {
@ -249,13 +244,8 @@ ContentParent::OnChannelConnected(int32 pid)
SetOtherProcess(handle);
#if defined(ANDROID) || defined(LINUX)
EnsurePrefService();
nsCOMPtr<nsIPrefBranch> branch;
branch = do_QueryInterface(mPrefService);
// Check nice preference
PRInt32 nice = 0;
branch->GetIntPref("dom.ipc.content.nice", &nice);
PRInt32 nice = Preferences::GetInt("dom.ipc.content.nice", 0);
// Environment variable overrides preference
char* relativeNicenessStr = getenv("MOZ_CHILD_PROCESS_RELATIVE_NICENESS");
@ -329,11 +319,7 @@ ContentParent::ActorDestroy(ActorDestroyReason why)
SetChildMemoryReporters(empty);
// remove the global remote preferences observers
nsCOMPtr<nsIPrefBranch> prefs
(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefs) {
prefs->RemoveObserver("", this);
}
Preferences::RemoveObserver(this, "");
RecvRemoveGeolocationListener();
@ -464,7 +450,6 @@ ContentParent::IsAlive()
bool
ContentParent::RecvReadPrefsArray(InfallibleTArray<PrefTuple> *prefs)
{
EnsurePrefService();
Preferences::MirrorPreferences(prefs);
return true;
}
@ -478,18 +463,6 @@ ContentParent::RecvReadFontList(InfallibleTArray<FontListEntry>* retValue)
return true;
}
void
ContentParent::EnsurePrefService()
{
nsresult rv;
if (!mPrefService) {
mPrefService = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
NS_ASSERTION(NS_SUCCEEDED(rv),
"We lost prefService in the Chrome process !");
}
}
bool
ContentParent::RecvReadPermissions(InfallibleTArray<IPC::Permission>* aPermissions)
{

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

@ -48,7 +48,6 @@
#include "nsIObserver.h"
#include "nsIThreadInternal.h"
#include "nsNetUtil.h"
#include "nsIPrefService.h"
#include "nsIPermissionManager.h"
#include "nsIDOMGeoPositionCallback.h"
#include "nsIMemoryReporter.h"
@ -167,8 +166,6 @@ private:
virtual bool RecvReadPrefsArray(InfallibleTArray<PrefTuple> *retValue);
virtual bool RecvReadFontList(InfallibleTArray<FontListEntry>* retValue);
void EnsurePrefService();
virtual bool RecvReadPermissions(InfallibleTArray<IPC::Permission>* aPermissions);
virtual bool RecvGetIndexedDBDirectory(nsString* aDirectory);
@ -238,8 +235,6 @@ private:
nsCOMArray<nsIMemoryReporter> mMemoryReporters;
bool mIsAlive;
nsCOMPtr<nsIPrefService> mPrefService;
bool mSendPermissionUpdates;
nsRefPtr<nsFrameMessageManager> mMessageManager;

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

@ -55,12 +55,11 @@
#include "nsIServiceManager.h"
#include "nsThreadUtils.h"
#include "nsIPrivateBrowsingService.h"
#include "mozilla/Preferences.h"
#include "nsIPluginStreamListener.h"
#include "nsPluginsDir.h"
#include "nsPluginSafety.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "nsPluginLogging.h"
#include "nsIJSContextStack.h"
@ -352,7 +351,7 @@ nsNPAPIPlugin::RunPluginOOP(const nsPluginTag *aPluginTag)
}
#endif
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
nsIPrefBranch* prefs = Preferences::GetRootBranch();
if (!prefs) {
return false;
}
@ -385,8 +384,7 @@ nsNPAPIPlugin::RunPluginOOP(const nsPluginTag *aPluginTag)
// so use the mime type (mIsJavaPlugin) and a special pref.
bool javaIsEnabled;
if (aPluginTag->mIsJavaPlugin &&
NS_SUCCEEDED(prefs->GetBoolPref("dom.ipc.plugins.java.enabled", &javaIsEnabled)) &&
!javaIsEnabled) {
!Preferences::GetBool("dom.ipc.plugins.java.enabled", true)) {
return false;
}
@ -417,8 +415,8 @@ nsNPAPIPlugin::RunPluginOOP(const nsPluginTag *aPluginTag)
match = (NS_WildCardMatch(prefFile.get(), maskStart, 0) == MATCH);
}
if (match && NS_SUCCEEDED(prefs->GetBoolPref(prefNames[currentPref],
&oopPluginsEnabled))) {
if (match && NS_SUCCEEDED(Preferences::GetBool(prefNames[currentPref],
&oopPluginsEnabled))) {
prefSet = true;
break;
}
@ -427,17 +425,17 @@ nsNPAPIPlugin::RunPluginOOP(const nsPluginTag *aPluginTag)
}
if (!prefSet) {
oopPluginsEnabled = false;
oopPluginsEnabled =
#ifdef XP_MACOSX
#if defined(__i386__)
prefs->GetBoolPref("dom.ipc.plugins.enabled.i386", &oopPluginsEnabled);
Preferences::GetBool("dom.ipc.plugins.enabled.i386", false);
#elif defined(__x86_64__)
prefs->GetBoolPref("dom.ipc.plugins.enabled.x86_64", &oopPluginsEnabled);
Preferences::GetBool("dom.ipc.plugins.enabled.x86_64", false);
#elif defined(__ppc__)
prefs->GetBoolPref("dom.ipc.plugins.enabled.ppc", &oopPluginsEnabled);
Preferences::GetBool("dom.ipc.plugins.enabled.ppc", false);
#endif
#else
prefs->GetBoolPref("dom.ipc.plugins.enabled", &oopPluginsEnabled);
Preferences::GetBool("dom.ipc.plugins.enabled", false);
#endif
}
@ -2061,12 +2059,10 @@ _getvalue(NPP npp, NPNVariable variable, void *result)
case NPNVjavascriptEnabledBool: {
*(NPBool*)result = false;
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefs) {
bool js = false;;
res = prefs->GetBoolPref("javascript.enabled", &js);
if (NS_SUCCEEDED(res))
*(NPBool*)result = js;
bool js = false;
res = Preferences::GetBool("javascript.enabled", &js);
if (NS_SUCCEEDED(res)) {
*(NPBool*)result = js;
}
return NPERR_NO_ERROR;
}

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

@ -61,6 +61,8 @@
#include "nsNetCID.h"
#include "nsIContent.h"
#include "mozilla/Preferences.h"
#ifdef MOZ_WIDGET_ANDROID
#include "ANPBase.h"
#include <android/log.h>
@ -105,13 +107,8 @@ nsNPAPIPluginInstance::nsNPAPIPluginInstance()
mNPP.pdata = NULL;
mNPP.ndata = this;
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefs) {
bool useLayersPref;
nsresult rv = prefs->GetBoolPref("plugins.use_layers", &useLayersPref);
if (NS_SUCCEEDED(rv))
mUsePluginLayersPref = useLayersPref;
}
mUsePluginLayersPref =
Preferences::GetBool("plugins.use_layers", mUsePluginLayersPref);
PLUGIN_LOG(PLUGIN_LOG_BASIC, ("nsNPAPIPluginInstance ctor: this=%p\n",this));
}

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

@ -41,16 +41,16 @@
#include "nsCRT.h"
#include "nsILocalFile.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsDependentString.h"
#include "nsXPIDLString.h"
#include "prmem.h"
#include "nsArrayEnumerator.h"
#include "mozilla/Preferences.h"
#include <windows.h>
#include "nsIWindowsRegKey.h"
using namespace mozilla;
typedef struct structVer
{
WORD wMajor;
@ -231,18 +231,15 @@ nsPluginDirServiceProvider::GetFile(const char *charProp, bool *persistant,
*_retval = nsnull;
*persistant = false;
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (!prefs)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIWindowsRegKey> regKey =
do_CreateInstance("@mozilla.org/windows-registry-key;1");
NS_ENSURE_TRUE(regKey, NS_ERROR_FAILURE);
if (nsCRT::strcmp(charProp, NS_WIN_JRE_SCAN_KEY) == 0) {
nsXPIDLCString strVer;
if (NS_FAILED(prefs->GetCharPref(charProp, getter_Copies(strVer))))
nsAdoptingCString strVer = Preferences::GetCString(charProp);
if (!strVer) {
return NS_ERROR_FAILURE;
}
verBlock minVer;
TranslateVersionStr(NS_ConvertASCIItoUTF16(strVer).get(), &minVer);
@ -332,9 +329,10 @@ nsPluginDirServiceProvider::GetFile(const char *charProp, bool *persistant,
}
}
} else if (nsCRT::strcmp(charProp, NS_WIN_QUICKTIME_SCAN_KEY) == 0) {
nsXPIDLCString strVer;
if (NS_FAILED(prefs->GetCharPref(charProp, getter_Copies(strVer))))
nsAdoptingCString strVer = Preferences::GetCString(charProp);
if (!strVer) {
return NS_ERROR_FAILURE;
}
verBlock minVer;
TranslateVersionStr(NS_ConvertASCIItoUTF16(strVer).get(), &minVer);
@ -371,9 +369,10 @@ nsPluginDirServiceProvider::GetFile(const char *charProp, bool *persistant,
}
}
} else if (nsCRT::strcmp(charProp, NS_WIN_WMP_SCAN_KEY) == 0) {
nsXPIDLCString strVer;
if (NS_FAILED(prefs->GetCharPref(charProp, getter_Copies(strVer))))
nsAdoptingCString strVer = Preferences::GetCString(charProp);
if (!strVer) {
return NS_ERROR_FAILURE;
}
verBlock minVer;
TranslateVersionStr(NS_ConvertASCIItoUTF16(strVer).get(), &minVer);
@ -409,8 +408,8 @@ nsPluginDirServiceProvider::GetFile(const char *charProp, bool *persistant,
}
}
} else if (nsCRT::strcmp(charProp, NS_WIN_ACROBAT_SCAN_KEY) == 0) {
nsXPIDLCString strVer;
if (NS_FAILED(prefs->GetCharPref(charProp, getter_Copies(strVer)))) {
nsAdoptingCString strVer = Preferences::GetCString(charProp);
if (!strVer) {
return NS_ERROR_FAILURE;
}

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

@ -80,7 +80,6 @@
#include "nsHashtable.h"
#include "nsIProxyInfo.h"
#include "nsPluginLogging.h"
#include "nsIPrefBranch.h"
#include "nsIScriptChannel.h"
#include "nsIBlocklistService.h"
#include "nsVersionComparator.h"
@ -88,6 +87,7 @@
#include "nsIObjectLoadingContent.h"
#include "nsIWritablePropertyBag2.h"
#include "nsPluginStreamListenerPeer.h"
#include "mozilla/Preferences.h"
#include "nsEnumeratorUtils.h"
#include "nsXPCOM.h"
@ -336,17 +336,7 @@ NS_IMETHODIMP nsPluginDocReframeEvent::Run() {
static bool UnloadPluginsASAP()
{
nsresult rv;
nsCOMPtr<nsIPrefBranch> pref(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
if (NS_SUCCEEDED(rv)) {
bool unloadPluginsASAP = false;
rv = pref->GetBoolPref("dom.ipc.plugins.unloadASAP", &unloadPluginsASAP);
if (NS_SUCCEEDED(rv)) {
return unloadPluginsASAP;
}
}
return false;
return Preferences::GetBool("dom.ipc.plugins.unloadASAP", false);
}
nsPluginHost::nsPluginHost()
@ -355,20 +345,10 @@ nsPluginHost::nsPluginHost()
{
// check to see if pref is set at startup to let plugins take over in
// full page mode for certain image mime types that we handle internally
mPrefService = do_GetService(NS_PREFSERVICE_CONTRACTID);
if (mPrefService) {
bool tmp;
nsresult rv = mPrefService->GetBoolPref("plugin.override_internal_types",
&tmp);
if (NS_SUCCEEDED(rv)) {
mOverrideInternalTypes = tmp;
}
mOverrideInternalTypes =
Preferences::GetBool("plugin.override_internal_types", false);
rv = mPrefService->GetBoolPref("plugin.disable", &tmp);
if (NS_SUCCEEDED(rv)) {
mPluginsDisabled = tmp;
}
}
mPluginsDisabled = Preferences::GetBool("plugin.disable", false);
nsCOMPtr<nsIObserverService> obsService =
mozilla::services::GetObserverService();
@ -428,16 +408,16 @@ nsPluginHost::GetInst()
return sInst;
}
bool nsPluginHost::IsRunningPlugin(nsPluginTag * plugin)
bool nsPluginHost::IsRunningPlugin(nsPluginTag * aPluginTag)
{
if (!plugin || !plugin->mEntryPoint) {
if (!aPluginTag || !aPluginTag->mPlugin) {
return false;
}
for (PRUint32 i = 0; i < mInstances.Length(); i++) {
nsNPAPIPluginInstance *instance = mInstances[i].get();
if (instance &&
instance->GetPlugin() == plugin->mEntryPoint &&
instance->GetPlugin() == aPluginTag->mPlugin &&
instance->IsRunning()) {
return true;
}
@ -866,8 +846,6 @@ nsresult nsPluginHost::Destroy()
}
#endif /* XP_WIN */
mPrefService = nsnull; // release prefs service to avoid leaks!
return NS_OK;
}
@ -1198,7 +1176,7 @@ nsPluginHost::TagForPlugin(nsNPAPIPlugin* aPlugin)
{
nsPluginTag* pluginTag;
for (pluginTag = mPlugins; pluginTag; pluginTag = pluginTag->mNext) {
if (pluginTag->mEntryPoint == aPlugin) {
if (pluginTag->mPlugin == aPlugin) {
return pluginTag;
}
}
@ -1213,37 +1191,31 @@ nsresult nsPluginHost::SetUpPluginInstance(const char *aMimeType,
{
NS_ENSURE_ARG_POINTER(aOwner);
nsresult rv = NS_OK;
rv = TrySetUpPluginInstance(aMimeType, aURL, aOwner);
// if we fail, refresh plugin list just in case the plugin has been
// just added and try to instantiate plugin instance again, see bug 143178
if (NS_FAILED(rv)) {
// we should also make sure not to do this more than once per page
// so if there are a few embed tags with unknown plugins,
// we don't get unnecessary overhead
// let's cache document to decide whether this is the same page or not
nsCOMPtr<nsIDocument> document;
aOwner->GetDocument(getter_AddRefs(document));
nsCOMPtr<nsIDocument> currentdocument = do_QueryReferent(mCurrentDocument);
if (document == currentdocument)
return rv;
mCurrentDocument = do_GetWeakReference(document);
// ReloadPlugins will do the job smartly: nothing will be done
// if no changes detected, in such a case just return
if (NS_ERROR_PLUGINS_PLUGINSNOTCHANGED == ReloadPlugins(false))
return rv;
// other failure return codes may be not fatal, so we can still try
aOwner->SetInstance(nsnull); // avoid assert about setting it twice
rv = TrySetUpPluginInstance(aMimeType, aURL, aOwner);
nsresult rv = TrySetUpPluginInstance(aMimeType, aURL, aOwner);
if (NS_SUCCEEDED(rv)) {
return rv;
}
return rv;
// If we failed to load a plugin instance we'll try again after
// reloading our plugin list. Only do that once per document to
// avoid redundant high resource usage on pages with multiple
// unkown instance types. We'll do that by caching the document.
nsCOMPtr<nsIDocument> document;
aOwner->GetDocument(getter_AddRefs(document));
nsCOMPtr<nsIDocument> currentdocument = do_QueryReferent(mCurrentDocument);
if (document == currentdocument) {
return rv;
}
mCurrentDocument = do_GetWeakReference(document);
// Don't try to set up an instance again if nothing changed.
if (ReloadPlugins(false) == NS_ERROR_PLUGINS_PLUGINSNOTCHANGED) {
return rv;
}
return TrySetUpPluginInstance(aMimeType, aURL, aOwner);
}
nsresult
@ -1460,11 +1432,7 @@ public:
NS_METHOD GetFilename(nsAString& aFilename)
{
bool bShowPath;
nsCOMPtr<nsIPrefBranch> prefService = do_GetService(NS_PREFSERVICE_CONTRACTID);
if (prefService &&
NS_SUCCEEDED(prefService->GetBoolPref("plugin.expose_full_path", &bShowPath)) &&
bShowPath) {
if (Preferences::GetBool("plugin.expose_full_path", false)) {
CopyUTF8toUTF16(mPluginTag.mFullPath, aFilename);
} else {
CopyUTF8toUTF16(mPluginTag.mFileName, aFilename);
@ -1658,15 +1626,15 @@ static nsresult CreateNPAPIPlugin(nsPluginTag *aPluginTag,
return rv;
}
nsresult nsPluginHost::EnsurePluginLoaded(nsPluginTag* plugin)
nsresult nsPluginHost::EnsurePluginLoaded(nsPluginTag* aPluginTag)
{
nsRefPtr<nsNPAPIPlugin> entrypoint = plugin->mEntryPoint;
if (!entrypoint) {
nsresult rv = CreateNPAPIPlugin(plugin, getter_AddRefs(entrypoint));
nsRefPtr<nsNPAPIPlugin> plugin = aPluginTag->mPlugin;
if (!plugin) {
nsresult rv = CreateNPAPIPlugin(aPluginTag, getter_AddRefs(plugin));
if (NS_FAILED(rv)) {
return rv;
}
plugin->mEntryPoint = entrypoint;
aPluginTag->mPlugin = plugin;
}
return NS_OK;
}
@ -1699,7 +1667,7 @@ nsresult nsPluginHost::GetPlugin(const char *aMimeType, nsNPAPIPlugin** aPlugin)
return rv;
}
NS_ADDREF(*aPlugin = pluginTag->mEntryPoint);
NS_ADDREF(*aPlugin = pluginTag->mPlugin);
return NS_OK;
}
@ -1823,7 +1791,7 @@ nsPluginHost::ClearSiteData(nsIPluginTag* plugin, const nsACString& domain,
// We only ensure support for clearing Flash site data for now.
// We will also attempt to clear data for any plugin that happens
// to be loaded already.
if (!tag->mIsFlashPlugin && !tag->mEntryPoint) {
if (!tag->mIsFlashPlugin && !tag->mPlugin) {
return NS_ERROR_FAILURE;
}
@ -1833,7 +1801,7 @@ nsPluginHost::ClearSiteData(nsIPluginTag* plugin, const nsACString& domain,
return rv;
}
PluginLibrary* library = tag->mEntryPoint->GetLibrary();
PluginLibrary* library = tag->mPlugin->GetLibrary();
// If 'domain' is the null string, clear everything.
if (domain.IsVoid()) {
@ -1874,7 +1842,7 @@ nsPluginHost::SiteHasData(nsIPluginTag* plugin, const nsACString& domain,
// We only ensure support for clearing Flash site data for now.
// We will also attempt to clear data for any plugin that happens
// to be loaded already.
if (!tag->mIsFlashPlugin && !tag->mEntryPoint) {
if (!tag->mIsFlashPlugin && !tag->mPlugin) {
return NS_ERROR_FAILURE;
}
@ -1884,7 +1852,7 @@ nsPluginHost::SiteHasData(nsIPluginTag* plugin, const nsACString& domain,
return rv;
}
PluginLibrary* library = tag->mEntryPoint->GetLibrary();
PluginLibrary* library = tag->mPlugin->GetLibrary();
// Get the list of sites from the plugin.
InfallibleTArray<nsCString> sites;
@ -2225,7 +2193,7 @@ nsresult nsPluginHost::ScanPluginsDirectory(nsIFile *pluginsDir,
}
if (warnOutdated) {
mPrefService->SetBoolPref("plugins.update.notifyUser", true);
Preferences::SetBool("plugins.update.notifyUser", true);
}
return NS_OK;
@ -2354,10 +2322,7 @@ nsresult nsPluginHost::FindPlugins(bool aCreatePluginList, bool * aPluginsChange
// the rest is optional
#ifdef XP_WIN
bool bScanPLIDs = false;
if (mPrefService)
mPrefService->GetBoolPref("plugin.scan.plid.all", &bScanPLIDs);
bool bScanPLIDs = Preferences::GetBool("plugin.scan.plid.all", false);
// Now lets scan any PLID directories
if (bScanPLIDs && mPrivateDirServiceProvider) {
@ -3239,13 +3204,9 @@ nsPluginHost::StopPluginInstance(nsNPAPIPluginInstance* aInstance)
bool doCache = aInstance->ShouldCache();
if (doCache) {
// try to get the max cached instances from a pref or use default
PRUint32 cachedInstanceLimit;
nsresult rv = NS_ERROR_FAILURE;
if (mPrefService)
rv = mPrefService->GetIntPref(NS_PREF_MAX_NUM_CACHED_INSTANCES, (int*)&cachedInstanceLimit);
if (NS_FAILED(rv))
cachedInstanceLimit = DEFAULT_NUMBER_OF_STOPPED_INSTANCES;
PRUint32 cachedInstanceLimit =
Preferences::GetUint(NS_PREF_MAX_NUM_CACHED_INSTANCES,
DEFAULT_NUMBER_OF_STOPPED_INSTANCES);
if (StoppedInstanceCount() >= cachedInstanceLimit) {
nsNPAPIPluginInstance *oldestInstance = FindOldestStoppedInstance();
if (oldestInstance) {
@ -3984,10 +3945,10 @@ nsPluginHost::PluginCrashed(nsNPAPIPlugin* aPlugin,
}
// Only after all instances have been invalidated is it safe to null
// out nsPluginTag.mEntryPoint. The next time we try to create an
// out nsPluginTag.mPlugin. The next time we try to create an
// instance of this plugin we reload it (launch a new plugin process).
crashedPluginTag->mEntryPoint = nsnull;
crashedPluginTag->mPlugin = nsnull;
#ifdef XP_WIN
CheckForDisabledWindows();

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

@ -53,7 +53,6 @@
#include "nsWeakPtr.h"
#include "nsIPrompt.h"
#include "nsISupportsArray.h"
#include "nsIPrefBranch.h"
#include "nsWeakReference.h"
#include "nsThreadUtils.h"
#include "nsTArray.h"
@ -275,9 +274,9 @@ private:
bool aCreatePluginList,
bool *aPluginsChanged);
nsresult EnsurePluginLoaded(nsPluginTag* plugin);
nsresult EnsurePluginLoaded(nsPluginTag* aPluginTag);
bool IsRunningPlugin(nsPluginTag * plugin);
bool IsRunningPlugin(nsPluginTag * aPluginTag);
// Stores all plugins info into the registry
nsresult WritePluginInfo();
@ -322,7 +321,6 @@ private:
nsTArray< nsRefPtr<nsNPAPIPluginInstance> > mInstances;
nsCOMPtr<nsIFile> mPluginRegFile;
nsCOMPtr<nsIPrefBranch> mPrefService;
#ifdef XP_WIN
nsRefPtr<nsPluginDirServiceProvider> mPrivateDirServiceProvider;
#endif

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

@ -40,8 +40,6 @@
#include "npapi.h"
#include "nsPluginHost.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include <prinrval.h>
#if defined(XP_WIN)
@ -52,14 +50,15 @@ void NS_NotifyPluginCall(PRIntervalTime);
#ifdef CALL_SAFETY_ON
#include "mozilla/Preferences.h"
extern bool gSkipPluginSafeCalls;
#define NS_INIT_PLUGIN_SAFE_CALLS \
PR_BEGIN_MACRO \
nsresult res; \
nsCOMPtr<nsIPrefBranch> pref(do_GetService(NS_PREFSERVICE_CONTRACTID, &res)); \
if(NS_SUCCEEDED(res) && pref) \
res = pref->GetBoolPref("plugin.dont_try_safe_calls", &gSkipPluginSafeCalls);\
#define NS_INIT_PLUGIN_SAFE_CALLS \
PR_BEGIN_MACRO \
gSkipPluginSafeCalls = \
::mozilla::Preferences::GetBool("plugin.dont_try_safe_calls", \
gSkipPluginSafeCalls); \
PR_END_MACRO
#define NS_TRY_SAFE_CALL_RETURN(ret, fun, pluginInst) \

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

@ -45,8 +45,6 @@
#include "nsIPluginInstanceOwner.h"
#include "nsIDocument.h"
#include "nsServiceManagerUtils.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "nsPluginsDir.h"
#include "nsPluginHost.h"
#include "nsIUnicodeDecoder.h"
@ -56,7 +54,9 @@
#include "nsICategoryManager.h"
#include "nsNPAPIPlugin.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/Preferences.h"
using namespace mozilla;
using mozilla::TimeStamp;
inline char* new_str(const char* str)
@ -388,10 +388,6 @@ nsPluginTag::RegisterWithCategoryManager(bool aOverrideInternalTypes,
const char *contractId = "@mozilla.org/content/plugin/document-loader-factory;1";
nsCOMPtr<nsIPrefBranch> psvc(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (!psvc)
return; // NS_ERROR_OUT_OF_MEMORY
// A preference controls whether or not the full page plugin is disabled for
// a particular type. The string must be in the form:
// type1,type2,type3,type4
@ -399,11 +395,11 @@ nsPluginTag::RegisterWithCategoryManager(bool aOverrideInternalTypes,
// (and other plugin host settings) so applications can reliably disable
// plugins - without relying on implementation details such as prefs/category
// manager entries.
nsXPIDLCString overrideTypes;
nsCAutoString overrideTypesFormatted;
if (aType != ePluginUnregister) {
psvc->GetCharPref("plugin.disable_full_page_plugin_for_types", getter_Copies(overrideTypes));
overrideTypesFormatted.Assign(',');
nsAdoptingCString overrideTypes =
Preferences::GetCString("plugin.disable_full_page_plugin_for_types");
overrideTypesFormatted += overrideTypes;
overrideTypesFormatted.Append(',');
}
@ -514,8 +510,8 @@ void nsPluginTag::TryUnloadPlugin(bool inShutdown)
return;
}
if (mEntryPoint) {
mEntryPoint->Shutdown();
mEntryPoint = nsnull;
if (mPlugin) {
mPlugin->Shutdown();
mPlugin = nsnull;
}
}

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

@ -108,7 +108,7 @@ public:
nsTArray<nsCString> mMimeDescriptions; // UTF-8
nsTArray<nsCString> mExtensions; // UTF-8
PRLibrary *mLibrary;
nsRefPtr<nsNPAPIPlugin> mEntryPoint;
nsRefPtr<nsNPAPIPlugin> mPlugin;
bool mIsJavaPlugin;
bool mIsNPRuntimeEnabledJavaPlugin;
bool mIsFlashPlugin;

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

@ -41,8 +41,6 @@
#elif XP_MACOSX
#include "PluginInterposeOSX.h"
#include "PluginUtilsOSX.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#endif
#ifdef MOZ_WIDGET_QT
#include <QtCore/QCoreApplication>
@ -1163,15 +1161,8 @@ PluginModuleParent::RecvGetNativeCursorsSupported(bool* supported)
{
PLUGIN_LOG_DEBUG(("%s", FULLFUNCTION));
#if defined(XP_MACOSX)
bool nativeCursorsSupported = false;
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
if (prefs) {
if (NS_FAILED(prefs->GetBoolPref("dom.ipc.plugins.nativeCursorSupport",
&nativeCursorsSupported))) {
nativeCursorsSupported = false;
}
}
*supported = nativeCursorsSupported;
*supported =
Preferences::GetBool("dom.ipc.plugins.nativeCursorSupport", false);
return true;
#else
NS_NOTREACHED(

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

@ -35,6 +35,7 @@
*
* ***** END LICENSE BLOCK ***** */
#include "mozilla/Hal.h"
#include "PowerManager.h"
#include "WakeLock.h"
#include "nsContentUtils.h"
@ -87,33 +88,32 @@ PowerManager::Shutdown()
return NS_OK;
}
nsresult
bool
PowerManager::CheckPermission()
{
if (nsContentUtils::IsCallerChrome()) {
return NS_OK;
return true;
}
nsCOMPtr<nsPIDOMWindow> win = do_QueryReferent(mWindow);
NS_ENSURE_STATE(win);
NS_ENSURE_TRUE(win, false);
nsCOMPtr<nsIDocument> doc = do_QueryInterface(win->GetExtantDocument());
NS_ENSURE_STATE(doc);
NS_ENSURE_TRUE(doc, false);
nsCOMPtr<nsIURI> uri;
doc->NodePrincipal()->GetURI(getter_AddRefs(uri));
if (!nsContentUtils::URIIsChromeOrInPref(uri, "dom.power.whitelist")) {
return NS_ERROR_DOM_SECURITY_ERR;
return false;
}
return NS_OK;
return true;
}
NS_IMETHODIMP
PowerManager::Reboot()
{
nsresult rv = CheckPermission();
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(CheckPermission(), NS_ERROR_DOM_SECURITY_ERR);
nsCOMPtr<nsIPowerManagerService> pmService =
do_GetService(POWERMANAGERSERVICE_CONTRACTID);
@ -127,8 +127,7 @@ PowerManager::Reboot()
NS_IMETHODIMP
PowerManager::PowerOff()
{
nsresult rv = CheckPermission();
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(CheckPermission(), NS_ERROR_DOM_SECURITY_ERR);
nsCOMPtr<nsIPowerManagerService> pmService =
do_GetService(POWERMANAGERSERVICE_CONTRACTID);
@ -142,8 +141,7 @@ PowerManager::PowerOff()
NS_IMETHODIMP
PowerManager::AddWakeLockListener(nsIDOMMozWakeLockListener *aListener)
{
nsresult rv = CheckPermission();
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(CheckPermission(), NS_ERROR_DOM_SECURITY_ERR);
// already added? bail out.
if (mListeners.Contains(aListener))
@ -156,8 +154,7 @@ PowerManager::AddWakeLockListener(nsIDOMMozWakeLockListener *aListener)
NS_IMETHODIMP
PowerManager::RemoveWakeLockListener(nsIDOMMozWakeLockListener *aListener)
{
nsresult rv = CheckPermission();
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(CheckPermission(), NS_ERROR_DOM_SECURITY_ERR);
mListeners.RemoveElement(aListener);
return NS_OK;
@ -166,8 +163,7 @@ PowerManager::RemoveWakeLockListener(nsIDOMMozWakeLockListener *aListener)
NS_IMETHODIMP
PowerManager::GetWakeLockState(const nsAString &aTopic, nsAString &aState)
{
nsresult rv = CheckPermission();
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(CheckPermission(), NS_ERROR_DOM_SECURITY_ERR);
nsCOMPtr<nsIPowerManagerService> pmService =
do_GetService(POWERMANAGERSERVICE_CONTRACTID);
@ -195,6 +191,51 @@ PowerManager::Callback(const nsAString &aTopic, const nsAString &aState)
return NS_OK;
}
NS_IMETHODIMP
PowerManager::GetScreenEnabled(bool *aEnabled)
{
if (!CheckPermission()) {
*aEnabled = true;
return NS_OK;
}
*aEnabled = hal::GetScreenEnabled();
return NS_OK;
}
NS_IMETHODIMP
PowerManager::SetScreenEnabled(bool aEnabled)
{
NS_ENSURE_TRUE(CheckPermission(), NS_ERROR_DOM_SECURITY_ERR);
// TODO bug 707589: When the screen's state changes, all visible windows
// should fire a visibility change event.
hal::SetScreenEnabled(aEnabled);
return NS_OK;
}
NS_IMETHODIMP
PowerManager::GetScreenBrightness(double *aBrightness)
{
if (!CheckPermission()) {
*aBrightness = 1;
return NS_OK;
}
*aBrightness = hal::GetScreenBrightness();
return NS_OK;
}
NS_IMETHODIMP
PowerManager::SetScreenBrightness(double aBrightness)
{
NS_ENSURE_TRUE(CheckPermission(), NS_ERROR_DOM_SECURITY_ERR);
NS_ENSURE_TRUE(0 <= aBrightness && aBrightness <= 1, NS_ERROR_INVALID_ARG);
hal::SetScreenBrightness(aBrightness);
return NS_OK;
}
} // power
} // dom
} // mozilla

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

@ -64,7 +64,7 @@ public:
nsresult Shutdown();
private:
nsresult CheckPermission();
bool CheckPermission();
nsWeakPtr mWindow;
nsTArray<nsCOMPtr<nsIDOMMozWakeLockListener> > mListeners;

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

@ -42,7 +42,7 @@ interface nsIDOMMozWakeLockListener;
/**
* This interface implements navigator.mozPower
*/
[scriptable, uuid(abf4b2b1-139d-4eff-998d-8f24616910ae)]
[scriptable, uuid(4586bed1-cf78-4436-b503-88277d645b68)]
interface nsIDOMMozPowerManager : nsISupports
{
void powerOff();
@ -73,4 +73,27 @@ interface nsIDOMMozPowerManager : nsISupports
* @param aTopic The resource name related to the wake lock.
*/
DOMString getWakeLockState(in DOMString aTopic);
/**
* Is the device's screen currently enabled? This attribute controls the
* device's screen, so setting it to false will turn off the screen.
*/
attribute boolean screenEnabled;
/**
* How bright is the screen's backlight, on a scale from 0 (very dim) to 1
* (full brightness)? Setting this attribute modifies the screen's
* brightness.
*
* You can read and write this attribute even when the screen is disabled,
* but the backlight is off while the screen is disabled.
*
* If you write a value of X into this attribute, the attribute may not have
* the same value X when you later read it. Most screens don't support as
* many different brightness levels as there are doubles between 0 and 1, so
* we may reduce the value's precision before storing it.
*
* @throw NS_ERROR_INVALID_ARG if brightness is not in the range [0, 1].
*/
attribute double screenBrightness;
};

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

@ -66,8 +66,6 @@
#include "nsIURI.h"
#include "nsIPermissionManager.h"
#include "nsIObserverService.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "nsIJSContextStack.h"
#include "nsThreadUtils.h"
#include "mozilla/Services.h"

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

@ -61,7 +61,6 @@ using mozilla::dom::StorageChild;
#include "nsReadableUtils.h"
#include "nsIObserverService.h"
#include "nsNetUtil.h"
#include "nsIPrefBranch.h"
#include "nsICookiePermission.h"
#include "nsIPermission.h"
#include "nsIPermissionManager.h"

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

@ -48,7 +48,8 @@
#include "nsIServiceManager.h"
#include "nsIPrivateDOMEvent.h"
#include "nsIServiceManager.h"
#include "nsIPrefService.h"
#include "mozilla/Preferences.h"
using namespace mozilla;
using namespace hal;
@ -122,17 +123,9 @@ NS_IMETHODIMP nsDeviceSensorData::GetZ(double *aZ)
NS_IMPL_ISUPPORTS1(nsDeviceSensors, nsIDeviceSensors)
nsDeviceSensors::nsDeviceSensors()
: mEnabled(true)
{
mLastDOMMotionEventTime = TimeStamp::Now();
nsCOMPtr<nsIPrefBranch> prefSrv = do_GetService(NS_PREFSERVICE_CONTRACTID);
if (prefSrv) {
bool bvalue;
nsresult rv = prefSrv->GetBoolPref("device.motion.enabled", &bvalue);
if (NS_SUCCEEDED(rv) && bvalue == false)
mEnabled = false;
}
mEnabled = Preferences::GetBool("device.motion.enabled", true);
for (int i = 0; i < NUM_SENSOR_TYPE; i++) {
nsTArray<nsIDOMWindow*> *windows = new nsTArray<nsIDOMWindow*>();

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

@ -41,10 +41,11 @@
#include "MaemoLocationProvider.h"
#include "nsIClassInfo.h"
#include "nsDOMClassInfoID.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "nsIServiceManager.h"
#include "nsServiceManagerUtils.h"
#include "mozilla/Preferences.h"
using namespace mozilla;
NS_IMPL_ISUPPORTS2(MaemoLocationProvider, nsIGeolocationProvider, nsITimerCallback)
@ -192,31 +193,31 @@ NS_IMETHODIMP MaemoLocationProvider::Startup()
{
nsresult rv(NS_OK);
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
if (!prefs)
return NS_ERROR_FAILURE;
rv = StartControl();
NS_ENSURE_SUCCESS(rv, rv);
rv = StartDevice();
NS_ENSURE_SUCCESS(rv, rv);
prefs->GetBoolPref("geo.herror.ignore.big", &mIgnoreBigHErr);
mIgnoreBigHErr =
Preferences::GetBool("geo.herror.ignore.big", mIgnoreBigHErr);
if (mIgnoreBigHErr)
prefs->GetIntPref("geo.herror.max.value", &mMaxHErr);
if (mIgnoreBigHErr) {
mMaxHErr = Preferences::GetInt("geo.herror.max.value", mMaxHErr);
}
prefs->GetBoolPref("geo.verror.ignore.big", &mIgnoreBigVErr);
mIgnoreBigVErr =
Preferences::GetBool("geo.verror.ignore.big", mIgnoreBigVErr);
if (mIgnoreBigVErr)
prefs->GetIntPref("geo.verror.max.value", &mMaxVErr);
if (mIgnoreBigVErr) {
mMaxVErr = Preferences::GetInt("geo.verror.max.value", mMaxVErr);
}
if (mUpdateTimer)
return NS_OK;
PRInt32 update = 0; //0 second no timer created
prefs->GetIntPref("geo.default.update", &update);
// 0 second no timer created
PRInt32 update = Preferences::GetInt("geo.default.update", 0);
if (!update)
return NS_OK;

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

@ -16,7 +16,7 @@
<script type="text/javascript">
const workerCount = 3;
const errorMessage = "expectedError";
const errorMessage = "Error: expectedError";
const errorFilename = "http://mochi.test:8888/tests/dom/workers/test/" +
"errorPropagation_worker.js";
const errorLineno = 48;

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

@ -20,7 +20,7 @@
}
worker.onerror = function(event) {
is(event.message, "foo!", "Got wrong error message!");
is(event.message, "Error: foo!", "Got wrong error message!");
event.preventDefault();
SimpleTest.finish();
}

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

@ -14,8 +14,8 @@
const filename = "http://mochi.test:8888/tests/dom/workers/test/" +
"recursiveOnerror_worker.js";
const errors = [
{ message: "2", lineno: 6 },
{ message: "1", lineno: 10 }
{ message: "Error: 2", lineno: 6 },
{ message: "Error: 1", lineno: 10 }
]
var errorCount = 0;

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

@ -63,6 +63,7 @@
//defines
#define STATE_ENABLED "state_enabled"
#define STATE_ALL "state_all"
#define STATE_ATTRIBUTE "state_attribute"
#define STATE_DATA "state_data"
@ -378,7 +379,7 @@ nsSetDocumentStateCommand::GetCommandStateParams(const char *aCommandName,
bool isCSS;
htmleditor->GetIsCSSEnabled(&isCSS);
return aParams->SetBooleanValue(STATE_ATTRIBUTE, isCSS);
return aParams->SetBooleanValue(STATE_ALL, isCSS);
}
if (!nsCRT::strcmp(aCommandName, "cmd_insertBrOnReturn"))

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

@ -50,6 +50,7 @@ _TEST_FILES = \
test_bug389350.html \
test_bug519928.html \
bug678842_subframe.html \
test_bug738440.html \
$(NULL)
_CHROME_TEST_FILES = \

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

@ -0,0 +1,37 @@
<!doctype html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=738440
-->
<title>Test for Bug 738440</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css" />
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=738440">Mozilla Bug 738440</a>
<div contenteditable></div>
<script>
/** Test for Bug 738440 **/
document.execCommand("stylewithcss", false, "true");
is(document.queryCommandState("stylewithcss"), true,
"setting stylewithcss to true should cause its state to be true");
is(document.queryCommandState("usecss"), false,
"usecss state should always be false");
document.execCommand("stylewithcss", false, "false");
is(document.queryCommandState("stylewithcss"), false,
"setting stylewithcss to false should cause its state to be false");
is(document.queryCommandState("usecss"), false,
"usecss state should always be false");
document.execCommand("usecss", false, "true");
is(document.queryCommandState("stylewithcss"), false,
"setting usecss to true should cause stylewithcss state to be false");
is(document.queryCommandState("usecss"), false,
"usecss state should always be false");
document.execCommand("usecss", false, "false");
is(document.queryCommandState("stylewithcss"), true,
"setting usecss to false should cause stylewithcss state to be true");
is(document.queryCommandState("usecss"), false,
"usecss state should always be false");
</script>

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

@ -9,12 +9,22 @@ function boom()
{
document.getElementById("i").focus();
try { document.execCommand("stylewithcss", false, "true") } catch(e) { }
try { document.execCommand("inserthtml", false, "<x>X</x>"); } catch(e) { }
try { document.execCommand("underline", false, null); } catch(e) { }
try { document.execCommand("justifyfull", false, null); } catch(e) { }
try { document.execCommand("underline", false, null); } catch(e) { }
try { document.execCommand("insertParagraph", false, null); } catch(e) { }
try { document.execCommand("delete", false, null); } catch(e) { }
try { document.execCommand("stylewithcss", false, "false") } catch(e) { }
try { document.execCommand("inserthtml", false, "<x>X</x>"); } catch(e) { }
try { document.execCommand("underline", false, null); } catch(e) { }
try { document.execCommand("justifyfull", false, null); } catch(e) { }
try { document.execCommand("underline", false, null); } catch(e) { }
try { document.execCommand("insertParagraph", false, null); } catch(e) { }
try { document.execCommand("delete", false, null); } catch(e) { }
document.documentElement.removeAttribute("class");
}

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

@ -6,7 +6,7 @@ load 407256-1.html
load 430624-1.html
load 459613.html
load 475132-1.xhtml
asserts-if(!Android,1) load 633709.xhtml # Bug 695364
asserts-if(!Android,2) load 633709.xhtml # Bug 695364 and bug 671153
asserts-if(!Android,6) load 636074-1.html # Bug 439258, charged to the wrong test due to bug 635550
load 713427-1.html
load 713427-2.xhtml

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

@ -299,7 +299,7 @@ const nsHTMLCSSUtils::CSSEquivTable hrAlignEquivTable[] = {
nsHTMLCSSUtils::nsHTMLCSSUtils(nsHTMLEditor* aEditor)
: mHTMLEditor(aEditor)
, mIsCSSPrefChecked(false)
, mIsCSSPrefChecked(true)
{
// let's retrieve the value of the "CSS editing" pref
mIsCSSPrefChecked = Preferences::GetBool("editor.use_css", mIsCSSPrefChecked);

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

@ -1624,6 +1624,9 @@ NS_IMETHODIMP nsHTMLEditor::PasteTransferable(nsITransferable *aTransferable)
//
NS_IMETHODIMP nsHTMLEditor::PasteNoFormatting(PRInt32 aSelectionType)
{
if (!FireClipboardEvent(NS_PASTE))
return NS_OK;
ForceCompositionEnd();
// Get Clipboard Service

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

@ -102,6 +102,7 @@ _TEST_FILES = \
test_select_all_without_body.html \
file_select_all_without_body.html \
test_root_element_replacement.html \
test_bug738366.html \
$(NULL)
ifneq (mobile,$(MOZ_BUILD_APP))

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

@ -25,7 +25,7 @@ editor.innerHTML = '<p></p><ul><li>Item 1</li><li>Item 2</li></ul><p></p>';
editor.focus();
addLoadEvent(function() {
document.execCommand("stylewithcss", false, "true");
var sel = window.getSelection();
sel.removeAllRanges();
var lis = document.getElementsByTagName("li");

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

@ -21,6 +21,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=410986
/** Test for Bug 410986 **/
var gPasteEvents = 0;
document.getElementById("editor").addEventListener("paste", function() {
++gPasteEvents;
}, false);
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
getSelection().selectAllChildren(document.getElementById("contents"));
@ -37,6 +42,7 @@ SimpleTest.waitForFocus(function() {
synthesizeKey("V", {accelKey: true, shiftKey: true});
}
is(ed.innerHTML, "green text", "Content should be pasted in plaintext format");
is(gPasteEvents, 1, "One paste event must be fired");
ed.innerHTML = "";
ed.blur();
@ -51,6 +57,7 @@ SimpleTest.waitForFocus(function() {
synthesizeKey("V", {accelKey: true});
isnot(ed.innerHTML.indexOf("<span style=\"color: green;\">green text</span>"), -1,
"Content should be pasted in HTML format");
is(gPasteEvents, 2, "Two paste events must be fired");
SimpleTest.finish();
},

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

@ -54,6 +54,8 @@ function justify(textNode, pos) {
}
function runTests() {
document.execCommand("stylewithcss", false, "true");
const test1 = document.getElementById("test1");
const test2 = document.getElementById("test2");
const test3 = document.getElementById("test3");

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

@ -0,0 +1,24 @@
<!DOCTYPE html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=738366
-->
<title>Test for Bug 738366</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=738366">Mozilla Bug 738366</a>
<div id="display" contenteditable>foobarbaz</div>
<script>
/** Test for Bug 738366 **/
getSelection().collapse(document.getElementById("display").firstChild, 3);
getSelection().extend(document.getElementById("display").firstChild, 6);
document.execCommand("bold");
is(document.getElementById("display").innerHTML, "foo<b>bar</b>baz",
"styleWithCSS must default to false");
document.execCommand("stylewithcss", false, "true");
document.execCommand("bold");
document.execCommand("bold");
is(document.getElementById("display").innerHTML,
'foo<span style="font-weight: bold;">bar</span>baz',
"styleWithCSS must be settable to true");
</script>

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

@ -31,6 +31,7 @@ const kIsLinux = navigator.platform.indexOf("Linux") == 0 || navigator.platform.
function runTests()
{
document.execCommand("stylewithcss", false, "true");
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var fm = Components.classes["@mozilla.org/focus-manager;1"].

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

@ -829,6 +829,11 @@ public:
#ifdef WIN32
static TemporaryRef<DrawTarget> CreateDrawTargetForD3D10Texture(ID3D10Texture2D *aTexture, SurfaceFormat aFormat);
static TemporaryRef<DrawTarget>
CreateDualDrawTargetForD3D10Textures(ID3D10Texture2D *aTextureA,
ID3D10Texture2D *aTextureB,
SurfaceFormat aFormat);
static void SetDirect3D10Device(ID3D10Device1 *aDevice);
static ID3D10Device1 *GetDirect3D10Device();

213
gfx/2d/DrawTargetDual.cpp Normal file
Просмотреть файл

@ -0,0 +1,213 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* ***** 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 Corporation code.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Bas Schouten <bschouten@mozilla.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 "DrawTargetDual.h"
#include "Tools.h"
namespace mozilla {
namespace gfx {
class DualSurface
{
public:
inline DualSurface(SourceSurface *aSurface)
{
if (aSurface->GetType() != SURFACE_DUAL_DT) {
mA = mB = aSurface;
return;
}
SourceSurfaceDual *ssDual =
static_cast<SourceSurfaceDual*>(aSurface);
mA = ssDual->mA;
mB = ssDual->mB;
}
SourceSurface *mA;
SourceSurface *mB;
};
/* This only needs to split patterns up for SurfacePatterns. Only in that
* case can we be dealing with a 'dual' source (SourceSurfaceDual) and do
* we need to pass separate patterns into our destination DrawTargets.
*/
class DualPattern
{
public:
inline DualPattern(const Pattern &aPattern)
: mPatternsInitialized(false)
{
if (aPattern.GetType() != PATTERN_SURFACE) {
mA = mB = &aPattern;
return;
}
const SurfacePattern *surfPat =
static_cast<const SurfacePattern*>(&aPattern);
if (surfPat->mSurface->GetType() != SURFACE_DUAL_DT) {
mA = mB = &aPattern;
return;
}
const SourceSurfaceDual *ssDual =
static_cast<const SourceSurfaceDual*>(surfPat->mSurface.get());
mA = new (mSurfPatA.addr()) SurfacePattern(ssDual->mA, surfPat->mExtendMode,
surfPat->mMatrix, surfPat->mFilter);
mB = new (mSurfPatB.addr()) SurfacePattern(ssDual->mB, surfPat->mExtendMode,
surfPat->mMatrix, surfPat->mFilter);
mPatternsInitialized = true;
}
inline ~DualPattern()
{
if (mPatternsInitialized) {
mA->~Pattern();
mB->~Pattern();
}
}
ClassStorage<SurfacePattern> mSurfPatA;
ClassStorage<SurfacePattern> mSurfPatB;
const Pattern *mA;
const Pattern *mB;
bool mPatternsInitialized;
};
void
DrawTargetDual::DrawSurface(SourceSurface *aSurface, const Rect &aDest, const Rect &aSource,
const DrawSurfaceOptions &aSurfOptions, const DrawOptions &aOptions)
{
DualSurface surface(aSurface);
mA->DrawSurface(surface.mA, aDest, aSource, aSurfOptions, aOptions);
mB->DrawSurface(surface.mB, aDest, aSource, aSurfOptions, aOptions);
}
void
DrawTargetDual::DrawSurfaceWithShadow(SourceSurface *aSurface, const Point &aDest,
const Color &aColor, const Point &aOffset,
Float aSigma, CompositionOp aOp)
{
DualSurface surface(aSurface);
mA->DrawSurfaceWithShadow(surface.mA, aDest, aColor, aOffset, aSigma, aOp);
mB->DrawSurfaceWithShadow(surface.mB, aDest, aColor, aOffset, aSigma, aOp);
}
void
DrawTargetDual::CopySurface(SourceSurface *aSurface, const IntRect &aSourceRect,
const IntPoint &aDestination)
{
DualSurface surface(aSurface);
mA->CopySurface(surface.mA, aSourceRect, aDestination);
mB->CopySurface(surface.mB, aSourceRect, aDestination);
}
void
DrawTargetDual::FillRect(const Rect &aRect, const Pattern &aPattern, const DrawOptions &aOptions)
{
DualPattern pattern(aPattern);
mA->FillRect(aRect, *pattern.mA, aOptions);
mB->FillRect(aRect, *pattern.mB, aOptions);
}
void
DrawTargetDual::StrokeRect(const Rect &aRect, const Pattern &aPattern,
const StrokeOptions &aStrokeOptions, const DrawOptions &aOptions)
{
DualPattern pattern(aPattern);
mA->StrokeRect(aRect, *pattern.mA, aStrokeOptions, aOptions);
mB->StrokeRect(aRect, *pattern.mB, aStrokeOptions, aOptions);
}
void
DrawTargetDual::StrokeLine(const Point &aStart, const Point &aEnd, const Pattern &aPattern,
const StrokeOptions &aStrokeOptions, const DrawOptions &aOptions)
{
DualPattern pattern(aPattern);
mA->StrokeLine(aStart, aEnd, *pattern.mA, aStrokeOptions, aOptions);
mB->StrokeLine(aStart, aEnd, *pattern.mB, aStrokeOptions, aOptions);
}
void
DrawTargetDual::Stroke(const Path *aPath, const Pattern &aPattern,
const StrokeOptions &aStrokeOptions, const DrawOptions &aOptions)
{
DualPattern pattern(aPattern);
mA->Stroke(aPath, *pattern.mA, aStrokeOptions, aOptions);
mB->Stroke(aPath, *pattern.mB, aStrokeOptions, aOptions);
}
void
DrawTargetDual::Fill(const Path *aPath, const Pattern &aPattern, const DrawOptions &aOptions)
{
DualPattern pattern(aPattern);
mA->Fill(aPath, *pattern.mA, aOptions);
mB->Fill(aPath, *pattern.mB, aOptions);
}
void
DrawTargetDual::FillGlyphs(ScaledFont *aScaledFont, const GlyphBuffer &aBuffer,
const Pattern &aPattern, const DrawOptions &aOptions,
const GlyphRenderingOptions *aRenderingOptions)
{
DualPattern pattern(aPattern);
mA->FillGlyphs(aScaledFont, aBuffer, *pattern.mA, aOptions, aRenderingOptions);
mB->FillGlyphs(aScaledFont, aBuffer, *pattern.mB, aOptions, aRenderingOptions);
}
void
DrawTargetDual::Mask(const Pattern &aSource, const Pattern &aMask, const DrawOptions &aOptions)
{
DualPattern source(aSource);
DualPattern mask(aMask);
mA->Mask(*source.mA, *mask.mA, aOptions);
mB->Mask(*source.mB, *mask.mB, aOptions);
}
TemporaryRef<DrawTarget>
DrawTargetDual::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const
{
RefPtr<DrawTarget> dtA = mA->CreateSimilarDrawTarget(aSize, aFormat);
RefPtr<DrawTarget> dtB = mB->CreateSimilarDrawTarget(aSize, aFormat);
return new DrawTargetDual(dtA, dtB);
}
}
}

170
gfx/2d/DrawTargetDual.h Normal file
Просмотреть файл

@ -0,0 +1,170 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* ***** 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 Corporation code.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Bas Schouten <bschouten@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef MOZILLA_GFX_DRAWTARGETDUAL_H_
#define MOZILLA_GFX_DRAWTARGETDUAL_H_
#include <vector>
#include <sstream>
#include "SourceSurfaceDual.h"
#include "2D.h"
namespace mozilla {
namespace gfx {
#define FORWARD_FUNCTION(funcName) \
virtual void funcName() { mA->funcName(); mB->funcName(); }
#define FORWARD_FUNCTION1(funcName, var1Type, var1Name) \
virtual void funcName(var1Type var1Name) { mA->funcName(var1Name); mB->funcName(var1Name); }
/* This is a special type of DrawTarget. It duplicates all drawing calls
* accross two drawtargets. An exception to this is when a snapshot of another
* dual DrawTarget is used as the source for any surface data. In this case
* the snapshot of the first source DrawTarget is used as a source for the call
* to the first destination DrawTarget (mA) and the snapshot of the second
* source DrawTarget is used at the source for the second destination
* DrawTarget (mB). This class facilitates black-background/white-background
* drawing for per-component alpha extraction for backends which do not support
* native component alpha.
*/
class DrawTargetDual : public DrawTarget
{
public:
DrawTargetDual(DrawTarget *aA, DrawTarget *aB)
: mA(aA)
, mB(aB)
{
mFormat = aA->GetFormat();
}
virtual BackendType GetType() const { return mA->GetType(); }
virtual TemporaryRef<SourceSurface> Snapshot() { return new SourceSurfaceDual(mA, mB); }
virtual IntSize GetSize() { return mA->GetSize(); }
FORWARD_FUNCTION(Flush)
FORWARD_FUNCTION1(PushClip, const Path *, aPath)
FORWARD_FUNCTION1(PushClipRect, const Rect &, aRect)
FORWARD_FUNCTION(PopClip)
FORWARD_FUNCTION1(ClearRect, const Rect &, aRect)
virtual void SetTransform(const Matrix &aTransform) {
mTransform = aTransform;
mA->SetTransform(aTransform);
mB->SetTransform(aTransform);
}
virtual void DrawSurface(SourceSurface *aSurface, const Rect &aDest, const Rect & aSource,
const DrawSurfaceOptions &aSurfOptions, const DrawOptions &aOptions);
virtual void DrawSurfaceWithShadow(SourceSurface *aSurface, const Point &aDest,
const Color &aColor, const Point &aOffset,
Float aSigma, CompositionOp aOp);
virtual void CopySurface(SourceSurface *aSurface, const IntRect &aSourceRect,
const IntPoint &aDestination);
virtual void FillRect(const Rect &aRect, const Pattern &aPattern, const DrawOptions &aOptions);
virtual void StrokeRect(const Rect &aRect, const Pattern &aPattern,
const StrokeOptions &aStrokeOptions, const DrawOptions &aOptions);
virtual void StrokeLine(const Point &aStart, const Point &aEnd, const Pattern &aPattern,
const StrokeOptions &aStrokeOptions, const DrawOptions &aOptions);
virtual void Stroke(const Path *aPath, const Pattern &aPattern,
const StrokeOptions &aStrokeOptions, const DrawOptions &aOptions);
virtual void Fill(const Path *aPath, const Pattern &aPattern, const DrawOptions &aOptions);
virtual void FillGlyphs(ScaledFont *aScaledFont, const GlyphBuffer &aBuffer,
const Pattern &aPattern, const DrawOptions &aOptions,
const GlyphRenderingOptions *aRenderingOptions);
virtual void Mask(const Pattern &aSource, const Pattern &aMask, const DrawOptions &aOptions);
virtual TemporaryRef<SourceSurface>
CreateSourceSurfaceFromData(unsigned char *aData,
const IntSize &aSize,
int32_t aStride,
SurfaceFormat aFormat) const
{
return mA->CreateSourceSurfaceFromData(aData, aSize, aStride, aFormat);
}
virtual TemporaryRef<SourceSurface> OptimizeSourceSurface(SourceSurface *aSurface) const
{
return mA->OptimizeSourceSurface(aSurface);
}
virtual TemporaryRef<SourceSurface>
CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const
{
return mA->CreateSourceSurfaceFromNativeSurface(aSurface);
}
virtual TemporaryRef<DrawTarget>
CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const;
virtual TemporaryRef<PathBuilder> CreatePathBuilder(FillRule aFillRule = FILL_WINDING) const
{
return mA->CreatePathBuilder(aFillRule);
}
virtual TemporaryRef<GradientStops>
CreateGradientStops(GradientStop *aStops,
uint32_t aNumStops,
ExtendMode aExtendMode = EXTEND_CLAMP) const
{
return mA->CreateGradientStops(aStops, aNumStops, aExtendMode);
}
virtual void *GetNativeSurface(NativeSurfaceType aType)
{
return NULL;
}
private:
RefPtr<DrawTarget> mA;
RefPtr<DrawTarget> mB;
};
}
}
#endif /* MOZILLA_GFX_DRAWTARGETDUAL_H_ */

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

@ -67,6 +67,7 @@
#include <d3d10_1.h>
#endif
#include "DrawTargetDual.h"
#include "Logging.h"
@ -232,6 +233,32 @@ Factory::CreateDrawTargetForD3D10Texture(ID3D10Texture2D *aTexture, SurfaceForma
return NULL;
}
TemporaryRef<DrawTarget>
Factory::CreateDualDrawTargetForD3D10Textures(ID3D10Texture2D *aTextureA,
ID3D10Texture2D *aTextureB,
SurfaceFormat aFormat)
{
RefPtr<DrawTargetD2D> newTargetA;
RefPtr<DrawTargetD2D> newTargetB;
newTargetA = new DrawTargetD2D();
if (!newTargetA->Init(aTextureA, aFormat)) {
gfxWarning() << "Failed to create draw target for D3D10 texture.";
return NULL;
}
newTargetB = new DrawTargetD2D();
if (!newTargetB->Init(aTextureB, aFormat)) {
gfxWarning() << "Failed to create draw target for D3D10 texture.";
return NULL;
}
RefPtr<DrawTarget> newTarget =
new DrawTargetDual(newTargetA, newTargetB);
return newTarget;
}
void
Factory::SetDirect3D10Device(ID3D10Device1 *aDevice)
{

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

@ -73,6 +73,7 @@ CPPSRCS = \
PathCairo.cpp \
Blur.cpp \
ScaledFontBase.cpp \
DrawTargetDual.cpp \
$(NULL)
ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))

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

@ -0,0 +1,74 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* ***** 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 Corporation code.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Bas Schouten <bschouten@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef MOZILLA_GFX_SOURCESURFACEDUAL_H_
#define MOZILLA_GFX_SOURCESURFACEDUAL_H_
#include "2D.h"
namespace mozilla {
namespace gfx {
class DualSurface;
class DualPattern;
class SourceSurfaceDual : public SourceSurface
{
public:
SourceSurfaceDual(DrawTarget *aDTA, DrawTarget *aDTB)
: mA(aDTA->Snapshot())
, mB(aDTB->Snapshot())
{ }
virtual SurfaceType GetType() const { return SURFACE_DUAL_DT; }
virtual IntSize GetSize() const { return mA->GetSize(); }
virtual SurfaceFormat GetFormat() const { return mA->GetFormat(); }
/* Readback from this surface type is not supported! */
virtual TemporaryRef<DataSourceSurface> GetDataSurface() { return NULL; }
private:
friend class DualSurface;
friend class DualPattern;
RefPtr<SourceSurface> mA;
RefPtr<SourceSurface> mB;
};
}
}
#endif /* MOZILLA_GFX_SOURCESURFACEDUAL_H_ */

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

@ -57,6 +57,15 @@ IsOperatorBoundByMask(CompositionOp aOp) {
}
}
template <class T>
struct ClassStorage
{
char bytes[sizeof(T)];
const T *addr() const { return (const T *)bytes; }
T *addr() { return (T *)(void *)bytes; }
};
}
}

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

@ -56,7 +56,8 @@ enum SurfaceType
SURFACE_CAIRO_IMAGE, /* Data surface wrapping a cairo image surface */
SURFACE_COREGRAPHICS_IMAGE, /* Surface wrapping a CoreGraphics Image */
SURFACE_COREGRAPHICS_CGCONTEXT, /* Surface wrapping a CG context */
SURFACE_SKIA /* Surface wrapping a Skia bitmap */
SURFACE_SKIA, /* Surface wrapping a Skia bitmap */
SURFACE_DUAL_DT /* Snapshot of a dual drawtarget */
};
enum SurfaceFormat

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

@ -41,6 +41,15 @@ BlendState NonPremul
RenderTargetWriteMask[0] = 0x0F; // All
};
BlendState NoBlendDual
{
AlphaToCoverageEnable = FALSE;
BlendEnable[0] = FALSE;
BlendEnable[1] = FALSE;
RenderTargetWriteMask[0] = 0x0F; // All
RenderTargetWriteMask[1] = 0x0F; // All
};
BlendState ComponentAlphaBlend
{
AlphaToCoverageEnable = FALSE;
@ -94,6 +103,11 @@ struct PS_OUTPUT {
float4 vAlpha;
};
struct PS_DUAL_OUTPUT {
float4 vOutput1 : SV_Target0;
float4 vOutput2 : SV_Target1;
};
VS_OUTPUT LayerQuadVS(const VS_INPUT aVertex)
{
VS_OUTPUT outp;
@ -185,6 +199,14 @@ float4 SolidColorShader(const VS_OUTPUT aVertex) : SV_Target
return fLayerColor;
}
PS_DUAL_OUTPUT AlphaExtractionPrepareShader(const VS_OUTPUT aVertex)
{
PS_DUAL_OUTPUT result;
result.vOutput1 = float4(0, 0, 0, 1);
result.vOutput2 = float4(1, 1, 1, 1);
return result;
}
technique10 RenderRGBLayerPremul
{
pass P0
@ -293,3 +315,15 @@ technique10 RenderSolidColorLayer
SetPixelShader( CompileShader( ps_4_0_level_9_3, SolidColorShader() ) );
}
}
technique10 PrepareAlphaExtractionTextures
{
pass P0
{
SetRasterizerState( LayerRast );
SetBlendState( NoBlendDual, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
SetVertexShader( CompileShader( vs_4_0_level_9_3, LayerQuadVS() ) );
SetGeometryShader( NULL );
SetPixelShader( CompileShader( ps_4_0_level_9_3, AlphaExtractionPrepareShader() ) );
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -194,8 +194,7 @@ ThebesLayerD3D10::Validate(ReadbackProcessor *aReadback)
SurfaceMode mode = GetSurfaceMode();
if (mode == SURFACE_COMPONENT_ALPHA &&
(gfxPlatform::UseAzureContentDrawing() ||
!mParent || !mParent->SupportsComponentAlphaChildren())) {
(!mParent || !mParent->SupportsComponentAlphaChildren())) {
mode = SURFACE_SINGLE_CHANNEL_ALPHA;
}
// If we have a transform that requires resampling of our texture, then
@ -343,27 +342,111 @@ ThebesLayerD3D10::VerifyContentType(SurfaceMode aMode)
mValidRegion.SetEmpty();
}
if (aMode != SURFACE_COMPONENT_ALPHA && mTextureOnWhite) {
// If we've transitioned away from component alpha, we can delete those resources.
mD2DSurfaceOnWhite = nsnull;
mSRViewOnWhite = nsnull;
mTextureOnWhite = nsnull;
mValidRegion.SetEmpty();
} else if (mDrawTarget) {
SurfaceFormat format = aMode != SURFACE_SINGLE_CHANNEL_ALPHA ?
FORMAT_B8G8R8X8 : FORMAT_B8G8R8A8;
if (format != mDrawTarget->GetFormat()) {
mDrawTarget = Factory::CreateDrawTargetForD3D10Texture(mTexture, format);
if (!mDrawTarget) {
NS_WARNING("Failed to create drawtarget for ThebesLayerD3D10.");
return;
}
}
}
if (aMode != SURFACE_COMPONENT_ALPHA && mTextureOnWhite) {
// If we've transitioned away from component alpha, we can delete those resources.
mD2DSurfaceOnWhite = nsnull;
mSRViewOnWhite = nsnull;
mTextureOnWhite = nsnull;
mValidRegion.SetEmpty();
}
}
static void
FillSurface(gfxASurface* aSurface, const nsIntRegion& aRegion,
const nsIntPoint& aOffset, const gfxRGBA& aColor)
void
ThebesLayerD3D10::SetupDualViewports(const gfxIntSize &aSize)
{
if (aSurface) {
nsRefPtr<gfxContext> ctx = new gfxContext(aSurface);
ctx->Translate(-gfxPoint(aOffset.x, aOffset.y));
gfxUtils::PathFromRegion(ctx, aRegion);
ctx->SetColor(aColor);
ctx->Fill();
D3D10_VIEWPORT viewport;
viewport.MaxDepth = 1.0f;
viewport.MinDepth = 0;
viewport.Width = aSize.width;
viewport.Height = aSize.height;
viewport.TopLeftX = 0;
viewport.TopLeftY = 0;
D3D10_VIEWPORT vps[2] = { viewport, viewport };
device()->RSSetViewports(2, vps);
gfx3DMatrix projection;
/*
* Matrix to transform to viewport space ( <-1.0, 1.0> topleft,
* <1.0, -1.0> bottomright)
*/
projection._11 = 2.0f / aSize.width;
projection._22 = -2.0f / aSize.height;
projection._33 = 0.0f;
projection._41 = -1.0f;
projection._42 = 1.0f;
projection._44 = 1.0f;
effect()->GetVariableByName("mProjection")->
SetRawValue(&projection._11, 0, 64);
}
void
ThebesLayerD3D10::FillTexturesBlackWhite(const nsIntRegion& aRegion, const nsIntPoint& aOffset)
{
if (mTexture && mTextureOnWhite) {
// It would be more optimal to draw the actual geometry, but more code
// and probably not worth the win here as this will often be a single
// rect.
nsRefPtr<ID3D10RenderTargetView> oldRT;
device()->OMGetRenderTargets(1, getter_AddRefs(oldRT), NULL);
nsRefPtr<ID3D10RenderTargetView> viewBlack;
nsRefPtr<ID3D10RenderTargetView> viewWhite;
device()->CreateRenderTargetView(mTexture, NULL, getter_AddRefs(viewBlack));
device()->CreateRenderTargetView(mTextureOnWhite, NULL, getter_AddRefs(viewWhite));
D3D10_TEXTURE2D_DESC desc;
mTexture->GetDesc(&desc);
nsIntSize oldVP = mD3DManager->GetViewport();
SetupDualViewports(gfxIntSize(desc.Width, desc.Height));
ID3D10RenderTargetView *views[2] = { viewBlack, viewWhite };
device()->OMSetRenderTargets(2, views, NULL);
gfx3DMatrix transform;
transform.Translate(gfxPoint3D(-aOffset.x, -aOffset.y, 0));
void* raw = &const_cast<gfx3DMatrix&>(transform)._11;
effect()->GetVariableByName("mLayerTransform")->SetRawValue(raw, 0, 64);
ID3D10EffectTechnique *technique =
effect()->GetTechniqueByName("PrepareAlphaExtractionTextures");
nsIntRegionRectIterator iter(aRegion);
const nsIntRect *iterRect;
while ((iterRect = iter.Next())) {
effect()->GetVariableByName("vLayerQuad")->AsVector()->SetFloatVector(
ShaderConstantRectD3D10(
(float)iterRect->x,
(float)iterRect->y,
(float)iterRect->width,
(float)iterRect->height)
);
technique->GetPassByIndex(0)->Apply(0);
device()->Draw(4, 0);
}
views[0] = oldRT;
device()->OMSetRenderTargets(1, views, NULL);
mD3DManager->SetViewport(oldVP);
}
}
@ -379,14 +462,15 @@ ThebesLayerD3D10::DrawRegion(nsIntRegion &aRegion, SurfaceMode aMode)
nsRefPtr<gfxASurface> destinationSurface;
if (aMode == SURFACE_COMPONENT_ALPHA) {
FillSurface(mD2DSurface, aRegion, visibleRect.TopLeft(), gfxRGBA(0.0, 0.0, 0.0, 1.0));
FillSurface(mD2DSurfaceOnWhite, aRegion, visibleRect.TopLeft(), gfxRGBA(1.0, 1.0, 1.0, 1.0));
gfxASurface* surfaces[2] = { mD2DSurface.get(), mD2DSurfaceOnWhite.get() };
destinationSurface = new gfxTeeSurface(surfaces, ArrayLength(surfaces));
// Using this surface as a source will likely go horribly wrong, since
// only the onBlack surface will really be used, so alpha information will
// be incorrect.
destinationSurface->SetAllowUseAsSource(false);
FillTexturesBlackWhite(aRegion, visibleRect.TopLeft());
if (!gfxPlatform::UseAzureContentDrawing()) {
gfxASurface* surfaces[2] = { mD2DSurface.get(), mD2DSurfaceOnWhite.get() };
destinationSurface = new gfxTeeSurface(surfaces, ArrayLength(surfaces));
// Using this surface as a source will likely go horribly wrong, since
// only the onBlack surface will really be used, so alpha information will
// be incorrect.
destinationSurface->SetAllowUseAsSource(false);
}
} else {
destinationSurface = mD2DSurface;
}
@ -405,7 +489,7 @@ ThebesLayerD3D10::DrawRegion(nsIntRegion &aRegion, SurfaceMode aMode)
const nsIntRect *iterRect;
while ((iterRect = iter.Next())) {
context->Rectangle(gfxRect(iterRect->x, iterRect->y, iterRect->width, iterRect->height));
if (mDrawTarget) {
if (mDrawTarget && aMode == SURFACE_SINGLE_CHANNEL_ALPHA) {
mDrawTarget->ClearRect(Rect(iterRect->x, iterRect->y, iterRect->width, iterRect->height));
}
}
@ -462,14 +546,7 @@ ThebesLayerD3D10::CreateNewTextures(const gfxIntSize &aSize, SurfaceMode aMode)
return;
}
} else {
mDrawTarget = Factory::CreateDrawTargetForD3D10Texture(mTexture, aMode != SURFACE_SINGLE_CHANNEL_ALPHA ?
FORMAT_B8G8R8X8 : FORMAT_B8G8R8A8);
if (!mDrawTarget) {
NS_WARNING("Failed to create DrawTarget for ThebesLayerD3D10.");
mDrawTarget = nsnull;
return;
}
mDrawTarget = nsnull;
}
}
@ -487,11 +564,30 @@ ThebesLayerD3D10::CreateNewTextures(const gfxIntSize &aSize, SurfaceMode aMode)
NS_WARNING("Failed to create shader resource view for ThebesLayerD3D10.");
}
mD2DSurfaceOnWhite = new gfxD2DSurface(mTextureOnWhite, gfxASurface::CONTENT_COLOR);
if (!gfxPlatform::UseAzureContentDrawing()) {
mD2DSurfaceOnWhite = new gfxD2DSurface(mTextureOnWhite, gfxASurface::CONTENT_COLOR);
if (!mD2DSurfaceOnWhite || mD2DSurfaceOnWhite->CairoStatus()) {
NS_WARNING("Failed to create surface for ThebesLayerD3D10.");
mD2DSurfaceOnWhite = nsnull;
if (!mD2DSurfaceOnWhite || mD2DSurfaceOnWhite->CairoStatus()) {
NS_WARNING("Failed to create surface for ThebesLayerD3D10.");
mD2DSurfaceOnWhite = nsnull;
return;
}
} else {
mDrawTarget = nsnull;
}
}
if (gfxPlatform::UseAzureContentDrawing() && !mDrawTarget) {
if (aMode == SURFACE_COMPONENT_ALPHA) {
mDrawTarget = Factory::CreateDualDrawTargetForD3D10Textures(mTexture, mTextureOnWhite, FORMAT_B8G8R8X8);
} else {
mDrawTarget = Factory::CreateDrawTargetForD3D10Texture(mTexture, aMode != SURFACE_SINGLE_CHANNEL_ALPHA ?
FORMAT_B8G8R8X8 : FORMAT_B8G8R8A8);
}
if (!mDrawTarget) {
NS_WARNING("Failed to create DrawTarget for ThebesLayerD3D10.");
mDrawTarget = nsnull;
return;
}
}

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

@ -97,6 +97,11 @@ private:
/* Create a new texture */
void CreateNewTextures(const gfxIntSize &aSize, SurfaceMode aMode);
void SetupDualViewports(const gfxIntSize &aSize);
// Fill textures with opaque black and white in the specified region.
void FillTexturesBlackWhite(const nsIntRegion& aRegion, const nsIntPoint& aOffset);
/* Copy a texture region */
void CopyRegion(ID3D10Texture2D* aSrc, const nsIntPoint &aSrcOffset,
ID3D10Texture2D* aDest, const nsIntPoint &aDestOffset,

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

@ -2336,19 +2336,19 @@ public:
}
bool CharIsSpace(PRUint32 aPos) {
NS_ASSERTION(0 <= aPos && aPos < mCharacterCount, "aPos out of range");
NS_ASSERTION(aPos < mCharacterCount, "aPos out of range");
return mCharacterGlyphs[aPos].CharIsSpace();
}
bool CharIsTab(PRUint32 aPos) {
NS_ASSERTION(0 <= aPos && aPos < mCharacterCount, "aPos out of range");
NS_ASSERTION(aPos < mCharacterCount, "aPos out of range");
return mCharacterGlyphs[aPos].CharIsTab();
}
bool CharIsNewline(PRUint32 aPos) {
NS_ASSERTION(0 <= aPos && aPos < mCharacterCount, "aPos out of range");
NS_ASSERTION(aPos < mCharacterCount, "aPos out of range");
return mCharacterGlyphs[aPos].CharIsNewline();
}
bool CharIsLowSurrogate(PRUint32 aPos) {
NS_ASSERTION(0 <= aPos && aPos < mCharacterCount, "aPos out of range");
NS_ASSERTION(aPos < mCharacterCount, "aPos out of range");
return mCharacterGlyphs[aPos].CharIsLowSurrogate();
}

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

@ -0,0 +1,40 @@
diff --git a/gfx/ycbcr/yuv_convert.cpp b/gfx/ycbcr/yuv_convert.cpp
--- a/gfx/ycbcr/yuv_convert.cpp
+++ b/gfx/ycbcr/yuv_convert.cpp
@@ -337,16 +337,17 @@ NS_GFX_(void) ScaleYCbCrToRGB32(const ui
source_dx_uv >> kFractionBits);
}
}
else {
ScaleYUVToRGB32Row_C(y_ptr, u_ptr, v_ptr,
dest_pixel, width, source_dx);
}
#else
+ (void)source_dx_uv;
ScaleYUVToRGB32Row(y_ptr, u_ptr, v_ptr,
dest_pixel, width, source_dx);
#endif
}
}
// MMX used for FastConvertYUVToRGB32Row and FilterRows requires emms.
if (has_mmx)
EMMS();
diff --git a/gfx/ycbcr/yuv_row.h b/gfx/ycbcr/yuv_row.h
--- a/gfx/ycbcr/yuv_row.h
+++ b/gfx/ycbcr/yuv_row.h
@@ -129,14 +129,14 @@ extern SIMD_ALIGNED(int16 kCoefficientsR
#if defined(ARCH_CPU_X86) && !defined(ARCH_CPU_X86_64)
#if defined(_MSC_VER)
#define EMMS() __asm emms
#pragma warning(disable: 4799)
#else
#define EMMS() asm("emms")
#endif
#else
-#define EMMS()
+#define EMMS() ((void)0)
#endif
} // extern "C"
#endif // MEDIA_BASE_YUV_ROW_H_

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

@ -25,3 +25,5 @@ convert.patch contains the following changes:
win64.patch: SSE2 optimization for Microsoft Visual C++ x64 version
TypeFromSize.patch: Bug 656185 - Add a method to detect YUVType from plane sizes.
QuellGccWarnings.patch: Bug 711895 - Avoid some GCC compilation warnings.

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

@ -9,3 +9,4 @@ cp $1/media/base/yuv_row_posix.cc yuv_row_c.cpp
patch -p3 <convert.patch
patch -p3 <win64.patch
patch -p3 <TypeFromSize.patch
patch -p3 <QuellGccWarnings.patch

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

@ -342,6 +342,7 @@ NS_GFX_(void) ScaleYCbCrToRGB32(const uint8* y_buf,
dest_pixel, width, source_dx);
}
#else
(void)source_dx_uv;
ScaleYUVToRGB32Row(y_ptr, u_ptr, v_ptr,
dest_pixel, width, source_dx);
#endif

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

@ -134,7 +134,7 @@ extern SIMD_ALIGNED(int16 kCoefficientsRgbY[768][4]);
#define EMMS() asm("emms")
#endif
#else
#define EMMS()
#define EMMS() ((void)0)
#endif
} // extern "C"

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

@ -880,21 +880,23 @@ RasterImage::GetFrame(PRUint32 aWhichFrame,
nsresult rv = NS_OK;
// If we have decoded data, and it is not a perfect match for what we are
// looking for, we must discard to be able to generate the proper data.
PRUint32 desiredDecodeFlags = aFlags & DECODE_FLAGS_MASK;
if (desiredDecodeFlags != mFrameDecodeFlags) {
// if we can't discard, then we're screwed; we have no way
// to re-decode. Similarly if we aren't allowed to do a sync
// decode.
if (!(aFlags & FLAG_SYNC_DECODE))
return NS_ERROR_NOT_AVAILABLE;
if (!CanForciblyDiscard() || mDecoder || mAnim)
return NS_ERROR_NOT_AVAILABLE;
ForceDiscard();
mFrameDecodeFlags = desiredDecodeFlags;
if (mDecoded) {
// If we have decoded data, and it is not a perfect match for what we are
// looking for, we must discard to be able to generate the proper data.
PRUint32 desiredDecodeFlags = aFlags & DECODE_FLAGS_MASK;
if (desiredDecodeFlags != mFrameDecodeFlags) {
// if we can't discard, then we're screwed; we have no way
// to re-decode. Similarly if we aren't allowed to do a sync
// decode.
if (!(aFlags & FLAG_SYNC_DECODE))
return NS_ERROR_NOT_AVAILABLE;
if (!CanForciblyDiscard() || mDecoder || mAnim)
return NS_ERROR_NOT_AVAILABLE;
ForceDiscard();
mFrameDecodeFlags = desiredDecodeFlags;
}
}
// If the caller requested a synchronous decode, do it

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

@ -379,10 +379,6 @@ jsd_GetErrorReporter(JSDContext* jsdc,
JSD_ErrorReporter* reporter,
void** callerdata);
static JSBool
jsd_DebugErrorHook(JSContext *cx, const char *message,
JSErrorReport *report, void *closure);
/***************************************************************************/
/* Script functions */

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

@ -276,6 +276,10 @@ jsd_DebuggerPause(JSDContext* jsdc, JSBool forceAllHooksOff)
JS_SetDebugErrorHook(jsdc->jsrt, NULL, NULL);
}
static JSBool
jsd_DebugErrorHook(JSContext *cx, const char *message,
JSErrorReport *report, void *closure);
void
jsd_DebuggerUnpause(JSDContext* jsdc)
{

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

@ -82,3 +82,49 @@ if test "$GNU_CC" -a "$GCC_USE_GNU_LD" -a -n "$MOZ_DEBUG_FLAGS"; then
fi
])
dnl GCC and clang will fail if given an unknown warning option like -Wfoobar.
dnl But later versions won't fail if given an unknown negated warning option
dnl like -Wno-foobar. So when we are check for support of negated warning
dnl options, we actually test the positive form, but add the negated form to
dnl the flags variable.
AC_DEFUN([MOZ_C_SUPPORTS_WARNING],
[
AC_CACHE_CHECK(whether the C compiler supports $1$2, $3,
[
AC_LANG_SAVE
AC_LANG_C
_SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Werror -W$2"
AC_TRY_COMPILE([],
[return(0);],
$3="yes",
$3="no")
CFLAGS="$_SAVE_CFLAGS"
AC_LANG_RESTORE
])
if test "${$3}" = "yes"; then
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} $1$2"
fi
])
AC_DEFUN([MOZ_CXX_SUPPORTS_WARNING],
[
AC_CACHE_CHECK(whether the C++ compiler supports $1$2, $3,
[
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
_SAVE_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -Werror -W$2"
AC_TRY_COMPILE([],
[return(0);],
$3="yes",
$3="no")
CXXFLAGS="$_SAVE_CXXFLAGS"
AC_LANG_RESTORE
])
if test "${$3}" = "yes"; then
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} $1$2"
fi
])

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

@ -1627,14 +1627,27 @@ if test "$GNU_CC"; then
_MOZ_RTTI_FLAGS_ON=-frtti
_MOZ_RTTI_FLAGS_OFF=-fno-rtti
# Turn on GNU specific features
# -Wall - turn on all warnings
# -pedantic - make compiler warn about non-ANSI stuff, and
# be a little bit stricter
# Warnings slamm took out for now (these were giving more noise than help):
# -Wbad-function-cast - warns when casting a function to a new return type
# -Wshadow - removed because it generates more noise than help --pete
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall -W -Wno-unused -Wpointer-arith"
# Turn on GNU-specific warnings:
# -Wall - turn on a lot of warnings
# -pedantic - this is turned on below
# -Wpointer-arith - enabled with -pedantic, but good to have even if not
# -Wdeclaration-after-statement - MSVC doesn't like these
# -Werror=return-type - catches missing returns, zero false positives
# -Wtype-limits - catches overflow bugs, few false positives
# -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
#
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall -Wpointer-arith -Wdeclaration-after-statement"
MOZ_C_SUPPORTS_WARNING(-W, error=return-type, ac_c_has_werror_return_type)
MOZ_C_SUPPORTS_WARNING(-W, type-limits, ac_c_has_wtype_limits)
MOZ_C_SUPPORTS_WARNING(-W, empty-body, ac_c_has_wempty_body)
# Turn off the following warnings that -Wall/-pedantic turn on:
# -Wno-unused - lots of violations in third-party code
# -Wno-overlength-strings - we exceed the minimum maximum length frequently
#
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wno-unused"
MOZ_C_SUPPORTS_WARNING(-Wno-, overlength-strings, ac_c_has_wno_overlength_strings)
if test -z "$INTEL_CC" -a -z "$CLANG_CC"; then
# Don't use -Wcast-align with ICC or clang
case "$CPU_ARCH" in
@ -1650,12 +1663,9 @@ if test "$GNU_CC"; then
dnl Turn pedantic on but disable the warnings for long long
_PEDANTIC=1
if test -z "$INTEL_CC"; then
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -W"
fi
_DEFINES_CFLAGS='-include $(DEPTH)/js-confdefs.h -DMOZILLA_CLIENT'
_USE_CPP_INCLUDE_FLAG=1
elif test "$SOLARIS_SUNPRO_CC"; then
DSO_CFLAGS=''
if test "$CPU_ARCH" = "sparc"; then
@ -1681,8 +1691,31 @@ else
fi
if test "$GNU_CXX"; then
# Turn on GNU specific features
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall -Wpointer-arith -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor"
# Turn on GNU-specific warnings:
# -Wall - turn on a lot of warnings
# -pedantic - this is turned on below
# -Wpointer-arith - enabled with -pedantic, but good to have even if not
# -Woverloaded-virtual - ???
# -Werror=return-type - catches missing returns, zero false positives
# -Wtype-limits - catches overflow bugs, few false positives
# -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
#
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall -Wpointer-arith -Woverloaded-virtual"
MOZ_CXX_SUPPORTS_WARNING(-W, error=return-type, ac_cxx_has_werror_return_type)
MOZ_CXX_SUPPORTS_WARNING(-W, type-limits, ac_cxx_has_wtype_limits)
MOZ_CXX_SUPPORTS_WARNING(-W, empty-body, ac_cxx_has_wempty_body)
# Turn off the following warnings that -Wall/-pedantic turn on:
# -Wno-ctor-dtor-privacy - ???
# -Wno-overlength-strings - we exceed the minimum maximum length frequently
# -Wno-invalid-offsetof - we use offsetof on non-POD types frequently
# -Wno-variadic-macros - ???
#
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-ctor-dtor-privacy"
MOZ_CXX_SUPPORTS_WARNING(-Wno-, overlength-strings, ac_cxx_has_wno_overlength_strings)
MOZ_CXX_SUPPORTS_WARNING(-Wno-, invalid-offsetof, ac_cxx_has_wno_invalid_offsetof)
MOZ_CXX_SUPPORTS_WARNING(-Wno-, variadic-macros, ac_cxx_has_wno_variadic_macros)
if test -z "$INTEL_CXX" -a -z "$CLANG_CXX"; then
# Don't use -Wcast-align with ICC or clang
case "$CPU_ARCH" in
@ -1706,81 +1739,7 @@ if test "$GNU_CXX"; then
# deleted function syntax.
if test "$CLANG_CXX"; then
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-c++0x-extensions"
fi
AC_CACHE_CHECK(whether the compiler supports -Wno-extended-offsetof,
ac_has_wno_extended_offsetof,
[
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
_SAVE_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -Wno-extended-offsetof"
AC_TRY_COMPILE([$configure_static_assert_macros
#ifndef __has_warning
#define __has_warning(x) 0
#endif],
[CONFIGURE_STATIC_ASSERT(__has_warning("-Wextended-offsetof"))],
ac_has_wno_extended_offsetof="yes",
ac_has_wno_extended_offsetof="no")
CXXFLAGS="$_SAVE_CXXFLAGS"
AC_LANG_RESTORE
])
if test "$ac_has_wno_extended_offsetof" = "yes"; then
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-extended-offsetof"
fi
AC_CACHE_CHECK(whether the compiler supports -Wno-invalid-offsetof,
ac_has_wno_invalid_offsetof,
[
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
_SAVE_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -Wno-invalid-offsetof"
AC_TRY_COMPILE([],
[return(0);],
ac_has_wno_invalid_offsetof="yes",
ac_has_wno_invalid_offsetof="no")
CXXFLAGS="$_SAVE_CXXFLAGS"
AC_LANG_RESTORE
])
if test "$ac_has_wno_invalid_offsetof" = "yes"; then
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-invalid-offsetof"
fi
AC_CACHE_CHECK(whether the compiler supports -Wno-variadic-macros,
ac_has_wno_variadic_macros,
[
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
_SAVE_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -Wno-variadic-macros"
AC_TRY_COMPILE([],
[return(0);],
ac_has_wno_variadic_macros="yes",
ac_has_wno_variadic_macros="no")
CXXFLAGS="$_SAVE_CXXFLAGS"
AC_LANG_RESTORE
])
if test "$ac_has_wno_variadic_macros" = "yes"; then
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-variadic-macros"
fi
AC_CACHE_CHECK(whether the compiler supports -Werror=return-type,
ac_has_werror_return_type,
[
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
_SAVE_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -Werror=return-type"
AC_TRY_COMPILE([],
[return(0);],
ac_has_werror_return_type="yes",
ac_has_werror_return_type="no")
CXXFLAGS="$_SAVE_CXXFLAGS"
AC_LANG_RESTORE
])
if test "$ac_has_werror_return_type" = "yes"; then
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=return-type"
MOZ_CXX_SUPPORTS_WARNING(-Wno-, extended-offsetof, ac_cxx_has_wno_extended_offsetof)
fi
else

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

@ -56,6 +56,12 @@
#include <sys/types.h>
#endif
#if defined(XP_UNIX)
#include <errno.h>
#elif defined(XP_WIN)
#include <windows.h>
#endif
using namespace std;
namespace js {
@ -86,6 +92,17 @@ namespace CType {
static JSBool ToString(JSContext* cx, unsigned argc, jsval* vp);
static JSBool ToSource(JSContext* cx, unsigned argc, jsval* vp);
static JSBool HasInstance(JSContext* cx, JSObject* obj, const jsval* v, JSBool* bp);
/**
* Get the global "ctypes" object.
*
* |obj| must be a CType object.
*
* This function never returns NULL.
*/
static JSObject* GetGlobalCTypes(JSContext* cx, JSObject* obj);
}
namespace PointerType {
@ -168,6 +185,14 @@ namespace CData {
static JSBool Address(JSContext* cx, unsigned argc, jsval* vp);
static JSBool ReadString(JSContext* cx, unsigned argc, jsval* vp);
static JSBool ToSource(JSContext* cx, unsigned argc, jsval* vp);
static JSBool ErrnoGetter(JSContext* cx, JSObject *obj, jsid idval,
jsval* vp);
#if defined(XP_WIN)
static JSBool LastErrorGetter(JSContext* cx, JSObject *obj, jsid idval,
jsval* vp);
#endif // defined(XP_WIN)
}
// Int64Base provides functions common to Int64 and UInt64.
@ -442,6 +467,16 @@ static JSFunctionSpec sUInt64Functions[] = {
JS_FS_END
};
static JSPropertySpec sModuleProps[] = {
{ "errno", 0, JSPROP_SHARED | JSPROP_PERMANENT,
CData::ErrnoGetter, NULL },
#if defined(XP_WIN)
{ "winLastError", 0, JSPROP_SHARED | JSPROP_PERMANENT,
CData::LastErrorGetter, NULL },
#endif // defined(XP_WIN)
{ 0, 0, 0, NULL, NULL }
};
static JSFunctionSpec sModuleFunctions[] = {
JS_FN("open", Library::Open, 1, CTYPESFN_FLAGS),
JS_FN("cast", CData::Cast, 2, CTYPESFN_FLAGS),
@ -729,9 +764,9 @@ static void
AttachProtos(JSObject* proto, JSObject** protos)
{
// For a given 'proto' of [[Class]] "CTypeProto", attach each of the 'protos'
// to the appropriate CTypeProtoSlot. (SLOT_UINT64PROTO is the last slot
// to the appropriate CTypeProtoSlot. (SLOT_CTYPES is the last slot
// of [[Class]] "CTypeProto" that we fill in this automated manner.)
for (uint32_t i = 0; i <= SLOT_UINT64PROTO; ++i)
for (uint32_t i = 0; i <= SLOT_CTYPES; ++i)
JS_SetReservedSlot(proto, i, OBJECT_TO_JSVAL(protos[i]));
}
@ -847,6 +882,10 @@ InitTypeClasses(JSContext* cx, JSObject* parent)
if (!protos[SLOT_UINT64PROTO])
return false;
// Finally, store a pointer to the global ctypes object.
// Note that there is no other reliable manner of locating this object.
protos[SLOT_CTYPES] = parent;
// Attach the prototypes just created to each of ctypes.CType.prototype,
// and the special type constructors, so we can access them when constructing
// instances of those types.
@ -942,8 +981,9 @@ JS_InitCTypesClass(JSContext* cx, JSObject* global)
if (!InitTypeClasses(cx, ctypes))
return false;
// attach API functions
if (!JS_DefineFunctions(cx, ctypes, sModuleFunctions))
// attach API functions and properties
if (!JS_DefineFunctions(cx, ctypes, sModuleFunctions) ||
!JS_DefineProperties(cx, ctypes, sModuleProps))
return false;
// Seal the ctypes object, to prevent modification.
@ -3226,6 +3266,23 @@ CType::HasInstance(JSContext* cx, JSObject* obj, const jsval* v, JSBool* bp)
return JS_TRUE;
}
static JSObject*
CType::GetGlobalCTypes(JSContext* cx, JSObject* obj)
{
JS_ASSERT(CType::IsCType(obj));
JSObject *objTypeProto = JS_GetPrototype(obj);
if (!objTypeProto) {
}
JS_ASSERT(objTypeProto);
JS_ASSERT(CType::IsCTypeProto(objTypeProto));
jsval valCTypes = JS_GetReservedSlot(objTypeProto, SLOT_CTYPES);
JS_ASSERT(!JSVAL_IS_PRIMITIVE(valCTypes));
return JSVAL_TO_OBJECT(valCTypes);
}
/*******************************************************************************
** PointerType implementation
*******************************************************************************/
@ -5149,13 +5206,45 @@ FunctionType::Call(JSContext* cx,
uintptr_t fn = *reinterpret_cast<uintptr_t*>(CData::GetData(obj));
#if defined(XP_WIN)
int32_t lastErrorStatus; // The status as defined by |GetLastError|
int32_t savedLastError = GetLastError();
SetLastError(0);
#endif //defined(XP_WIN)
int errnoStatus; // The status as defined by |errno|
int savedErrno = errno;
errno = 0;
// suspend the request before we call into the function, since the call
// may block or otherwise take a long time to return.
{
JSAutoSuspendRequest suspend(cx);
ffi_call(&fninfo->mCIF, FFI_FN(fn), returnValue.mData,
reinterpret_cast<void**>(values.begin()));
// Save error value.
// We need to save it before leaving the scope of |suspend| as destructing
// |suspend| has the side-effect of clearing |GetLastError|
// (see bug 684017).
errnoStatus = errno;
#if defined(XP_WIN)
lastErrorStatus = GetLastError();
#endif // defined(XP_WIN)
}
#if defined(XP_WIN)
SetLastError(savedLastError);
#endif // defined(XP_WIN)
errno = savedErrno;
// Store the error value for later consultation with |ctypes.getStatus|
JSObject *objCTypes = CType::GetGlobalCTypes(cx, typeObj);
JS_SetReservedSlot(objCTypes, SLOT_ERRNO, INT_TO_JSVAL(errnoStatus));
#if defined(XP_WIN)
JS_SetReservedSlot(objCTypes, SLOT_LASTERROR, INT_TO_JSVAL(lastErrorStatus));
#endif // defined(XP_WIN)
// Small integer types get returned as a word-sized ffi_arg. Coerce it back
// into the correct size for ConvertToJS.
@ -5976,6 +6065,33 @@ CData::ToSource(JSContext* cx, unsigned argc, jsval* vp)
return JS_TRUE;
}
JSBool
CData::ErrnoGetter(JSContext* cx, JSObject* obj, jsid, jsval* vp)
{
if (!IsCTypesGlobal(obj)) {
JS_ReportError(cx, "this is not not global object ctypes");
return JS_FALSE;
}
*vp = JS_GetReservedSlot(obj, SLOT_ERRNO);
return JS_TRUE;
}
#if defined(XP_WIN)
JSBool
CData::LastErrorGetter(JSContext* cx, JSObject* obj, jsid, jsval* vp)
{
if (!IsCTypesGlobal(obj)) {
JS_ReportError(cx, "not global object ctypes");
return JS_FALSE;
}
*vp = JS_GetReservedSlot(obj, SLOT_LASTERROR);
return JS_TRUE;
}
#endif // defined(XP_WIN)
/*******************************************************************************
** Int64 and UInt64 implementation
*******************************************************************************/

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

@ -369,6 +369,8 @@ JSBool ExplicitConvert(JSContext* cx, jsval val, JSObject* targetType,
enum CTypesGlobalSlot {
SLOT_CALLBACKS = 0, // pointer to JSCTypesCallbacks struct
SLOT_ERRNO = 1, // jsval for latest |errno|
SLOT_LASTERROR = 2, // jsval for latest |GetLastError|, used only with Windows
CTYPESGLOBAL_SLOTS
};
@ -389,8 +391,9 @@ enum CTypeProtoSlot {
SLOT_FUNCTIONDATAPROTO = 8, // common ancestor of all CData objects of FunctionType
SLOT_INT64PROTO = 9, // ctypes.Int64.prototype object
SLOT_UINT64PROTO = 10, // ctypes.UInt64.prototype object
SLOT_OURDATAPROTO = 11, // the data prototype corresponding to this object
SLOT_CLOSURECX = 12, // JSContext for use with FunctionType closures
SLOT_CTYPES = 11, // ctypes object
SLOT_OURDATAPROTO = 12, // the data prototype corresponding to this object
SLOT_CLOSURECX = 13, // JSContext for use with FunctionType closures
CTYPEPROTO_SLOTS
};

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

@ -404,11 +404,24 @@ DoGetElement(JSContext *cx, JSObject *obj, uint32_t index, JSBool *hole, Value *
return true;
}
template<typename IndexType>
static void
AssertGreaterThanZero(IndexType index)
{
JS_ASSERT(index >= 0);
}
template<>
void
AssertGreaterThanZero(uint32_t index)
{
}
template<typename IndexType>
static JSBool
GetElement(JSContext *cx, JSObject *obj, IndexType index, JSBool *hole, Value *vp)
{
JS_ASSERT(index >= 0);
AssertGreaterThanZero(index);
if (obj->isDenseArray() && index < obj->getDenseArrayInitializedLength() &&
!(*vp = obj->getDenseArrayElement(uint32_t(index))).isMagic(JS_ARRAY_HOLE)) {
*hole = JS_FALSE;

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

@ -1189,15 +1189,36 @@ js_ErrorToException(JSContext *cx, const char *message, JSErrorReport *reportp,
return true;
}
static bool
IsDuckTypedErrorObject(JSContext *cx, JSObject *exnObject, const char **filename_strp)
{
JSBool found;
if (!JS_HasProperty(cx, exnObject, js_message_str, &found) || !found)
return false;
const char *filename_str = *filename_strp;
if (!JS_HasProperty(cx, exnObject, filename_str, &found) || !found) {
/* DOMException duck quacks "filename" (all lowercase) */
filename_str = "filename";
if (!JS_HasProperty(cx, exnObject, filename_str, &found) || !found)
return false;
}
if (!JS_HasProperty(cx, exnObject, js_lineNumber_str, &found) || !found)
return false;
*filename_strp = filename_str;
return true;
}
JSBool
js_ReportUncaughtException(JSContext *cx)
{
jsval exn;
JSObject *exnObject;
jsval roots[5];
jsval roots[6];
JSErrorReport *reportp, report;
JSString *str;
const char *bytes;
if (!JS_IsExceptionPending(cx))
return true;
@ -1226,51 +1247,75 @@ js_ReportUncaughtException(JSContext *cx)
/* XXX L10N angels cry once again. see also everywhere else */
str = ToString(cx, exn);
JSAutoByteString bytesStorage;
if (!str) {
bytes = "unknown (can't convert to string)";
} else {
if (str)
roots[1] = StringValue(str);
if (!bytesStorage.encode(cx, str))
return false;
bytes = bytesStorage.ptr();
}
const char *filename_str = js_fileName_str;
JSAutoByteString filename;
if (!reportp && exnObject && exnObject->isError()) {
if (!JS_GetProperty(cx, exnObject, js_message_str, &roots[2]))
return false;
if (JSVAL_IS_STRING(roots[2])) {
bytesStorage.clear();
if (!bytesStorage.encode(cx, str))
return false;
bytes = bytesStorage.ptr();
if (!reportp && exnObject &&
(exnObject->isError() ||
IsDuckTypedErrorObject(cx, exnObject, &filename_str)))
{
JSString *name = NULL;
if (JS_GetProperty(cx, exnObject, js_name_str, &roots[2]) &&
JSVAL_IS_STRING(roots[2]))
{
name = JSVAL_TO_STRING(roots[2]);
}
if (!JS_GetProperty(cx, exnObject, js_fileName_str, &roots[3]))
return false;
str = ToString(cx, roots[3]);
if (!str || !filename.encode(cx, str))
return false;
JSString *msg = NULL;
if (JS_GetProperty(cx, exnObject, js_message_str, &roots[3]) &&
JSVAL_IS_STRING(roots[3]))
{
msg = JSVAL_TO_STRING(roots[3]);
}
if (name && msg) {
JSString *colon = JS_NewStringCopyZ(cx, ": ");
if (!colon)
return false;
JSString *nameColon = JS_ConcatStrings(cx, name, colon);
if (!nameColon)
return false;
str = JS_ConcatStrings(cx, nameColon, msg);
if (!str)
return false;
} else if (name) {
str = name;
} else if (msg) {
str = msg;
}
if (JS_GetProperty(cx, exnObject, filename_str, &roots[4])) {
JSString *tmp = ToString(cx, roots[4]);
if (tmp)
filename.encode(cx, tmp);
}
if (!JS_GetProperty(cx, exnObject, js_lineNumber_str, &roots[4]))
return false;
uint32_t lineno;
if (!ToUint32(cx, roots[4], &lineno))
return false;
if (!JS_GetProperty(cx, exnObject, js_lineNumber_str, &roots[5]) ||
!ToUint32(cx, roots[5], &lineno))
{
lineno = 0;
}
reportp = &report;
PodZero(&report);
report.filename = filename.ptr();
report.lineno = (unsigned) lineno;
if (JSVAL_IS_STRING(roots[2])) {
JSFixedString *fixed = JSVAL_TO_STRING(roots[2])->ensureFixed(cx);
if (!fixed)
return false;
report.ucmessage = fixed->chars();
if (str) {
if (JSFixedString *fixed = str->ensureFixed(cx))
report.ucmessage = fixed->chars();
}
}
JSAutoByteString bytesStorage;
const char *bytes = NULL;
if (str)
bytes = bytesStorage.encode(cx, str);
if (!bytes)
bytes = "unknown (can't convert to string)";
if (!reportp) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
JSMSG_UNCAUGHT_EXCEPTION, bytes);

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

@ -1367,7 +1367,7 @@ void
JSCompartment::reduceGCTriggerBytes(size_t amount)
{
JS_ASSERT(amount > 0);
JS_ASSERT(gcTriggerBytes - amount >= 0);
JS_ASSERT(gcTriggerBytes >= amount);
if (gcTriggerBytes - amount < GC_ALLOCATION_THRESHOLD * GC_HEAP_GROWTH_FACTOR)
return;
gcTriggerBytes -= amount;

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

@ -774,6 +774,9 @@ ScanTypeObject(GCMarker *gcmarker, types::TypeObject *type)
if (type->proto)
PushMarkStack(gcmarker, type->proto);
if (type->singleton && !type->lazy())
PushMarkStack(gcmarker, type->singleton);
if (type->newScript) {
PushMarkStack(gcmarker, type->newScript->fun);
PushMarkStack(gcmarker, type->newScript->shape);
@ -781,12 +784,6 @@ ScanTypeObject(GCMarker *gcmarker, types::TypeObject *type)
if (type->interpretedFunction)
PushMarkStack(gcmarker, type->interpretedFunction);
if (type->singleton && !type->lazy())
PushMarkStack(gcmarker, type->singleton);
if (type->interpretedFunction)
PushMarkStack(gcmarker, type->interpretedFunction);
}
static void

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

@ -1775,9 +1775,7 @@ class TypedArrayTemplate
{
JS_ASSERT(tarray);
JS_ASSERT(0 <= begin);
JS_ASSERT(begin <= getLength(tarray));
JS_ASSERT(0 <= end);
JS_ASSERT(end <= getLength(tarray));
JSObject *bufobj = getBuffer(tarray);

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

@ -7,6 +7,7 @@
a {
font-weight: bold;
line-height: 1.1em;
color: blue;
}
a#first {

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

@ -7,6 +7,7 @@
a {
font-weight: bold;
line-height: 1.1em;
color: blue;
}
a#first {
@ -26,4 +27,4 @@ gets mapped to 40px.
-->
<div>
<a id="first" href="">Hello</a><a id="second" href="">Worldz</a>
</div>
</div>

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

@ -71,11 +71,11 @@ private:
nsRect mRects[2];
public:
nsRect& Overflow(size_t aIndex) {
NS_ASSERTION(0 <= aIndex && aIndex < 2, "index out of range");
NS_ASSERTION(aIndex < 2, "index out of range");
return mRects[aIndex];
}
const nsRect& Overflow(size_t aIndex) const {
NS_ASSERTION(0 <= aIndex && aIndex < 2, "index out of range");
NS_ASSERTION(aIndex < 2, "index out of range");
return mRects[aIndex];
}

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

@ -23,7 +23,7 @@
<!-- embellished operator (bug 21479) -->
<p><math xmlns="http://www.w3.org/1998/Math/MathML">
<mover>
<mtext>■□■□■□■□■□■□</mtext>
<mspace width="300px" height="10px" mathbackground="black"></mspace>
<mo>&#xaf;</mo>
</mover>
</math></p>

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше