This commit is contained in:
Rob Campbell 2011-11-28 10:38:03 -04:00
Родитель d131587fde 30d74a0fd5
Коммит c57f132792
392 изменённых файлов: 8249 добавлений и 5261 удалений

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

@ -44,7 +44,8 @@
#include "nsMai.h"
#include "prlink.h"
#include "prenv.h"
#include "nsIPrefBranch.h"
#include "mozilla/Preferences.h"
#include "nsIGConfService.h"
#include "nsIServiceManager.h"
#include "nsAutoPtr.h"
#include "nsAccessibilityService.h"
@ -53,6 +54,8 @@
#include <gtk/gtk.h>
#include <atk/atk.h>
using namespace mozilla;
typedef GType (* AtkGetTypeType) (void);
GType g_atk_hyperlink_impl_type = G_TYPE_INVALID;
static bool sATKChecked = false;
@ -61,10 +64,12 @@ static const char sATKLibName[] = "libatk-1.0.so.0";
static const char sATKHyperlinkImplGetTypeSymbol[] =
"atk_hyperlink_impl_get_type";
static const char sAccEnv [] = "GNOME_ACCESSIBILITY";
static const char sSysPrefService [] =
"@mozilla.org/system-preference-service;1";
static const char sUseSystemPrefsKey[] =
"config.use_system_prefs";
static const char sAccessibilityKey [] =
"config.use_system_prefs.accessibility";
static const char sGconfAccessibilityKey[] =
"/desktop/gnome/interface/accessibility";
/* gail function pointer */
static guint (* gail_add_global_event_listener) (GSignalEmissionHook listener,
@ -625,11 +630,17 @@ nsApplicationAccessibleWrap::Init()
isGnomeATEnabled = !!atoi(envValue);
} else {
//check gconf-2 setting
nsresult rv;
nsCOMPtr<nsIPrefBranch> sysPrefService =
do_GetService(sSysPrefService, &rv);
if (NS_SUCCEEDED(rv) && sysPrefService) {
sysPrefService->GetBoolPref(sAccessibilityKey, &isGnomeATEnabled);
if (Preferences::GetBool(sUseSystemPrefsKey, false)) {
nsresult rv;
nsCOMPtr<nsIGConfService> gconf =
do_GetService(NS_GCONFSERVICE_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv) && gconf) {
gconf->GetBool(NS_LITERAL_CSTRING(sGconfAccessibilityKey),
&isGnomeATEnabled);
}
} else {
isGnomeATEnabled =
Preferences::GetBool(sAccessibilityKey, false);
}
}

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

@ -50,6 +50,7 @@
#include "nsIContentViewer.h"
#include "nsCURILoader.h"
#include "nsDocAccessible.h"
#include "nsHTMLCanvasAccessible.h"
#include "nsHTMLImageMapAccessible.h"
#include "nsHTMLLinkAccessible.h"
#include "nsHTMLSelectAccessible.h"
@ -275,6 +276,16 @@ nsAccessibilityService::CreateHTMLComboboxAccessible(nsIContent* aContent,
return accessible;
}
already_AddRefed<nsAccessible>
nsAccessibilityService::CreateHTMLCanvasAccessible(nsIContent* aContent,
nsIPresShell* aPresShell)
{
nsCOMPtr<nsIWeakReference> weakShell(do_GetWeakReference(aPresShell));
nsAccessible* accessible = new nsHTMLCanvasAccessible(aContent, weakShell);
NS_IF_ADDREF(accessible);
return accessible;
}
already_AddRefed<nsAccessible>
nsAccessibilityService::CreateHTMLImageAccessible(nsIContent* aContent,
nsIPresShell* aPresShell)

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

@ -83,6 +83,8 @@ public:
CreateHTML4ButtonAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
virtual already_AddRefed<nsAccessible>
CreateHTMLButtonAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
already_AddRefed<nsAccessible>
CreateHTMLCanvasAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
virtual already_AddRefed<nsAccessible>
CreateHTMLCaptionAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
virtual already_AddRefed<nsAccessible>

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

@ -391,29 +391,25 @@ nsRootAccessible::ProcessDOMEvent(nsIDOMEvent* aDOMEvent)
nsINode* targetNode = accessible->GetNode();
#ifdef MOZ_XUL
bool isTree = targetNode->IsElement() &&
targetNode->AsElement()->NodeInfo()->Equals(nsGkAtoms::tree, kNameSpaceID_XUL);
nsRefPtr<nsXULTreeAccessible> treeAcc;
if (targetNode->IsElement() &&
targetNode->AsElement()->NodeInfo()->Equals(nsGkAtoms::tree,
kNameSpaceID_XUL)) {
treeAcc = do_QueryObject(accessible);
if (isTree) {
nsRefPtr<nsXULTreeAccessible> treeAcc = do_QueryObject(accessible);
NS_ASSERTION(treeAcc,
"Accessible for xul:tree isn't nsXULTreeAccessible.");
if (eventType.EqualsLiteral("TreeViewChanged")) {
treeAcc->TreeViewChanged();
return;
}
if (treeAcc) {
if (eventType.EqualsLiteral("TreeViewChanged")) {
treeAcc->TreeViewChanged();
return;
}
if (eventType.EqualsLiteral("TreeRowCountChanged")) {
HandleTreeRowCountChangedEvent(aDOMEvent, treeAcc);
return;
}
if (eventType.EqualsLiteral("TreeRowCountChanged")) {
HandleTreeRowCountChangedEvent(aDOMEvent, treeAcc);
return;
}
if (eventType.EqualsLiteral("TreeInvalidated")) {
HandleTreeInvalidatedEvent(aDOMEvent, treeAcc);
return;
}
if (eventType.EqualsLiteral("TreeInvalidated")) {
HandleTreeInvalidatedEvent(aDOMEvent, treeAcc);
return;
}
}
#endif
@ -451,18 +447,16 @@ nsRootAccessible::ProcessDOMEvent(nsIDOMEvent* aDOMEvent)
return;
}
nsAccessible *treeItemAccessible = nsnull;
nsAccessible* treeItemAcc = nsnull;
#ifdef MOZ_XUL
// If it's a tree element, need the currently selected item
if (isTree) {
treeItemAccessible = accessible->CurrentItem();
if (treeItemAccessible)
accessible = treeItemAccessible;
// If it's a tree element, need the currently selected item.
if (treeAcc) {
treeItemAcc = accessible->CurrentItem();
if (treeItemAcc)
accessible = treeItemAcc;
}
#endif
#ifdef MOZ_XUL
if (treeItemAccessible && eventType.EqualsLiteral("OpenStateChange")) {
if (treeItemAcc && eventType.EqualsLiteral("OpenStateChange")) {
PRUint64 state = accessible->State();
bool isEnabled = (state & states::EXPANDED) != 0;
@ -472,7 +466,7 @@ nsRootAccessible::ProcessDOMEvent(nsIDOMEvent* aDOMEvent)
return;
}
if (treeItemAccessible && eventType.EqualsLiteral("select")) {
if (treeItemAcc && eventType.EqualsLiteral("select")) {
// XXX: We shouldn't be based on DOM select event which doesn't provide us
// any context info. We should integrate into nsTreeSelection instead.
// If multiselect tree, we should fire selectionadd or selection removed
@ -491,8 +485,10 @@ nsRootAccessible::ProcessDOMEvent(nsIDOMEvent* aDOMEvent)
return;
}
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_SELECTION,
treeItemAccessible);
nsRefPtr<AccSelChangeEvent> selChangeEvent =
new AccSelChangeEvent(treeAcc, treeItemAcc,
AccSelChangeEvent::eSelectionAdd);
nsEventShell::FireEvent(selChangeEvent);
return;
}
}

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

@ -50,6 +50,7 @@ LIBXUL_LIBRARY = 1
CPPSRCS = \
nsHTMLCanvasAccessible.cpp \
nsHTMLFormControlAccessible.cpp \
nsHTMLImageAccessible.cpp \
nsHTMLImageMapAccessible.cpp \

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

@ -0,0 +1,52 @@
/* -*- Mode: C++; tab-width: 2; 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.org 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):
*
* 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 "nsHTMLCanvasAccessible.h"
using namespace mozilla::a11y;
nsHTMLCanvasAccessible::
nsHTMLCanvasAccessible(nsIContent* aContent, nsIWeakReference* aShell) :
nsHyperTextAccessible(aContent, aShell)
{
}
PRUint32
nsHTMLCanvasAccessible::NativeRole()
{
return nsIAccessibleRole::ROLE_CANVAS;
}

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

@ -0,0 +1,56 @@
/* -*- Mode: C++; tab-width: 2; 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.org 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):
*
* 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 "nsHyperTextAccessible.h"
#ifndef _nsHTMLCanvasAccessible_H_
#define _nsHTMLCanvasAccessible_H_
/**
* HTML canvas accessible (html:canvas).
*/
class nsHTMLCanvasAccessible : public nsHyperTextAccessible
{
public:
nsHTMLCanvasAccessible(nsIContent* aContent, nsIWeakReference* aShell);
virtual ~nsHTMLCanvasAccessible() { }
// nsAccessible
virtual PRUint32 NativeRole();
};
#endif

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

@ -7,6 +7,7 @@ const ROLE_APPLICATION = nsIAccessibleRole.ROLE_APPLICATION;
const ROLE_APP_ROOT = nsIAccessibleRole.ROLE_APP_ROOT;
const ROLE_AUTOCOMPLETE = nsIAccessibleRole.ROLE_AUTOCOMPLETE;
const ROLE_BUTTONDROPDOWNGRID = nsIAccessibleRole.ROLE_BUTTONDROPDOWNGRID;
const ROLE_CANVAS = nsIAccessibleRole.ROLE_CANVAS;
const ROLE_CAPTION = nsIAccessibleRole.ROLE_CAPTION;
const ROLE_CELL = nsIAccessibleRole.ROLE_CELL;
const ROLE_CHECKBUTTON = nsIAccessibleRole.ROLE_CHECKBUTTON;

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

@ -52,6 +52,7 @@ _TEST_FILES =\
test_aria_imgmap.html \
test_aria_presentation.html \
test_button.xul \
test_canvas.html \
test_combobox.xul \
test_cssoverflow.html \
test_dochierarchy.html \

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

@ -0,0 +1,57 @@
<!DOCTYPE html>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=495912
-->
<head>
<title>File Input Control tests</title>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="../common.js"></script>
<script type="application/javascript"
src="../role.js"></script>
<script type="application/javascript">
function doTest()
{
var accTree = {
role: ROLE_CANVAS,
children: [
]
};
testAccessibleTree("canvas", accTree);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank"
title="Expose alternative content in Canvas element to ATs"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=495912">Mozilla Bug 495912</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<canvas id="canvas" tabindex="0">
fallback content.
</canvas>
<script type="text/javascript">
var c=document.getElementById("canvas");
var cxt=c.getContext("2d");
cxt.fillStyle="#005500";
cxt.fillRect(0,0,150,75);
</script>
</body>
</html>

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

@ -1,5 +1,5 @@
<?xml version="1.0"?>
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist" lastupdate="1318359094000">
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist" lastupdate="1321712096000">
<emItems>
<emItem blockID="i41" id="{99079a25-328f-4bd4-be04-00955acaa0a7}">
<versionRange minVersion="0.1" maxVersion="4.3.1.00" severity="1">
@ -117,6 +117,13 @@
<versionRange minVersion="2.2" maxVersion="2.2">
</versionRange>
</emItem>
<emItem blockID="i45" id="{22119944-ED35-4ab1-910B-E619EA06A115}">
<versionRange minVersion="0.1" maxVersion="7.6.1">
<targetApplication id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}">
<versionRange minVersion="8.0a1" maxVersion="*" />
</targetApplication>
</versionRange>
</emItem>
<emItem blockID="i3" id="langpack-vi-VN@firefox.mozilla.org">
<versionRange minVersion="2.0" maxVersion="2.0">
</versionRange>

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

@ -1,8 +1,8 @@
ac_add_options --enable-debug
ac_add_options --enable-trace-malloc
CC=/tools/gcc-4.5-0moz2/bin/gcc
CXX=/tools/gcc-4.5-0moz2/bin/g++
. $topsrcdir/build/unix/mozconfig.linux
# Avoid dependency on libstdc++ 4.5
ac_add_options --enable-stdcxx-compat

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

@ -3,5 +3,5 @@ ac_add_options --enable-official-branding
ac_add_options --enable-update-channel=${MOZ_UPDATE_CHANNEL}
ac_add_options --enable-update-packaging
CC=/tools/gcc-4.5-0moz2/bin/gcc
CXX=/tools/gcc-4.5-0moz2/bin/g++
. $topsrcdir/build/unix/mozconfig.linux

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

@ -5,8 +5,8 @@ ac_add_options --enable-codesighs
# Nightlies only since this has a cost in performance
ac_add_options --enable-js-diagnostics
CC=/tools/gcc-4.5-0moz2/bin/gcc
CXX=/tools/gcc-4.5-0moz2/bin/g++
. $topsrcdir/build/unix/mozconfig.linux
# Avoid dependency on libstdc++ 4.5
ac_add_options --enable-stdcxx-compat

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

@ -1,8 +1,8 @@
ac_add_options --enable-update-packaging
ac_add_options --enable-codesighs
CC=/tools/gcc-4.5-0moz2/bin/gcc
CXX=/tools/gcc-4.5-0moz2/bin/g++
. $topsrcdir/build/unix/mozconfig.linux
# Avoid dependency on libstdc++ 4.5
ac_add_options --enable-stdcxx-compat

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

@ -2,8 +2,8 @@ ac_add_options --enable-update-channel=${MOZ_UPDATE_CHANNEL}
ac_add_options --enable-update-packaging
ac_add_options --enable-official-branding
CC=/tools/gcc-4.5-0moz2/bin/gcc
CXX=/tools/gcc-4.5-0moz2/bin/g++
. $topsrcdir/build/unix/mozconfig.linux
# Avoid dependency on libstdc++ 4.5
ac_add_options --enable-stdcxx-compat

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

@ -9,8 +9,8 @@ ac_add_options --disable-updater
ac_add_options --prefix=$PREFIX
ac_add_options --libdir=$LIBDIR
CC=/tools/gcc-4.5-0moz2/bin/gcc
CXX=/tools/gcc-4.5-0moz2/bin/g++
. $topsrcdir/build/unix/mozconfig.linux
# Avoid dependency on libstdc++ 4.5
ac_add_options --enable-stdcxx-compat

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

@ -1,8 +1,8 @@
ac_add_options --enable-debug
ac_add_options --enable-trace-malloc
CC=/tools/gcc-4.5-0moz2/bin/gcc
CXX=/tools/gcc-4.5-0moz2/bin/g++
. $topsrcdir/build/unix/mozconfig.linux
# Avoid dependency on libstdc++ 4.5
ac_add_options --enable-stdcxx-compat

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

@ -3,5 +3,5 @@ ac_add_options --enable-official-branding
ac_add_options --enable-update-channel=${MOZ_UPDATE_CHANNEL}
ac_add_options --enable-update-packaging
CC=/tools/gcc-4.5-0moz2/bin/gcc
CXX=/tools/gcc-4.5-0moz2/bin/g++
. $topsrcdir/build/unix/mozconfig.linux

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

@ -5,8 +5,8 @@ ac_add_options --enable-codesighs
# Nightlies only since this has a cost in performance
ac_add_options --enable-js-diagnostics
CC=/tools/gcc-4.5-0moz2/bin/gcc
CXX=/tools/gcc-4.5-0moz2/bin/g++
. $topsrcdir/build/unix/mozconfig.linux
# Avoid dependency on libstdc++ 4.5
ac_add_options --enable-stdcxx-compat

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

@ -2,8 +2,8 @@ ac_add_options --enable-update-channel=${MOZ_UPDATE_CHANNEL}
ac_add_options --enable-update-packaging
ac_add_options --enable-official-branding
CC=/tools/gcc-4.5-0moz2/bin/gcc
CXX=/tools/gcc-4.5-0moz2/bin/g++
. $topsrcdir/build/unix/mozconfig.linux
# Avoid dependency on libstdc++ 4.5
ac_add_options --enable-stdcxx-compat

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

@ -9,8 +9,8 @@ ac_add_options --disable-updater
ac_add_options --prefix=$PREFIX
ac_add_options --libdir=$LIBDIR
CC=/tools/gcc-4.5-0moz2/bin/gcc
CXX=/tools/gcc-4.5-0moz2/bin/g++
. $topsrcdir/build/unix/mozconfig.linux
# Avoid dependency on libstdc++ 4.5
ac_add_options --enable-stdcxx-compat

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

@ -148,6 +148,7 @@
@BINPATH@/components/dom_json.xpt
@BINPATH@/components/dom_range.xpt
@BINPATH@/components/dom_sidebar.xpt
@BINPATH@/components/dom_sms.xpt
@BINPATH@/components/dom_storage.xpt
@BINPATH@/components/dom_stylesheets.xpt
@BINPATH@/components/dom_threads.xpt

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

@ -314,6 +314,7 @@ searchplugins/atlas-sk.src
searchplugins/baidu.gif
searchplugins/baidu.png
searchplugins/baidu.src
searchplugins/bluu.xml
searchplugins/bok-NO.gif
searchplugins/bok-NO.png
searchplugins/bok-NO.src

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

@ -88,6 +88,17 @@
padding: 2px 4px;
}
/* Because of -moz-box-align: center above, separators will be invisible unless
we set their min-height. See bug 583510 for more information. */
toolbarseparator {
min-height: 22px;
}
/* We need more height when toolbar buttons show both icon and text. */
toolbar[mode="full"] toolbarseparator {
min-height: 36px;
}
#nav-bar {
padding-bottom: 4px !important;
}

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

@ -2,12 +2,6 @@
/* Sidebars */
.sidebar-placesTree {
background-color: transparent !important;
-moz-appearance: none !important;
border: none !important;
}
#bookmarksPanel,
#history-panel,
#sidebar-search-container {

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

@ -36,13 +36,14 @@ dnl the terms of any one of the MPL, the GPL or the LGPL.
dnl
dnl ***** END LICENSE BLOCK *****
dnl MOZ_CHECK_HEADER(HEADER-FILE, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
dnl MOZ_CHECK_HEADER(HEADER-FILE, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, INCLUDES]]])
AC_DEFUN([MOZ_CHECK_HEADER],
[ dnl Do the transliteration at runtime so arg 1 can be a shell variable.
ac_safe=`echo "$1" | sed 'y%./+-%__p_%'`
AC_MSG_CHECKING([for $1])
AC_CACHE_VAL(ac_cv_header_$ac_safe,
[ AC_TRY_COMPILE([#include <$1>], ,
[ AC_TRY_COMPILE([$4
#include <$1>], ,
eval "ac_cv_header_$ac_safe=yes",
eval "ac_cv_header_$ac_safe=no") ])
if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
@ -54,12 +55,12 @@ AC_DEFUN([MOZ_CHECK_HEADER],
fi
])
dnl MOZ_CHECK_HEADERS(HEADER-FILE... [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
dnl MOZ_CHECK_HEADERS(HEADER-FILE... [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, INCLUDES]]])
AC_DEFUN([MOZ_CHECK_HEADERS],
[ for ac_hdr in $1
do
MOZ_CHECK_HEADER($ac_hdr,
[ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
AC_DEFINE_UNQUOTED($ac_tr_hdr) $2], $3)
AC_DEFINE_UNQUOTED($ac_tr_hdr) $2], $3, [$4])
done
])

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

@ -0,0 +1,2 @@
CC=/tools/gcc-4.5-0moz2/bin/gcc
CXX=/tools/gcc-4.5-0moz2/bin/g++

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

@ -5935,12 +5935,11 @@ if test "$MOZ_XTF"; then
fi
dnl ========================================================
dnl Pref extensions (autoconfig and system-pref)
dnl Pref extensions (autoconfig)
dnl ========================================================
MOZ_ARG_DISABLE_BOOL(pref-extensions,
[ --disable-pref-extensions
Disable pref extensions such as autoconfig and
system-pref],
Disable pref extensions such as autoconfig],
MOZ_PREF_EXTENSIONS=,
MOZ_PREF_EXTENSIONS=1 )
@ -8761,8 +8760,8 @@ if test "$USE_FC_FREETYPE"; then
if test "$COMPILE_ENVIRONMENT"; then
_SAVE_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $FT2_CFLAGS $XCFLAGS"
AC_CHECK_HEADERS(fontconfig/fcfreetype.h, ,
[AC_MSG_ERROR(Can't find header fontconfig/fcfreetype.h.)])
MOZ_CHECK_HEADERS([fontconfig/fcfreetype.h], ,
[AC_MSG_ERROR(Can't find header fontconfig/fcfreetype.h.)], [#include <fontconfig/fontconfig.h>])
CPPFLAGS="$_SAVE_CPPFLAGS"
else
AC_DEFINE(HAVE_FONTCONFIG_FCFREETYPE_H)

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

@ -1290,11 +1290,6 @@ public:
static void TraceWrapper(nsWrapperCache* aCache, TraceCallback aCallback,
void *aClosure);
/**
* Convert nsIContent::IME_STATUS_* to nsIWidget::IME_STATUS_*
*/
static PRUint32 GetWidgetStatusFromIMEStatus(PRUint32 aState);
/*
* Notify when the first XUL menu is opened and when the all XUL menus are
* closed. At opening, aInstalling should be TRUE, otherwise, it should be

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

@ -46,8 +46,8 @@ class nsDOMAttributeMap;
class nsIContent;
#define NS_IATTRIBUTE_IID \
{ 0xf809b623, 0x5b1e, 0x4121, \
{ 0xb8, 0x9d, 0x19, 0x24, 0x7b, 0x70, 0x77, 0x08 } }
{ 0x536167ae, 0x8a9c, 0x4712, \
{ 0x8b, 0x61, 0x3, 0x43, 0xf6, 0xbc, 0x64, 0x75 } }
class nsIAttribute : public nsINode
{

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

@ -63,8 +63,11 @@ class nsIDOMCSSStyleDeclaration;
namespace mozilla {
namespace css {
class StyleRule;
}
}
} // namespace css
namespace widget {
struct IMEState;
} // namespace widget
} // namespace mozilla
enum nsLinkState {
eLinkState_Unknown = 0,
@ -75,8 +78,8 @@ enum nsLinkState {
// IID for the nsIContent interface
#define NS_ICONTENT_IID \
{ 0xb651e0a7, 0x1471, 0x49cc, \
{ 0xb4, 0xe1, 0xc2, 0xca, 0x01, 0xfe, 0xb7, 0x80 } }
{ 0xed40a3e5, 0xd7ed, 0x473e, \
{ 0x85, 0xe3, 0x82, 0xc3, 0xf0, 0x41, 0xdb, 0x52 } }
/**
* A node of content in a document's content model. This interface
@ -84,6 +87,8 @@ enum nsLinkState {
*/
class nsIContent : public nsINode {
public:
typedef mozilla::widget::IMEState IMEState;
#ifdef MOZILLA_INTERNAL_API
// If you're using the external API, the only thing you can know about
// nsIContent is that it exists with an IID
@ -604,40 +609,18 @@ public:
* Get desired IME state for the content.
*
* @return The desired IME status for the content.
* This is a combination of IME_STATUS_* flags,
* controlling what happens to IME when the content takes focus.
* If this is IME_STATUS_NONE, IME remains in its current state.
* IME_STATUS_ENABLE and IME_STATUS_DISABLE must not be set
* together; likewise IME_STATUS_OPEN and IME_STATUS_CLOSE must
* not be set together.
* If you return IME_STATUS_DISABLE, you should not set the
* OPEN or CLOSE flag; that way, when IME is next enabled,
* the previous OPEN/CLOSE state will be restored (unless the newly
* focused content specifies the OPEN/CLOSE state by setting the OPEN
* or CLOSE flag with the ENABLE flag).
* IME_STATUS_PASSWORD should be returned only from password editor,
* this value has a special meaning. It is used as alternative of
* IME_STATUS_DISABLED.
* IME_STATUS_PLUGIN should be returned only when plug-in has focus.
* When a plug-in is focused content, we should send native events
* directly. Because we don't process some native events, but they may
* be needed by the plug-in.
* This is a combination of an IME enabled value and
* an IME open value of widget::IMEState.
* If you return DISABLED, you should not set the OPEN and CLOSE
* value.
* PASSWORD should be returned only from password editor, this value
* has a special meaning. It is used as alternative of DISABLED.
* PLUGIN should be returned only when plug-in has focus. When a
* plug-in is focused content, we should send native events directly.
* Because we don't process some native events, but they may be needed
* by the plug-in.
*/
enum {
IME_STATUS_NONE = 0x0000,
IME_STATUS_ENABLE = 0x0001,
IME_STATUS_DISABLE = 0x0002,
IME_STATUS_PASSWORD = 0x0004,
IME_STATUS_PLUGIN = 0x0008,
IME_STATUS_OPEN = 0x0010,
IME_STATUS_CLOSE = 0x0020
};
enum {
IME_STATUS_MASK_ENABLED = IME_STATUS_ENABLE | IME_STATUS_DISABLE |
IME_STATUS_PASSWORD | IME_STATUS_PLUGIN,
IME_STATUS_MASK_OPENED = IME_STATUS_OPEN | IME_STATUS_CLOSE
};
virtual PRUint32 GetDesiredIMEState();
virtual IMEState GetDesiredIMEState();
/**
* Gets content node with the binding (or native code, possibly on the

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

@ -41,7 +41,7 @@ interface nsIDOMEventListener;
interface nsIDOMBlob;
interface nsIDOMFileError;
[scriptable, builtinclass, uuid(fc316500-87c4-411e-ab75-dd62468f4174)]
[scriptable, builtinclass, uuid(d158de26-904e-4731-b42c-8b3a4d172703)]
interface nsIDOMFileReader : nsIDOMEventTarget
{
[implicit_jscontext]

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

@ -124,8 +124,8 @@ class Element;
} // namespace mozilla
#define NS_IDOCUMENT_IID \
{ 0x184e0a3c, 0x1899, 0x417d, \
{ 0xbf, 0xf4, 0x5a, 0x15, 0xe6, 0xe8, 0xaa, 0x94 } }
{ 0x3b78f6, 0x6dc5, 0x44c6, \
{ 0xbc, 0x28, 0x60, 0x2a, 0xb2, 0x4f, 0xfb, 0x7b } }
// Flag for AddStyleSheet().
#define NS_STYLESHEET_FROM_CATALOG (1 << 0)

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

@ -288,8 +288,8 @@ private:
// IID for the nsINode interface
#define NS_INODE_IID \
{ 0x20d16be2, 0x3c58, 0x4099, \
{ 0xbf, 0xa6, 0xd0, 0xe7, 0x6b, 0xb1, 0x3d, 0xc5 } }
{ 0xd026d280, 0x5b25, 0x41c0, \
{ 0x92, 0xcf, 0x6, 0xf6, 0xf, 0xb, 0x9a, 0xfe } }
/**
* An internal interface that abstracts some DOMNode-related parts that both
@ -728,6 +728,7 @@ public:
*/
NS_DECL_NSIDOMEVENTTARGET
using nsIDOMEventTarget::AddEventListener;
using nsIDOMEventTarget::AddSystemEventListener;
/**
* Adds a mutation observer to be notified when this node, or any of its

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

@ -53,7 +53,7 @@ interface nsIDOMBlob;
#include "jsapi.h"
%}
[scriptable, builtinclass, uuid(dea238a1-240f-45f4-9f07-7769bc69eb76)]
[scriptable, builtinclass, uuid(e2b59e48-3655-4429-a94c-b4332c346ba2)]
interface nsIXMLHttpRequestEventTarget : nsIDOMEventTarget {
// event handler attributes
attribute nsIDOMEventListener onabort;
@ -64,7 +64,7 @@ interface nsIXMLHttpRequestEventTarget : nsIDOMEventTarget {
attribute nsIDOMEventListener onloadend;
};
[scriptable, builtinclass, uuid(09ff3682-7759-4441-a765-f70e1a1fabcf)]
[scriptable, builtinclass, uuid(db9357fc-edf7-42b2-aab2-c24ab19ece20)]
interface nsIXMLHttpRequestUpload : nsIXMLHttpRequestEventTarget {
// for future use
};

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

@ -212,6 +212,7 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID);
using namespace mozilla::dom;
using namespace mozilla::layers;
using namespace mozilla::widget;
using namespace mozilla;
const char kLoadAsData[] = "loadAsData";
@ -4026,25 +4027,6 @@ nsContentUtils::DropJSObjects(void* aScriptObjectHolder)
return rv;
}
/* static */
PRUint32
nsContentUtils::GetWidgetStatusFromIMEStatus(PRUint32 aState)
{
switch (aState & nsIContent::IME_STATUS_MASK_ENABLED) {
case nsIContent::IME_STATUS_DISABLE:
return nsIWidget::IME_STATUS_DISABLED;
case nsIContent::IME_STATUS_ENABLE:
return nsIWidget::IME_STATUS_ENABLED;
case nsIContent::IME_STATUS_PASSWORD:
return nsIWidget::IME_STATUS_PASSWORD;
case nsIContent::IME_STATUS_PLUGIN:
return nsIWidget::IME_STATUS_PLUGIN;
default:
NS_ERROR("The given state doesn't have valid enable state");
return nsIWidget::IME_STATUS_ENABLED;
}
}
/* static */
void
nsContentUtils::NotifyInstalledMenuKeyboardListener(bool aInstalling)

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

@ -109,6 +109,7 @@
#include "nsIDOMEventListener.h"
#include "nsIWebNavigation.h"
#include "nsIBaseWindow.h"
#include "nsIWidget.h"
#include "jsapi.h"
@ -1096,6 +1097,28 @@ nsINode::AddEventListener(const nsAString& aType,
return NS_OK;
}
NS_IMETHODIMP
nsINode::AddSystemEventListener(const nsAString& aType,
nsIDOMEventListener *aListener,
bool aUseCapture,
bool aWantsUntrusted,
PRUint8 aOptionalArgc)
{
NS_ASSERTION(!aWantsUntrusted || aOptionalArgc > 1,
"Won't check if this is chrome, you want to set "
"aWantsUntrusted to false or make the aWantsUntrusted "
"explicit by making aOptionalArgc non-zero.");
if (!aWantsUntrusted &&
(aOptionalArgc < 2 &&
!nsContentUtils::IsChromeDoc(OwnerDoc()))) {
aWantsUntrusted = true;
}
return NS_AddSystemEventListener(this, aType, aListener, aUseCapture,
aWantsUntrusted);
}
NS_IMETHODIMP
nsINode::RemoveEventListener(const nsAString& aType,
nsIDOMEventListener* aListener,
@ -1108,6 +1131,8 @@ nsINode::RemoveEventListener(const nsAString& aType,
return NS_OK;
}
NS_IMPL_REMOVE_SYSTEM_EVENT_LISTENER(nsINode)
nsresult
nsINode::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
{
@ -1339,11 +1364,11 @@ nsIContent::GetFlattenedTreeParent() const
return parent;
}
PRUint32
nsIContent::IMEState
nsIContent::GetDesiredIMEState()
{
if (!IsEditableInternal()) {
return IME_STATUS_DISABLE;
return IMEState(IMEState::DISABLED);
}
// NOTE: The content for independent editors (e.g., input[type=text],
// textarea) must override this method, so, we don't need to worry about
@ -1356,26 +1381,23 @@ nsIContent::GetDesiredIMEState()
}
nsIDocument* doc = GetCurrentDoc();
if (!doc) {
return IME_STATUS_DISABLE;
return IMEState(IMEState::DISABLED);
}
nsIPresShell* ps = doc->GetShell();
if (!ps) {
return IME_STATUS_DISABLE;
return IMEState(IMEState::DISABLED);
}
nsPresContext* pc = ps->GetPresContext();
if (!pc) {
return IME_STATUS_DISABLE;
return IMEState(IMEState::DISABLED);
}
nsIEditor* editor = GetHTMLEditor(pc);
nsCOMPtr<nsIEditorIMESupport> imeEditor = do_QueryInterface(editor);
if (!imeEditor) {
return IME_STATUS_DISABLE;
return IMEState(IMEState::DISABLED);
}
// Use "enable" for the default value because IME is disabled unexpectedly,
// it makes serious a11y problem.
PRUint32 state = IME_STATUS_ENABLE;
nsresult rv = imeEditor->GetPreferredIMEState(&state);
NS_ENSURE_SUCCESS(rv, IME_STATUS_ENABLE);
IMEState state;
imeEditor->GetPreferredIMEState(&state);
return state;
}

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

@ -884,7 +884,7 @@ NS_IMETHODIMP nsXMLHttpRequest::GetResponseText(nsAString& aResponseText)
// We only decode text lazily if we're also parsing to a doc.
// Also, if we've decoded all current data already, then no need to decode
// more.
if (IsWaitingForHTMLCharset() || !mResponseXML ||
if (!mResponseXML ||
mResponseBodyDecodedPos == mResponseBody.Length()) {
aResponseText = mResponseText;
return NS_OK;
@ -1473,16 +1473,6 @@ nsXMLHttpRequest::IsSystemXHR()
return !!nsContentUtils::IsSystemPrincipal(mPrincipal);
}
bool
nsXMLHttpRequest::IsWaitingForHTMLCharset()
{
if (!mIsHtml || !mResponseXML) {
return false;
}
nsCOMPtr<nsIDocument> doc = do_QueryInterface(mResponseXML);
return doc->GetDocumentCharacterSetSource() < kCharsetFromDocTypeDefault;
}
nsresult
nsXMLHttpRequest::CheckChannelForCrossSiteRequest(nsIChannel* aChannel)
{
@ -1928,7 +1918,13 @@ nsXMLHttpRequest::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
nsCAutoString type;
channel->GetContentType(type);
if (type.EqualsLiteral("text/html")) {
if ((mResponseType == XML_HTTP_RESPONSE_TYPE_DOCUMENT) &&
type.EqualsLiteral("text/html")) {
// HTML parsing is only supported for responseType == "document" to
// avoid running the parser and, worse, populating responseXML for
// legacy users of XHR who use responseType == "" for retrieving the
// responseText of text/html resources. This legacy case is so common
// that it's not useful to emit a warning about it.
if (!(mState & XML_HTTP_REQUEST_ASYNC)) {
// We don't make cool new features available in the bad synchronous
// mode. The synchronous mode is for legacy only.
@ -3138,13 +3134,11 @@ nsXMLHttpRequest::MaybeDispatchProgressEvents(bool aFinalProgress)
mLoadTotal = mLoadTransferred;
mLoadLengthComputable = true;
}
if (aFinalProgress || !IsWaitingForHTMLCharset()) {
mInLoadProgressEvent = true;
DispatchProgressEvent(this, NS_LITERAL_STRING(PROGRESS_STR),
true, mLoadLengthComputable, mLoadTransferred,
mLoadTotal, mLoadTransferred, mLoadTotal);
mInLoadProgressEvent = false;
}
mInLoadProgressEvent = true;
DispatchProgressEvent(this, NS_LITERAL_STRING(PROGRESS_STR),
true, mLoadLengthComputable, mLoadTransferred,
mLoadTotal, mLoadTransferred, mLoadTotal);
mInLoadProgressEvent = false;
if (mResponseType == XML_HTTP_RESPONSE_TYPE_CHUNKED_TEXT ||
mResponseType == XML_HTTP_RESPONSE_TYPE_CHUNKED_ARRAYBUFFER) {
mResponseBody.Truncate();

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

@ -236,8 +236,6 @@ protected:
bool IsSystemXHR();
bool IsWaitingForHTMLCharset();
void ChangeStateToDone();
/**

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

@ -510,7 +510,6 @@ _TEST_FILES2 = \
file_html_in_xhr2.html \
file_html_in_xhr3.html \
file_html_in_xhr.sjs \
file_html_in_xhr_slow.sjs \
test_bug664916.html \
test_bug666604.html \
test_bug675121.html \

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

@ -1,24 +0,0 @@
var timer;
function handleRequest(request, response)
{
var converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"]
.createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
converter.charset = "windows-1251";
var stream = converter.convertToInputStream("\u042E");
var out = response.bodyOutputStream;
response.setHeader("Cache-Control", "no-cache", false);
response.setHeader("Content-Type", "text/html", false);
out.writeFrom(stream, 1);
var firstPart = "<meta charset='windows";
out.write(firstPart, firstPart.length);
out.flush();
response.processAsync();
timer = Components.classes["@mozilla.org/timer;1"]
.createInstance(Components.interfaces.nsITimer);
timer.initWithCallback(function() {
response.write("-1251'>");
response.finish();
}, 500, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
}

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

@ -29,7 +29,12 @@ function runTest() {
ok(this.responseXML, "Should have gotten responseXML");
is(this.responseXML.characterSet, "windows-1251", "Wrong character encoding");
is(this.responseXML.documentElement.firstChild.data, " \u042E ", "Decoded using the wrong encoding.");
is(this.responseText.indexOf("\u042E"), 27, "Bad responseText");
try {
this.responseText;
ok(false, "responseText access should have thrown.");
} catch (e) {
is(e.code, 11, "Should have thrown INVALID_STATE_ERR.");
}
is(this.responseXML.getElementsByTagName("div").length, 1, "There should be one div.");
ok(!this.responseXML.documentElement.hasAttribute("data-fail"), "Should not have a data-fail attribute.");
var scripts = this.responseXML.getElementsByTagName("script");
@ -44,27 +49,21 @@ function runTest() {
}
}
xhr.open("GET", "file_html_in_xhr.html", true);
xhr.responseType = "document";
xhr.send();
}
function continueAfterReport() {
ok(!document.documentElement.hasAttribute("data-fail"), "Should not have a data-fail attribute on mochitest doc.");
xhr = new XMLHttpRequest();
xhr.onprogress = function() {
ok(this.responseText, "Got falsy responseText");
if (this.responseText) {
ok(this.responseText.length, "Got zero-length responseText");
if (this.responseText.length) {
is(this.responseText.charCodeAt(0), 0x042E, "Wrong character encoding for slow text");
}
}
}
xhr.onreadystatechange = function() {
if (this.readyState == 4) {
is(this.responseText.indexOf("\u042E"), -1, "Honored meta in default mode.");
is(this.responseText.indexOf("\uFFFD"), 29, "Honored meta in default mode 2.");
is(this.responseXML, null, "responseXML should be null for HTML in the default mode");
testNonParsingText();
}
}
xhr.open("GET", "file_html_in_xhr_slow.sjs");
xhr.open("GET", "file_html_in_xhr2.html");
xhr.send();
}

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

@ -144,4 +144,6 @@ nsresult
NS_NewDOMTouchEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, class nsInputEvent *aEvent);
nsresult
NS_NewDOMCustomEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, nsEvent* aEvent);
nsresult
NS_NewDOMSmsEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, nsEvent* aEvent);
#endif // nsIPrivateDOMEvent_h__

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

@ -103,6 +103,8 @@ nsDOMEventTargetHelper::RemoveEventListener(const nsAString& aType,
return NS_OK;
}
NS_IMPL_REMOVE_SYSTEM_EVENT_LISTENER(nsDOMEventTargetHelper)
NS_IMETHODIMP
nsDOMEventTargetHelper::AddEventListener(const nsAString& aType,
nsIDOMEventListener *aListener,
@ -130,6 +132,31 @@ nsDOMEventTargetHelper::AddEventListener(const nsAString& aType,
return NS_OK;
}
NS_IMETHODIMP
nsDOMEventTargetHelper::AddSystemEventListener(const nsAString& aType,
nsIDOMEventListener *aListener,
bool aUseCapture,
bool aWantsUntrusted,
PRUint8 aOptionalArgc)
{
NS_ASSERTION(!aWantsUntrusted || aOptionalArgc > 1,
"Won't check if this is chrome, you want to set "
"aWantsUntrusted to false or make the aWantsUntrusted "
"explicit by making aOptionalArgc non-zero.");
if (aOptionalArgc < 2) {
nsresult rv;
nsIScriptContext* context = GetContextForEventHandlers(&rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> doc =
nsContentUtils::GetDocumentFromScriptContext(context);
aWantsUntrusted = doc && !nsContentUtils::IsChromeDoc(doc);
}
return NS_AddSystemEventListener(this, aType, aListener, aUseCapture,
aWantsUntrusted);
}
NS_IMETHODIMP
nsDOMEventTargetHelper::DispatchEvent(nsIDOMEvent* aEvent, bool* aRetVal)
{

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

@ -904,6 +904,8 @@ nsEventDispatcher::CreateEvent(nsPresContext* aPresContext,
return NS_NewDOMHashChangeEvent(aDOMEvent, aPresContext, nsnull);
if (aEventType.LowerCaseEqualsLiteral("customevent"))
return NS_NewDOMCustomEvent(aDOMEvent, aPresContext, nsnull);
if (aEventType.LowerCaseEqualsLiteral("mozsmsevent"))
return NS_NewDOMSmsEvent(aDOMEvent, aPresContext, nsnull);
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
}

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

@ -701,10 +701,8 @@ nsEventListenerManager::CompileEventHandlerInternal(nsListenerStruct *aListenerS
// Bind it
nsScriptObjectHolder boundHandler(context);
context->BindCompiledEventHandler(mTarget, listener->GetEventScope(),
handler, boundHandler);
listener->SetHandler(
static_cast<JSObject*>(
static_cast<void*>(boundHandler)));
handler.getObject(), boundHandler);
listener->SetHandler(boundHandler.getObject());
}
return result;

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

@ -318,4 +318,26 @@ protected:
static PRUint32 sCreatedCount;
};
/**
* NS_AddSystemEventListener() is a helper function for implementing
* nsIDOMEventTarget::AddSystemEventListener().
*/
inline nsresult
NS_AddSystemEventListener(nsIDOMEventTarget* aTarget,
const nsAString& aType,
nsIDOMEventListener *aListener,
bool aUseCapture,
bool aWantsUntrusted)
{
nsEventListenerManager* listenerManager = aTarget->GetListenerManager(true);
NS_ENSURE_STATE(listenerManager);
PRUint32 flags = NS_EVENT_FLAG_SYSTEM_EVENT;
flags |= aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
if (aWantsUntrusted) {
flags |= NS_PRIV_EVENT_UNTRUSTED_PERMITTED;
}
listenerManager->AddEventListenerByType(aListener, aType, flags);
return NS_OK;
}
#endif // nsEventListenerManager_h__

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

@ -40,7 +40,6 @@
#include "nsIMEStateManager.h"
#include "nsCOMPtr.h"
#include "nsIWidget.h"
#include "nsIViewManager.h"
#include "nsIPresShell.h"
#include "nsISupports.h"
@ -51,6 +50,8 @@
#include "nsIDocument.h"
#include "nsPresContext.h"
#include "nsIDOMWindow.h"
#include "nsIDOMMouseEvent.h"
#include "nsIDOMNSEvent.h"
#include "nsContentUtils.h"
#include "nsINode.h"
#include "nsIFrame.h"
@ -68,6 +69,8 @@
#include "nsIForm.h"
#include "nsHTMLFormElement.h"
using namespace mozilla::widget;
/******************************************************************/
/* nsIMEStateManager */
/******************************************************************/
@ -87,8 +90,10 @@ nsIMEStateManager::OnDestroyPresContext(nsPresContext* aPresContext)
return NS_OK;
nsCOMPtr<nsIWidget> widget = GetWidget(sPresContext);
if (widget) {
PRUint32 newState = GetNewIMEState(sPresContext, nsnull);
SetIMEState(newState, nsnull, widget, IMEContext::FOCUS_REMOVED);
IMEState newState = GetNewIMEState(sPresContext, nsnull);
InputContextAction action(InputContextAction::CAUSE_UNKNOWN,
InputContextAction::LOST_FOCUS);
SetIMEState(newState, nsnull, widget, action);
}
sContent = nsnull;
sPresContext = nsnull;
@ -112,8 +117,10 @@ nsIMEStateManager::OnRemoveContent(nsPresContext* aPresContext,
nsresult rv = widget->CancelIMEComposition();
if (NS_FAILED(rv))
widget->ResetInputState();
PRUint32 newState = GetNewIMEState(sPresContext, nsnull);
SetIMEState(newState, nsnull, widget, IMEContext::FOCUS_REMOVED);
IMEState newState = GetNewIMEState(sPresContext, nsnull);
InputContextAction action(InputContextAction::CAUSE_UNKNOWN,
InputContextAction::LOST_FOCUS);
SetIMEState(newState, nsnull, widget, action);
}
sContent = nsnull;
@ -125,7 +132,16 @@ nsIMEStateManager::OnRemoveContent(nsPresContext* aPresContext,
nsresult
nsIMEStateManager::OnChangeFocus(nsPresContext* aPresContext,
nsIContent* aContent,
PRUint32 aReason)
InputContextAction::Cause aCause)
{
InputContextAction action(aCause);
return OnChangeFocusInternal(aPresContext, aContent, action);
}
nsresult
nsIMEStateManager::OnChangeFocusInternal(nsPresContext* aPresContext,
nsIContent* aContent,
InputContextAction aAction)
{
NS_ENSURE_ARG_POINTER(aPresContext);
@ -157,25 +173,22 @@ nsIMEStateManager::OnChangeFocus(nsPresContext* aPresContext,
}
}
PRUint32 newState = GetNewIMEState(aPresContext, aContent);
IMEState newState = GetNewIMEState(aPresContext, aContent);
if (aPresContext == sPresContext && aContent == sContent) {
// actual focus isn't changing, but if IME enabled state is changing,
// we should do it.
PRUint32 newEnabledState = newState & nsIContent::IME_STATUS_MASK_ENABLED;
if (newEnabledState == 0) {
// the enabled state isn't changing, we should do nothing.
return NS_OK;
}
IMEContext context;
if (!widget || NS_FAILED(widget->GetInputMode(context))) {
// this platform doesn't support IME controlling
return NS_OK;
}
if (context.mStatus ==
nsContentUtils::GetWidgetStatusFromIMEStatus(newEnabledState)) {
InputContext context = widget->GetInputContext();
if (context.mIMEState.mEnabled == newState.mEnabled) {
// the enabled state isn't changing.
return NS_OK;
}
aAction.mFocusChange = InputContextAction::FOCUS_NOT_CHANGED;
} else if (aAction.mFocusChange == InputContextAction::FOCUS_NOT_CHANGED) {
// If aContent isn't null or aContent is null but editable, somebody gets
// focus.
bool gotFocus = aContent || (newState.mEnabled == IMEState::ENABLED);
aAction.mFocusChange =
gotFocus ? InputContextAction::GOT_FOCUS : InputContextAction::LOST_FOCUS;
}
// Current IME transaction should commit
@ -189,10 +202,8 @@ nsIMEStateManager::OnChangeFocus(nsPresContext* aPresContext,
oldWidget->ResetInputState();
}
if (newState != nsIContent::IME_STATUS_NONE) {
// Update IME state for new focus widget
SetIMEState(newState, aContent, widget, aReason);
}
// Update IME state for new focus widget
SetIMEState(newState, aContent, widget, aAction);
sPresContext = aPresContext;
sContent = aContent;
@ -205,19 +216,60 @@ nsIMEStateManager::OnInstalledMenuKeyboardListener(bool aInstalling)
{
sInstalledMenuKeyboardListener = aInstalling;
PRUint32 reason = aInstalling ? IMEContext::FOCUS_MOVED_TO_MENU
: IMEContext::FOCUS_MOVED_FROM_MENU;
OnChangeFocus(sPresContext, sContent, reason);
InputContextAction action(InputContextAction::CAUSE_UNKNOWN,
aInstalling ? InputContextAction::MENU_GOT_PSEUDO_FOCUS :
InputContextAction::MENU_LOST_PSEUDO_FOCUS);
OnChangeFocusInternal(sPresContext, sContent, action);
}
void
nsIMEStateManager::UpdateIMEState(PRUint32 aNewIMEState, nsIContent* aContent)
nsIMEStateManager::OnClickInEditor(nsPresContext* aPresContext,
nsIContent* aContent,
nsIDOMMouseEvent* aMouseEvent)
{
if (sPresContext != aPresContext || sContent != aContent) {
return;
}
nsCOMPtr<nsIWidget> widget = GetWidget(aPresContext);
NS_ENSURE_TRUE(widget, );
bool isTrusted;
nsCOMPtr<nsIDOMNSEvent> NSEvent = do_QueryInterface(aMouseEvent);
nsresult rv = NSEvent->GetIsTrusted(&isTrusted);
NS_ENSURE_SUCCESS(rv, );
if (!isTrusted) {
return; // ignore untrusted event.
}
PRUint16 button;
rv = aMouseEvent->GetButton(&button);
NS_ENSURE_SUCCESS(rv, );
if (button != 0) {
return; // not a left click event.
}
PRInt32 clickCount;
rv = aMouseEvent->GetDetail(&clickCount);
NS_ENSURE_SUCCESS(rv, );
if (clickCount != 1) {
return; // should notify only first click event.
}
InputContextAction action(InputContextAction::CAUSE_MOUSE,
InputContextAction::FOCUS_NOT_CHANGED);
IMEState newState = GetNewIMEState(aPresContext, aContent);
SetIMEState(newState, aContent, widget, action);
}
void
nsIMEStateManager::UpdateIMEState(const IMEState &aNewIMEState,
nsIContent* aContent)
{
if (!sPresContext) {
NS_WARNING("ISM doesn't know which editor has focus");
return;
}
NS_PRECONDITION(aNewIMEState != 0, "aNewIMEState doesn't specify new state.");
nsCOMPtr<nsIWidget> widget = GetWidget(sPresContext);
if (!widget) {
NS_WARNING("focused widget is not found");
@ -225,43 +277,41 @@ nsIMEStateManager::UpdateIMEState(PRUint32 aNewIMEState, nsIContent* aContent)
}
// Don't update IME state when enabled state isn't actually changed.
IMEContext context;
nsresult rv = widget->GetInputMode(context);
if (NS_FAILED(rv)) {
return; // This platform doesn't support controling the IME state.
}
PRUint32 newEnabledState = aNewIMEState & nsIContent::IME_STATUS_MASK_ENABLED;
if (context.mStatus ==
nsContentUtils::GetWidgetStatusFromIMEStatus(newEnabledState)) {
InputContext context = widget->GetInputContext();
if (context.mIMEState.mEnabled == aNewIMEState.mEnabled) {
return;
}
// commit current composition
widget->ResetInputState();
SetIMEState(aNewIMEState, aContent, widget, IMEContext::EDITOR_STATE_MODIFIED);
InputContextAction action(InputContextAction::CAUSE_UNKNOWN,
InputContextAction::FOCUS_NOT_CHANGED);
SetIMEState(aNewIMEState, aContent, widget, action);
}
PRUint32
IMEState
nsIMEStateManager::GetNewIMEState(nsPresContext* aPresContext,
nsIContent* aContent)
{
// On Printing or Print Preview, we don't need IME.
if (aPresContext->Type() == nsPresContext::eContext_PrintPreview ||
aPresContext->Type() == nsPresContext::eContext_Print) {
return nsIContent::IME_STATUS_DISABLE;
return IMEState(IMEState::DISABLED);
}
if (sInstalledMenuKeyboardListener)
return nsIContent::IME_STATUS_DISABLE;
if (sInstalledMenuKeyboardListener) {
return IMEState(IMEState::DISABLED);
}
if (!aContent) {
// Even if there are no focused content, the focused document might be
// editable, such case is design mode.
nsIDocument* doc = aPresContext->Document();
if (doc && doc->HasFlag(NODE_IS_EDITABLE))
return nsIContent::IME_STATUS_ENABLE;
return nsIContent::IME_STATUS_DISABLE;
if (doc && doc->HasFlag(NODE_IS_EDITABLE)) {
return IMEState(IMEState::ENABLED);
}
return IMEState(IMEState::DISABLED);
}
return aContent->GetDesiredIMEState();
@ -290,65 +340,62 @@ private:
};
void
nsIMEStateManager::SetIMEState(PRUint32 aState,
nsIMEStateManager::SetIMEState(const IMEState &aState,
nsIContent* aContent,
nsIWidget* aWidget,
PRUint32 aReason)
InputContextAction aAction)
{
if (aState & nsIContent::IME_STATUS_MASK_ENABLED) {
if (!aWidget)
return;
NS_ENSURE_TRUE(aWidget, );
PRUint32 state = nsContentUtils::GetWidgetStatusFromIMEStatus(aState);
IMEContext context;
context.mStatus = state;
if (aContent && aContent->GetNameSpaceID() == kNameSpaceID_XHTML &&
(aContent->Tag() == nsGkAtoms::input ||
aContent->Tag() == nsGkAtoms::textarea)) {
aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::type,
context.mHTMLInputType);
aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::moz_action_hint,
context.mActionHint);
InputContext oldContext = aWidget->GetInputContext();
// if we don't have an action hint and return won't submit the form use "next"
if (context.mActionHint.IsEmpty() && aContent->Tag() == nsGkAtoms::input) {
bool willSubmit = false;
nsCOMPtr<nsIFormControl> control(do_QueryInterface(aContent));
mozilla::dom::Element* formElement = control->GetFormElement();
nsCOMPtr<nsIForm> form;
if (control) {
// is this a form and does it have a default submit element?
if ((form = do_QueryInterface(formElement)) && form->GetDefaultSubmitElement()) {
willSubmit = true;
// is this an html form and does it only have a single text input element?
} else if (formElement && formElement->Tag() == nsGkAtoms::form && formElement->IsHTML() &&
static_cast<nsHTMLFormElement*>(formElement)->HasSingleTextControl()) {
willSubmit = true;
}
InputContext context;
context.mIMEState = aState;
if (aContent && aContent->GetNameSpaceID() == kNameSpaceID_XHTML &&
(aContent->Tag() == nsGkAtoms::input ||
aContent->Tag() == nsGkAtoms::textarea)) {
aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::type,
context.mHTMLInputType);
aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::moz_action_hint,
context.mActionHint);
// if we don't have an action hint and return won't submit the form use "next"
if (context.mActionHint.IsEmpty() && aContent->Tag() == nsGkAtoms::input) {
bool willSubmit = false;
nsCOMPtr<nsIFormControl> control(do_QueryInterface(aContent));
mozilla::dom::Element* formElement = control->GetFormElement();
nsCOMPtr<nsIForm> form;
if (control) {
// is this a form and does it have a default submit element?
if ((form = do_QueryInterface(formElement)) && form->GetDefaultSubmitElement()) {
willSubmit = true;
// is this an html form and does it only have a single text input element?
} else if (formElement && formElement->Tag() == nsGkAtoms::form && formElement->IsHTML() &&
static_cast<nsHTMLFormElement*>(formElement)->HasSingleTextControl()) {
willSubmit = true;
}
context.mActionHint.Assign(willSubmit ? control->GetType() == NS_FORM_INPUT_SEARCH
? NS_LITERAL_STRING("search")
: NS_LITERAL_STRING("go")
: formElement
? NS_LITERAL_STRING("next")
: EmptyString());
}
context.mActionHint.Assign(willSubmit ? control->GetType() == NS_FORM_INPUT_SEARCH
? NS_LITERAL_STRING("search")
: NS_LITERAL_STRING("go")
: formElement
? NS_LITERAL_STRING("next")
: EmptyString());
}
if (XRE_GetProcessType() == GeckoProcessType_Content) {
context.mReason = aReason | IMEContext::FOCUS_FROM_CONTENT_PROCESS;
} else {
context.mReason = aReason;
}
aWidget->SetInputMode(context);
nsContentUtils::AddScriptRunner(new IMEEnabledStateChangedEvent(state));
}
if (aState & nsIContent::IME_STATUS_MASK_OPENED) {
bool open = !!(aState & nsIContent::IME_STATUS_OPEN);
aWidget->SetIMEOpenState(open);
// XXX I think that we should use nsContentUtils::IsCallerChrome() instead
// of the process type.
if (aAction.mCause == InputContextAction::CAUSE_UNKNOWN &&
XRE_GetProcessType() != GeckoProcessType_Content) {
aAction.mCause = InputContextAction::CAUSE_UNKNOWN_CHROME;
}
aWidget->SetInputContext(context, aAction);
if (oldContext.mIMEState.mEnabled != context.mIMEState.mEnabled) {
nsContentUtils::AddScriptRunner(
new IMEEnabledStateChangedEvent(context.mIMEState.mEnabled));
}
}

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

@ -40,11 +40,12 @@
#define nsIMEStateManager_h__
#include "nscore.h"
#include "nsIWidget.h"
class nsIContent;
class nsIDOMMouseEvent;
class nsPIDOMWindow;
class nsPresContext;
class nsIWidget;
class nsTextStateManager;
class nsISelection;
@ -54,13 +55,23 @@ class nsISelection;
class nsIMEStateManager
{
protected:
typedef mozilla::widget::IMEState IMEState;
typedef mozilla::widget::InputContext InputContext;
typedef mozilla::widget::InputContextAction InputContextAction;
public:
static nsresult OnDestroyPresContext(nsPresContext* aPresContext);
static nsresult OnRemoveContent(nsPresContext* aPresContext,
nsIContent* aContent);
/**
* OnChangeFocus() should be called when focused content is changed or
* IME enabled state is changed. If focus isn't actually changed and IME
* enabled state isn't changed, this will do nothing.
*/
static nsresult OnChangeFocus(nsPresContext* aPresContext,
nsIContent* aContent,
PRUint32 aReason);
InputContextAction::Cause aCause);
static void OnInstalledMenuKeyboardListener(bool aInstalling);
// These two methods manage focus and selection/text observers.
@ -85,14 +96,27 @@ public:
// isn't changed by the new state, this method does nothing.
// Note that this method changes the IME state of the active element in the
// widget. So, the caller must have focus.
// aNewIMEState must have an enabled state of nsIContent::IME_STATUS_*.
// And optionally, it can have an open state of nsIContent::IME_STATUS_*.
static void UpdateIMEState(PRUint32 aNewIMEState, nsIContent* aContent);
static void UpdateIMEState(const IMEState &aNewIMEState,
nsIContent* aContent);
// This method is called when user clicked in an editor.
// aContent must be:
// If the editor is for <input> or <textarea>, the element.
// If the editor is for contenteditable, the active editinghost.
// If the editor is for designMode, NULL.
static void OnClickInEditor(nsPresContext* aPresContext,
nsIContent* aContent,
nsIDOMMouseEvent* aMouseEvent);
protected:
static void SetIMEState(PRUint32 aState, nsIContent* aContent,
nsIWidget* aWidget, PRUint32 aReason);
static PRUint32 GetNewIMEState(nsPresContext* aPresContext,
static nsresult OnChangeFocusInternal(nsPresContext* aPresContext,
nsIContent* aContent,
InputContextAction aAction);
static void SetIMEState(const IMEState &aState,
nsIContent* aContent,
nsIWidget* aWidget,
InputContextAction aAction);
static IMEState GetNewIMEState(nsPresContext* aPresContext,
nsIContent* aContent);
static nsIWidget* GetWidget(nsPresContext* aPresContext);

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

@ -370,21 +370,38 @@ protected:
/**
* Initialize a decoder as a clone of an existing decoder in another
* element.
* mLoadingSrc must already be set.
*/
nsresult InitializeDecoderAsClone(nsMediaDecoder* aOriginal);
/**
* Initialize a decoder to load the given channel. The decoder's stream
* listener is returned via aListener.
* mLoadingSrc must already be set.
*/
nsresult InitializeDecoderForChannel(nsIChannel *aChannel,
nsIStreamListener **aListener);
/**
* Finish setting up the decoder after Load() has been called on it.
* Called by InitializeDecoderForChannel/InitializeDecoderAsClone.
*/
nsresult FinishDecoderSetup(nsMediaDecoder* aDecoder);
/**
* Call this after setting up mLoadingSrc and mDecoder.
*/
void AddMediaElementToURITable();
/**
* Call this before clearing mLoadingSrc.
*/
void RemoveMediaElementFromURITable();
/**
* Call this to find a media element with the same NodePrincipal and mLoadingSrc
* set to aURI, and with a decoder on which Load() has been called.
*/
nsHTMLMediaElement* LookupMediaElementURITable(nsIURI* aURI);
/**
* Execute the initial steps of the load algorithm that ensure existing
* loads are aborted, the element is emptied, and a new load ID is
@ -431,7 +448,7 @@ protected:
/**
* The resource-fetch algorithm step of the load algorithm.
*/
nsresult LoadResource(nsIURI* aURI);
nsresult LoadResource();
/**
* Selects the next <source> child from which to load a resource. Called
@ -492,11 +509,11 @@ protected:
};
/**
* Suspends the load of resource at aURI, so that it can be resumed later
* Suspends the load of mLoadingSrc, so that it can be resumed later
* by ResumeLoad(). This is called when we have a media with a 'preload'
* attribute value of 'none', during the resource selection algorithm.
*/
void SuspendLoad(nsIURI* aURI);
void SuspendLoad();
/**
* Resumes a previously suspended load (suspended by SuspendLoad(uri)).
@ -535,6 +552,7 @@ protected:
*/
void ProcessMediaFragmentURI();
// The current decoder. Load() has been called on this decoder.
nsRefPtr<nsMediaDecoder> mDecoder;
// A reference to the ImageContainer which contains the current frame
@ -597,11 +615,11 @@ protected:
// Current audio sample rate.
PRUint32 mRate;
// URI of the resource we're attempting to load. When the decoder is
// successfully initialized, we rely on it to record the URI we're playing,
// and clear mLoadingSrc. This stores the value we return in the currentSrc
// attribute until the decoder is initialized. Use GetCurrentSrc() to access
// the currentSrc attribute.
// URI of the resource we're attempting to load. This stores the value we
// return in the currentSrc attribute. Use GetCurrentSrc() to access the
// currentSrc attribute.
// This is always the original URL we're trying to load --- before
// redirects etc.
nsCOMPtr<nsIURI> mLoadingSrc;
// Stores the current preload action for this element. Initially set to

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

@ -71,6 +71,7 @@
#include "nsIScrollableFrame.h"
#include "nsIView.h"
#include "nsIViewManager.h"
#include "nsIWidget.h"
#include "nsRange.h"
#include "nsIPresShell.h"
#include "nsPresContext.h"
@ -2652,7 +2653,7 @@ nsGenericHTMLFormElement::GetForm(nsIDOMHTMLFormElement** aForm)
return NS_OK;
}
PRUint32
nsIContent::IMEState
nsGenericHTMLFormElement::GetDesiredIMEState()
{
nsCOMPtr<nsIEditor> editor = nsnull;
@ -2662,7 +2663,7 @@ nsGenericHTMLFormElement::GetDesiredIMEState()
nsCOMPtr<nsIEditorIMESupport> imeEditor = do_QueryInterface(editor);
if (!imeEditor)
return nsGenericHTMLElement::GetDesiredIMEState();
PRUint32 state;
IMEState state;
rv = imeEditor->GetPreferredIMEState(&state);
if (NS_FAILED(rv))
return nsGenericHTMLElement::GetDesiredIMEState();

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

@ -884,7 +884,7 @@ public:
bool aCompileEventHandlers);
virtual void UnbindFromTree(bool aDeep = true,
bool aNullParent = true);
virtual PRUint32 GetDesiredIMEState();
virtual IMEState GetDesiredIMEState();
virtual nsEventStates IntrinsicState() const;
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);

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

@ -506,14 +506,14 @@ nsHTMLCanvasElement::GetContext(const nsAString& aContextId,
jsid propid = JS_IdArrayGet(cx, props, i);
jsval propname, propval;
if (!JS_IdToValue(cx, propid, &propname) ||
!JS_GetPropertyById(cx, opts, propid, &propval))
{
!JS_GetPropertyById(cx, opts, propid, &propval)) {
continue;
}
JSString *propnameString = JS_ValueToString(cx, propname);
nsDependentJSString pstr;
if (!propnameString || !pstr.init(cx, propnameString)) {
JS_DestroyIdArray(cx, props);
mCurrentContext = nsnull;
return NS_ERROR_FAILURE;
}
@ -528,6 +528,7 @@ nsHTMLCanvasElement::GetContext(const nsAString& aContextId,
JSString *propvalString = JS_ValueToString(cx, propval);
nsDependentJSString vstr;
if (!propvalString || !vstr.init(cx, propvalString)) {
JS_DestroyIdArray(cx, props);
mCurrentContext = nsnull;
return NS_ERROR_FAILURE;
}
@ -535,6 +536,7 @@ nsHTMLCanvasElement::GetContext(const nsAString& aContextId,
contextProps->SetPropertyAsAString(pstr, vstr);
}
}
JS_DestroyIdArray(cx, props);
}
}

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

@ -89,6 +89,7 @@
#include "nsIPrivateDOMEvent.h"
#include "nsIDOMNotifyAudioAvailableEvent.h"
#include "nsMediaFragmentURIParser.h"
#include "nsURIHashKey.h"
#ifdef MOZ_OGG
#include "nsOggDecoder.h"
@ -479,11 +480,14 @@ void nsHTMLMediaElement::AbortExistingLoads()
mCurrentLoadID++;
bool fireTimeUpdate = false;
if (mDecoder) {
RemoveMediaElementFromURITable();
fireTimeUpdate = mDecoder->GetCurrentTime() != 0.0;
mDecoder->Shutdown();
mDecoder = nsnull;
}
mLoadingSrc = nsnull;
if (mNetworkState == nsIDOMHTMLMediaElement::NETWORK_LOADING ||
mNetworkState == nsIDOMHTMLMediaElement::NETWORK_IDLE)
@ -497,6 +501,7 @@ void nsHTMLMediaElement::AbortExistingLoads()
mIsLoadingFromSourceChildren = false;
mSuspendedAfterFirstFrame = false;
mAllowSuspendAfterFirstFrame = true;
mLoadIsSuspended = false;
mSourcePointer = nsnull;
// TODO: The playback rate must be set to the default playback rate.
@ -648,12 +653,12 @@ void nsHTMLMediaElement::SelectResource()
if (mPreloadAction == nsHTMLMediaElement::PRELOAD_NONE) {
// preload:none media, suspend the load here before we make any
// network requests.
SuspendLoad(uri);
SuspendLoad();
mIsRunningSelectResource = false;
return;
}
rv = LoadResource(uri);
rv = LoadResource();
if (NS_SUCCEEDED(rv)) {
mIsRunningSelectResource = false;
return;
@ -750,11 +755,11 @@ void nsHTMLMediaElement::LoadFromSourceChildren()
if (mPreloadAction == nsHTMLMediaElement::PRELOAD_NONE) {
// preload:none media, suspend the load here before we make any
// network requests.
SuspendLoad(uri);
SuspendLoad();
return;
}
if (NS_SUCCEEDED(LoadResource(uri))) {
if (NS_SUCCEEDED(LoadResource())) {
return;
}
@ -764,7 +769,7 @@ void nsHTMLMediaElement::LoadFromSourceChildren()
NS_NOTREACHED("Execution should not reach here!");
}
void nsHTMLMediaElement::SuspendLoad(nsIURI* aURI)
void nsHTMLMediaElement::SuspendLoad()
{
mLoadIsSuspended = true;
mNetworkState = nsIDOMHTMLMediaElement::NETWORK_IDLE;
@ -775,20 +780,19 @@ void nsHTMLMediaElement::SuspendLoad(nsIURI* aURI)
void nsHTMLMediaElement::ResumeLoad(PreloadAction aAction)
{
NS_ASSERTION(mLoadIsSuspended, "Can only resume preload if halted for one");
nsCOMPtr<nsIURI> uri = mLoadingSrc;
mLoadIsSuspended = false;
mPreloadAction = aAction;
ChangeDelayLoadStatus(true);
mNetworkState = nsIDOMHTMLMediaElement::NETWORK_LOADING;
if (!mIsLoadingFromSourceChildren) {
// We were loading from the element's src attribute.
if (NS_FAILED(LoadResource(uri))) {
if (NS_FAILED(LoadResource())) {
NoSupportedMediaSourceError();
}
} else {
// We were loading from a child <source> element. Try to resume the
// load of that child, and if that fails, try the next child.
if (NS_FAILED(LoadResource(uri))) {
if (NS_FAILED(LoadResource())) {
LoadFromSourceChildren();
}
}
@ -873,7 +877,7 @@ void nsHTMLMediaElement::UpdatePreloadAction()
}
}
nsresult nsHTMLMediaElement::LoadResource(nsIURI* aURI)
nsresult nsHTMLMediaElement::LoadResource()
{
NS_ASSERTION(mDelayingLoadEvent,
"Should delay load event (if in document) during load");
@ -890,9 +894,17 @@ nsresult nsHTMLMediaElement::LoadResource(nsIURI* aURI)
mChannel = nsnull;
}
nsHTMLMediaElement* other = LookupMediaElementURITable(mLoadingSrc);
if (other) {
// Clone it.
nsresult rv = InitializeDecoderAsClone(other->mDecoder);
if (NS_SUCCEEDED(rv))
return rv;
}
PRInt16 shouldLoad = nsIContentPolicy::ACCEPT;
nsresult rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_MEDIA,
aURI,
mLoadingSrc,
NodePrincipal(),
static_cast<nsGenericElement*>(this),
EmptyCString(), // mime type
@ -920,7 +932,7 @@ nsresult nsHTMLMediaElement::LoadResource(nsIURI* aURI)
}
nsCOMPtr<nsIChannel> channel;
rv = NS_NewChannel(getter_AddRefs(channel),
aURI,
mLoadingSrc,
nsnull,
loadGroup,
nsnull,
@ -949,7 +961,7 @@ nsresult nsHTMLMediaElement::LoadResource(nsIURI* aURI)
} else {
rv = nsContentUtils::GetSecurityManager()->
CheckLoadURIWithPrincipal(NodePrincipal(),
aURI,
mLoadingSrc,
nsIScriptSecurityManager::STANDARD);
listener = loadListener;
}
@ -991,9 +1003,11 @@ nsresult nsHTMLMediaElement::LoadWithChannel(nsIChannel *aChannel,
AbortExistingLoads();
ChangeDelayLoadStatus(true);
nsresult rv = aChannel->GetOriginalURI(getter_AddRefs(mLoadingSrc));
NS_ENSURE_SUCCESS(rv, rv);
nsresult rv = InitializeDecoderForChannel(aChannel, aListener);
ChangeDelayLoadStatus(true);
rv = InitializeDecoderForChannel(aChannel, aListener);
if (NS_FAILED(rv)) {
ChangeDelayLoadStatus(false);
return rv;
@ -1017,6 +1031,7 @@ NS_IMETHODIMP nsHTMLMediaElement::MozLoadFrom(nsIDOMHTMLMediaElement* aOther)
ChangeDelayLoadStatus(true);
mLoadingSrc = other->mLoadingSrc;
nsresult rv = InitializeDecoderAsClone(other->mDecoder);
if (NS_FAILED(rv)) {
ChangeDelayLoadStatus(false);
@ -1241,6 +1256,76 @@ NS_IMETHODIMP nsHTMLMediaElement::SetMuted(bool aMuted)
return NS_OK;
}
class MediaElementSetForURI : public nsURIHashKey {
public:
MediaElementSetForURI(const nsIURI* aKey) : nsURIHashKey(aKey) {}
MediaElementSetForURI(const MediaElementSetForURI& toCopy)
: nsURIHashKey(toCopy), mElements(toCopy.mElements) {}
nsTArray<nsHTMLMediaElement*> mElements;
};
typedef nsTHashtable<MediaElementSetForURI> MediaElementURITable;
// Elements in this table must have non-null mDecoder and mLoadingSrc, and those
// can't change while the element is in the table. The table is keyed by
// the element's mLoadingSrc. Each entry has a list of all elements with the
// same mLoadingSrc.
static MediaElementURITable* gElementTable;
void
nsHTMLMediaElement::AddMediaElementToURITable()
{
NS_ASSERTION(mDecoder && mDecoder->GetStream(), "Call this only with decoder Load called");
if (!gElementTable) {
gElementTable = new MediaElementURITable();
gElementTable->Init();
}
MediaElementSetForURI* entry = gElementTable->PutEntry(mLoadingSrc);
entry->mElements.AppendElement(this);
}
void
nsHTMLMediaElement::RemoveMediaElementFromURITable()
{
NS_ASSERTION(mDecoder, "Don't call this without decoder!");
NS_ASSERTION(mLoadingSrc, "Can't have decoder without source!");
if (!gElementTable)
return;
MediaElementSetForURI* entry = gElementTable->GetEntry(mLoadingSrc);
if (!entry)
return;
entry->mElements.RemoveElement(this);
if (entry->mElements.IsEmpty()) {
gElementTable->RemoveEntry(mLoadingSrc);
if (gElementTable->Count() == 0) {
delete gElementTable;
gElementTable = nsnull;
}
}
}
nsHTMLMediaElement*
nsHTMLMediaElement::LookupMediaElementURITable(nsIURI* aURI)
{
if (!gElementTable)
return nsnull;
MediaElementSetForURI* entry = gElementTable->GetEntry(aURI);
if (!entry)
return nsnull;
for (PRUint32 i = 0; i < entry->mElements.Length(); ++i) {
nsHTMLMediaElement* elem = entry->mElements[i];
bool equal;
// Look for elements that have the same principal.
// XXX when we implement crossorigin for video, we'll also need to check
// for the same crossorigin mode here. Ditto for anything else that could
// cause us to send different headers.
if (NS_SUCCEEDED(elem->NodePrincipal()->Equals(NodePrincipal(), &equal)) && equal) {
NS_ASSERTION(elem->mDecoder && elem->mDecoder->GetStream(), "Decoder gone");
return elem;
}
}
return nsnull;
}
nsHTMLMediaElement::nsHTMLMediaElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: nsGenericHTMLElement(aNodeInfo),
mCurrentLoadID(0),
@ -1297,16 +1382,14 @@ nsHTMLMediaElement::~nsHTMLMediaElement()
UnregisterFreezableElement();
if (mDecoder) {
RemoveMediaElementFromURITable();
mDecoder->Shutdown();
mDecoder = nsnull;
}
if (mChannel) {
mChannel->Cancel(NS_BINDING_ABORTED);
mChannel = nsnull;
}
if (mAudioStream) {
mAudioStream->Shutdown();
mAudioStream = nsnull;
}
}
@ -1347,9 +1430,13 @@ NS_IMETHODIMP nsHTMLMediaElement::Play()
if (mNetworkState == nsIDOMHTMLMediaElement::NETWORK_EMPTY) {
nsresult rv = Load();
NS_ENSURE_SUCCESS(rv, rv);
} else if (mLoadIsSuspended) {
}
if (mLoadIsSuspended) {
ResumeLoad(PRELOAD_ENOUGH);
} else if (mDecoder) {
}
// Even if we just did Load() or ResumeLoad(), we could already have a decoder
// here if we managed to clone an existing decoder.
if (mDecoder) {
if (mDecoder->IsEnded()) {
SetCurrentTime(0);
}
@ -1811,7 +1898,9 @@ nsHTMLMediaElement::CreateDecoder(const nsACString& aType)
nsresult nsHTMLMediaElement::InitializeDecoderAsClone(nsMediaDecoder* aOriginal)
{
nsMediaStream* originalStream = aOriginal->GetCurrentStream();
NS_ASSERTION(mLoadingSrc, "mLoadingSrc must already be set");
nsMediaStream* originalStream = aOriginal->GetStream();
if (!originalStream)
return NS_ERROR_FAILURE;
nsRefPtr<nsMediaDecoder> decoder = aOriginal->Clone();
@ -1848,6 +1937,8 @@ nsresult nsHTMLMediaElement::InitializeDecoderAsClone(nsMediaDecoder* aOriginal)
nsresult nsHTMLMediaElement::InitializeDecoderForChannel(nsIChannel *aChannel,
nsIStreamListener **aListener)
{
NS_ASSERTION(mLoadingSrc, "mLoadingSrc must already be set");
nsCAutoString mimeType;
aChannel->GetContentType(mimeType);
@ -1878,10 +1969,10 @@ nsresult nsHTMLMediaElement::InitializeDecoderForChannel(nsIChannel *aChannel,
nsresult nsHTMLMediaElement::FinishDecoderSetup(nsMediaDecoder* aDecoder)
{
mDecoder = aDecoder;
NS_ASSERTION(mLoadingSrc, "mLoadingSrc set up");
// Decoder has assumed ownership responsibility for remembering the URI.
mLoadingSrc = nsnull;
mDecoder = aDecoder;
AddMediaElementToURITable();
// Force a same-origin check before allowing events for this media resource.
mMediaSecurityVerified = false;
@ -2019,9 +2110,11 @@ void nsHTMLMediaElement::NetworkError()
void nsHTMLMediaElement::DecodeError()
{
if (mDecoder) {
RemoveMediaElementFromURITable();
mDecoder->Shutdown();
mDecoder = nsnull;
}
mLoadingSrc = nsnull;
if (mIsLoadingFromSourceChildren) {
mError = nsnull;
if (mSourceLoadCandidate) {
@ -2669,13 +2762,10 @@ void nsHTMLMediaElement::FireTimeUpdate(bool aPeriodic)
void nsHTMLMediaElement::GetCurrentSpec(nsCString& aString)
{
if (mDecoder) {
nsMediaStream* stream = mDecoder->GetCurrentStream();
if (stream) {
stream->URI()->GetSpec(aString);
}
} else if (mLoadingSrc) {
if (mLoadingSrc) {
mLoadingSrc->GetSpec(aString);
} else {
aString.Truncate();
}
}

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

@ -52,6 +52,7 @@
#include "nsIObjectFrame.h"
#include "nsNPAPIPluginInstance.h"
#include "nsIConstraintValidation.h"
#include "nsIWidget.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -116,7 +117,7 @@ public:
bool aNotify);
virtual bool IsHTMLFocusable(bool aWithMouse, bool *aIsFocusable, PRInt32 *aTabIndex);
virtual PRUint32 GetDesiredIMEState();
virtual IMEState GetDesiredIMEState();
// Overriden nsIFormControl methods
NS_IMETHOD_(PRUint32) GetType() const
@ -376,11 +377,11 @@ nsHTMLObjectElement::IsHTMLFocusable(bool aWithMouse,
return false;
}
PRUint32
nsIContent::IMEState
nsHTMLObjectElement::GetDesiredIMEState()
{
if (Type() == eType_Plugin) {
return nsIContent::IME_STATUS_PLUGIN;
return IMEState(IMEState::PLUGIN);
}
return nsGenericHTMLFormElement::GetDesiredIMEState();

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

@ -50,6 +50,7 @@
#include "nsIDOMGetSVGDocument.h"
#include "nsIDOMSVGDocument.h"
#include "nsIScriptError.h"
#include "nsIWidget.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -119,7 +120,7 @@ public:
bool aNotify);
virtual bool IsHTMLFocusable(bool aWithMouse, bool *aIsFocusable, PRInt32 *aTabIndex);
virtual PRUint32 GetDesiredIMEState();
virtual IMEState GetDesiredIMEState();
virtual void DoneAddingChildren(bool aHaveNotified);
virtual bool IsDoneAddingChildren();
@ -365,11 +366,11 @@ nsHTMLSharedObjectElement::IsHTMLFocusable(bool aWithMouse,
return nsGenericHTMLElement::IsHTMLFocusable(aWithMouse, aIsFocusable, aTabIndex);
}
PRUint32
nsIContent::IMEState
nsHTMLSharedObjectElement::GetDesiredIMEState()
{
if (Type() == eType_Plugin) {
return nsIContent::IME_STATUS_PLUGIN;
return IMEState(IMEState::PLUGIN);
}
return nsGenericHTMLElement::GetDesiredIMEState();

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

@ -377,7 +377,7 @@ double nsBuiltinDecoder::GetCurrentTime()
return mCurrentTime;
}
nsMediaStream* nsBuiltinDecoder::GetCurrentStream()
nsMediaStream* nsBuiltinDecoder::GetStream()
{
return mStream;
}

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

@ -405,7 +405,7 @@ class nsBuiltinDecoder : public nsMediaDecoder
virtual void SetInfinite(bool aInfinite);
virtual bool IsInfinite();
virtual nsMediaStream* GetCurrentStream();
virtual nsMediaStream* GetStream();
virtual already_AddRefed<nsIPrincipal> GetCurrentPrincipal();
virtual void NotifySuspendedStatusChanged();

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

@ -1571,7 +1571,7 @@ nsresult nsBuiltinDecoderStateMachine::RunStateMachine()
{
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
nsMediaStream* stream = mDecoder->GetCurrentStream();
nsMediaStream* stream = mDecoder->GetStream();
NS_ENSURE_TRUE(stream, NS_ERROR_NULL_POINTER);
switch (mState) {
@ -1652,7 +1652,7 @@ nsresult nsBuiltinDecoderStateMachine::RunStateMachine()
// data to begin playback, or if we've not downloaded a reasonable
// amount of data inside our buffering time.
TimeDuration elapsed = now - mBufferingStart;
bool isLiveStream = mDecoder->GetCurrentStream()->GetLength() == -1;
bool isLiveStream = mDecoder->GetStream()->GetLength() == -1;
if ((isLiveStream || !mDecoder->CanPlayThrough()) &&
elapsed < TimeDuration::FromSeconds(mBufferingWait) &&
(mQuickBuffering ? HasLowDecodedData(QUICK_BUFFERING_LOW_DATA_USECS)
@ -1850,7 +1850,7 @@ void nsBuiltinDecoderStateMachine::AdvanceFrame()
// Check to see if we don't have enough data to play up to the next frame.
// If we don't, switch to buffering mode.
nsMediaStream* stream = mDecoder->GetCurrentStream();
nsMediaStream* stream = mDecoder->GetStream();
if (mState == DECODER_STATE_DECODING &&
mDecoder->GetState() == nsBuiltinDecoder::PLAY_STATE_PLAYING &&
HasLowDecodedData(remainingTime + EXHAUSTED_DATA_MARGIN_USECS) &&
@ -2028,7 +2028,7 @@ void nsBuiltinDecoderStateMachine::StartBuffering()
}
nsresult nsBuiltinDecoderStateMachine::GetBuffered(nsTimeRanges* aBuffered) {
nsMediaStream* stream = mDecoder->GetCurrentStream();
nsMediaStream* stream = mDecoder->GetStream();
NS_ENSURE_TRUE(stream, NS_ERROR_FAILURE);
stream->Pin();
nsresult res = mReader->GetBuffered(aBuffered, mStartTime);

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

@ -261,7 +261,7 @@ double nsMediaDecoder::GetFrameDelay()
void nsMediaDecoder::PinForSeek()
{
nsMediaStream* stream = GetCurrentStream();
nsMediaStream* stream = GetStream();
if (!stream || mPinnedForSeek) {
return;
}
@ -271,7 +271,7 @@ void nsMediaDecoder::PinForSeek()
void nsMediaDecoder::UnpinForSeek()
{
nsMediaStream* stream = GetCurrentStream();
nsMediaStream* stream = GetStream();
if (!stream || !mPinnedForSeek) {
return;
}

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

@ -91,8 +91,8 @@ public:
virtual bool Init(nsHTMLMediaElement* aElement);
// Get the current nsMediaStream being used. Its URI will be returned
// by currentSrc.
virtual nsMediaStream* GetCurrentStream() = 0;
// by currentSrc. Returns what was passed to Load(), if Load() has been called.
virtual nsMediaStream* GetStream() = 0;
// Return the principal of the current URI being played or downloaded.
virtual already_AddRefed<nsIPrincipal> GetCurrentPrincipal() = 0;

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

@ -169,7 +169,7 @@ public:
// The following can be called on the main thread only:
// Get the URI
nsIURI* URI() { return mURI; }
nsIURI* URI() const { return mURI; }
// Close the stream, stop any listeners, channels, etc.
// Cancels any currently blocking Read request and forces that request to
// return an error.

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

@ -315,7 +315,7 @@ nsresult nsOggReader::ReadMetadata(nsVideoInfo* aInfo)
{
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
nsMediaStream* stream = mDecoder->GetCurrentStream();
nsMediaStream* stream = mDecoder->GetStream();
if (mDecoder->GetStateMachine()->GetDuration() == -1 &&
mDecoder->GetStateMachine()->GetState() != nsDecoderStateMachine::DECODER_STATE_SHUTDOWN &&
stream->GetLength() >= 0 &&
@ -552,7 +552,7 @@ PRInt64 nsOggReader::ReadOggPage(ogg_page* aPage)
// Read from the stream into the buffer
PRUint32 bytesRead = 0;
nsresult rv = mDecoder->GetCurrentStream()->Read(buffer, 4096, &bytesRead);
nsresult rv = mDecoder->GetStream()->Read(buffer, 4096, &bytesRead);
if (NS_FAILED(rv) || (bytesRead == 0 && ret == 0)) {
// End of file.
return -1;
@ -616,7 +616,7 @@ GetChecksum(ogg_page* page)
PRInt64 nsOggReader::RangeStartTime(PRInt64 aOffset)
{
NS_ASSERTION(mDecoder->OnDecodeThread(), "Should be on decode thread.");
nsMediaStream* stream = mDecoder->GetCurrentStream();
nsMediaStream* stream = mDecoder->GetStream();
NS_ENSURE_TRUE(stream != nsnull, nsnull);
nsresult res = stream->Seek(nsISeekableStream::NS_SEEK_SET, aOffset);
NS_ENSURE_SUCCESS(res, nsnull);
@ -640,7 +640,7 @@ PRInt64 nsOggReader::RangeEndTime(PRInt64 aEndOffset)
NS_ASSERTION(mDecoder->OnStateMachineThread() || mDecoder->OnDecodeThread(),
"Should be on state machine or decode thread.");
nsMediaStream* stream = mDecoder->GetCurrentStream();
nsMediaStream* stream = mDecoder->GetStream();
NS_ENSURE_TRUE(stream != nsnull, -1);
PRInt64 position = stream->Tell();
PRInt64 endTime = RangeEndTime(0, aEndOffset, false);
@ -653,7 +653,7 @@ PRInt64 nsOggReader::RangeEndTime(PRInt64 aStartOffset,
PRInt64 aEndOffset,
bool aCachedDataOnly)
{
nsMediaStream* stream = mDecoder->GetCurrentStream();
nsMediaStream* stream = mDecoder->GetStream();
nsAutoOggSyncState sync;
// We need to find the last page which ends before aEndOffset that
@ -770,7 +770,7 @@ nsresult nsOggReader::GetSeekRanges(nsTArray<SeekRange>& aRanges)
{
NS_ASSERTION(mDecoder->OnDecodeThread(), "Should be on decode thread.");
nsTArray<nsByteRange> cached;
nsresult res = mDecoder->GetCurrentStream()->GetCachedRanges(cached);
nsresult res = mDecoder->GetStream()->GetCachedRanges(cached);
NS_ENSURE_SUCCESS(res, res);
for (PRUint32 index = 0; index < cached.Length(); index++) {
@ -809,7 +809,7 @@ nsOggReader::SelectSeekRange(const nsTArray<SeekRange>& ranges,
{
NS_ASSERTION(mDecoder->OnDecodeThread(), "Should be on decode thread.");
PRInt64 so = 0;
PRInt64 eo = mDecoder->GetCurrentStream()->GetLength();
PRInt64 eo = mDecoder->GetStream()->GetLength();
PRInt64 st = aStartTime;
PRInt64 et = aEndTime;
for (PRUint32 i = 0; i < ranges.Length(); i++) {
@ -837,7 +837,7 @@ nsOggReader::SelectSeekRange(const nsTArray<SeekRange>& ranges,
nsOggReader::IndexedSeekResult nsOggReader::RollbackIndexedSeek(PRInt64 aOffset)
{
mSkeletonState->Deactivate();
nsMediaStream* stream = mDecoder->GetCurrentStream();
nsMediaStream* stream = mDecoder->GetStream();
NS_ENSURE_TRUE(stream != nsnull, SEEK_FATAL_ERROR);
nsresult res = stream->Seek(nsISeekableStream::NS_SEEK_SET, aOffset);
NS_ENSURE_SUCCESS(res, SEEK_FATAL_ERROR);
@ -846,7 +846,7 @@ nsOggReader::IndexedSeekResult nsOggReader::RollbackIndexedSeek(PRInt64 aOffset)
nsOggReader::IndexedSeekResult nsOggReader::SeekToKeyframeUsingIndex(PRInt64 aTarget)
{
nsMediaStream* stream = mDecoder->GetCurrentStream();
nsMediaStream* stream = mDecoder->GetStream();
NS_ENSURE_TRUE(stream != nsnull, SEEK_FATAL_ERROR);
if (!HasSkeleton() || !mSkeletonState->HasIndex()) {
return SEEK_INDEX_FAIL;
@ -1014,7 +1014,7 @@ nsresult nsOggReader::Seek(PRInt64 aTarget,
NS_ASSERTION(mDecoder->OnDecodeThread(), "Should be on decode thread.");
LOG(PR_LOG_DEBUG, ("%p About to seek to %lld", mDecoder, aTarget));
nsresult res;
nsMediaStream* stream = mDecoder->GetCurrentStream();
nsMediaStream* stream = mDecoder->GetStream();
NS_ENSURE_TRUE(stream != nsnull, NS_ERROR_FAILURE);
if (aTarget == aStartTime) {
@ -1139,7 +1139,7 @@ nsresult nsOggReader::SeekBisection(PRInt64 aTarget,
{
NS_ASSERTION(mDecoder->OnDecodeThread(), "Should be on decode thread.");
nsresult res;
nsMediaStream* stream = mDecoder->GetCurrentStream();
nsMediaStream* stream = mDecoder->GetStream();
if (aTarget == aRange.mTimeStart) {
if (NS_FAILED(ResetDecode())) {
@ -1407,7 +1407,7 @@ nsresult nsOggReader::GetBuffered(nsTimeRanges* aBuffered, PRInt64 aStartTime)
return NS_OK;
}
nsMediaStream* stream = mDecoder->GetCurrentStream();
nsMediaStream* stream = mDecoder->GetStream();
nsTArray<nsByteRange> ranges;
nsresult res = stream->GetCachedRanges(ranges);
NS_ENSURE_SUCCESS(res, res);

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

@ -71,7 +71,7 @@ nsresult nsRawReader::ReadMetadata(nsVideoInfo* aInfo)
NS_ASSERTION(mDecoder->OnDecodeThread(),
"Should be on decode thread.");
nsMediaStream* stream = mDecoder->GetCurrentStream();
nsMediaStream* stream = mDecoder->GetStream();
NS_ASSERTION(stream, "Decoder has no media stream");
if (!ReadFromStream(stream, reinterpret_cast<PRUint8*>(&mMetadata),
@ -189,7 +189,7 @@ bool nsRawReader::DecodeVideoFrame(bool &aKeyframeSkip,
PRUint32 length = mFrameSize - sizeof(nsRawPacketHeader);
nsAutoArrayPtr<PRUint8> buffer(new PRUint8[length]);
nsMediaStream* stream = mDecoder->GetCurrentStream();
nsMediaStream* stream = mDecoder->GetStream();
NS_ASSERTION(stream, "Decoder has no media stream");
// We're always decoding one frame when called
@ -259,7 +259,7 @@ nsresult nsRawReader::Seek(PRInt64 aTime, PRInt64 aStartTime, PRInt64 aEndTime,
NS_ASSERTION(mDecoder->OnDecodeThread(),
"Should be on decode thread.");
nsMediaStream *stream = mDecoder->GetCurrentStream();
nsMediaStream *stream = mDecoder->GetStream();
NS_ASSERTION(stream, "Decoder has no media stream");
PRUint32 frame = mCurrentFrame;

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

@ -73,6 +73,7 @@ _TEST_FILES = \
can_play_type_webm.js \
cancellable_request.sjs \
dynamic_redirect.sjs \
dynamic_resource.sjs \
file_access_controls.html \
fragment_play.js \
fragment_noplay.js \
@ -120,6 +121,7 @@ _TEST_FILES = \
test_info_leak.html \
test_load.html \
test_load_candidates.html \
test_load_same_resource.html \
test_load_source.html \
test_loop.html \
test_media_selection.html \

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

@ -1,3 +1,17 @@
function parseQuery(request, key) {
var params = request.queryString.split('&');
for (var j = 0; j < params.length; ++j) {
var p = params[j];
if (p == key)
return true;
if (p.indexOf(key + "=") == 0)
return p.substring(key.length + 1);
if (p.indexOf("=") < 0 && key == "")
return p;
}
return false;
}
var types = {
ogg: "video/ogg",
ogv: "video/ogg",
@ -10,7 +24,8 @@ var types = {
// allow headers.
function handleRequest(request, response)
{
var resource = request.queryString;
var resource = parseQuery(request, "");
var file = Components.classes["@mozilla.org/file/directory_service;1"].
getService(Components.interfaces.nsIProperties).
get("CurWorkD", Components.interfaces.nsILocalFile);

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

@ -1,3 +1,17 @@
function parseQuery(request, key) {
var params = request.queryString.split('&');
for (var j = 0; j < params.length; ++j) {
var p = params[j];
if (p == key)
return true;
if (p.indexOf(key + "=") == 0)
return p.substring(key.length + 1);
if (p.indexOf("=") < 0 && key == "")
return p;
}
return false;
}
function push32BE(array, input) {
array.push(String.fromCharCode((input >> 24) & 0xff));
array.push(String.fromCharCode((input >> 16) & 0xff));
@ -60,7 +74,7 @@ function poll(f) {
function handleRequest(request, response)
{
var cancel = request.queryString.match(/^cancelkey=(.*)$/);
var cancel = parseQuery(request, "cancelkey");
if (cancel) {
setState(cancel[1], "cancelled");
response.setStatusLine(request.httpVersion, 200, "OK");
@ -74,7 +88,7 @@ function handleRequest(request, response)
}
var bytes = buildWave(samples, 44100).join("");
var key = request.queryString.match(/^key=(.*)$/);
var key = parseQuery(request, "key");
response.setHeader("Content-Type", "audio/x-wav");
response.setHeader("Content-Length", ""+bytes.length, false);

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

@ -1,9 +1,23 @@
function parseQuery(request, key) {
var params = request.queryString.split('&');
for (var j = 0; j < params.length; ++j) {
var p = params[j];
if (p == key)
return true;
if (p.indexOf(key + "=") == 0)
return p.substring(key.length + 1);
if (p.indexOf("=") < 0 && key == "")
return p;
}
return false;
}
// Return seek.ogv file content for the first request with a given key.
// All subsequent requests return a redirect to a different-origin resource.
function handleRequest(request, response)
{
var key = (request.queryString.match(/^key=(.*)&/))[1];
var resource = (request.queryString.match(/res=(.*)$/))[1];
var key = parseQuery(request, "key");
var resource = parseQuery(request, "res");
if (getState(key) == "redirect") {
var origin = request.host == "mochi.test" ? "example.org" : "mochi.test:8888";

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

@ -0,0 +1,48 @@
function parseQuery(request, key) {
var params = request.queryString.split('&');
for (var j = 0; j < params.length; ++j) {
var p = params[j];
if (p == key)
return true;
if (p.indexOf(key + "=") == 0)
return p.substring(key.length + 1);
if (p.indexOf("=") < 0 && key == "")
return p;
}
return false;
}
// Return resource1 file content for the first request with a given key.
// All subsequent requests return resource2. Both must be video/ogg.
function handleRequest(request, response)
{
var key = parseQuery(request, "key");
var resource1 = parseQuery(request, "res1");
var resource2 = parseQuery(request, "res2");
var resource = getState(key) == "2" ? resource2 : resource1;
setState(key, "2");
var file = Components.classes["@mozilla.org/file/directory_service;1"].
getService(Components.interfaces.nsIProperties).
get("CurWorkD", Components.interfaces.nsILocalFile);
var fis = Components.classes['@mozilla.org/network/file-input-stream;1'].
createInstance(Components.interfaces.nsIFileInputStream);
var bis = Components.classes["@mozilla.org/binaryinputstream;1"].
createInstance(Components.interfaces.nsIBinaryInputStream);
var paths = "tests/content/media/test/" + resource;
var split = paths.split("/");
for(var i = 0; i < split.length; ++i) {
file.append(split[i]);
}
fis.init(file, -1, -1, false);
dump("file=" + file + "\n");
bis.setInputStream(fis);
var bytes = bis.readBytes(bis.available());
response.setStatusLine(request.httpVersion, 206, "Partial Content");
response.setHeader("Content-Range", "bytes 0-" + (bytes.length - 1) + "/" + bytes.length);
response.setHeader("Content-Length", ""+bytes.length, false);
response.setHeader("Content-Type", "video/ogg", false);
response.write(bytes, bytes.length);
bis.close();
}

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

@ -140,7 +140,13 @@ function nextTest() {
gVideo = createVideo();
gVideo.expectedResult = gTests[gTestNum].result;
gVideo.testDescription = gTests[gTestNum].description;
gVideo.src = gTests[gTestNum].url;
// Uniquify the resource URL to ensure that the resources loaded by earlier or subsequent tests
// don't overlap with the resources we load here, which are loaded with non-default preferences set.
// We also want to make sure that an HTTP fetch actually happens for each testcase.
var url = gTests[gTestNum].url;
var random = Math.floor(Math.random()*1000000000);
url += (url.search(/\?/) < 0 ? "?" : "&") + "rand=" + random;
gVideo.src = url;
//dump("Starting test " + gTestNum + " at " + gVideo.src + " expecting:" + gVideo.expectedResult + "\n");
if (!gTestedRemoved) {
document.body.appendChild(gVideo);

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

@ -25,9 +25,13 @@ var gProgressTests = [
// Used by test_mozLoadFrom. Need one test file per decoder backend, plus
// anything for testing clone-specific bugs.
var cloneKey = Math.floor(Math.random()*100000000);
var gCloneTests = gSmallTests.concat([
// Actual duration is ~200ms, we have Content-Duration lie about it.
{ name:"bug520908.ogv", type:"video/ogg", duration:9000 },
// short-video is more like 1s, so if you load this twice you'll get an unexpected duration
{ name:"dynamic_resource.sjs?key=" + cloneKey + "&res1=320x240.ogv&res2=short-video.ogv",
type:"video/ogg", duration:0.233 },
]);
// Used by test_play_twice. Need one test file per decoder backend, plus

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

@ -1,25 +1,26 @@
function parseQuery(request, key) {
var params = request.queryString.split('&');
for (var j = 0; j < params.length; ++j) {
var p = params[j];
if (p == key)
return true;
if (p.indexOf(key + "=") == 0)
return p.substring(key.length + 1);
if (p.indexOf("=") < 0 && key == "")
return p;
}
return false;
}
// Return file content for the first request with a given key.
// All subsequent requests return a redirect to a different-origin resource.
function handleRequest(request, response)
{
var params = request.queryString.split('&');
var domain = null;
var file = null;
var allowed = false;
for (var i=0; i<params.length; i++) {
var kv = params[i].split('=');
if (kv.length == 1 && kv[0] == 'allowed') {
allowed = true;
} else if (kv.length == 2 && kv[0] == 'file') {
file = kv[1];
} else if (kv.length == 2 && kv[0] == 'domain') {
domain = kv[1];
}
}
var domain = parseQuery(request, "domain");
var file = parseQuery(request, "file");
var allowed = parseQuery(request, "allowed");
response.setStatusLine(request.httpVersion, 303, "See Other");
response.setHeader("Location", "http://" + domain + "/tests/content/media/test/" + (allowed ? "allowed.sjs?" : "") + file);
response.setHeader("Content-Type", "text/html");
}

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

@ -1,9 +1,24 @@
function parseQuery(request, key) {
var params = request.queryString.split('&');
for (var j = 0; j < params.length; ++j) {
var p = params[j];
if (p == key)
return true;
if (p.indexOf(key + "=") == 0)
return p.substring(key.length + 1);
if (p.indexOf("=") < 0 && key == "")
return p;
}
return false;
}
function handleRequest(request, response)
{
var referer = request.hasHeader("Referer") ? request.getHeader("Referer")
: undefined;
if (referer == "http://mochi.test:8888/tests/content/media/test/test_referer.html") {
var [ignore, name, type] = request.queryString.match(/name=(.*)&type=(.*)$/);
var name = parseQuery(request, "name");
var type = parseQuery(request, "type");
var file = Components.classes["@mozilla.org/file/directory_service;1"].
getService(Components.interfaces.nsIProperties).
get("CurWorkD", Components.interfaces.nsILocalFile);

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

@ -77,14 +77,14 @@ function videoError(event, id) {
}
</script>
<!-- We make the resource URIs unique to ensure that they are (re)loaded with the new disable-decoder prefs. -->
<video id="video1">
<source type="video/ogg" src="320x240.ogv" onerror="videoError(event, 'video1');"/>
<source type="audio/wave" src="r11025_u8_c1.wav" id='s2' onerror="videoError(event, 'video1');"/>
<source type="video/ogg" src="320x240.ogv?decoder_disabled=1" onerror="videoError(event, 'video1');"/>
<source type="audio/wave" src="r11025_u8_c1.wav?decoder_disabled=1" id='s2' onerror="videoError(event, 'video1');"/>
</video>
<video id="video2" src="320x240.ogv" onerror="videoError(event, 'video2');"></video>
<video id="video3" src="r11025_u8_c1.wav" onerror="videoError(event, 'video3');"></video>
<video id="video2" src="320x240.ogv?decoder_disabled=2" onerror="videoError(event, 'video2');"></video>
<video id="video3" src="r11025_u8_c1.wav?decoder_disabled=2" onerror="videoError(event, 'video3');"></video>
</pre>

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

@ -0,0 +1,70 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test loading of the same resource in multiple elements</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script type="text/javascript" src="manifest.js"></script>
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
var manager = new MediaTestManager;
function cloneLoaded(event) {
ok(true, "Clone loaded OK");
var e = event.target;
if (e._expectedDuration) {
ok(Math.abs(e.duration - e._expectedDuration) < 0.1,
"Clone " + e.currentSrc + " duration: " + e.duration + " expected: " + e._expectedDuration);
}
manager.finished(e.token);
}
function tryClone(event) {
var e = event.target;
var clone = e.cloneNode(false);
clone.token = e.token;
if (e._expectedDuration) {
ok(Math.abs(e.duration - e._expectedDuration) < 0.1,
e.currentSrc + " duration: " + e.duration + " expected: " + e._expectedDuration);
clone._expectedDuration = e._expectedDuration;
}
clone.addEventListener("loadeddata", cloneLoaded, false);
}
// This test checks that loading the same URI twice in different elements at the same time
// uses the same resource without doing another network fetch. One of the gCloneTests
// uses dynamic_resource.sjs to return one resource on the first fetch and a different resource
// on the second fetch. These resources have different lengths, so if the cloned element
// does a network fetch it will get a resource with the wrong length and we get a test
// failure.
function initTest(test, token) {
var elemType = /^audio/.test(test.type) ? "audio" : "video";
var e = document.createElement(elemType);
if (e.canPlayType(test.type)) {
e.src = test.name;
if (test.duration) {
e._expectedDuration = test.duration;
}
ok(true, "Trying to load " + test.name);
e.addEventListener("loadeddata", tryClone, false);
e.load();
e.token = token;
manager.started(token);
}
}
manager.runTests(gCloneTests, initTest);
</script>
</pre>
</body>
</html>

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

@ -30,6 +30,7 @@ manager.onFinished = function() {
};
var test = getPlayableVideo(gSeekTests);
var baseName = test.name;
var gTest = test;
var bogusSrc = "bogus.duh";
var bogusType = "video/bogus";
@ -144,8 +145,9 @@ var tests = [
suspend:
function(e) {
var v = e.target;
if (v._gotSuspend)
if (v._gotSuspend) {
return; // We can receive multiple suspend events, like the one after download completes.
}
v._gotSuspend = true;
is(v._gotLoadStart, true, "(4) Must get loadstart.");
is(v._gotLoadedMetaData, false, "(4) Must not get loadedmetadata.");
@ -557,14 +559,23 @@ var tests = [
}
];
var iterationCount = 0;
function startTest(test, token) {
if (test == tests[0]) {
++iterationCount;
}
if (iterationCount == 2) {
// Do this series of tests on logically different resources
test.name = baseName + "?" + Math.floor(Math.random()*100000);
}
var v = document.createElement("video");
v.token = token;
test.setup(v);
manager.started(token);
}
manager.runTests(tests, startTest);
var twiceTests = tests.concat(tests);
manager.runTests(twiceTests, startTest);
</script>
</pre>

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

@ -261,7 +261,7 @@ nsresult nsWaveReader::Seek(PRInt64 aTarget, PRInt64 aStartTime, PRInt64 aEndTim
PRInt64 position = RoundDownToFrame(static_cast<PRInt64>(TimeToBytes(seekTime)));
NS_ASSERTION(PR_INT64_MAX - mWavePCMOffset > position, "Integer overflow during wave seek");
position += mWavePCMOffset;
return mDecoder->GetCurrentStream()->Seek(nsISeekableStream::NS_SEEK_SET, position);
return mDecoder->GetStream()->Seek(nsISeekableStream::NS_SEEK_SET, position);
}
static double RoundToUsecs(double aSeconds) {
@ -270,9 +270,9 @@ static double RoundToUsecs(double aSeconds) {
nsresult nsWaveReader::GetBuffered(nsTimeRanges* aBuffered, PRInt64 aStartTime)
{
PRInt64 startOffset = mDecoder->GetCurrentStream()->GetNextCachedData(mWavePCMOffset);
PRInt64 startOffset = mDecoder->GetStream()->GetNextCachedData(mWavePCMOffset);
while (startOffset >= 0) {
PRInt64 endOffset = mDecoder->GetCurrentStream()->GetCachedDataEnd(startOffset);
PRInt64 endOffset = mDecoder->GetStream()->GetCachedDataEnd(startOffset);
// Bytes [startOffset..endOffset] are cached.
NS_ASSERTION(startOffset >= mWavePCMOffset, "Integer underflow in GetBuffered");
NS_ASSERTION(endOffset >= mWavePCMOffset, "Integer underflow in GetBuffered");
@ -282,7 +282,7 @@ nsresult nsWaveReader::GetBuffered(nsTimeRanges* aBuffered, PRInt64 aStartTime)
// the media element.
aBuffered->Add(RoundToUsecs(BytesToTime(startOffset - mWavePCMOffset)),
RoundToUsecs(BytesToTime(endOffset - mWavePCMOffset)));
startOffset = mDecoder->GetCurrentStream()->GetNextCachedData(endOffset);
startOffset = mDecoder->GetStream()->GetNextCachedData(endOffset);
}
return NS_OK;
}
@ -296,7 +296,7 @@ nsWaveReader::ReadAll(char* aBuf, PRInt64 aSize, PRInt64* aBytesRead)
}
do {
PRUint32 read = 0;
if (NS_FAILED(mDecoder->GetCurrentStream()->Read(aBuf + got, PRUint32(aSize - got), &read))) {
if (NS_FAILED(mDecoder->GetStream()->Read(aBuf + got, PRUint32(aSize - got), &read))) {
NS_WARNING("Stream read failed");
return false;
}
@ -318,7 +318,7 @@ nsWaveReader::LoadRIFFChunk()
char riffHeader[RIFF_INITIAL_SIZE];
const char* p = riffHeader;
NS_ABORT_IF_FALSE(mDecoder->GetCurrentStream()->Tell() == 0,
NS_ABORT_IF_FALSE(mDecoder->GetStream()->Tell() == 0,
"LoadRIFFChunk called when stream in invalid state");
if (!ReadAll(riffHeader, sizeof(riffHeader))) {
@ -390,7 +390,7 @@ nsWaveReader::LoadFormatChunk()
const char* p = waveFormat;
// RIFF chunks are always word (two byte) aligned.
NS_ABORT_IF_FALSE(mDecoder->GetCurrentStream()->Tell() % 2 == 0,
NS_ABORT_IF_FALSE(mDecoder->GetStream()->Tell() % 2 == 0,
"LoadFormatChunk called with unaligned stream");
// The "format" chunk may not directly follow the "riff" chunk, so skip
@ -455,7 +455,7 @@ nsWaveReader::LoadFormatChunk()
}
// RIFF chunks are always word (two byte) aligned.
NS_ABORT_IF_FALSE(mDecoder->GetCurrentStream()->Tell() % 2 == 0,
NS_ABORT_IF_FALSE(mDecoder->GetStream()->Tell() % 2 == 0,
"LoadFormatChunk left stream unaligned");
// Make sure metadata is fairly sane. The rate check is fairly arbitrary,
@ -485,7 +485,7 @@ bool
nsWaveReader::FindDataOffset()
{
// RIFF chunks are always word (two byte) aligned.
NS_ABORT_IF_FALSE(mDecoder->GetCurrentStream()->Tell() % 2 == 0,
NS_ABORT_IF_FALSE(mDecoder->GetStream()->Tell() % 2 == 0,
"FindDataOffset called with unaligned stream");
// The "data" chunk may not directly follow the "format" chunk, so skip
@ -495,7 +495,7 @@ nsWaveReader::FindDataOffset()
return false;
}
PRInt64 offset = mDecoder->GetCurrentStream()->Tell();
PRInt64 offset = mDecoder->GetStream()->Tell();
if (offset <= 0 || offset > PR_UINT32_MAX) {
NS_WARNING("PCM data offset out of range");
return false;
@ -535,7 +535,7 @@ nsWaveReader::GetDataLength()
// If the decoder has a valid content length, and it's shorter than the
// expected length of the PCM data, calculate the playback duration from
// the content length rather than the expected PCM data length.
PRInt64 streamLength = mDecoder->GetCurrentStream()->GetLength();
PRInt64 streamLength = mDecoder->GetStream()->GetLength();
if (streamLength >= 0) {
PRInt64 dataLength = NS_MAX<PRInt64>(0, streamLength - mWavePCMOffset);
length = NS_MIN(dataLength, length);
@ -546,5 +546,5 @@ nsWaveReader::GetDataLength()
PRInt64
nsWaveReader::GetPosition()
{
return mDecoder->GetCurrentStream()->Tell();
return mDecoder->GetStream()->Tell();
}

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

@ -86,7 +86,7 @@ static int webm_read(void *aBuffer, size_t aLength, void *aUserData)
{
NS_ASSERTION(aUserData, "aUserData must point to a valid nsBuiltinDecoder");
nsBuiltinDecoder* decoder = reinterpret_cast<nsBuiltinDecoder*>(aUserData);
nsMediaStream* stream = decoder->GetCurrentStream();
nsMediaStream* stream = decoder->GetStream();
NS_ASSERTION(stream, "Decoder has no media stream");
nsresult rv = NS_OK;
@ -112,7 +112,7 @@ static int webm_seek(int64_t aOffset, int aWhence, void *aUserData)
{
NS_ASSERTION(aUserData, "aUserData must point to a valid nsBuiltinDecoder");
nsBuiltinDecoder* decoder = reinterpret_cast<nsBuiltinDecoder*>(aUserData);
nsMediaStream* stream = decoder->GetCurrentStream();
nsMediaStream* stream = decoder->GetStream();
NS_ASSERTION(stream, "Decoder has no media stream");
nsresult rv = stream->Seek(aWhence, aOffset);
return NS_SUCCEEDED(rv) ? 0 : -1;
@ -122,7 +122,7 @@ static int64_t webm_tell(void *aUserData)
{
NS_ASSERTION(aUserData, "aUserData must point to a valid nsBuiltinDecoder");
nsBuiltinDecoder* decoder = reinterpret_cast<nsBuiltinDecoder*>(aUserData);
nsMediaStream* stream = decoder->GetCurrentStream();
nsMediaStream* stream = decoder->GetStream();
NS_ASSERTION(stream, "Decoder has no media stream");
return stream->Tell();
}
@ -559,7 +559,7 @@ nsReturnRef<NesteggPacketHolder> nsWebMReader::NextPacket(TrackType aTrackType)
if (r <= 0) {
return nsReturnRef<NesteggPacketHolder>();
}
PRInt64 offset = mDecoder->GetCurrentStream()->Tell();
PRInt64 offset = mDecoder->GetStream()->Tell();
holder.own(new NesteggPacketHolder(packet, offset));
unsigned int track = 0;
@ -769,7 +769,7 @@ nsresult nsWebMReader::Seek(PRInt64 aTarget, PRInt64 aStartTime, PRInt64 aEndTim
nsresult nsWebMReader::GetBuffered(nsTimeRanges* aBuffered, PRInt64 aStartTime)
{
nsMediaStream* stream = mDecoder->GetCurrentStream();
nsMediaStream* stream = mDecoder->GetStream();
uint64_t timecodeScale;
if (!mContext || nestegg_tstamp_scale(mContext, &timecodeScale) == -1) {
@ -783,7 +783,7 @@ nsresult nsWebMReader::GetBuffered(nsTimeRanges* aBuffered, PRInt64 aStartTime)
aBuffered->Add(0, duration / NS_PER_S);
}
} else {
nsMediaStream* stream = mDecoder->GetCurrentStream();
nsMediaStream* stream = mDecoder->GetStream();
nsTArray<nsByteRange> ranges;
nsresult res = stream->GetCachedRanges(ranges);
NS_ENSURE_SUCCESS(res, res);

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

@ -334,6 +334,11 @@ nsSMILTimeValueSpec::RegisterEventListener(Element* aTarget)
if (!aTarget)
return;
// Don't listen for accessKey events if script is disabled. (see bug 704482)
if (mParams.mType == nsSMILTimeValueSpecParams::ACCESSKEY &&
!aTarget->GetOwnerDocument()->IsScriptEnabled())
return;
if (!mEventListener) {
mEventListener = new EventListener(this);
}

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

@ -144,7 +144,7 @@ DOMSVGLengthList::InternalListLengthWillChange(PRUint32 aNewLength)
}
SVGLengthList&
DOMSVGLengthList::InternalList()
DOMSVGLengthList::InternalList() const
{
SVGAnimatedLengthList *alist = Element()->GetAnimatedLengthList(AttrEnum());
return IsAnimValList() && alist->mAnimVal ? *alist->mAnimVal : alist->mBaseVal;

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

@ -103,8 +103,7 @@ public:
*/
PRUint32 Length() const {
NS_ABORT_IF_FALSE(mItems.Length() == 0 ||
mItems.Length() ==
const_cast<DOMSVGLengthList*>(this)->InternalList().Length(),
mItems.Length() == InternalList().Length(),
"DOM wrapper's list length is out of sync");
return mItems.Length();
}
@ -116,7 +115,7 @@ public:
private:
nsSVGElement* Element() {
nsSVGElement* Element() const {
return mAList->mElement;
}
@ -143,7 +142,7 @@ private:
* get const protection, but our setter methods guard against changing
* animVal lists.
*/
SVGLengthList& InternalList();
SVGLengthList& InternalList() const;
/// Creates a DOMSVGLength for aIndex, if it doesn't already exist.
void EnsureItemAt(PRUint32 aIndex);

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

@ -144,7 +144,7 @@ DOMSVGNumberList::InternalListLengthWillChange(PRUint32 aNewLength)
}
SVGNumberList&
DOMSVGNumberList::InternalList()
DOMSVGNumberList::InternalList() const
{
SVGAnimatedNumberList *alist = Element()->GetAnimatedNumberList(AttrEnum());
return IsAnimValList() && alist->mAnimVal ? *alist->mAnimVal : alist->mBaseVal;

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

@ -102,8 +102,7 @@ public:
*/
PRUint32 Length() const {
NS_ABORT_IF_FALSE(mItems.Length() == 0 ||
mItems.Length() ==
const_cast<DOMSVGNumberList*>(this)->InternalList().Length(),
mItems.Length() == InternalList().Length(),
"DOM wrapper's list length is out of sync");
return mItems.Length();
}
@ -115,7 +114,7 @@ public:
private:
nsSVGElement* Element() {
nsSVGElement* Element() const {
return mAList->mElement;
}
@ -138,7 +137,7 @@ private:
* get const protection, but our setter methods guard against changing
* animVal lists.
*/
SVGNumberList& InternalList();
SVGNumberList& InternalList() const;
/// Creates a DOMSVGNumber for aIndex, if it doesn't already exist.
void EnsureItemAt(PRUint32 aIndex);

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

@ -230,18 +230,18 @@ DOMSVGPathSegList::InternalListWillChangeTo(const SVGPathData& aNewValue)
bool
DOMSVGPathSegList::AttrIsAnimating() const
{
return const_cast<DOMSVGPathSegList*>(this)->InternalAList().IsAnimating();
return InternalAList().IsAnimating();
}
SVGPathData&
DOMSVGPathSegList::InternalList()
DOMSVGPathSegList::InternalList() const
{
SVGAnimatedPathSegList *alist = mElement->GetAnimPathSegList();
return mIsAnimValList && alist->IsAnimating() ? *alist->mAnimVal : alist->mBaseVal;
}
SVGAnimatedPathSegList&
DOMSVGPathSegList::InternalAList()
DOMSVGPathSegList::InternalAList() const
{
NS_ABORT_IF_FALSE(mElement->GetAnimPathSegList(), "Internal error");
return *mElement->GetAnimPathSegList();

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

@ -120,8 +120,7 @@ public:
*/
PRUint32 Length() const {
NS_ABORT_IF_FALSE(mItems.Length() == 0 ||
mItems.Length() ==
const_cast<DOMSVGPathSegList*>(this)->InternalList().CountItems(),
mItems.Length() == InternalList().CountItems(),
"DOM wrapper's list length is out of sync");
return mItems.Length();
}
@ -184,9 +183,9 @@ private:
* get const protection, but our setter methods guard against changing
* anim val lists.
*/
SVGPathData& InternalList();
SVGPathData& InternalList() const;
SVGAnimatedPathSegList& InternalAList();
SVGAnimatedPathSegList& InternalAList() const;
/// Creates an instance of the appropriate DOMSVGPathSeg sub-class for
// aIndex, if it doesn't already exist.

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

@ -175,18 +175,18 @@ DOMSVGPointList::InternalListWillChangeTo(const SVGPointList& aNewValue)
bool
DOMSVGPointList::AttrIsAnimating() const
{
return const_cast<DOMSVGPointList*>(this)->InternalAList().IsAnimating();
return InternalAList().IsAnimating();
}
SVGPointList&
DOMSVGPointList::InternalList()
DOMSVGPointList::InternalList() const
{
SVGAnimatedPointList *alist = mElement->GetAnimatedPointList();
return mIsAnimValList && alist->IsAnimating() ? *alist->mAnimVal : alist->mBaseVal;
}
SVGAnimatedPointList&
DOMSVGPointList::InternalAList()
DOMSVGPointList::InternalAList() const
{
NS_ABORT_IF_FALSE(mElement->GetAnimatedPointList(), "Internal error");
return *mElement->GetAnimatedPointList();

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

@ -120,8 +120,7 @@ public:
*/
PRUint32 Length() const {
NS_ABORT_IF_FALSE(mItems.Length() == 0 ||
mItems.Length() ==
const_cast<DOMSVGPointList*>(this)->InternalList().Length(),
mItems.Length() == InternalList().Length(),
"DOM wrapper's list length is out of sync");
return mItems.Length();
}
@ -184,9 +183,9 @@ private:
* get const protection, but our setter methods guard against changing
* anim val lists.
*/
SVGPointList& InternalList();
SVGPointList& InternalList() const;
SVGAnimatedPointList& InternalAList();
SVGAnimatedPointList& InternalAList() const;
/// Creates a DOMSVGPoint for aIndex, if it doesn't already exist.
void EnsureItemAt(PRUint32 aIndex);

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

@ -146,7 +146,7 @@ DOMSVGTransformList::InternalListLengthWillChange(PRUint32 aNewLength)
}
SVGTransformList&
DOMSVGTransformList::InternalList()
DOMSVGTransformList::InternalList() const
{
SVGAnimatedTransformList *alist = Element()->GetAnimatedTransformList();
return IsAnimValList() && alist->mAnimVal ?

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

@ -97,8 +97,7 @@ public:
*/
PRUint32 Length() const {
NS_ABORT_IF_FALSE(mItems.IsEmpty() ||
mItems.Length() ==
const_cast<DOMSVGTransformList*>(this)->InternalList().Length(),
mItems.Length() == InternalList().Length(),
"DOM wrapper's list length is out of sync");
return mItems.Length();
}
@ -110,7 +109,7 @@ public:
private:
nsSVGElement* Element() {
nsSVGElement* Element() const {
return mAList->mElement;
}
@ -129,7 +128,7 @@ private:
* get const protection, but our setter methods guard against changing
* animVal lists.
*/
SVGTransformList& InternalList();
SVGTransformList& InternalList() const;
/// Creates a DOMSVGTransform for aIndex, if it doesn't already exist.
void EnsureItemAt(PRUint32 aIndex);

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

@ -115,7 +115,7 @@ public:
const nsCString& aClassStr) = 0;
virtual nsresult CompileMember(nsIScriptContext* aContext,
const nsCString& aClassStr,
void* aClassObject)=0;
JSObject* aClassObject) = 0;
virtual void Trace(TraceCallback aCallback, void *aClosure) const = 0;

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

@ -173,7 +173,7 @@ nsXBLProtoImplMethod::InstallMember(nsIScriptContext* aContext,
nsresult
nsXBLProtoImplMethod::CompileMember(nsIScriptContext* aContext, const nsCString& aClassStr,
void* aClassObject)
JSObject* aClassObject)
{
NS_TIME_FUNCTION_MIN(5);
NS_PRECONDITION(!IsCompiled(),
@ -239,13 +239,13 @@ nsXBLProtoImplMethod::CompileMember(nsIScriptContext* aContext, const nsCString&
nsresult rv = aContext->CompileFunction(aClassObject,
cname,
paramCount,
(const char**)args,
const_cast<const char**>(args),
body,
functionUri.get(),
uncompiledMethod->mBodyText.GetLineNumber(),
JSVERSION_LATEST,
true,
(void **) &methodObject);
&methodObject);
// Destroy our uncompiled method and delete our arg list.
delete uncompiledMethod;

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

@ -127,7 +127,7 @@ public:
const nsCString& aClassStr);
virtual nsresult CompileMember(nsIScriptContext* aContext,
const nsCString& aClassStr,
void* aClassObject);
JSObject* aClassObject);
virtual void Trace(TraceCallback aCallback, void *aClosure) const;

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

@ -222,7 +222,7 @@ nsXBLProtoImplProperty::InstallMember(nsIScriptContext* aContext,
nsresult
nsXBLProtoImplProperty::CompileMember(nsIScriptContext* aContext, const nsCString& aClassStr,
void* aClassObject)
JSObject* aClassObject)
{
NS_PRECONDITION(!mIsCompiled,
"Trying to compile an already-compiled property");
@ -260,7 +260,7 @@ nsXBLProtoImplProperty::CompileMember(nsIScriptContext* aContext, const nsCStrin
mGetterText->GetLineNumber(),
JSVERSION_LATEST,
true,
(void **) &getterObject);
&getterObject);
// Make sure we free mGetterText here before setting mJSGetterObject, since
// that'll overwrite mGetterText
@ -310,7 +310,7 @@ nsXBLProtoImplProperty::CompileMember(nsIScriptContext* aContext, const nsCStrin
mSetterText->GetLineNumber(),
JSVERSION_LATEST,
true,
(void **) &setterObject);
&setterObject);
// Make sure we free mSetterText here before setting mJSGetterObject, since
// that'll overwrite mSetterText

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

@ -72,7 +72,7 @@ public:
const nsCString& aClassStr);
virtual nsresult CompileMember(nsIScriptContext* aContext,
const nsCString& aClassStr,
void* aClassObject);
JSObject* aClassObject);
virtual void Trace(TraceCallback aCallback, void *aClosure) const;

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

@ -323,15 +323,14 @@ nsXBLPrototypeHandler::ExecuteHandler(nsIDOMEventTarget* aTarget,
JSObject* scope = boundGlobal->GetGlobalJSObject();
nsScriptObjectHolder boundHandler(boundContext);
rv = boundContext->BindCompiledEventHandler(scriptTarget, scope,
handler, boundHandler);
handler.getObject(), boundHandler);
NS_ENSURE_SUCCESS(rv, rv);
// Execute it.
nsCOMPtr<nsIDOMEventListener> eventListener;
rv = NS_NewJSEventListener(boundContext, scope,
scriptTarget, onEventAtom,
static_cast<JSObject*>(
static_cast<void*>(boundHandler)),
boundHandler.getObject(),
getter_AddRefs(eventListener));
NS_ENSURE_SUCCESS(rv, rv);
@ -349,9 +348,9 @@ nsXBLPrototypeHandler::EnsureEventHandler(nsIScriptGlobalObject* aGlobal,
// Check to see if we've already compiled this
nsCOMPtr<nsPIDOMWindow> pWindow = do_QueryInterface(aGlobal);
if (pWindow) {
void* cachedHandler = pWindow->GetCachedXBLPrototypeHandler(this);
JSObject* cachedHandler = pWindow->GetCachedXBLPrototypeHandler(this);
if (cachedHandler) {
aHandler.set(cachedHandler);
aHandler.setObject(cachedHandler);
return aHandler ? NS_OK : NS_ERROR_FAILURE;
}
}

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

@ -727,7 +727,7 @@ nsScriptEventHandlerOwnerTearoff::GetCompiledEventHandler(
mElement->FindPrototypeAttribute(kNameSpaceID_None, aName);
if (attr) {
XUL_PROTOTYPE_ATTRIBUTE_METER(gNumCacheHits);
aHandler.set(attr->mEventHandler);
aHandler.setObject(attr->mEventHandler);
}
return NS_OK;
@ -815,7 +815,7 @@ nsScriptEventHandlerOwnerTearoff::CompileEventHandler(
elem->mHoldsScriptObject = true;
}
attr->mEventHandler = (void *)aHandler;
attr->mEventHandler = aHandler.getObject();
}
return NS_OK;
@ -2567,7 +2567,7 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_NATIVE_BEGIN(nsXULPrototypeNode)
if (elem->mHoldsScriptObject) {
PRUint32 i;
for (i = 0; i < elem->mNumAttributes; ++i) {
void *handler = elem->mAttributes[i].mEventHandler;
JSObject* handler = elem->mAttributes[i].mEventHandler;
NS_IMPL_CYCLE_COLLECTION_TRACE_CALLBACK(elem->mScriptTypeID,
handler,
"mAttributes[i].mEventHandler")

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

@ -126,7 +126,7 @@ public:
// mEventHandler is only valid for the language ID specified in the
// containing nsXULPrototypeElement. We would ideally use
// nsScriptObjectHolder, but want to avoid the extra lang ID.
void* mEventHandler;
JSObject* mEventHandler;
#ifdef XUL_PROTOTYPE_ATTRIBUTE_METERING
/**

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

@ -71,6 +71,7 @@ DIRS = \
DIRS += \
base \
battery \
sms \
src \
locales \
plugins/base \

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

@ -69,6 +69,8 @@
#include "mozilla/Preferences.h"
#include "mozilla/Telemetry.h"
#include "BatteryManager.h"
#include "SmsManager.h"
#include "nsISmsService.h"
// This should not be in the namespace.
DOMCI_DATA(Navigator, mozilla::dom::Navigator)
@ -106,6 +108,10 @@ Navigator::~Navigator()
if (mBatteryManager) {
mBatteryManager->Shutdown();
}
if (mSmsManager) {
mSmsManager->Shutdown();
}
}
NS_INTERFACE_MAP_BEGIN(Navigator)
@ -115,6 +121,7 @@ NS_INTERFACE_MAP_BEGIN(Navigator)
NS_INTERFACE_MAP_ENTRY(nsIDOMNavigatorGeolocation)
NS_INTERFACE_MAP_ENTRY(nsIDOMMozNavigatorBattery)
NS_INTERFACE_MAP_ENTRY(nsIDOMNavigatorDesktopNotification)
NS_INTERFACE_MAP_ENTRY(nsIDOMMozNavigatorSms)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Navigator)
NS_INTERFACE_MAP_END
@ -145,6 +152,11 @@ Navigator::SetDocShell(nsIDocShell* aDocShell)
mBatteryManager->Shutdown();
mBatteryManager = nsnull;
}
if (mSmsManager) {
mSmsManager->Shutdown();
mSmsManager = nsnull;
}
}
//*****************************************************************************
@ -525,6 +537,11 @@ Navigator::LoadingNewDocument()
mBatteryManager->Shutdown();
mBatteryManager = nsnull;
}
if (mSmsManager) {
mSmsManager->Shutdown();
mSmsManager = nsnull;
}
}
nsresult
@ -772,6 +789,102 @@ Navigator::GetMozBattery(nsIDOMMozBatteryManager** aBattery)
return NS_OK;
}
//*****************************************************************************
// Navigator::nsIDOMNavigatorSms
//*****************************************************************************
bool
Navigator::IsSmsAllowed() const
{
static const bool defaultSmsPermission = false;
// First of all, the general pref has to be turned on.
if (!Preferences::GetBool("dom.sms.enabled", defaultSmsPermission)) {
return false;
}
// In addition of having 'dom.sms.enabled' set to true, we require the
// website to be whitelisted. This is a temporary 'security model'.
// 'dom.sms.whitelist' has to contain comma-separated values of URI prepath.
// For local files, "file://" must be listed.
// For data-urls: "moz-nullprincipal:".
// Chrome files also have to be whitelisted for the moment.
nsCOMPtr<nsIDocument> doc = do_GetInterface(mDocShell);
if (!doc) {
return defaultSmsPermission;
}
nsCOMPtr<nsIURI> uri;
doc->NodePrincipal()->GetURI(getter_AddRefs(uri));
if (!uri) {
return defaultSmsPermission;
}
nsCAutoString uriPrePath;
uri->GetPrePath(uriPrePath);
const nsAdoptingString& whitelist =
Preferences::GetString("dom.sms.whitelist");
nsCharSeparatedTokenizer tokenizer(whitelist, ',',
nsCharSeparatedTokenizerTemplate<>::SEPARATOR_OPTIONAL);
while (tokenizer.hasMoreTokens()) {
const nsSubstring& whitelistItem = tokenizer.nextToken();
if (NS_ConvertUTF16toUTF8(whitelistItem).Equals(uriPrePath)) {
return true;
}
}
// The current page hasn't been whitelisted.
return false;
}
bool
Navigator::IsSmsSupported() const
{
nsCOMPtr<nsISmsService> smsService = do_GetService(SMSSERVICE_CONTRACTID);
NS_ENSURE_TRUE(smsService, false);
bool result = false;
smsService->HasSupport(&result);
return result;
}
NS_IMETHODIMP
Navigator::GetMozSms(nsIDOMMozSmsManager** aSmsManager)
{
*aSmsManager = nsnull;
if (!mSmsManager) {
if (!IsSmsSupported() || !IsSmsAllowed()) {
return NS_OK;
}
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(mDocShell);
NS_ENSURE_TRUE(window, NS_OK);
nsCOMPtr<nsIDocument> document = do_GetInterface(mDocShell);
NS_ENSURE_TRUE(document, NS_OK);
nsIScriptGlobalObject* sgo = document->GetScopeObject();
NS_ENSURE_TRUE(sgo, NS_OK);
nsIScriptContext* scx = sgo->GetContext();
NS_ENSURE_TRUE(scx, NS_OK);
mSmsManager = new sms::SmsManager();
mSmsManager->Init(window->GetCurrentInnerWindow(), scx);
}
NS_ADDREF(*aSmsManager = mSmsManager);
return NS_OK;
}
PRInt64
Navigator::SizeOf() const
{

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