Merge m-c to fx-team

This commit is contained in:
Carsten "Tomcat" Book 2013-11-28 14:35:04 +01:00
commit 2b1042fd24
715 changed files with 18816 additions and 6326 deletions

View File

@ -2,4 +2,4 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DEFINES = -DBIN_SUFFIX=$(BIN_SUFFIX)
REVIEWBOARD_URL = 'https://reviewboard.allizom.org/'

View File

@ -6,8 +6,6 @@ DEFFILE = $(win_srcdir)/IA2Marshal.def
IA2DIR = $(topsrcdir)/other-licenses/ia2
DEFINES += -DREGISTER_PROXY_DLL
GARBAGE += $(MIDL_GENERATED_FILES)
# Please keep this list in sync with the moz.build file until the rest of this

View File

@ -7,3 +7,5 @@
LIBRARY_NAME = 'IA2Marshal'
FORCE_SHARED_LIB = True
DEFINES['REGISTER_PROXY_DLL'] = True

View File

@ -4,8 +4,6 @@
DEFFILE = $(win_srcdir)/AccessibleMarshal.def
DEFINES += -DREGISTER_PROXY_DLL
GARBAGE += $(MIDL_GENERATED_FILES) done_gen dlldata.c
MIDL_GENERATED_FILES = \

View File

@ -17,3 +17,5 @@ GENERATED_SOURCES += [
]
FORCE_SHARED_LIB = True
DEFINES['REGISTER_PROXY_DLL'] = True

View File

@ -2,6 +2,7 @@
support-files =
jsatcommon.js
output.js
doc_traversal.html
[test_alive.html]
[test_braille.html]
@ -9,4 +10,5 @@ support-files =
[test_landmarks.html]
[test_live_regions.html]
[test_tables.html]
[test_traversal.html]
[test_utterance_order.html]

View File

@ -0,0 +1,117 @@
<!DOCTYPE html>
<html>
<head>
<title>Traversal Rule test document</title>
<meta charset="utf-8" />
</head>
<body>
<h3 id="heading-1">A small first heading</h3>
<form>
<label for="input-1-1">Name:</label>
<input id="input-1-1">
<label id="label-1-2">Favourite Ice Cream Flavour:<input id="input-1-2"></label>
<button id="button-1-1">Magic Button</button>
<label for="radio-1-1">Radios are old: </label>
<input id="radio-1-1" type="radio">
<label for="radio-1-2">Radios are new: </label>
<input id="radio-1-2" type="radio">
<label for="input-1-3">Password:</label>
<input id="input-1-3" type="password">
<label for="input-1-4">Unlucky number:</label>
<input id="input-1-4" type="tel">
<input id="button-1-2" type="button" value="Fun">
<label for="checkbox-1-1">Check me: </label>
<input id="checkbox-1-1" type="checkbox">
<select id="select-1-1">
<option>Value 1</option>
<option>Value 2</option>
<option>Value 3</option>
</select>
<select id="select-1-2" multiple="true">
<option>Value 1</option>
<option>Value 2</option>
<option>Value 3</option>
</select>
<label for="checkbox-1-2">Check me too: </label>
<input id="checkbox-1-2" type="checkbox">
<label for="checkbox-1-3">But not me: </label>
<input id="checkbox-1-3" type="checkbox" aria-hidden="true">
<label for="checkbox-1-4">Or me! </label>
<input id="checkbox-1-3" type="checkbox" style="visibility:hidden">
<select id="select-1-3" size="3">
<option>Value 1</option>
<option>Value 2</option>
<option>Value 3</option>
</select>
<label for="input-1-5">Electronic mailing address:</label>
<input id="input-1-5" type="email">
<input id="button-1-3" type="submit" value="Submit">
</form>
<h2 id="heading-2">A larger second</h2>
<div id="heading-3" role="heading">ARIA is fun</div>
<input id="button-2-1" type="button" value="More Fun">
<div id="button-2-2" tabindex="0" role="button">ARIA fun</div>
<div id="button-2-3" tabindex="0" role="button" aria-pressed="false">My little togglebutton</div>
<div id="button-2-4" tabindex="0" role="spinbutton">ARIA fun</div>
<h1 id="heading-4" style="display:none">Invisible header</h1>
<dl id="list-1">
<dt id="listitem-1-1">Programming Language</dt>
<dd>A esoteric weapon wielded by only the most formidable warriors,
for its unrelenting strict power is unfathomable.</dd>
</dl>
<ul id="list-2">
<li id="listitem-2-1">Lists of Programming Languages</li>
<li id="listitem-2-2">Lisp
<ol id="list-3">
<li id="listitem-3-1">Scheme</li>
<li id="listitem-3-2">Racket</li>
<li id="listitem-3-3">Clojure</li>
</ol>
</li>
<li id="listitem-2-3">JavaScript</li>
</ul>
<h6 id="heading-5">The last (visible) one!</h6>
<img id="image-1" src="http://example.com" alt="">
<img id="image-2" src="../moz.png" alt="stuff">
<div id="image-3" tabindex="0" role="img">Not actually an image</div>
<h4 id="heading-6" aria-hidden="true">Hidden header</h4>
<a id="link-1" href="http://www.mozilla.org">Link</a>
<a id="anchor-1">Words</a>
<a id="link-2" href="http://www.mozilla.org">Link the second</a>
<a id="anchor-2">Sentences</a>
<a id="link-3" href="http://www.example.com">Link the third</a>
<hr id="separator-1">
<table id="table-1">
<tr>
<td>3</td>
<td>1</td>
</tr>
<tr>
<td>4</td>
<td>1</td>
</tr>
</table>
<div id="separator-2" role="separator">Just an innocuous separator</div>
<table id="table-2">
<thead>
<tr>
<th>Dirty Words</th>
<th>Meaning</th>
</tr>
</thead>
<tfoot>
<tr>
<td>Mud</td>
<td>Wet Dirt</td>
</tr>
</tfoot>
<tbody>
<tr>
<td>Dirt</td>
<td>Messy Stuff</td>
</tr>
</tbody>
</table>
</body>
</html>

View File

@ -0,0 +1,121 @@
<!DOCTYPE html>
<html>
<head>
<title>Tests AccessFu TraversalRules</title>
<meta charset="utf-8" />
<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="chrome://mochikit/content/chrome-harness.js">
</script>
<script type="application/javascript" src="../common.js"></script>
<script type="application/javascript" src="../browser.js"></script>
<script type="application/javascript" src="../events.js"></script>
<script type="application/javascript" src="../role.js"></script>
<script type="application/javascript" src="../states.js"></script>
<script type="application/javascript" src="../pivot.js"></script>
<script type="application/javascript" src="../layout.js"></script>
<script type="application/javascript">
Components.utils.import("resource://gre/modules/accessibility/TraversalRules.jsm");
var gBrowserWnd = null;
var gQueue = null;
function doTest()
{
var doc = currentTabDocument();
var docAcc = getAccessible(doc, [nsIAccessibleDocument]);
gQueue = new eventQueue();
gQueue.onFinish = function onFinish()
{
closeBrowserWindow();
}
queueTraversalSequence(gQueue, docAcc, TraversalRules.Heading, null,
['heading-1', 'heading-2', 'heading-3', 'heading-5']);
queueTraversalSequence(gQueue, docAcc, TraversalRules.Entry, null,
['input-1-1', 'label-1-2', 'input-1-3',
'input-1-4', 'input-1-5']);
// move back an element to hit all the form elements, because the VC is
// currently at the first input element
gQueue.push(new setVCPosInvoker(docAcc, "movePrevious",
TraversalRules.Heading, "heading-1"));
queueTraversalSequence(gQueue, docAcc, TraversalRules.FormElement, null,
['input-1-1', 'label-1-2', 'button-1-1',
'radio-1-1', 'radio-1-2', 'input-1-3',
'input-1-4', 'button-1-2', 'checkbox-1-1',
'select-1-1', 'select-1-2', 'checkbox-1-2',
'select-1-3', 'input-1-5', 'button-1-3',
'button-2-1', 'button-2-2', 'button-2-3',
'button-2-4']);
queueTraversalSequence(gQueue, docAcc, TraversalRules.Button, null,
['button-1-1', 'button-1-2', 'button-1-3',
'button-2-1', 'button-2-2', 'button-2-3',
'button-2-4']);
queueTraversalSequence(gQueue, docAcc, TraversalRules.RadioButton, null,
['radio-1-1', 'radio-1-2']);
queueTraversalSequence(gQueue, docAcc, TraversalRules.Checkbox, null,
['checkbox-1-1', 'checkbox-1-2']);
queueTraversalSequence(gQueue, docAcc, TraversalRules.Combobox, null,
['select-1-1', 'select-1-2', 'select-1-3']);
queueTraversalSequence(gQueue, docAcc, TraversalRules.List, null,
['list-1', 'list-2', 'list-3']);
queueTraversalSequence(gQueue, docAcc, TraversalRules.ListItem, null,
['listitem-1-1', 'listitem-2-1', 'listitem-2-2',
'listitem-3-1', 'listitem-3-2', 'listitem-3-3',
'listitem-2-3']);
queueTraversalSequence(gQueue, docAcc, TraversalRules.Graphic, null,
['image-2', 'image-3']);
queueTraversalSequence(gQueue, docAcc, TraversalRules.Link, null,
['link-1', 'link-2', 'link-3']);
queueTraversalSequence(gQueue, docAcc, TraversalRules.Anchor, null,
['anchor-1', 'anchor-2']);
queueTraversalSequence(gQueue, docAcc, TraversalRules.Separator, null,
['separator-1', 'separator-2']);
queueTraversalSequence(gQueue, docAcc, TraversalRules.Table, null,
['table-1', 'table-2']);
gQueue.invoke();
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(function () {
/* We open a new browser because we need to test with a top-level content
document. */
openBrowserWindow(
doTest,
getRootDirectory(window.location.href) + "doc_traversal.html");
});
</script>
</head>
<body id="body">
<a target="_blank"
title="Add tests for AccessFu TraversalRules"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=933808">Mozilla Bug 933808</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
</body>
</html>

View File

@ -7,10 +7,6 @@ include $(topsrcdir)/config/makefiles/rcs.mk
PREF_JS_EXPORTS = $(srcdir)/b2g.js
ifdef ENABLE_MARIONETTE
DEFINES += -DENABLE_MARIONETTE=1
endif
ifndef LIBXUL_SDK
ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
@ -39,7 +35,6 @@ LOCAL_INCLUDES += -I$(topsrcdir)/xpcom/base
LOCAL_INCLUDES += -I$(topsrcdir)/xpcom/build
LOCAL_INCLUDES += -I$(DEPTH)/build
DEFINES += -DXPCOM_GLUE
STL_FLAGS=
LIBS += $(JEMALLOC_LIBS)
@ -83,12 +78,6 @@ include $(topsrcdir)/config/rules.mk
APP_ICON = b2g
DEFINES += \
-DAPP_NAME=$(MOZ_APP_NAME) \
-DAPP_VERSION=$(MOZ_APP_VERSION) \
-DMOZ_UPDATER=$(MOZ_UPDATER) \
$(NULL)
source_repo ?= $(call getSourceRepo,$(srcdir)/..)
ifneq (,$(filter http%,$(source_repo)))
DEFINES += -DMOZ_SOURCE_REPO="$(source_repo)"

View File

@ -12,3 +12,11 @@ if not CONFIG['LIBXUL_SDK']:
SOURCES += [
'nsBrowserApp.cpp',
]
if CONFIG['ENABLE_MARIONETTE']:
DEFINES['ENABLE_MARIONETTE'] = 1
DEFINES['XPCOM_GLUE'] = True
for var in ('MOZ_APP_NAME', 'MOZ_APP_VERSION', 'MOZ_UPDATER'):
DEFINES[var] = CONFIG[var]

View File

@ -1,8 +0,0 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DEFINES += -DAB_CD=$(MOZ_UI_LOCALE) \
-DPACKAGE=browser \
-DMOZ_APP_VERSION=$(MOZ_APP_VERSION) \
$(NULL)

View File

@ -4,3 +4,6 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DEFINES['AB_CD'] = CONFIG['MOZ_UI_LOCALE']
DEFINES['PACKAGE'] = 'browser'
DEFINES['MOZ_APP_VERSION'] = CONFIG['MOZ_APP_VERSION']

View File

@ -1,4 +1,4 @@
{
"revision": "74ed51578aa6d69a994d88be8d97f3b136288cd7",
"revision": "3fe38577e17209728a54b14624143dbf99ade2df",
"repo_path": "/integration/gaia-central"
}

View File

@ -4,18 +4,6 @@
GAIA_PATH := gaia/profile
ifeq ($(OS_ARCH),WINNT)
DEFINES += \
-DB2G_NAME=L\"$(MOZ_APP_NAME)-bin$(BIN_SUFFIX)\" \
-DGAIA_PATH=L\"$(subst /,\\\\,$(GAIA_PATH))\" \
$(NULL)
else # Non-windows machines use the same wrapper program
DEFINES += \
-DB2G_NAME=\"$(MOZ_APP_NAME)-bin$(BIN_SUFFIX)\" \
-DGAIA_PATH=\"$(GAIA_PATH)\" \
$(NULL)
endif
ifdef .PYMAKE
# For use of GNU make in pymake builds.
GAIA_MAKE=$(GMAKE)

View File

@ -10,7 +10,11 @@ if CONFIG['OS_ARCH'] == 'WINNT':
SOURCES += [
'run-b2g.cpp',
]
DEFINES['B2G_NAME'] = 'L"%s-bin%s"' % (PROGRAM, CONFIG['BIN_SUFFIX'])
DEFINES['GAIA_PATH'] = 'L"gaia\\\\profile"'
else:
SOURCES += [
'run-b2g.c',
]
DEFINES['B2G_NAME'] = '"%s-bin%s"' % (PROGRAM, CONFIG['BIN_SUFFIX'])
DEFINES['GAIA_PATH'] = '"gaia/profile"'

View File

@ -4,10 +4,6 @@
dist_dest = $(DIST)/$(MOZ_MACBUNDLE_NAME)
ifdef ENABLE_MARIONETTE
DEFINES += -DENABLE_MARIONETTE=1
endif
PREF_JS_EXPORTS = $(srcdir)/profile/firefox.js \
$(NULL)
@ -17,7 +13,6 @@ AB_CD = en-US
DEFINES += \
-DAB_CD=$(AB_CD) \
-DAPP_VERSION="$(MOZ_APP_VERSION)" \
-DFIREFOX_ICO=\"$(DIST)/branding/firefox.ico\" \
-DDOCUMENT_ICO=\"$(DIST)/branding/document.ico\" \
-DNEWWINDOW_ICO=\"$(DIST)/branding/newwindow.ico\" \
@ -25,13 +20,8 @@ DEFINES += \
-DPBMODE_ICO=\"$(DIST)/branding/pbmode.ico\" \
$(NULL)
ifdef MOZILLA_OFFICIAL
DEFINES += -DMOZILLA_OFFICIAL
endif
ifdef LIBXUL_SDK #{
PREF_JS_EXPORTS += $(srcdir)/profile/channel-prefs.js
DEFINES += -DLIBXUL_SDK
endif #} LIBXUL_SDK
# Build a binary bootstrapping with XRE_main
@ -43,7 +33,6 @@ LOCAL_INCLUDES += \
-I$(DEPTH)/build \
$(NULL)
DEFINES += -DXPCOM_GLUE
STL_FLAGS=
LIBS += \

View File

@ -11,3 +11,14 @@ PROGRAM = CONFIG['MOZ_APP_NAME']
SOURCES += [
'nsBrowserApp.cpp',
]
if CONFIG['ENABLE_MARIONETTE']:
DEFINES['ENABLE_MARIONETTE'] = 1
DEFINES['APP_VERSION'] = CONFIG['MOZ_APP_VERSION']
for var in ('MOZILLA_OFFICIAL', 'LIBXUL_SDK'):
if CONFIG[var]:
DEFINES[var] = True
DEFINES['XPCOM_GLUE'] = True

View File

@ -1,34 +0,0 @@
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
include $(topsrcdir)/config/config.mk
abs_srcdir = $(abspath $(srcdir))
include $(topsrcdir)/config/rules.mk
PRE_RELEASE_SUFFIX := ""
DEFINES += \
-DMOZ_APP_VERSION=$(MOZ_APP_VERSION) \
-DAPP_LICENSE_BLOCK=$(abs_srcdir)/content/overrides/app-license.html \
-DPRE_RELEASE_SUFFIX="$(PRE_RELEASE_SUFFIX)" \
$(NULL)
ifneq (,$(filter windows gtk2 gtk3 cocoa, $(MOZ_WIDGET_TOOLKIT)))
DEFINES += -DHAVE_SHELL_SERVICE=1
endif
ifneq (,$(filter windows cocoa gtk2 gtk3, $(MOZ_WIDGET_TOOLKIT)))
DEFINES += -DCONTEXT_COPY_IMAGE_CONTENTS=1
endif
ifneq (,$(filter windows cocoa, $(MOZ_WIDGET_TOOLKIT)))
DEFINES += -DCAN_DRAW_IN_TITLEBAR=1
endif
ifneq (,$(filter windows gtk2 gtk3, $(MOZ_WIDGET_TOOLKIT)))
DEFINES += -DMENUBAR_CAN_AUTOHIDE=1
endif

View File

@ -27,19 +27,19 @@
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="gBrowserInit.onLoad()" onunload="gBrowserInit.onUnload()" onclose="return WindowIsClosing();"
title="&mainWindow.title;@PRE_RELEASE_SUFFIX@"
title_normal="&mainWindow.title;@PRE_RELEASE_SUFFIX@"
title="&mainWindow.title;"
title_normal="&mainWindow.title;"
#ifdef XP_MACOSX
title_privatebrowsing="&mainWindow.title;@PRE_RELEASE_SUFFIX@&mainWindow.titlemodifiermenuseparator;&mainWindow.titlePrivateBrowsingSuffix;"
titledefault="&mainWindow.title;@PRE_RELEASE_SUFFIX@"
title_privatebrowsing="&mainWindow.title;&mainWindow.titlemodifiermenuseparator;&mainWindow.titlePrivateBrowsingSuffix;"
titledefault="&mainWindow.title;"
titlemodifier=""
titlemodifier_normal=""
titlemodifier_privatebrowsing="&mainWindow.titlePrivateBrowsingSuffix;"
#else
title_privatebrowsing="&mainWindow.titlemodifier;@PRE_RELEASE_SUFFIX@ &mainWindow.titlePrivateBrowsingSuffix;"
titlemodifier="&mainWindow.titlemodifier;@PRE_RELEASE_SUFFIX@"
titlemodifier_normal="&mainWindow.titlemodifier;@PRE_RELEASE_SUFFIX@"
titlemodifier_privatebrowsing="&mainWindow.titlemodifier;@PRE_RELEASE_SUFFIX@ &mainWindow.titlePrivateBrowsingSuffix;"
title_privatebrowsing="&mainWindow.titlemodifier; &mainWindow.titlePrivateBrowsingSuffix;"
titlemodifier="&mainWindow.titlemodifier;"
titlemodifier_normal="&mainWindow.titlemodifier;"
titlemodifier_privatebrowsing="&mainWindow.titlemodifier; &mainWindow.titlePrivateBrowsingSuffix;"
#endif
#ifdef CAN_DRAW_IN_TITLEBAR
#ifdef XP_WIN

View File

@ -18,7 +18,7 @@
windowtype="Social:Chat"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&mainWindow.title;@PRE_RELEASE_SUFFIX@"
title="&mainWindow.title;"
onload="gChatWindow.onLoad();"
onunload="gChatWindow.onUnload();"
macanimationtype="document"

View File

@ -4088,41 +4088,30 @@
return;
}
let paints = {};
let intervals = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils)
.stopFrameTimeRecording(aTab._recordingHandle, paints);
.stopFrameTimeRecording(aTab._recordingHandle);
delete aTab._recordingHandle;
paints = paints.value; // The result array itself.
let frameCount = intervals.length;
if (this._tabAnimationLoggingEnabled) {
let msg = "Tab " + (aTab.closing ? "close" : "open") + " (Frame-interval / paint-processing):\n";
let msg = "Tab " + (aTab.closing ? "close" : "open") + " (Frame-interval):\n";
for (let i = 0; i < frameCount; i++) {
msg += Math.round(intervals[i]) + " / " + Math.round(paints[i]) + "\n";
msg += Math.round(intervals[i]) + "\n";
}
Services.console.logStringMessage(msg);
}
// For telemetry, the first frame interval is not useful since it may represent an interval
// to a relatively old frame (prior to recording start). So we'll ignore it for the average.
// But if we recorded only 1 frame (very rare), then the first paint duration is a good
// representative of the first frame interval for our cause (indicates very bad animation).
// First paint duration is always useful for us.
if (frameCount > 0) {
if (frameCount > 1) {
let averageInterval = 0;
let averagePaint = paints[0];
for (let i = 1; i < frameCount; i++) {
averageInterval += intervals[i];
averagePaint += paints[i];
};
averagePaint /= frameCount;
averageInterval = (frameCount == 1)
? averagePaint
: averageInterval / (frameCount - 1);
averageInterval = averageInterval / (frameCount - 1);
Services.telemetry.getHistogramById("FX_TAB_ANIM_ANY_FRAME_INTERVAL_MS").add(averageInterval);
Services.telemetry.getHistogramById("FX_TAB_ANIM_ANY_FRAME_PAINT_MS").add(averagePaint);
if (aTab._recordingTabOpenPlain) {
delete aTab._recordingTabOpenPlain;
@ -4130,7 +4119,6 @@
// easier to overview the data without slicing by it. Hence the additional histograms with _PREVIEW.
let preview = this._browserNewtabpageEnabled ? "_PREVIEW" : "";
Services.telemetry.getHistogramById("FX_TAB_ANIM_OPEN" + preview + "_FRAME_INTERVAL_MS").add(averageInterval);
Services.telemetry.getHistogramById("FX_TAB_ANIM_OPEN" + preview + "_FRAME_PAINT_MS").add(averagePaint);
}
}
]]>

View File

@ -21,3 +21,16 @@ BROWSER_CHROME_MANIFESTS += [
'content/test/newtab/browser.ini',
'content/test/social/browser.ini',
]
DEFINES['MOZ_APP_VERSION'] = CONFIG['MOZ_APP_VERSION']
DEFINES['APP_LICENSE_BLOCK'] = '%s/content/overrides/app-license.html' % SRCDIR
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('windows', 'gtk2', 'gtk3', 'cocoa'):
DEFINES['HAVE_SHELL_SERVICE'] = 1
DEFINES['CONTEXT_COPY_IMAGE_CONTENTS'] = 1
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('windows', 'cocoa'):
DEFINES['CAN_DRAW_IN_TITLEBAR'] = 1
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('windows', 'gtk2', 'gtk3'):
DEFINES['MENUBAR_CAN_AUTOHIDE'] = 1

View File

@ -2,4 +2,4 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DEFINES += -DAB_CD=$(AB_CD) -DMOZ_DISTRIBUTION_ID_UNQUOTED=$(MOZ_DISTRIBUTION_ID)
DEFINES += -DAB_CD=$(AB_CD)

View File

@ -4,3 +4,4 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DEFINES['MOZ_DISTRIBUTION_ID_UNQUOTED'] = CONFIG['MOZ_DISTRIBUTION_ID']

View File

@ -2,4 +2,4 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DEFINES += -DAB_CD=$(AB_CD) -DMOZ_DISTRIBUTION_ID_UNQUOTED=$(MOZ_DISTRIBUTION_ID)
DEFINES += -DAB_CD=$(AB_CD)

View File

@ -4,3 +4,4 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DEFINES['MOZ_DISTRIBUTION_ID_UNQUOTED'] = CONFIG['MOZ_DISTRIBUTION_ID']

View File

@ -2,4 +2,4 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DEFINES += -DAB_CD=$(AB_CD) -DMOZ_DISTRIBUTION_ID_UNQUOTED=$(MOZ_DISTRIBUTION_ID)
DEFINES += -DAB_CD=$(AB_CD)

View File

@ -4,3 +4,4 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DEFINES['MOZ_DISTRIBUTION_ID_UNQUOTED'] = CONFIG['MOZ_DISTRIBUTION_ID']

View File

@ -2,10 +2,4 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DEFINES += \
-DMOZ_APP_NAME=$(MOZ_APP_NAME) \
-DMOZ_MACBUNDLE_NAME=$(MOZ_MACBUNDLE_NAME) \
$(NULL)
LOCAL_INCLUDES = -I$(srcdir)/../../build

View File

@ -19,3 +19,6 @@ EXTRA_PP_COMPONENTS += [
]
FINAL_LIBRARY = 'browsercomps'
for var in ('MOZ_APP_NAME', 'MOZ_MACBUNDLE_NAME'):
DEFINES[var] = CONFIG[var]

View File

@ -1,12 +0,0 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
ifeq ($(OS_ARCH),WINNT)
DEFINES += -DHAS_IE_MIGRATOR -DHAS_SAFARI_MIGRATOR
endif
ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
DEFINES += -DHAS_SAFARI_MIGRATOR
endif

View File

@ -18,6 +18,7 @@ if CONFIG['OS_ARCH'] == 'WINNT':
EXTRA_COMPONENTS += [
'IEProfileMigrator.js',
]
DEFINES['HAS_IE_MIGRATOR'] = True
EXTRA_PP_COMPONENTS += [
'BrowserProfileMigrators.manifest',
@ -28,11 +29,13 @@ if CONFIG['OS_ARCH'] == 'WINNT':
EXTRA_PP_COMPONENTS += [
'SafariProfileMigrator.js',
]
DEFINES['HAS_SAFARI_MIGRATOR'] = True
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
EXTRA_PP_COMPONENTS += [
'SafariProfileMigrator.js',
]
DEFINES['HAS_SAFARI_MIGRATOR'] = True
EXTRA_PP_JS_MODULES += [
'MigrationUtils.jsm',

View File

@ -1,15 +0,0 @@
# -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
include $(topsrcdir)/config/rules.mk
DEFINES += \
-DMOZ_APP_NAME=$(MOZ_APP_NAME) \
-DMOZ_MACBUNDLE_NAME=$(MOZ_MACBUNDLE_NAME) \
$(NULL)
ifneq (,$(filter windows gtk2 gtk3 cocoa, $(MOZ_WIDGET_TOOLKIT)))
DEFINES += -DHAVE_SHELL_SERVICE=1
endif

View File

@ -1,14 +0,0 @@
# -- This Source Code Form is subject to the terms of the Mozilla Public
# - License, v. 2.0. If a copy of the MPL was not distributed with this file,
# - You can obtain one at http://mozilla.org/MPL/2.0/.
include $(topsrcdir)/config/rules.mk
DEFINES += \
-DMOZ_APP_NAME=$(MOZ_APP_NAME) \
-DMOZ_MACBUNDLE_NAME=$(MOZ_MACBUNDLE_NAME) \
$(NULL)
ifneq (,$(filter windows gtk2 cocoa, $(MOZ_WIDGET_TOOLKIT)))
DEFINES += -DHAVE_SHELL_SERVICE=1
endif

View File

@ -4,3 +4,8 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
for var in ('MOZ_APP_NAME', 'MOZ_MACBUNDLE_NAME'):
DEFINES[var] = CONFIG[var]
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('windows', 'gtk2', 'cocoa'):
DEFINES['HAVE_SHELL_SERVICE'] = 1

View File

@ -10,3 +10,9 @@ BROWSER_CHROME_MANIFESTS += [
'in-content/tests/browser.ini',
'tests/browser.ini',
]
for var in ('MOZ_APP_NAME', 'MOZ_MACBUNDLE_NAME'):
DEFINES[var] = CONFIG[var]
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('windows', 'gtk2', 'gtk3', 'cocoa'):
DEFINES['HAVE_SHELL_SERVICE'] = 1

View File

@ -5,9 +5,6 @@
include $(topsrcdir)/config/rules.mk
DEFINES += -DMOZ_APP_NAME=\"$(MOZ_APP_NAME)\" \
-DMOZ_APP_VERSION=\"$(MOZ_APP_VERSION)\"
CXXFLAGS += $(TK_CFLAGS)
clobber::

View File

@ -24,3 +24,6 @@ EXTRA_COMPONENTS += [
'nsSetDefaultBrowser.js',
'nsSetDefaultBrowser.manifest',
]
for var in ('MOZ_APP_NAME', 'MOZ_APP_VERSION'):
DEFINES[var] = '"%s"' % CONFIG[var]

View File

@ -18,6 +18,5 @@ endif
ifneq (Darwin,$(OS_ARCH))
MOCHITEST_BROWSER_FILES += \
browser_dbg_break-on-dom-event.js \
browser_dbg_event-listeners.js \
$(NULL)
endif

View File

@ -97,6 +97,7 @@ skip-if = true
[browser_dbg_debugger-statement.js]
[browser_dbg_editor-contextmenu.js]
[browser_dbg_editor-mode.js]
[browser_dbg_event-listeners.js]
[browser_dbg_function-display-name.js]
[browser_dbg_globalactor.js]
[browser_dbg_host-layout.js]

View File

@ -8,8 +8,6 @@ CONFIG_DIR = instgen
SFX_MODULE = $(topsrcdir)/other-licenses/7zstub/firefox/7zSD.sfx
APP_VERSION := $(shell cat $(srcdir)/../../config/version.txt)
DEFINES += -DAPP_VERSION=$(APP_VERSION)
PRE_RELEASE_SUFFIX := ""
DEFINES += -DPRE_RELEASE_SUFFIX="$(PRE_RELEASE_SUFFIX)"
INSTALLER_FILES = \
app.tag \

View File

@ -32,8 +32,7 @@
!define AppRegName "Firefox"
!define BrandShortName "@MOZ_APP_DISPLAYNAME@"
!define PreReleaseSuffix "@PRE_RELEASE_SUFFIX@"
!define BrandFullName "${BrandFullNameInternal}${PreReleaseSuffix}"
!define BrandFullName "${BrandFullNameInternal}"
!define NO_UNINSTALL_SURVEY
@ -60,15 +59,6 @@
!define BaseURLStubPing "http://download-stats.mozilla.org/stub"
# NO_INSTDIR_FROM_REG is defined for pre-releases which have a PreReleaseSuffix
# (e.g. Alpha X, Beta X, etc.) to prevent finding a non-default installation
# directory in the registry and using that as the default. This prevents
# Beta releases built with official branding from finding an existing install
# of an official release and defaulting to its installation directory.
!if "@PRE_RELEASE_SUFFIX@" != ""
!define NO_INSTDIR_FROM_REG
!endif
# ARCH is used when it is necessary to differentiate the x64 registry keys from
# the x86 registry keys (e.g. the uninstall registry key).
#ifdef HAVE_64BIT_OS

View File

@ -7,12 +7,8 @@ include $(topsrcdir)/config/rules.mk
#########################################
# application.ini
ifdef MOZILLA_OFFICIAL
DEFINES += -DMOZILLA_OFFICIAL
endif
GRE_BUILDID := $(shell cat $(DEPTH)/config/buildid)
DEFINES += -DGRE_MILESTONE=$(GRE_MILESTONE) -DGRE_BUILDID=$(GRE_BUILDID)
DEFINES += -DGRE_BUILDID=$(GRE_BUILDID)
# 'application.ini' breaks firefox build config. So we use something different.
metroapp.ini: metroapp.ini.in $(DEPTH)/config/buildid $(topsrcdir)/config/milestone.txt

View File

@ -1,10 +0,0 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
include $(topsrcdir)/config/config.mk
DEFINES += -DAB_CD=$(MOZ_UI_LOCALE) \
-DPACKAGE=browser \
-DMOZ_APP_VERSION=$(MOZ_APP_VERSION) \
$(NULL)

View File

@ -8,3 +8,7 @@ METRO_CHROME_MANIFESTS += ['tests/mochiperf/metro.ini', 'tests/mochitest/metro.i
XPCSHELL_TESTS_MANIFESTS += ['tests/unit/xpcshell.ini']
DIST_SUBDIR = 'metro'
DEFINES['AB_CD'] = CONFIG['MOZ_UI_LOCALE']
DEFINES['PACKAGE'] = 'browser'
DEFINES['MOZ_APP_VERSION'] = CONFIG['MOZ_APP_VERSION']

View File

@ -17,3 +17,8 @@ if CONFIG['OS_ARCH'] == 'WINNT':
DIRS += ['shell']
DIST_SUBDIR = 'metro'
if CONFIG['MOZILLA_OFFICIAL']:
DEFINES['MOZILLA_OFFICIAL'] = True
DEFINES['GRE_MILESTONE'] = CONFIG['GRE_MILESTONE']

View File

@ -21,5 +21,3 @@ OS_LIBS = \
advapi32.lib \
wininet.lib \
$(NULL)
DEFINES += -DUNICODE -D_UNICODE -DNS_NO_XPCOM

View File

@ -13,3 +13,6 @@ SOURCES += [
# We want this exe in dist/bin
DIST_SUBDIR = ''
for var in ('UNICODE', '_UNICODE', 'NS_NO_XPCOM'):
DEFINES[var] = True

View File

@ -14,5 +14,3 @@ OS_LIBS = \
shell32.lib \
propsys.lib \
$(NULL)
DEFINES += -DUNICODE -D_UNICODE

View File

@ -11,3 +11,6 @@ SOURCES += [
]
DIST_SUBDIR = 'metro/install'
for var in ('UNICODE', '_UNICODE'):
DEFINES[var] = True

View File

@ -21,5 +21,3 @@ OS_LIBS = \
propsys.lib \
advapi32.lib \
$(NULL)
DEFINES += -DUNICODE -D_UNICODE

View File

@ -12,3 +12,6 @@ SOURCES += [
# We want this exe in dist/bin
DIST_SUBDIR = ''
for var in ('UNICODE', '_UNICODE'):
DEFINES[var] = True

View File

@ -1,9 +0,0 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
include $(topsrcdir)/config/config.mk
ifdef MOZILLA_OFFICIAL
DEFINES += -DMOZILLA_OFFICIAL=1
endif

View File

@ -34,3 +34,5 @@ EXTRA_PP_JS_MODULES += [
'RecentWindow.jsm',
]
if CONFIG['MOZILLA_OFFICIAL']:
DEFINES['MOZILLA_OFFICIAL'] = 1

View File

@ -24,9 +24,8 @@ endif
APP_BUILDID := $(shell cat $(DEPTH)/config/buildid)
APP_INI_DEPS += $(DEPTH)/config/buildid
DEFINES += -DGRE_MILESTONE=$(GRE_MILESTONE) -DAPP_BUILDID=$(APP_BUILDID)
DEFINES += -DAPP_BUILDID=$(APP_BUILDID)
DEFINES += -DMOZ_APP_VERSION="$(MOZ_APP_VERSION)"
APP_INI_DEPS += $(DEPTH)/config/autoconf.mk
MOZ_SOURCE_STAMP := $(firstword $(shell cd $(topsrcdir)/$(MOZ_BUILD_APP)/.. && hg parent --template="{node|short}\n" 2>/dev/null))
@ -39,34 +38,6 @@ ifneq (,$(source_repo))
DEFINES += -DMOZ_SOURCE_REPO="$(source_repo)"
endif
DEFINES += \
-DMOZ_APP_BASENAME="$(MOZ_APP_BASENAME)" \
-DMOZ_APP_VENDOR="$(MOZ_APP_VENDOR)" \
-DMOZ_APP_ID="$(MOZ_APP_ID)" \
-DMAR_CHANNEL_ID="$(MAR_CHANNEL_ID)" \
-DACCEPTED_MAR_CHANNEL_IDS="$(ACCEPTED_MAR_CHANNEL_IDS)" \
$(NULL)
ifeq ($(MOZ_BUILD_APP),browser)
DEFINES += -DMOZ_BUILD_APP_IS_BROWSER
endif
ifdef MOZ_APP_PROFILE
DEFINES += -DMOZ_APP_PROFILE="$(MOZ_APP_PROFILE)"
endif
ifdef MOZ_CRASHREPORTER
DEFINES += -DMOZ_CRASHREPORTER
endif
ifdef MOZ_PROFILE_MIGRATOR
DEFINES += -DMOZ_PROFILE_MIGRATOR
endif
ifdef MOZ_EXTENSION_MANAGER
DEFINES += -DMOZ_EXTENSION_MANAGER
endif
endif
# Put a useful .gdbinit in the bin directory, to be picked up automatically
@ -123,8 +94,6 @@ ifdef MOZ_APP_BASENAME
$(FINAL_TARGET)/application.ini: $(APP_INI_DEPS)
ifdef MOZ_APP_STATIC_INI
DEFINES += -DMOZ_APP_STATIC_INI
application.ini.h: appini_header.py $(FINAL_TARGET)/application.ini
$(PYTHON) $^ > $@
export:: application.ini.h

View File

@ -570,14 +570,7 @@ class ShutdownLeaks(object):
self.seenShutdown = True
def process(self):
leakingTests = self._parseLeakingTests()
if leakingTests:
totalWindows = sum(len(test["leakedWindows"]) for test in leakingTests)
totalDocShells = sum(len(test["leakedDocShells"]) for test in leakingTests)
self.logger("TEST-UNEXPECTED-FAIL | ShutdownLeaks | leaked %d DOMWindow(s) and %d DocShell(s) until shutdown", totalWindows, totalDocShells)
for test in leakingTests:
for test in self._parseLeakingTests():
for url, count in self._zipLeakedWindows(test["leakedWindows"]):
self.logger("TEST-UNEXPECTED-FAIL | %s | leaked %d window(s) until shutdown [url = %s]", test["fileName"], count, url)

View File

@ -75,10 +75,6 @@ JAVAFILES += \
$(testconstants-dep) \
$(NULL)
DEFINES += \
-DANDROID_PACKAGE_NAME=$(ANDROID_PACKAGE_NAME) \
$(NULL)
include $(topsrcdir)/config/rules.mk
tools:: $(ANDROID_APK_NAME).apk

View File

@ -7,3 +7,5 @@
ANDROID_RESFILES = [
'res/values/strings.xml',
]
DEFINES['ANDROID_PACKAGE_NAME'] = CONFIG['ANDROID_PACKAGE_NAME']

View File

@ -22,3 +22,19 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
'mobile/robocop',
]
for var in ('GRE_MILESTONE', 'MOZ_APP_VERSION', 'MOZ_APP_BASENAME',
'MOZ_APP_VENDOR', 'MOZ_APP_ID', 'MAR_CHANNEL_ID',
'ACCEPTED_MAR_CHANNEL_IDS'):
DEFINES[var] = CONFIG[var]
if CONFIG['MOZ_BUILD_APP'] == 'browser':
DEFINES['MOZ_BUILD_APP_IS_BROWSER'] = True
if CONFIG['MOZ_APP_PROFILE']:
DEFINES['MOZ_APP_PROFILE'] = CONFIG['MOZ_APP_PROFILE']
for var in ('MOZ_CRASHREPORTER', 'MOZ_PROFILE_MIGRATOR',
'MOZ_EXTENSION_MANAGER', 'MOZ_APP_STATIC_INI'):
if CONFIG[var]:
DEFINES[var] = True

View File

@ -11,6 +11,5 @@ LIBRARY = $(LIB_PREFIX)$(LIBRARY_NAME).$(LIB_SUFFIX)
include $(topsrcdir)/config/rules.mk
DEFINES += -D_GNU_SOURCE
CXXFLAGS += -fuse-cxa-atexit
INCLUDES += -I$(srcdir)/stlport

View File

@ -45,3 +45,5 @@ SOURCES += [
'src/c_locale.c',
'src/cxa.c',
]
DEFINES['_GNU_SOURCE'] = True

View File

@ -15,8 +15,6 @@ WRAP_LDFLAGS=
include $(topsrcdir)/config/rules.mk
DEFINES += -DELFHACK_BUILD
test-array$(DLL_SUFFIX) test-ctors$(DLL_SUFFIX): %$(DLL_SUFFIX): %.$(OBJ_SUFFIX) elfhack
$(MKSHLIB) $(LDFLAGS) $< -nostartfiles
@echo ===

View File

@ -15,6 +15,4 @@ $(CSRCS): %.c: ../inject.c
GARBAGE += $(CSRCS)
DEFINES += -DELFHACK_BUILD
CFLAGS := -O2 -fno-stack-protector $(filter -m% -I%,$(CFLAGS))

View File

@ -16,3 +16,5 @@ else:
GENERATED_SOURCES += [
"%s.c" % cpu,
]
DEFINES['ELFHACK_BUILD'] = True

View File

@ -23,3 +23,5 @@ HOST_SOURCES += [
]
HOST_PROGRAM = 'elfhack'
DEFINES['ELFHACK_BUILD'] = True

View File

@ -35,11 +35,11 @@ NS_IMPL_CI_INTERFACE_GETTER2(nsNullPrincipal,
nsIPrincipal,
nsISerializable)
NS_IMETHODIMP_(nsrefcnt)
NS_IMETHODIMP_(nsrefcnt)
nsNullPrincipal::AddRef()
{
NS_PRECONDITION(int32_t(refcount) >= 0, "illegal refcnt");
nsrefcnt count = PR_ATOMIC_INCREMENT(&refcount);
nsrefcnt count = ++refcount;
NS_LOG_ADDREF(this, count, "nsNullPrincipal", sizeof(*this));
return count;
}
@ -48,7 +48,7 @@ NS_IMETHODIMP_(nsrefcnt)
nsNullPrincipal::Release()
{
NS_PRECONDITION(0 != refcount, "dup release");
nsrefcnt count = PR_ATOMIC_DECREMENT(&refcount);
nsrefcnt count = --refcount;
NS_LOG_RELEASE(this, count, "nsNullPrincipal");
if (count == 0) {
delete this;

View File

@ -51,7 +51,7 @@ nsBasePrincipal::AddRef()
{
NS_PRECONDITION(int32_t(refcount) >= 0, "illegal refcnt");
// XXXcaa does this need to be threadsafe? See bug 143559.
nsrefcnt count = PR_ATOMIC_INCREMENT(&refcount);
nsrefcnt count = ++refcount;
NS_LOG_ADDREF(this, count, "nsBasePrincipal", sizeof(*this));
return count;
}
@ -60,7 +60,7 @@ NS_IMETHODIMP_(nsrefcnt)
nsBasePrincipal::Release()
{
NS_PRECONDITION(0 != refcount, "dup release");
nsrefcnt count = PR_ATOMIC_DECREMENT(&refcount);
nsrefcnt count = --refcount;
NS_LOG_RELEASE(this, count, "nsBasePrincipal");
if (count == 0) {
delete this;

View File

@ -29,11 +29,11 @@ NS_IMPL_CI_INTERFACE_GETTER2(nsSystemPrincipal,
nsIPrincipal,
nsISerializable)
NS_IMETHODIMP_(nsrefcnt)
NS_IMETHODIMP_(nsrefcnt)
nsSystemPrincipal::AddRef()
{
NS_PRECONDITION(int32_t(refcount) >= 0, "illegal refcnt");
nsrefcnt count = PR_ATOMIC_INCREMENT(&refcount);
nsrefcnt count = ++refcount;
NS_LOG_ADDREF(this, count, "nsSystemPrincipal", sizeof(*this));
return count;
}
@ -42,7 +42,7 @@ NS_IMETHODIMP_(nsrefcnt)
nsSystemPrincipal::Release()
{
NS_PRECONDITION(0 != refcount, "dup release");
nsrefcnt count = PR_ATOMIC_DECREMENT(&refcount);
nsrefcnt count = --refcount;
NS_LOG_RELEASE(this, count, "nsSystemPrincipal");
if (count == 0) {
delete this;

View File

@ -907,7 +907,7 @@ public:
* this document. If you're not absolutely sure you need this, use
* GetWindow().
*/
nsPIDOMWindow* GetInnerWindow()
nsPIDOMWindow* GetInnerWindow() const
{
return mRemovedFromDocShell ? nullptr : mWindow;
}
@ -1613,7 +1613,10 @@ public:
/**
* Return true when this document is active, i.e., the active document
* in a content viewer.
* in a content viewer. Note that this will return true for bfcached
* documents, so this does NOT match the "active document" concept in
* the WHATWG spec. That would correspond to GetInnerWindow() &&
* GetInnerWindow()->IsCurrentInnerWindow().
*/
bool IsActive() const { return mDocumentContainer && !mRemovedFromDocShell; }

View File

@ -10,7 +10,7 @@
#include "WebGLContextUtils.h"
#include "WebGLBuffer.h"
#include "WebGLVertexAttribData.h"
#include "WebGLMemoryReporterWrapper.h"
#include "WebGLMemoryTracker.h"
#include "WebGLFramebuffer.h"
#include "WebGLVertexArray.h"
#include "WebGLQuery.h"
@ -178,7 +178,7 @@ WebGLContext::WebGLContext()
mPixelStorePackAlignment = 4;
mPixelStoreUnpackAlignment = 4;
WebGLMemoryReporterWrapper::AddWebGLContext(this);
WebGLMemoryTracker::AddWebGLContext(this);
mAllowRestore = true;
mContextLossTimerRunning = false;
@ -212,7 +212,7 @@ WebGLContext::WebGLContext()
WebGLContext::~WebGLContext()
{
DestroyResourcesAndContext();
WebGLMemoryReporterWrapper::RemoveWebGLContext(this);
WebGLMemoryTracker::RemoveWebGLContext(this);
TerminateContextLossTimer();
mContextRestorer = nullptr;
}
@ -669,8 +669,8 @@ void WebGLContext::LoseOldestWebGLContextIfLimitExceeded()
// when choosing which one to lose first.
UpdateLastUseIndex();
WebGLMemoryReporterWrapper::ContextsArrayType &contexts
= WebGLMemoryReporterWrapper::Contexts();
WebGLMemoryTracker::ContextsArrayType &contexts
= WebGLMemoryTracker::Contexts();
// quick exit path, should cover a majority of cases
if (contexts.Length() <= kMaxWebGLContextsPerPrincipal) {

View File

@ -122,7 +122,7 @@ class WebGLContext :
{
friend class WebGLContextUserData;
friend class WebGLMemoryPressureObserver;
friend class WebGLMemoryReporterWrapper;
friend class WebGLMemoryTracker;
friend class WebGLExtensionLoseContext;
friend class WebGLExtensionCompressedTextureS3TC;
friend class WebGLExtensionCompressedTextureATC;

View File

@ -4,7 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "WebGLContext.h"
#include "WebGLMemoryReporterWrapper.h"
#include "WebGLMemoryTracker.h"
#include "nsIMemoryReporter.h"
using namespace mozilla;
@ -37,7 +37,7 @@ WebGLMemoryReporter::CollectReports(nsIMemoryReporterCallback* aCb,
REPORT("webgl-texture-memory",
nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_BYTES,
WebGLMemoryReporterWrapper::GetTextureMemoryUsed(),
WebGLMemoryTracker::GetTextureMemoryUsed(),
"Memory used by WebGL textures.The OpenGL"
" implementation is free to store these textures in either video"
" memory or main memory. This measurement is only a lower bound,"
@ -46,12 +46,12 @@ WebGLMemoryReporter::CollectReports(nsIMemoryReporterCallback* aCb,
REPORT("webgl-texture-count",
nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_COUNT,
WebGLMemoryReporterWrapper::GetTextureCount(),
WebGLMemoryTracker::GetTextureCount(),
"Number of WebGL textures.");
REPORT("webgl-buffer-memory",
nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_BYTES,
WebGLMemoryReporterWrapper::GetBufferMemoryUsed(),
WebGLMemoryTracker::GetBufferMemoryUsed(),
"Memory used by WebGL buffers. The OpenGL"
" implementation is free to store these buffers in either video"
" memory or main memory. This measurement is only a lower bound,"
@ -60,7 +60,7 @@ WebGLMemoryReporter::CollectReports(nsIMemoryReporterCallback* aCb,
REPORT("explicit/webgl/buffer-cache-memory",
nsIMemoryReporter::KIND_HEAP, nsIMemoryReporter::UNITS_BYTES,
WebGLMemoryReporterWrapper::GetBufferCacheMemoryUsed(),
WebGLMemoryTracker::GetBufferCacheMemoryUsed(),
"Memory used by WebGL buffer caches. The WebGL"
" implementation caches the contents of element array buffers"
" only.This adds up with the webgl-buffer-memory value, but"
@ -69,12 +69,12 @@ WebGLMemoryReporter::CollectReports(nsIMemoryReporterCallback* aCb,
REPORT("webgl-buffer-count",
nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_COUNT,
WebGLMemoryReporterWrapper::GetBufferCount(),
WebGLMemoryTracker::GetBufferCount(),
"Number of WebGL buffers.");
REPORT("webgl-renderbuffer-memory",
nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_BYTES,
WebGLMemoryReporterWrapper::GetRenderbufferMemoryUsed(),
WebGLMemoryTracker::GetRenderbufferMemoryUsed(),
"Memory used by WebGL renderbuffers. The OpenGL"
" implementation is free to store these renderbuffers in either"
" video memory or main memory. This measurement is only a lower"
@ -83,23 +83,23 @@ WebGLMemoryReporter::CollectReports(nsIMemoryReporterCallback* aCb,
REPORT("webgl-renderbuffer-count",
nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_COUNT,
WebGLMemoryReporterWrapper::GetRenderbufferCount(),
WebGLMemoryTracker::GetRenderbufferCount(),
"Number of WebGL renderbuffers.");
REPORT("explicit/webgl/shader",
nsIMemoryReporter::KIND_HEAP, nsIMemoryReporter::UNITS_BYTES,
WebGLMemoryReporterWrapper::GetShaderSize(),
WebGLMemoryTracker::GetShaderSize(),
"Combined size of WebGL shader ASCII sources and translation"
" logs cached on the heap.");
REPORT("webgl-shader-count",
nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_COUNT,
WebGLMemoryReporterWrapper::GetShaderCount(),
WebGLMemoryTracker::GetShaderCount(),
"Number of WebGL shaders.");
REPORT("webgl-context-count",
nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_COUNT,
WebGLMemoryReporterWrapper::GetContextCount(),
WebGLMemoryTracker::GetContextCount(),
"Number of WebGL contexts.");
#undef REPORT
@ -107,23 +107,25 @@ WebGLMemoryReporter::CollectReports(nsIMemoryReporterCallback* aCb,
return NS_OK;
}
WebGLMemoryReporterWrapper* WebGLMemoryReporterWrapper::sUniqueInstance = nullptr;
NS_IMPL_ISUPPORTS1(WebGLMemoryTracker, nsISupports)
WebGLMemoryReporterWrapper* WebGLMemoryReporterWrapper::UniqueInstance()
StaticRefPtr<WebGLMemoryTracker> WebGLMemoryTracker::sUniqueInstance;
WebGLMemoryTracker* WebGLMemoryTracker::UniqueInstance()
{
if (!sUniqueInstance) {
sUniqueInstance = new WebGLMemoryReporterWrapper;
sUniqueInstance = new WebGLMemoryTracker;
}
return sUniqueInstance;
}
WebGLMemoryReporterWrapper::WebGLMemoryReporterWrapper()
WebGLMemoryTracker::WebGLMemoryTracker()
{
mReporter = new WebGLMemoryReporter;
NS_RegisterMemoryReporter(mReporter);
}
WebGLMemoryReporterWrapper::~WebGLMemoryReporterWrapper()
WebGLMemoryTracker::~WebGLMemoryTracker()
{
NS_UnregisterMemoryReporter(mReporter);
}
@ -131,7 +133,7 @@ WebGLMemoryReporterWrapper::~WebGLMemoryReporterWrapper()
NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(WebGLBufferMallocSizeOf)
int64_t
WebGLMemoryReporterWrapper::GetBufferCacheMemoryUsed() {
WebGLMemoryTracker::GetBufferCacheMemoryUsed() {
const ContextsArrayType & contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {
@ -149,7 +151,7 @@ WebGLMemoryReporterWrapper::GetBufferCacheMemoryUsed() {
NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(WebGLShaderMallocSizeOf)
int64_t
WebGLMemoryReporterWrapper::GetShaderSize() {
WebGLMemoryTracker::GetShaderSize() {
const ContextsArrayType & contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {

View File

@ -3,8 +3,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef WEBGLMEMORYREPORTERWRAPPER_H_
#define WEBGLMEMORYREPORTERWRAPPER_H_
#ifndef WEBGLMEMORYTRACKER_H_
#define WEBGLMEMORYTRACKER_H_
#include "WebGLContext.h"
#include "WebGLBuffer.h"
@ -14,24 +14,27 @@
#include "WebGLUniformLocation.h"
#include "WebGLTexture.h"
#include "WebGLRenderbuffer.h"
#include "mozilla/StaticPtr.h"
namespace mozilla {
class WebGLMemoryReporterWrapper
class WebGLMemoryTracker : public nsISupports
{
WebGLMemoryReporterWrapper();
~WebGLMemoryReporterWrapper();
static WebGLMemoryReporterWrapper* sUniqueInstance;
NS_DECL_ISUPPORTS
WebGLMemoryTracker();
virtual ~WebGLMemoryTracker();
static StaticRefPtr<WebGLMemoryTracker> sUniqueInstance;
// here we store plain pointers, not RefPtrs: we don't want the
// WebGLMemoryReporterWrapper unique instance to keep alive all
// WebGLMemoryTracker unique instance to keep alive all
// WebGLContexts ever created.
typedef nsTArray<const WebGLContext*> ContextsArrayType;
ContextsArrayType mContexts;
nsCOMPtr<nsIMemoryReporter> mReporter;
static WebGLMemoryReporterWrapper* UniqueInstance();
static WebGLMemoryTracker* UniqueInstance();
static ContextsArrayType & Contexts() { return UniqueInstance()->mContexts; }
@ -47,7 +50,6 @@ class WebGLMemoryReporterWrapper
ContextsArrayType & contexts = Contexts();
contexts.RemoveElement(c);
if (contexts.IsEmpty()) {
delete sUniqueInstance;
sUniqueInstance = nullptr;
}
}

View File

@ -358,3 +358,17 @@ nsDOMEventTargetHelper::WantsUntrusted(bool* aRetVal)
*aRetVal = (doc && !nsContentUtils::IsChromeDoc(doc)) || !NS_IsMainThread();
return rv;
}
void
nsDOMEventTargetHelper::EventListenerAdded(nsIAtom* aType)
{
mozilla::ErrorResult rv;
EventListenerWasAdded(Substring(nsDependentAtomString(aType), 2), rv);
}
void
nsDOMEventTargetHelper::EventListenerRemoved(nsIAtom* aType)
{
mozilla::ErrorResult rv;
EventListenerWasRemoved(Substring(nsDependentAtomString(aType), 2), rv);
}

View File

@ -17,9 +17,14 @@
#include "mozilla/Attributes.h"
#include "mozilla/dom/EventTarget.h"
class JSCompartment;
namespace mozilla {
class ErrorResult;
}
#define NS_DOMEVENTTARGETHELPER_IID \
{ 0xda0e6d40, 0xc17b, 0x4937, \
{ 0x8e, 0xa2, 0x99, 0xca, 0x1c, 0x81, 0xea, 0xbe } }
{ 0xa28385c6, 0x9451, 0x4d7e, \
{ 0xa3, 0xdd, 0xf4, 0xb6, 0x87, 0x2f, 0xa4, 0x76 } }
class nsDOMEventTargetHelper : public mozilla::dom::EventTarget
{
@ -125,6 +130,15 @@ public:
virtual void DisconnectFromOwner();
nsIGlobalObject* GetParentObject() const { return mParentObject; }
bool HasOrHasHadOwner() { return mHasOrHasHadOwnerWindow; }
virtual void EventListenerAdded(nsIAtom* aType) MOZ_OVERRIDE;
virtual void EventListenerRemoved(nsIAtom* aType) MOZ_OVERRIDE;
virtual void EventListenerWasAdded(const nsAString& aType,
mozilla::ErrorResult& aRv,
JSCompartment* aCompartment = nullptr) {}
virtual void EventListenerWasRemoved(const nsAString& aType,
mozilla::ErrorResult& aRv,
JSCompartment* aCompartment = nullptr) {}
protected:
nsresult WantsUntrusted(bool* aRetVal);

View File

@ -574,14 +574,13 @@ nsEventListenerManager::FindEventHandler(uint32_t aEventType,
}
nsListenerStruct*
nsEventListenerManager::SetEventHandlerInternal(nsIScriptContext *aContext,
JS::Handle<JSObject*> aScopeObject,
nsEventListenerManager::SetEventHandlerInternal(JS::Handle<JSObject*> aScopeObject,
nsIAtom* aName,
const nsAString& aTypeString,
const nsEventHandler& aHandler,
bool aPermitUntrustedEvents)
{
MOZ_ASSERT((aContext && aScopeObject) || aHandler.HasEventHandler(),
MOZ_ASSERT(aScopeObject || aHandler.HasEventHandler(),
"Must have one or the other!");
MOZ_ASSERT(aName || !aTypeString.IsEmpty());
@ -595,7 +594,7 @@ nsEventListenerManager::SetEventHandlerInternal(nsIScriptContext *aContext,
flags.mListenerIsJSListener = true;
nsCOMPtr<nsIJSEventListener> scriptListener;
NS_NewJSEventListener(aContext, aScopeObject, mTarget, aName,
NS_NewJSEventListener(aScopeObject, mTarget, aName,
aHandler, getter_AddRefs(scriptListener));
if (!aName && aTypeString.EqualsLiteral("error")) {
@ -614,8 +613,8 @@ nsEventListenerManager::SetEventHandlerInternal(nsIScriptContext *aContext,
bool same = scriptListener->GetHandler() == aHandler;
// Possibly the same listener, but update still the context and scope.
scriptListener->SetHandler(aHandler, aContext, aScopeObject);
if (mTarget && !same) {
scriptListener->SetHandler(aHandler, aScopeObject);
if (mTarget && !same && aName) {
mTarget->EventListenerRemoved(aName);
mTarget->EventListenerAdded(aName);
}
@ -651,31 +650,9 @@ nsEventListenerManager::SetEventHandler(nsIAtom *aName,
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsINode> node(do_QueryInterface(mTarget));
nsCOMPtr<nsIDocument> doc;
nsCOMPtr<nsIScriptGlobalObject> global;
if (node) {
// Try to get context from doc
// XXX sXBL/XBL2 issue -- do we really want the owner here? What
// if that's the XBL document?
doc = node->OwnerDoc();
MOZ_ASSERT(!doc->IsLoadedAsData(), "Should not get in here at all");
// We want to allow compiling an event handler even in an unloaded
// document, so use GetScopeObject here, not GetScriptHandlingObject.
global = do_QueryInterface(doc->GetScopeObject());
} else {
nsCOMPtr<nsPIDOMWindow> win = GetTargetAsInnerWindow();
if (win) {
doc = win->GetDoc();
global = do_QueryInterface(win);
} else {
global = do_QueryInterface(mTarget);
}
}
nsCOMPtr<nsIScriptGlobalObject> global =
GetScriptGlobalAndDocument(getter_AddRefs(doc));
if (!global) {
// This can happen; for example this document might have been
@ -754,13 +731,14 @@ nsEventListenerManager::SetEventHandler(nsIAtom *aName,
JS::Rooted<JSObject*> scope(context->GetNativeContext(),
global->GetGlobalJSObject());
nsListenerStruct* ls = SetEventHandlerInternal(context, scope, aName,
nsListenerStruct* ls = SetEventHandlerInternal(scope, aName,
EmptyString(),
nsEventHandler(),
aPermitUntrustedEvents);
if (!aDeferCompilation) {
return CompileEventHandlerInternal(ls, true, &aBody);
nsCxPusher pusher;
return CompileEventHandlerInternal(ls, pusher, &aBody);
}
return NS_OK;
@ -789,7 +767,7 @@ nsEventListenerManager::RemoveEventHandler(nsIAtom* aName,
nsresult
nsEventListenerManager::CompileEventHandlerInternal(nsListenerStruct *aListenerStruct,
bool aNeedsCxPush,
nsCxPusher& aPusher,
const nsAString* aBody)
{
NS_PRECONDITION(aListenerStruct->GetJSListener(),
@ -803,14 +781,19 @@ nsEventListenerManager::CompileEventHandlerInternal(nsListenerStruct *aListenerS
NS_ASSERTION(!listener->GetHandler().HasEventHandler(),
"What is there to compile?");
nsIScriptContext *context = listener->GetEventContext();
nsCOMPtr<nsIDocument> doc;
nsCOMPtr<nsIScriptGlobalObject> global =
GetScriptGlobalAndDocument(getter_AddRefs(doc));
NS_ENSURE_STATE(global);
nsIScriptContext* context = global->GetScriptContext();
NS_ENSURE_STATE(context);
JSContext *cx = context->GetNativeContext();
JS::Rooted<JSObject*> handler(cx);
nsCOMPtr<nsPIDOMWindow> win; // Will end up non-null if mTarget is a window
nsCxPusher pusher;
if (aNeedsCxPush) {
if (aPusher.GetCurrentScriptContext() != context) {
pusher.Push(cx);
}
@ -859,16 +842,6 @@ nsEventListenerManager::CompileEventHandlerInternal(nsListenerStruct *aListenerS
uint32_t lineNo = 0;
nsAutoCString url (NS_LITERAL_CSTRING("-moz-evil:lying-event-listener"));
nsCOMPtr<nsIDocument> doc;
if (content) {
doc = content->OwnerDoc();
} else {
win = do_QueryInterface(mTarget);
if (win) {
doc = win->GetExtantDoc();
}
}
if (doc) {
nsIURI *uri = doc->GetDocumentURI();
if (uri) {
@ -904,6 +877,7 @@ nsEventListenerManager::CompileEventHandlerInternal(nsListenerStruct *aListenerS
}
if (handler) {
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(mTarget);
// Bind it
JS::Rooted<JSObject*> boundHandler(cx);
JS::Rooted<JSObject*> scope(cx, listener->GetEventScope());
@ -942,11 +916,7 @@ nsEventListenerManager::HandleEventSubType(nsListenerStruct* aListenerStruct,
// compiled the event handler itself
if ((aListenerStruct->mListenerType == eJSEventListener) &&
aListenerStruct->mHandlerIsString) {
nsIJSEventListener *jslistener = aListenerStruct->GetJSListener();
result = CompileEventHandlerInternal(aListenerStruct,
jslistener->GetEventContext() !=
aPusher->GetCurrentScriptContext(),
nullptr);
result = CompileEventHandlerInternal(aListenerStruct, *aPusher, nullptr);
aListenerStruct = nullptr;
}
@ -1197,8 +1167,9 @@ nsEventListenerManager::GetListenerInfo(nsCOMArray<nsIEventListenerInfo>* aList)
// If this is a script handler and we haven't yet
// compiled the event handler itself go ahead and compile it
if ((ls.mListenerType == eJSEventListener) && ls.mHandlerIsString) {
nsCxPusher pusher;
CompileEventHandlerInternal(const_cast<nsListenerStruct*>(&ls),
true, nullptr);
pusher, nullptr);
}
nsAutoString eventType;
if (ls.mAllEvents) {
@ -1244,7 +1215,7 @@ nsEventListenerManager::SetEventHandler(nsIAtom* aEventName,
// Untrusted events are always permitted for non-chrome script
// handlers.
SetEventHandlerInternal(nullptr, JS::NullPtr(), aEventName,
SetEventHandlerInternal(JS::NullPtr(), aEventName,
aTypeString, nsEventHandler(aHandler),
!mIsMainThreadELM ||
!nsContentUtils::IsCallerChrome());
@ -1261,7 +1232,7 @@ nsEventListenerManager::SetEventHandler(OnErrorEventHandlerNonNull* aHandler)
// Untrusted events are always permitted for non-chrome script
// handlers.
SetEventHandlerInternal(nullptr, JS::NullPtr(), nsGkAtoms::onerror,
SetEventHandlerInternal(JS::NullPtr(), nsGkAtoms::onerror,
EmptyString(), nsEventHandler(aHandler),
!nsContentUtils::IsCallerChrome());
} else {
@ -1271,7 +1242,7 @@ nsEventListenerManager::SetEventHandler(OnErrorEventHandlerNonNull* aHandler)
}
// Untrusted events are always permitted.
SetEventHandlerInternal(nullptr, JS::NullPtr(), nullptr,
SetEventHandlerInternal(JS::NullPtr(), nullptr,
NS_LITERAL_STRING("error"),
nsEventHandler(aHandler), true);
}
@ -1287,7 +1258,7 @@ nsEventListenerManager::SetEventHandler(OnBeforeUnloadEventHandlerNonNull* aHand
// Untrusted events are always permitted for non-chrome script
// handlers.
SetEventHandlerInternal(nullptr, JS::NullPtr(), nsGkAtoms::onbeforeunload,
SetEventHandlerInternal(JS::NullPtr(), nsGkAtoms::onbeforeunload,
EmptyString(), nsEventHandler(aHandler),
!mIsMainThreadELM ||
!nsContentUtils::IsCallerChrome());
@ -1307,7 +1278,8 @@ nsEventListenerManager::GetEventHandlerInternal(nsIAtom *aEventName,
nsIJSEventListener *listener = ls->GetJSListener();
if (ls->mHandlerIsString) {
CompileEventHandlerInternal(ls, true, nullptr);
nsCxPusher pusher;
CompileEventHandlerInternal(ls, pusher, nullptr);
}
const nsEventHandler& handler = listener->GetHandler();
@ -1359,3 +1331,33 @@ nsEventListenerManager::MarkForCC()
mRefCnt.RemovePurple();
}
}
already_AddRefed<nsIScriptGlobalObject>
nsEventListenerManager::GetScriptGlobalAndDocument(nsIDocument** aDoc)
{
nsCOMPtr<nsINode> node(do_QueryInterface(mTarget));
nsCOMPtr<nsIDocument> doc;
nsCOMPtr<nsIScriptGlobalObject> global;
if (node) {
// Try to get context from doc
// XXX sXBL/XBL2 issue -- do we really want the owner here? What
// if that's the XBL document?
doc = node->OwnerDoc();
MOZ_ASSERT(!doc->IsLoadedAsData(), "Should not get in here at all");
// We want to allow compiling an event handler even in an unloaded
// document, so use GetScopeObject here, not GetScriptHandlingObject.
global = do_QueryInterface(doc->GetScopeObject());
} else {
nsCOMPtr<nsPIDOMWindow> win = GetTargetAsInnerWindow();
if (win) {
doc = win->GetExtantDoc();
global = do_QueryInterface(win);
} else {
global = do_QueryInterface(mTarget);
}
}
doc.forget(aDoc);
return global.forget();
}

View File

@ -427,7 +427,7 @@ protected:
* will look for it on mTarget.
*/
nsresult CompileEventHandlerInternal(nsListenerStruct *aListenerStruct,
bool aNeedsCxPush,
nsCxPusher& aPusher,
const nsAString* aBody);
/**
@ -444,8 +444,7 @@ protected:
* allowed to be null. The nsListenerStruct that results, if any, is returned
* in aListenerStruct.
*/
nsListenerStruct* SetEventHandlerInternal(nsIScriptContext *aContext,
JS::Handle<JSObject*> aScopeGlobal,
nsListenerStruct* SetEventHandlerInternal(JS::Handle<JSObject*> aScopeGlobal,
nsIAtom* aName,
const nsAString& aTypeString,
const nsEventHandler& aHandler,
@ -538,6 +537,9 @@ protected:
bool ListenerCanHandle(nsListenerStruct* aLs, mozilla::WidgetEvent* aEvent);
already_AddRefed<nsIScriptGlobalObject>
GetScriptGlobalAndDocument(nsIDocument** aDoc);
uint32_t mMayHavePaintEventListener : 1;
uint32_t mMayHaveMutationListeners : 1;
uint32_t mMayHaveCapturingListeners : 1;

View File

@ -3320,8 +3320,9 @@ HTMLInputElement::StartRangeThumbDrag(WidgetGUIEvent* aEvent)
{
mIsDraggingRange = true;
mRangeThumbDragStartValue = GetValueAsDecimal();
nsIPresShell::SetCapturingContent(this, CAPTURE_IGNOREALLOWED |
CAPTURE_RETARGETTOELEMENT);
// Don't use CAPTURE_RETARGETTOELEMENT, as that breaks pseudo-class styling
// of the thumb.
nsIPresShell::SetCapturingContent(this, CAPTURE_IGNOREALLOWED);
nsRangeFrame* rangeFrame = do_QueryFrame(GetPrimaryFrame());
// Before we change the value, record the current value so that we'll

View File

@ -18,6 +18,7 @@
#include "MediaResource.h"
#include "nsError.h"
#include "mozilla/Preferences.h"
#include "mozilla/StaticPtr.h"
#include "nsIMemoryReporter.h"
#include "nsComponentManagerUtils.h"
#include "nsITimer.h"
@ -53,11 +54,13 @@ PRLogModuleInfo* gMediaDecoderLog;
#define DECODER_LOG(type, msg)
#endif
class MediaMemoryTracker
class MediaMemoryTracker : public nsISupports
{
NS_DECL_ISUPPORTS
MediaMemoryTracker();
~MediaMemoryTracker();
static MediaMemoryTracker* sUniqueInstance;
virtual ~MediaMemoryTracker();
static StaticRefPtr<MediaMemoryTracker> sUniqueInstance;
static MediaMemoryTracker* UniqueInstance() {
if (!sUniqueInstance) {
@ -86,7 +89,6 @@ public:
DecodersArray& decoders = Decoders();
decoders.RemoveElement(aDecoder);
if (decoders.IsEmpty()) {
delete sUniqueInstance;
sUniqueInstance = nullptr;
}
}
@ -103,7 +105,9 @@ public:
}
};
MediaMemoryTracker* MediaMemoryTracker::sUniqueInstance = nullptr;
StaticRefPtr<MediaMemoryTracker> MediaMemoryTracker::sUniqueInstance;
NS_IMPL_ISUPPORTS1(MediaMemoryTracker, nsISupports)
NS_IMPL_ISUPPORTS1(MediaDecoder, nsIObserver)

View File

@ -93,6 +93,32 @@ MP4Reader::~MP4Reader()
MOZ_COUNT_DTOR(MP4Reader);
}
void
MP4Reader::InitLayersBackendType()
{
if (!IsVideoContentType(mDecoder->GetResource()->GetContentType())) {
// Not playing video, we don't care about the layers backend type.
return;
}
// Extract the layer manager backend type so that platform decoders
// can determine whether it's worthwhile using hardware accelerated
// video decoding.
MediaDecoderOwner* owner = mDecoder->GetOwner();
if (!owner) {
NS_WARNING("MP4Reader without a decoder owner, can't get HWAccel");
return;
}
dom::HTMLMediaElement* element = owner->GetMediaElement();
NS_ENSURE_TRUE_VOID(element);
nsRefPtr<LayerManager> layerManager =
nsContentUtils::LayerManagerForDocument(element->OwnerDoc());
NS_ENSURE_TRUE_VOID(layerManager);
mLayersBackendType = layerManager->GetBackendType();
}
nsresult
MP4Reader::Init(MediaDecoderReader* aCloneDonor)
{
@ -103,22 +129,7 @@ MP4Reader::Init(MediaDecoderReader* aCloneDonor)
mPlatform = PlatformDecoderModule::Create();
NS_ENSURE_TRUE(mPlatform, NS_ERROR_FAILURE);
if (IsVideoContentType(mDecoder->GetResource()->GetContentType())) {
// Extract the layer manager backend type so that platform decoders
// can determine whether it's worthwhile using hardware accelerated
// video decoding.
MediaDecoderOwner* owner = mDecoder->GetOwner();
NS_ENSURE_TRUE(owner, NS_ERROR_FAILURE);
dom::HTMLMediaElement* element = owner->GetMediaElement();
NS_ENSURE_TRUE(element, NS_ERROR_FAILURE);
nsRefPtr<LayerManager> layerManager =
nsContentUtils::LayerManagerForDocument(element->OwnerDoc());
NS_ENSURE_TRUE(layerManager, NS_ERROR_FAILURE);
mLayersBackendType = layerManager->GetBackendType();
}
InitLayersBackendType();
return NS_OK;
}
@ -130,16 +141,30 @@ MP4Reader::ReadMetadata(MediaInfo* aInfo,
bool ok = mDemuxer->Init();
NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
mInfo.mAudio.mHasAudio = mHasAudio = mDemuxer->HasAudio();
const AudioDecoderConfig& audio = mDemuxer->AudioConfig();
mInfo.mAudio.mHasAudio = mHasAudio = mDemuxer->HasAudio() &&
audio.IsValidConfig();
// If we have audio, we *only* allow AAC to be decoded.
if (mHasAudio && audio.codec() != kCodecAAC) {
return NS_ERROR_FAILURE;
}
const VideoDecoderConfig& video = mDemuxer->VideoConfig();
mInfo.mVideo.mHasVideo = mHasVideo = mDemuxer->HasVideo() &&
video.IsValidConfig();
// If we have video, we *only* allow H.264 to be decoded.
if (mHasVideo && video.codec() != kCodecH264) {
return NS_ERROR_FAILURE;
}
if (mHasAudio) {
const AudioDecoderConfig& config = mDemuxer->AudioConfig();
mInfo.mAudio.mRate = config.samples_per_second();
mInfo.mAudio.mChannels = ChannelLayoutToChannelCount(config.channel_layout());
mInfo.mAudio.mRate = audio.samples_per_second();
mInfo.mAudio.mChannels = ChannelLayoutToChannelCount(audio.channel_layout());
mAudioDecoder = mPlatform->CreateAudioDecoder(mInfo.mAudio.mChannels,
mInfo.mAudio.mRate,
config.bits_per_channel(),
config.extra_data(),
config.extra_data_size());
audio.bits_per_channel(),
audio.extra_data(),
audio.extra_data_size());
NS_ENSURE_TRUE(mAudioDecoder != nullptr, NS_ERROR_FAILURE);
}
@ -148,7 +173,6 @@ MP4Reader::ReadMetadata(MediaInfo* aInfo,
const VideoDecoderConfig& config = mDemuxer->VideoConfig();
IntSize sz = config.natural_size();
mInfo.mVideo.mDisplay = nsIntSize(sz.width(), sz.height());
mVideoDecoder = mPlatform->CreateVideoDecoder(mLayersBackendType,
mDecoder->GetImageContainer());
NS_ENSURE_TRUE(mVideoDecoder != nullptr, NS_ERROR_FAILURE);

View File

@ -53,6 +53,8 @@ public:
virtual void OnDecodeThreadFinish() MOZ_OVERRIDE;
private:
// Initializes mLayersBackendType if possible.
void InitLayersBackendType();
MP4SampleQueue& SampleQueue(mp4_demuxer::TrackType aTrack);

View File

@ -33,6 +33,8 @@ protected:
}
public:
typedef gfx::AttributeMap AttributeMap;
// interfaces:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_SVG_FE_COMPONENT_TRANSFER_FUNCTION_ELEMENT_CID)
@ -42,7 +44,8 @@ public:
int32_t aNameSpaceID, nsIAtom* aAttribute) const MOZ_OVERRIDE;
virtual int32_t GetChannel() = 0;
bool GenerateLookupTable(uint8_t* aTable);
AttributeMap ComputeAttributes();
// WebIDL
virtual JSObject* WrapNode(JSContext* aCx,

View File

@ -9,6 +9,8 @@
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEBlend)
using namespace mozilla::gfx;
namespace mozilla {
namespace dom {
@ -68,60 +70,15 @@ SVGFEBlendElement::Mode()
return mEnumAttributes[MODE].ToDOMAnimatedEnum(this);
}
nsresult
SVGFEBlendElement::Filter(nsSVGFilterInstance* aInstance,
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& rect)
FilterPrimitiveDescription
SVGFEBlendElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
const IntRect& aFilterSubregion,
nsTArray<nsRefPtr<gfxASurface> >& aInputImages)
{
CopyRect(aTarget, aSources[0], rect);
uint8_t* sourceData = aSources[1]->mImage->Data();
uint8_t* targetData = aTarget->mImage->Data();
uint32_t stride = aTarget->mImage->Stride();
uint16_t mode = mEnumAttributes[MODE].GetAnimValue();
for (int32_t x = rect.x; x < rect.XMost(); x++) {
for (int32_t y = rect.y; y < rect.YMost(); y++) {
uint32_t targIndex = y * stride + 4 * x;
uint32_t qa = targetData[targIndex + GFX_ARGB32_OFFSET_A];
uint32_t qb = sourceData[targIndex + GFX_ARGB32_OFFSET_A];
for (int32_t i = std::min(GFX_ARGB32_OFFSET_B, GFX_ARGB32_OFFSET_R);
i <= std::max(GFX_ARGB32_OFFSET_B, GFX_ARGB32_OFFSET_R); i++) {
uint32_t ca = targetData[targIndex + i];
uint32_t cb = sourceData[targIndex + i];
uint32_t val;
switch (mode) {
case SVG_FEBLEND_MODE_NORMAL:
val = (255 - qa) * cb + 255 * ca;
break;
case SVG_FEBLEND_MODE_MULTIPLY:
val = ((255 - qa) * cb + (255 - qb + cb) * ca);
break;
case SVG_FEBLEND_MODE_SCREEN:
val = 255 * (cb + ca) - ca * cb;
break;
case SVG_FEBLEND_MODE_DARKEN:
val = std::min((255 - qa) * cb + 255 * ca,
(255 - qb) * ca + 255 * cb);
break;
case SVG_FEBLEND_MODE_LIGHTEN:
val = std::max((255 - qa) * cb + 255 * ca,
(255 - qb) * ca + 255 * cb);
break;
default:
return NS_ERROR_FAILURE;
break;
}
val = std::min(val / 255, 255U);
targetData[targIndex + i] = static_cast<uint8_t>(val);
}
uint32_t alpha = 255 * 255 - (255 - qa) * (255 - qb);
FAST_DIVIDE_BY_255(targetData[targIndex + GFX_ARGB32_OFFSET_A], alpha);
}
}
return NS_OK;
uint32_t mode = mEnumAttributes[MODE].GetAnimValue();
FilterPrimitiveDescription descr(FilterPrimitiveDescription::eBlend);
descr.Attributes().Set(eBlendBlendmode, mode);
return descr;
}
bool

View File

@ -14,13 +14,6 @@ nsresult NS_NewSVGFEBlendElement(nsIContent **aResult,
namespace mozilla {
namespace dom {
static const unsigned short SVG_FEBLEND_MODE_UNKNOWN = 0;
static const unsigned short SVG_FEBLEND_MODE_NORMAL = 1;
static const unsigned short SVG_FEBLEND_MODE_MULTIPLY = 2;
static const unsigned short SVG_FEBLEND_MODE_SCREEN = 3;
static const unsigned short SVG_FEBLEND_MODE_DARKEN = 4;
static const unsigned short SVG_FEBLEND_MODE_LIGHTEN = 5;
typedef nsSVGFE SVGFEBlendElementBase;
class SVGFEBlendElement : public SVGFEBlendElementBase
@ -36,10 +29,10 @@ protected:
JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
public:
virtual nsresult Filter(nsSVGFilterInstance* aInstance,
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect) MOZ_OVERRIDE;
virtual FilterPrimitiveDescription
GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
const IntRect& aFilterSubregion,
nsTArray<nsRefPtr<gfxASurface> >& aInputImages) MOZ_OVERRIDE;
virtual bool AttributeAffectsRendering(
int32_t aNameSpaceID, nsIAtom* aAttribute) const MOZ_OVERRIDE;
virtual nsSVGString& GetResultImageName() MOZ_OVERRIDE { return mStringAttributes[RESULT]; }

View File

@ -12,6 +12,8 @@
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEColorMatrix)
using namespace mozilla::gfx;
namespace mozilla {
namespace dom {
@ -82,142 +84,35 @@ SVGFEColorMatrixElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources
aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN1], this));
}
nsresult
SVGFEColorMatrixElement::Filter(nsSVGFilterInstance* instance,
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& rect)
FilterPrimitiveDescription
SVGFEColorMatrixElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
const IntRect& aFilterSubregion,
nsTArray<nsRefPtr<gfxASurface> >& aInputImages)
{
uint8_t* sourceData = aSources[0]->mImage->Data();
uint8_t* targetData = aTarget->mImage->Data();
uint32_t stride = aTarget->mImage->Stride();
uint16_t type = mEnumAttributes[TYPE].GetAnimValue();
uint32_t type = mEnumAttributes[TYPE].GetAnimValue();
const SVGNumberList &values = mNumberListAttributes[VALUES].GetAnimValue();
FilterPrimitiveDescription descr(FilterPrimitiveDescription::eColorMatrix);
if (!mNumberListAttributes[VALUES].IsExplicitlySet() &&
(type == SVG_FECOLORMATRIX_TYPE_MATRIX ||
type == SVG_FECOLORMATRIX_TYPE_SATURATE ||
type == SVG_FECOLORMATRIX_TYPE_HUE_ROTATE)) {
// identity matrix filter
CopyRect(aTarget, aSources[0], rect);
return NS_OK;
}
static const float identityMatrix[] =
{ 1, 0, 0, 0, 0,
0, 1, 0, 0, 0,
0, 0, 1, 0, 0,
0, 0, 0, 1, 0 };
static const float luminanceToAlphaMatrix[] =
{ 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0.2125f, 0.7154f, 0.0721f, 0, 0 };
float colorMatrix[NUM_ENTRIES_IN_4x5_MATRIX];
float s, c;
switch (type) {
case SVG_FECOLORMATRIX_TYPE_MATRIX:
if (values.Length() != NUM_ENTRIES_IN_4x5_MATRIX)
return NS_ERROR_FAILURE;
for(uint32_t j = 0; j < values.Length(); j++) {
colorMatrix[j] = values[j];
}
break;
case SVG_FECOLORMATRIX_TYPE_SATURATE:
if (values.Length() != 1)
return NS_ERROR_FAILURE;
s = values[0];
if (s > 1 || s < 0)
return NS_ERROR_FAILURE;
memcpy(colorMatrix, identityMatrix, sizeof(colorMatrix));
colorMatrix[0] = 0.213f + 0.787f * s;
colorMatrix[1] = 0.715f - 0.715f * s;
colorMatrix[2] = 0.072f - 0.072f * s;
colorMatrix[5] = 0.213f - 0.213f * s;
colorMatrix[6] = 0.715f + 0.285f * s;
colorMatrix[7] = 0.072f - 0.072f * s;
colorMatrix[10] = 0.213f - 0.213f * s;
colorMatrix[11] = 0.715f - 0.715f * s;
colorMatrix[12] = 0.072f + 0.928f * s;
break;
case SVG_FECOLORMATRIX_TYPE_HUE_ROTATE:
{
memcpy(colorMatrix, identityMatrix, sizeof(colorMatrix));
if (values.Length() != 1)
return NS_ERROR_FAILURE;
float hueRotateValue = values[0];
c = static_cast<float>(cos(hueRotateValue * M_PI / 180));
s = static_cast<float>(sin(hueRotateValue * M_PI / 180));
memcpy(colorMatrix, identityMatrix, sizeof(colorMatrix));
colorMatrix[0] = 0.213f + 0.787f * c - 0.213f * s;
colorMatrix[1] = 0.715f - 0.715f * c - 0.715f * s;
colorMatrix[2] = 0.072f - 0.072f * c + 0.928f * s;
colorMatrix[5] = 0.213f - 0.213f * c + 0.143f * s;
colorMatrix[6] = 0.715f + 0.285f * c + 0.140f * s;
colorMatrix[7] = 0.072f - 0.072f * c - 0.283f * s;
colorMatrix[10] = 0.213f - 0.213f * c - 0.787f * s;
colorMatrix[11] = 0.715f - 0.715f * c + 0.715f * s;
colorMatrix[12] = 0.072f + 0.928f * c + 0.072f * s;
break;
}
case SVG_FECOLORMATRIX_TYPE_LUMINANCE_TO_ALPHA:
memcpy(colorMatrix, luminanceToAlphaMatrix, sizeof(colorMatrix));
break;
default:
return NS_ERROR_FAILURE;
}
for (int32_t x = rect.x; x < rect.XMost(); x++) {
for (int32_t y = rect.y; y < rect.YMost(); y++) {
uint32_t targIndex = y * stride + 4 * x;
float col[4];
for (int i = 0, row = 0; i < 4; i++, row += 5) {
col[i] =
sourceData[targIndex + GFX_ARGB32_OFFSET_R] * colorMatrix[row + 0] +
sourceData[targIndex + GFX_ARGB32_OFFSET_G] * colorMatrix[row + 1] +
sourceData[targIndex + GFX_ARGB32_OFFSET_B] * colorMatrix[row + 2] +
sourceData[targIndex + GFX_ARGB32_OFFSET_A] * colorMatrix[row + 3] +
255 * colorMatrix[row + 4];
col[i] = clamped(col[i], 0.f, 255.f);
}
targetData[targIndex + GFX_ARGB32_OFFSET_R] =
static_cast<uint8_t>(col[0]);
targetData[targIndex + GFX_ARGB32_OFFSET_G] =
static_cast<uint8_t>(col[1]);
targetData[targIndex + GFX_ARGB32_OFFSET_B] =
static_cast<uint8_t>(col[2]);
targetData[targIndex + GFX_ARGB32_OFFSET_A] =
static_cast<uint8_t>(col[3]);
descr.Attributes().Set(eColorMatrixType, (uint32_t)SVG_FECOLORMATRIX_TYPE_MATRIX);
static const float identityMatrix[] =
{ 1, 0, 0, 0, 0,
0, 1, 0, 0, 0,
0, 0, 1, 0, 0,
0, 0, 0, 1, 0 };
descr.Attributes().Set(eColorMatrixValues, identityMatrix, 20);
} else {
descr.Attributes().Set(eColorMatrixType, type);
if (values.Length()) {
descr.Attributes().Set(eColorMatrixValues, &values[0], values.Length());
} else {
descr.Attributes().Set(eColorMatrixValues, nullptr, 0);
}
}
return NS_OK;
return descr;
}
bool

View File

@ -18,12 +18,6 @@ namespace dom {
typedef nsSVGFE SVGFEColorMatrixElementBase;
static const unsigned short SVG_FECOLORMATRIX_TYPE_UNKNOWN = 0;
static const unsigned short SVG_FECOLORMATRIX_TYPE_MATRIX = 1;
static const unsigned short SVG_FECOLORMATRIX_TYPE_SATURATE = 2;
static const unsigned short SVG_FECOLORMATRIX_TYPE_HUE_ROTATE = 3;
static const unsigned short SVG_FECOLORMATRIX_TYPE_LUMINANCE_TO_ALPHA = 4;
class SVGFEColorMatrixElement : public SVGFEColorMatrixElementBase
{
friend nsresult (::NS_NewSVGFEColorMatrixElement(nsIContent **aResult,
@ -37,10 +31,10 @@ protected:
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
public:
virtual nsresult Filter(nsSVGFilterInstance* aInstance,
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect) MOZ_OVERRIDE;
virtual FilterPrimitiveDescription
GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
const IntRect& aFilterSubregion,
nsTArray<nsRefPtr<gfxASurface> >& aInputImages) MOZ_OVERRIDE;
virtual bool AttributeAffectsRendering(
int32_t aNameSpaceID, nsIAtom* aAttribute) const MOZ_OVERRIDE;
virtual nsSVGString& GetResultImageName() MOZ_OVERRIDE { return mStringAttributes[RESULT]; }
@ -54,8 +48,6 @@ public:
already_AddRefed<DOMSVGAnimatedNumberList> Values();
protected:
virtual bool OperatesOnPremultipledAlpha(int32_t) MOZ_OVERRIDE { return false; }
virtual EnumAttributesInfo GetEnumInfo() MOZ_OVERRIDE;
virtual StringAttributesInfo GetStringInfo() MOZ_OVERRIDE;
virtual NumberListAttributesInfo GetNumberListInfo() MOZ_OVERRIDE;

View File

@ -7,9 +7,12 @@
#include "mozilla/dom/SVGFEComponentTransferElement.h"
#include "mozilla/dom/SVGFEComponentTransferElementBinding.h"
#include "nsSVGUtils.h"
#include "mozilla/gfx/2D.h"
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEComponentTransfer)
using namespace mozilla::gfx;;
namespace mozilla {
namespace dom {
@ -48,20 +51,13 @@ SVGFEComponentTransferElement::GetStringInfo()
//--------------------------------------------
nsresult
SVGFEComponentTransferElement::Filter(nsSVGFilterInstance *instance,
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& rect)
FilterPrimitiveDescription
SVGFEComponentTransferElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
const IntRect& aFilterSubregion,
nsTArray<nsRefPtr<gfxASurface> >& aInputImages)
{
uint8_t* sourceData = aSources[0]->mImage->Data();
uint8_t* targetData = aTarget->mImage->Data();
uint32_t stride = aTarget->mImage->Stride();
nsRefPtr<SVGComponentTransferFunctionElement> childForChannel[4];
uint8_t tableR[256], tableG[256], tableB[256], tableA[256];
for (int i=0; i<256; i++)
tableR[i] = tableG[i] = tableB[i] = tableA[i] = i;
uint8_t* tables[] = { tableR, tableG, tableB, tableA };
for (nsIContent* childContent = nsINode::GetFirstChild();
childContent;
childContent = childContent->GetNextSibling()) {
@ -70,26 +66,29 @@ SVGFEComponentTransferElement::Filter(nsSVGFilterInstance *instance,
CallQueryInterface(childContent,
(SVGComponentTransferFunctionElement**)getter_AddRefs(child));
if (child) {
if (!child->GenerateLookupTable(tables[child->GetChannel()])) {
return NS_ERROR_FAILURE;
}
childForChannel[child->GetChannel()] = child;
}
}
for (int32_t y = rect.y; y < rect.YMost(); y++) {
for (int32_t x = rect.x; x < rect.XMost(); x++) {
int32_t targIndex = y * stride + x * 4;
targetData[targIndex + GFX_ARGB32_OFFSET_B] =
tableB[sourceData[targIndex + GFX_ARGB32_OFFSET_B]];
targetData[targIndex + GFX_ARGB32_OFFSET_G] =
tableG[sourceData[targIndex + GFX_ARGB32_OFFSET_G]];
targetData[targIndex + GFX_ARGB32_OFFSET_R] =
tableR[sourceData[targIndex + GFX_ARGB32_OFFSET_R]];
targetData[targIndex + GFX_ARGB32_OFFSET_A] =
tableA[sourceData[targIndex + GFX_ARGB32_OFFSET_A]];
static const AttributeName attributeNames[4] = {
eComponentTransferFunctionR,
eComponentTransferFunctionG,
eComponentTransferFunctionB,
eComponentTransferFunctionA
};
FilterPrimitiveDescription descr(FilterPrimitiveDescription::eComponentTransfer);
for (int32_t i = 0; i < 4; i++) {
if (childForChannel[i]) {
descr.Attributes().Set(attributeNames[i], childForChannel[i]->ComputeAttributes());
} else {
AttributeMap functionAttributes;
functionAttributes.Set(eComponentTransferFunctionType,
(uint32_t)SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY);
descr.Attributes().Set(attributeNames[i], functionAttributes);
}
}
return NS_OK;
return descr;
}
bool

View File

@ -29,10 +29,10 @@ protected:
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
public:
virtual nsresult Filter(nsSVGFilterInstance* aInstance,
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect) MOZ_OVERRIDE;
virtual FilterPrimitiveDescription
GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
const IntRect& aFilterSubregion,
nsTArray<nsRefPtr<gfxASurface> >& aInputImages) MOZ_OVERRIDE;
virtual bool AttributeAffectsRendering(
int32_t aNameSpaceID, nsIAtom* aAttribute) const MOZ_OVERRIDE;
virtual nsSVGString& GetResultImageName() MOZ_OVERRIDE { return mStringAttributes[RESULT]; }
@ -45,8 +45,6 @@ public:
already_AddRefed<SVGAnimatedString> In1();
protected:
virtual bool OperatesOnPremultipledAlpha(int32_t) MOZ_OVERRIDE { return false; }
virtual StringAttributesInfo GetStringInfo() MOZ_OVERRIDE;
enum { RESULT, IN1 };

View File

@ -9,6 +9,8 @@
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEComposite)
using namespace mozilla::gfx;
namespace mozilla {
namespace dom {
@ -107,67 +109,22 @@ SVGFECompositeElement::SetK(float k1, float k2, float k3, float k4)
mNumberAttributes[ATTR_K4].SetBaseValue(k4, this);
}
nsresult
SVGFECompositeElement::Filter(nsSVGFilterInstance* instance,
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& rect)
FilterPrimitiveDescription
SVGFECompositeElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
const IntRect& aFilterSubregion,
nsTArray<nsRefPtr<gfxASurface> >& aInputImages)
{
uint16_t op = mEnumAttributes[OPERATOR].GetAnimValue();
FilterPrimitiveDescription descr(FilterPrimitiveDescription::eComposite);
uint32_t op = mEnumAttributes[OPERATOR].GetAnimValue();
descr.Attributes().Set(eCompositeOperator, op);
// Cairo does not support arithmetic operator
if (op == SVG_FECOMPOSITE_OPERATOR_ARITHMETIC) {
float k1, k2, k3, k4;
GetAnimatedNumberValues(&k1, &k2, &k3, &k4, nullptr);
// Copy the first source image
CopyRect(aTarget, aSources[0], rect);
uint8_t* sourceData = aSources[1]->mImage->Data();
uint8_t* targetData = aTarget->mImage->Data();
uint32_t stride = aTarget->mImage->Stride();
// Blend in the second source image
float k1Scaled = k1 / 255.0f;
float k4Scaled = k4*255.0f;
for (int32_t x = rect.x; x < rect.XMost(); x++) {
for (int32_t y = rect.y; y < rect.YMost(); y++) {
uint32_t targIndex = y * stride + 4 * x;
for (int32_t i = 0; i < 4; i++) {
uint8_t i1 = targetData[targIndex + i];
uint8_t i2 = sourceData[targIndex + i];
float result = k1Scaled*i1*i2 + k2*i1 + k3*i2 + k4Scaled;
targetData[targIndex + i] =
static_cast<uint8_t>(clamped(result, 0.f, 255.f));
}
}
}
return NS_OK;
float k[4];
GetAnimatedNumberValues(k, k+1, k+2, k+3, nullptr);
descr.Attributes().Set(eCompositeCoefficients, k, 4);
}
// Cairo supports the operation we are trying to perform
gfxContext ctx(aTarget->mImage);
ctx.SetOperator(gfxContext::OPERATOR_SOURCE);
ctx.SetSource(aSources[1]->mImage);
// Ensure rendering is limited to the filter primitive subregion
ctx.Clip(aTarget->mFilterPrimitiveSubregion);
ctx.Paint();
if (op < SVG_FECOMPOSITE_OPERATOR_OVER || op > SVG_FECOMPOSITE_OPERATOR_XOR) {
return NS_ERROR_FAILURE;
}
static const gfxContext::GraphicsOperator opMap[] = {
gfxContext::OPERATOR_DEST,
gfxContext::OPERATOR_OVER,
gfxContext::OPERATOR_IN,
gfxContext::OPERATOR_OUT,
gfxContext::OPERATOR_ATOP,
gfxContext::OPERATOR_XOR };
ctx.SetOperator(opMap[op]);
ctx.SetSource(aSources[0]->mImage);
ctx.Paint();
return NS_OK;
return descr;
}
bool
@ -192,34 +149,6 @@ SVGFECompositeElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources)
aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN2], this));
}
nsIntRect
SVGFECompositeElement::ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
const nsSVGFilterInstance& aInstance)
{
uint16_t op = mEnumAttributes[OPERATOR].GetAnimValue();
if (op == SVG_FECOMPOSITE_OPERATOR_ARITHMETIC) {
// "arithmetic" operator can produce non-zero alpha values even where
// all input alphas are zero, so we can actually render outside the
// union of the source bboxes.
// XXX we could also check that k4 is nonzero and check for other
// cases like k1/k2 or k1/k3 zero.
return GetMaxRect();
}
if (op == SVG_FECOMPOSITE_OPERATOR_IN ||
op == SVG_FECOMPOSITE_OPERATOR_ATOP) {
// We will only draw where in2 has nonzero alpha, so it's a good
// bounding box for us
return aSourceBBoxes[1];
}
// The regular Porter-Duff operators always compute zero alpha values
// where all sources have zero alpha, so the union of their bounding
// boxes is also a bounding box for our rendering
return SVGFECompositeElementBase::ComputeTargetBBox(aSourceBBoxes, aInstance);
}
//----------------------------------------------------------------------
// nsSVGElement methods

View File

@ -16,15 +16,6 @@ nsresult NS_NewSVGFECompositeElement(nsIContent **aResult,
namespace mozilla {
namespace dom {
// Composite Operators
static const unsigned short SVG_FECOMPOSITE_OPERATOR_UNKNOWN = 0;
static const unsigned short SVG_FECOMPOSITE_OPERATOR_OVER = 1;
static const unsigned short SVG_FECOMPOSITE_OPERATOR_IN = 2;
static const unsigned short SVG_FECOMPOSITE_OPERATOR_OUT = 3;
static const unsigned short SVG_FECOMPOSITE_OPERATOR_ATOP = 4;
static const unsigned short SVG_FECOMPOSITE_OPERATOR_XOR = 5;
static const unsigned short SVG_FECOMPOSITE_OPERATOR_ARITHMETIC = 6;
typedef nsSVGFE SVGFECompositeElementBase;
class SVGFECompositeElement : public SVGFECompositeElementBase
@ -40,16 +31,14 @@ protected:
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
public:
virtual nsresult Filter(nsSVGFilterInstance* aInstance,
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect) MOZ_OVERRIDE;
virtual FilterPrimitiveDescription
GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
const IntRect& aFilterSubregion,
nsTArray<nsRefPtr<gfxASurface> >& aInputImages) MOZ_OVERRIDE;
virtual bool AttributeAffectsRendering(
int32_t aNameSpaceID, nsIAtom* aAttribute) const MOZ_OVERRIDE;
virtual nsSVGString& GetResultImageName() MOZ_OVERRIDE { return mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources) MOZ_OVERRIDE;
virtual nsIntRect ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
const nsSVGFilterInstance& aInstance) MOZ_OVERRIDE;
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;

View File

@ -7,17 +7,15 @@
#include "mozilla/dom/SVGFEConvolveMatrixElementBinding.h"
#include "DOMSVGAnimatedNumberList.h"
#include "nsSVGUtils.h"
#include "nsSVGFilterInstance.h"
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEConvolveMatrix)
using namespace mozilla::gfx;
namespace mozilla {
namespace dom {
// Edge Mode Values
static const unsigned short SVG_EDGEMODE_DUPLICATE = 1;
static const unsigned short SVG_EDGEMODE_WRAP = 2;
static const unsigned short SVG_EDGEMODE_NONE = 3;
JSObject*
SVGFEConvolveMatrixElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aScope)
{
@ -165,115 +163,13 @@ SVGFEConvolveMatrixElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSour
aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN1], this));
}
nsIntRect
SVGFEConvolveMatrixElement::ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
const nsSVGFilterInstance& aInstance)
FilterPrimitiveDescription
SVGFEConvolveMatrixElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
const IntRect& aFilterSubregion,
nsTArray<nsRefPtr<gfxASurface> >& aInputImages)
{
// XXX A more precise box is possible when 'bias' is zero and 'edgeMode' is
// 'none', but it requires analysis of 'kernelUnitLength', 'order' and
// 'targetX/Y', so it's quite a lot of work. Don't do it for now.
return GetMaxRect();
}
const FilterPrimitiveDescription failureDescription(FilterPrimitiveDescription::eNone);
void
SVGFEConvolveMatrixElement::ComputeNeededSourceBBoxes(const nsIntRect& aTargetBBox,
nsTArray<nsIntRect>& aSourceBBoxes, const nsSVGFilterInstance& aInstance)
{
// XXX Precise results are possible but we're going to skip that work
// for now. Do nothing, which means the needed-box remains the
// source's output bounding box.
}
nsIntRect
SVGFEConvolveMatrixElement::ComputeChangeBBox(const nsTArray<nsIntRect>& aSourceChangeBoxes,
const nsSVGFilterInstance& aInstance)
{
// XXX Precise results are possible but we're going to skip that work
// for now.
return GetMaxRect();
}
static int32_t BoundInterval(int32_t aVal, int32_t aMax)
{
aVal = std::max(aVal, 0);
return std::min(aVal, aMax - 1);
}
static int32_t WrapInterval(int32_t aVal, int32_t aMax)
{
aVal = aVal % aMax;
return aVal < 0 ? aMax + aVal : aVal;
}
static void
ConvolvePixel(const uint8_t *aSourceData,
uint8_t *aTargetData,
int32_t aWidth, int32_t aHeight,
int32_t aStride,
int32_t aX, int32_t aY,
uint16_t aEdgeMode,
const float *aKernel,
float aDivisor, float aBias,
bool aPreserveAlpha,
int32_t aOrderX, int32_t aOrderY,
int32_t aTargetX, int32_t aTargetY)
{
float sum[4] = {0, 0, 0, 0};
aBias *= 255;
int32_t offsets[4] = {GFX_ARGB32_OFFSET_R,
GFX_ARGB32_OFFSET_G,
GFX_ARGB32_OFFSET_B,
GFX_ARGB32_OFFSET_A } ;
int32_t channels = aPreserveAlpha ? 3 : 4;
for (int32_t y = 0; y < aOrderY; y++) {
int32_t sampleY = aY + y - aTargetY;
bool overscanY = sampleY < 0 || sampleY >= aHeight;
for (int32_t x = 0; x < aOrderX; x++) {
int32_t sampleX = aX + x - aTargetX;
bool overscanX = sampleX < 0 || sampleX >= aWidth;
for (int32_t i = 0; i < channels; i++) {
if (overscanY || overscanX) {
switch (aEdgeMode) {
case SVG_EDGEMODE_DUPLICATE:
sum[i] +=
aSourceData[BoundInterval(sampleY, aHeight) * aStride +
BoundInterval(sampleX, aWidth) * 4 + offsets[i]] *
aKernel[aOrderX * y + x];
break;
case SVG_EDGEMODE_WRAP:
sum[i] +=
aSourceData[WrapInterval(sampleY, aHeight) * aStride +
WrapInterval(sampleX, aWidth) * 4 + offsets[i]] *
aKernel[aOrderX * y + x];
break;
default:
break;
}
} else {
sum[i] +=
aSourceData[sampleY * aStride + 4 * sampleX + offsets[i]] *
aKernel[aOrderX * y + x];
}
}
}
}
for (int32_t i = 0; i < channels; i++) {
aTargetData[aY * aStride + 4 * aX + offsets[i]] =
BoundInterval(static_cast<int32_t>(sum[i] / aDivisor + aBias), 256);
}
if (aPreserveAlpha) {
aTargetData[aY * aStride + 4 * aX + GFX_ARGB32_OFFSET_A] =
aSourceData[aY * aStride + 4 * aX + GFX_ARGB32_OFFSET_A];
}
}
nsresult
SVGFEConvolveMatrixElement::Filter(nsSVGFilterInstance* instance,
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& rect)
{
const SVGNumberList &kernelMatrix =
mNumberListAttributes[KERNELMATRIX].GetAnimValue();
uint32_t kmLength = kernelMatrix.Length();
@ -283,7 +179,7 @@ SVGFEConvolveMatrixElement::Filter(nsSVGFilterInstance* instance,
if (orderX <= 0 || orderY <= 0 ||
static_cast<uint32_t>(orderX * orderY) != kmLength) {
return NS_ERROR_FAILURE;
return failureDescription;
}
int32_t targetX, targetY;
@ -291,24 +187,24 @@ SVGFEConvolveMatrixElement::Filter(nsSVGFilterInstance* instance,
if (mIntegerAttributes[TARGET_X].IsExplicitlySet()) {
if (targetX < 0 || targetX >= orderX)
return NS_ERROR_FAILURE;
return failureDescription;
} else {
targetX = orderX / 2;
}
if (mIntegerAttributes[TARGET_Y].IsExplicitlySet()) {
if (targetY < 0 || targetY >= orderY)
return NS_ERROR_FAILURE;
return failureDescription;
} else {
targetY = orderY / 2;
}
if (orderX > NS_SVG_OFFSCREEN_MAX_DIMENSION ||
orderY > NS_SVG_OFFSCREEN_MAX_DIMENSION)
return NS_ERROR_FAILURE;
return failureDescription;
const fallible_t fallible = fallible_t();
nsAutoArrayPtr<float> kernel(new (fallible) float[orderX * orderY]);
if (!kernel)
return NS_ERROR_FAILURE;
return failureDescription;
for (uint32_t i = 0; i < kmLength; i++) {
kernel[kmLength - 1 - i] = kernelMatrix[i];
}
@ -317,7 +213,7 @@ SVGFEConvolveMatrixElement::Filter(nsSVGFilterInstance* instance,
if (mNumberAttributes[DIVISOR].IsExplicitlySet()) {
divisor = mNumberAttributes[DIVISOR].GetAnimValue();
if (divisor == 0)
return NS_ERROR_FAILURE;
return failureDescription;
} else {
divisor = kernel[0];
for (uint32_t i = 1; i < kmLength; i++)
@ -326,36 +222,25 @@ SVGFEConvolveMatrixElement::Filter(nsSVGFilterInstance* instance,
divisor = 1;
}
ScaleInfo info = SetupScalingFilter(instance, aSources[0], aTarget, rect,
&mNumberPairAttributes[KERNEL_UNIT_LENGTH]);
if (!info.mTarget)
return NS_ERROR_FAILURE;
uint16_t edgeMode = mEnumAttributes[EDGEMODE].GetAnimValue();
uint32_t edgeMode = mEnumAttributes[EDGEMODE].GetAnimValue();
bool preserveAlpha = mBooleanAttributes[PRESERVEALPHA].GetAnimValue();
float bias = mNumberAttributes[BIAS].GetAnimValue();
const nsIntRect& dataRect = info.mDataRect;
int32_t stride = info.mSource->Stride();
int32_t width = info.mSource->GetSize().width;
int32_t height = info.mSource->GetSize().height;
uint8_t *sourceData = info.mSource->Data();
uint8_t *targetData = info.mTarget->Data();
Size kernelUnitLength =
GetKernelUnitLength(aInstance, &mNumberPairAttributes[KERNEL_UNIT_LENGTH]);
for (int32_t y = dataRect.y; y < dataRect.YMost(); y++) {
for (int32_t x = dataRect.x; x < dataRect.XMost(); x++) {
ConvolvePixel(sourceData, targetData,
width, height, stride,
x, y,
edgeMode, kernel, divisor, bias, preserveAlpha,
orderX, orderY, targetX, targetY);
}
}
FilterPrimitiveDescription descr(FilterPrimitiveDescription::eConvolveMatrix);
AttributeMap& atts = descr.Attributes();
atts.Set(eConvolveMatrixKernelSize, IntSize(orderX, orderY));
atts.Set(eConvolveMatrixKernelMatrix, &kernelMatrix[0], kmLength);
atts.Set(eConvolveMatrixDivisor, divisor);
atts.Set(eConvolveMatrixBias, bias);
atts.Set(eConvolveMatrixTarget, IntPoint(targetX, targetY));
atts.Set(eConvolveMatrixEdgeMode, edgeMode);
atts.Set(eConvolveMatrixKernelUnitLength, kernelUnitLength);
atts.Set(eConvolveMatrixPreserveAlpha, preserveAlpha);
FinishScalingFilter(&info);
return NS_OK;
return descr;
}
bool

View File

@ -39,21 +39,14 @@ protected:
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
public:
virtual nsresult Filter(nsSVGFilterInstance* aInstance,
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect) MOZ_OVERRIDE;
virtual FilterPrimitiveDescription
GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
const IntRect& aFilterSubregion,
nsTArray<nsRefPtr<gfxASurface> >& aInputImages) MOZ_OVERRIDE;
virtual bool AttributeAffectsRendering(
int32_t aNameSpaceID, nsIAtom* aAttribute) const MOZ_OVERRIDE;
virtual nsSVGString& GetResultImageName() MOZ_OVERRIDE { return mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources) MOZ_OVERRIDE;
virtual nsIntRect ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
const nsSVGFilterInstance& aInstance) MOZ_OVERRIDE;
virtual void ComputeNeededSourceBBoxes(const nsIntRect& aTargetBBox,
nsTArray<nsIntRect>& aSourceBBoxes, const nsSVGFilterInstance& aInstance) MOZ_OVERRIDE;
virtual nsIntRect ComputeChangeBBox(const nsTArray<nsIntRect>& aSourceChangeBoxes,
const nsSVGFilterInstance& aInstance) MOZ_OVERRIDE;
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;
@ -72,10 +65,6 @@ public:
already_AddRefed<SVGAnimatedNumber> KernelUnitLengthY();
protected:
virtual bool OperatesOnPremultipledAlpha(int32_t) MOZ_OVERRIDE {
return !mBooleanAttributes[PRESERVEALPHA].GetAnimValue();
}
virtual NumberAttributesInfo GetNumberInfo() MOZ_OVERRIDE;
virtual NumberPairAttributesInfo GetNumberPairInfo() MOZ_OVERRIDE;
virtual IntegerAttributesInfo GetIntegerInfo() MOZ_OVERRIDE;

View File

@ -6,9 +6,12 @@
#include "mozilla/dom/SVGFEDiffuseLightingElement.h"
#include "mozilla/dom/SVGFEDiffuseLightingElementBinding.h"
#include "nsSVGUtils.h"
#include "nsSVGFilterInstance.h"
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEDiffuseLighting)
using namespace mozilla::gfx;
namespace mozilla {
namespace dom {
@ -57,6 +60,18 @@ SVGFEDiffuseLightingElement::KernelUnitLengthY()
nsSVGNumberPair::eSecond, this);
}
FilterPrimitiveDescription
SVGFEDiffuseLightingElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
const IntRect& aFilterSubregion,
nsTArray<nsRefPtr<gfxASurface> >& aInputImages)
{
float diffuseConstant = mNumberAttributes[DIFFUSE_CONSTANT].GetAnimValue();
FilterPrimitiveDescription descr(FilterPrimitiveDescription::eDiffuseLighting);
descr.Attributes().Set(eDiffuseLightingDiffuseConstant, diffuseConstant);
return AddLightingAttributes(descr, aInstance);
}
bool
SVGFEDiffuseLightingElement::AttributeAffectsRendering(int32_t aNameSpaceID,
nsIAtom* aAttribute) const
@ -66,26 +81,5 @@ SVGFEDiffuseLightingElement::AttributeAffectsRendering(int32_t aNameSpaceID,
aAttribute == nsGkAtoms::diffuseConstant);
}
//----------------------------------------------------------------------
// nsSVGElement methods
void
SVGFEDiffuseLightingElement::LightPixel(const float *N, const float *L,
nscolor color, uint8_t *targetData)
{
float diffuseNL =
mNumberAttributes[DIFFUSE_CONSTANT].GetAnimValue() * DOT(N, L);
if (diffuseNL < 0) diffuseNL = 0;
targetData[GFX_ARGB32_OFFSET_B] =
std::min(uint32_t(diffuseNL * NS_GET_B(color)), 255U);
targetData[GFX_ARGB32_OFFSET_G] =
std::min(uint32_t(diffuseNL * NS_GET_G(color)), 255U);
targetData[GFX_ARGB32_OFFSET_R] =
std::min(uint32_t(diffuseNL * NS_GET_R(color)), 255U);
targetData[GFX_ARGB32_OFFSET_A] = 255;
}
} // namespace dom
} // namespace mozilla

View File

@ -29,6 +29,10 @@ protected:
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
public:
virtual FilterPrimitiveDescription
GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
const IntRect& aFilterSubregion,
nsTArray<nsRefPtr<gfxASurface> >& aInputImages) MOZ_OVERRIDE;
virtual bool AttributeAffectsRendering(
int32_t aNameSpaceID, nsIAtom* aAttribute) const;
@ -40,11 +44,6 @@ public:
already_AddRefed<SVGAnimatedNumber> DiffuseConstant();
already_AddRefed<SVGAnimatedNumber> KernelUnitLengthX();
already_AddRefed<SVGAnimatedNumber> KernelUnitLengthY();
protected:
virtual void LightPixel(const float *N, const float *L,
nscolor color, uint8_t *targetData);
};
} // namespace dom

View File

@ -10,15 +10,11 @@
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEDisplacementMap)
using namespace mozilla::gfx;
namespace mozilla {
namespace dom {
// Channel Selectors
static const unsigned short SVG_CHANNEL_R = 1;
static const unsigned short SVG_CHANNEL_G = 2;
static const unsigned short SVG_CHANNEL_B = 3;
static const unsigned short SVG_CHANNEL_A = 4;
JSObject*
SVGFEDisplacementMapElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aScope)
{
@ -94,68 +90,20 @@ SVGFEDisplacementMapElement::YChannelSelector()
return mEnumAttributes[CHANNEL_Y].ToDOMAnimatedEnum(this);
}
nsresult
SVGFEDisplacementMapElement::Filter(nsSVGFilterInstance* instance,
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& rect)
FilterPrimitiveDescription
SVGFEDisplacementMapElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
const IntRect& aFilterSubregion,
nsTArray<nsRefPtr<gfxASurface> >& aInputImages)
{
float scale = instance->GetPrimitiveNumber(SVGContentUtils::XY,
&mNumberAttributes[SCALE]);
if (scale == 0.0f) {
CopyRect(aTarget, aSources[0], rect);
return NS_OK;
}
int32_t width = instance->GetSurfaceWidth();
int32_t height = instance->GetSurfaceHeight();
uint8_t* sourceData = aSources[0]->mImage->Data();
uint8_t* displacementData = aSources[1]->mImage->Data();
uint8_t* targetData = aTarget->mImage->Data();
uint32_t stride = aTarget->mImage->Stride();
static const uint8_t dummyData[4] = { 0, 0, 0, 0 };
static const uint16_t channelMap[5] = {
0,
GFX_ARGB32_OFFSET_R,
GFX_ARGB32_OFFSET_G,
GFX_ARGB32_OFFSET_B,
GFX_ARGB32_OFFSET_A };
uint16_t xChannel = channelMap[mEnumAttributes[CHANNEL_X].GetAnimValue()];
uint16_t yChannel = channelMap[mEnumAttributes[CHANNEL_Y].GetAnimValue()];
double scaleOver255 = scale / 255.0;
double scaleAdjustment = 0.5 - 0.5 * scale;
for (int32_t y = rect.y; y < rect.YMost(); y++) {
for (int32_t x = rect.x; x < rect.XMost(); x++) {
uint32_t targIndex = y * stride + 4 * x;
// At some point we might want to replace this with a bilinear sample.
int32_t sourceX = x +
NSToIntFloor(scaleOver255 * displacementData[targIndex + xChannel] +
scaleAdjustment);
int32_t sourceY = y +
NSToIntFloor(scaleOver255 * displacementData[targIndex + yChannel] +
scaleAdjustment);
bool outOfBounds = sourceX < 0 || sourceX >= width ||
sourceY < 0 || sourceY >= height;
const uint8_t* data;
int32_t multiplier;
if (outOfBounds) {
data = dummyData;
multiplier = 0;
} else {
data = sourceData;
multiplier = 1;
}
*(uint32_t*)(targetData + targIndex) =
*(uint32_t*)(data + multiplier * (sourceY * stride + 4 * sourceX));
}
}
return NS_OK;
float scale = aInstance->GetPrimitiveNumber(SVGContentUtils::XY,
&mNumberAttributes[SCALE]);
uint32_t xChannel = mEnumAttributes[CHANNEL_X].GetAnimValue();
uint32_t yChannel = mEnumAttributes[CHANNEL_Y].GetAnimValue();
FilterPrimitiveDescription descr(FilterPrimitiveDescription::eDisplacementMap);
descr.Attributes().Set(eDisplacementMapScale, scale);
descr.Attributes().Set(eDisplacementMapXChannel, xChannel);
descr.Attributes().Set(eDisplacementMapYChannel, yChannel);
return descr;
}
bool
@ -178,38 +126,6 @@ SVGFEDisplacementMapElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSou
aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN2], this));
}
nsIntRect
SVGFEDisplacementMapElement::ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
const nsSVGFilterInstance& aInstance)
{
// XXX we could do something clever here involving analysis of 'scale'
// to figure out the maximum displacement, and then return mIn1's bounds
// adjusted for the maximum displacement
return GetMaxRect();
}
void
SVGFEDisplacementMapElement::ComputeNeededSourceBBoxes(const nsIntRect& aTargetBBox,
nsTArray<nsIntRect>& aSourceBBoxes, const nsSVGFilterInstance& aInstance)
{
// in2 contains the displacements, which we read for each target pixel
aSourceBBoxes[1] = aTargetBBox;
// XXX to figure out which parts of 'in' we might read, we could
// do some analysis of 'scale' to figure out the maximum displacement.
// For now, just leave aSourceBBoxes[0] alone, i.e. assume we use its
// entire output bounding box.
// If we change this, we need to change coordinate assumptions above
}
nsIntRect
SVGFEDisplacementMapElement::ComputeChangeBBox(const nsTArray<nsIntRect>& aSourceChangeBoxes,
const nsSVGFilterInstance& aInstance)
{
// XXX we could do something clever here involving analysis of 'scale'
// to figure out the maximum displacement
return GetMaxRect();
}
//----------------------------------------------------------------------
// nsSVGElement methods

View File

@ -30,21 +30,14 @@ protected:
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
public:
virtual nsresult Filter(nsSVGFilterInstance* aInstance,
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect) MOZ_OVERRIDE;
virtual FilterPrimitiveDescription
GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
const IntRect& aFilterSubregion,
nsTArray<nsRefPtr<gfxASurface> >& aInputImages) MOZ_OVERRIDE;
virtual bool AttributeAffectsRendering(
int32_t aNameSpaceID, nsIAtom* aAttribute) const MOZ_OVERRIDE;
virtual nsSVGString& GetResultImageName() MOZ_OVERRIDE { return mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources) MOZ_OVERRIDE;
virtual nsIntRect ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
const nsSVGFilterInstance& aInstance) MOZ_OVERRIDE;
virtual void ComputeNeededSourceBBoxes(const nsIntRect& aTargetBBox,
nsTArray<nsIntRect>& aSourceBBoxes, const nsSVGFilterInstance& aInstance) MOZ_OVERRIDE;
virtual nsIntRect ComputeChangeBBox(const nsTArray<nsIntRect>& aSourceChangeBoxes,
const nsSVGFilterInstance& aInstance) MOZ_OVERRIDE;
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;
@ -56,22 +49,18 @@ public:
already_AddRefed<SVGAnimatedEnumeration> YChannelSelector();
protected:
virtual bool OperatesOnSRGB(nsSVGFilterInstance* aInstance,
int32_t aInput, Image* aImage) MOZ_OVERRIDE {
switch (aInput) {
virtual bool OperatesOnSRGB(int32_t aInputIndex,
bool aInputIsAlreadySRGB) MOZ_OVERRIDE {
switch (aInputIndex) {
case 0:
return aImage->mColorModel.mColorSpace == ColorModel::SRGB;
return aInputIsAlreadySRGB;
case 1:
return SVGFEDisplacementMapElementBase::OperatesOnSRGB(aInstance,
aInput, aImage);
return SVGFEDisplacementMapElementBase::OperatesOnSRGB(aInputIndex, aInputIsAlreadySRGB);
default:
NS_ERROR("Will not give correct output color model");
NS_ERROR("Will not give correct color model");
return false;
}
}
virtual bool OperatesOnPremultipledAlpha(int32_t aInput) MOZ_OVERRIDE {
return !(aInput == 1);
}
virtual NumberAttributesInfo GetNumberInfo() MOZ_OVERRIDE;
virtual EnumAttributesInfo GetEnumInfo() MOZ_OVERRIDE;

View File

@ -5,9 +5,12 @@
#include "mozilla/dom/SVGFEDistantLightElement.h"
#include "mozilla/dom/SVGFEDistantLightElementBinding.h"
#include "nsSVGFilterInstance.h"
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEDistantLight)
using namespace mozilla::gfx;
namespace mozilla {
namespace dom {
@ -40,6 +43,19 @@ SVGFEDistantLightElement::AttributeAffectsRendering(int32_t aNameSpaceID,
aAttribute == nsGkAtoms::elevation);
}
AttributeMap
SVGFEDistantLightElement::ComputeLightAttributes(nsSVGFilterInstance* aInstance)
{
float azimuth, elevation;
GetAnimatedNumberValues(&azimuth, &elevation, nullptr);
AttributeMap map;
map.Set(eLightType, (uint32_t)eLightTypeDistant);
map.Set(eDistantLightAzimuth, azimuth);
map.Set(eDistantLightElevation, elevation);
return map;
}
already_AddRefed<SVGAnimatedNumber>
SVGFEDistantLightElement::Azimuth()
{

View File

@ -9,14 +9,14 @@
#include "nsSVGFilters.h"
#include "nsSVGNumber2.h"
typedef SVGFEUnstyledElement SVGFEDistantLightElementBase;
nsresult NS_NewSVGFEDistantLightElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo);
namespace mozilla {
namespace dom {
typedef SVGFELightElement SVGFEDistantLightElementBase;
class SVGFEDistantLightElement : public SVGFEDistantLightElementBase
{
friend nsresult (::NS_NewSVGFEDistantLightElement(nsIContent **aResult,
@ -30,6 +30,7 @@ protected:
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
public:
virtual AttributeMap ComputeLightAttributes(nsSVGFilterInstance* aInstance) MOZ_OVERRIDE;
virtual bool AttributeAffectsRendering(
int32_t aNameSpaceID, nsIAtom* aAttribute) const MOZ_OVERRIDE;

View File

@ -7,9 +7,12 @@
#include "mozilla/dom/SVGFEFloodElementBinding.h"
#include "gfxContext.h"
#include "gfxColor.h"
#include "nsIFrame.h"
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEFlood)
using namespace mozilla::gfx;
namespace mozilla {
namespace dom {
@ -29,34 +32,26 @@ nsSVGElement::StringInfo SVGFEFloodElement::sStringInfo[1] =
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEFloodElement)
nsresult
SVGFEFloodElement::Filter(nsSVGFilterInstance *instance,
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect)
FilterPrimitiveDescription
SVGFEFloodElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
const IntRect& aFilterSubregion,
nsTArray<nsRefPtr<gfxASurface> >& aInputImages)
{
FilterPrimitiveDescription descr(FilterPrimitiveDescription::eFlood);
nsIFrame* frame = GetPrimaryFrame();
if (!frame) return NS_ERROR_FAILURE;
nsStyleContext* style = frame->StyleContext();
nscolor floodColor = style->StyleSVGReset()->mFloodColor;
float floodOpacity = style->StyleSVGReset()->mFloodOpacity;
gfxContext ctx(aTarget->mImage);
ctx.SetColor(gfxRGBA(NS_GET_R(floodColor) / 255.0,
NS_GET_G(floodColor) / 255.0,
NS_GET_B(floodColor) / 255.0,
NS_GET_A(floodColor) / 255.0 * floodOpacity));
ctx.Rectangle(aTarget->mFilterPrimitiveSubregion);
ctx.Fill();
return NS_OK;
}
nsIntRect
SVGFEFloodElement::ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
const nsSVGFilterInstance& aInstance)
{
return GetMaxRect();
if (frame) {
nsStyleContext* style = frame->StyleContext();
nscolor floodColor = style->StyleSVGReset()->mFloodColor;
float floodOpacity = style->StyleSVGReset()->mFloodOpacity;
Color color(NS_GET_R(floodColor) / 255.0,
NS_GET_G(floodColor) / 255.0,
NS_GET_B(floodColor) / 255.0,
NS_GET_A(floodColor) / 255.0 * floodOpacity);
descr.Attributes().Set(eFloodColor, color);
} else {
descr.Attributes().Set(eFloodColor, Color());
}
return descr;
}
//----------------------------------------------------------------------

View File

@ -31,13 +31,11 @@ protected:
public:
virtual bool SubregionIsUnionOfRegions() MOZ_OVERRIDE { return false; }
virtual nsresult Filter(nsSVGFilterInstance* aInstance,
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect) MOZ_OVERRIDE;
virtual FilterPrimitiveDescription
GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
const IntRect& aFilterSubregion,
nsTArray<nsRefPtr<gfxASurface> >& aInputImages) MOZ_OVERRIDE;
virtual nsSVGString& GetResultImageName() MOZ_OVERRIDE { return mStringAttributes[RESULT]; }
virtual nsIntRect ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
const nsSVGFilterInstance& aInstance) MOZ_OVERRIDE;
// nsIContent interface
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const MOZ_OVERRIDE;
@ -45,8 +43,7 @@ public:
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;
protected:
virtual bool OperatesOnSRGB(nsSVGFilterInstance*,
int32_t, Image*) MOZ_OVERRIDE { return true; }
virtual bool ProducesSRGB() MOZ_OVERRIDE { return true; }
virtual StringAttributesInfo GetStringInfo() MOZ_OVERRIDE;

Some files were not shown because too many files have changed in this diff Show More