mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 04:45:45 +00:00
Merge from mozilla-central.
This commit is contained in:
commit
104953870f
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0"?>
|
||||
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist" lastupdate="1324588296000">
|
||||
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist" lastupdate="1325216886000">
|
||||
<emItems>
|
||||
<emItem blockID="i41" id="{99079a25-328f-4bd4-be04-00955acaa0a7}">
|
||||
<versionRange minVersion="0.1" maxVersion="4.3.1.00" severity="1">
|
||||
@ -116,6 +116,8 @@
|
||||
<versionRange severity="3">
|
||||
</versionRange>
|
||||
</emItem>
|
||||
<emItem blockID="i48" id="admin@youtubespeedup.com">
|
||||
</emItem>
|
||||
<emItem blockID="i20" id="{AB2CE124-6272-4b12-94A9-7303C7397BD1}">
|
||||
<versionRange minVersion="0.1" maxVersion="5.2.0.7164" severity="1">
|
||||
</versionRange>
|
||||
|
@ -46,6 +46,10 @@
|
||||
label="&spellAddToDictionary.label;"
|
||||
accesskey="&spellAddToDictionary.accesskey;"
|
||||
oncommand="InlineSpellCheckerUI.addToDictionary();"/>
|
||||
<menuitem id="spell-undo-add-to-dictionary"
|
||||
label="&spellUndoAddToDictionary.label;"
|
||||
accesskey="&spellUndoAddToDictionary.accesskey;"
|
||||
oncommand="InlineSpellCheckerUI.undoAddToDictionary();" />
|
||||
<menuseparator id="spell-suggestions-separator"/>
|
||||
<menuitem id="context-openlinkincurrent"
|
||||
label="&openLinkCmdInCurrent.label;"
|
||||
|
@ -337,6 +337,7 @@ nsContextMenu.prototype = {
|
||||
.setAttribute("checked", canSpell && InlineSpellCheckerUI.enabled);
|
||||
|
||||
this.showItem("spell-add-to-dictionary", onMisspelling);
|
||||
this.showItem("spell-undo-add-to-dictionary", InlineSpellCheckerUI.canUndo());
|
||||
|
||||
// suggestion list
|
||||
this.showItem("spell-suggestions-separator", onMisspelling);
|
||||
|
@ -23,7 +23,7 @@ SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(function() {
|
||||
// Need privs because the feed seems to have an about:feeds principal or some
|
||||
// such. It's not same-origin with us in any case.
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
is($("testFrame").contentDocument.documentElement.id, "feedHandler",
|
||||
"Feed served as text/xml without a channel/link should have been sniffed");
|
||||
});
|
||||
|
@ -23,7 +23,7 @@ SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(function() {
|
||||
// Need privs because the feed seems to have an about:feeds principal or some
|
||||
// such. It's not same-origin with us in any case.
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
is($("testFrame").contentDocument.documentElement.id, "",
|
||||
"Text got sniffed as a feed?");
|
||||
});
|
||||
|
@ -19,6 +19,7 @@ Browser context menu tests.
|
||||
/** Test for Login Manager: multiple login autocomplete. **/
|
||||
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
Components.utils.import("resource://gre/modules/InlineSpellChecker.jsm");
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
@ -514,12 +515,36 @@ function runTest(testNum) {
|
||||
"---", null,
|
||||
"spell-add-dictionaries", true], null,
|
||||
].concat(inspectItems));
|
||||
|
||||
contextMenu.ownerDocument.getElementById("spell-add-to-dictionary").doCommand(); // Add to dictionary
|
||||
closeContextMenu();
|
||||
openContextMenuFor(contenteditable); // Invoke context menu for next test.
|
||||
openContextMenuFor(textarea, false, true); // Invoke context menu for next test.
|
||||
break;
|
||||
|
||||
case 15:
|
||||
// Context menu for textarea after a word has been added
|
||||
// to the dictionary
|
||||
checkContextMenu(["spell-undo-add-to-dictionary", true,
|
||||
"context-undo", false,
|
||||
"---", null,
|
||||
"context-cut", false,
|
||||
"context-copy", false,
|
||||
"context-paste", null, // ignore clipboard state
|
||||
"context-delete", false,
|
||||
"---", null,
|
||||
"context-selectall", true,
|
||||
"---", null,
|
||||
"spell-check-enabled", true,
|
||||
"spell-dictionaries", true,
|
||||
["spell-check-dictionary-en-US", true,
|
||||
"---", null,
|
||||
"spell-add-dictionaries", true], null,
|
||||
].concat(inspectItems));
|
||||
contextMenu.ownerDocument.getElementById("spell-undo-add-to-dictionary").doCommand(); // Undo add to dictionary
|
||||
closeContextMenu();
|
||||
openContextMenuFor(contenteditable);
|
||||
break;
|
||||
|
||||
case 15:
|
||||
case 16:
|
||||
// Context menu for contenteditable
|
||||
checkContextMenu(["spell-no-suggestions", false,
|
||||
"spell-add-to-dictionary", true,
|
||||
@ -544,7 +569,7 @@ function runTest(testNum) {
|
||||
openContextMenuFor(inputspell); // Invoke context menu for next test.
|
||||
break;
|
||||
|
||||
case 16:
|
||||
case 17:
|
||||
// Context menu for spell-check input
|
||||
checkContextMenu(["*prodigality", true, // spelling suggestion
|
||||
"spell-add-to-dictionary", true,
|
||||
@ -569,13 +594,13 @@ function runTest(testNum) {
|
||||
openContextMenuFor(link); // Invoke context menu for next test.
|
||||
break;
|
||||
|
||||
case 17:
|
||||
case 18:
|
||||
executeCopyCommand("cmd_copyLink", "http://mozilla.com/");
|
||||
closeContextMenu();
|
||||
openContextMenuFor(pagemenu); // Invoke context menu for next test.
|
||||
break;
|
||||
|
||||
case 18:
|
||||
case 19:
|
||||
// Context menu for element with assigned content context menu
|
||||
checkContextMenu(["+Plain item", {type: "", icon: "", checked: false, disabled: false},
|
||||
"+Disabled item", {type: "", icon: "", checked: false, disabled: true},
|
||||
@ -618,7 +643,7 @@ function runTest(testNum) {
|
||||
openContextMenuFor(pagemenu, true); // Invoke context menu for next test.
|
||||
break;
|
||||
|
||||
case 19:
|
||||
case 20:
|
||||
// Context menu for element with assigned content context menu
|
||||
// The shift key should bypass content context menu processing
|
||||
checkContextMenu(["context-back", false,
|
||||
|
@ -23,11 +23,9 @@ var rv = { tests: null };
|
||||
var testCheckInterval = null;
|
||||
|
||||
function startTest() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
|
||||
var url = window.location.href.replace(/test_feed_discovery\.html/,
|
||||
'feed_discovery.html');
|
||||
window.openDialog(url, '', 'dialog=no,width=10,height=10', rv);
|
||||
SpecialPowers.openDialog(window, [url, '', 'dialog=no,width=10,height=10', rv]);
|
||||
testCheckInterval = window.setInterval(tryIfTestIsFinished, 500);
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=494328
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
addLoadEvent(function() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
var links = $("testFrame").contentDocument.getElementById("feedContent").querySelectorAll("div.enclosure > a");
|
||||
is(links[0].textContent, "Episode 1", "filename decoded incorrectly");
|
||||
is(links[1].textContent, "Episode #2", "filename decoded incorrectly");
|
||||
|
@ -140,7 +140,7 @@ function restoreSession() {
|
||||
ss.setWindowState(top, stateString, true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// restore the session into a new window and close the current tab
|
||||
var newWindow = top.openDialog(top.location, "_blank", "chrome,dialog=no,all");
|
||||
newWindow.addEventListener("load", function() {
|
||||
|
@ -317,11 +317,9 @@ nsGNOMEShellService::SetDefaultBrowser(bool aClaimAllTypes,
|
||||
rv = bundleService->CreateBundle(BRAND_PROPERTIES, getter_AddRefs(brandBundle));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsString brandShortName, brandFullName;
|
||||
nsString brandShortName;
|
||||
brandBundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(),
|
||||
getter_Copies(brandShortName));
|
||||
brandBundle->GetStringFromName(NS_LITERAL_STRING("brandFullName").get(),
|
||||
getter_Copies(brandFullName));
|
||||
|
||||
// use brandShortName as the application id.
|
||||
NS_ConvertUTF16toUTF8 id(brandShortName);
|
||||
|
@ -1025,12 +1025,7 @@ toolbar[iconsize="small"] #feed-button {
|
||||
#page-proxy-favicon {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
#page-proxy-stack {
|
||||
width: 24px;
|
||||
height: 20px;
|
||||
padding: 2px 4px;
|
||||
margin: 2px 4px;
|
||||
}
|
||||
|
||||
#page-proxy-favicon:not([src]) {
|
||||
|
@ -1111,11 +1111,6 @@ toolbar[mode="icons"] #zoom-in-button {
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
#page-proxy-stack {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
#page-proxy-favicon:not([src]) {
|
||||
list-style-image: url("chrome://mozapps/skin/places/defaultFavicon.png");
|
||||
}
|
||||
|
@ -1490,12 +1490,7 @@ html|*.urlbar-input:-moz-lwtheme:-moz-placeholder,
|
||||
#page-proxy-favicon {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
#page-proxy-stack {
|
||||
width: 24px;
|
||||
height: 18px;
|
||||
padding: 1px 4px;
|
||||
margin: 1px 4px;
|
||||
}
|
||||
|
||||
#page-proxy-favicon:not([src]) {
|
||||
|
@ -62,6 +62,7 @@ ifeq (android,$(MOZ_WIDGET_TOOLKIT))
|
||||
mobile/sutagent/android/watcher \
|
||||
mobile/sutagent/android/ffxcp \
|
||||
mobile/sutagent/android/fencp \
|
||||
mobile/robocop \
|
||||
$(NULL)
|
||||
endif
|
||||
endif
|
||||
|
@ -409,10 +409,7 @@ user_pref("extensions.getAddons.search.url", "http://%(server)s/extensions-dummy
|
||||
|
||||
if useServerLocations == False:
|
||||
part = """
|
||||
user_pref("capability.principal.codebase.p1.granted",
|
||||
"UniversalXPConnect UniversalBrowserRead UniversalBrowserWrite \
|
||||
UniversalPreferencesRead UniversalPreferencesWrite \
|
||||
UniversalFileRead");
|
||||
user_pref("capability.principal.codebase.p1.granted", "UniversalXPConnect");
|
||||
user_pref("capability.principal.codebase.p1.id", "%(origin)s");
|
||||
user_pref("capability.principal.codebase.p1.subjectName", "");
|
||||
""" % { "origin": "http://" + self.webServer + ":" + str(self.httpPort) }
|
||||
@ -422,10 +419,7 @@ user_pref("capability.principal.codebase.p1.subjectName", "");
|
||||
privileged = filter(lambda loc: "privileged" in loc.options, locations)
|
||||
for (i, l) in itertools.izip(itertools.count(1), privileged):
|
||||
part = """
|
||||
user_pref("capability.principal.codebase.p%(i)d.granted",
|
||||
"UniversalXPConnect UniversalBrowserRead UniversalBrowserWrite \
|
||||
UniversalPreferencesRead UniversalPreferencesWrite \
|
||||
UniversalFileRead");
|
||||
user_pref("capability.principal.codebase.p%(i)d.granted", "UniversalXPConnect");
|
||||
user_pref("capability.principal.codebase.p%(i)d.id", "%(origin)s");
|
||||
user_pref("capability.principal.codebase.p%(i)d.subjectName", "");
|
||||
""" % { "i": i,
|
||||
|
53
build/mobile/robocop/Assert.java.in
Normal file
53
build/mobile/robocop/Assert.java.in
Normal file
@ -0,0 +1,53 @@
|
||||
#filter substitution
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Firefox Mobile Test Framework.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Trevor Fairey <tnfairey@gmail.com>
|
||||
* David Burns <dburns@mozilla.com>
|
||||
* Joel Maher <joel.maher@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
package @ANDROID_PACKAGE_NAME@;
|
||||
|
||||
public interface Assert {
|
||||
void dumpLog(String message);
|
||||
void setLogFile(String filename);
|
||||
|
||||
void ok(boolean condition, String name, String diag);
|
||||
void is(Object a, Object b, String name);
|
||||
void isnot(Object a, Object b, String name);
|
||||
void todo(boolean condition, String name, String diag);
|
||||
void todo_is(Object a, Object b, String name);
|
||||
void todo_isnot(Object a, Object b, String name);
|
||||
void info(String name, String message);
|
||||
}
|
212
build/mobile/robocop/FennecNativeAssert.java.in
Normal file
212
build/mobile/robocop/FennecNativeAssert.java.in
Normal file
@ -0,0 +1,212 @@
|
||||
#filter substitution
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Firefox Mobile Test Framework.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Trevor Fairey <tnfairey@gmail.com>
|
||||
* David Burns <dburns@mozilla.com>
|
||||
* Joel Maher <joel.maher@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
package @ANDROID_PACKAGE_NAME@;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import java.lang.Class;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.Long;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import org.json.*;
|
||||
|
||||
import com.jayway.android.robotium.solo.Solo;
|
||||
|
||||
public class FennecNativeAssert implements Assert {
|
||||
// Map of IDs to element names.
|
||||
private HashMap locators = null;
|
||||
private String logFile = null;
|
||||
|
||||
// Objects for reflexive access of fennec classes.
|
||||
|
||||
private LinkedList<testInfo> testList = new LinkedList<testInfo>();
|
||||
|
||||
// If waiting for an event.
|
||||
private boolean asleep = false;
|
||||
|
||||
public FennecNativeAssert(){
|
||||
}
|
||||
|
||||
// Write information to a logfile and logcat
|
||||
public void dumpLog(String message)
|
||||
{
|
||||
File file = new File(logFile);
|
||||
BufferedWriter bw = null;
|
||||
|
||||
try {
|
||||
bw = new BufferedWriter(new FileWriter(logFile, true));
|
||||
bw.write(message);
|
||||
bw.newLine();
|
||||
} catch(IOException e) {
|
||||
Log.e("Robocop", "exception with file writer on: " + logFile);
|
||||
} finally {
|
||||
try {
|
||||
if (bw != null) {
|
||||
bw.flush();
|
||||
bw.close();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
Log.i("Robocop", message);
|
||||
}
|
||||
|
||||
// Set the filename used for dumpLog.
|
||||
public void setLogFile(String filename)
|
||||
{
|
||||
logFile = filename;
|
||||
}
|
||||
|
||||
|
||||
class testInfo {
|
||||
public boolean result;
|
||||
public String name;
|
||||
public String diag;
|
||||
public boolean todo;
|
||||
public testInfo(boolean r, String n, String d, boolean t) {
|
||||
result = r;
|
||||
name = n;
|
||||
diag = d;
|
||||
todo = t;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void _logResult(testInfo test, String passString, String failString)
|
||||
{
|
||||
boolean isError = true;
|
||||
String resultString = failString;
|
||||
if(test.result || test.todo){
|
||||
isError = false;
|
||||
}
|
||||
if(test.result)
|
||||
{
|
||||
resultString = passString;
|
||||
}
|
||||
String diag= test.name;
|
||||
if(test.diag!=null) diag+= " - " + test.diag;
|
||||
|
||||
String message = resultString + " | " + "ROBOCOP" + " | " + diag;
|
||||
if(isError) {
|
||||
if(logFile == null)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
else {
|
||||
dumpLog(message);
|
||||
}
|
||||
}
|
||||
else {
|
||||
dumpLog(message);
|
||||
}
|
||||
}
|
||||
|
||||
public void ok(boolean condition, String name, String diag) {
|
||||
testInfo test = new testInfo(condition, name, diag, false);
|
||||
_logResult(test, "TEST-PASS", "TEST-UNEXPECTED-FAIL");
|
||||
testList.add(test);
|
||||
}
|
||||
|
||||
public void is(Object a, Object b, String name) {
|
||||
boolean pass = a.equals(b);
|
||||
String diag = "got " + a.toString() + ", expected " + b.toString();
|
||||
if(pass) {
|
||||
diag = a.toString() + " should equal " + b.toString();
|
||||
}
|
||||
ok(pass, name, diag);
|
||||
}
|
||||
|
||||
public void isnot(Object a, Object b, String name) {
|
||||
boolean pass = !a.equals(b);
|
||||
String diag = "didn't expect " + a.toString() + ", but got it";
|
||||
if(pass) {
|
||||
diag = a.toString() + " should not equal " + b.toString();
|
||||
}
|
||||
ok(pass, name, diag);
|
||||
}
|
||||
|
||||
public void todo(boolean condition, String name, String diag) {
|
||||
testInfo test = new testInfo(condition, name, diag, true);
|
||||
_logResult(test, "TEST-UNEXPECTED-PASS", "TEST-KNOWN-FAIL");
|
||||
testList.add(test);
|
||||
}
|
||||
|
||||
public void todo_is(Object a, Object b, String name) {
|
||||
boolean pass = a.equals(b);
|
||||
String diag = "got " + a.toString() + ", expected " + b.toString();
|
||||
if(pass) {
|
||||
diag = a.toString() + " should equal " + b.toString();
|
||||
}
|
||||
todo(pass, name, diag);
|
||||
}
|
||||
|
||||
public void todo_isnot(Object a, Object b, String name) {
|
||||
boolean pass = !a.equals(b);
|
||||
String diag = "didn't expect " + a.toString() + ", but got it";
|
||||
if(pass) {
|
||||
diag = a.toString() + " should not equal " + b.toString();
|
||||
}
|
||||
todo(pass, name, diag);
|
||||
}
|
||||
|
||||
public void info(String name, String message) {
|
||||
testInfo test = new testInfo(true, name, message, false);
|
||||
_logResult(test, "TEST-INFO", "INFO FAILED?");
|
||||
}
|
||||
}
|
@ -51,16 +51,25 @@ JAVAFILES = \
|
||||
R.java \
|
||||
|
||||
_JAVA_HARNESS = \
|
||||
Actions.java \
|
||||
Assert.java \
|
||||
Driver.java \
|
||||
Element.java \
|
||||
Actions.java \
|
||||
FennecNativeActions.java \
|
||||
FennecNativeAssert.java \
|
||||
FennecNativeDriver.java \
|
||||
FennecNativeElement.java \
|
||||
RoboCopException.java \
|
||||
FennecNativeDriver.java \
|
||||
FennecNativeActions.java \
|
||||
$(NULL)
|
||||
|
||||
_JAVA_TESTS = $(patsubst $(TESTPATH)/%.in,%,$(wildcard $(TESTPATH)/*.java.in))
|
||||
|
||||
_TEST_FILES = \
|
||||
$(TESTPATH)/robocop_blank_01.html \
|
||||
$(TESTPATH)/robocop_blank_02.html \
|
||||
$(TESTPATH)/robocop_blank_03.html \
|
||||
$(NULL)
|
||||
|
||||
_ROBOCOP_TOOLS = \
|
||||
$(TESTPATH)/robocop.ini \
|
||||
parse_ids.py \
|
||||
@ -104,13 +113,16 @@ $(_ROBOCOP_TOOLS):
|
||||
cp $(TESTPATH)/robocop.ini robocop.ini
|
||||
cp $(srcdir)/parse_ids.txt parse_ids.txt
|
||||
|
||||
libs:: $(_TEST_FILES)
|
||||
$(NSINSTALL) -D $(DEPTH)/_tests/testing/mochitest/tests/robocop
|
||||
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/robocop/
|
||||
|
||||
tools:: robocop.apk
|
||||
|
||||
classes.dex: robocop.ap_
|
||||
classes.dex: $(_ROBOCOP_TOOLS)
|
||||
classes.dex: $(_JAVA_HARNESS)
|
||||
classes.dex: $(_JAVA_TESTS)
|
||||
classes.dex: $(TEST_FILES)
|
||||
$(NSINSTALL) -D classes
|
||||
$(JAVAC) $(JAVAC_FLAGS) -d classes $(JAVAFILES) $(_JAVA_HARNESS) $(addprefix $(DEPTH)/mobile/android/base/tests/,$(_JAVA_TESTS))
|
||||
$(DX) --dex --output=$@ classes $(ROBOTIUM_PATH)
|
||||
@ -118,15 +130,12 @@ classes.dex: $(TEST_FILES)
|
||||
robocop.ap_: AndroidManifest.xml
|
||||
$(AAPT) package -f -M AndroidManifest.xml -I $(ANDROID_SDK)/android.jar -I . -S res -F $@ -J ./
|
||||
|
||||
robocop-unsigned-unaligned.apk: robocop.ap_ classes.dex
|
||||
$(APKBUILDER) $@ -v $(APKBUILDER_FLAGS) -z robocop.ap_ -f classes.dex
|
||||
|
||||
robocop-unaligned.apk: robocop-unsigned-unaligned.apk
|
||||
cp robocop-unsigned-unaligned.apk $@
|
||||
jarsigner -keystore ~/.android/debug.keystore -storepass android -keypass android $@ androiddebugkey
|
||||
|
||||
robocop.apk: robocop-unaligned.apk
|
||||
$(ZIPALIGN) -f -v 4 robocop-unaligned.apk $@
|
||||
robocop.apk: robocop.ap_ classes.dex
|
||||
$(APKBUILDER) robocop-raw.apk -v $(APKBUILDER_FLAGS) -z robocop.ap_ -f classes.dex
|
||||
ifdef JARSIGNER
|
||||
$(JARSIGNER) robocop-raw.apk
|
||||
endif
|
||||
$(ZIPALIGN) -f -v 4 robocop-raw.apk $@
|
||||
cp $(TESTPATH)/robocop.ini robocop.ini
|
||||
cp $(srcdir)/parse_ids.py parse_ids.py
|
||||
|
||||
|
@ -1088,19 +1088,6 @@ nsScriptSecurityManager::CheckSameOriginDOMProp(nsIPrincipal* aSubject,
|
||||
if (aObject == mSystemPrincipal)
|
||||
return NS_ERROR_DOM_PROP_ACCESS_DENIED;
|
||||
|
||||
/*
|
||||
* If we failed the origin tests it still might be the case that we
|
||||
* are a signed script and have permissions to do this operation.
|
||||
* Check for that here.
|
||||
*/
|
||||
bool capabilityEnabled = false;
|
||||
const char* cap = aAction == nsIXPCSecurityManager::ACCESS_SET_PROPERTY ?
|
||||
"UniversalBrowserWrite" : "UniversalBrowserRead";
|
||||
rv = IsCapabilityEnabled(cap, &capabilityEnabled);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (capabilityEnabled)
|
||||
return NS_OK;
|
||||
|
||||
/*
|
||||
** Access tests failed, so now report error.
|
||||
*/
|
||||
@ -1321,7 +1308,7 @@ nsScriptSecurityManager::CheckLoadURIFromScript(JSContext *cx, nsIURI *aURI)
|
||||
}
|
||||
|
||||
// See if we're attempting to load a file: URI. If so, let a
|
||||
// UniversalFileRead capability trump the above check.
|
||||
// UniversalXPConnect capability trump the above check.
|
||||
bool isFile = false;
|
||||
bool isRes = false;
|
||||
if (NS_FAILED(aURI->SchemeIs("file", &isFile)) ||
|
||||
@ -1330,7 +1317,7 @@ nsScriptSecurityManager::CheckLoadURIFromScript(JSContext *cx, nsIURI *aURI)
|
||||
if (isFile || isRes)
|
||||
{
|
||||
bool enabled;
|
||||
if (NS_FAILED(IsCapabilityEnabled("UniversalFileRead", &enabled)))
|
||||
if (NS_FAILED(IsCapabilityEnabled("UniversalXPConnect", &enabled)))
|
||||
return NS_ERROR_FAILURE;
|
||||
if (enabled)
|
||||
return NS_OK;
|
||||
|
@ -220,10 +220,6 @@ LIBXUL_LIBS=@LIBXUL_LIBS@
|
||||
ENABLE_STRIP = @ENABLE_STRIP@
|
||||
PKG_SKIP_STRIP = @PKG_SKIP_STRIP@
|
||||
|
||||
ClientWallet=1
|
||||
CookieManagement=1
|
||||
SingleSignon=1
|
||||
|
||||
MOZ_POST_DSO_LIB_COMMAND = @MOZ_POST_DSO_LIB_COMMAND@
|
||||
MOZ_POST_PROGRAM_COMMAND = @MOZ_POST_PROGRAM_COMMAND@
|
||||
|
||||
@ -596,9 +592,6 @@ CXX_WRAPPER = @CXX_WRAPPER@
|
||||
|
||||
MOZ_DEMANGLE_SYMBOLS = @MOZ_DEMANGLE_SYMBOLS@
|
||||
|
||||
# XXX - these need to be cleaned up and have real checks added -cls
|
||||
CM_BLDTYPE=dbg
|
||||
AWT_11=1
|
||||
OS_TARGET=@OS_TARGET@
|
||||
OS_ARCH=@OS_ARCH@
|
||||
OS_RELEASE=@OS_RELEASE@
|
||||
|
82
configure.in
82
configure.in
@ -336,6 +336,7 @@ if test -n "$gonkdir" ; then
|
||||
fi
|
||||
|
||||
AC_DEFINE(ANDROID)
|
||||
AC_DEFINE(HAVE_SYS_UIO_H)
|
||||
CROSS_COMPILE=1
|
||||
MOZ_CHROME_FILE_FORMAT=omni
|
||||
ZLIB_DIR=yes
|
||||
@ -1864,20 +1865,15 @@ if test "$GNU_CC"; then
|
||||
_MOZ_RTTI_FLAGS_ON=-frtti
|
||||
_MOZ_RTTI_FLAGS_OFF=-fno-rtti
|
||||
|
||||
# Turn on GNU-specific warnings:
|
||||
# -Wall - turn on a lot of warnings
|
||||
# -pedantic - this is turned on below
|
||||
# -Wpointer-arith - enabled with -pedantic, but good to have even if not
|
||||
# -Werror=declaration-after-statement - MSVC doesn't like these
|
||||
# -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
|
||||
#
|
||||
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall -Wpointer-arith -Wdeclaration-after-statement -Wempty-body"
|
||||
|
||||
# Turn off the following warnings that -Wall/-pedantic turn on:
|
||||
# -Woverlength-strings - we exceed the minimum maximum length all the time
|
||||
#
|
||||
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wno-overlength-strings"
|
||||
|
||||
# Turn on GNU specific features
|
||||
# -Wall - turn on all warnings
|
||||
# -pedantic - make compiler warn about non-ANSI stuff, and
|
||||
# be a little bit stricter
|
||||
# -Wdeclaration-after-statement - MSVC doesn't like these
|
||||
# Warnings slamm took out for now (these were giving more noise than help):
|
||||
# -Wbad-function-cast - warns when casting a function to a new return type
|
||||
# -Wshadow - removed because it generates more noise than help --pete
|
||||
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall -W -Wno-unused -Wpointer-arith -Wdeclaration-after-statement"
|
||||
if test -z "$INTEL_CC" -a -z "$CLANG_CC"; then
|
||||
# Don't use -Wcast-align with ICC or clang
|
||||
case "$CPU_ARCH" in
|
||||
@ -1893,26 +1889,12 @@ if test "$GNU_CC"; then
|
||||
dnl Turn pedantic on but disable the warnings for long long
|
||||
_PEDANTIC=1
|
||||
|
||||
if test -z "$INTEL_CC"; then
|
||||
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -W"
|
||||
fi
|
||||
|
||||
_DEFINES_CFLAGS='-include $(DEPTH)/mozilla-config.h -DMOZILLA_CLIENT'
|
||||
_USE_CPP_INCLUDE_FLAG=1
|
||||
|
||||
AC_CACHE_CHECK(whether the compiler supports -Wtype-limits,
|
||||
ac_cc_has_wtype_limits,
|
||||
[
|
||||
AC_LANG_SAVE
|
||||
AC_LANG_C
|
||||
_SAVE_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS -Wtype-limits"
|
||||
AC_TRY_COMPILE([],
|
||||
[return(0);],
|
||||
ac_cc_has_wtype_limits="yes",
|
||||
ac_cc_has_wtype_limits="no")
|
||||
CFLAGS="$_SAVE_CFLAGS"
|
||||
AC_LANG_RESTORE
|
||||
])
|
||||
if test "$ac_cc_has_wtype_limits" = "yes"; then
|
||||
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wtype-limits"
|
||||
fi
|
||||
elif test "$SOLARIS_SUNPRO_CC"; then
|
||||
DSO_CFLAGS=''
|
||||
if test "$CPU_ARCH" = "sparc"; then
|
||||
@ -1940,22 +1922,8 @@ fi
|
||||
if test "$GNU_CXX"; then
|
||||
# FIXME: Let us build with strict aliasing. bug 414641.
|
||||
CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-strict-aliasing"
|
||||
|
||||
# Turn on GNU-specific warnings:
|
||||
# -Wall - turn on a lot of warnings
|
||||
# -pedantic - this is turned on below
|
||||
# -Wpointer-arith - enabled with -pedantic, but good to have even if not
|
||||
# -Woverloaded-virtual - ???
|
||||
# -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
|
||||
#
|
||||
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall -Wpointer-arith -Woverloaded-virtual -Wempty-body"
|
||||
|
||||
# Turn off the following warnings that -Wall/-pedantic turn on:
|
||||
# -Woverlength-strings - we exceed the minimum maximum length all the time
|
||||
# -Wctor-dtor-privacy - ???
|
||||
#
|
||||
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-overlength-strings -Wno-ctor-dtor-privacy"
|
||||
|
||||
# Turn on GNU specific features
|
||||
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall -Wpointer-arith -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor"
|
||||
if test -z "$INTEL_CXX" -a -z "$CLANG_CXX"; then
|
||||
# Don't use -Wcast-align with ICC or clang
|
||||
case "$CPU_ARCH" in
|
||||
@ -2056,24 +2024,6 @@ if test "$GNU_CXX"; then
|
||||
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=return-type"
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK(whether the compiler supports -Wtype-limits,
|
||||
ac_has_wtype_limits,
|
||||
[
|
||||
AC_LANG_SAVE
|
||||
AC_LANG_CPLUSPLUS
|
||||
_SAVE_CXXFLAGS="$CXXFLAGS"
|
||||
CXXFLAGS="$CXXFLAGS -Wtype-limits"
|
||||
AC_TRY_COMPILE([],
|
||||
[return(0);],
|
||||
ac_has_wtype_limits="yes",
|
||||
ac_has_wtype_limits="no")
|
||||
CXXFLAGS="$_SAVE_CXXFLAGS"
|
||||
AC_LANG_RESTORE
|
||||
])
|
||||
if test "$ac_has_wtype_limits" = "yes"; then
|
||||
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wtype-limits"
|
||||
fi
|
||||
|
||||
else
|
||||
_DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -D_MOZILLA_CONFIG_H_ $(ACDEFINES)'
|
||||
fi
|
||||
|
@ -232,10 +232,9 @@ public:
|
||||
static bool IsCallerTrustedForWrite();
|
||||
|
||||
/**
|
||||
* Check whether a caller is trusted to have aCapability. This also
|
||||
* checks for UniversalXPConnect in addition to aCapability.
|
||||
* Check whether a caller has UniversalXPConnect.
|
||||
*/
|
||||
static bool IsCallerTrustedForCapability(const char* aCapability);
|
||||
static bool CallerHasUniversalXPConnect();
|
||||
|
||||
static bool IsImageSrcSetDisabled();
|
||||
|
||||
|
@ -1148,16 +1148,9 @@ nsContentUtils::Shutdown()
|
||||
|
||||
// static
|
||||
bool
|
||||
nsContentUtils::IsCallerTrustedForCapability(const char* aCapability)
|
||||
nsContentUtils::CallerHasUniversalXPConnect()
|
||||
{
|
||||
// The secman really should handle UniversalXPConnect case, since that
|
||||
// should include UniversalBrowserRead... doesn't right now, though.
|
||||
bool hasCap;
|
||||
if (NS_FAILED(sSecurityManager->IsCapabilityEnabled(aCapability, &hasCap)))
|
||||
return false;
|
||||
if (hasCap)
|
||||
return true;
|
||||
|
||||
if (NS_FAILED(sSecurityManager->IsCapabilityEnabled("UniversalXPConnect",
|
||||
&hasCap)))
|
||||
return false;
|
||||
@ -1227,16 +1220,9 @@ nsContentUtils::CanCallerAccess(nsIPrincipal* aSubjectPrincipal,
|
||||
return true;
|
||||
}
|
||||
|
||||
// The subject doesn't subsume aPrincipal. Allow access only if the subject
|
||||
// has either "UniversalXPConnect" (if aPrincipal is system principal) or
|
||||
// "UniversalBrowserRead" (in all other cases).
|
||||
bool isSystem;
|
||||
rv = sSecurityManager->IsSystemPrincipal(aPrincipal, &isSystem);
|
||||
isSystem = NS_FAILED(rv) || isSystem;
|
||||
const char* capability =
|
||||
NS_FAILED(rv) || isSystem ? "UniversalXPConnect" : "UniversalBrowserRead";
|
||||
|
||||
return IsCallerTrustedForCapability(capability);
|
||||
// The subject doesn't subsume aPrincipal. Allow access only if the subject
|
||||
// has UniversalXPConnect.
|
||||
return CallerHasUniversalXPConnect();
|
||||
}
|
||||
|
||||
// static
|
||||
@ -1469,13 +1455,13 @@ nsContentUtils::IsCallerChrome()
|
||||
bool
|
||||
nsContentUtils::IsCallerTrustedForRead()
|
||||
{
|
||||
return IsCallerTrustedForCapability("UniversalBrowserRead");
|
||||
return CallerHasUniversalXPConnect();
|
||||
}
|
||||
|
||||
bool
|
||||
nsContentUtils::IsCallerTrustedForWrite()
|
||||
{
|
||||
return IsCallerTrustedForCapability("UniversalBrowserWrite");
|
||||
return CallerHasUniversalXPConnect();
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -165,12 +165,12 @@ nsDOMFileBase::GetMozFullPath(nsAString &aFileName)
|
||||
{
|
||||
NS_ASSERTION(mIsFile, "Should only be called on files");
|
||||
|
||||
// It is unsafe to call IsCallerTrustedForCapability on a non-main thread. If
|
||||
// It is unsafe to call CallerHasUniversalXPConnect on a non-main thread. If
|
||||
// you hit the following assertion you need to figure out some other way to
|
||||
// determine privileges and call GetMozFullPathInternal.
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
if (nsContentUtils::IsCallerTrustedForCapability("UniversalFileRead")) {
|
||||
if (nsContentUtils::CallerHasUniversalXPConnect()) {
|
||||
return GetMozFullPathInternal(aFileName);
|
||||
}
|
||||
aFileName.Truncate();
|
||||
|
@ -2129,7 +2129,8 @@ nsGenericElement::GetBoundingClientRect(nsIDOMClientRect** aResult)
|
||||
}
|
||||
|
||||
nsRect r = nsLayoutUtils::GetAllInFlowRectsUnion(frame,
|
||||
nsLayoutUtils::GetContainingBlockForClientRect(frame));
|
||||
nsLayoutUtils::GetContainingBlockForClientRect(frame),
|
||||
nsLayoutUtils::RECTS_ACCOUNT_FOR_TRANSFORMS);
|
||||
rect->SetLayoutRect(r);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -2157,7 +2158,8 @@ nsGenericElement::GetClientRects(nsIDOMClientRectList** aResult)
|
||||
|
||||
nsLayoutUtils::RectListBuilder builder(rectList);
|
||||
nsLayoutUtils::GetAllInFlowRects(frame,
|
||||
nsLayoutUtils::GetContainingBlockForClientRect(frame), &builder);
|
||||
nsLayoutUtils::GetContainingBlockForClientRect(frame), &builder,
|
||||
nsLayoutUtils::RECTS_ACCOUNT_FOR_TRANSFORMS);
|
||||
if (NS_FAILED(builder.mRV))
|
||||
return builder.mRV;
|
||||
*aResult = rectList.forget().get();
|
||||
@ -2440,7 +2442,7 @@ nsGenericElement::InternalIsSupported(nsISupports* aObject,
|
||||
}
|
||||
} else if (PL_strcasecmp(f, "SVGEvents") == 0 ||
|
||||
PL_strcasecmp(f, "SVGZoomEvents") == 0 ||
|
||||
nsSVGFeatures::HaveFeature(aObject, aFeature)) {
|
||||
nsSVGFeatures::HasFeature(aObject, aFeature)) {
|
||||
if (aVersion.IsEmpty() ||
|
||||
PL_strcmp(v, "1.0") == 0 ||
|
||||
PL_strcmp(v, "1.1") == 0) {
|
||||
|
@ -2749,10 +2749,10 @@ nsXMLHttpRequest::SetRequestHeader(const nsACString& header,
|
||||
}
|
||||
|
||||
// Prevent modification to certain HTTP headers (see bug 302263), unless
|
||||
// the executing script has UniversalBrowserWrite permission.
|
||||
// the executing script has UniversalXPConnect.
|
||||
|
||||
bool privileged;
|
||||
rv = IsCapabilityEnabled("UniversalBrowserWrite", &privileged);
|
||||
rv = IsCapabilityEnabled("UniversalXPConnect", &privileged);
|
||||
if (NS_FAILED(rv))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -62,7 +62,7 @@ function afterReload() {
|
||||
"password field value forgotten");
|
||||
is(iframeDoc.getElementById("hidden").value, "gecko",
|
||||
"hidden field value preserved");
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalFileRead");
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
is(iframeDoc.getElementById("file").value, filePath,
|
||||
"file field value preserved");
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
request.send(null);
|
||||
|
||||
// Try reading headers in privileged context
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalBrowserRead");
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
is(request.getResponseHeader("Set-Cookie"), "test", "Reading Set-Cookie response header in privileged context");
|
||||
is(request.getResponseHeader("Set-Cookie2"), "test2", "Reading Set-Cookie2 response header in privileged context");
|
||||
is(request.getResponseHeader("X-Dummy"), "test", "Reading X-Dummy response header in privileged context");
|
||||
|
@ -55,7 +55,7 @@ for (i = 0; i < headers.length; i++)
|
||||
request.setRequestHeader(headers[i], "test" + i);
|
||||
|
||||
// Read out headers
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalBrowserWrite");
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
var channel = request.channel.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
for (i = 0; i < headers.length; i++) {
|
||||
// Retrieving Content-Length will throw an exception
|
||||
|
@ -95,7 +95,7 @@ class WebGLFramebuffer;
|
||||
class WebGLRenderbuffer;
|
||||
class WebGLUniformLocation;
|
||||
class WebGLExtension;
|
||||
class WebGLVertexAttribData;
|
||||
struct WebGLVertexAttribData;
|
||||
|
||||
class WebGLContextBoundObject;
|
||||
|
||||
|
@ -21024,7 +21024,7 @@ img.onload = wrapFunction(function ()
|
||||
ctx667.drawImage(img, 0, 25);
|
||||
// (The alpha values do not really survive float->int conversion, so just
|
||||
// do approximate comparisons)
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
isPixel(ctx667, 12,40, 1,3,254,255, 0);
|
||||
isPixel(ctx667, 37,40, 8,252,248,191, 2);
|
||||
isPixel(ctx667, 62,40, 6,10,250,127, 4);
|
||||
@ -21151,7 +21151,7 @@ deferTest();
|
||||
img.onload = wrapFunction(function ()
|
||||
{
|
||||
ctx672.drawImage(img, 0, 0);
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
isPixel(ctx672, 12,20, 255,255,0,255, 0);
|
||||
isPixel(ctx672, 50,20, 0,255,255,255, 0);
|
||||
isPixel(ctx672, 87,20, 0,0,255,255, 0);
|
||||
|
@ -255,7 +255,7 @@ public:
|
||||
* Dispatches an event.
|
||||
* If aDOMEvent is not nsnull, it is used for dispatching
|
||||
* (aEvent can then be nsnull) and (if aDOMEvent is not |trusted| already),
|
||||
* the |trusted| flag is set based on the UniversalBrowserWrite capability.
|
||||
* the |trusted| flag is set based on the UniversalXPConnect capability.
|
||||
* Otherwise this works like nsEventDispatcher::Dispatch.
|
||||
* @note Use this method when dispatching nsIDOMEvent.
|
||||
*/
|
||||
|
@ -452,11 +452,11 @@ nsDOMDataTransfer::MozGetDataAt(const nsAString& aFormat,
|
||||
nsTArray<TransferItem>& item = mItems[aIndex];
|
||||
|
||||
// allow access to any data in the drop and dragdrop events, or if the
|
||||
// UniversalBrowserRead privilege is set, otherwise only allow access to
|
||||
// UniversalXPConnect privilege is set, otherwise only allow access to
|
||||
// data from the same principal.
|
||||
nsIPrincipal* principal = nsnull;
|
||||
if (mEventType != NS_DRAGDROP_DROP && mEventType != NS_DRAGDROP_DRAGDROP &&
|
||||
!nsContentUtils::IsCallerTrustedForCapability("UniversalBrowserRead")) {
|
||||
!nsContentUtils::CallerHasUniversalXPConnect()) {
|
||||
nsresult rv = NS_OK;
|
||||
principal = GetCurrentPrincipal(&rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@ -525,7 +525,7 @@ nsDOMDataTransfer::MozSetDataAt(const nsAString& aFormat,
|
||||
// XXX perhaps this should also limit any non-string type as well
|
||||
if ((aFormat.EqualsLiteral("application/x-moz-file-promise") ||
|
||||
aFormat.EqualsLiteral("application/x-moz-file")) &&
|
||||
!nsContentUtils::IsCallerTrustedForCapability("UniversalXPConnect")) {
|
||||
!nsContentUtils::CallerHasUniversalXPConnect()) {
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
|
||||
|
@ -580,7 +580,7 @@ nsDOMEvent::InitEvent(const nsAString& aEventTypeArg, bool aCanBubbleArg, bool a
|
||||
|
||||
bool enabled = false;
|
||||
nsContentUtils::GetSecurityManager()->
|
||||
IsCapabilityEnabled("UniversalBrowserWrite", &enabled);
|
||||
IsCapabilityEnabled("UniversalXPConnect", &enabled);
|
||||
|
||||
if (!enabled) {
|
||||
SetTrusted(false);
|
||||
|
@ -941,7 +941,7 @@ nsHTMLInputElement::GetValueInternal(nsAString& aValue) const
|
||||
return NS_OK;
|
||||
|
||||
case VALUE_MODE_FILENAME:
|
||||
if (nsContentUtils::IsCallerTrustedForCapability("UniversalFileRead")) {
|
||||
if (nsContentUtils::CallerHasUniversalXPConnect()) {
|
||||
if (mFiles.Count()) {
|
||||
return mFiles[0]->GetMozFullPath(aValue);
|
||||
}
|
||||
@ -990,9 +990,9 @@ nsHTMLInputElement::SetValue(const nsAString& aValue)
|
||||
// OK and gives pages a way to clear a file input if necessary.
|
||||
if (mType == NS_FORM_INPUT_FILE) {
|
||||
if (!aValue.IsEmpty()) {
|
||||
if (!nsContentUtils::IsCallerTrustedForCapability("UniversalFileRead")) {
|
||||
if (!nsContentUtils::CallerHasUniversalXPConnect()) {
|
||||
// setting the value of a "FILE" input widget requires the
|
||||
// UniversalFileRead privilege
|
||||
// UniversalXPConnect privilege
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
const PRUnichar *name = PromiseFlatString(aValue).get();
|
||||
@ -1037,7 +1037,7 @@ nsHTMLInputElement::GetList(nsIDOMHTMLElement** aValue)
|
||||
NS_IMETHODIMP
|
||||
nsHTMLInputElement::MozGetFileNameArray(PRUint32 *aLength, PRUnichar ***aFileNames)
|
||||
{
|
||||
if (!nsContentUtils::IsCallerTrustedForCapability("UniversalFileRead")) {
|
||||
if (!nsContentUtils::CallerHasUniversalXPConnect()) {
|
||||
// Since this function returns full paths it's important that normal pages
|
||||
// can't call it.
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
@ -1064,9 +1064,9 @@ nsHTMLInputElement::MozGetFileNameArray(PRUint32 *aLength, PRUnichar ***aFileNam
|
||||
NS_IMETHODIMP
|
||||
nsHTMLInputElement::MozSetFileNameArray(const PRUnichar **aFileNames, PRUint32 aLength)
|
||||
{
|
||||
if (!nsContentUtils::IsCallerTrustedForCapability("UniversalFileRead")) {
|
||||
if (!nsContentUtils::CallerHasUniversalXPConnect()) {
|
||||
// setting the value of a "FILE" input widget requires the
|
||||
// UniversalFileRead privilege
|
||||
// UniversalXPConnect privilege
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ function initVals() {
|
||||
}
|
||||
|
||||
function initControl1() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalFileRead");
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
$("i1").value = fullPath;
|
||||
is($("i1").value, fullPath, "Should have set full path 1");
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ var inputChange = 0;
|
||||
var textareaChange = 0;
|
||||
|
||||
function testUserInput() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserWrite');
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
var input = document.getElementById("input");
|
||||
var textarea = document.getElementById("textarea");
|
||||
|
||||
|
@ -137,9 +137,12 @@ nsWebMReader::nsWebMReader(nsBuiltinDecoder* aDecoder)
|
||||
mAudioStartUsec(-1),
|
||||
mAudioFrames(0),
|
||||
mHasVideo(false),
|
||||
mHasAudio(false)
|
||||
mHasAudio(false),
|
||||
mForceStereoMode(0)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsWebMReader);
|
||||
|
||||
Preferences::GetInt("media.webm.force_stereo_mode", &mForceStereoMode);
|
||||
}
|
||||
|
||||
nsWebMReader::~nsWebMReader()
|
||||
@ -306,25 +309,21 @@ nsresult nsWebMReader::ReadMetadata(nsVideoInfo* aInfo)
|
||||
break;
|
||||
}
|
||||
|
||||
PRInt32 forceStereoMode;
|
||||
if (NS_SUCCEEDED(Preferences::GetInt("media.webm.force_stereo_mode",
|
||||
&forceStereoMode))) {
|
||||
switch (forceStereoMode) {
|
||||
case 1:
|
||||
mInfo.mStereoMode = STEREO_MODE_LEFT_RIGHT;
|
||||
break;
|
||||
case 2:
|
||||
mInfo.mStereoMode = STEREO_MODE_RIGHT_LEFT;
|
||||
break;
|
||||
case 3:
|
||||
mInfo.mStereoMode = STEREO_MODE_TOP_BOTTOM;
|
||||
break;
|
||||
case 4:
|
||||
mInfo.mStereoMode = STEREO_MODE_BOTTOM_TOP;
|
||||
break;
|
||||
default:
|
||||
mInfo.mStereoMode = STEREO_MODE_MONO;
|
||||
}
|
||||
switch (mForceStereoMode) {
|
||||
case 1:
|
||||
mInfo.mStereoMode = STEREO_MODE_LEFT_RIGHT;
|
||||
break;
|
||||
case 2:
|
||||
mInfo.mStereoMode = STEREO_MODE_RIGHT_LEFT;
|
||||
break;
|
||||
case 3:
|
||||
mInfo.mStereoMode = STEREO_MODE_TOP_BOTTOM;
|
||||
break;
|
||||
case 4:
|
||||
mInfo.mStereoMode = STEREO_MODE_BOTTOM_TOP;
|
||||
break;
|
||||
default:
|
||||
mInfo.mStereoMode = STEREO_MODE_MONO;
|
||||
}
|
||||
}
|
||||
else if (!mHasAudio && type == NESTEGG_TRACK_AUDIO) {
|
||||
|
@ -240,6 +240,10 @@ private:
|
||||
// Booleans to indicate if we have audio and/or video data
|
||||
bool mHasVideo;
|
||||
bool mHasAudio;
|
||||
|
||||
// Value of the "media.webm.force_stereo_mode" pref, which we need off the
|
||||
// main thread.
|
||||
PRInt32 mForceStereoMode;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
199
content/svg/content/src/DOMSVGStringList.cpp
Normal file
199
content/svg/content/src/DOMSVGStringList.cpp
Normal file
@ -0,0 +1,199 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla SVG Project code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Robert Longson <longsonr@gmail.com>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "DOMSVGStringList.h"
|
||||
#include "DOMSVGTests.h"
|
||||
#include "nsDOMError.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsSVGAttrTearoffTable.h"
|
||||
|
||||
// See the architecture comment in this file's header.
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
static nsSVGAttrTearoffTable<SVGStringList, DOMSVGStringList>
|
||||
sSVGStringListTearoffTable;
|
||||
|
||||
NS_SVG_VAL_IMPL_CYCLE_COLLECTION(DOMSVGStringList, mElement)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMSVGStringList)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMSVGStringList)
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
DOMCI_DATA(SVGStringList, mozilla::DOMSVGStringList)
|
||||
namespace mozilla {
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMSVGStringList)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGStringList)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGStringList)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
/* static */ already_AddRefed<DOMSVGStringList>
|
||||
DOMSVGStringList::GetDOMWrapper(SVGStringList *aList,
|
||||
nsSVGElement *aElement,
|
||||
bool aIsConditionalProcessingAttribute,
|
||||
PRUint8 aAttrEnum)
|
||||
{
|
||||
DOMSVGStringList *wrapper =
|
||||
sSVGStringListTearoffTable.GetTearoff(aList);
|
||||
if (!wrapper) {
|
||||
wrapper = new DOMSVGStringList(aElement,
|
||||
aIsConditionalProcessingAttribute,
|
||||
aAttrEnum);
|
||||
sSVGStringListTearoffTable.AddTearoff(aList, wrapper);
|
||||
}
|
||||
NS_ADDREF(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
DOMSVGStringList::~DOMSVGStringList()
|
||||
{
|
||||
// Script no longer has any references to us.
|
||||
sSVGStringListTearoffTable.RemoveTearoff(&InternalList());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// nsIDOMSVGStringList implementation:
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMSVGStringList::GetNumberOfItems(PRUint32 *aNumberOfItems)
|
||||
{
|
||||
*aNumberOfItems = InternalList().Length();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMSVGStringList::Clear()
|
||||
{
|
||||
if (InternalList().IsExplicitlySet()) {
|
||||
InternalList().Clear();
|
||||
mElement->DidChangeStringList(mIsConditionalProcessingAttribute,
|
||||
mAttrEnum);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMSVGStringList::Initialize(const nsAString & newItem, nsAString & _retval)
|
||||
{
|
||||
if (InternalList().IsExplicitlySet()) {
|
||||
InternalList().Clear();
|
||||
}
|
||||
return InsertItemBefore(newItem, 0, _retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMSVGStringList::GetItem(PRUint32 index,
|
||||
nsAString & _retval)
|
||||
{
|
||||
if (index >= InternalList().Length()) {
|
||||
return NS_ERROR_DOM_INDEX_SIZE_ERR;
|
||||
}
|
||||
_retval = InternalList()[index];
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMSVGStringList::InsertItemBefore(const nsAString & newItem,
|
||||
PRUint32 index,
|
||||
nsAString & _retval)
|
||||
{
|
||||
index = NS_MIN(index, InternalList().Length());
|
||||
|
||||
// Ensure we have enough memory so we can avoid complex error handling below:
|
||||
if (!InternalList().SetCapacity(InternalList().Length() + 1)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
InternalList().InsertItem(index, newItem);
|
||||
|
||||
mElement->DidChangeStringList(mIsConditionalProcessingAttribute, mAttrEnum);
|
||||
_retval = newItem;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMSVGStringList::ReplaceItem(const nsAString & newItem,
|
||||
PRUint32 index,
|
||||
nsAString & _retval)
|
||||
{
|
||||
if (index >= InternalList().Length()) {
|
||||
return NS_ERROR_DOM_INDEX_SIZE_ERR;
|
||||
}
|
||||
|
||||
_retval = InternalList()[index];
|
||||
InternalList().ReplaceItem(index, newItem);
|
||||
|
||||
mElement->DidChangeStringList(mIsConditionalProcessingAttribute, mAttrEnum);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMSVGStringList::RemoveItem(PRUint32 index,
|
||||
nsAString & _retval)
|
||||
{
|
||||
if (index >= InternalList().Length()) {
|
||||
return NS_ERROR_DOM_INDEX_SIZE_ERR;
|
||||
}
|
||||
|
||||
InternalList().RemoveItem(index);
|
||||
|
||||
mElement->DidChangeStringList(mIsConditionalProcessingAttribute, mAttrEnum);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMSVGStringList::AppendItem(const nsAString & newItem,
|
||||
nsAString & _retval)
|
||||
{
|
||||
return InsertItemBefore(newItem, InternalList().Length(), _retval);
|
||||
}
|
||||
|
||||
SVGStringList &
|
||||
DOMSVGStringList::InternalList()
|
||||
{
|
||||
if (mIsConditionalProcessingAttribute) {
|
||||
nsCOMPtr<DOMSVGTests> tests = do_QueryInterface(mElement);
|
||||
return tests->mStringListAttributes[mAttrEnum];
|
||||
}
|
||||
return mElement->GetStringListInfo().mStringLists[mAttrEnum];
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
129
content/svg/content/src/DOMSVGStringList.h
Normal file
129
content/svg/content/src/DOMSVGStringList.h
Normal file
@ -0,0 +1,129 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla SVG Project code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Robert Longson <longsonr@gmail.com>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef MOZILLA_DOMSVGSTRINGLIST_H__
|
||||
#define MOZILLA_DOMSVGSTRINGLIST_H__
|
||||
|
||||
#include "nsIDOMSVGStringList.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsAutoPtr.h"
|
||||
|
||||
class nsSVGElement;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class SVGStringList;
|
||||
|
||||
/**
|
||||
* Class DOMSVGStringList
|
||||
*
|
||||
* This class is used to create the DOM tearoff objects that wrap internal
|
||||
* SVGPathData objects.
|
||||
*
|
||||
* See the architecture comment in DOMSVGAnimatedLengthList.h first (that's
|
||||
* LENGTH list), then continue reading the remainder of this comment.
|
||||
*
|
||||
* The architecture of this class is similar to that of DOMSVGLengthList
|
||||
* except for two important aspects:
|
||||
*
|
||||
* First, since there is no nsIDOMSVGAnimatedStringList interface in SVG, we
|
||||
* have no parent DOMSVGAnimatedStringList (unlike DOMSVGLengthList which has
|
||||
* a parent DOMSVGAnimatedLengthList class). As a consequence, much of the
|
||||
* logic that would otherwise be in DOMSVGAnimatedStringList (and is in
|
||||
* DOMSVGAnimatedLengthList) is contained in this class.
|
||||
*
|
||||
* Second, since there is no nsIDOMSVGString interface in SVG, we have no
|
||||
* DOMSVGString items to maintain. As far as script is concerned, objects
|
||||
* of this class contain a list of strings, not a list of mutable objects
|
||||
* like the other SVG list types. As a result, unlike the other SVG list
|
||||
* types, this class does not create its items lazily on demand and store
|
||||
* them so it can return the same objects each time. It simply returns a new
|
||||
* string each time any given item is requested.
|
||||
*/
|
||||
class DOMSVGStringList : public nsIDOMSVGStringList
|
||||
{
|
||||
public:
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS(DOMSVGStringList)
|
||||
NS_DECL_NSIDOMSVGSTRINGLIST
|
||||
|
||||
/**
|
||||
* Factory method to create and return a DOMSVGStringList wrapper
|
||||
* for a given internal SVGStringList object. The factory takes care
|
||||
* of caching the object that it returns so that the same object can be
|
||||
* returned for the given SVGStringList each time it is requested.
|
||||
* The cached object is only removed from the cache when it is destroyed due
|
||||
* to there being no more references to it. If that happens, any subsequent
|
||||
* call requesting the DOM wrapper for the SVGStringList will naturally
|
||||
* result in a new DOMSVGStringList being returned.
|
||||
*/
|
||||
static already_AddRefed<DOMSVGStringList>
|
||||
GetDOMWrapper(SVGStringList *aList,
|
||||
nsSVGElement *aElement,
|
||||
bool aIsConditionalProcessingAttribute,
|
||||
PRUint8 aAttrEnum);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Only our static GetDOMWrapper() factory method may create objects of our
|
||||
* type.
|
||||
*/
|
||||
DOMSVGStringList(nsSVGElement *aElement,
|
||||
bool aIsConditionalProcessingAttribute, PRUint8 aAttrEnum)
|
||||
: mElement(aElement)
|
||||
, mAttrEnum(aAttrEnum)
|
||||
, mIsConditionalProcessingAttribute(aIsConditionalProcessingAttribute)
|
||||
{}
|
||||
|
||||
~DOMSVGStringList();
|
||||
|
||||
void DidChangeStringList(PRUint8 aAttrEnum, bool aDoSetAttr);
|
||||
|
||||
SVGStringList &InternalList();
|
||||
|
||||
// Strong ref to our element to keep it alive.
|
||||
nsRefPtr<nsSVGElement> mElement;
|
||||
|
||||
PRUint8 mAttrEnum;
|
||||
|
||||
bool mIsConditionalProcessingAttribute;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // MOZILLA_DOMSVGSTRINGLIST_H__
|
289
content/svg/content/src/DOMSVGTests.cpp
Normal file
289
content/svg/content/src/DOMSVGTests.cpp
Normal file
@ -0,0 +1,289 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Robert Longson <longsonr@gmail.com>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "DOMSVGTests.h"
|
||||
#include "DOMSVGStringList.h"
|
||||
#include "nsSVGFeatures.h"
|
||||
#include "nsSVGSwitchElement.h"
|
||||
#include "nsCharSeparatedTokenizer.h"
|
||||
#include "nsStyleUtil.h"
|
||||
#include "nsSVGUtils.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
NS_IMPL_ISUPPORTS1(DOMSVGTests, nsIDOMSVGTests)
|
||||
|
||||
DOMSVGTests::StringListInfo DOMSVGTests::sStringListInfo[3] =
|
||||
{
|
||||
{ &nsGkAtoms::requiredFeatures, false },
|
||||
{ &nsGkAtoms::requiredExtensions, false },
|
||||
{ &nsGkAtoms::systemLanguage, true }
|
||||
};
|
||||
|
||||
/* readonly attribute nsIDOMSVGStringList requiredFeatures; */
|
||||
NS_IMETHODIMP
|
||||
DOMSVGTests::GetRequiredFeatures(nsIDOMSVGStringList * *aRequiredFeatures)
|
||||
{
|
||||
nsCOMPtr<nsSVGElement> element = do_QueryInterface(this);
|
||||
*aRequiredFeatures = DOMSVGStringList::GetDOMWrapper(
|
||||
&mStringListAttributes[FEATURES], element, true, FEATURES).get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGStringList requiredExtensions; */
|
||||
NS_IMETHODIMP
|
||||
DOMSVGTests::GetRequiredExtensions(nsIDOMSVGStringList * *aRequiredExtensions)
|
||||
{
|
||||
nsCOMPtr<nsSVGElement> element = do_QueryInterface(this);
|
||||
*aRequiredExtensions = DOMSVGStringList::GetDOMWrapper(
|
||||
&mStringListAttributes[EXTENSIONS], element, true, EXTENSIONS).get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGStringList systemLanguage; */
|
||||
NS_IMETHODIMP
|
||||
DOMSVGTests::GetSystemLanguage(nsIDOMSVGStringList * *aSystemLanguage)
|
||||
{
|
||||
nsCOMPtr<nsSVGElement> element = do_QueryInterface(this);
|
||||
*aSystemLanguage = DOMSVGStringList::GetDOMWrapper(
|
||||
&mStringListAttributes[LANGUAGE], element, true, LANGUAGE).get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean hasExtension (in DOMString extension); */
|
||||
NS_IMETHODIMP
|
||||
DOMSVGTests::HasExtension(const nsAString & extension, bool *_retval)
|
||||
{
|
||||
*_retval = nsSVGFeatures::HasExtension(extension);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
DOMSVGTests::IsConditionalProcessingAttribute(const nsIAtom* aAttribute) const
|
||||
{
|
||||
for (PRUint32 i = 0; i < ArrayLength(sStringListInfo); i++) {
|
||||
if (aAttribute == *sStringListInfo[i].mName) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
DOMSVGTests::GetBestLanguagePreferenceRank(const nsSubstring& aAcceptLangs) const
|
||||
{
|
||||
const nsDefaultStringComparator defaultComparator;
|
||||
|
||||
PRInt32 lowestRank = -1;
|
||||
|
||||
for (PRUint32 i = 0; i < mStringListAttributes[LANGUAGE].Length(); i++) {
|
||||
nsCharSeparatedTokenizer languageTokenizer(aAcceptLangs, ',');
|
||||
PRInt32 index = 0;
|
||||
while (languageTokenizer.hasMoreTokens()) {
|
||||
const nsSubstring &languageToken = languageTokenizer.nextToken();
|
||||
bool exactMatch = (languageToken == mStringListAttributes[LANGUAGE][i]);
|
||||
bool prefixOnlyMatch =
|
||||
!exactMatch &&
|
||||
nsStyleUtil::DashMatchCompare(mStringListAttributes[LANGUAGE][i],
|
||||
languageTokenizer.nextToken(),
|
||||
defaultComparator);
|
||||
if (index == 0 && exactMatch) {
|
||||
// best possible match
|
||||
return 0;
|
||||
}
|
||||
if ((exactMatch || prefixOnlyMatch) &&
|
||||
(lowestRank == -1 || 2 * index + prefixOnlyMatch < lowestRank)) {
|
||||
lowestRank = 2 * index + prefixOnlyMatch;
|
||||
}
|
||||
++index;
|
||||
}
|
||||
}
|
||||
return lowestRank;
|
||||
}
|
||||
|
||||
const nsString * const DOMSVGTests::kIgnoreSystemLanguage = (nsString *) 0x01;
|
||||
|
||||
bool
|
||||
DOMSVGTests::PassesConditionalProcessingTests(const nsString *aAcceptLangs) const
|
||||
{
|
||||
// Required Features
|
||||
if (mStringListAttributes[FEATURES].IsExplicitlySet()) {
|
||||
if (mStringListAttributes[FEATURES].IsEmpty()) {
|
||||
return false;
|
||||
}
|
||||
nsCOMPtr<nsIContent> content(
|
||||
do_QueryInterface(const_cast<DOMSVGTests*>(this)));
|
||||
|
||||
for (PRUint32 i = 0; i < mStringListAttributes[FEATURES].Length(); i++) {
|
||||
if (!nsSVGFeatures::HasFeature(content, mStringListAttributes[FEATURES][i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Required Extensions
|
||||
//
|
||||
// The requiredExtensions attribute defines a list of required language
|
||||
// extensions. Language extensions are capabilities within a user agent that
|
||||
// go beyond the feature set defined in the SVG specification.
|
||||
// Each extension is identified by a URI reference.
|
||||
// For now, claim that mozilla's SVG implementation supports XHTML and MathML.
|
||||
if (mStringListAttributes[EXTENSIONS].IsExplicitlySet()) {
|
||||
if (mStringListAttributes[EXTENSIONS].IsEmpty()) {
|
||||
return false;
|
||||
}
|
||||
for (PRUint32 i = 0; i < mStringListAttributes[EXTENSIONS].Length(); i++) {
|
||||
if (!nsSVGFeatures::HasExtension(mStringListAttributes[EXTENSIONS][i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (aAcceptLangs == kIgnoreSystemLanguage) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// systemLanguage
|
||||
//
|
||||
// Evaluates to "true" if one of the languages indicated by user preferences
|
||||
// exactly equals one of the languages given in the value of this parameter,
|
||||
// or if one of the languages indicated by user preferences exactly equals a
|
||||
// prefix of one of the languages given in the value of this parameter such
|
||||
// that the first tag character following the prefix is "-".
|
||||
if (mStringListAttributes[LANGUAGE].IsExplicitlySet()) {
|
||||
if (mStringListAttributes[LANGUAGE].IsEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get our language preferences
|
||||
const nsAutoString acceptLangs(aAcceptLangs ? *aAcceptLangs :
|
||||
Preferences::GetLocalizedString("intl.accept_languages"));
|
||||
|
||||
if (acceptLangs.IsEmpty()) {
|
||||
NS_WARNING("no default language specified for systemLanguage conditional test");
|
||||
return false;
|
||||
}
|
||||
|
||||
const nsDefaultStringComparator defaultComparator;
|
||||
|
||||
for (PRUint32 i = 0; i < mStringListAttributes[LANGUAGE].Length(); i++) {
|
||||
nsCharSeparatedTokenizer languageTokenizer(acceptLangs, ',');
|
||||
while (languageTokenizer.hasMoreTokens()) {
|
||||
if (nsStyleUtil::DashMatchCompare(mStringListAttributes[LANGUAGE][i],
|
||||
languageTokenizer.nextToken(),
|
||||
defaultComparator)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
DOMSVGTests::ParseConditionalProcessingAttribute(nsIAtom* aAttribute,
|
||||
const nsAString& aValue,
|
||||
nsAttrValue& aResult)
|
||||
{
|
||||
for (PRUint32 i = 0; i < ArrayLength(sStringListInfo); i++) {
|
||||
if (aAttribute == *sStringListInfo[i].mName) {
|
||||
nsresult rv = mStringListAttributes[i].SetValue(
|
||||
aValue, sStringListInfo[i].mIsCommaSeparated);
|
||||
if (NS_FAILED(rv)) {
|
||||
mStringListAttributes[i].Clear();
|
||||
}
|
||||
MaybeInvalidate();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
DOMSVGTests::GetValue(PRUint8 aAttrEnum, nsAString& aValue) const
|
||||
{
|
||||
NS_ABORT_IF_FALSE(aAttrEnum >= 0 && aAttrEnum < ArrayLength(sStringListInfo),
|
||||
"aAttrEnum out of range");
|
||||
mStringListAttributes[aAttrEnum].GetValue(
|
||||
aValue, sStringListInfo[aAttrEnum].mIsCommaSeparated);
|
||||
}
|
||||
|
||||
void
|
||||
DOMSVGTests::UnsetAttr(const nsIAtom* aAttribute)
|
||||
{
|
||||
for (PRUint32 i = 0; i < ArrayLength(sStringListInfo); i++) {
|
||||
if (aAttribute == *sStringListInfo[i].mName) {
|
||||
mStringListAttributes[i].Clear();
|
||||
MaybeInvalidate();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DOMSVGTests::DidChangeStringList(PRUint8 aAttrEnum)
|
||||
{
|
||||
NS_ASSERTION(aAttrEnum < ArrayLength(sStringListInfo), "aAttrEnum out of range");
|
||||
|
||||
nsCOMPtr<nsSVGElement> element = do_QueryInterface(this);
|
||||
|
||||
nsAutoString serializedValue;
|
||||
GetValue(aAttrEnum, serializedValue);
|
||||
|
||||
nsAttrValue attrValue(serializedValue);
|
||||
element->SetParsedAttr(kNameSpaceID_None,
|
||||
*sStringListInfo[aAttrEnum].mName,
|
||||
nsnull, attrValue, true);
|
||||
|
||||
MaybeInvalidate();
|
||||
}
|
||||
|
||||
void
|
||||
DOMSVGTests::MaybeInvalidate()
|
||||
{
|
||||
nsCOMPtr<nsSVGElement> element = do_QueryInterface(this);
|
||||
|
||||
nsIContent* parent = element->GetFlattenedTreeParent();
|
||||
|
||||
if (parent &&
|
||||
parent->NodeInfo()->Equals(nsGkAtoms::svgSwitch, kNameSpaceID_SVG)) {
|
||||
static_cast<nsSVGSwitchElement*>(parent)->MaybeInvalidate();
|
||||
}
|
||||
}
|
123
content/svg/content/src/DOMSVGTests.h
Normal file
123
content/svg/content/src/DOMSVGTests.h
Normal file
@ -0,0 +1,123 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Robert Longson <longsonr@gmail.com>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef MOZILLA_DOMSVGTESTS_H__
|
||||
#define MOZILLA_DOMSVGTESTS_H__
|
||||
|
||||
#include "nsIDOMSVGTests.h"
|
||||
#include "SVGStringList.h"
|
||||
|
||||
class DOMSVGTests : public nsIDOMSVGTests
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOMSVGTESTS
|
||||
|
||||
friend class mozilla::DOMSVGStringList;
|
||||
typedef mozilla::SVGStringList SVGStringList;
|
||||
|
||||
/**
|
||||
* Compare the language name(s) in a systemLanguage attribute to the
|
||||
* user's language preferences, as defined in
|
||||
* http://www.w3.org/TR/SVG11/struct.html#SystemLanguageAttribute
|
||||
* We have a match if a language name in the users language preferences
|
||||
* exactly equals one of the language names or exactly equals a prefix of
|
||||
* one of the language names in the systemLanguage attribute.
|
||||
* @returns 2 * the lowest index in the aAcceptLangs that matches + 1
|
||||
* if only the prefix matches, or -1 if no indices match.
|
||||
* XXX This algorithm is O(M*N).
|
||||
*/
|
||||
PRInt32 GetBestLanguagePreferenceRank(const nsSubstring& aAcceptLangs) const;
|
||||
|
||||
/**
|
||||
* Special value to pass to PassesConditionalProcessingTests to ignore systemLanguage
|
||||
* attributes
|
||||
*/
|
||||
static const nsString * const kIgnoreSystemLanguage;
|
||||
|
||||
/**
|
||||
* Check whether the conditional processing attributes requiredFeatures,
|
||||
* requiredExtensions and systemLanguage all "return true" if they apply to
|
||||
* and are specified on the given element. Returns true if this element
|
||||
* should be rendered, false if it should not.
|
||||
*
|
||||
* @param aAcceptLangs Optional parameter to pass in the value of the
|
||||
* intl.accept_languages preference if the caller has it cached.
|
||||
* Alternatively, pass in kIgnoreSystemLanguage to skip the systemLanguage
|
||||
* check if the caller is giving that special treatment.
|
||||
*/
|
||||
bool PassesConditionalProcessingTests(
|
||||
const nsString *aAcceptLangs = nsnull) const;
|
||||
|
||||
/**
|
||||
* Returns true if the attribute is one of the conditional processing
|
||||
* attributes.
|
||||
*/
|
||||
bool IsConditionalProcessingAttribute(const nsIAtom* aAttribute) const;
|
||||
|
||||
bool ParseConditionalProcessingAttribute(
|
||||
nsIAtom* aAttribute,
|
||||
const nsAString& aValue,
|
||||
nsAttrValue& aResult);
|
||||
|
||||
/**
|
||||
* Serialises the conditional processing attribute.
|
||||
*/
|
||||
void GetValue(PRUint8 aAttrEnum, nsAString& aValue) const;
|
||||
|
||||
/**
|
||||
* Unsets a conditional processing attribute.
|
||||
*/
|
||||
void UnsetAttr(const nsIAtom* aAttribute);
|
||||
|
||||
void DidChangeStringList(PRUint8 aAttrEnum);
|
||||
|
||||
void MaybeInvalidate();
|
||||
|
||||
private:
|
||||
|
||||
struct StringListInfo {
|
||||
nsIAtom** mName;
|
||||
bool mIsCommaSeparated;
|
||||
};
|
||||
|
||||
enum { FEATURES, EXTENSIONS, LANGUAGE };
|
||||
SVGStringList mStringListAttributes[3];
|
||||
static StringListInfo sStringListInfo[3];
|
||||
};
|
||||
|
||||
#endif // MOZILLA_DOMSVGTESTS_H__
|
@ -61,6 +61,8 @@ CPPSRCS = \
|
||||
DOMSVGPathSegList.cpp \
|
||||
DOMSVGPoint.cpp \
|
||||
DOMSVGPointList.cpp \
|
||||
DOMSVGStringList.cpp \
|
||||
DOMSVGTests.cpp \
|
||||
DOMSVGTransform.cpp \
|
||||
DOMSVGTransformList.cpp \
|
||||
nsDOMSVGZoomEvent.cpp \
|
||||
@ -134,6 +136,7 @@ CPPSRCS = \
|
||||
SVGPathData.cpp \
|
||||
SVGPathSegUtils.cpp \
|
||||
SVGPointList.cpp \
|
||||
SVGStringList.cpp \
|
||||
SVGTransform.cpp \
|
||||
SVGTransformList.cpp \
|
||||
SVGTransformListParser.cpp \
|
||||
|
110
content/svg/content/src/SVGStringList.cpp
Normal file
110
content/svg/content/src/SVGStringList.cpp
Normal file
@ -0,0 +1,110 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla SVG Project code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Robert Longson <longsonr@gmail.com>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "mozilla/Util.h"
|
||||
|
||||
#include "SVGStringList.h"
|
||||
#include "nsSVGElement.h"
|
||||
#include "nsDOMError.h"
|
||||
#include "nsString.h"
|
||||
#include "nsSVGUtils.h"
|
||||
#include "nsTextFormatter.h"
|
||||
#include "nsWhitespaceTokenizer.h"
|
||||
#include "nsCharSeparatedTokenizer.h"
|
||||
#include "nsMathUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
nsresult
|
||||
SVGStringList::CopyFrom(const SVGStringList& rhs)
|
||||
{
|
||||
if (!mStrings.SetCapacity(rhs.Length())) {
|
||||
// Yes, we do want fallible alloc here
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mStrings = rhs.mStrings;
|
||||
mIsSet = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
SVGStringList::GetValue(nsAString& aValue, bool aIsCommaSeparated) const
|
||||
{
|
||||
aValue.Truncate();
|
||||
PRUint32 last = mStrings.Length() - 1;
|
||||
for (PRUint32 i = 0; i < mStrings.Length(); ++i) {
|
||||
aValue.Append(mStrings[i]);
|
||||
if (i != last) {
|
||||
if (aIsCommaSeparated) {
|
||||
aValue.Append(',');
|
||||
}
|
||||
aValue.Append(' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
SVGStringList::SetValue(const nsAString& aValue, bool aIsCommaSeparated)
|
||||
{
|
||||
SVGStringList temp;
|
||||
|
||||
if (aIsCommaSeparated) {
|
||||
nsCharSeparatedTokenizerTemplate<IsSVGWhitespace>
|
||||
tokenizer(aValue, ',');
|
||||
|
||||
while (tokenizer.hasMoreTokens()) {
|
||||
if (!temp.AppendItem(tokenizer.nextToken())) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
if (tokenizer.lastTokenEndedWithSeparator()) {
|
||||
return NS_ERROR_DOM_SYNTAX_ERR; // trailing comma
|
||||
}
|
||||
} else {
|
||||
nsWhitespaceTokenizer tokenizer(aValue);
|
||||
|
||||
while (tokenizer.hasMoreTokens()) {
|
||||
if (!temp.AppendItem(tokenizer.nextToken())) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return CopyFrom(temp);
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
174
content/svg/content/src/SVGStringList.h
Normal file
174
content/svg/content/src/SVGStringList.h
Normal file
@ -0,0 +1,174 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla SVG Project code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Robert Longson <longsonr@gmail.com>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef MOZILLA_SVGSTRINGLIST_H__
|
||||
#define MOZILLA_SVGSTRINGLIST_H__
|
||||
|
||||
#include "nsTArray.h"
|
||||
#include "nsSVGElement.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
/**
|
||||
*
|
||||
* The DOM wrapper class for this class is DOMSVGStringList.
|
||||
*/
|
||||
class SVGStringList
|
||||
{
|
||||
friend class DOMSVGStringList;
|
||||
|
||||
public:
|
||||
|
||||
SVGStringList() : mIsSet(false) {}
|
||||
~SVGStringList(){}
|
||||
|
||||
nsresult SetValue(const nsAString& aValue, bool aIsCommaSeparated);
|
||||
|
||||
void Clear() {
|
||||
mStrings.Clear();
|
||||
mIsSet = false;
|
||||
}
|
||||
|
||||
/// This may return an incomplete string on OOM, but that's acceptable.
|
||||
void GetValue(nsAString& aValue, bool aIsCommaSeparated) const;
|
||||
|
||||
bool IsEmpty() const {
|
||||
return mStrings.IsEmpty();
|
||||
}
|
||||
|
||||
PRUint32 Length() const {
|
||||
return mStrings.Length();
|
||||
}
|
||||
|
||||
const nsAString& operator[](PRUint32 aIndex) const {
|
||||
return mStrings[aIndex];
|
||||
}
|
||||
|
||||
bool operator==(const SVGStringList& rhs) const {
|
||||
return mStrings == rhs.mStrings;
|
||||
}
|
||||
|
||||
bool SetCapacity(PRUint32 size) {
|
||||
return mStrings.SetCapacity(size);
|
||||
}
|
||||
|
||||
void Compact() {
|
||||
mStrings.Compact();
|
||||
}
|
||||
|
||||
// Returns true if the animated value of this stringlist has been explicitly
|
||||
// set by taking on the base value which has been explicitly set by markup
|
||||
// or a DOM call, false otherwise.
|
||||
bool IsExplicitlySet() const
|
||||
{ return mIsSet; }
|
||||
|
||||
// Access to methods that can modify objects of this type is deliberately
|
||||
// limited. This is to reduce the chances of someone modifying objects of
|
||||
// this type without taking the necessary steps to keep DOM wrappers in sync.
|
||||
// If you need wider access to these methods, consider adding a method to
|
||||
// SVGAnimatedStringList and having that class act as an intermediary so it
|
||||
// can take care of keeping DOM wrappers in sync.
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* This may fail on OOM if the internal capacity needs to be increased, in
|
||||
* which case the list will be left unmodified.
|
||||
*/
|
||||
nsresult CopyFrom(const SVGStringList& rhs);
|
||||
|
||||
nsAString& operator[](PRUint32 aIndex) {
|
||||
return mStrings[aIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
* This may fail (return false) on OOM if the internal capacity is being
|
||||
* increased, in which case the list will be left unmodified.
|
||||
*/
|
||||
bool SetLength(PRUint32 aStringOfItems) {
|
||||
return mStrings.SetLength(aStringOfItems);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// Marking the following private only serves to show which methods are only
|
||||
// used by our friend classes (as opposed to our subclasses) - it doesn't
|
||||
// really provide additional safety.
|
||||
|
||||
bool InsertItem(PRUint32 aIndex, const nsAString &aString) {
|
||||
if (aIndex >= mStrings.Length()) {
|
||||
aIndex = mStrings.Length();
|
||||
}
|
||||
if (mStrings.InsertElementAt(aIndex, aString)) {
|
||||
mIsSet = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ReplaceItem(PRUint32 aIndex, const nsAString &aString) {
|
||||
NS_ABORT_IF_FALSE(aIndex < mStrings.Length(),
|
||||
"DOM wrapper caller should have raised INDEX_SIZE_ERR");
|
||||
mStrings[aIndex] = aString;
|
||||
}
|
||||
|
||||
void RemoveItem(PRUint32 aIndex) {
|
||||
NS_ABORT_IF_FALSE(aIndex < mStrings.Length(),
|
||||
"DOM wrapper caller should have raised INDEX_SIZE_ERR");
|
||||
mStrings.RemoveElementAt(aIndex);
|
||||
}
|
||||
|
||||
bool AppendItem(const nsAString &aString) {
|
||||
if (mStrings.AppendElement(aString)) {
|
||||
mIsSet = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
/* See SVGLengthList for the rationale for using nsTArray<float> instead
|
||||
* of nsTArray<float, 1>.
|
||||
*/
|
||||
nsTArray<nsString> mStrings;
|
||||
bool mIsSet;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // MOZILLA_SVGSTRINGLIST_H__
|
@ -67,11 +67,12 @@ NS_IMPL_RELEASE_INHERITED(nsSVGAElement, nsSVGAElementBase)
|
||||
DOMCI_NODE_DATA(SVGAElement, nsSVGAElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsSVGAElement)
|
||||
NS_NODE_INTERFACE_TABLE7(nsSVGAElement,
|
||||
NS_NODE_INTERFACE_TABLE8(nsSVGAElement,
|
||||
nsIDOMNode,
|
||||
nsIDOMElement,
|
||||
nsIDOMSVGElement,
|
||||
nsIDOMSVGAElement,
|
||||
nsIDOMSVGTests,
|
||||
nsIDOMSVGURIReference,
|
||||
nsILink,
|
||||
Link)
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "nsIDOMSVGURIReference.h"
|
||||
#include "nsILink.h"
|
||||
#include "nsSVGString.h"
|
||||
#include "DOMSVGTests.h"
|
||||
|
||||
#include "Link.h"
|
||||
|
||||
@ -50,6 +51,7 @@ typedef nsSVGGraphicElement nsSVGAElementBase;
|
||||
|
||||
class nsSVGAElement : public nsSVGAElementBase,
|
||||
public nsIDOMSVGAElement,
|
||||
public DOMSVGTests,
|
||||
public nsIDOMSVGURIReference,
|
||||
public nsILink,
|
||||
public mozilla::dom::Link
|
||||
|
@ -104,9 +104,10 @@ NS_IMPL_RELEASE_INHERITED(nsSVGAltGlyphElement,nsSVGAltGlyphElementBase)
|
||||
DOMCI_NODE_DATA(SVGAltGlyphElement, nsSVGAltGlyphElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsSVGAltGlyphElement)
|
||||
NS_NODE_INTERFACE_TABLE7(nsSVGAltGlyphElement, nsIDOMNode, nsIDOMElement,
|
||||
NS_NODE_INTERFACE_TABLE8(nsSVGAltGlyphElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGAltGlyphElement,
|
||||
nsIDOMSVGTextPositioningElement, nsIDOMSVGTextContentElement,
|
||||
nsIDOMSVGTests,
|
||||
nsIDOMSVGURIReference)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGAltGlyphElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGAltGlyphElementBase)
|
||||
|
@ -81,9 +81,9 @@ NS_IMPL_RELEASE_INHERITED(nsSVGAnimateElement,nsSVGAnimateElementBase)
|
||||
DOMCI_NODE_DATA(SVGAnimateElement, nsSVGAnimateElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsSVGAnimateElement)
|
||||
NS_NODE_INTERFACE_TABLE5(nsSVGAnimateElement, nsIDOMNode, nsIDOMElement,
|
||||
NS_NODE_INTERFACE_TABLE6(nsSVGAnimateElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGAnimationElement,
|
||||
nsIDOMSVGAnimateElement)
|
||||
nsIDOMSVGTests, nsIDOMSVGAnimateElement)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGAnimateElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGAnimateElementBase)
|
||||
|
||||
|
@ -51,9 +51,9 @@ NS_IMPL_RELEASE_INHERITED(nsSVGAnimateMotionElement,nsSVGAnimateMotionElementBas
|
||||
DOMCI_NODE_DATA(SVGAnimateMotionElement, nsSVGAnimateMotionElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsSVGAnimateMotionElement)
|
||||
NS_NODE_INTERFACE_TABLE5(nsSVGAnimateMotionElement, nsIDOMNode,
|
||||
NS_NODE_INTERFACE_TABLE6(nsSVGAnimateMotionElement, nsIDOMNode,
|
||||
nsIDOMElement, nsIDOMSVGElement,
|
||||
nsIDOMSVGAnimationElement,
|
||||
nsIDOMSVGAnimationElement, nsIDOMSVGTests,
|
||||
nsIDOMSVGAnimateMotionElement)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGAnimateMotionElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGAnimateMotionElementBase)
|
||||
|
@ -92,9 +92,10 @@ NS_IMPL_RELEASE_INHERITED(nsSVGAnimateTransformElement,nsSVGAnimateTransformElem
|
||||
DOMCI_NODE_DATA(SVGAnimateTransformElement, nsSVGAnimateTransformElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsSVGAnimateTransformElement)
|
||||
NS_NODE_INTERFACE_TABLE5(nsSVGAnimateTransformElement, nsIDOMNode,
|
||||
NS_NODE_INTERFACE_TABLE6(nsSVGAnimateTransformElement, nsIDOMNode,
|
||||
nsIDOMElement, nsIDOMSVGElement,
|
||||
nsIDOMSVGAnimationElement,
|
||||
nsIDOMSVGTests,
|
||||
nsIDOMSVGAnimateTransformElement)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGAnimateTransformElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGAnimateTransformElementBase)
|
||||
|
@ -55,6 +55,7 @@ NS_IMPL_RELEASE_INHERITED(nsSVGAnimationElement, nsSVGAnimationElementBase)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsSVGAnimationElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISMILAnimationElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMElementTimeControl)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGTests)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGAnimationElementBase)
|
||||
|
||||
// Cycle collection magic -- based on nsSVGUseElement
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsReferencedElement.h"
|
||||
#include "nsIDOMSVGAnimationElement.h"
|
||||
#include "DOMSVGTests.h"
|
||||
#include "nsIDOMElementTimeControl.h"
|
||||
#include "nsISMILAnimationElement.h"
|
||||
#include "nsSMILTimedElement.h"
|
||||
@ -50,6 +51,7 @@
|
||||
typedef nsSVGElement nsSVGAnimationElementBase;
|
||||
|
||||
class nsSVGAnimationElement : public nsSVGAnimationElementBase,
|
||||
public DOMSVGTests,
|
||||
public nsISMILAnimationElement,
|
||||
public nsIDOMElementTimeControl
|
||||
{
|
||||
|
@ -100,8 +100,9 @@ NS_IMPL_RELEASE_INHERITED(nsSVGCircleElement,nsSVGCircleElementBase)
|
||||
DOMCI_NODE_DATA(SVGCircleElement, nsSVGCircleElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsSVGCircleElement)
|
||||
NS_NODE_INTERFACE_TABLE4(nsSVGCircleElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGCircleElement)
|
||||
NS_NODE_INTERFACE_TABLE5(nsSVGCircleElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGTests,
|
||||
nsIDOMSVGCircleElement)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGCircleElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGCircleElementBase)
|
||||
|
||||
|
@ -60,8 +60,9 @@ NS_IMPL_RELEASE_INHERITED(nsSVGClipPathElement,nsSVGClipPathElementBase)
|
||||
DOMCI_NODE_DATA(SVGClipPathElement, nsSVGClipPathElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsSVGClipPathElement)
|
||||
NS_NODE_INTERFACE_TABLE5(nsSVGClipPathElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGClipPathElement,
|
||||
NS_NODE_INTERFACE_TABLE6(nsSVGClipPathElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGTests,
|
||||
nsIDOMSVGClipPathElement,
|
||||
nsIDOMSVGUnitTypes)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGClipPathElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGClipPathElementBase)
|
||||
|
@ -40,12 +40,14 @@
|
||||
#include "nsSVGGraphicElement.h"
|
||||
#include "nsIDOMSVGClipPathElement.h"
|
||||
#include "nsIDOMSVGUnitTypes.h"
|
||||
#include "DOMSVGTests.h"
|
||||
#include "nsSVGEnum.h"
|
||||
|
||||
typedef nsSVGGraphicElement nsSVGClipPathElementBase;
|
||||
|
||||
class nsSVGClipPathElement : public nsSVGClipPathElementBase,
|
||||
public nsIDOMSVGClipPathElement,
|
||||
public DOMSVGTests,
|
||||
public nsIDOMSVGUnitTypes
|
||||
{
|
||||
friend class nsSVGClipPathFrame;
|
||||
|
@ -40,13 +40,15 @@
|
||||
|
||||
#include "nsSVGGraphicElement.h"
|
||||
#include "nsIDOMSVGDefsElement.h"
|
||||
#include "DOMSVGTests.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
typedef nsSVGGraphicElement nsSVGDefsElementBase;
|
||||
|
||||
class nsSVGDefsElement : public nsSVGDefsElementBase,
|
||||
public nsIDOMSVGDefsElement
|
||||
public nsIDOMSVGDefsElement,
|
||||
public DOMSVGTests
|
||||
{
|
||||
protected:
|
||||
friend nsresult NS_NewSVGDefsElement(nsIContent **aResult,
|
||||
@ -88,8 +90,9 @@ NS_IMPL_RELEASE_INHERITED(nsSVGDefsElement,nsSVGDefsElementBase)
|
||||
DOMCI_NODE_DATA(SVGDefsElement, nsSVGDefsElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsSVGDefsElement)
|
||||
NS_NODE_INTERFACE_TABLE4(nsSVGDefsElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGDefsElement)
|
||||
NS_NODE_INTERFACE_TABLE5(nsSVGDefsElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGTests,
|
||||
nsIDOMSVGDefsElement)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGDefsElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGDefsElementBase)
|
||||
|
||||
|
@ -40,7 +40,6 @@
|
||||
|
||||
#include "nsSVGElement.h"
|
||||
#include "nsSVGSVGElement.h"
|
||||
#include "nsSVGSwitchElement.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsRange.h"
|
||||
#include "nsIDOMAttr.h"
|
||||
@ -81,6 +80,7 @@
|
||||
#include "SVGAnimatedPointList.h"
|
||||
#include "SVGAnimatedPathSegList.h"
|
||||
#include "SVGAnimatedTransformList.h"
|
||||
#include "DOMSVGTests.h"
|
||||
#include "nsIDOMSVGUnitTypes.h"
|
||||
#include "nsSVGRect.h"
|
||||
#include "nsIFrame.h"
|
||||
@ -275,19 +275,6 @@ nsSVGElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
if (aNamespaceID == kNameSpaceID_None &&
|
||||
(aName == nsGkAtoms::requiredFeatures ||
|
||||
aName == nsGkAtoms::requiredExtensions ||
|
||||
aName == nsGkAtoms::systemLanguage)) {
|
||||
|
||||
nsIContent* parent = GetFlattenedTreeParent();
|
||||
|
||||
if (parent &&
|
||||
parent->NodeInfo()->Equals(nsGkAtoms::svgSwitch, kNameSpaceID_SVG)) {
|
||||
static_cast<nsSVGSwitchElement*>(parent)->MaybeInvalidate();
|
||||
}
|
||||
}
|
||||
|
||||
return nsSVGElementBase::AfterSetAttr(aNamespaceID, aName, aValue, aNotify);
|
||||
}
|
||||
|
||||
@ -481,6 +468,30 @@ nsSVGElement::ParseAttribute(PRInt32 aNamespaceID,
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundMatch) {
|
||||
// Check for conditional processing attributes
|
||||
nsCOMPtr<DOMSVGTests> tests(do_QueryInterface(this));
|
||||
if (tests && tests->ParseConditionalProcessingAttribute(
|
||||
aAttribute, aValue, aResult)) {
|
||||
foundMatch = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundMatch) {
|
||||
// Check for StringList attribute
|
||||
StringListAttributesInfo stringListInfo = GetStringListInfo();
|
||||
for (i = 0; i < stringListInfo.mStringListCount; i++) {
|
||||
if (aAttribute == *stringListInfo.mStringListInfo[i].mName) {
|
||||
rv = stringListInfo.mStringLists[i].SetValue(aValue, false);
|
||||
if (NS_FAILED(rv)) {
|
||||
stringListInfo.Reset(i);
|
||||
}
|
||||
foundMatch = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundMatch) {
|
||||
// Check for nsSVGViewBox attribute
|
||||
if (aAttribute == nsGkAtoms::viewBox) {
|
||||
@ -724,6 +735,23 @@ nsSVGElement::UnsetAttrInternal(PRInt32 aNamespaceID, nsIAtom* aName,
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for conditional processing attributes
|
||||
nsCOMPtr<DOMSVGTests> tests(do_QueryInterface(this));
|
||||
if (tests && tests->IsConditionalProcessingAttribute(aName)) {
|
||||
tests->UnsetAttr(aName);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if this is a string list attribute going away
|
||||
StringListAttributesInfo stringListInfo = GetStringListInfo();
|
||||
|
||||
for (PRUint32 i = 0; i < stringListInfo.mStringListCount; i++) {
|
||||
if (aName == *stringListInfo.mStringListInfo[i].mName) {
|
||||
stringListInfo.Reset(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if this is a string attribute going away
|
||||
@ -754,12 +782,11 @@ nsSVGElement::GetAttributeChangeHint(const nsIAtom* aAttribute,
|
||||
nsChangeHint retval =
|
||||
nsSVGElementBase::GetAttributeChangeHint(aAttribute, aModType);
|
||||
|
||||
if (aAttribute == nsGkAtoms::requiredFeatures ||
|
||||
aAttribute == nsGkAtoms::requiredExtensions ||
|
||||
aAttribute == nsGkAtoms::systemLanguage) {
|
||||
nsCOMPtr<DOMSVGTests> tests(do_QueryInterface(const_cast<nsSVGElement*>(this)));
|
||||
if (tests && tests->IsConditionalProcessingAttribute(aAttribute)) {
|
||||
// It would be nice to only reconstruct the frame if the value returned by
|
||||
// NS_SVG_PassesConditionalProcessingTests has changed, but we don't know
|
||||
// that
|
||||
// DOMSVGTests::PassesConditionalProcessingTests has changed, but we don't
|
||||
// know that
|
||||
NS_UpdateHint(retval, nsChangeHint_ReconstructFrame);
|
||||
}
|
||||
return retval;
|
||||
@ -2118,6 +2145,44 @@ nsSVGElement::DidAnimateString(PRUint8 aAttrEnum)
|
||||
}
|
||||
}
|
||||
|
||||
nsSVGElement::StringListAttributesInfo
|
||||
nsSVGElement::GetStringListInfo()
|
||||
{
|
||||
return StringListAttributesInfo(nsnull, nsnull, 0);
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGElement::DidChangeStringList(bool aIsConditionalProcessingAttribute,
|
||||
PRUint8 aAttrEnum)
|
||||
{
|
||||
if (aIsConditionalProcessingAttribute) {
|
||||
nsCOMPtr<DOMSVGTests> tests(do_QueryInterface(this));
|
||||
tests->DidChangeStringList(aAttrEnum);
|
||||
return;
|
||||
}
|
||||
|
||||
StringListAttributesInfo info = GetStringListInfo();
|
||||
|
||||
NS_ASSERTION(info.mStringListCount > 0,
|
||||
"DidChangeStringList on element with no string list attribs");
|
||||
|
||||
NS_ASSERTION(aAttrEnum < info.mStringListCount, "aAttrEnum out of range");
|
||||
|
||||
nsAutoString serializedValue;
|
||||
info.mStringLists[aAttrEnum].GetValue(serializedValue, this);
|
||||
|
||||
nsAttrValue attrValue(serializedValue);
|
||||
SetParsedAttr(kNameSpaceID_None, *info.mStringListInfo[aAttrEnum].mName,
|
||||
nsnull, attrValue, true);
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGElement::StringListAttributesInfo::Reset(PRUint8 aAttrEnum)
|
||||
{
|
||||
mStringLists[aAttrEnum].Clear();
|
||||
// caller notifies
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSVGElement::ReportAttributeParseFailure(nsIDocument* aDocument,
|
||||
nsIAtom* aAttribute,
|
||||
|
@ -76,6 +76,8 @@ class SVGAnimatedPointList;
|
||||
class SVGAnimatedPathSegList;
|
||||
class SVGAnimatedPreserveAspectRatio;
|
||||
class SVGAnimatedTransformList;
|
||||
class SVGStringList;
|
||||
class DOMSVGStringList;
|
||||
}
|
||||
|
||||
typedef nsStyledElementNotElementCSSInlineStyle nsSVGElementBase;
|
||||
@ -96,6 +98,7 @@ public:
|
||||
typedef mozilla::SVGAnimatedPathSegList SVGAnimatedPathSegList;
|
||||
typedef mozilla::SVGAnimatedPreserveAspectRatio SVGAnimatedPreserveAspectRatio;
|
||||
typedef mozilla::SVGAnimatedTransformList SVGAnimatedTransformList;
|
||||
typedef mozilla::SVGStringList SVGStringList;
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
@ -177,6 +180,8 @@ public:
|
||||
virtual void DidChangePathSegList(bool aDoSetAttr);
|
||||
virtual void DidChangeTransformList(bool aDoSetAttr);
|
||||
virtual void DidChangeString(PRUint8 aAttrEnum) {}
|
||||
void DidChangeStringList(bool aIsConditionalProcessingAttribute,
|
||||
PRUint8 aAttrEnum);
|
||||
|
||||
virtual void DidAnimateLength(PRUint8 aAttrEnum);
|
||||
virtual void DidAnimateNumber(PRUint8 aAttrEnum);
|
||||
@ -489,6 +494,27 @@ protected:
|
||||
void Reset(PRUint8 aAttrEnum);
|
||||
};
|
||||
|
||||
friend class mozilla::DOMSVGStringList;
|
||||
|
||||
struct StringListInfo {
|
||||
nsIAtom** mName;
|
||||
};
|
||||
|
||||
struct StringListAttributesInfo {
|
||||
SVGStringList* mStringLists;
|
||||
StringListInfo* mStringListInfo;
|
||||
PRUint32 mStringListCount;
|
||||
|
||||
StringListAttributesInfo(SVGStringList *aStringLists,
|
||||
StringListInfo *aStringListInfo,
|
||||
PRUint32 aStringListCount) :
|
||||
mStringLists(aStringLists), mStringListInfo(aStringListInfo),
|
||||
mStringListCount(aStringListCount)
|
||||
{}
|
||||
|
||||
void Reset(PRUint8 aAttrEnum);
|
||||
};
|
||||
|
||||
virtual LengthAttributesInfo GetLengthInfo();
|
||||
virtual NumberAttributesInfo GetNumberInfo();
|
||||
virtual NumberPairAttributesInfo GetNumberPairInfo();
|
||||
@ -504,6 +530,7 @@ protected:
|
||||
virtual NumberListAttributesInfo GetNumberListInfo();
|
||||
virtual LengthListAttributesInfo GetLengthListInfo();
|
||||
virtual StringAttributesInfo GetStringInfo();
|
||||
virtual StringListAttributesInfo GetStringListInfo();
|
||||
|
||||
static nsSVGEnumMapping sSVGUnitTypesMap[];
|
||||
|
||||
|
@ -1,152 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Scooter Morris.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Scooter Morris <scootermorris@comcast.net>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/**
|
||||
* This file is used to help create a mapping from a specified SVG element to
|
||||
* attributes supported by that element. This mapping can be used to help
|
||||
* ensure that we don't accidentally implement support for attributes like
|
||||
* requiredFeatures on elements for which the SVG specification does not
|
||||
* define support.
|
||||
*
|
||||
* To use, include this file into another file after defining the SVG_ELEMENT
|
||||
* C preprocessor macro as appropriate.
|
||||
*
|
||||
* The following constants represent the following attributes:
|
||||
*
|
||||
* ATTRS_CONDITIONAL
|
||||
* The requiredFeatures, requiredExtensions, and systemLanguage attributes
|
||||
*
|
||||
* ATTRS_EXTERNAL
|
||||
* The externalResourcesRequired attribute
|
||||
*
|
||||
* ATTRS_ALL
|
||||
* A convenience value indicating support for all of the above
|
||||
*
|
||||
* ATTRS_NONE
|
||||
* A convenience value indicating support for none of the above
|
||||
*/
|
||||
|
||||
//This file must not have include guards.
|
||||
|
||||
#define ATTRS_NONE 0x00
|
||||
#define ATTRS_CONDITIONAL 0x01
|
||||
#define ATTRS_EXTERNAL 0x02
|
||||
#define ATTRS_ALL (ATTRS_CONDITIONAL | ATTRS_EXTERNAL)
|
||||
// tags
|
||||
SVG_ELEMENT(a, ATTRS_ALL)
|
||||
SVG_ELEMENT(altGlyph, ATTRS_ALL)
|
||||
SVG_ELEMENT(altGlyphDef, ATTRS_NONE)
|
||||
SVG_ELEMENT(altGlyphItem, ATTRS_NONE)
|
||||
SVG_ELEMENT(animate, ATTRS_ALL)
|
||||
SVG_ELEMENT(animateColor, ATTRS_ALL)
|
||||
SVG_ELEMENT(animateMotion, ATTRS_ALL)
|
||||
SVG_ELEMENT(animateTransform, ATTRS_ALL)
|
||||
SVG_ELEMENT(circle, ATTRS_ALL)
|
||||
SVG_ELEMENT(clipPath, ATTRS_ALL)
|
||||
SVG_ELEMENT(colorProfile, ATTRS_NONE)
|
||||
SVG_ELEMENT(cursor, ATTRS_ALL)
|
||||
SVG_ELEMENT(definition_src, ATTRS_NONE)
|
||||
SVG_ELEMENT(defs, ATTRS_ALL)
|
||||
SVG_ELEMENT(desc, ATTRS_NONE)
|
||||
SVG_ELEMENT(ellipse, ATTRS_ALL)
|
||||
SVG_ELEMENT(feBlend, ATTRS_NONE)
|
||||
SVG_ELEMENT(feColorMatrix, ATTRS_NONE)
|
||||
SVG_ELEMENT(feComponentTransfer, ATTRS_NONE)
|
||||
SVG_ELEMENT(feComposite, ATTRS_NONE)
|
||||
SVG_ELEMENT(feConvolveMatrix, ATTRS_NONE)
|
||||
SVG_ELEMENT(feDiffuseLighting, ATTRS_NONE)
|
||||
SVG_ELEMENT(feDisplacementMap, ATTRS_NONE)
|
||||
SVG_ELEMENT(feDistantLight, ATTRS_NONE)
|
||||
SVG_ELEMENT(feFlood, ATTRS_NONE)
|
||||
SVG_ELEMENT(feFuncR, ATTRS_NONE)
|
||||
SVG_ELEMENT(feFuncG, ATTRS_NONE)
|
||||
SVG_ELEMENT(feFuncB, ATTRS_NONE)
|
||||
SVG_ELEMENT(feFuncA, ATTRS_NONE)
|
||||
SVG_ELEMENT(feGaussianBlur, ATTRS_NONE)
|
||||
SVG_ELEMENT(feImage, ATTRS_EXTERNAL)
|
||||
SVG_ELEMENT(feMerge, ATTRS_NONE)
|
||||
SVG_ELEMENT(feMergeNode, ATTRS_NONE)
|
||||
SVG_ELEMENT(feMorphology, ATTRS_NONE)
|
||||
SVG_ELEMENT(feOffset, ATTRS_NONE)
|
||||
SVG_ELEMENT(fePointLight, ATTRS_NONE)
|
||||
SVG_ELEMENT(feSpecularLighting, ATTRS_NONE)
|
||||
SVG_ELEMENT(feSpotLight, ATTRS_NONE)
|
||||
SVG_ELEMENT(feTile, ATTRS_NONE)
|
||||
SVG_ELEMENT(feTurbulence, ATTRS_NONE)
|
||||
SVG_ELEMENT(filter, ATTRS_EXTERNAL)
|
||||
SVG_ELEMENT(font, ATTRS_EXTERNAL)
|
||||
SVG_ELEMENT(font_face, ATTRS_NONE)
|
||||
SVG_ELEMENT(font_face_format, ATTRS_NONE)
|
||||
SVG_ELEMENT(font_face_name, ATTRS_NONE)
|
||||
SVG_ELEMENT(font_face_src, ATTRS_NONE)
|
||||
SVG_ELEMENT(font_face_uri, ATTRS_NONE)
|
||||
SVG_ELEMENT(foreignObject, ATTRS_ALL)
|
||||
SVG_ELEMENT(g, ATTRS_ALL)
|
||||
SVG_ELEMENT(glyph, ATTRS_NONE)
|
||||
SVG_ELEMENT(glyphRef, ATTRS_NONE)
|
||||
SVG_ELEMENT(hkern, ATTRS_NONE)
|
||||
SVG_ELEMENT(image, ATTRS_ALL)
|
||||
SVG_ELEMENT(line, ATTRS_ALL)
|
||||
SVG_ELEMENT(linearGradient, ATTRS_EXTERNAL)
|
||||
SVG_ELEMENT(marker, ATTRS_NONE)
|
||||
SVG_ELEMENT(mask, ATTRS_ALL)
|
||||
SVG_ELEMENT(metadata, ATTRS_NONE)
|
||||
SVG_ELEMENT(missingGlyph, ATTRS_NONE)
|
||||
SVG_ELEMENT(mpath, ATTRS_EXTERNAL)
|
||||
SVG_ELEMENT(path, ATTRS_ALL)
|
||||
SVG_ELEMENT(pattern, ATTRS_ALL)
|
||||
SVG_ELEMENT(polygon, ATTRS_ALL)
|
||||
SVG_ELEMENT(polyline, ATTRS_ALL)
|
||||
SVG_ELEMENT(radialGradient, ATTRS_EXTERNAL)
|
||||
SVG_ELEMENT(rect, ATTRS_ALL)
|
||||
SVG_ELEMENT(script, ATTRS_EXTERNAL)
|
||||
SVG_ELEMENT(set, ATTRS_ALL)
|
||||
SVG_ELEMENT(stop, ATTRS_NONE)
|
||||
SVG_ELEMENT(style, ATTRS_NONE)
|
||||
SVG_ELEMENT(svg, ATTRS_ALL)
|
||||
SVG_ELEMENT(svgSwitch, ATTRS_ALL) // switch is a C++ keyword, hence svgSwitch
|
||||
SVG_ELEMENT(symbol, ATTRS_NONE)
|
||||
SVG_ELEMENT(text, ATTRS_ALL)
|
||||
SVG_ELEMENT(textPath, ATTRS_ALL)
|
||||
SVG_ELEMENT(title, ATTRS_NONE)
|
||||
SVG_ELEMENT(tref, ATTRS_ALL)
|
||||
SVG_ELEMENT(tspan, ATTRS_ALL)
|
||||
SVG_ELEMENT(use, ATTRS_ALL)
|
||||
SVG_ELEMENT(view, ATTRS_EXTERNAL)
|
||||
SVG_ELEMENT(vkern, ATTRS_NONE)
|
@ -102,8 +102,9 @@ NS_IMPL_RELEASE_INHERITED(nsSVGEllipseElement,nsSVGEllipseElementBase)
|
||||
DOMCI_NODE_DATA(SVGEllipseElement, nsSVGEllipseElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsSVGEllipseElement)
|
||||
NS_NODE_INTERFACE_TABLE4(nsSVGEllipseElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGEllipseElement)
|
||||
NS_NODE_INTERFACE_TABLE5(nsSVGEllipseElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGTests,
|
||||
nsIDOMSVGEllipseElement)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGEllipseElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGEllipseElementBase)
|
||||
|
||||
|
@ -47,20 +47,13 @@
|
||||
*/
|
||||
|
||||
#include "nsSVGFeatures.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsWhitespaceTokenizer.h"
|
||||
#include "nsCharSeparatedTokenizer.h"
|
||||
#include "nsStyleUtil.h"
|
||||
#include "nsSVGUtils.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
/*static*/ bool
|
||||
nsSVGFeatures::HaveFeature(nsISupports* aObject, const nsAString& aFeature)
|
||||
nsSVGFeatures::HasFeature(nsISupports* aObject, const nsAString& aFeature)
|
||||
{
|
||||
if (aFeature.EqualsLiteral("http://www.w3.org/TR/SVG11/feature#Script")) {
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(aObject));
|
||||
@ -82,19 +75,7 @@ nsSVGFeatures::HaveFeature(nsISupports* aObject, const nsAString& aFeature)
|
||||
}
|
||||
|
||||
/*static*/ bool
|
||||
nsSVGFeatures::HaveFeatures(nsISupports* aObject, const nsSubstring& aFeatures)
|
||||
{
|
||||
nsWhitespaceTokenizer tokenizer(aFeatures);
|
||||
while (tokenizer.hasMoreTokens()) {
|
||||
if (!HaveFeature(aObject, tokenizer.nextToken())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*static*/ bool
|
||||
nsSVGFeatures::HaveExtension(const nsAString& aExtension)
|
||||
nsSVGFeatures::HasExtension(const nsAString& aExtension)
|
||||
{
|
||||
#define SVG_SUPPORTED_EXTENSION(str) if (aExtension.EqualsLiteral(str)) return true;
|
||||
SVG_SUPPORTED_EXTENSION("http://www.w3.org/1999/xhtml")
|
||||
@ -103,147 +84,3 @@ nsSVGFeatures::HaveExtension(const nsAString& aExtension)
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*static*/ bool
|
||||
nsSVGFeatures::HaveExtensions(const nsSubstring& aExtensions)
|
||||
{
|
||||
nsWhitespaceTokenizer tokenizer(aExtensions);
|
||||
while (tokenizer.hasMoreTokens()) {
|
||||
if (!HaveExtension(tokenizer.nextToken())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*static*/ bool
|
||||
nsSVGFeatures::MatchesLanguagePreferences(const nsSubstring& aAttribute,
|
||||
const nsSubstring& aAcceptLangs)
|
||||
{
|
||||
const nsDefaultStringComparator defaultComparator;
|
||||
|
||||
nsCharSeparatedTokenizerTemplate<IsSVGWhitespace>
|
||||
attributeTokenizer(aAttribute, ',');
|
||||
|
||||
while (attributeTokenizer.hasMoreTokens()) {
|
||||
const nsSubstring &attributeToken = attributeTokenizer.nextToken();
|
||||
nsCharSeparatedTokenizer languageTokenizer(aAcceptLangs, ',');
|
||||
while (languageTokenizer.hasMoreTokens()) {
|
||||
if (nsStyleUtil::DashMatchCompare(attributeToken,
|
||||
languageTokenizer.nextToken(),
|
||||
defaultComparator)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*static*/ PRInt32
|
||||
nsSVGFeatures::GetBestLanguagePreferenceRank(const nsSubstring& aAttribute,
|
||||
const nsSubstring& aAcceptLangs)
|
||||
{
|
||||
const nsDefaultStringComparator defaultComparator;
|
||||
|
||||
nsCharSeparatedTokenizer attributeTokenizer(aAttribute, ',');
|
||||
PRInt32 lowestRank = -1;
|
||||
|
||||
while (attributeTokenizer.hasMoreTokens()) {
|
||||
const nsSubstring &attributeToken = attributeTokenizer.nextToken();
|
||||
nsCharSeparatedTokenizer languageTokenizer(aAcceptLangs, ',');
|
||||
PRInt32 index = 0;
|
||||
while (languageTokenizer.hasMoreTokens()) {
|
||||
const nsSubstring &languageToken = languageTokenizer.nextToken();
|
||||
bool exactMatch = (languageToken == attributeToken);
|
||||
bool prefixOnlyMatch =
|
||||
!exactMatch &&
|
||||
nsStyleUtil::DashMatchCompare(attributeToken,
|
||||
languageTokenizer.nextToken(),
|
||||
defaultComparator);
|
||||
if (index == 0 && exactMatch) {
|
||||
// best possible match
|
||||
return 0;
|
||||
}
|
||||
if ((exactMatch || prefixOnlyMatch) &&
|
||||
(lowestRank == -1 || 2 * index + prefixOnlyMatch < lowestRank)) {
|
||||
lowestRank = 2 * index + prefixOnlyMatch;
|
||||
}
|
||||
++index;
|
||||
}
|
||||
}
|
||||
return lowestRank;
|
||||
}
|
||||
|
||||
/*static*/ bool
|
||||
nsSVGFeatures::ElementSupportsAttributes(const nsIAtom *aTagName, PRUint16 aAttr)
|
||||
{
|
||||
#define SVG_ELEMENT(_atom, _supports) if (aTagName == nsGkAtoms::_atom) return (_supports & aAttr) != 0;
|
||||
#include "nsSVGElementList.h"
|
||||
#undef SVG_ELEMENT
|
||||
return false;
|
||||
}
|
||||
|
||||
const nsString * const nsSVGFeatures::kIgnoreSystemLanguage = (nsString *) 0x01;
|
||||
|
||||
/*static*/ bool
|
||||
nsSVGFeatures::PassesConditionalProcessingTests(nsIContent *aContent,
|
||||
const nsString *aAcceptLangs)
|
||||
{
|
||||
if (!aContent->IsElement()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ElementSupportsAttributes(aContent->Tag(), ATTRS_CONDITIONAL)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Required Features
|
||||
nsAutoString value;
|
||||
if (aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::requiredFeatures, value)) {
|
||||
if (value.IsEmpty() || !HaveFeatures(aContent, value)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Required Extensions
|
||||
//
|
||||
// The requiredExtensions attribute defines a list of required language
|
||||
// extensions. Language extensions are capabilities within a user agent that
|
||||
// go beyond the feature set defined in the SVG specification.
|
||||
// Each extension is identified by a URI reference.
|
||||
// For now, claim that mozilla's SVG implementation supports XHTML and MathML.
|
||||
if (aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::requiredExtensions, value)) {
|
||||
if (value.IsEmpty() || !HaveExtensions(value)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (aAcceptLangs == kIgnoreSystemLanguage) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// systemLanguage
|
||||
//
|
||||
// Evaluates to "true" if one of the languages indicated by user preferences
|
||||
// exactly equals one of the languages given in the value of this parameter,
|
||||
// or if one of the languages indicated by user preferences exactly equals a
|
||||
// prefix of one of the languages given in the value of this parameter such
|
||||
// that the first tag character following the prefix is "-".
|
||||
if (aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::systemLanguage,
|
||||
value)) {
|
||||
|
||||
const nsAutoString acceptLangs(aAcceptLangs ? *aAcceptLangs :
|
||||
Preferences::GetLocalizedString("intl.accept_languages"));
|
||||
|
||||
// Get our language preferences
|
||||
if (!acceptLangs.IsEmpty()) {
|
||||
return MatchesLanguagePreferences(value, acceptLangs);
|
||||
} else {
|
||||
// For now, evaluate to true.
|
||||
NS_WARNING("no default language specified for systemLanguage conditional test");
|
||||
return !value.IsEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -41,9 +41,6 @@
|
||||
|
||||
#include "nsString.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsIAtom;
|
||||
|
||||
class nsSVGFeatures
|
||||
{
|
||||
public:
|
||||
@ -56,56 +53,7 @@ public:
|
||||
* http://www.w3.org/TR/SVG11/feature.html
|
||||
*/
|
||||
static bool
|
||||
HaveFeature(nsISupports* aObject, const nsAString& aFeature);
|
||||
|
||||
/**
|
||||
* Compare the language name(s) in a systemLanguage attribute to the
|
||||
* user's language preferences, as defined in
|
||||
* http://www.w3.org/TR/SVG11/struct.html#SystemLanguageAttribute
|
||||
* We have a match if a language name in the users language preferences
|
||||
* exactly equals one of the language names or exactly equals a prefix of
|
||||
* one of the language names in the systemLanguage attribute.
|
||||
* @returns 2 * the lowest index in the aAcceptLangs that matches + 1
|
||||
* if only the prefix matches, or -1 if no indices match.
|
||||
* XXX This algorithm is O(M*N).
|
||||
*/
|
||||
static int
|
||||
GetBestLanguagePreferenceRank(const nsSubstring& aAttribute,
|
||||
const nsSubstring& aAcceptLangs);
|
||||
|
||||
/**
|
||||
* Special value to pass to PassesConditionalProcessingTests to ignore systemLanguage
|
||||
* attributes
|
||||
*/
|
||||
static const nsString * const kIgnoreSystemLanguage;
|
||||
|
||||
/**
|
||||
* Check whether the conditional processing attributes requiredFeatures,
|
||||
* requiredExtensions and systemLanguage all "return true" if they apply to
|
||||
* and are specified on the given element. Returns true if this element
|
||||
* should be rendered, false if it should not.
|
||||
*
|
||||
* @param aContent the element to test
|
||||
* @param aAcceptLangs Optional parameter to pass in the value of the
|
||||
* intl.accept_languages preference if the caller has it cached.
|
||||
* Alternatively, pass in kIgnoreSystemLanguage to skip the systemLanguage
|
||||
* check if the caller is giving that special treatment.
|
||||
*/
|
||||
static bool
|
||||
PassesConditionalProcessingTests(nsIContent *aContent,
|
||||
const nsString *aAcceptLangs = nsnull);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Check whether we support the given list of feature strings.
|
||||
*
|
||||
* @param aObject the object, which should support the feature,
|
||||
* for example nsIDOMNode or nsIDOMDOMImplementation
|
||||
* @param aFeatures a whitespace separated list containing one or more of the
|
||||
* feature strings specified at http://www.w3.org/TR/SVG11/feature.html
|
||||
*/
|
||||
static bool
|
||||
HaveFeatures(nsISupports* aObject, const nsSubstring& aFeatures);
|
||||
HasFeature(nsISupports* aObject, const nsAString& aFeature);
|
||||
|
||||
/**
|
||||
* Check whether we support the given extension string.
|
||||
@ -114,41 +62,7 @@ private:
|
||||
* "http://www.w3.org/1999/xhtml" and "http://www.w3.org/1998/Math/MathML"
|
||||
*/
|
||||
static bool
|
||||
HaveExtension(const nsAString& aExtension);
|
||||
|
||||
/**
|
||||
* Check whether we support the given list of extension strings.
|
||||
*
|
||||
* @param aExtension a whitespace separated list containing one or more
|
||||
* extension strings
|
||||
*/
|
||||
static bool
|
||||
HaveExtensions(const nsSubstring& aExtensions);
|
||||
|
||||
/**
|
||||
* Compare the language name(s) in a systemLanguage attribute to the
|
||||
* user's language preferences, as defined in
|
||||
* http://www.w3.org/TR/SVG11/struct.html#SystemLanguageAttribute
|
||||
* We have a match if a language name in the users language preferences
|
||||
* exactly equals one of the language names or exactly equals a prefix of
|
||||
* one of the language names in the systemLanguage attribute.
|
||||
* XXX This algorithm is O(M*N).
|
||||
*/
|
||||
static bool
|
||||
MatchesLanguagePreferences(const nsSubstring& aAttribute,
|
||||
const nsSubstring& aAcceptLangs);
|
||||
|
||||
/**
|
||||
* Check whether this element supports the specified attributes
|
||||
* (i.e. whether the SVG specification defines the attributes
|
||||
* for the specified element).
|
||||
*
|
||||
* @param aTagName the tag for the element
|
||||
* @param aAttr the conditional to test for, either
|
||||
* ATTRS_TEST or ATTRS_EXTERNAL
|
||||
*/
|
||||
static bool
|
||||
ElementSupportsAttributes(const nsIAtom *aTagName, PRUint16 aAttr);
|
||||
HasExtension(const nsAString& aExtension);
|
||||
};
|
||||
|
||||
#endif // __NS_SVGFEATURES_H__
|
||||
|
@ -84,8 +84,9 @@ NS_IMPL_RELEASE_INHERITED(nsSVGFilterElement,nsSVGFilterElementBase)
|
||||
DOMCI_NODE_DATA(SVGFilterElement, nsSVGFilterElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsSVGFilterElement)
|
||||
NS_NODE_INTERFACE_TABLE5(nsSVGFilterElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGFilterElement,
|
||||
NS_NODE_INTERFACE_TABLE6(nsSVGFilterElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGTests,
|
||||
nsIDOMSVGFilterElement,
|
||||
nsIDOMSVGURIReference)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGFilterElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGFilterElementBase)
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "nsIDOMSVGFilterElement.h"
|
||||
#include "nsIDOMSVGURIReference.h"
|
||||
#include "nsIDOMSVGUnitTypes.h"
|
||||
#include "DOMSVGTests.h"
|
||||
#include "nsSVGLength2.h"
|
||||
#include "nsSVGIntegerPair.h"
|
||||
#include "nsSVGEnum.h"
|
||||
@ -50,6 +51,7 @@ typedef nsSVGGraphicElement nsSVGFilterElementBase;
|
||||
|
||||
class nsSVGFilterElement : public nsSVGFilterElementBase,
|
||||
public nsIDOMSVGFilterElement,
|
||||
public DOMSVGTests,
|
||||
public nsIDOMSVGURIReference,
|
||||
public nsIDOMSVGUnitTypes
|
||||
{
|
||||
|
@ -62,8 +62,9 @@ NS_IMPL_RELEASE_INHERITED(nsSVGForeignObjectElement,nsSVGForeignObjectElementBas
|
||||
DOMCI_NODE_DATA(SVGForeignObjectElement, nsSVGForeignObjectElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsSVGForeignObjectElement)
|
||||
NS_NODE_INTERFACE_TABLE4(nsSVGForeignObjectElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGForeignObjectElement)
|
||||
NS_NODE_INTERFACE_TABLE5(nsSVGForeignObjectElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGTests,
|
||||
nsIDOMSVGForeignObjectElement)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGForeignObjectElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGForeignObjectElementBase)
|
||||
|
||||
|
@ -41,12 +41,14 @@
|
||||
|
||||
#include "nsSVGGraphicElement.h"
|
||||
#include "nsIDOMSVGForeignObjectElem.h"
|
||||
#include "DOMSVGTests.h"
|
||||
#include "nsSVGLength2.h"
|
||||
|
||||
typedef nsSVGGraphicElement nsSVGForeignObjectElementBase;
|
||||
|
||||
class nsSVGForeignObjectElement : public nsSVGForeignObjectElementBase,
|
||||
public nsIDOMSVGForeignObjectElement
|
||||
public nsIDOMSVGForeignObjectElement,
|
||||
public DOMSVGTests
|
||||
{
|
||||
friend class nsSVGForeignObjectFrame;
|
||||
|
||||
|
@ -40,13 +40,15 @@
|
||||
|
||||
#include "nsSVGGraphicElement.h"
|
||||
#include "nsIDOMSVGGElement.h"
|
||||
#include "DOMSVGTests.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
typedef nsSVGGraphicElement nsSVGGElementBase;
|
||||
|
||||
class nsSVGGElement : public nsSVGGElementBase,
|
||||
public nsIDOMSVGGElement
|
||||
public nsIDOMSVGGElement,
|
||||
public DOMSVGTests
|
||||
{
|
||||
protected:
|
||||
friend nsresult NS_NewSVGGElement(nsIContent **aResult,
|
||||
@ -88,8 +90,9 @@ NS_IMPL_RELEASE_INHERITED(nsSVGGElement,nsSVGGElementBase)
|
||||
DOMCI_NODE_DATA(SVGGElement, nsSVGGElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsSVGGElement)
|
||||
NS_NODE_INTERFACE_TABLE4(nsSVGGElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGGElement)
|
||||
NS_NODE_INTERFACE_TABLE5(nsSVGGElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGTests,
|
||||
nsIDOMSVGGElement)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGGElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGGElementBase)
|
||||
|
||||
|
@ -183,8 +183,9 @@ NS_IMPL_RELEASE_INHERITED(nsSVGLinearGradientElement,nsSVGLinearGradientElementB
|
||||
DOMCI_NODE_DATA(SVGLinearGradientElement, nsSVGLinearGradientElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsSVGLinearGradientElement)
|
||||
NS_NODE_INTERFACE_TABLE5(nsSVGLinearGradientElement, nsIDOMNode,
|
||||
NS_NODE_INTERFACE_TABLE6(nsSVGLinearGradientElement, nsIDOMNode,
|
||||
nsIDOMElement, nsIDOMSVGElement,
|
||||
nsIDOMSVGTests,
|
||||
nsIDOMSVGGradientElement,
|
||||
nsIDOMSVGLinearGradientElement)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGLinearGradientElement)
|
||||
@ -272,8 +273,9 @@ NS_IMPL_RELEASE_INHERITED(nsSVGRadialGradientElement,nsSVGRadialGradientElementB
|
||||
DOMCI_NODE_DATA(SVGRadialGradientElement, nsSVGRadialGradientElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsSVGRadialGradientElement)
|
||||
NS_NODE_INTERFACE_TABLE5(nsSVGRadialGradientElement, nsIDOMNode,
|
||||
NS_NODE_INTERFACE_TABLE6(nsSVGRadialGradientElement, nsIDOMNode,
|
||||
nsIDOMElement, nsIDOMSVGElement,
|
||||
nsIDOMSVGTests,
|
||||
nsIDOMSVGGradientElement,
|
||||
nsIDOMSVGRadialGradientElement)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGRadialGradientElement)
|
||||
|
@ -41,6 +41,7 @@
|
||||
|
||||
#include "nsIDOMSVGURIReference.h"
|
||||
#include "nsIDOMSVGGradientElement.h"
|
||||
#include "DOMSVGTests.h"
|
||||
#include "nsIDOMSVGUnitTypes.h"
|
||||
#include "nsSVGStylableElement.h"
|
||||
#include "nsSVGLength2.h"
|
||||
@ -53,6 +54,7 @@
|
||||
typedef nsSVGStylableElement nsSVGGradientElementBase;
|
||||
|
||||
class nsSVGGradientElement : public nsSVGGradientElementBase,
|
||||
public DOMSVGTests,
|
||||
public nsIDOMSVGURIReference,
|
||||
public nsIDOMSVGUnitTypes
|
||||
{
|
||||
|
@ -72,8 +72,9 @@ NS_IMPL_RELEASE_INHERITED(nsSVGImageElement,nsSVGImageElementBase)
|
||||
DOMCI_NODE_DATA(SVGImageElement, nsSVGImageElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsSVGImageElement)
|
||||
NS_NODE_INTERFACE_TABLE7(nsSVGImageElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGImageElement,
|
||||
NS_NODE_INTERFACE_TABLE8(nsSVGImageElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGTests,
|
||||
nsIDOMSVGImageElement,
|
||||
nsIDOMSVGURIReference, imgIDecoderObserver,
|
||||
nsIImageLoadingContent)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGImageElement)
|
||||
|
@ -106,8 +106,9 @@ NS_IMPL_RELEASE_INHERITED(nsSVGLineElement,nsSVGLineElementBase)
|
||||
DOMCI_NODE_DATA(SVGLineElement, nsSVGLineElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsSVGLineElement)
|
||||
NS_NODE_INTERFACE_TABLE4(nsSVGLineElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGLineElement)
|
||||
NS_NODE_INTERFACE_TABLE5(nsSVGLineElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGTests,
|
||||
nsIDOMSVGLineElement)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGLineElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGLineElementBase)
|
||||
|
||||
|
@ -75,9 +75,9 @@ NS_IMPL_RELEASE_INHERITED(nsSVGMaskElement,nsSVGMaskElementBase)
|
||||
DOMCI_NODE_DATA(SVGMaskElement, nsSVGMaskElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsSVGMaskElement)
|
||||
NS_NODE_INTERFACE_TABLE5(nsSVGMaskElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGMaskElement,
|
||||
nsIDOMSVGUnitTypes)
|
||||
NS_NODE_INTERFACE_TABLE6(nsSVGMaskElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGTests,
|
||||
nsIDOMSVGMaskElement, nsIDOMSVGUnitTypes)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGMaskElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGMaskElementBase)
|
||||
|
||||
|
@ -39,6 +39,7 @@
|
||||
|
||||
#include "nsSVGStylableElement.h"
|
||||
#include "nsIDOMSVGMaskElement.h"
|
||||
#include "DOMSVGTests.h"
|
||||
#include "nsIDOMSVGUnitTypes.h"
|
||||
#include "nsSVGLength2.h"
|
||||
#include "nsSVGEnum.h"
|
||||
@ -49,6 +50,7 @@ typedef nsSVGStylableElement nsSVGMaskElementBase;
|
||||
|
||||
class nsSVGMaskElement : public nsSVGMaskElementBase,
|
||||
public nsIDOMSVGMaskElement,
|
||||
public DOMSVGTests,
|
||||
public nsIDOMSVGUnitTypes
|
||||
{
|
||||
friend class nsSVGMaskFrame;
|
||||
|
@ -67,9 +67,9 @@ NS_IMPL_RELEASE_INHERITED(nsSVGPathElement,nsSVGPathElementBase)
|
||||
DOMCI_NODE_DATA(SVGPathElement, nsSVGPathElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsSVGPathElement)
|
||||
NS_NODE_INTERFACE_TABLE5(nsSVGPathElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGPathElement,
|
||||
nsIDOMSVGAnimatedPathData)
|
||||
NS_NODE_INTERFACE_TABLE6(nsSVGPathElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGTests,
|
||||
nsIDOMSVGPathElement, nsIDOMSVGAnimatedPathData)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGPathElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGPathElementBase)
|
||||
|
||||
|
@ -36,6 +36,19 @@
|
||||
|
||||
#include "nsSVGPathGeometryElement.h"
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsSVGPathGeometryElement, nsSVGPathGeometryElementBase)
|
||||
NS_IMPL_RELEASE_INHERITED(nsSVGPathGeometryElement, nsSVGPathGeometryElementBase)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSVGPathGeometryElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGTests)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGPathGeometryElementBase)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
nsSVGPathGeometryElement::nsSVGPathGeometryElement(already_AddRefed<nsINodeInfo> aNodeInfo)
|
||||
: nsSVGPathGeometryElementBase(aNodeInfo)
|
||||
{
|
||||
|
@ -38,6 +38,7 @@
|
||||
#define __NS_SVGPATHGEOMETRYELEMENT_H__
|
||||
|
||||
#include "nsSVGGraphicElement.h"
|
||||
#include "DOMSVGTests.h"
|
||||
#include "nsTArray.h"
|
||||
#include "gfxPath.h"
|
||||
#include "gfxMatrix.h"
|
||||
@ -52,11 +53,15 @@ class gfxContext;
|
||||
|
||||
typedef nsSVGGraphicElement nsSVGPathGeometryElementBase;
|
||||
|
||||
class nsSVGPathGeometryElement : public nsSVGPathGeometryElementBase
|
||||
class nsSVGPathGeometryElement : public nsSVGPathGeometryElementBase,
|
||||
public DOMSVGTests
|
||||
{
|
||||
public:
|
||||
nsSVGPathGeometryElement(already_AddRefed<nsINodeInfo> aNodeInfo);
|
||||
|
||||
// interfaces:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
virtual bool AttributeDefinesGeometry(const nsIAtom *aName);
|
||||
virtual bool IsMarkable();
|
||||
virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks);
|
||||
|
@ -85,10 +85,10 @@ NS_IMPL_RELEASE_INHERITED(nsSVGPatternElement,nsSVGPatternElementBase)
|
||||
DOMCI_NODE_DATA(SVGPatternElement, nsSVGPatternElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsSVGPatternElement)
|
||||
NS_NODE_INTERFACE_TABLE7(nsSVGPatternElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGFitToViewBox,
|
||||
nsIDOMSVGURIReference, nsIDOMSVGPatternElement,
|
||||
nsIDOMSVGUnitTypes)
|
||||
NS_NODE_INTERFACE_TABLE8(nsSVGPatternElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGTests,
|
||||
nsIDOMSVGFitToViewBox, nsIDOMSVGURIReference,
|
||||
nsIDOMSVGPatternElement, nsIDOMSVGUnitTypes)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGPatternElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGPatternElementBase)
|
||||
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "nsIDOMSVGURIReference.h"
|
||||
#include "nsIDOMSVGFitToViewBox.h"
|
||||
#include "nsIDOMSVGPatternElement.h"
|
||||
#include "DOMSVGTests.h"
|
||||
#include "nsIDOMSVGUnitTypes.h"
|
||||
#include "nsSVGLength2.h"
|
||||
#include "nsSVGEnum.h"
|
||||
@ -56,9 +57,10 @@
|
||||
typedef nsSVGStylableElement nsSVGPatternElementBase;
|
||||
|
||||
class nsSVGPatternElement : public nsSVGPatternElementBase,
|
||||
public nsIDOMSVGPatternElement,
|
||||
public DOMSVGTests,
|
||||
public nsIDOMSVGURIReference,
|
||||
public nsIDOMSVGFitToViewBox,
|
||||
public nsIDOMSVGPatternElement,
|
||||
public nsIDOMSVGUnitTypes
|
||||
{
|
||||
friend class nsSVGPatternFrame;
|
||||
|
@ -82,8 +82,9 @@ NS_IMPL_RELEASE_INHERITED(nsSVGPolygonElement,nsSVGPolygonElementBase)
|
||||
DOMCI_NODE_DATA(SVGPolygonElement, nsSVGPolygonElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsSVGPolygonElement)
|
||||
NS_NODE_INTERFACE_TABLE4(nsSVGPolygonElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGPolygonElement)
|
||||
NS_NODE_INTERFACE_TABLE5(nsSVGPolygonElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGTests,
|
||||
nsIDOMSVGPolygonElement)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGPolygonElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGPolygonElementBase)
|
||||
|
||||
|
@ -76,8 +76,9 @@ NS_IMPL_RELEASE_INHERITED(nsSVGPolylineElement,nsSVGPolylineElementBase)
|
||||
DOMCI_NODE_DATA(SVGPolylineElement, nsSVGPolylineElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsSVGPolylineElement)
|
||||
NS_NODE_INTERFACE_TABLE4(nsSVGPolylineElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGPolylineElement)
|
||||
NS_NODE_INTERFACE_TABLE5(nsSVGPolylineElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGTests,
|
||||
nsIDOMSVGPolylineElement)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGPolylineElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGPolylineElementBase)
|
||||
|
||||
|
@ -103,8 +103,9 @@ NS_IMPL_RELEASE_INHERITED(nsSVGRectElement,nsSVGRectElementBase)
|
||||
DOMCI_NODE_DATA(SVGRectElement, nsSVGRectElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsSVGRectElement)
|
||||
NS_NODE_INTERFACE_TABLE4(nsSVGRectElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGRectElement)
|
||||
NS_NODE_INTERFACE_TABLE5(nsSVGRectElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGTests,
|
||||
nsIDOMSVGRectElement)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGRectElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGRectElementBase)
|
||||
|
||||
|
@ -182,8 +182,9 @@ NS_IMPL_RELEASE_INHERITED(nsSVGSVGElement,nsSVGSVGElementBase)
|
||||
DOMCI_NODE_DATA(SVGSVGElement, nsSVGSVGElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsSVGSVGElement)
|
||||
NS_NODE_INTERFACE_TABLE7(nsSVGSVGElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGSVGElement,
|
||||
NS_NODE_INTERFACE_TABLE8(nsSVGSVGElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGTests,
|
||||
nsIDOMSVGSVGElement,
|
||||
nsIDOMSVGFitToViewBox, nsIDOMSVGLocatable,
|
||||
nsIDOMSVGZoomAndPan)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGSVGElement)
|
||||
|
@ -42,6 +42,7 @@
|
||||
|
||||
#include "nsSVGStylableElement.h"
|
||||
#include "nsIDOMSVGSVGElement.h"
|
||||
#include "DOMSVGTests.h"
|
||||
#include "nsIDOMSVGFitToViewBox.h"
|
||||
#include "nsIDOMSVGLocatable.h"
|
||||
#include "nsIDOMSVGZoomAndPan.h"
|
||||
@ -118,6 +119,7 @@ public:
|
||||
|
||||
class nsSVGSVGElement : public nsSVGSVGElementBase,
|
||||
public nsIDOMSVGSVGElement,
|
||||
public DOMSVGTests,
|
||||
public nsIDOMSVGFitToViewBox,
|
||||
public nsIDOMSVGLocatable,
|
||||
public nsIDOMSVGZoomAndPan
|
||||
|
@ -82,9 +82,9 @@ NS_IMPL_RELEASE_INHERITED(nsSVGSetElement,nsSVGSetElementBase)
|
||||
DOMCI_NODE_DATA(SVGSetElement, nsSVGSetElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsSVGSetElement)
|
||||
NS_NODE_INTERFACE_TABLE5(nsSVGSetElement, nsIDOMNode, nsIDOMElement,
|
||||
NS_NODE_INTERFACE_TABLE6(nsSVGSetElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGAnimationElement,
|
||||
nsIDOMSVGSetElement)
|
||||
nsIDOMSVGTests, nsIDOMSVGSetElement)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGSetElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGSetElementBase)
|
||||
|
||||
|
@ -36,8 +36,8 @@
|
||||
|
||||
#include "mozilla/Util.h"
|
||||
|
||||
#include "nsSVGFeatures.h"
|
||||
#include "nsSVGSwitchElement.h"
|
||||
#include "DOMSVGTests.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsISVGChildFrame.h"
|
||||
#include "nsSVGUtils.h"
|
||||
@ -71,8 +71,9 @@ NS_IMPL_RELEASE_INHERITED(nsSVGSwitchElement,nsSVGSwitchElementBase)
|
||||
DOMCI_NODE_DATA(SVGSwitchElement, nsSVGSwitchElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsSVGSwitchElement)
|
||||
NS_NODE_INTERFACE_TABLE4(nsSVGSwitchElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGSwitchElement)
|
||||
NS_NODE_INTERFACE_TABLE5(nsSVGSwitchElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGSwitchElement,
|
||||
nsIDOMSVGTests)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGSwitchElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGSwitchElementBase)
|
||||
|
||||
@ -175,13 +176,16 @@ nsSVGSwitchElement::FindActiveChild() const
|
||||
for (nsIContent* child = nsINode::GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
if (nsSVGFeatures::PassesConditionalProcessingTests(
|
||||
child, nsSVGFeatures::kIgnoreSystemLanguage)) {
|
||||
nsAutoString value;
|
||||
if (child->GetAttr(kNameSpaceID_None, nsGkAtoms::systemLanguage,
|
||||
value)) {
|
||||
|
||||
if (!child->IsElement()) {
|
||||
continue;
|
||||
}
|
||||
nsCOMPtr<DOMSVGTests> tests(do_QueryInterface(child));
|
||||
if (tests) {
|
||||
if (tests->PassesConditionalProcessingTests(
|
||||
DOMSVGTests::kIgnoreSystemLanguage)) {
|
||||
PRInt32 languagePreferenceRank =
|
||||
nsSVGFeatures::GetBestLanguagePreferenceRank(value, acceptLangs);
|
||||
tests->GetBestLanguagePreferenceRank(acceptLangs);
|
||||
switch (languagePreferenceRank) {
|
||||
case 0:
|
||||
// best possible match
|
||||
@ -197,9 +201,9 @@ nsSVGSwitchElement::FindActiveChild() const
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else if (!bestChild) {
|
||||
bestChild = child;
|
||||
}
|
||||
} else if (!bestChild) {
|
||||
bestChild = child;
|
||||
}
|
||||
}
|
||||
return bestChild;
|
||||
@ -208,7 +212,11 @@ nsSVGSwitchElement::FindActiveChild() const
|
||||
for (nsIContent* child = nsINode::GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
if (nsSVGFeatures::PassesConditionalProcessingTests(child, &acceptLangs)) {
|
||||
if (!child->IsElement()) {
|
||||
continue;
|
||||
}
|
||||
nsCOMPtr<DOMSVGTests> tests(do_QueryInterface(child));
|
||||
if (!tests || tests->PassesConditionalProcessingTests(&acceptLangs)) {
|
||||
return child;
|
||||
}
|
||||
}
|
||||
|
@ -41,11 +41,13 @@
|
||||
|
||||
#include "nsSVGGraphicElement.h"
|
||||
#include "nsIDOMSVGSwitchElement.h"
|
||||
#include "DOMSVGTests.h"
|
||||
|
||||
typedef nsSVGGraphicElement nsSVGSwitchElementBase;
|
||||
|
||||
class nsSVGSwitchElement : public nsSVGSwitchElementBase,
|
||||
public nsIDOMSVGSwitchElement
|
||||
public nsIDOMSVGSwitchElement,
|
||||
public DOMSVGTests
|
||||
{
|
||||
friend class nsSVGSwitchFrame;
|
||||
protected:
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "mozilla/Util.h"
|
||||
|
||||
#include "nsIDOMSVGSymbolElement.h"
|
||||
#include "DOMSVGTests.h"
|
||||
#include "nsSVGStylableElement.h"
|
||||
#include "nsSVGViewBox.h"
|
||||
#include "SVGAnimatedPreserveAspectRatio.h"
|
||||
@ -47,8 +48,9 @@ using namespace mozilla;
|
||||
typedef nsSVGStylableElement nsSVGSymbolElementBase;
|
||||
|
||||
class nsSVGSymbolElement : public nsSVGSymbolElementBase,
|
||||
public nsIDOMSVGFitToViewBox,
|
||||
public nsIDOMSVGSymbolElement
|
||||
public nsIDOMSVGSymbolElement,
|
||||
public DOMSVGTests,
|
||||
public nsIDOMSVGFitToViewBox
|
||||
{
|
||||
protected:
|
||||
friend nsresult NS_NewSVGSymbolElement(nsIContent **aResult,
|
||||
|
@ -95,10 +95,11 @@ NS_IMPL_RELEASE_INHERITED(nsSVGTSpanElement,nsSVGTSpanElementBase)
|
||||
DOMCI_NODE_DATA(SVGTSpanElement, nsSVGTSpanElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsSVGTSpanElement)
|
||||
NS_NODE_INTERFACE_TABLE6(nsSVGTSpanElement, nsIDOMNode, nsIDOMElement,
|
||||
NS_NODE_INTERFACE_TABLE7(nsSVGTSpanElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGTSpanElement,
|
||||
nsIDOMSVGTextPositioningElement,
|
||||
nsIDOMSVGTextContentElement)
|
||||
nsIDOMSVGTextContentElement,
|
||||
nsIDOMSVGTests)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGTSpanElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGTSpanElementBase)
|
||||
|
||||
|
@ -41,6 +41,16 @@
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsSVGTextContentElement, nsSVGTextContentElementBase)
|
||||
NS_IMPL_RELEASE_INHERITED(nsSVGTextContentElement, nsSVGTextContentElementBase)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSVGTextContentElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGTests)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGTextContentElementBase)
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength textLength; */
|
||||
NS_IMETHODIMP nsSVGTextContentElement::GetTextLength(nsIDOMSVGAnimatedLength * *aTextLength)
|
||||
{
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "nsIDOMSVGTextContentElement.h"
|
||||
#include "nsSVGTextContainerFrame.h"
|
||||
#include "nsSVGStylableElement.h"
|
||||
#include "DOMSVGTests.h"
|
||||
|
||||
typedef nsSVGStylableElement nsSVGTextContentElementBase;
|
||||
|
||||
@ -51,9 +52,11 @@ typedef nsSVGStylableElement nsSVGTextContentElementBase;
|
||||
* upshot is that any changes to this class also need to be made in
|
||||
* nsSVGTextElement.
|
||||
*/
|
||||
class nsSVGTextContentElement : public nsSVGTextContentElementBase
|
||||
class nsSVGTextContentElement : public nsSVGTextContentElementBase,
|
||||
public DOMSVGTests
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIDOMSVGTEXTCONTENTELEMENT
|
||||
|
||||
protected:
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include "SVGAnimatedNumberList.h"
|
||||
#include "DOMSVGAnimatedNumberList.h"
|
||||
#include "DOMSVGPoint.h"
|
||||
#include "DOMSVGTests.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@ -71,7 +72,8 @@ typedef nsSVGGraphicElement nsSVGTextElementBase;
|
||||
* nsSVGTextPositioningElement in sync (and vice versa).
|
||||
*/
|
||||
class nsSVGTextElement : public nsSVGTextElementBase,
|
||||
public nsIDOMSVGTextElement // nsIDOMSVGTextPositioningElement
|
||||
public nsIDOMSVGTextElement, // nsIDOMSVGTextPositioningElement
|
||||
public DOMSVGTests
|
||||
{
|
||||
protected:
|
||||
friend nsresult NS_NewSVGTextElement(nsIContent **aResult,
|
||||
@ -130,10 +132,11 @@ NS_IMPL_RELEASE_INHERITED(nsSVGTextElement,nsSVGTextElementBase)
|
||||
DOMCI_NODE_DATA(SVGTextElement, nsSVGTextElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsSVGTextElement)
|
||||
NS_NODE_INTERFACE_TABLE6(nsSVGTextElement, nsIDOMNode, nsIDOMElement,
|
||||
NS_NODE_INTERFACE_TABLE7(nsSVGTextElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGTextElement,
|
||||
nsIDOMSVGTextPositioningElement,
|
||||
nsIDOMSVGTextContentElement)
|
||||
nsIDOMSVGTextContentElement,
|
||||
nsIDOMSVGTests)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGTextElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGTextElementBase)
|
||||
|
||||
|
@ -93,9 +93,10 @@ NS_IMPL_RELEASE_INHERITED(nsSVGTextPathElement,nsSVGTextPathElementBase)
|
||||
DOMCI_NODE_DATA(SVGTextPathElement, nsSVGTextPathElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsSVGTextPathElement)
|
||||
NS_NODE_INTERFACE_TABLE6(nsSVGTextPathElement, nsIDOMNode, nsIDOMElement,
|
||||
NS_NODE_INTERFACE_TABLE7(nsSVGTextPathElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGTextPathElement,
|
||||
nsIDOMSVGTextContentElement, nsIDOMSVGURIReference)
|
||||
nsIDOMSVGTextContentElement, nsIDOMSVGTests,
|
||||
nsIDOMSVGURIReference)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGTextPathElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGTextPathElementBase)
|
||||
|
||||
|
@ -92,8 +92,9 @@ NS_IMPL_RELEASE_INHERITED(nsSVGUseElement,nsSVGUseElementBase)
|
||||
DOMCI_NODE_DATA(SVGUseElement, nsSVGUseElement)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsSVGUseElement)
|
||||
NS_NODE_INTERFACE_TABLE6(nsSVGUseElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGURIReference,
|
||||
NS_NODE_INTERFACE_TABLE7(nsSVGUseElement, nsIDOMNode, nsIDOMElement,
|
||||
nsIDOMSVGElement, nsIDOMSVGTests,
|
||||
nsIDOMSVGURIReference,
|
||||
nsIDOMSVGUseElement, nsIMutationObserver)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGUseElement)
|
||||
if (aIID.Equals(NS_GET_IID(nsSVGUseElement)))
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "nsIDOMSVGAnimatedString.h"
|
||||
#include "nsIDOMSVGURIReference.h"
|
||||
#include "nsIDOMSVGUseElement.h"
|
||||
#include "DOMSVGTests.h"
|
||||
#include "nsStubMutationObserver.h"
|
||||
#include "nsSVGGraphicElement.h"
|
||||
#include "nsSVGLength2.h"
|
||||
@ -63,8 +64,9 @@ NS_NewSVGSVGElement(nsIContent **aResult,
|
||||
typedef nsSVGGraphicElement nsSVGUseElementBase;
|
||||
|
||||
class nsSVGUseElement : public nsSVGUseElementBase,
|
||||
public nsIDOMSVGURIReference,
|
||||
public nsIDOMSVGUseElement,
|
||||
public DOMSVGTests,
|
||||
public nsIDOMSVGURIReference,
|
||||
public nsStubMutationObserver
|
||||
{
|
||||
friend class nsSVGUseFrame;
|
||||
|
@ -276,54 +276,6 @@ var tests = [
|
||||
}
|
||||
}
|
||||
},
|
||||
/*
|
||||
{
|
||||
// SVGPathSegList test:
|
||||
target_element_id: 'path',
|
||||
attr_name: 'd',
|
||||
prop_name: null, // SVGAnimatedPathData is an inherited interface!
|
||||
bv_name: 'normalizedPathSegList',
|
||||
av_name: 'animatedNormalizedPathSegList',
|
||||
el_type: 'SVGPathElement',
|
||||
prop_type: null,
|
||||
list_type: 'SVGPathSegList',
|
||||
item_type: 'SVGPathSeg',
|
||||
attr_val_3a: '',
|
||||
attr_val_3b: '',
|
||||
attr_val_4 : '',
|
||||
attr_val_5a: '',
|
||||
attr_val_5b: '',
|
||||
item_constructor: function() {
|
||||
// XXX return different values each time
|
||||
return SVGPathElement.createSVGPathSegLinetoAbs(1, 1);
|
||||
},
|
||||
item_is: function(itemA, itemB, message) {
|
||||
ok(typeof(itemA.pathSegTypeAsLetter) != 'undefined' &&
|
||||
typeof(itemB.pathSegTypeAsLetter) != 'undefined',
|
||||
'expecting pathSegTypeAsLetter property');
|
||||
|
||||
// First: are we dealing with the same type of segment?
|
||||
is(itemA.pathSegTypeAsLetter, itemB.pathSegTypeAsLetter, message);
|
||||
if (itemA.pathSegTypeAsLetter != itemB.pathSegTypeAsLetter)
|
||||
return; // The rest of this function is nonsense if types don't match.
|
||||
|
||||
// Make sure property-counts match (so we can iterate across itemA's
|
||||
// properties and not worry about itemB having extra properties that
|
||||
// we might be skipping over).
|
||||
is(keys(itemA).length, keys(itemB).length,
|
||||
'expecting same property-count when comparing path segs of same type.');
|
||||
|
||||
// Compare the properties, skipping the constant properties inherited
|
||||
// from 'SVGPathSeg', and skipping the pathSegTypeAsLetter field since we
|
||||
// already checked that above.
|
||||
for (var prop in itemA) {
|
||||
if (!SVGPathSeg.hasOwnProperty(prop) &&
|
||||
prop != 'pathSegTypeAsLetter') {
|
||||
is(itemA[prop], itemB[prop], message);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
// SVGStringList test:
|
||||
target_element_id: 'g',
|
||||
@ -335,17 +287,22 @@ var tests = [
|
||||
prop_type: null,
|
||||
list_type: 'SVGStringList',
|
||||
item_type: 'DOMString',
|
||||
attr_val_3a: '',
|
||||
attr_val_3b: '',
|
||||
attr_val_4 : '',
|
||||
attr_val_5a: '',
|
||||
attr_val_5b: '',
|
||||
attr_val_3a: 'http://www.w3.org/TR/SVG11/feature#Shape http://www.w3.org/TR/SVG11/feature#Image ' +
|
||||
'http://www.w3.org/TR/SVG11/feature#Style',
|
||||
attr_val_3b: 'http://www.w3.org/TR/SVG11/feature#CoreAttribute http://www.w3.org/TR/SVG11/feature#Structure ' +
|
||||
'http://www.w3.org/TR/SVG11/feature#Gradient',
|
||||
attr_val_4 : 'http://www.w3.org/TR/SVG11/feature#Pattern http://www.w3.org/TR/SVG11/feature#Clip ' +
|
||||
'http://www.w3.org/TR/SVG11/feature#Mask http://www.w3.org/TR/SVG11/feature#Extensibility',
|
||||
attr_val_5a: 'http://www.w3.org/TR/SVG11/feature#BasicStructure http://www.w3.org/TR/SVG11/feature#BasicText ' +
|
||||
'http://www.w3.org/TR/SVG11/feature#BasicPaintAttribute http://www.w3.org/TR/SVG11/feature#BasicGraphicsAttribute ' +
|
||||
'http://www.w3.org/TR/SVG11/feature#BasicClip',
|
||||
attr_val_5b: 'http://www.w3.org/TR/SVG11/feature#DocumentEventsAttribute http://www.w3.org/TR/SVG11/feature#GraphicalEventsAttribute ' +
|
||||
'http://www.w3.org/TR/SVG11/feature#AnimationEventsAttribute http://www.w3.org/TR/SVG11/feature#Hyperlinking ' +
|
||||
'http://www.w3.org/TR/SVG11/feature#XlinkAttribute',
|
||||
item_constructor: function() {
|
||||
// XXX return a meaningful string
|
||||
return ;
|
||||
return 'http://www.w3.org/TR/SVG11/feature#XlinkAttribute';
|
||||
}
|
||||
},
|
||||
*/
|
||||
{
|
||||
// SVGTransformList test:
|
||||
target_element_id: 'g',
|
||||
@ -535,36 +492,39 @@ function run_baseVal_API_tests()
|
||||
|
||||
t.element.setAttribute(t.attr_name, t.attr_val_4);
|
||||
|
||||
var old_items = get_array_of_list_items(t.baseVal);
|
||||
item = t.baseVal.getItem(3);
|
||||
res = t.baseVal.initialize(item);
|
||||
if (t.item_type != "DOMString") {
|
||||
var old_items = get_array_of_list_items(t.baseVal);
|
||||
item = t.baseVal.getItem(3);
|
||||
res = t.baseVal.initialize(item);
|
||||
|
||||
ok(res !== item &&
|
||||
t.baseVal.getItem(0) !== item &&
|
||||
t.baseVal.getItem(0) !== old_items[0] &&
|
||||
res === t.baseVal.getItem(0),
|
||||
'The method '+t.list_type+'.initialize() should clone the object that '+
|
||||
'is passed in if that object is already in a list.');
|
||||
// [SVGWG issue] not what the spec currently says
|
||||
ok(res !== item &&
|
||||
t.baseVal.getItem(0) !== item &&
|
||||
t.baseVal.getItem(0) !== old_items[0] &&
|
||||
res === t.baseVal.getItem(0),
|
||||
'The method '+t.list_type+'.initialize() should clone the object that '+
|
||||
'is passed in if that object is already in a list.');
|
||||
// [SVGWG issue] not what the spec currently says
|
||||
|
||||
item = t.baseVal.getItem(0);
|
||||
res = t.baseVal.initialize(item);
|
||||
|
||||
ok(res !== item &&
|
||||
t.baseVal.getItem(0) !== item,
|
||||
'The method '+t.list_type+'.initialize() should clone the object that '+
|
||||
'is passed in, even if that object is the only item in that list.');
|
||||
// [SVGWG issue] not what the spec currently says
|
||||
item = t.baseVal.getItem(0);
|
||||
res = t.baseVal.initialize(item);
|
||||
|
||||
threw = false;
|
||||
try {
|
||||
t.baseVal.initialize({});
|
||||
} catch(e) {
|
||||
threw = true;
|
||||
ok(res !== item &&
|
||||
t.baseVal.getItem(0) !== item,
|
||||
'The method '+t.list_type+'.initialize() should clone the object that '+
|
||||
'is passed in, even if that object is the only item in that list.');
|
||||
// [SVGWG issue] not what the spec currently says
|
||||
|
||||
threw = false;
|
||||
try {
|
||||
t.baseVal.initialize({});
|
||||
} catch(e) {
|
||||
threw = true;
|
||||
}
|
||||
ok(threw,
|
||||
'The method '+t.list_type+'.initialize() should throw if passed an '+
|
||||
'object of the wrong type.');
|
||||
}
|
||||
ok(threw,
|
||||
'The method '+t.list_type+'.initialize() should throw if passed an '+
|
||||
'object of the wrong type.');
|
||||
|
||||
// Test .insertItemBefore():
|
||||
|
||||
@ -604,35 +564,39 @@ function run_baseVal_API_tests()
|
||||
|
||||
is(t.baseVal.numberOfItems, 7,
|
||||
'The '+t.list_type+' object should contain seven list items.');
|
||||
ok(res !== item &&
|
||||
t.baseVal.getItem(2) !== item &&
|
||||
t.baseVal.getItem(2) !== old_items[2] &&
|
||||
res === t.baseVal.getItem(2),
|
||||
'The method '+t.list_type+'.insertItemBefore() should clone the '+
|
||||
'object that is passed in if that object is already in a list.');
|
||||
// [SVGWG issue] not what the spec currently says
|
||||
if (t.item_type != "DOMString") {
|
||||
ok(res !== item &&
|
||||
t.baseVal.getItem(2) !== item &&
|
||||
t.baseVal.getItem(2) !== old_items[2] &&
|
||||
res === t.baseVal.getItem(2),
|
||||
'The method '+t.list_type+'.insertItemBefore() should clone the '+
|
||||
'object that is passed in if that object is already in a list.');
|
||||
// [SVGWG issue] not what the spec currently says
|
||||
}
|
||||
|
||||
item = t.baseVal.getItem(2);
|
||||
res = t.baseVal.insertItemBefore(item, 2);
|
||||
|
||||
is(t.baseVal.numberOfItems, 8,
|
||||
'The '+t.list_type+' object should contain eight list items.');
|
||||
ok(res !== item &&
|
||||
t.baseVal.getItem(2) !== item,
|
||||
'The method '+t.list_type+'.insertItemBefore() should clone the '+
|
||||
'object that is passed in, even if that object is the item in '+
|
||||
'the list at the index specified.');
|
||||
// [SVGWG issue] not what the spec currently says
|
||||
if (t.item_type != "DOMString") {
|
||||
ok(res !== item &&
|
||||
t.baseVal.getItem(2) !== item,
|
||||
'The method '+t.list_type+'.insertItemBefore() should clone the '+
|
||||
'object that is passed in, even if that object is the item in '+
|
||||
'the list at the index specified.');
|
||||
// [SVGWG issue] not what the spec currently says
|
||||
|
||||
threw = false;
|
||||
try {
|
||||
t.baseVal.insertItemBefore({}, 2);
|
||||
} catch(e) {
|
||||
threw = true;
|
||||
threw = false;
|
||||
try {
|
||||
t.baseVal.insertItemBefore({}, 2);
|
||||
} catch(e) {
|
||||
threw = true;
|
||||
}
|
||||
ok(threw,
|
||||
'The method '+t.list_type+'.insertItemBefore() should throw if passed '+
|
||||
'an object of the wrong type.');
|
||||
}
|
||||
ok(threw,
|
||||
'The method '+t.list_type+'.insertItemBefore() should throw if passed '+
|
||||
'an object of the wrong type.');
|
||||
|
||||
// Test .replaceItem():
|
||||
|
||||
@ -644,11 +608,13 @@ function run_baseVal_API_tests()
|
||||
|
||||
is(t.baseVal.numberOfItems, 4,
|
||||
'The '+t.list_type+' object should contain four list items.');
|
||||
ok(res === item,
|
||||
'The list item returned by '+t.list_type+'.replaceItem() should be '+
|
||||
'the exact same object as the item that was passed to that method, '+
|
||||
'since the item that was passed to that method did not already belong '+
|
||||
'to a list.');
|
||||
if (t.item_type != "DOMString") {
|
||||
ok(res === item,
|
||||
'The list item returned by '+t.list_type+'.replaceItem() should be '+
|
||||
'the exact same object as the item that was passed to that method, '+
|
||||
'since the item that was passed to that method did not already belong '+
|
||||
'to a list.');
|
||||
}
|
||||
ok(t.baseVal.getItem(2) === item,
|
||||
'The list item at index 2 should be the exact same object as the '+
|
||||
'object that was passed to the '+t.list_type+'.replaceItem() method, '+
|
||||
@ -677,35 +643,39 @@ function run_baseVal_API_tests()
|
||||
|
||||
is(t.baseVal.numberOfItems, 4,
|
||||
'The '+t.list_type+' object should contain four list items.');
|
||||
ok(res !== item &&
|
||||
t.baseVal.getItem(1) !== item &&
|
||||
t.baseVal.getItem(1) !== old_items[1] &&
|
||||
res === t.baseVal.getItem(1),
|
||||
'The method '+t.list_type+'.replaceItem() should clone the object '+
|
||||
'that is passed in if that object is already in a list.');
|
||||
// [SVGWG issue] not what the spec currently says
|
||||
if (t.item_type != "DOMString") {
|
||||
ok(res !== item &&
|
||||
t.baseVal.getItem(1) !== item &&
|
||||
t.baseVal.getItem(1) !== old_items[1] &&
|
||||
res === t.baseVal.getItem(1),
|
||||
'The method '+t.list_type+'.replaceItem() should clone the object '+
|
||||
'that is passed in if that object is already in a list.');
|
||||
// [SVGWG issue] not what the spec currently says
|
||||
}
|
||||
|
||||
item = t.baseVal.getItem(1);
|
||||
res = t.baseVal.replaceItem(item, 1);
|
||||
|
||||
is(t.baseVal.numberOfItems, 4,
|
||||
'The '+t.list_type+' object should contain four list items.');
|
||||
ok(res !== item &&
|
||||
t.baseVal.getItem(1) !== item,
|
||||
'The method '+t.list_type+'.replaceItem() should clone the object '+
|
||||
'that is passed in, even if the object that object and the object '+
|
||||
'that is being replaced are the exact same objects.');
|
||||
// [SVGWG issue] not what the spec currently says
|
||||
if (t.item_type != "DOMString") {
|
||||
ok(res !== item &&
|
||||
t.baseVal.getItem(1) !== item,
|
||||
'The method '+t.list_type+'.replaceItem() should clone the object '+
|
||||
'that is passed in, even if the object that object and the object '+
|
||||
'that is being replaced are the exact same objects.');
|
||||
// [SVGWG issue] not what the spec currently says
|
||||
|
||||
threw = false;
|
||||
try {
|
||||
t.baseVal.replaceItem({}, 2);
|
||||
} catch(e) {
|
||||
threw = true;
|
||||
threw = false;
|
||||
try {
|
||||
t.baseVal.replaceItem({}, 2);
|
||||
} catch(e) {
|
||||
threw = true;
|
||||
}
|
||||
ok(threw,
|
||||
'The method '+t.list_type+'.replaceItem() should throw if passed '+
|
||||
'an object of the wrong type.');
|
||||
}
|
||||
ok(threw,
|
||||
'The method '+t.list_type+'.replaceItem() should throw if passed '+
|
||||
'an object of the wrong type.');
|
||||
|
||||
// Test .removeItem():
|
||||
|
||||
@ -717,9 +687,11 @@ function run_baseVal_API_tests()
|
||||
|
||||
is(t.baseVal.numberOfItems, 3,
|
||||
'The '+t.list_type+' object should contain three list items.');
|
||||
ok(res === item,
|
||||
'The list item returned by '+t.list_type+'.removeItem() should be the '+
|
||||
'exact same object as the item that was at the specified index.');
|
||||
if (t.item_type != "DOMString") {
|
||||
ok(res === item,
|
||||
'The list item returned by '+t.list_type+'.removeItem() should be the '+
|
||||
'exact same object as the item that was at the specified index.');
|
||||
}
|
||||
ok(t.baseVal.getItem(1) === old_items[1],
|
||||
'The list item that was at index 1 should still be at index 1 after '+
|
||||
'the item at index 2 was removed using the '+t.list_type+
|
||||
@ -769,36 +741,38 @@ function run_baseVal_API_tests()
|
||||
|
||||
is(t.baseVal.numberOfItems, 6,
|
||||
'The '+t.list_type+' object should contain six list items.');
|
||||
ok(res !== item &&
|
||||
t.baseVal.getItem(5) !== item &&
|
||||
res === t.baseVal.getItem(5),
|
||||
'The method '+t.list_type+'.appendItem() should clone the object '+
|
||||
'that is passed in if that object is already in a list.');
|
||||
// [SVGWG issue] not what the spec currently says
|
||||
if (t.item_type != "DOMString") {
|
||||
ok(res !== item &&
|
||||
t.baseVal.getItem(5) !== item &&
|
||||
res === t.baseVal.getItem(5),
|
||||
'The method '+t.list_type+'.appendItem() should clone the object '+
|
||||
'that is passed in if that object is already in a list.');
|
||||
// [SVGWG issue] not what the spec currently says
|
||||
}
|
||||
|
||||
item = t.baseVal.getItem(5);
|
||||
res = t.baseVal.appendItem(item);
|
||||
|
||||
is(t.baseVal.numberOfItems, 7,
|
||||
'The '+t.list_type+' object should contain seven list items.');
|
||||
ok(res !== item &&
|
||||
t.baseVal.getItem(6) !== item,
|
||||
'The method '+t.list_type+'.appendItem() should clone the object '+
|
||||
'that is passed in, if that object is already the last item in '+
|
||||
'that list.');
|
||||
// [SVGWG issue] not what the spec currently says
|
||||
if (t.item_type != "DOMString") {
|
||||
ok(res !== item &&
|
||||
t.baseVal.getItem(6) !== item,
|
||||
'The method '+t.list_type+'.appendItem() should clone the object '+
|
||||
'that is passed in, if that object is already the last item in '+
|
||||
'that list.');
|
||||
// [SVGWG issue] not what the spec currently says
|
||||
|
||||
|
||||
|
||||
threw = false;
|
||||
try {
|
||||
t.baseVal.appendItem({});
|
||||
} catch(e) {
|
||||
threw = true;
|
||||
threw = false;
|
||||
try {
|
||||
t.baseVal.appendItem({});
|
||||
} catch(e) {
|
||||
threw = true;
|
||||
}
|
||||
ok(threw,
|
||||
'The method '+t.list_type+'.appendItem() should throw if passed '+
|
||||
'an object of the wrong type.');
|
||||
}
|
||||
ok(threw,
|
||||
'The method '+t.list_type+'.appendItem() should throw if passed '+
|
||||
'an object of the wrong type.');
|
||||
}
|
||||
}
|
||||
|
||||
@ -953,7 +927,9 @@ function run_basic_setAttribute_tests()
|
||||
// Test the effect of setting the attribute to new values:
|
||||
|
||||
t.old_baseVal_items = get_array_of_list_items(t.baseVal);
|
||||
t.old_animVal_items = get_array_of_list_items(t.animVal);
|
||||
if (t.animVal) {
|
||||
t.old_animVal_items = get_array_of_list_items(t.animVal);
|
||||
}
|
||||
|
||||
t.element.setAttribute(t.attr_name, t.attr_val_3a);
|
||||
t.element.setAttribute(t.attr_name, t.attr_val_5a);
|
||||
@ -969,17 +945,19 @@ function run_basic_setAttribute_tests()
|
||||
'(5).');
|
||||
}
|
||||
|
||||
ok(t.baseVal.getItem(2) === t.old_baseVal_items[2],
|
||||
'After its attribute changes, list items in the '+t.list_type+' for '+
|
||||
t.bv_path+' that are at indexes that existed prior to the attribute '+
|
||||
'change should be the exact same objects as the objects that were '+
|
||||
'at those indexes prior to the attribute change.');
|
||||
if (t.item_type != "DOMString") {
|
||||
ok(t.baseVal.getItem(2) === t.old_baseVal_items[2],
|
||||
'After its attribute changes, list items in the '+t.list_type+' for '+
|
||||
t.bv_path+' that are at indexes that existed prior to the attribute '+
|
||||
'change should be the exact same objects as the objects that were '+
|
||||
'at those indexes prior to the attribute change.');
|
||||
|
||||
ok(t.baseVal.getItem(3) !== t.old_baseVal_items[3],
|
||||
'After its attribute changes, list items in the '+t.list_type+' for '+
|
||||
t.bv_path+' that are at indexes that did not exist prior to the '+
|
||||
'attribute change should not be the same objects as any objects that '+
|
||||
'were at those indexes at some earlier time.');
|
||||
ok(t.baseVal.getItem(3) !== t.old_baseVal_items[3],
|
||||
'After its attribute changes, list items in the '+t.list_type+' for '+
|
||||
t.bv_path+' that are at indexes that did not exist prior to the '+
|
||||
'attribute change should not be the same objects as any objects that '+
|
||||
'were at those indexes at some earlier time.');
|
||||
}
|
||||
|
||||
if (t.animVal) {
|
||||
ok(t.animVal.getItem(2) === t.old_animVal_items[2],
|
||||
@ -1350,7 +1328,9 @@ function run_tests()
|
||||
};
|
||||
}
|
||||
|
||||
t.element.appendChild(create_animate_elements(t));
|
||||
if (t.animVal) {
|
||||
t.element.appendChild(create_animate_elements(t));
|
||||
}
|
||||
}
|
||||
|
||||
// Run the major test groups:
|
||||
|
@ -42,7 +42,7 @@ function doNavigationIfReady() {
|
||||
}
|
||||
|
||||
function doNavigation() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
|
||||
// Test clicking on an unmodified <a>.
|
||||
doNavigationTest(1, "a_href_helper_01.svg");
|
||||
|
@ -36,7 +36,7 @@ xmlDoc.addEventListener("load", documentLoaded, false);
|
||||
|
||||
function execute()
|
||||
{
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
xmlDoc.load("http://green/heikki/login/data.xml");
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,8 @@ protected:
|
||||
|
||||
const txExpandedName key()
|
||||
{
|
||||
NS_ASSERTION(mCurrentPos < mMap.mItems.Length(),
|
||||
NS_ASSERTION(mCurrentPos >= 0 &&
|
||||
mCurrentPos < mMap.mItems.Length(),
|
||||
"invalid position in txExpandedNameMap::iterator");
|
||||
return txExpandedName(mMap.mItems[mCurrentPos].mNamespaceID,
|
||||
mMap.mItems[mCurrentPos].mLocalName);
|
||||
@ -111,7 +112,8 @@ protected:
|
||||
protected:
|
||||
void* itemValue()
|
||||
{
|
||||
NS_ASSERTION(mCurrentPos < mMap.mItems.Length(),
|
||||
NS_ASSERTION(mCurrentPos >= 0 &&
|
||||
mCurrentPos < mMap.mItems.Length(),
|
||||
"invalid position in txExpandedNameMap::iterator");
|
||||
return mMap.mItems[mCurrentPos].mValue;
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user