Merge backout of bug 263359

This commit is contained in:
Ehsan Akhgari 2011-03-25 18:16:31 -04:00
commit 0c0464e633
341 changed files with 6845 additions and 4208 deletions

View File

@ -55,3 +55,5 @@ dba2abb7db57078c5a4810884834d3056a5d56c2 last-mozilla-central
138f593553b66c9f815e8f57870c19d6347f7702 UPDATE_PACKAGING_R12
138f593553b66c9f815e8f57870c19d6347f7702 UPDATE_PACKAGING_R13
138f593553b66c9f815e8f57870c19d6347f7702 UPDATE_PACKAGING_R11_1_MU
e56ecd8b3a68c158025207c5fd081d043e28f5ce GECKO_2_0_BASE
e273946b74c8d631ed86bd74ba9afe0e67b12378 GECKO_2_1_BASE

View File

@ -3297,7 +3297,7 @@ nsAccessible::GetAttrValue(nsIAtom *aProperty, double *aValue)
return NS_OK;
PRInt32 error = NS_OK;
double value = attrValue.ToFloat(&error);
double value = attrValue.ToDouble(&error);
if (NS_SUCCEEDED(error))
*aValue = value;

View File

@ -362,7 +362,7 @@ nsXFormsRangeAccessible::GetMaximumValue(double *aMaximumValue)
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 error = NS_OK;
*aMaximumValue = value.ToFloat(&error);
*aMaximumValue = value.ToDouble(&error);
return error;
}
@ -377,7 +377,7 @@ nsXFormsRangeAccessible::GetMinimumValue(double *aMinimumValue)
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 error = NS_OK;
*aMinimumValue = value.ToFloat(&error);
*aMinimumValue = value.ToDouble(&error);
return error;
}
@ -392,7 +392,7 @@ nsXFormsRangeAccessible::GetMinimumIncrement(double *aMinimumIncrement)
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 error = NS_OK;
*aMinimumIncrement = value.ToFloat(&error);
*aMinimumIncrement = value.ToDouble(&error);
return error;
}
@ -407,7 +407,7 @@ nsXFormsRangeAccessible::GetCurrentValue(double *aCurrentValue)
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 error = NS_OK;
*aCurrentValue = value.ToFloat(&error);
*aCurrentValue = value.ToDouble(&error);
return error;
}

View File

@ -569,7 +569,7 @@ nsXULProgressMeterAccessible::GetMaximumValue(double *aMaximumValue)
nsAutoString value;
if (mContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::max, value)) {
PRInt32 result = NS_OK;
*aMaximumValue = value.ToFloat(&result);
*aMaximumValue = value.ToDouble(&result);
return result;
}
@ -614,7 +614,7 @@ nsXULProgressMeterAccessible::GetCurrentValue(double *aCurrentValue)
return NS_OK;
PRInt32 error = NS_OK;
double value = attrValue.ToFloat(&error);
double value = attrValue.ToDouble(&error);
if (NS_FAILED(error))
return NS_OK; // Zero value because of wrong markup.

View File

@ -272,7 +272,7 @@ nsXULSliderAccessible::GetSliderAttr(nsIAtom *aName, double *aValue)
return NS_OK;
PRInt32 error = NS_OK;
double value = attrValue.ToFloat(&error);
double value = attrValue.ToDouble(&error);
if (NS_SUCCEEDED(error))
*aValue = value;

View File

@ -2,6 +2,7 @@
<head>
<title>Text attributes tests</title>
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
@ -190,43 +191,43 @@
testDefaultTextAttrs(ID, defAttrs);
attrs = {"language": "ru"};
testTextAttrs(ID, 0, attrs, defAttrs, 0, 12);
testTextAttrs(ID, 0, attrs, defAttrs, 0, 6);
attrs = {};
testTextAttrs(ID, 12, attrs, defAttrs, 12, 13);
testTextAttrs(ID, 6, attrs, defAttrs, 6, 7);
tempElem = getNode(ID).firstChild.nextSibling.nextSibling.nextSibling;
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
attrs = { "background-color": gComputedStyle.backgroundColor};
testTextAttrs(ID, 13, attrs, defAttrs, 13, 26);
testTextAttrs(ID, 13, attrs, defAttrs, 7, 20);
attrs = {};
testTextAttrs(ID, 26, attrs, defAttrs, 26, 27);
testTextAttrs(ID, 20, attrs, defAttrs, 20, 21);
attrs = {"language": "de"};
testTextAttrs(ID, 27, attrs, defAttrs, 27, 42);
testTextAttrs(ID, 21, attrs, defAttrs, 21, 36);
attrs = {};
testTextAttrs(ID, 42, attrs, defAttrs, 42, 50);
testTextAttrs(ID, 36, attrs, defAttrs, 36, 44);
attrs = {};
testTextAttrs(ID, 43, attrs, defAttrs, 42, 50);
testTextAttrs(ID, 37, attrs, defAttrs, 36, 44);
tempElem = tempElem.nextSibling.nextSibling.nextSibling.nextSibling.firstChild.nextSibling;
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
attrs = {"color": gComputedStyle.color};
testTextAttrs(ID, 50, attrs, defAttrs, 50, 57);
testTextAttrs(ID, 44, attrs, defAttrs, 44, 51);
tempElem = tempElem.firstChild.nextSibling;
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
attrs = {"font-weight": kBoldFontWeight,
"color": gComputedStyle.color};
testTextAttrs(ID, 57, attrs, defAttrs, 57, 61);
testTextAttrs(ID, 51, attrs, defAttrs, 51, 55);
tempElem = tempElem.parentNode;
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
attrs = {"color": gComputedStyle.color};
testTextAttrs(ID, 61, attrs, defAttrs, 61, 68);
testTextAttrs(ID, 55, attrs, defAttrs, 55, 62);
//////////////////////////////////////////////////////////////////////////
// area9, different single style spans in styled paragraph

View File

@ -2,6 +2,7 @@
<html>
<head>
<title>nsIAccessibleText getText related function tests for html:input,html:div and html:textarea</title>
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
@ -65,7 +66,7 @@
testWords("div12", ["4,261.01"], kTodo);
// "カタカナ"
testWords("div13", ["カタカナ"], kTodo);
testWords("div13", ["カタカナ"], kOk);
// "Peter's car"
testWords("div14", ["Peter's", "car"], kTodo);

View File

@ -37,6 +37,10 @@
new invokerChecker(EVENT_FOCUS, getAccessible, this.linkNode)
];
this.unexpectedEventSeq = [
new invokerChecker(EVENT_REORDER, this.linkNode.parentNode)
];
this.invoke = function focusAnchor_invoke()
{
this.linkNode.focus();
@ -44,8 +48,8 @@
this.check = function focusAnchor_check(aEvent)
{
isnot(this.link, aEvent.accessible,
"Focus should be fired against new link accessible!");
is(this.link, aEvent.accessible,
"The link accessible shouldn't be recreated!");
}
this.getID = function focusAnchor_getID()
@ -63,6 +67,10 @@
new invokerChecker(EVENT_FOCUS, getAccessible, this.linkNode)
];
this.unexpectedEventSeq = [
new invokerChecker(EVENT_REORDER, this.linkNode.parentNode)
];
this.invoke = function tabAnchor_invoke()
{
synthesizeKey("VK_TAB", { shiftKey: false });
@ -70,8 +78,8 @@
this.check = function tabAnchor_check(aEvent)
{
isnot(this.link, aEvent.accessible,
"Focus should be fired against new link accessible!");
is(this.link, aEvent.accessible,
"The link accessible shouldn't be recreated!");
}
this.getID = function tabAnchor_getID()
@ -119,6 +127,11 @@
href="https://bugzilla.mozilla.org/show_bug.cgi?id=570275">
Mozilla Bug 570275
</a><br>
<a target="_blank"
title="Don't recreate frames for inlines with overflow style applied"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=606087">
Mozilla Bug 606087
</a><br>
<p id="display"></p>
<div id="content" style="display: none"></div>

View File

@ -8510,8 +8510,17 @@ function safeModeRestart()
let promptTitle = gNavigatorBundle.getString("safeModeRestartPromptTitle");
let promptMessage =
gNavigatorBundle.getString("safeModeRestartPromptMessage");
let rv = Services.prompt.confirm(window, promptTitle, promptMessage);
if (rv) {
let restartText = gNavigatorBundle.getString("safeModeRestartButton");
let buttonFlags = (Services.prompt.BUTTON_POS_0 *
Services.prompt.BUTTON_TITLE_IS_STRING) +
(Services.prompt.BUTTON_POS_1 *
Services.prompt.BUTTON_TITLE_CANCEL) +
Services.prompt.BUTTON_POS_0_DEFAULT;
let rv = Services.prompt.confirmEx(window, promptTitle, promptMessage,
buttonFlags, restartText, null, null,
null, {});
if (rv == 0) {
let environment = Components.classes["@mozilla.org/process/environment;1"].
getService(Components.interfaces.nsIEnvironment);
environment.set("MOZ_SAFE_MODE_RESTART", "1");

View File

@ -1822,9 +1822,12 @@
<parameter name="aListener"/>
<body>
<![CDATA[
NS_ASSERT(arguments.length == 1,
"gBrowser.addProgressListener was called with a second argument, " +
"which is not supported. See bug 608628.");
if (arguments.length != 1) {
Components.utils.reportError("gBrowser.addProgressListener was " +
"called with a second argument, " +
"which is not supported. See bug " +
"608628.");
}
if (!this.mAddProgressListenerWasCalled) {
this.mAddProgressListenerWasCalled = true;

View File

@ -345,18 +345,6 @@ var gMainPane = {
var downloadFolder = document.getElementById("downloadFolder");
var currentDirPref = document.getElementById("browser.download.dir");
// The user's download folder is based on the preferences listed above.
// However, if the system does not support a download folder, the
// actual path returned will be the system's desktop or home folder.
// If this is the case, skip off displaying the Download label and
// display Desktop, even though folderList might be 1.
var fileLocator = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties);
var desk = fileLocator.get("Desk", Components.interfaces.nsILocalFile);
var dnldMgr = Components.classes["@mozilla.org/download-manager;1"]
.getService(Components.interfaces.nsIDownloadManager);
var supportDownloadLabel = !dnldMgr.defaultDownloadsDirectory.equals(desk);
// Used in defining the correct path to the folder icon.
var ios = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
@ -369,7 +357,7 @@ var gMainPane = {
// Custom path selected and is configured
downloadFolder.label = this._getDisplayNameOfFile(currentDirPref.value);
iconUrlSpec = fph.getURLSpecFromFile(currentDirPref.value);
} else if (folderListPref.value == 1 && supportDownloadLabel) {
} else if (folderListPref.value == 1) {
// 'Downloads'
// In 1.5, this pointed to a folder we created called 'My Downloads'
// and was available as an option in the 1.5 drop down. On XP this

View File

@ -152,6 +152,25 @@ function debug(aMsg) {
/* :::::::: The Service ::::::::::::::: */
function SessionStoreService() {
XPCOMUtils.defineLazyGetter(this, "_prefBranch", function () {
return Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefService).getBranch("browser.").
QueryInterface(Ci.nsIPrefBranch2);
});
// minimal interval between two save operations (in milliseconds)
XPCOMUtils.defineLazyGetter(this, "_interval", function () {
// used often, so caching/observing instead of fetching on-demand
this._prefBranch.addObserver("sessionstore.interval", this, true);
return this._prefBranch.getIntPref("sessionstore.interval");
});
// when crash recovery is disabled, session data is not written to disk
XPCOMUtils.defineLazyGetter(this, "_resume_from_crash", function () {
// get crash recovery state from prefs and allow for proper reaction to state changes
this._prefBranch.addObserver("sessionstore.resume_from_crash", this, true);
return this._prefBranch.getBoolPref("sessionstore.resume_from_crash");
});
}
SessionStoreService.prototype = {
@ -168,12 +187,6 @@ SessionStoreService.prototype = {
// set default load state
_loadState: STATE_STOPPED,
// minimal interval between two save operations (in milliseconds)
_interval: 15000,
// when crash recovery is disabled, session data is not written to disk
_resume_from_crash: true,
// During the initial restore and setBrowserState calls tracks the number of
// windows yet to be restored
_restoreCount: 0,
@ -248,9 +261,6 @@ SessionStoreService.prototype = {
* Initialize the component
*/
initService: function() {
this._prefBranch = Services.prefs.getBranch("browser.");
this._prefBranch.QueryInterface(Ci.nsIPrefBranch2);
OBSERVING.forEach(function(aTopic) {
Services.obs.addObserver(this, aTopic, true);
}, this);
@ -258,14 +268,6 @@ SessionStoreService.prototype = {
var pbs = Cc["@mozilla.org/privatebrowsing;1"].
getService(Ci.nsIPrivateBrowsingService);
this._inPrivateBrowsing = pbs.privateBrowsingEnabled;
// get interval from prefs - used often, so caching/observing instead of fetching on-demand
this._interval = this._prefBranch.getIntPref("sessionstore.interval");
this._prefBranch.addObserver("sessionstore.interval", this, true);
// get crash recovery state from prefs and allow for proper reaction to state changes
this._resume_from_crash = this._prefBranch.getBoolPref("sessionstore.resume_from_crash");
this._prefBranch.addObserver("sessionstore.resume_from_crash", this, true);
// observe prefs changes so we can modify stored data to match
this._prefBranch.addObserver("sessionstore.max_tabs_undo", this, true);

View File

@ -1,5 +1,5 @@
function test() {
var startup_info = Components.classes["@mozilla.org/toolkit/app-startup;1"].getService(Components.interfaces.nsIAppStartup_MOZILLA_2_0).getStartupInfo();
var startup_info = Components.classes["@mozilla.org/toolkit/app-startup;1"].getService(Components.interfaces.nsIAppStartup).getStartupInfo();
// No .process info on mac
ok(startup_info.process <= startup_info.main, "process created before main is run " + uneval(startup_info));

View File

@ -306,6 +306,7 @@ extensions.{972ce4c6-7e08-4474-a285-3208198ce6fd}.description=The default theme.
# safeModeRestart
safeModeRestartPromptTitle=Restart with Add-ons Disabled
safeModeRestartPromptMessage=Are you sure you want to disable all add-ons and restart?
safeModeRestartButton=Restart
# LOCALIZATION NOTE (browser.menu.showCharacterEncoding): Set to the string
# "true" (spelled and capitalized exactly that way) to show the "Character

View File

@ -179,10 +179,11 @@
}
#navigator-toolbox[tabsontop=false] > #PersonalToolbar {
margin-top: 2px;
border-top: 1px solid @toolbarShadowColor@;
margin-top: 3px;
}
#navigator-toolbox[tabsontop=false] > #PersonalToolbar:not(:-moz-lwtheme) {
margin-top: 2px;
border-top: 1px solid @toolbarShadowColor@;
background-image: -moz-linear-gradient(@toolbarHighlight@, rgba(255,255,255,0));
}
@ -327,6 +328,12 @@
-moz-image-region: rect(32px, 49px, 48px, 32px);
}
#minimize-button:-moz-locale-dir(rtl),
#restore-button:-moz-locale-dir(rtl),
#close-button:-moz-locale-dir(rtl) {
-moz-transform: scaleX(-1);
}
/* ::::: splitmenu highlight style that imitates Windows 7 start menu ::::: */
@media all and (-moz-windows-default-theme) {
.splitmenu-menuitem,

View File

@ -171,9 +171,11 @@ CONFIGURES += $(TOPSRCDIR)/js/src/configure
# The default rule is build
build::
$(MAKE) -f $(TOPSRCDIR)/client.mk $(if $(MOZ_PGO),profiledbuild,realbuild)
# Print out any options loaded from mozconfig.
all build clean depend distclean export libs install realclean::
all realbuild clean depend distclean export libs install realclean::
@if test -f .mozconfig.out; then \
cat .mozconfig.out; \
rm -f .mozconfig.out; \
@ -207,11 +209,11 @@ else
endif
profiledbuild::
$(MAKE) -f $(TOPSRCDIR)/client.mk build MOZ_PROFILE_GENERATE=1
$(MAKE) -f $(TOPSRCDIR)/client.mk realbuild MOZ_PROFILE_GENERATE=1
$(MAKE) -C $(PGO_OBJDIR) package
OBJDIR=${PGO_OBJDIR} $(PROFILE_GEN_SCRIPT)
$(MAKE) -f $(TOPSRCDIR)/client.mk maybe_clobber_profiledbuild
$(MAKE) -f $(TOPSRCDIR)/client.mk build MOZ_PROFILE_USE=1
$(MAKE) -f $(TOPSRCDIR)/client.mk realbuild MOZ_PROFILE_USE=1
#####################################################
# Build date unification
@ -228,7 +230,7 @@ endif
#####################################################
# Preflight, before building any project
build alldep preflight_all::
realbuild alldep preflight_all::
ifeq (,$(MOZ_CURRENT_PROJECT)$(if $(MOZ_PREFLIGHT_ALL),,1))
# Don't run preflight_all for individual projects in multi-project builds
# (when MOZ_CURRENT_PROJECT is set.)
@ -252,7 +254,7 @@ endif
# loop through them.
ifeq (,$(MOZ_CURRENT_PROJECT)$(if $(MOZ_BUILD_PROJECTS),,1))
configure depend build install export libs clean realclean distclean alldep preflight postflight maybe_clobber_profiledbuild upload sdk::
configure depend realbuild install export libs clean realclean distclean alldep preflight postflight maybe_clobber_profiledbuild upload sdk::
set -e; \
for app in $(MOZ_BUILD_PROJECTS); do \
$(MAKE) -f $(TOPSRCDIR)/client.mk $@ MOZ_CURRENT_PROJECT=$$app; \
@ -332,7 +334,7 @@ depend:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
####################################
# Preflight
build alldep preflight::
realbuild alldep preflight::
ifdef MOZ_PREFLIGHT
set -e; \
for mkfile in $(MOZ_PREFLIGHT); do \
@ -343,7 +345,7 @@ endif
####################################
# Build it
build:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
realbuild:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
$(MOZ_MAKE)
####################################
@ -356,7 +358,7 @@ install export libs clean realclean distclean alldep maybe_clobber_profiledbuild
####################################
# Postflight
build alldep postflight::
realbuild alldep postflight::
ifdef MOZ_POSTFLIGHT
set -e; \
for mkfile in $(MOZ_POSTFLIGHT); do \
@ -369,7 +371,7 @@ endif # MOZ_CURRENT_PROJECT
####################################
# Postflight, after building all projects
build alldep postflight_all::
realbuild alldep postflight_all::
ifeq (,$(MOZ_CURRENT_PROJECT)$(if $(MOZ_POSTFLIGHT_ALL),,1))
# Don't run postflight_all for individual projects in multi-project builds
# (when MOZ_CURRENT_PROJECT is set.)
@ -409,4 +411,4 @@ echo-variable-%:
# in parallel.
.NOTPARALLEL:
.PHONY: checkout real_checkout depend build profiledbuild maybe_clobber_profiledbuild export libs alldep install clean realclean distclean cleansrcdir pull_all build_all clobber clobber_all pull_and_build_all everything configure preflight_all preflight postflight postflight_all upload sdk
.PHONY: checkout real_checkout depend realbuild build profiledbuild maybe_clobber_profiledbuild export libs alldep install clean realclean distclean cleansrcdir pull_all build_all clobber clobber_all pull_and_build_all everything configure preflight_all preflight postflight postflight_all upload sdk

View File

@ -121,7 +121,6 @@ USE_ELF_HACK = @USE_ELF_HACK@
INCREMENTAL_LINKER = @INCREMENTAL_LINKER@
MACOSX_DEPLOYMENT_TARGET = @MACOSX_DEPLOYMENT_TARGET@
MOZ_MAIL_NEWS = @MOZ_MAIL_NEWS@
MOZ_PLAINTEXT_EDITOR_ONLY = @MOZ_PLAINTEXT_EDITOR_ONLY@
BUILD_STATIC_LIBS = @BUILD_STATIC_LIBS@
MOZ_ENABLE_LIBXUL = @MOZ_ENABLE_LIBXUL@
ENABLE_TESTS = @ENABLE_TESTS@

View File

@ -63,6 +63,29 @@ from __future__ import with_statement
import sys, os
import expandlibs_config as conf
def relativize(path):
'''Returns a path relative to the current working directory, if it is
shorter than the given path'''
def splitpath(path):
dir, file = os.path.split(path)
if os.path.splitdrive(dir)[1] == os.sep:
return [file]
return splitpath(dir) + [file]
if not os.path.exists(path):
return path
curdir = splitpath(os.path.abspath(os.curdir))
abspath = splitpath(os.path.abspath(path))
while curdir and abspath and curdir[0] == abspath[0]:
del curdir[0]
del abspath[0]
if not curdir and not abspath:
return '.'
relpath = os.path.join(*[os.pardir for i in curdir] + abspath)
if len(path) > len(relpath):
return relpath
return path
class LibDescriptor(dict):
KEYS = ['OBJS', 'LIBS']
@ -99,15 +122,15 @@ class ExpandArgs(list):
'''Internal function doing the actual work'''
(root, ext) = os.path.splitext(arg)
if ext != conf.LIB_SUFFIX or not os.path.basename(root).startswith(conf.LIB_PREFIX):
return [arg]
return [relativize(arg)]
if len(conf.IMPORT_LIB_SUFFIX):
dll = root + conf.IMPORT_LIB_SUFFIX
else:
dll = root.replace(conf.LIB_PREFIX, conf.DLL_PREFIX, 1) + conf.DLL_SUFFIX
if os.path.exists(dll):
return [dll]
return [relativize(dll)]
if os.path.exists(arg):
return [arg]
return [relativize(arg)]
return self._expand_desc(arg)
def _expand_desc(self, arg):
@ -115,7 +138,7 @@ class ExpandArgs(list):
if os.path.exists(arg + conf.LIBS_DESC_SUFFIX):
with open(arg + conf.LIBS_DESC_SUFFIX, 'r') as f:
desc = LibDescriptor(f.readlines())
objs = desc['OBJS']
objs = [relativize(o) for o in desc['OBJS']]
for lib in desc['LIBS']:
objs += self._expand(lib)
return objs

View File

@ -52,7 +52,7 @@ See https://bugzilla.mozilla.org/show_bug.cgi?id=584474#c59 for more details.
from __future__ import with_statement
import sys
import os
from expandlibs import ExpandArgs
from expandlibs import ExpandArgs, relativize
import expandlibs_config as conf
from optparse import OptionParser
import subprocess
@ -93,7 +93,7 @@ class ExpandArgsMore(ExpandArgs):
subprocess.call(ar_extract + [os.path.abspath(arg)], cwd=tmp)
objs = []
for root, dirs, files in os.walk(tmp):
objs += [os.path.join(root, f) for f in files if os.path.splitext(f)[1] == conf.OBJ_SUFFIX]
objs += [relativize(os.path.join(root, f)) for f in files if os.path.splitext(f)[1] == conf.OBJ_SUFFIX]
newlist += objs
else:
newlist += [arg]

View File

@ -7,6 +7,7 @@ import imp
from tempfile import mkdtemp
from shutil import rmtree
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from mozunit import MozTestRunner
from UserString import UserString
# Create a controlled configuration for use by expandlibs
@ -35,7 +36,7 @@ config_unix = {
config = sys.modules['expandlibs_config'] = imp.new_module('expandlibs_config')
from expandlibs import LibDescriptor, ExpandArgs
from expandlibs import LibDescriptor, ExpandArgs, relativize
from expandlibs_gen import generate
from expandlibs_exec import ExpandArgsMore
@ -52,6 +53,21 @@ def ImportLib(name):
if not len(config.IMPORT_LIB_SUFFIX): return Dll(name)
return config.LIB_PREFIX + name + config.IMPORT_LIB_SUFFIX
class TestRelativize(unittest.TestCase):
def test_relativize(self):
'''Test relativize()'''
os_path_exists = os.path.exists
def exists(path):
return True
os.path.exists = exists
self.assertEqual(relativize(os.path.abspath(os.curdir)), os.curdir)
self.assertEqual(relativize(os.path.abspath(os.pardir)), os.pardir)
self.assertEqual(relativize(os.path.join(os.curdir, 'a')), 'a')
self.assertEqual(relativize(os.path.join(os.path.abspath(os.curdir), 'a')), 'a')
# relativize is expected to return the absolute path if it is shorter
self.assertEqual(relativize(os.sep), os.sep)
os.path.exists = os.path.exists
class TestLibDescriptor(unittest.TestCase):
def test_serialize(self):
'''Test LibDescriptor's serialization'''
@ -83,8 +99,12 @@ def wrap_method(conf, wrapped_method):
for key in conf:
setattr(config, key, conf[key])
self.init()
wrapped_method(self)
self.cleanup()
try:
wrapped_method(self)
except:
raise
finally:
self.cleanup()
return _method
class ReplicateTests(type):
@ -101,7 +121,7 @@ class ReplicateTests(type):
class TestCaseWithTmpDir(unittest.TestCase):
__metaclass__ = ReplicateTests
def init(self):
self.tmpdir = mkdtemp()
self.tmpdir = os.path.abspath(mkdtemp(dir=os.curdir))
def cleanup(self):
rmtree(self.tmpdir)
@ -149,6 +169,9 @@ class TestExpandInit(TestCaseWithTmpDir):
self.arg_files += [self.tmpfile(Lib('f'))]
self.touch(self.files)
def assertRelEqual(self, args1, args2):
self.assertEqual(args1, [relativize(a) for a in args2])
class TestExpandArgs(TestExpandInit):
def test_expand(self):
'''Test library expansion'''
@ -156,44 +179,45 @@ class TestExpandArgs(TestExpandInit):
# with the descriptor content, and import libraries are used when
# a library doesn't exist
args = ExpandArgs(['foo', '-bar'] + self.arg_files + [self.tmpfile('liby', Lib('y'))])
self.assertEqual(args, ['foo', '-bar'] + self.files + self.liby_files + self.libx_files)
self.assertRelEqual(args, ['foo', '-bar'] + self.files + self.liby_files + self.libx_files)
# When a library exists at the same time as a descriptor, we just use
# the library
self.touch([self.tmpfile('libx', Lib('x'))])
args = ExpandArgs(['foo', '-bar'] + self.arg_files + [self.tmpfile('liby', Lib('y'))])
self.assertEqual(args, ['foo', '-bar'] + self.files + self.liby_files + [self.tmpfile('libx', Lib('x'))])
self.assertRelEqual(args, ['foo', '-bar'] + self.files + self.liby_files + [self.tmpfile('libx', Lib('x'))])
self.touch([self.tmpfile('liby', Lib('y'))])
args = ExpandArgs(['foo', '-bar'] + self.arg_files + [self.tmpfile('liby', Lib('y'))])
self.assertEqual(args, ['foo', '-bar'] + self.files + [self.tmpfile('liby', Lib('y'))])
self.assertRelEqual(args, ['foo', '-bar'] + self.files + [self.tmpfile('liby', Lib('y'))])
class TestExpandArgsMore(TestExpandInit):
def test_makelist(self):
'''Test grouping object files in lists'''
# ExpandArgsMore does the same as ExpandArgs
with ExpandArgsMore(['foo', '-bar'] + self.arg_files + [self.tmpfile('liby', Lib('y'))]) as args:
self.assertEqual(args, ['foo', '-bar'] + self.files + self.liby_files + self.libx_files)
self.assertRelEqual(args, ['foo', '-bar'] + self.files + self.liby_files + self.libx_files)
# But also has an extra method replacing object files with a list
args.makelist()
# self.files has objects at #1, #2, #4
self.assertEqual(args[:3], ['foo', '-bar'] + self.files[:1])
self.assertEqual(args[4:], [self.files[3]] + self.files[5:] + [self.tmpfile('liby', Lib('z'))])
self.assertRelEqual(args[:3], ['foo', '-bar'] + self.files[:1])
self.assertRelEqual(args[4:], [self.files[3]] + self.files[5:] + [self.tmpfile('liby', Lib('z'))])
# Check the list file content
objs = [f for f in self.files + self.liby_files + self.libx_files if f.endswith(config.OBJ_SUFFIX)]
if config.EXPAND_LIBS_LIST_STYLE == "linkerscript":
self.assertNotEqual(args[3][0], '@')
filename = args[3]
content = ["INPUT(%s)" % f for f in objs]
content = ["INPUT(%s)" % relativize(f) for f in objs]
with open(filename, 'r') as f:
self.assertEqual([l.strip() for l in f.readlines() if len(l.strip())], content)
elif config.EXPAND_LIBS_LIST_STYLE == "list":
self.assertEqual(args[3][0], '@')
filename = args[3][1:]
content = objs
with open(filename, 'r') as f:
self.assertEqual([l.strip() for l in f.readlines() if len(l.strip())], content)
with open(filename, 'r') as f:
self.assertRelEqual([l.strip() for l in f.readlines() if len(l.strip())], content)
tmp = args.tmp
# Check that all temporary files are properly removed
@ -207,9 +231,9 @@ class TestExpandArgsMore(TestExpandInit):
def call(args, **kargs):
# The command called is always AR_EXTRACT
ar_extract = config.AR_EXTRACT.split()
self.assertEqual(args[:len(ar_extract)], ar_extract)
self.assertRelEqual(args[:len(ar_extract)], ar_extract)
# Remaining argument is always one library
self.assertEqual([os.path.splitext(arg)[1] for arg in args[len(ar_extract):]], [config.LIB_SUFFIX])
self.assertRelEqual([os.path.splitext(arg)[1] for arg in args[len(ar_extract):]], [config.LIB_SUFFIX])
# Simulate AR_EXTRACT extracting one object file for the library
lib = os.path.splitext(os.path.basename(args[len(ar_extract)]))[0]
extracted[lib] = os.path.join(kargs['cwd'], "%s" % Obj(lib))
@ -219,7 +243,7 @@ class TestExpandArgsMore(TestExpandInit):
# ExpandArgsMore does the same as ExpandArgs
self.touch([self.tmpfile('liby', Lib('y'))])
with ExpandArgsMore(['foo', '-bar'] + self.arg_files + [self.tmpfile('liby', Lib('y'))]) as args:
self.assertEqual(args, ['foo', '-bar'] + self.files + [self.tmpfile('liby', Lib('y'))])
self.assertRelEqual(args, ['foo', '-bar'] + self.files + [self.tmpfile('liby', Lib('y'))])
# ExpandArgsMore also has an extra method extracting static libraries
# when possible
@ -230,11 +254,11 @@ class TestExpandArgsMore(TestExpandInit):
# If we don't have an AR_EXTRACT, extract() expands libraries with a
# descriptor when the corresponding library exists (which ExpandArgs
# alone doesn't)
self.assertEqual(args, ['foo', '-bar'] + files)
self.assertRelEqual(args, ['foo', '-bar'] + files)
else:
# With AR_EXTRACT, it uses the descriptors when there are, and actually
# extracts the remaining libraries
self.assertEqual(args, ['foo', '-bar'] + [extracted[os.path.splitext(os.path.basename(f))[0]] if f.endswith(config.LIB_SUFFIX) else f for f in files])
self.assertRelEqual(args, ['foo', '-bar'] + [extracted[os.path.splitext(os.path.basename(f))[0]] if f.endswith(config.LIB_SUFFIX) else f for f in files])
tmp = args.tmp
# Check that all temporary files are properly removed
@ -244,4 +268,4 @@ class TestExpandArgsMore(TestExpandInit):
subprocess.call = subprocess_call
if __name__ == '__main__':
unittest.main()
unittest.main(testRunner=MozTestRunner())

View File

@ -4982,7 +4982,6 @@ VPX_ARM_ASM=
MOZ_PANGO=1
MOZ_PERMISSIONS=1
MOZ_PLACES=1
MOZ_PLAINTEXT_EDITOR_ONLY=
MOZ_PLUGINS=1
MOZ_PREF_EXTENSIONS=1
MOZ_PROFILELOCKING=1
@ -5921,19 +5920,6 @@ if test "$OS_ARCH" != "WINCE" -a "$OS_ARCH" != "WINNT" -a "$MOZ_USE_NATIVE_UCONV
fi
dnl ========================================================
dnl Libeditor can be build as plaintext-only,
dnl or as a full html and text editing component.
dnl We build both by default.
dnl ========================================================
MOZ_ARG_ENABLE_BOOL(plaintext-editor-only,
[ --enable-plaintext-editor-only
Allow only plaintext editing],
MOZ_PLAINTEXT_EDITOR_ONLY=1,
MOZ_PLAINTEXT_EDITOR_ONLY= )
dnl Note the #define is MOZILLA, not MOZ, for compat with the Mac build.
AC_SUBST(MOZ_PLAINTEXT_EDITOR_ONLY)
dnl ========================================================
dnl = Disable Fast Load
dnl ========================================================

View File

@ -76,8 +76,8 @@ enum nsLinkState {
// IID for the nsIContent interface
#define NS_ICONTENT_IID \
{ 0x557a7d96, 0xb9cd, 0x4be2, \
{ 0xa3, 0xe7, 0x5f, 0x43, 0x6d, 0xfd, 0xd9, 0x4f } }
{ 0x8331ca9f, 0x8717, 0x4ab4, \
{ 0xad, 0x17, 0xb4, 0x9d, 0xdc, 0xe8, 0xb6, 0x77 } }
/**
* A node of content in a document's content model. This interface

View File

@ -41,7 +41,7 @@ interface nsIDOMEventListener;
interface nsIDOMBlob;
interface nsIDOMFileError;
[scriptable, uuid(71c32f16-ea5d-415e-9303-0db981c17bed)]
[scriptable, uuid(f186170f-f07c-4f0b-9e3c-08f7dd496e74)]
interface nsIDOMFileReader : nsISupports
{
void readAsBinaryString(in nsIDOMBlob filedata);
@ -57,9 +57,6 @@ interface nsIDOMFileReader : nsISupports
readonly attribute DOMString result;
readonly attribute nsIDOMFileError error;
// event handler attributes
attribute nsIDOMEventListener onloadend;
};
%{ C++

View File

@ -1517,6 +1517,8 @@ public:
// state is unlocked/false.
virtual nsresult SetImageLockingState(PRBool aLocked) = 0;
virtual nsresult GetMozCurrentStateObject(nsIVariant** aResult) = 0;
protected:
~nsIDocument()
{

View File

@ -141,7 +141,7 @@ interface nsIContentViewManager : nsISupports
readonly attribute nsIContentView rootContentView;
};
[scriptable, uuid(50a67436-bb44-11df-8d9a-001e37d2764a)]
[scriptable, uuid(13c512d6-fba0-402a-9244-fe7941c43965)]
interface nsIFrameLoader : nsISupports
{
/**
@ -217,16 +217,23 @@ interface nsIFrameLoader : nsISupports
attribute boolean delayRemoteDialogs;
/**
* The default rendering mode is synchronous scrolling. In this
* mode, it's an error to try to set a target viewport.
*/
const unsigned long RENDER_MODE_DEFAULT = 0x00000000;
/**
* DEPRECATED. Please QI to nsIContentViewManager.
* FIXME 615368
* When asynchronous scrolling is enabled, a target viewport can be
* set to transform content pixels wrt its CSS viewport.
*
* NB: when async scrolling is enabled, it's the *user's*
* responsibility to update the target scroll offset. In effect,
* the platform hands over control of scroll offset to the user.
*/
void scrollViewportTo(in float xPx, in float yPx);
void scrollViewportBy(in float dxPx, in float dyPx);
void setViewportScale(in float xScale, in float yScale);
readonly attribute float viewportScrollX;
readonly attribute float viewportScrollY;
const unsigned long RENDER_MODE_ASYNC_SCROLL = 0x00000001;
attribute unsigned long renderMode;
};
native alreadyAddRefed_nsFrameLoader(already_AddRefed<nsFrameLoader>);
@ -252,25 +259,3 @@ interface nsIFrameLoaderOwner : nsISupports
*/
void swapFrameLoaders(in nsIFrameLoaderOwner aOtherOwner);
};
/** Please merge me into something else after 2.0 branches. */
[scriptable, uuid(e3e2d3f8-1397-4984-abb3-435c29a1ca55)]
interface nsIFrameLoader_MOZILLA_2_0_BRANCH : nsISupports
{
/**
* The default rendering mode is synchronous scrolling. In this
* mode, it's an error to try to set a target viewport.
*/
const unsigned long RENDER_MODE_DEFAULT = 0x00000000;
/**
* When asynchronous scrolling is enabled, a target viewport can be
* set to transform content pixels wrt its CSS viewport.
*
* NB: when async scrolling is enabled, it's the *user's*
* responsibility to update the target scroll offset. In effect,
* the platform hands over control of scroll offset to the user.
*/
const unsigned long RENDER_MODE_ASYNC_SCROLL = 0x00000001;
attribute unsigned long renderMode;
};

View File

@ -52,7 +52,7 @@ interface nsIInputStream;
#include "jsapi.h"
%}
[scriptable, uuid(6ce0a193-b033-4c3d-b748-f851b09261f5)]
[scriptable, uuid(dea238a1-240f-45f4-9f07-7769bc69eb76)]
interface nsIXMLHttpRequestEventTarget : nsIDOMEventTarget {
// event handler attributes
attribute nsIDOMEventListener onabort;
@ -60,6 +60,7 @@ interface nsIXMLHttpRequestEventTarget : nsIDOMEventTarget {
attribute nsIDOMEventListener onload;
attribute nsIDOMEventListener onloadstart;
attribute nsIDOMEventListener onprogress;
attribute nsIDOMEventListener onloadend;
};
[scriptable, uuid(09ff3682-7759-4441-a765-f70e1a1fabcf)]

View File

@ -262,9 +262,9 @@ nsAttrValue::SetTo(const nsAttrValue& aOther)
break;
}
#endif
case eFloatValue:
case eDoubleValue:
{
cont->mFloatValue = otherCont->mFloatValue;
cont->mDoubleValue = otherCont->mDoubleValue;
break;
}
case eIntMarginValue:
@ -443,10 +443,10 @@ nsAttrValue::ToString(nsAString& aResult) const
break;
}
#endif
case eFloatValue:
case eDoubleValue:
{
aResult.Truncate();
aResult.AppendFloat(GetFloatValue());
aResult.AppendFloat(GetDoubleValue());
break;
}
default:
@ -607,10 +607,10 @@ nsAttrValue::HashValue() const
return NS_PTR_TO_INT32(cont->mSVGValue);
}
#endif
case eFloatValue:
case eDoubleValue:
{
// XXX this is crappy, but oh well
return cont->mFloatValue;
return cont->mDoubleValue;
}
case eIntMarginValue:
{
@ -706,9 +706,9 @@ nsAttrValue::Equals(const nsAttrValue& aOther) const
return thisCont->mSVGValue == otherCont->mSVGValue;
}
#endif
case eFloatValue:
case eDoubleValue:
{
return thisCont->mFloatValue == otherCont->mFloatValue;
return thisCont->mDoubleValue == otherCont->mDoubleValue;
}
case eIntMarginValue:
{
@ -1206,19 +1206,19 @@ nsAttrValue::ParseColor(const nsAString& aString)
return PR_FALSE;
}
PRBool nsAttrValue::ParseFloatValue(const nsAString& aString)
PRBool nsAttrValue::ParseDoubleValue(const nsAString& aString)
{
ResetIfSet();
PRInt32 ec;
float val = PromiseFlatString(aString).ToFloat(&ec);
double val = PromiseFlatString(aString).ToDouble(&ec);
if (NS_FAILED(ec)) {
return PR_FALSE;
}
if (EnsureEmptyMiscContainer()) {
MiscContainer* cont = GetMiscContainer();
cont->mFloatValue = val;
cont->mType = eFloatValue;
cont->mDoubleValue = val;
cont->mType = eDoubleValue;
nsAutoString serializedFloat;
serializedFloat.AppendFloat(val);
SetMiscAtomOrString(serializedFloat.Equals(aString) ? nsnull : &aString);

View File

@ -130,7 +130,7 @@ public:
#ifdef MOZ_SVG
,eSVGValue = 0x12
#endif
,eFloatValue = 0x13
,eDoubleValue = 0x13
,eIntMarginValue = 0x14
};
@ -165,7 +165,7 @@ public:
#ifdef MOZ_SVG
inline nsISVGValue* GetSVGValue() const;
#endif
inline float GetFloatValue() const;
inline double GetDoubleValue() const;
PRBool GetIntMarginValue(nsIntMargin& aMargin) const;
/**
@ -297,12 +297,12 @@ public:
PRBool ParseColor(const nsAString& aString);
/**
* Parse a string value into a float.
* Parse a string value into a double-precision floating point value.
*
* @param aString the string to parse
* @return whether the value could be parsed
*/
PRBool ParseFloatValue(const nsAString& aString);
PRBool ParseDoubleValue(const nsAString& aString);
/**
* Parse a lazy URI. This just sets up the storage for the URI; it
@ -346,7 +346,7 @@ private:
#ifdef MOZ_SVG
nsISVGValue* mSVGValue;
#endif
float mFloatValue;
double mDoubleValue;
nsIntMargin* mIntMargin;
};
};
@ -458,11 +458,11 @@ nsAttrValue::GetSVGValue() const
}
#endif
inline float
nsAttrValue::GetFloatValue() const
inline double
nsAttrValue::GetDoubleValue() const
{
NS_PRECONDITION(Type() == eFloatValue, "wrong type");
return GetMiscContainer()->mFloatValue;
NS_PRECONDITION(Type() == eDoubleValue, "wrong type");
return GetMiscContainer()->mDoubleValue;
}
inline PRBool

View File

@ -442,11 +442,9 @@ DragDataProducer::Produce(nsDOMDataTransfer* aDataTransfer,
nsIContent* findFormParent = findFormNode->GetParent();
while (findFormParent) {
nsCOMPtr<nsIFormControl> form(do_QueryInterface(findFormParent));
if (form && form->GetType() != NS_FORM_OBJECT &&
form->GetType() != NS_FORM_FIELDSET &&
form->GetType() != NS_FORM_LABEL &&
form->GetType() != NS_FORM_OUTPUT)
if (form && !form->AllowDraggableChildren()) {
return NS_OK;
}
findFormParent = findFormParent->GetParent();
}

View File

@ -535,24 +535,6 @@ nsContentSink::ProcessHeaderData(nsIAtom* aHeader, const nsAString& aValue,
}
}
}
// Don't report "refresh" headers back to necko, since our document handles
// them
else if (aHeader != nsGkAtoms::refresh && mParser) {
// we also need to report back HTTP-EQUIV headers to the channel
// so that it can process things like pragma: no-cache or other
// cache-control headers. Ideally this should also be the way for
// cookies to be set! But we'll worry about that in the next
// iteration
nsCOMPtr<nsIChannel> channel;
if (NS_SUCCEEDED(mParser->GetChannel(getter_AddRefs(channel)))) {
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel));
if (httpChannel) {
httpChannel->SetResponseHeader(nsAtomCString(aHeader),
NS_ConvertUTF16toUTF8(aValue),
PR_TRUE);
}
}
}
return rv;
}

View File

@ -6393,9 +6393,9 @@ LayerManagerForDocumentInternal(nsIDocument *aDoc, bool aRequirePersistent,
nsIWidget* widget = displayRoot->GetNearestWidget(nsnull);
if (widget) {
nsRefPtr<LayerManager> manager =
static_cast<nsIWidget_MOZILLA_2_0_BRANCH*>(widget)->
GetLayerManager(aRequirePersistent ? nsIWidget_MOZILLA_2_0_BRANCH::LAYER_MANAGER_PERSISTENT :
nsIWidget_MOZILLA_2_0_BRANCH::LAYER_MANAGER_CURRENT,
widget->
GetLayerManager(aRequirePersistent ? nsIWidget::LAYER_MANAGER_PERSISTENT :
nsIWidget::LAYER_MANAGER_CURRENT,
aAllowRetaining);
return manager.forget();
}

View File

@ -94,7 +94,6 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMFileReader)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsDOMFileReader,
nsXHREventTarget)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnLoadEndListener)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mFile)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mProgressNotifier)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mPrincipal)
@ -103,7 +102,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMFileReader,
nsXHREventTarget)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnLoadEndListener)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mFile)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mProgressNotifier)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mPrincipal)
@ -126,19 +124,6 @@ NS_INTERFACE_MAP_END_INHERITING(nsXHREventTarget)
NS_IMPL_ADDREF_INHERITED(nsDOMFileReader, nsXHREventTarget)
NS_IMPL_RELEASE_INHERITED(nsDOMFileReader, nsXHREventTarget)
NS_IMETHODIMP
nsDOMFileReader::GetOnloadend(nsIDOMEventListener** aOnloadend)
{
return GetInnerEventListener(mOnLoadEndListener, aOnloadend);
}
NS_IMETHODIMP
nsDOMFileReader::SetOnloadend(nsIDOMEventListener* aOnloadend)
{
return RemoveAddEventListener(NS_LITERAL_STRING(LOADEND_STR),
mOnLoadEndListener, aOnloadend);
}
//nsICharsetDetectionObserver
NS_IMETHODIMP

View File

@ -152,8 +152,6 @@ protected:
PRUint64 mReadTotal;
PRUint64 mReadTransferred;
nsRefPtr<nsDOMEventListenerWrapper> mOnLoadEndListener;
};
#endif

View File

@ -1735,7 +1735,6 @@ NS_INTERFACE_TABLE_HEAD(nsDocument)
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIRadioGroupContainer_MOZILLA_2_0_BRANCH)
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIMutationObserver)
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIApplicationCacheContainer)
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMNSDocument_MOZILLA_2_0_BRANCH)
NS_OFFSET_AND_INTERFACE_TABLE_END
NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsDocument)
@ -8188,7 +8187,7 @@ nsIDocument::ScheduleBeforePaintEvent(nsIAnimationFrameListener* aListener)
}
NS_IMETHODIMP
nsresult
nsDocument::GetMozCurrentStateObject(nsIVariant** aState)
{
// Get the document's current state object. This is the object returned form

View File

@ -517,8 +517,7 @@ class nsDocument : public nsIDocument,
public nsIScriptObjectPrincipal,
public nsIRadioGroupContainer_MOZILLA_2_0_BRANCH,
public nsIApplicationCacheContainer,
public nsStubMutationObserver,
public nsIDOMNSDocument_MOZILLA_2_0_BRANCH
public nsStubMutationObserver
{
public:
typedef mozilla::dom::Element Element;
@ -814,7 +813,6 @@ public:
// nsIDOMNSDocument
NS_DECL_NSIDOMNSDOCUMENT
NS_DECL_NSIDOMNSDOCUMENT_MOZILLA_2_0_BRANCH
// nsIDOMDocumentEvent
NS_DECL_NSIDOMDOCUMENTEVENT
@ -993,6 +991,8 @@ public:
virtual NS_HIDDEN_(nsresult) RemoveImage(imgIRequest* aImage);
virtual NS_HIDDEN_(nsresult) SetImageLockingState(PRBool aLocked);
virtual nsresult GetMozCurrentStateObject(nsIVariant** aResult);
protected:
friend class nsNodeUtils;

View File

@ -1471,7 +1471,7 @@ nsHTMLCopyEncoder::IncludeInContext(nsINode *aNode)
tag == nsGkAtoms::dfn ||
tag == nsGkAtoms::code ||
tag == nsGkAtoms::cite ||
tag == nsGkAtoms::variable ||
tag == nsGkAtoms::var ||
tag == nsGkAtoms::abbr ||
tag == nsGkAtoms::font ||
tag == nsGkAtoms::script ||

View File

@ -310,7 +310,6 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE_AMBIGUOUS(nsFrameLoader, nsIFrameLoader)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsFrameLoader)
NS_INTERFACE_MAP_ENTRY(nsIFrameLoader)
NS_INTERFACE_MAP_ENTRY(nsIFrameLoader_MOZILLA_2_0_BRANCH)
NS_INTERFACE_MAP_ENTRY(nsIContentViewManager)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIFrameLoader)
NS_INTERFACE_MAP_END
@ -1684,36 +1683,6 @@ nsFrameLoader::UpdateBaseWindowPositionAndSize(nsIFrame *aIFrame)
return NS_OK;
}
NS_IMETHODIMP
nsFrameLoader::ScrollViewportTo(float aXpx, float aYpx)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsFrameLoader::ScrollViewportBy(float aDXpx, float aDYpx)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsFrameLoader::SetViewportScale(float aXScale, float aYScale)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsFrameLoader::GetViewportScrollX(float* aViewportScrollX)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsFrameLoader::GetViewportScrollY(float* aViewportScrollY)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsFrameLoader::GetRenderMode(PRUint32* aRenderMode)
{

View File

@ -164,7 +164,6 @@ private:
class nsFrameLoader : public nsIFrameLoader,
public nsIFrameLoader_MOZILLA_2_0_BRANCH,
public nsIContentViewManager
{
friend class AutoResetInShow;
@ -196,7 +195,6 @@ public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsFrameLoader, nsIFrameLoader)
NS_DECL_NSIFRAMELOADER
NS_DECL_NSIFRAMELOADER_MOZILLA_2_0_BRANCH
NS_DECL_NSICONTENTVIEWMANAGER
NS_HIDDEN_(nsresult) CheckForRecursiveLoad(nsIURI* aURI);
nsresult ReallyStartLoading();

View File

@ -627,10 +627,9 @@ nsFrameScriptExecutor::LoadFrameScriptInternal(const nsAString& aURL)
JSObject* global = nsnull;
mGlobal->GetJSObject(&global);
if (global) {
jsval val;
JS_ExecuteScript(mCx, global,
(JSScript*)JS_GetPrivate(mCx, holder->mObject),
&val);
nsnull);
}
}
JSContext* unused;
@ -682,12 +681,18 @@ nsFrameScriptExecutor::LoadFrameScriptInternal(const nsAString& aURL)
JSPrincipals* jsprin = nsnull;
mPrincipal->GetJSPrincipals(mCx, &jsprin);
nsContentUtils::XPConnect()->FlagSystemFilenamePrefix(url.get(), PR_TRUE);
uint32 oldopts = JS_GetOptions(mCx);
JS_SetOptions(mCx, oldopts | JSOPTION_NO_SCRIPT_RVAL);
JSScript* script =
JS_CompileUCScriptForPrincipals(mCx, nsnull, jsprin,
(jschar*)dataString.get(),
dataString.Length(),
url.get(), 1);
JS_SetOptions(mCx, oldopts);
if (script) {
JSObject* scriptObj = JS_NewScriptObject(mCx, script);
JS_AddObjectRoot(mCx, &scriptObj);
@ -702,9 +707,8 @@ nsFrameScriptExecutor::LoadFrameScriptInternal(const nsAString& aURL)
"Cached message manager script");
sCachedScripts->Put(aURL, holder);
}
jsval val;
JS_ExecuteScript(mCx, global,
(JSScript*)JS_GetPrivate(mCx, scriptObj), &val);
(JSScript*)JS_GetPrivate(mCx, scriptObj), nsnull);
JS_RemoveObjectRoot(mCx, &scriptObj);
}
//XXX Argh, JSPrincipals are manually refcounted!

View File

@ -71,7 +71,7 @@
#include "nsIDocShell.h"
#include "nsIEditorDocShell.h"
#include "nsIEditor.h"
#include "nsIHTMLEditor_MOZILLA_2_0_BRANCH.h"
#include "nsIHTMLEditor.h"
static const PRInt32 kLongLineLen = 128;
@ -105,7 +105,7 @@ IsInvisibleBreak(nsIContent *aNode, nsIAtom *aTag) {
if (editorDocShell) {
nsCOMPtr<nsIEditor> editor;
editorDocShell->GetEditor(getter_AddRefs(editor));
nsCOMPtr<nsIHTMLEditor_MOZILLA_2_0_BRANCH> htmlEditor = do_QueryInterface(editor);
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(editor);
if (htmlEditor) {
PRBool isVisible = PR_FALSE;
nsCOMPtr<nsIDOMNode> domNode = do_QueryInterface(aNode);

View File

@ -109,6 +109,7 @@
#define PROGRESS_STR "progress"
#define UPLOADPROGRESS_STR "uploadprogress"
#define READYSTATE_STR "readystatechange"
#define LOADEND_STR "loadend"
// CIDs
@ -518,6 +519,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsXHREventTarget,
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnAbortListener)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnLoadStartListener)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnProgressListener)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnLoadendListener)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsXHREventTarget,
@ -527,6 +529,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsXHREventTarget,
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnAbortListener)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnLoadStartListener)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnProgressListener)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnLoadendListener)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsXHREventTarget)
@ -601,6 +604,19 @@ nsXHREventTarget::SetOnprogress(nsIDOMEventListener* aOnprogress)
mOnProgressListener, aOnprogress);
}
NS_IMETHODIMP
nsXHREventTarget::GetOnloadend(nsIDOMEventListener** aOnLoadend)
{
return GetInnerEventListener(mOnLoadendListener, aOnLoadend);
}
NS_IMETHODIMP
nsXHREventTarget::SetOnloadend(nsIDOMEventListener* aOnLoadend)
{
return RemoveAddEventListener(NS_LITERAL_STRING(LOADEND_STR),
mOnLoadendListener, aOnLoadend);
}
/////////////////////////////////////////////
nsXMLHttpRequestUpload::~nsXMLHttpRequestUpload()
@ -1561,6 +1577,10 @@ nsXMLHttpRequest::DispatchProgressEvent(nsPIDOMEventTarget* aTarget,
return;
}
PRBool dispatchLoadend = aType.EqualsLiteral(LOAD_STR) ||
aType.EqualsLiteral(ERROR_STR) ||
aType.EqualsLiteral(ABORT_STR);
nsCOMPtr<nsIDOMEvent> event;
nsresult rv = nsEventDispatcher::CreateEvent(nsnull, nsnull,
NS_LITERAL_STRING("ProgressEvent"),
@ -1592,8 +1612,14 @@ nsXMLHttpRequest::DispatchProgressEvent(nsPIDOMEventTarget* aTarget,
event = xhrprogressEvent;
}
aTarget->DispatchDOMEvent(nsnull, event, nsnull, nsnull);
if (dispatchLoadend) {
DispatchProgressEvent(aTarget, NS_LITERAL_STRING(LOADEND_STR),
aUseLSEventWrapper, aLengthComputable,
aLoaded, aTotal, aPosition, aTotalSize);
}
}
already_AddRefed<nsIHttpChannel>
nsXMLHttpRequest::GetCurrentHttpChannel()
{

View File

@ -157,6 +157,7 @@ protected:
nsRefPtr<nsDOMEventListenerWrapper> mOnAbortListener;
nsRefPtr<nsDOMEventListenerWrapper> mOnLoadStartListener;
nsRefPtr<nsDOMEventListenerWrapper> mOnProgressListener;
nsRefPtr<nsDOMEventListenerWrapper> mOnLoadendListener;
};
class nsXMLHttpRequestUpload : public nsXHREventTarget,

View File

@ -249,6 +249,8 @@ _TEST_FILES1 = test_bug5141.html \
test_bug454325.html \
file_bug391728_2.html \
test_bug456262.html \
test_bug482935.html \
bug482935.sjs \
test_bug590870.html \
file_bug590870.html \
test_bug590812.html \

View File

@ -0,0 +1,12 @@
function handleRequest(request, response) {
var body = "initial";
try {
body = request.getHeader("X-Request");
} catch(e) {
body = "request.getHeader() failed! Exception: " + e;
}
response.setHeader("Cache-Control", "max-age=3600");
response.bodyOutputStream.write(body, body.length);
}

View File

@ -72,17 +72,20 @@ function start(obj) {
if (expectedResponseText) {
is(evt.target.responseText, expectedResponseText, "Wrong responseText");
}
stop(evt);
logEvent(evt);
}
xhr.onerror =
function(evt) {
stop(evt);
logEvent(evt);
}
xhr.onabort =
function(evt) {
logEvent(evt);
}
xhr.onloadend =
function (evt) {
stop(evt);
}
xhr.onloadstart =
function (evt) {
logEvent(evt);
@ -117,6 +120,10 @@ function start(obj) {
function (evt) {
logEvent(evt);
}
xhr.upload.onloadend =
function (evt) {
logEvent(evt);
}
}
try {
@ -170,72 +177,92 @@ var tests =
{ method: "GET", withUpload: none, testAbort: false, testRedirectError: false, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: XHR, type: "progress", optional: true},
{target: XHR, type: "load", optional: false}]},
{target: XHR, type: "load", optional: false},
{target: XHR, type: "loadend", optional: false}]},
{ method: "GET", withUpload: none, testAbort: true, testRedirectError: false, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: XHR, type: "abort", optional: false}]},
{target: XHR, type: "abort", optional: false},
{target: XHR, type: "loadend", optional: false}]},
{ method: "GET", withUpload: none, testAbort: false, testRedirectError: true, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: XHR, type: "error", optional: false}]},
{target: XHR, type: "error", optional: false},
{target: XHR, type: "loadend", optional: false}]},
{ method: "GET", withUpload: none, testAbort: false, testRedirectError: false, testNetworkError: true,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: XHR, type: "error", optional: false}]},
{target: XHR, type: "error", optional: false},
{target: XHR, type: "loadend", optional: false}]},
{ method: "GET", withUpload: small, testAbort: false, testRedirectError: false, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: XHR, type: "progress", optional: true},
{target: XHR, type: "load", optional: false}]},
{target: XHR, type: "load", optional: false},
{target: XHR, type: "loadend", optional: false}]},
{ method: "GET", withUpload: small, testAbort: true, testRedirectError: false, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: XHR, type: "abort", optional: false}]},
{target: XHR, type: "abort", optional: false},
{target: XHR, type: "loadend", optional: false}]},
{ method: "GET", withUpload: small, testAbort: false, testRedirectError: true, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: XHR, type: "error", optional: false}]},
{target: XHR, type: "error", optional: false},
{target: XHR, type: "loadend", optional: false}]},
{ method: "GET", withUpload: small, testAbort: false, testRedirectError: false, testNetworkError: true,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: XHR, type: "error", optional: false}]},
{target: XHR, type: "error", optional: false},
{target: XHR, type: "loadend", optional: false}]},
{ method: "GET", withUpload: mid, testAbort: false, testRedirectError: false, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: XHR, type: "progress", optional: true},
{target: XHR, type: "load", optional: false}]},
{target: XHR, type: "load", optional: false},
{target: XHR, type: "loadend", optional: false}]},
{ method: "GET", withUpload: mid, testAbort: true, testRedirectError: false, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: XHR, type: "abort", optional: false}]},
{target: XHR, type: "abort", optional: false},
{target: XHR, type: "loadend", optional: false}]},
{ method: "GET", withUpload: mid, testAbort: false, testRedirectError: true, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: XHR, type: "error", optional: false}]},
{target: XHR, type: "error", optional: false},
{target: XHR, type: "loadend", optional: false}]},
{ method: "GET", withUpload: mid, testAbort: false, testRedirectError: false, testNetworkError: true,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: XHR, type: "error", optional: false}]},
{target: XHR, type: "error", optional: false},
{target: XHR, type: "loadend", optional: false}]},
{ method: "GET", withUpload: large, testAbort: false, testRedirectError: false, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: XHR, type: "progress", optional: true},
{target: XHR, type: "load", optional: false}]},
{target: XHR, type: "load", optional: false},
{target: XHR, type: "loadend", optional: false}]},
{ method: "GET", withUpload: large, testAbort: true, testRedirectError: false, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: XHR, type: "abort", optional: false}]},
{target: XHR, type: "abort", optional: false},
{target: XHR, type: "loadend", optional: false}]},
{ method: "GET", withUpload: large, testAbort: false, testRedirectError: true, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: XHR, type: "error", optional: false}]},
{target: XHR, type: "error", optional: false},
{target: XHR, type: "loadend", optional: false}]},
{ method: "GET", withUpload: large, testAbort: false, testRedirectError: false, testNetworkError: true,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: XHR, type: "error", optional: false}]},
{target: XHR, type: "error", optional: false},
{target: XHR, type: "loadend", optional: false}]},
{ method: "POST", withUpload: none, testAbort: false, testRedirectError: false, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: XHR, type: "progress", optional: true},
{target: XHR, type: "load", optional: false}]},
{target: XHR, type: "load", optional: false},
{target: XHR, type: "loadend", optional: false}]},
{ method: "POST", withUpload: none, testAbort: true, testRedirectError: false, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: XHR, type: "abort", optional: false}]},
{target: XHR, type: "abort", optional: false},
{target: XHR, type: "loadend", optional: false}]},
{ method: "POST", withUpload: none, testAbort: false, testRedirectError: true, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: XHR, type: "error", optional: false}]},
{target: XHR, type: "error", optional: false},
{target: XHR, type: "loadend", optional: false}]},
{ method: "POST", withUpload: none, testAbort: false, testRedirectError: false, testNetworkError: true,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: XHR, type: "error", optional: false}]},
{target: XHR, type: "error", optional: false},
{target: XHR, type: "loadend", optional: false}]},
{ method: "POST", withUpload: small, testAbort: false, testRedirectError: false, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
@ -243,27 +270,35 @@ var tests =
{target: XHR, type: "uploadprogress", optional: true},
{target: UPLOAD, type: "progress", optional: true},
{target: UPLOAD, type: "load", optional: false},
{target: UPLOAD, type: "loadend", optional: false},
{target: XHR, type: "progress", optional: true},
{target: XHR, type: "load", optional: false}]},
{target: XHR, type: "load", optional: false},
{target: XHR, type: "loadend", optional: false}]},
{ method: "POST", withUpload: small, testAbort: true, testRedirectError: false, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: UPLOAD, type: "loadstart", optional: false},
{target: XHR, type: "abort", optional: false},
{target: UPLOAD, type: "abort", optional: false}]},
{target: XHR, type: "loadend", optional: false},
{target: UPLOAD, type: "abort", optional: false},
{target: UPLOAD, type: "loadend", optional: false}]},
{ method: "POST", withUpload: small, testAbort: false, testRedirectError: true, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: UPLOAD, type: "loadstart", optional: false},
{target: XHR, type: "uploadprogress", optional: true},
{target: UPLOAD, type: "progress", optional: true},
{target: XHR, type: "error", optional: false},
{target: UPLOAD, type: "error", optional: false}]},
{target: XHR, type: "loadend", optional: false},
{target: UPLOAD, type: "error", optional: false},
{target: UPLOAD, type: "loadend", optional: false}]},
{ method: "POST", withUpload: small, testAbort: false, testRedirectError: false, testNetworkError: true,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: UPLOAD, type: "loadstart", optional: false},
{target: XHR, type: "uploadprogress", optional: true},
{target: UPLOAD, type: "progress", optional: true},
{target: XHR, type: "error", optional: false},
{target: UPLOAD, type: "error", optional: false}]},
{target: XHR, type: "loadend", optional: false},
{target: UPLOAD, type: "error", optional: false},
{target: UPLOAD, type: "loadend", optional: false}]},
{ method: "POST", withUpload: mid, testAbort: false, testRedirectError: false, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
@ -271,27 +306,35 @@ var tests =
{target: XHR, type: "uploadprogress", optional: true},
{target: UPLOAD, type: "progress", optional: true},
{target: UPLOAD, type: "load", optional: false},
{target: UPLOAD, type: "loadend", optional: false},
{target: XHR, type: "progress", optional: true},
{target: XHR, type: "load", optional: false}]},
{target: XHR, type: "load", optional: false},
{target: XHR, type: "loadend", optional: false}]},
{ method: "POST", withUpload: mid, testAbort: true, testRedirectError: false, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: UPLOAD, type: "loadstart", optional: false},
{target: XHR, type: "abort", optional: false},
{target: UPLOAD, type: "abort", optional: false}]},
{target: XHR, type: "loadend", optional: false},
{target: UPLOAD, type: "abort", optional: false},
{target: UPLOAD, type: "loadend", optional: false}]},
{ method: "POST", withUpload: mid, testAbort: false, testRedirectError: true, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: UPLOAD, type: "loadstart", optional: false},
{target: XHR, type: "uploadprogress", optional: true},
{target: UPLOAD, type: "progress", optional: true},
{target: XHR, type: "error", optional: false},
{target: UPLOAD, type: "error", optional: false}]},
{target: XHR, type: "loadend", optional: false},
{target: UPLOAD, type: "error", optional: false},
{target: UPLOAD, type: "loadend", optional: false}]},
{ method: "POST", withUpload: mid, testAbort: false, testRedirectError: false, testNetworkError: true,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: UPLOAD, type: "loadstart", optional: false},
{target: XHR, type: "uploadprogress", optional: true},
{target: UPLOAD, type: "progress", optional: true},
{target: XHR, type: "error", optional: false},
{target: UPLOAD, type: "error", optional: false}]},
{target: XHR, type: "loadend", optional: false},
{target: UPLOAD, type: "error", optional: false},
{target: UPLOAD, type: "loadend", optional: false}]},
{ method: "POST", withUpload: large, testAbort: false, testRedirectError: false, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
@ -299,27 +342,35 @@ var tests =
{target: XHR, type: "uploadprogress", optional: true},
{target: UPLOAD, type: "progress", optional: true},
{target: UPLOAD, type: "load", optional: false},
{target: UPLOAD, type: "loadend", optional: false},
{target: XHR, type: "progress", optional: true},
{target: XHR, type: "load", optional: false}]},
{target: XHR, type: "load", optional: false},
{target: XHR, type: "loadend", optional: false}]},
{ method: "POST", withUpload: large, testAbort: true, testRedirectError: false, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: UPLOAD, type: "loadstart", optional: false},
{target: XHR, type: "abort", optional: false},
{target: UPLOAD, type: "abort", optional: false}]},
{target: XHR, type: "loadend", optional: false},
{target: UPLOAD, type: "abort", optional: false},
{target: UPLOAD, type: "loadend", optional: false}]},
{ method: "POST", withUpload: large, testAbort: false, testRedirectError: true, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: UPLOAD, type: "loadstart", optional: false},
{target: XHR, type: "uploadprogress", optional: true},
{target: UPLOAD, type: "progress", optional: true},
{target: XHR, type: "error", optional: false},
{target: UPLOAD, type: "error", optional: false}]},
{target: XHR, type: "loadend", optional: false},
{target: UPLOAD, type: "error", optional: false},
{target: UPLOAD, type: "loadend", optional: false}]},
{ method: "POST", withUpload: large, testAbort: false, testRedirectError: false, testNetworkError: true,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: UPLOAD, type: "loadstart", optional: false},
{target: XHR, type: "uploadprogress", optional: true},
{target: UPLOAD, type: "progress", optional: true},
{target: XHR, type: "error", optional: false},
{target: UPLOAD, type: "error", optional: false}]},
{target: XHR, type: "loadend", optional: false},
{target: UPLOAD, type: "error", optional: false},
{target: UPLOAD, type: "loadend", optional: false}]},
];
function runTest() {

View File

@ -0,0 +1,109 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test bug 482935</title>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href=" /tests/SimpleTest/test.css" />
</head>
<body onload="onWindowLoad()">
<script class="testbody" type="text/javascript">
var url = "bug482935.sjs";
function clearCache() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
Components.classes["@mozilla.org/network/cache-service;1"].
getService(Components.interfaces.nsICacheService).
evictEntries(Components.interfaces.nsICache.STORE_ANYWHERE);
netscape.security.PrivilegeManager.disablePrivilege("UniversalXPConnect");
}
// Tests that the response is cached if the request is cancelled
// after it has reached state 4
function testCancelInPhase4() {
clearCache();
// First request - should be loaded from server
var xhr = new XMLHttpRequest();
xhr.addEventListener("readystatechange", function(e) {
if (xhr.readyState >= 4) {
xhr.abort();
setTimeout(function() {
// This request was cancelled, so the responseText should be empty string
is(xhr.responseText, "", "Expected empty response to cancelled request");
// Second request - should be found in cache
var xhr2 = new XMLHttpRequest();
xhr2.open("GET", url, false); // note : synch-request
xhr2.setRequestHeader("X-Request", "1", false);
try { xhr2.send(); }
catch(e) {
is(xhr2.status, "200", "Exception!");
}
is(xhr2.responseText, "0", "Received fresh value for second request");
testCancelBeforePhase4();
}, 100);
}
}, false);
xhr.open("GET", url, true);
xhr.setRequestHeader("X-Request", "0", false);
try { xhr.send(); }
catch(e) {
is("Nothing", "Exception", "Boom: " + e);
}
}
// Tests that response is NOT cached if the request is cancelled
// before it has reached state 4
function testCancelBeforePhase4() {
clearCache();
// First request - should be loaded from server
var xhr = new XMLHttpRequest();
xhr.addEventListener("readystatechange", function(e) {
if (xhr.readyState == 3) {
xhr.abort();
setTimeout(function() {
// This request was cancelled, so the responseText should be empty string
is(xhr.responseText, "", "Expected empty response to cancelled request");
// Second request - should be found in cache
var xhr2 = new XMLHttpRequest();
xhr2.open("GET", url, false); // note : synch-request
xhr2.setRequestHeader("X-Request", "1", false);
try { xhr2.send(); }
catch(e) {
is(xhr2.status, "200", "Exception!");
}
is(xhr2.responseText, "1", "Received cached value for second request");
SimpleTest.finish();
}, 100);
}
}, false);
xhr.open("GET", url, true);
xhr.setRequestHeader("X-Request", "0", false);
try { xhr.send(); }
catch(e) {
is("Nothing", "Exception", "Boom: " + e);
}
}
function onWindowLoad() {
testCancelInPhase4();
}
SimpleTest.waitForExplicitFinish();
</script>
</body>
</html>

View File

@ -0,0 +1,196 @@
/* -*- 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 Corporation code.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Robert O'Callahan <robert@ocallahan.org>
*
* 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 "CanvasImageCache.h"
#include "nsIImageLoadingContent.h"
#include "nsExpirationTracker.h"
#include "imgIRequest.h"
#include "gfxASurface.h"
#include "gfxPoint.h"
#include "nsIDOMElement.h"
#include "nsTHashtable.h"
#include "nsHTMLCanvasElement.h"
namespace mozilla {
struct ImageCacheKey {
ImageCacheKey(nsIDOMElement* aImage, nsHTMLCanvasElement* aCanvas)
: mImage(aImage), mCanvas(aCanvas) {}
nsIDOMElement* mImage;
nsHTMLCanvasElement* mCanvas;
};
struct ImageCacheEntryData {
ImageCacheEntryData(const ImageCacheEntryData& aOther)
: mImage(aOther.mImage)
, mILC(aOther.mILC)
, mCanvas(aOther.mCanvas)
, mRequest(aOther.mRequest)
, mSurface(aOther.mSurface)
, mSize(aOther.mSize)
{}
ImageCacheEntryData(const ImageCacheKey& aKey)
: mImage(aKey.mImage)
, mILC(nsnull)
, mCanvas(aKey.mCanvas)
{}
nsExpirationState* GetExpirationState() { return &mState; }
// Key
nsCOMPtr<nsIDOMElement> mImage;
nsIImageLoadingContent* mILC;
nsRefPtr<nsHTMLCanvasElement> mCanvas;
// Value
nsCOMPtr<imgIRequest> mRequest;
nsRefPtr<gfxASurface> mSurface;
gfxIntSize mSize;
nsExpirationState mState;
};
class ImageCacheEntry : public PLDHashEntryHdr {
public:
typedef ImageCacheKey KeyType;
typedef const ImageCacheKey* KeyTypePointer;
ImageCacheEntry(const KeyType *key) :
mData(new ImageCacheEntryData(*key)) {}
ImageCacheEntry(const ImageCacheEntry &toCopy) :
mData(new ImageCacheEntryData(*toCopy.mData)) {}
~ImageCacheEntry() {}
PRBool KeyEquals(KeyTypePointer key) const
{
return mData->mImage == key->mImage && mData->mCanvas == key->mCanvas;
}
static KeyTypePointer KeyToPointer(KeyType& key) { return &key; }
static PLDHashNumber HashKey(KeyTypePointer key)
{
return (NS_PTR_TO_INT32(key->mImage) ^ NS_PTR_TO_INT32(key->mCanvas)) >> 2;
}
enum { ALLOW_MEMMOVE = PR_TRUE };
nsAutoPtr<ImageCacheEntryData> mData;
};
class ImageCache : public nsExpirationTracker<ImageCacheEntryData,4> {
public:
// We use 3 generations of 1 second each to get a 2-3 seconds timeout.
enum { GENERATION_MS = 1000 };
ImageCache()
: nsExpirationTracker<ImageCacheEntryData,4>(GENERATION_MS)
{
mCache.Init();
}
~ImageCache() {
AgeAllGenerations();
}
virtual void NotifyExpired(ImageCacheEntryData* aObject)
{
RemoveObject(aObject);
// Deleting the entry will delete aObject since the entry owns aObject
mCache.RemoveEntry(ImageCacheKey(aObject->mImage, aObject->mCanvas));
}
nsTHashtable<ImageCacheEntry> mCache;
};
static ImageCache* gImageCache = nsnull;
void
CanvasImageCache::NotifyDrawImage(nsIDOMElement* aImage,
nsHTMLCanvasElement* aCanvas,
imgIRequest* aRequest,
gfxASurface* aSurface,
const gfxIntSize& aSize)
{
if (!gImageCache) {
gImageCache = new ImageCache();
}
ImageCacheEntry* entry = gImageCache->mCache.PutEntry(ImageCacheKey(aImage, aCanvas));
if (entry) {
if (entry->mData->mSurface) {
// We are overwriting an existing entry.
gImageCache->RemoveObject(entry->mData);
}
gImageCache->AddObject(entry->mData);
nsCOMPtr<nsIImageLoadingContent> ilc = do_QueryInterface(aImage);
if (ilc) {
ilc->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
getter_AddRefs(entry->mData->mRequest));
}
entry->mData->mILC = ilc;
entry->mData->mSurface = aSurface;
entry->mData->mSize = aSize;
}
}
gfxASurface*
CanvasImageCache::Lookup(nsIDOMElement* aImage,
nsHTMLCanvasElement* aCanvas,
gfxIntSize* aSize)
{
if (!gImageCache)
return nsnull;
ImageCacheEntry* entry = gImageCache->mCache.GetEntry(ImageCacheKey(aImage, aCanvas));
if (!entry || !entry->mData->mILC)
return nsnull;
nsCOMPtr<imgIRequest> request;
entry->mData->mILC->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST, getter_AddRefs(request));
if (request != entry->mData->mRequest)
return nsnull;
gImageCache->MarkUsed(entry->mData);
*aSize = entry->mData->mSize;
return entry->mData->mSurface;
}
void
CanvasImageCache::Shutdown()
{
delete gImageCache;
gImageCache = nsnull;
}
}

View File

@ -0,0 +1,77 @@
/* -*- 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 Corporation code.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Robert O'Callahan <robert@ocallahan.org>
*
* 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 CANVASIMAGECACHE_H_
#define CANVASIMAGECACHE_H_
class nsIDOMElement;
class nsHTMLCanvasElement;
class imgIRequest;
class gfxASurface;
struct gfxIntSize;
namespace mozilla {
class CanvasImageCache {
public:
/**
* Notify that image element aImage was (or is about to be) drawn to aCanvas
* using the first frame of aRequest's image. The data for the surface is
* in aSurface, and the image size is in aSize.
*/
static void NotifyDrawImage(nsIDOMElement* aImage,
nsHTMLCanvasElement* aCanvas,
imgIRequest* aRequest,
gfxASurface* aSurface,
const gfxIntSize& aSize);
/**
* Check whether aImage has recently been drawn into aCanvas. If we return
* a non-null surface, then the image was recently drawn into the canvas
* (with the same image request) and the returned surface contains the image
* data, and the image size will be returned in aSize.
*/
static gfxASurface* Lookup(nsIDOMElement* aImage,
nsHTMLCanvasElement* aCanvas,
gfxIntSize* aSize);
static void Shutdown();
};
}
#endif /* CANVASIMAGECACHE_H_ */

View File

@ -83,16 +83,13 @@ CanvasUtils::DoDrawImageSecurityCheck(nsHTMLCanvasElement *aCanvasElement,
if (aPrincipal == nsnull)
return;
nsCOMPtr<nsINode> elem = do_QueryInterface(static_cast<nsIDOMHTMLCanvasElement*>(aCanvasElement));
if (elem) { // XXXbz How could this actually be null?
PRBool subsumes;
nsresult rv =
elem->NodePrincipal()->Subsumes(aPrincipal, &subsumes);
if (NS_SUCCEEDED(rv) && subsumes) {
// This canvas has access to that image anyway
return;
}
PRBool subsumes;
nsresult rv =
aCanvasElement->NodePrincipal()->Subsumes(aPrincipal, &subsumes);
if (NS_SUCCEEDED(rv) && subsumes) {
// This canvas has access to that image anyway
return;
}
aCanvasElement->SetWriteOnly();

View File

@ -52,6 +52,7 @@ EXPORTS = \
$(NULL)
CPPSRCS = \
CanvasImageCache.cpp \
CanvasUtils.cpp \
nsCanvasRenderingContext2D.cpp \
$(NULL)

View File

@ -749,7 +749,6 @@ DOMCI_DATA(WebGLRenderingContext, WebGLContext)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(WebGLContext)
NS_INTERFACE_MAP_ENTRY(nsIDOMWebGLRenderingContext)
NS_INTERFACE_MAP_ENTRY(nsIDOMWebGLRenderingContext_MOZILLA_2_0_BRANCH)
NS_INTERFACE_MAP_ENTRY(nsICanvasRenderingContextInternal)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMWebGLRenderingContext)

View File

@ -315,7 +315,6 @@ struct WebGLContextOptions {
class WebGLContext :
public nsIDOMWebGLRenderingContext,
public nsIDOMWebGLRenderingContext_MOZILLA_2_0_BRANCH,
public nsICanvasRenderingContextInternal,
public nsSupportsWeakReference
{
@ -328,7 +327,6 @@ public:
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(WebGLContext, nsIDOMWebGLRenderingContext)
NS_DECL_NSIDOMWEBGLRENDERINGCONTEXT
NS_DECL_NSIDOMWEBGLRENDERINGCONTEXT_MOZILLA_2_0_BRANCH
// nsICanvasRenderingContextInternal
NS_IMETHOD SetCanvasElement(nsHTMLCanvasElement* aParentCanvas);

View File

@ -111,18 +111,13 @@
#include "gfxUtils.h"
#include "nsFrameManager.h"
#include "nsFrameLoader.h"
#include "nsBidiPresUtils.h"
#include "Layers.h"
#include "CanvasUtils.h"
#include "nsIMemoryReporter.h"
#include "nsStyleUtil.h"
#include "CanvasImageCache.h"
#ifdef MOZ_IPC
# include <algorithm>
@ -416,8 +411,10 @@ public:
LayerManager *aManager);
void MarkContextClean();
NS_IMETHOD SetIsIPC(PRBool isIPC);
// this rect is in CSS pixels
// this rect is in canvas device space
NS_IMETHOD Redraw(const gfxRect &r);
// this rect is in mThebes's current user space
NS_IMETHOD RedrawUser(const gfxRect &r);
// nsISupports interface + CC
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
@ -434,6 +431,29 @@ public:
STYLE_MAX
};
class PathAutoSaveRestore
{
public:
PathAutoSaveRestore(nsCanvasRenderingContext2D* aCtx) :
mContext(aCtx->mThebes)
{
if (aCtx->mHasPath) {
mPath = mContext->CopyPath();
}
}
~PathAutoSaveRestore()
{
mContext->NewPath();
if (mPath) {
mContext->AppendPath(mPath);
}
}
private:
gfxContext *mContext;
nsRefPtr<gfxPath> mPath;
};
friend class PathAutoSaveRestore;
protected:
/**
@ -508,7 +528,17 @@ protected:
* Flag to avoid duplicate calls to InvalidateFrame. Set to true whenever
* Redraw is called, reset to false when Render is called.
*/
PRBool mIsEntireFrameInvalid;
PRPackedBool mIsEntireFrameInvalid;
/**
* When this is set, the first call to Redraw(gfxRect) should set
* mIsEntireFrameInvalid since we expect it will be followed by
* many more Redraw calls.
*/
PRPackedBool mPredictManyRedrawCalls;
/**
* This is set whenever there's a nonempty path set by the API user.
*/
PRPackedBool mHasPath;
/**
* Number of times we've invalidated before calling redraw
@ -608,7 +638,7 @@ protected:
* Draws the current path in the given style. Takes care of
* any shadow drawing and will use intermediate surfaces as needed.
*
* If dirtyRect is given, it will contain the device-space dirty
* If dirtyRect is given, it will contain the user-space dirty
* rectangle of the draw operation.
*/
nsresult DrawPath(Style style, gfxRect *dirtyRect = nsnull);
@ -826,7 +856,8 @@ nsCanvasRenderingContext2D::nsCanvasRenderingContext2D()
: mValid(PR_FALSE), mOpaque(PR_FALSE), mResetLayer(PR_TRUE)
, mIPC(PR_FALSE)
, mCanvasElement(nsnull)
, mSaveCount(0), mIsEntireFrameInvalid(PR_FALSE), mInvalidateCount(0)
, mSaveCount(0), mIsEntireFrameInvalid(PR_FALSE)
, mPredictManyRedrawCalls(PR_FALSE), mHasPath(PR_FALSE), mInvalidateCount(0)
, mLastStyle(STYLE_MAX), mStyleStack(20)
{
sNumLivingContexts++;
@ -856,6 +887,7 @@ nsCanvasRenderingContext2D::Reset()
mThebes = nsnull;
mValid = PR_FALSE;
mIsEntireFrameInvalid = PR_FALSE;
mPredictManyRedrawCalls = PR_FALSE;
return NS_OK;
}
@ -1019,6 +1051,10 @@ nsCanvasRenderingContext2D::ApplyStyle(Style aWhichStyle,
nsresult
nsCanvasRenderingContext2D::Redraw()
{
if (mIsEntireFrameInvalid)
return NS_OK;
mIsEntireFrameInvalid = PR_TRUE;
if (!mCanvasElement) {
NS_ASSERTION(mDocShell, "Redraw with no canvas element or docshell!");
return NS_OK;
@ -1028,11 +1064,6 @@ nsCanvasRenderingContext2D::Redraw()
nsSVGEffects::InvalidateDirectRenderingObservers(HTMLCanvasElement());
#endif
if (mIsEntireFrameInvalid)
return NS_OK;
mIsEntireFrameInvalid = PR_TRUE;
HTMLCanvasElement()->InvalidateFrame();
return NS_OK;
@ -1041,6 +1072,16 @@ nsCanvasRenderingContext2D::Redraw()
NS_IMETHODIMP
nsCanvasRenderingContext2D::Redraw(const gfxRect& r)
{
++mInvalidateCount;
if (mIsEntireFrameInvalid)
return NS_OK;
if (mPredictManyRedrawCalls ||
mInvalidateCount > kCanvasMaxInvalidateCount) {
return Redraw();
}
if (!mCanvasElement) {
NS_ASSERTION(mDocShell, "Redraw with no canvas element or docshell!");
return NS_OK;
@ -1050,17 +1091,22 @@ nsCanvasRenderingContext2D::Redraw(const gfxRect& r)
nsSVGEffects::InvalidateDirectRenderingObservers(HTMLCanvasElement());
#endif
if (mIsEntireFrameInvalid)
return NS_OK;
if (++mInvalidateCount > kCanvasMaxInvalidateCount)
return Redraw();
HTMLCanvasElement()->InvalidateFrame(&r);
return NS_OK;
}
NS_IMETHODIMP
nsCanvasRenderingContext2D::RedrawUser(const gfxRect& r)
{
if (mIsEntireFrameInvalid) {
++mInvalidateCount;
return NS_OK;
}
return Redraw(mThebes->UserToDevice(r));
}
NS_IMETHODIMP
nsCanvasRenderingContext2D::SetDimensions(PRInt32 width, PRInt32 height)
{
@ -1919,8 +1965,6 @@ nsCanvasRenderingContext2D::DrawPath(Style style, gfxRect *dirtyRect)
// just use the clip extents
*dirtyRect = mThebes->GetClipExtents();
}
*dirtyRect = mThebes->UserToDevice(*dirtyRect);
}
return NS_OK;
@ -1936,7 +1980,7 @@ nsCanvasRenderingContext2D::ClearRect(float x, float y, float w, float h)
if (!FloatValidate(x,y,w,h))
return NS_ERROR_DOM_SYNTAX_ERR;
gfxContextPathAutoSaveRestore pathSR(mThebes);
PathAutoSaveRestore pathSR(this);
gfxContextAutoSaveRestore autoSR(mThebes);
mThebes->SetOperator(gfxContext::OPERATOR_CLEAR);
@ -1944,8 +1988,7 @@ nsCanvasRenderingContext2D::ClearRect(float x, float y, float w, float h)
mThebes->Rectangle(gfxRect(x, y, w, h));
mThebes->Fill();
gfxRect dirty = mThebes->UserToDevice(mThebes->GetUserPathExtent());
return Redraw(dirty);
return RedrawUser(mThebes->GetUserPathExtent());
}
nsresult
@ -1954,7 +1997,7 @@ nsCanvasRenderingContext2D::DrawRect(const gfxRect& rect, Style style)
if (!FloatValidate(rect.pos.x, rect.pos.y, rect.size.width, rect.size.height))
return NS_ERROR_DOM_SYNTAX_ERR;
gfxContextPathAutoSaveRestore pathSR(mThebes);
PathAutoSaveRestore pathSR(this);
mThebes->NewPath();
mThebes->Rectangle(rect);
@ -1964,7 +2007,7 @@ nsCanvasRenderingContext2D::DrawRect(const gfxRect& rect, Style style)
if (NS_FAILED(rv))
return rv;
return Redraw(dirty);
return RedrawUser(dirty);
}
NS_IMETHODIMP
@ -1986,6 +2029,7 @@ nsCanvasRenderingContext2D::StrokeRect(float x, float y, float w, float h)
NS_IMETHODIMP
nsCanvasRenderingContext2D::BeginPath()
{
mHasPath = PR_FALSE;
mThebes->NewPath();
return NS_OK;
}
@ -2004,7 +2048,7 @@ nsCanvasRenderingContext2D::Fill()
nsresult rv = DrawPath(STYLE_FILL, &dirty);
if (NS_FAILED(rv))
return rv;
return Redraw(dirty);
return RedrawUser(dirty);
}
NS_IMETHODIMP
@ -2014,7 +2058,7 @@ nsCanvasRenderingContext2D::Stroke()
nsresult rv = DrawPath(STYLE_STROKE, &dirty);
if (NS_FAILED(rv))
return rv;
return Redraw(dirty);
return RedrawUser(dirty);
}
NS_IMETHODIMP
@ -2030,6 +2074,7 @@ nsCanvasRenderingContext2D::MoveTo(float x, float y)
if (!FloatValidate(x,y))
return NS_ERROR_DOM_SYNTAX_ERR;
mHasPath = PR_TRUE;
mThebes->MoveTo(gfxPoint(x, y));
return NS_OK;
}
@ -2040,6 +2085,7 @@ nsCanvasRenderingContext2D::LineTo(float x, float y)
if (!FloatValidate(x,y))
return NS_ERROR_DOM_SYNTAX_ERR;
mHasPath = PR_TRUE;
mThebes->LineTo(gfxPoint(x, y));
return NS_OK;
}
@ -2056,6 +2102,7 @@ nsCanvasRenderingContext2D::QuadraticCurveTo(float cpx, float cpy, float x, floa
gfxPoint p(x,y);
gfxPoint cp(cpx, cpy);
mHasPath = PR_TRUE;
mThebes->CurveTo((c+cp*2)/3.0, (p+cp*2)/3.0, p);
return NS_OK;
@ -2069,6 +2116,7 @@ nsCanvasRenderingContext2D::BezierCurveTo(float cp1x, float cp1y,
if (!FloatValidate(cp1x,cp1y,cp2x,cp2y,x,y))
return NS_ERROR_DOM_SYNTAX_ERR;
mHasPath = PR_TRUE;
mThebes->CurveTo(gfxPoint(cp1x, cp1y),
gfxPoint(cp2x, cp2y),
gfxPoint(x, y));
@ -2085,6 +2133,8 @@ nsCanvasRenderingContext2D::ArcTo(float x1, float y1, float x2, float y2, float
if (radius < 0)
return NS_ERROR_DOM_INDEX_SIZE_ERR;
mHasPath = PR_TRUE;
gfxPoint p0 = mThebes->CurrentPoint();
double dir, a2, b2, c2, cosx, sinx, d, anx, any, bnx, bny, x3, y3, x4, y4, cx, cy, angle0, angle1;
@ -2144,6 +2194,7 @@ nsCanvasRenderingContext2D::Arc(float x, float y, float r, float startAngle, flo
gfxPoint p(x,y);
mHasPath = PR_TRUE;
if (ccw)
mThebes->NegativeArc(p, r, startAngle, endAngle);
else
@ -2157,6 +2208,7 @@ nsCanvasRenderingContext2D::Rect(float x, float y, float w, float h)
if (!FloatValidate(x,y,w,h))
return NS_ERROR_DOM_SYNTAX_ERR;
mHasPath = PR_TRUE;
mThebes->Rectangle(gfxRect(x, y, w, h));
return NS_OK;
}
@ -2853,7 +2905,7 @@ nsCanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
mThebes->Paint(CurrentState().StyleIsColor(STYLE_FILL) ? 1.0 : CurrentState().globalAlpha);
if (aOp == nsCanvasRenderingContext2D::TEXT_DRAW_OPERATION_FILL && !doDrawShadow)
return Redraw(mThebes->UserToDevice(boundingBox));
return RedrawUser(boundingBox);
return Redraw();
}
@ -3315,48 +3367,50 @@ nsCanvasRenderingContext2D::DrawImage(nsIDOMElement *imgElt, float a1,
{
NS_ENSURE_ARG(imgElt);
nsresult rv;
gfxRect dirty(0.0, 0.0, 0.0, 0.0);
double sx,sy,sw,sh;
double dx,dy,dw,dh;
gfxMatrix matrix;
nsRefPtr<gfxPattern> pattern;
nsRefPtr<gfxPath> path;
gfxIntSize imgSize;
nsRefPtr<gfxASurface> imgsurf =
CanvasImageCache::Lookup(imgElt, HTMLCanvasElement(), &imgSize);
// The canvas spec says that drawImage should draw the first frame
// of animated images
PRUint32 sfeFlags = nsLayoutUtils::SFE_WANT_FIRST_FRAME;
nsLayoutUtils::SurfaceFromElementResult res =
nsLayoutUtils::SurfaceFromElement(imgElt, sfeFlags);
if (!res.mSurface) {
// Spec says to silently do nothing if the element is still loading.
return res.mIsStillLoading ? NS_OK : NS_ERROR_NOT_AVAILABLE;
}
if (!imgsurf) {
// The canvas spec says that drawImage should draw the first frame
// of animated images
PRUint32 sfeFlags = nsLayoutUtils::SFE_WANT_FIRST_FRAME;
nsLayoutUtils::SurfaceFromElementResult res =
nsLayoutUtils::SurfaceFromElement(imgElt, sfeFlags);
if (!res.mSurface) {
// Spec says to silently do nothing if the element is still loading.
return res.mIsStillLoading ? NS_OK : NS_ERROR_NOT_AVAILABLE;
}
#ifndef WINCE
// On non-CE, force a copy if we're using drawImage with our destination
// as a source to work around some Cairo self-copy semantics issues.
if (res.mSurface == mSurface) {
sfeFlags |= nsLayoutUtils::SFE_WANT_NEW_SURFACE;
res = nsLayoutUtils::SurfaceFromElement(imgElt, sfeFlags);
if (!res.mSurface)
return NS_ERROR_NOT_AVAILABLE;
}
// On non-CE, force a copy if we're using drawImage with our destination
// as a source to work around some Cairo self-copy semantics issues.
if (res.mSurface == mSurface) {
sfeFlags |= nsLayoutUtils::SFE_WANT_NEW_SURFACE;
res = nsLayoutUtils::SurfaceFromElement(imgElt, sfeFlags);
if (!res.mSurface)
return NS_ERROR_NOT_AVAILABLE;
}
#endif
nsRefPtr<gfxASurface> imgsurf = res.mSurface;
nsCOMPtr<nsIPrincipal> principal = res.mPrincipal;
gfxIntSize imgSize = res.mSize;
PRBool forceWriteOnly = res.mIsWriteOnly;
imgsurf = res.mSurface.forget();
imgSize = res.mSize;
if (mCanvasElement)
CanvasUtils::DoDrawImageSecurityCheck(HTMLCanvasElement(), principal, forceWriteOnly);
if (mCanvasElement) {
CanvasUtils::DoDrawImageSecurityCheck(HTMLCanvasElement(),
res.mPrincipal, res.mIsWriteOnly);
}
gfxContextPathAutoSaveRestore pathSR(mThebes, PR_FALSE);
rv = NS_OK;
if (res.mImageRequest) {
CanvasImageCache::NotifyDrawImage(imgElt, HTMLCanvasElement(),
res.mImageRequest, imgsurf, imgSize);
}
}
if (optional_argc == 0) {
dx = a1;
@ -3383,20 +3437,17 @@ nsCanvasRenderingContext2D::DrawImage(nsIDOMElement *imgElt, float a1,
dh = a8;
} else {
// XXX ERRMSG we need to report an error to developers here! (bug 329026)
rv = NS_ERROR_INVALID_ARG;
goto FINISH;
return NS_ERROR_INVALID_ARG;
}
if (dw == 0.0 || dh == 0.0) {
rv = NS_OK;
// not really failure, but nothing to do --
// and noone likes a divide-by-zero
goto FINISH;
return NS_OK;
}
if (!FloatValidate(sx, sy, sw, sh) || !FloatValidate(dx, dy, dw, dh)) {
rv = NS_ERROR_DOM_SYNTAX_ERR;
goto FINISH;
return NS_ERROR_DOM_SYNTAX_ERR;
}
// check args
@ -3406,8 +3457,7 @@ nsCanvasRenderingContext2D::DrawImage(nsIDOMElement *imgElt, float a1,
dw < 0.0 || dh < 0.0)
{
// XXX ERRMSG we need to report an error to developers here! (bug 329026)
rv = NS_ERROR_DOM_INDEX_SIZE_ERR;
goto FINISH;
return NS_ERROR_DOM_INDEX_SIZE_ERR;
}
matrix.Translate(gfxPoint(sx, sy));
@ -3434,8 +3484,7 @@ nsCanvasRenderingContext2D::DrawImage(nsIDOMElement *imgElt, float a1,
if (opaque && unscaled) {
bitblt(surf, sx, sy, sw, sh, dx, dy);
rv = NS_OK;
goto FINISH;
return NS_OK;
}
}
}
@ -3450,15 +3499,17 @@ nsCanvasRenderingContext2D::DrawImage(nsIDOMElement *imgElt, float a1,
else
pattern->SetFilter(gfxPattern::FILTER_NEAREST);
pathSR.Save();
PathAutoSaveRestore pathSR(this);
// Clear the surface if we need to simulate unbounded SOURCE operator
ClearSurfaceForUnboundedSource();
{
gfxContextAutoSaveRestore autoSR(mThebes);
gfxContextMatrixAutoSaveRestore autoMatrixSR(mThebes);
mThebes->Translate(gfxPoint(dx, dy));
mThebes->SetPattern(pattern);
DirtyAllStyles();
gfxRect clip(0, 0, dw, dh);
@ -3479,11 +3530,9 @@ nsCanvasRenderingContext2D::DrawImage(nsIDOMElement *imgElt, float a1,
}
PRBool doUseIntermediateSurface = NeedToUseIntermediateSurface();
mThebes->SetPattern(pattern);
DirtyAllStyles();
if (doUseIntermediateSurface) {
gfxContextAutoSaveRestore autoSR(mThebes);
// draw onto a pushed group
mThebes->PushGroup(gfxASurface::CONTENT_COLOR_ALPHA);
mThebes->Clip(clip);
@ -3501,18 +3550,17 @@ nsCanvasRenderingContext2D::DrawImage(nsIDOMElement *imgElt, float a1,
mThebes->Rectangle(clip);
mThebes->Fill();
} else {
gfxContextAutoSaveRestore autoSR(mThebes);
/* we need to use to clip instead of fill for globalAlpha */
mThebes->Clip(clip);
mThebes->Paint(CurrentState().globalAlpha);
}
dirty = mThebes->UserToDevice(clip);
RedrawUser(clip);
}
FINISH:
if (NS_SUCCEEDED(rv))
rv = Redraw(dirty);
return rv;
return NS_OK;
}
NS_IMETHODIMP
@ -3663,9 +3711,7 @@ nsCanvasRenderingContext2D::DrawWindow(nsIDOMWindow* aWindow, float aX, float aY
// note that aX and aY are coordinates in the document that
// we're drawing; aX and aY are drawn to 0,0 in current user
// space.
gfxRect damageRect = mThebes->UserToDevice(gfxRect(0, 0, aW, aH));
Redraw(damageRect);
RedrawUser(gfxRect(0, 0, aW, aH));
return rv;
}
@ -3996,7 +4042,7 @@ nsCanvasRenderingContext2D::PutImageData_explicit(PRInt32 x, PRInt32 y, PRUint32
}
}
gfxContextPathAutoSaveRestore pathSR(mThebes);
PathAutoSaveRestore pathSR(this);
gfxContextAutoSaveRestore autoSR(mThebes);
// ignore clipping region, as per spec
@ -4101,6 +4147,9 @@ nsCanvasRenderingContext2D::GetCanvasLayer(CanvasLayer *aOldLayer,
void
nsCanvasRenderingContext2D::MarkContextClean()
{
if (mInvalidateCount > 0) {
mPredictManyRedrawCalls = mInvalidateCount > kCanvasMaxInvalidateCount;
}
mIsEntireFrameInvalid = PR_FALSE;
mInvalidateCount = 0;
}

View File

@ -82,6 +82,7 @@ _TEST_FILES_0 = \
test_mozGetAsFile.html \
test_canvas_strokeStyle_getter.html \
test_bug613794.html \
test_drawImage_edge_cases.html \
$(NULL)
ifneq (1_Linux,$(MOZ_SUITE)_$(OS_ARCH))

View File

@ -25,8 +25,6 @@ c.width = c.height = 1;
c = c.getContext("2d");
SimpleTest.waitForExplicitFinish();
var threw = true;
try {
c.putImageData({ width: 1, height: 1, data: [ 0, 0, 0, 0] }, 0, 0);
@ -47,8 +45,6 @@ try {
is(threw, DOMException.TYPE_MISMATCH_ERR,
"Should throw type error when data is not an array");
SimpleTest.finish();
</script>
</pre>

View File

@ -19871,7 +19871,7 @@ function test_size_attributes_parse_negative() {
var canvas = document.getElementById('c639');
var ctx = canvas.getContext('2d');
todo(canvas.width == 300, "canvas.width == 300");
ok(canvas.width == 300, "canvas.width == 300");
}
@ -20084,7 +20084,7 @@ var canvas = document.getElementById('c650');
var ctx = canvas.getContext('2d');
canvas.setAttribute('width', '-100');
todo(canvas.width == 300, "canvas.width == 300");
ok(canvas.width == 300, "canvas.width == 300");
}

View File

@ -0,0 +1,43 @@
<!DOCTYPE HTML>
<html>
<head>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body onload="doTest()">
<p id="display">
<canvas id="c" width="1" height="1"></canvas>
<img id="img" src="image_red.png">
</p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
var c = document.getElementById("c");
var ctx = c.getContext("2d");
var img = document.getElementById("img");
SimpleTest.waitForExplicitFinish();
function doTest() {
ctx.drawImage(img, 0, 0);
img.src = "image_green-1x1.png";
img.onload = function() {
ctx.drawImage(img, 0, 0);
var data = ctx.getImageData(0, 0, 1, 1).data;
is(data[0], 0, "Red channel should be 0");
is(data[1], 255, "Green channel should be 1.0");
is(data[2], 0, "Blue channel should be 0")
is(data[3], 255, "Alpha channel should be opaque");
SimpleTest.finish();
}
}
</script>
</pre>
</body>
</html>

View File

@ -272,8 +272,9 @@ NS_METHOD nsDOMEvent::GetType(nsAString& aType)
mCachedType = aType;
return NS_OK;
}
return NS_ERROR_FAILURE;
aType.Truncate();
return NS_OK;
}
static nsresult

View File

@ -50,6 +50,7 @@
#include "nsINode.h"
#include "nsPIDOMWindow.h"
#include "nsDOMPopStateEvent.h"
#include "nsFrameLoader.h"
#define NS_TARGET_CHAIN_FORCE_CONTENT_DISPATCH (1 << 0)
#define NS_TARGET_CHAIN_WANTS_WILL_HANDLE_EVENT (1 << 1)
@ -472,6 +473,12 @@ nsEventDispatcher::Dispatch(nsISupports* aTarget,
NS_ERROR_ILLEGAL_VALUE);
NS_ASSERTION(!aTargets || !aEvent->message, "Wrong parameters!");
// If we're dispatching an already created DOMEvent object, make
// sure it is initialized!
// If aTargets is non-null, the event isn't going to be dispatched.
NS_ENSURE_TRUE(aEvent->message || !aDOMEvent || aTargets,
NS_ERROR_DOM_UNSPECIFIED_EVENT_TYPE_ERR);
#ifdef NS_FUNCTION_TIMER
const char* timer_event_name = nsDOMEvent::GetEventName(aEvent->message);
NS_TIME_FUNCTION_MIN_FMT(20, "Dispatching '%s' event",
@ -494,11 +501,22 @@ nsEventDispatcher::Dispatch(nsISupports* aTarget,
if (!nsContentUtils::IsChromeDoc(doc)) {
nsPIDOMWindow* win = doc ? doc->GetInnerWindow() : nsnull;
// If we can't dispatch the event to chrome, do nothing.
NS_ENSURE_TRUE(win && win->GetChromeEventHandler(), NS_OK);
nsPIDOMEventTarget* piTarget = win ? win->GetChromeEventHandler() : nsnull;
NS_ENSURE_TRUE(piTarget, NS_OK);
nsCOMPtr<nsIFrameLoaderOwner> flo = do_QueryInterface(piTarget);
if (flo) {
nsRefPtr<nsFrameLoader> fl = flo->GetFrameLoader();
if (fl) {
nsPIDOMEventTarget* t = fl->GetTabChildGlobalAsEventTarget();
piTarget = t ? t : piTarget;
}
}
// Set the target to be the original dispatch target,
aEvent->target = target;
// but use chrome event handler for event target chain.
target = do_QueryInterface(win->GetChromeEventHandler());
// but use chrome event handler or TabChildGlobal for event target chain.
target = piTarget;
}
}

View File

@ -166,9 +166,8 @@ nsIMEStateManager::OnChangeFocus(nsPresContext* aPresContext,
// the enabled state isn't changing, we should do nothing.
return NS_OK;
}
nsIWidget_MOZILLA_2_0_BRANCH* widget2 = static_cast<nsIWidget_MOZILLA_2_0_BRANCH*>(widget.get());
IMEContext context;
if (!widget2 || NS_FAILED(widget2->GetInputMode(context))) {
if (!widget || NS_FAILED(widget->GetInputMode(context))) {
// this platform doesn't support IME controlling
return NS_OK;
}
@ -223,9 +222,8 @@ nsIMEStateManager::UpdateIMEState(PRUint32 aNewIMEState, nsIContent* aContent)
}
// Don't update IME state when enabled state isn't actually changed.
nsIWidget_MOZILLA_2_0_BRANCH* widget2 = static_cast<nsIWidget_MOZILLA_2_0_BRANCH*>(widget.get());
IMEContext context;
nsresult rv = widget2->GetInputMode(context);
nsresult rv = widget->GetInputMode(context);
if (NS_FAILED(rv)) {
return; // This platform doesn't support controling the IME state.
}
@ -294,8 +292,7 @@ nsIMEStateManager::SetIMEState(PRUint32 aState,
nsIWidget* aWidget)
{
if (aState & nsIContent::IME_STATUS_MASK_ENABLED) {
nsIWidget_MOZILLA_2_0_BRANCH* widget2 = static_cast<nsIWidget_MOZILLA_2_0_BRANCH*>(aWidget);
if (!widget2)
if (!aWidget)
return;
PRUint32 state = nsContentUtils::GetWidgetStatusFromIMEStatus(aState);
@ -330,7 +327,7 @@ nsIMEStateManager::SetIMEState(PRUint32 aState,
}
}
widget2->SetInputMode(context);
aWidget->SetInputMode(context);
nsContentUtils::AddScriptRunner(new IMEEnabledStateChangedEvent(state));
}

View File

@ -99,6 +99,7 @@ _TEST_FILES = \
test_bug605242.html \
test_bug607464.html \
test_bug624127.html \
test_bug641477.html \
$(NULL)
#bug 585630

View File

@ -61,6 +61,11 @@ function fireDrop(element, shouldAllowDrop, shouldAllowOnlyChromeDrop) {
ok(!ds.getCurrentSession(), "There shouldn't be a drag session anymore!");
}
var chromeGotEvent = false;
function chromeListener(e) {
chromeGotEvent = true;
}
function runTests()
{
var targetHandling = document.getElementById("handling_target");
@ -73,9 +78,11 @@ function runTests()
gGotHandlingDrop = false;
gGotNotHandlingDrop = false;
SpecialPowers.addChromeEventListener("drop", chromeListener, true, false);
var targetNotHandling = document.getElementById("nothandling_target");
fireDrop(targetNotHandling, true, true);
SpecialPowers.removeChromeEventListener("drop", chromeListener, true);
ok(chromeGotEvent, "Chrome should have got drop event!");
is(gGotHandlingDrop, false, "Didn't get drop on accepting element (2)");
is(gGotNotHandlingDrop, false, "Didn't get drop on unaccepting element (2)");

View File

@ -0,0 +1,38 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=641477
-->
<head>
<title>Test for Bug 641477</title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=641477">Mozilla Bug 641477</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 641477 **/
var didThrow = false;
var e = document.createEvent("Event");
try {
is(e.type, "", "Event type should be empty string before initialization");
document.dispatchEvent(e);
} catch(ex) {
didThrow = (ex.code == 0);
}
ok(didThrow, "Should have thrown UNSPECIFIED_EVENT_TYPE_ERR!");
</script>
</pre>
</body>
</html>

View File

@ -101,8 +101,8 @@ PR_STATIC_ASSERT((PRUint32)eButtonElementTypesMax < (PRUint32)NS_FORM_INPUT_ELEM
PR_STATIC_ASSERT((PRUint32)eInputElementTypesMax < 1<<8);
#define NS_IFORMCONTROL_IID \
{ 0x218eb090, 0x32eb, 0x4e2a, \
{ 0x96, 0x42, 0xcd, 0xcd, 0x33, 0xae, 0xdb, 0x95 } }
{ 0x671ef379, 0x7ac0, 0x414c, \
{ 0xa2, 0x2b, 0xc1, 0x9e, 0x0b, 0x61, 0x4e, 0x83 } }
/**
* Interface which all form controls (e.g. buttons, checkboxes, text,
@ -181,39 +181,146 @@ public:
virtual PRBool AllowDrop() = 0;
/**
* Returns true if this is a control which submits the form when
* activated by the user.
* @return Whether this is a submit control.
* Returns whether this is a control which submits the form when activated by
* the user.
* @return whether this is a submit control.
*/
virtual PRBool IsSubmitControl() const = 0;
inline PRBool IsSubmitControl() const;
/**
* Returns true if this is a control which has a text field.
* Returns whether this is a text control.
* @param aExcludePassword to have NS_FORM_INPUT_PASSWORD returning false.
* @return Whether this is a text control.
* @return whether this is a text control.
*/
virtual PRBool IsTextControl(PRBool aExcludePassword) const = 0;
inline PRBool IsTextControl(PRBool aExcludePassword) const ;
/**
* Returns true if this is a control which has a single line text field.
* Returns whether this is a single line text control.
* @param aExcludePassword to have NS_FORM_INPUT_PASSWORD returning false.
* @return Whether this is a single line text control.
* @return whether this is a single line text control.
*/
virtual PRBool IsSingleLineTextControl(PRBool aExcludePassword) const = 0;
inline PRBool IsSingleLineTextControl(PRBool aExcludePassword) const;
/**
* Returns true if this is a labelable form control.
* @return Whether this is a labelable form control.
* Returns whether this is a labelable form control.
* @return whether this is a labelable form control.
*/
virtual PRBool IsLabelableControl() const = 0;
inline PRBool IsLabelableControl() const;
/**
* Returns true if this is a submittable form control.
* @return Whether this is a submittable form control.
* Returns whether this is a submittable form control.
* @return whether this is a submittable form control.
*/
virtual PRBool IsSubmittableControl() const = 0;
inline PRBool IsSubmittableControl() const;
/**
* Returns whether this form control can have draggable children.
* @return whether this form control can have draggable children.
*/
inline PRBool AllowDraggableChildren() const;
protected:
/**
* Returns whether mType corresponds to a single line text control type.
* @param aExcludePassword to have NS_FORM_INPUT_PASSWORD ignored.
* @param aType the type to be tested.
* @return whether mType corresponds to a single line text control type.
*/
inline static bool IsSingleLineTextControl(bool aExcludePassword, PRUint32 aType);
/**
* Returns whether this is a auto-focusable form control.
* @return whether this is a auto-focusable form control.
*/
inline bool IsAutofocusable() const;
};
PRBool
nsIFormControl::IsSubmitControl() const
{
PRUint32 type = GetType();
return type == NS_FORM_INPUT_SUBMIT ||
type == NS_FORM_INPUT_IMAGE ||
type == NS_FORM_BUTTON_SUBMIT;
}
PRBool
nsIFormControl::IsTextControl(PRBool aExcludePassword) const
{
PRUint32 type = GetType();
return type == NS_FORM_TEXTAREA ||
IsSingleLineTextControl(aExcludePassword, type);
}
PRBool
nsIFormControl::IsSingleLineTextControl(PRBool aExcludePassword) const
{
return IsSingleLineTextControl(aExcludePassword, GetType());
}
/*static*/
bool
nsIFormControl::IsSingleLineTextControl(bool aExcludePassword, PRUint32 aType)
{
return aType == NS_FORM_INPUT_TEXT ||
aType == NS_FORM_INPUT_EMAIL ||
aType == NS_FORM_INPUT_SEARCH ||
aType == NS_FORM_INPUT_TEL ||
aType == NS_FORM_INPUT_URL ||
(!aExcludePassword && aType == NS_FORM_INPUT_PASSWORD);
}
PRBool
nsIFormControl::IsLabelableControl() const
{
// TODO: keygen should be in that list, see bug 101019.
// TODO: meter should be added, see bug 555985.
// TODO: NS_FORM_INPUT_HIDDEN should be removed, see bug 597650.
PRUint32 type = GetType();
return type & NS_FORM_INPUT_ELEMENT ||
type & NS_FORM_BUTTON_ELEMENT ||
// type == NS_FORM_KEYGEN ||
// type == NS_FORM_METER ||
type == NS_FORM_OUTPUT ||
// type == NS_FORM_PROGRESS ||
type == NS_FORM_SELECT ||
type == NS_FORM_TEXTAREA;
}
PRBool
nsIFormControl::IsSubmittableControl() const
{
// TODO: keygen should be in that list, see bug 101019.
PRUint32 type = GetType();
return type == NS_FORM_OBJECT ||
type == NS_FORM_TEXTAREA ||
type == NS_FORM_SELECT ||
// type == NS_FORM_KEYGEN ||
type & NS_FORM_BUTTON_ELEMENT ||
type & NS_FORM_INPUT_ELEMENT;
}
PRBool
nsIFormControl::AllowDraggableChildren() const
{
PRUint32 type = GetType();
return type == NS_FORM_OBJECT ||
type == NS_FORM_LABEL ||
type == NS_FORM_FIELDSET ||
type == NS_FORM_OUTPUT;
}
bool
nsIFormControl::IsAutofocusable() const
{
PRUint32 type = GetType();
return type & NS_FORM_INPUT_ELEMENT ||
type & NS_FORM_BUTTON_ELEMENT ||
type == NS_FORM_TEXTAREA ||
type == NS_FORM_SELECT;
}
NS_DEFINE_STATIC_IID_ACCESSOR(nsIFormControl, NS_IFORMCONTROL_IID)
#endif /* nsIFormControl_h___ */

View File

@ -1648,19 +1648,19 @@ nsGenericHTMLElement::MapCommonAttributesExceptHiddenInto(const nsMappedAttribut
nsRuleData* aData)
{
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(UserInterface)) {
nsRuleDataUserInterface *ui = aData->mUserInterfaceData;
if (ui->mUserModify.GetUnit() == eCSSUnit_Null) {
nsCSSValue* userModify = aData->ValueForUserModify();
if (userModify->GetUnit() == eCSSUnit_Null) {
const nsAttrValue* value =
aAttributes->GetAttr(nsGkAtoms::contenteditable);
if (value) {
if (value->Equals(nsGkAtoms::_empty, eCaseMatters) ||
value->Equals(nsGkAtoms::_true, eIgnoreCase)) {
ui->mUserModify.SetIntValue(NS_STYLE_USER_MODIFY_READ_WRITE,
eCSSUnit_Enumerated);
userModify->SetIntValue(NS_STYLE_USER_MODIFY_READ_WRITE,
eCSSUnit_Enumerated);
}
else if (value->Equals(nsGkAtoms::_false, eIgnoreCase)) {
ui->mUserModify.SetIntValue(NS_STYLE_USER_MODIFY_READ_ONLY,
eCSSUnit_Enumerated);
userModify->SetIntValue(NS_STYLE_USER_MODIFY_READ_ONLY,
eCSSUnit_Enumerated);
}
}
}
@ -1669,8 +1669,8 @@ nsGenericHTMLElement::MapCommonAttributesExceptHiddenInto(const nsMappedAttribut
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Visibility)) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::lang);
if (value && value->Type() == nsAttrValue::eString) {
aData->mDisplayData->mLang.SetStringValue(value->GetStringValue(),
eCSSUnit_Ident);
aData->ValueForLang()->SetStringValue(value->GetStringValue(),
eCSSUnit_Ident);
}
}
}
@ -1682,10 +1682,10 @@ nsGenericHTMLElement::MapCommonAttributesInto(const nsMappedAttributes* aAttribu
nsGenericHTMLElement::MapCommonAttributesExceptHiddenInto(aAttributes, aData);
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Display)) {
nsRuleDataDisplay* disp = aData->mDisplayData;
if (disp->mDisplay.GetUnit() == eCSSUnit_Null) {
nsCSSValue* display = aData->ValueForDisplay();
if (display->GetUnit() == eCSSUnit_Null) {
if (aAttributes->IndexOfAttr(nsGkAtoms::hidden, kNameSpaceID_None) >= 0) {
disp->mDisplay.SetIntValue(NS_STYLE_DISPLAY_NONE, eCSSUnit_Enumerated);
display->SetIntValue(NS_STYLE_DISPLAY_NONE, eCSSUnit_Enumerated);
}
}
}
@ -1787,22 +1787,27 @@ nsGenericHTMLElement::MapImageAlignAttributeInto(const nsMappedAttributes* aAttr
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
if (value && value->Type() == nsAttrValue::eEnum) {
PRInt32 align = value->GetEnumValue();
if ((aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(Display)) &&
aRuleData->mDisplayData->mFloat.GetUnit() == eCSSUnit_Null) {
if (align == NS_STYLE_TEXT_ALIGN_LEFT)
aRuleData->mDisplayData->mFloat.SetIntValue(NS_STYLE_FLOAT_LEFT, eCSSUnit_Enumerated);
else if (align == NS_STYLE_TEXT_ALIGN_RIGHT)
aRuleData->mDisplayData->mFloat.SetIntValue(NS_STYLE_FLOAT_RIGHT, eCSSUnit_Enumerated);
if (aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(Display)) {
nsCSSValue* cssFloat = aRuleData->ValueForCssFloat();
if (cssFloat->GetUnit() == eCSSUnit_Null) {
if (align == NS_STYLE_TEXT_ALIGN_LEFT) {
cssFloat->SetIntValue(NS_STYLE_FLOAT_LEFT, eCSSUnit_Enumerated);
} else if (align == NS_STYLE_TEXT_ALIGN_RIGHT) {
cssFloat->SetIntValue(NS_STYLE_FLOAT_RIGHT, eCSSUnit_Enumerated);
}
}
}
if ((aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(TextReset)) &&
aRuleData->mTextData->mVerticalAlign.GetUnit() == eCSSUnit_Null) {
switch (align) {
case NS_STYLE_TEXT_ALIGN_LEFT:
case NS_STYLE_TEXT_ALIGN_RIGHT:
break;
default:
aRuleData->mTextData->mVerticalAlign.SetIntValue(align, eCSSUnit_Enumerated);
break;
if (aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(TextReset)) {
nsCSSValue* verticalAlign = aRuleData->ValueForVerticalAlign();
if (verticalAlign->GetUnit() == eCSSUnit_Null) {
switch (align) {
case NS_STYLE_TEXT_ALIGN_LEFT:
case NS_STYLE_TEXT_ALIGN_RIGHT:
break;
default:
verticalAlign->SetIntValue(align, eCSSUnit_Enumerated);
break;
}
}
}
}
@ -1814,11 +1819,12 @@ nsGenericHTMLElement::MapDivAlignAttributeInto(const nsMappedAttributes* aAttrib
nsRuleData* aRuleData)
{
if (aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(Text)) {
if (aRuleData->mTextData->mTextAlign.GetUnit() == eCSSUnit_Null) {
nsCSSValue* textAlign = aRuleData->ValueForTextAlign();
if (textAlign->GetUnit() == eCSSUnit_Null) {
// align: enum
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
if (value && value->Type() == nsAttrValue::eEnum)
aRuleData->mTextData->mTextAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
textAlign->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
}
}
}
@ -1843,11 +1849,12 @@ nsGenericHTMLElement::MapImageMarginAttributeInto(const nsMappedAttributes* aAtt
hval.SetPercentValue(value->GetPercentValue());
if (hval.GetUnit() != eCSSUnit_Null) {
nsCSSRect& margin = aData->mMarginData->mMargin;
if (margin.mLeft.GetUnit() == eCSSUnit_Null)
margin.mLeft = hval;
if (margin.mRight.GetUnit() == eCSSUnit_Null)
margin.mRight = hval;
nsCSSValue* left = aData->ValueForMarginLeftValue();
if (left->GetUnit() == eCSSUnit_Null)
*left = hval;
nsCSSValue* right = aData->ValueForMarginRightValue();
if (right->GetUnit() == eCSSUnit_Null)
*right = hval;
}
}
@ -1861,11 +1868,12 @@ nsGenericHTMLElement::MapImageMarginAttributeInto(const nsMappedAttributes* aAtt
vval.SetPercentValue(value->GetPercentValue());
if (vval.GetUnit() != eCSSUnit_Null) {
nsCSSRect& margin = aData->mMarginData->mMargin;
if (margin.mTop.GetUnit() == eCSSUnit_Null)
margin.mTop = vval;
if (margin.mBottom.GetUnit() == eCSSUnit_Null)
margin.mBottom = vval;
nsCSSValue* top = aData->ValueForMarginTop();
if (top->GetUnit() == eCSSUnit_Null)
*top = vval;
nsCSSValue* bottom = aData->ValueForMarginBottom();
if (bottom->GetUnit() == eCSSUnit_Null)
*bottom = vval;
}
}
}
@ -1878,21 +1886,23 @@ nsGenericHTMLElement::MapImageSizeAttributesInto(const nsMappedAttributes* aAttr
return;
// width: value
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
nsCSSValue* width = aData->ValueForWidth();
if (width->GetUnit() == eCSSUnit_Null) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
if (value && value->Type() == nsAttrValue::eInteger)
aData->mPositionData->mWidth.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
width->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
else if (value && value->Type() == nsAttrValue::ePercent)
aData->mPositionData->mWidth.SetPercentValue(value->GetPercentValue());
width->SetPercentValue(value->GetPercentValue());
}
// height: value
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
nsCSSValue* height = aData->ValueForHeight();
if (height->GetUnit() == eCSSUnit_Null) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::height);
if (value && value->Type() == nsAttrValue::eInteger)
aData->mPositionData->mHeight.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
height->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
else if (value && value->Type() == nsAttrValue::ePercent)
aData->mPositionData->mHeight.SetPercentValue(value->GetPercentValue());
height->SetPercentValue(value->GetPercentValue());
}
}
@ -1912,35 +1922,44 @@ nsGenericHTMLElement::MapImageBorderAttributeInto(const nsMappedAttributes* aAtt
if (value->Type() == nsAttrValue::eInteger)
val = value->GetIntegerValue();
nsCSSRect& borderWidth = aData->mMarginData->mBorderWidth;
if (borderWidth.mLeft.GetUnit() == eCSSUnit_Null)
borderWidth.mLeft.SetFloatValue((float)val, eCSSUnit_Pixel);
if (borderWidth.mTop.GetUnit() == eCSSUnit_Null)
borderWidth.mTop.SetFloatValue((float)val, eCSSUnit_Pixel);
if (borderWidth.mRight.GetUnit() == eCSSUnit_Null)
borderWidth.mRight.SetFloatValue((float)val, eCSSUnit_Pixel);
if (borderWidth.mBottom.GetUnit() == eCSSUnit_Null)
borderWidth.mBottom.SetFloatValue((float)val, eCSSUnit_Pixel);
nsCSSValue* borderLeftWidth = aData->ValueForBorderLeftWidthValue();
if (borderLeftWidth->GetUnit() == eCSSUnit_Null)
borderLeftWidth->SetFloatValue((float)val, eCSSUnit_Pixel);
nsCSSValue* borderTopWidth = aData->ValueForBorderTopWidth();
if (borderTopWidth->GetUnit() == eCSSUnit_Null)
borderTopWidth->SetFloatValue((float)val, eCSSUnit_Pixel);
nsCSSValue* borderRightWidth = aData->ValueForBorderRightWidthValue();
if (borderRightWidth->GetUnit() == eCSSUnit_Null)
borderRightWidth->SetFloatValue((float)val, eCSSUnit_Pixel);
nsCSSValue* borderBottomWidth = aData->ValueForBorderBottomWidth();
if (borderBottomWidth->GetUnit() == eCSSUnit_Null)
borderBottomWidth->SetFloatValue((float)val, eCSSUnit_Pixel);
nsCSSRect& borderStyle = aData->mMarginData->mBorderStyle;
if (borderStyle.mLeft.GetUnit() == eCSSUnit_Null)
borderStyle.mLeft.SetIntValue(NS_STYLE_BORDER_STYLE_SOLID, eCSSUnit_Enumerated);
if (borderStyle.mTop.GetUnit() == eCSSUnit_Null)
borderStyle.mTop.SetIntValue(NS_STYLE_BORDER_STYLE_SOLID, eCSSUnit_Enumerated);
if (borderStyle.mRight.GetUnit() == eCSSUnit_Null)
borderStyle.mRight.SetIntValue(NS_STYLE_BORDER_STYLE_SOLID, eCSSUnit_Enumerated);
if (borderStyle.mBottom.GetUnit() == eCSSUnit_Null)
borderStyle.mBottom.SetIntValue(NS_STYLE_BORDER_STYLE_SOLID, eCSSUnit_Enumerated);
nsCSSValue* borderLeftStyle = aData->ValueForBorderLeftStyleValue();
if (borderLeftStyle->GetUnit() == eCSSUnit_Null)
borderLeftStyle->SetIntValue(NS_STYLE_BORDER_STYLE_SOLID, eCSSUnit_Enumerated);
nsCSSValue* borderTopStyle = aData->ValueForBorderTopStyle();
if (borderTopStyle->GetUnit() == eCSSUnit_Null)
borderTopStyle->SetIntValue(NS_STYLE_BORDER_STYLE_SOLID, eCSSUnit_Enumerated);
nsCSSValue* borderRightStyle = aData->ValueForBorderRightStyleValue();
if (borderRightStyle->GetUnit() == eCSSUnit_Null)
borderRightStyle->SetIntValue(NS_STYLE_BORDER_STYLE_SOLID, eCSSUnit_Enumerated);
nsCSSValue* borderBottomStyle = aData->ValueForBorderBottomStyle();
if (borderBottomStyle->GetUnit() == eCSSUnit_Null)
borderBottomStyle->SetIntValue(NS_STYLE_BORDER_STYLE_SOLID, eCSSUnit_Enumerated);
nsCSSRect& borderColor = aData->mMarginData->mBorderColor;
if (borderColor.mLeft.GetUnit() == eCSSUnit_Null)
borderColor.mLeft.SetIntValue(NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR, eCSSUnit_Enumerated);
if (borderColor.mTop.GetUnit() == eCSSUnit_Null)
borderColor.mTop.SetIntValue(NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR, eCSSUnit_Enumerated);
if (borderColor.mRight.GetUnit() == eCSSUnit_Null)
borderColor.mRight.SetIntValue(NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR, eCSSUnit_Enumerated);
if (borderColor.mBottom.GetUnit() == eCSSUnit_Null)
borderColor.mBottom.SetIntValue(NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR, eCSSUnit_Enumerated);
nsCSSValue* borderLeftColor = aData->ValueForBorderLeftColorValue();
if (borderLeftColor->GetUnit() == eCSSUnit_Null)
borderLeftColor->SetIntValue(NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR, eCSSUnit_Enumerated);
nsCSSValue* borderTopColor = aData->ValueForBorderTopColor();
if (borderTopColor->GetUnit() == eCSSUnit_Null)
borderTopColor->SetIntValue(NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR, eCSSUnit_Enumerated);
nsCSSValue* borderRightColor = aData->ValueForBorderRightColorValue();
if (borderRightColor->GetUnit() == eCSSUnit_Null)
borderRightColor->SetIntValue(NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR, eCSSUnit_Enumerated);
nsCSSValue* borderBottomColor = aData->ValueForBorderBottomColor();
if (borderBottomColor->GetUnit() == eCSSUnit_Null)
borderBottomColor->SetIntValue(NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR, eCSSUnit_Enumerated);
}
void
@ -1951,7 +1970,8 @@ nsGenericHTMLElement::MapBackgroundInto(const nsMappedAttributes* aAttributes,
return;
nsPresContext* presContext = aData->mPresContext;
if (aData->mColorData->mBackImage.GetUnit() == eCSSUnit_Null &&
nsCSSValue* backImage = aData->ValueForBackgroundImage();
if (backImage->GetUnit() == eCSSUnit_Null &&
presContext->UseDocumentColors()) {
// background
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::background);
@ -1981,8 +2001,7 @@ nsGenericHTMLElement::MapBackgroundInto(const nsMappedAttributes* aAttributes,
new nsCSSValue::Image(uri, buffer, doc->GetDocumentURI(),
doc->NodePrincipal(), doc);
if (NS_LIKELY(img)) {
nsCSSValueList* list =
aData->mColorData->mBackImage.SetListValue();
nsCSSValueList* list = backImage->SetListValue();
list->mValue.SetImageValue(img);
}
}
@ -1991,7 +2010,7 @@ nsGenericHTMLElement::MapBackgroundInto(const nsMappedAttributes* aAttributes,
else if (presContext->CompatibilityMode() == eCompatibility_NavQuirks) {
// in NavQuirks mode, allow the empty string to set the
// background to empty
nsCSSValueList* list = aData->mColorData->mBackImage.SetListValue();
nsCSSValueList* list = backImage->SetListValue();
list->mValue.SetNoneValue();
}
}
@ -2005,12 +2024,13 @@ nsGenericHTMLElement::MapBGColorInto(const nsMappedAttributes* aAttributes,
if (!(aData->mSIDs & NS_STYLE_INHERIT_BIT(Background)))
return;
if (aData->mColorData->mBackColor.GetUnit() == eCSSUnit_Null &&
nsCSSValue* backColor = aData->ValueForBackgroundColor();
if (backColor->GetUnit() == eCSSUnit_Null &&
aData->mPresContext->UseDocumentColors()) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::bgcolor);
nscolor color;
if (value && value->GetColorValue(color)) {
aData->mColorData->mBackColor.SetColorValue(color);
backColor->SetColorValue(color);
}
}
}
@ -2032,8 +2052,8 @@ nsGenericHTMLElement::MapScrollingAttributeInto(const nsMappedAttributes* aAttri
// scrolling
nsCSSValue* overflowValues[2] = {
&aData->mDisplayData->mOverflowX,
&aData->mDisplayData->mOverflowY,
aData->ValueForOverflowX(),
aData->ValueForOverflowY(),
};
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(overflowValues); ++i) {
if (overflowValues[i]->GetUnit() == eCSSUnit_Null) {
@ -2157,11 +2177,11 @@ nsGenericHTMLElement::SetUnsignedIntAttr(nsIAtom* aAttr, PRUint32 aValue)
}
nsresult
nsGenericHTMLElement::GetFloatAttr(nsIAtom* aAttr, float aDefault, float* aResult)
nsGenericHTMLElement::GetDoubleAttr(nsIAtom* aAttr, double aDefault, double* aResult)
{
const nsAttrValue* attrVal = mAttrsAndChildren.GetAttr(aAttr);
if (attrVal && attrVal->Type() == nsAttrValue::eFloatValue) {
*aResult = attrVal->GetFloatValue();
if (attrVal && attrVal->Type() == nsAttrValue::eDoubleValue) {
*aResult = attrVal->GetDoubleValue();
}
else {
*aResult = aDefault;
@ -2170,7 +2190,7 @@ nsGenericHTMLElement::GetFloatAttr(nsIAtom* aAttr, float aDefault, float* aResul
}
nsresult
nsGenericHTMLElement::SetFloatAttr(nsIAtom* aAttr, float aValue)
nsGenericHTMLElement::SetDoubleAttr(nsIAtom* aAttr, double aValue)
{
nsAutoString value;
value.AppendFloat(aValue);
@ -2505,7 +2525,7 @@ nsGenericHTMLFormElement::BindToTree(nsIDocument* aDocument,
// specified and the element accept the autofocus attribute. In addition,
// the document should not be already loaded and the "browser.autofocus"
// preference should be 'true'.
if (AcceptAutofocus() && HasAttr(kNameSpaceID_None, nsGkAtoms::autofocus) &&
if (IsAutofocusable() && HasAttr(kNameSpaceID_None, nsGkAtoms::autofocus) &&
nsContentUtils::GetBoolPref("browser.autofocus", PR_TRUE)) {
nsCOMPtr<nsIRunnable> event = new nsAutoFocusEvent(this);
rv = NS_DispatchToCurrentThread(event);
@ -2742,64 +2762,6 @@ nsGenericHTMLFormElement::IsHTMLFocusable(PRBool aWithMouse,
return PR_FALSE;
}
PRBool
nsGenericHTMLFormElement::IsSubmitControl() const
{
PRInt32 type = GetType();
return type == NS_FORM_INPUT_SUBMIT ||
type == NS_FORM_BUTTON_SUBMIT ||
type == NS_FORM_INPUT_IMAGE;
}
PRBool
nsGenericHTMLFormElement::IsTextControl(PRBool aExcludePassword) const
{
PRInt32 type = GetType();
return nsGenericHTMLFormElement::IsSingleLineTextControl(aExcludePassword) ||
type == NS_FORM_TEXTAREA;
}
PRBool
nsGenericHTMLFormElement::IsSingleLineTextControlInternal(PRBool aExcludePassword,
PRInt32 aType) const
{
return aType == NS_FORM_INPUT_TEXT ||
aType == NS_FORM_INPUT_EMAIL ||
aType == NS_FORM_INPUT_SEARCH ||
aType == NS_FORM_INPUT_TEL ||
aType == NS_FORM_INPUT_URL ||
(!aExcludePassword && aType == NS_FORM_INPUT_PASSWORD);
}
PRBool
nsGenericHTMLFormElement::IsSingleLineTextControl(PRBool aExcludePassword) const
{
return IsSingleLineTextControlInternal(aExcludePassword, GetType());
}
PRBool
nsGenericHTMLFormElement::IsLabelableControl() const
{
// Check for non-labelable form controls as they are not numerous.
// TODO: datalist should be added to this list.
PRInt32 type = GetType();
return type != NS_FORM_FIELDSET &&
type != NS_FORM_LABEL &&
type != NS_FORM_OBJECT;
}
PRBool
nsGenericHTMLFormElement::IsSubmittableControl() const
{
// TODO: keygen should be in that list, see bug 101019.
PRInt32 type = GetType();
return type == NS_FORM_OBJECT ||
type == NS_FORM_TEXTAREA ||
type == NS_FORM_SELECT ||
type & NS_FORM_BUTTON_ELEMENT ||
type & NS_FORM_INPUT_ELEMENT;
}
nsEventStates
nsGenericHTMLFormElement::IntrinsicState() const
{

View File

@ -686,26 +686,26 @@ protected:
NS_HIDDEN_(nsresult) SetUnsignedIntAttr(nsIAtom* aAttr, PRUint32 aValue);
/**
* Helper method for NS_IMPL_FLOAT_ATTR macro.
* Gets the float-value of an attribute, returns specified default value
* if the attribute isn't set or isn't set to a float. Only works for
* Helper method for NS_IMPL_DOUBLE_ATTR macro.
* Gets the double-value of an attribute, returns specified default value
* if the attribute isn't set or isn't set to a double. Only works for
* attributes in null namespace.
*
* @param aAttr name of attribute.
* @param aDefault default-value to return if attribute isn't set.
* @param aResult result value [out]
*/
NS_HIDDEN_(nsresult) GetFloatAttr(nsIAtom* aAttr, float aDefault, float* aValue);
NS_HIDDEN_(nsresult) GetDoubleAttr(nsIAtom* aAttr, double aDefault, double* aValue);
/**
* Helper method for NS_IMPL_FLOAT_ATTR macro.
* Sets value of attribute to specified float. Only works for attributes
* Helper method for NS_IMPL_DOUBLE_ATTR macro.
* Sets value of attribute to specified double. Only works for attributes
* in null namespace.
*
* @param aAttr name of attribute.
* @param aValue Float value of attribute.
* @param aValue Double value of attribute.
*/
NS_HIDDEN_(nsresult) SetFloatAttr(nsIAtom* aAttr, float aValue);
NS_HIDDEN_(nsresult) SetDoubleAttr(nsIAtom* aAttr, double aValue);
/**
* Helper for GetURIAttr and GetHrefURIForAnchors which returns an
@ -860,16 +860,6 @@ public:
{
return PR_TRUE;
}
virtual PRBool IsSubmitControl() const;
PRBool IsTextControl(PRBool aExcludePassword) const;
PRBool IsSingleLineTextControl(PRBool aExcludePassword) const;
PRBool IsLabelableControl() const;
PRBool IsSubmittableControl() const;
// nsIContent
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
@ -934,18 +924,8 @@ protected:
virtual nsresult AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAString* aValue, PRBool aNotify);
/**
* Returns if the element should react on autofocus attribute.
*/
virtual PRBool AcceptAutofocus() const
{
return PR_FALSE;
}
void UpdateEditableFormControlState();
PRBool IsSingleLineTextControlInternal(PRBool aExcludePassword, PRInt32 mType) const;
/**
* This method will update the form owner, using @form or looking to a parent.
*
@ -1209,23 +1189,23 @@ protected:
}
/**
* A macro to implement the getter and setter for a given float
* valued content property. The method uses the generic GetAttr and
* SetAttr methods.
* A macro to implement the getter and setter for a given double-precision
* floating point valued content property. The method uses GetDoubleAttr and
* SetDoubleAttr methods.
*/
#define NS_IMPL_FLOAT_ATTR(_class, _method, _atom) \
NS_IMPL_FLOAT_ATTR_DEFAULT_VALUE(_class, _method, _atom, 0.0)
#define NS_IMPL_DOUBLE_ATTR(_class, _method, _atom) \
NS_IMPL_DOUBLE_ATTR_DEFAULT_VALUE(_class, _method, _atom, 0.0)
#define NS_IMPL_FLOAT_ATTR_DEFAULT_VALUE(_class, _method, _atom, _default) \
#define NS_IMPL_DOUBLE_ATTR_DEFAULT_VALUE(_class, _method, _atom, _default) \
NS_IMETHODIMP \
_class::Get##_method(float* aValue) \
_class::Get##_method(double* aValue) \
{ \
return GetFloatAttr(nsGkAtoms::_atom, _default, aValue); \
return GetDoubleAttr(nsGkAtoms::_atom, _default, aValue); \
} \
NS_IMETHODIMP \
_class::Set##_method(float aValue) \
_class::Set##_method(double aValue) \
{ \
return SetFloatAttr(nsGkAtoms::_atom, aValue); \
return SetDoubleAttr(nsGkAtoms::_atom, aValue); \
}
/**

View File

@ -133,10 +133,11 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
nsRuleData* aData)
{
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Display)) {
if (aData->mDisplayData->mClear.GetUnit() == eCSSUnit_Null) {
nsCSSValue* clear = aData->ValueForClear();
if (clear->GetUnit() == eCSSUnit_Null) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::clear);
if (value && value->Type() == nsAttrValue::eEnum)
aData->mDisplayData->mClear.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
clear->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
}
}

View File

@ -136,7 +136,7 @@ NS_IMPL_ISUPPORTS1(BodyRule, nsIStyleRule)
/* virtual */ void
BodyRule::MapRuleInfoInto(nsRuleData* aData)
{
if (!aData || !(aData->mSIDs & NS_STYLE_INHERIT_BIT(Margin)) || !aData->mMarginData || !mPart)
if (!(aData->mSIDs & NS_STYLE_INHERIT_BIT(Margin)) || !mPart)
return; // We only care about margins.
PRInt32 bodyMarginWidth = -1;
@ -158,22 +158,24 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData)
if (value && value->Type() == nsAttrValue::eInteger) {
bodyMarginWidth = value->GetIntegerValue();
if (bodyMarginWidth < 0) bodyMarginWidth = 0;
nsCSSRect& margin = aData->mMarginData->mMargin;
if (margin.mLeft.GetUnit() == eCSSUnit_Null)
margin.mLeft.SetFloatValue((float)bodyMarginWidth, eCSSUnit_Pixel);
if (margin.mRight.GetUnit() == eCSSUnit_Null)
margin.mRight.SetFloatValue((float)bodyMarginWidth, eCSSUnit_Pixel);
nsCSSValue* marginLeft = aData->ValueForMarginLeftValue();
if (marginLeft->GetUnit() == eCSSUnit_Null)
marginLeft->SetFloatValue((float)bodyMarginWidth, eCSSUnit_Pixel);
nsCSSValue* marginRight = aData->ValueForMarginRightValue();
if (marginRight->GetUnit() == eCSSUnit_Null)
marginRight->SetFloatValue((float)bodyMarginWidth, eCSSUnit_Pixel);
}
value = mPart->GetParsedAttr(nsGkAtoms::marginheight);
if (value && value->Type() == nsAttrValue::eInteger) {
bodyMarginHeight = value->GetIntegerValue();
if (bodyMarginHeight < 0) bodyMarginHeight = 0;
nsCSSRect& margin = aData->mMarginData->mMargin;
if (margin.mTop.GetUnit() == eCSSUnit_Null)
margin.mTop.SetFloatValue((float)bodyMarginHeight, eCSSUnit_Pixel);
if (margin.mBottom.GetUnit() == eCSSUnit_Null)
margin.mBottom.SetFloatValue((float)bodyMarginHeight, eCSSUnit_Pixel);
nsCSSValue* marginTop = aData->ValueForMarginTop();
if (marginTop->GetUnit() == eCSSUnit_Null)
marginTop->SetFloatValue((float)bodyMarginHeight, eCSSUnit_Pixel);
nsCSSValue* marginBottom = aData->ValueForMarginBottom();
if (marginBottom->GetUnit() == eCSSUnit_Null)
marginBottom->SetFloatValue((float)bodyMarginHeight, eCSSUnit_Pixel);
}
if (eCompatibility_NavQuirks == mode){
@ -182,9 +184,9 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData)
if (value && value->Type() == nsAttrValue::eInteger) {
bodyTopMargin = value->GetIntegerValue();
if (bodyTopMargin < 0) bodyTopMargin = 0;
nsCSSRect& margin = aData->mMarginData->mMargin;
if (margin.mTop.GetUnit() == eCSSUnit_Null)
margin.mTop.SetFloatValue((float)bodyTopMargin, eCSSUnit_Pixel);
nsCSSValue* marginTop = aData->ValueForMarginTop();
if (marginTop->GetUnit() == eCSSUnit_Null)
marginTop->SetFloatValue((float)bodyTopMargin, eCSSUnit_Pixel);
}
// bottommargin (IE-attribute)
@ -192,9 +194,9 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData)
if (value && value->Type() == nsAttrValue::eInteger) {
bodyBottomMargin = value->GetIntegerValue();
if (bodyBottomMargin < 0) bodyBottomMargin = 0;
nsCSSRect& margin = aData->mMarginData->mMargin;
if (margin.mBottom.GetUnit() == eCSSUnit_Null)
margin.mBottom.SetFloatValue((float)bodyBottomMargin, eCSSUnit_Pixel);
nsCSSValue* marginBottom = aData->ValueForMarginBottom();
if (marginBottom->GetUnit() == eCSSUnit_Null)
marginBottom->SetFloatValue((float)bodyBottomMargin, eCSSUnit_Pixel);
}
// leftmargin (IE-attribute)
@ -202,9 +204,9 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData)
if (value && value->Type() == nsAttrValue::eInteger) {
bodyLeftMargin = value->GetIntegerValue();
if (bodyLeftMargin < 0) bodyLeftMargin = 0;
nsCSSRect& margin = aData->mMarginData->mMargin;
if (margin.mLeft.GetUnit() == eCSSUnit_Null)
margin.mLeft.SetFloatValue((float)bodyLeftMargin, eCSSUnit_Pixel);
nsCSSValue* marginLeft = aData->ValueForMarginLeftValue();
if (marginLeft->GetUnit() == eCSSUnit_Null)
marginLeft->SetFloatValue((float)bodyLeftMargin, eCSSUnit_Pixel);
}
// rightmargin (IE-attribute)
@ -212,9 +214,9 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData)
if (value && value->Type() == nsAttrValue::eInteger) {
bodyRightMargin = value->GetIntegerValue();
if (bodyRightMargin < 0) bodyRightMargin = 0;
nsCSSRect& margin = aData->mMarginData->mMargin;
if (margin.mRight.GetUnit() == eCSSUnit_Null)
margin.mRight.SetFloatValue((float)bodyRightMargin, eCSSUnit_Pixel);
nsCSSValue* marginRight = aData->ValueForMarginRightValue();
if (marginRight->GetUnit() == eCSSUnit_Null)
marginRight->SetFloatValue((float)bodyRightMargin, eCSSUnit_Pixel);
}
}
@ -245,19 +247,21 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData)
}
if ((bodyMarginWidth == -1) && (frameMarginWidth >= 0)) {
nsCSSRect& margin = aData->mMarginData->mMargin;
if (margin.mLeft.GetUnit() == eCSSUnit_Null)
margin.mLeft.SetFloatValue((float)frameMarginWidth, eCSSUnit_Pixel);
if (margin.mRight.GetUnit() == eCSSUnit_Null)
margin.mRight.SetFloatValue((float)frameMarginWidth, eCSSUnit_Pixel);
nsCSSValue* marginLeft = aData->ValueForMarginLeftValue();
if (marginLeft->GetUnit() == eCSSUnit_Null)
marginLeft->SetFloatValue((float)frameMarginWidth, eCSSUnit_Pixel);
nsCSSValue* marginRight = aData->ValueForMarginRightValue();
if (marginRight->GetUnit() == eCSSUnit_Null)
marginRight->SetFloatValue((float)frameMarginWidth, eCSSUnit_Pixel);
}
if ((bodyMarginHeight == -1) && (frameMarginHeight >= 0)) {
nsCSSRect& margin = aData->mMarginData->mMargin;
if (margin.mTop.GetUnit() == eCSSUnit_Null)
margin.mTop.SetFloatValue((float)frameMarginHeight, eCSSUnit_Pixel);
if (margin.mBottom.GetUnit() == eCSSUnit_Null)
margin.mBottom.SetFloatValue((float)frameMarginHeight, eCSSUnit_Pixel);
nsCSSValue* marginTop = aData->ValueForMarginTop();
if (marginTop->GetUnit() == eCSSUnit_Null)
marginTop->SetFloatValue((float)frameMarginHeight, eCSSUnit_Pixel);
nsCSSValue* marginBottom = aData->ValueForMarginBottom();
if (marginBottom->GetUnit() == eCSSUnit_Null)
marginBottom->SetFloatValue((float)frameMarginHeight, eCSSUnit_Pixel);
}
}
}
@ -389,13 +393,14 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aD
}
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Color)) {
if (aData->mColorData->mColor.GetUnit() == eCSSUnit_Null &&
nsCSSValue *colorValue = aData->ValueForColor();
if (colorValue->GetUnit() == eCSSUnit_Null &&
aData->mPresContext->UseDocumentColors()) {
// color: color
nscolor color;
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::text);
if (value && value->GetColorValue(color))
aData->mColorData->mColor.SetColorValue(color);
colorValue->SetColorValue(color);
}
}

View File

@ -137,11 +137,6 @@ public:
virtual nsXPCClassInfo* GetClassInfo();
protected:
virtual PRBool AcceptAutofocus() const
{
return PR_TRUE;
}
PRUint8 mType;
PRPackedBool mHandlingClick;
PRPackedBool mDisabledChanged;

View File

@ -126,8 +126,8 @@ nsHTMLCanvasElement::GetWidthHeight()
return size;
}
NS_IMPL_INT_ATTR_DEFAULT_VALUE(nsHTMLCanvasElement, Width, width, DEFAULT_CANVAS_WIDTH)
NS_IMPL_INT_ATTR_DEFAULT_VALUE(nsHTMLCanvasElement, Height, height, DEFAULT_CANVAS_HEIGHT)
NS_IMPL_UINT_ATTR_DEFAULT_VALUE(nsHTMLCanvasElement, Width, width, DEFAULT_CANVAS_WIDTH)
NS_IMPL_UINT_ATTR_DEFAULT_VALUE(nsHTMLCanvasElement, Height, height, DEFAULT_CANVAS_HEIGHT)
NS_IMPL_BOOL_ATTR(nsHTMLCanvasElement, MozOpaque, moz_opaque)
nsresult
@ -190,7 +190,7 @@ nsHTMLCanvasElement::ParseAttribute(PRInt32 aNamespaceID,
{
if (aNamespaceID == kNameSpaceID_None &&
(aAttribute == nsGkAtoms::width || aAttribute == nsGkAtoms::height)) {
return aResult.ParseIntWithBounds(aValue, 0);
return aResult.ParseNonNegativeIntValue(aValue);
}
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,

View File

@ -186,22 +186,22 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
nsRuleData* aData)
{
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Font)) {
nsRuleDataFont& font = *(aData->mFontData);
// face: string list
if (font.mFamily.GetUnit() == eCSSUnit_Null) {
nsCSSValue* family = aData->ValueForFontFamily();
if (family->GetUnit() == eCSSUnit_Null) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::face);
if (value && value->Type() == nsAttrValue::eString &&
!value->IsEmptyString()) {
font.mFamily.SetStringValue(value->GetStringValue(), eCSSUnit_Families);
family->SetStringValue(value->GetStringValue(), eCSSUnit_Families);
}
}
// pointSize: int
if (font.mSize.GetUnit() == eCSSUnit_Null) {
nsCSSValue* fontSize = aData->ValueForFontSize();
if (fontSize->GetUnit() == eCSSUnit_Null) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::pointSize);
if (value && value->Type() == nsAttrValue::eInteger)
font.mSize.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Point);
fontSize->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Point);
else {
// size: int, enum ,
value = aAttributes->GetAttr(nsGkAtoms::size);
@ -215,27 +215,29 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
size = value->GetIntegerValue();
size = ((0 < size) ? ((size < 8) ? size : 7) : 1);
font.mSize.SetIntValue(size, eCSSUnit_Enumerated);
fontSize->SetIntValue(size, eCSSUnit_Enumerated);
}
}
}
}
// fontWeight: int
if (font.mWeight.GetUnit() == eCSSUnit_Null) {
nsCSSValue* fontWeight = aData->ValueForFontWeight();
if (fontWeight->GetUnit() == eCSSUnit_Null) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::fontWeight);
if (value && value->Type() == nsAttrValue::eInteger) // +/-
font.mWeight.SetIntValue(value->GetIntegerValue(), eCSSUnit_Integer);
fontWeight->SetIntValue(value->GetIntegerValue(), eCSSUnit_Integer);
}
}
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Color)) {
if (aData->mColorData->mColor.GetUnit() == eCSSUnit_Null &&
nsCSSValue* colorValue = aData->ValueForColor();
if (colorValue->GetUnit() == eCSSUnit_Null &&
aData->mPresContext->UseDocumentColors()) {
// color: color
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::color);
nscolor color;
if (value && value->GetColorValue(color)) {
aData->mColorData->mColor.SetColorValue(color);
colorValue->SetColorValue(color);
}
}
}
@ -246,12 +248,12 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::color);
nscolor color;
if (value && value->GetColorValue(color)) {
nsCSSValue& decoration = aData->mTextData->mDecoration;
nsCSSValue* decoration = aData->ValueForTextDecoration();
PRInt32 newValue = NS_STYLE_TEXT_DECORATION_OVERRIDE_ALL;
if (decoration.GetUnit() == eCSSUnit_Enumerated) {
newValue |= decoration.GetIntValue();
if (decoration->GetUnit() == eCSSUnit_Enumerated) {
newValue |= decoration->GetIntValue();
}
decoration.SetIntValue(newValue, eCSSUnit_Enumerated);
decoration->SetIntValue(newValue, eCSSUnit_Enumerated);
}
}

View File

@ -43,6 +43,7 @@
#include "nsPresContext.h"
#include "nsMappedAttributes.h"
#include "nsRuleData.h"
#include "nsCSSProps.h"
class nsHTMLHRElement : public nsGenericHTMLElement,
public nsIDOMHTMLHRElement,
@ -175,45 +176,48 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
if (value && value->Type() == nsAttrValue::eEnum) {
// Map align attribute into auto side margins
nsCSSRect& margin = aData->mMarginData->mMargin;
nsCSSValue* marginLeft = aData->ValueForMarginLeftValue();
nsCSSValue* marginRight = aData->ValueForMarginRightValue();
switch (value->GetEnumValue()) {
case NS_STYLE_TEXT_ALIGN_LEFT:
if (margin.mLeft.GetUnit() == eCSSUnit_Null)
margin.mLeft.SetFloatValue(0.0f, eCSSUnit_Pixel);
if (margin.mRight.GetUnit() == eCSSUnit_Null)
margin.mRight.SetAutoValue();
if (marginLeft->GetUnit() == eCSSUnit_Null)
marginLeft->SetFloatValue(0.0f, eCSSUnit_Pixel);
if (marginRight->GetUnit() == eCSSUnit_Null)
marginRight->SetAutoValue();
break;
case NS_STYLE_TEXT_ALIGN_RIGHT:
if (margin.mLeft.GetUnit() == eCSSUnit_Null)
margin.mLeft.SetAutoValue();
if (margin.mRight.GetUnit() == eCSSUnit_Null)
margin.mRight.SetFloatValue(0.0f, eCSSUnit_Pixel);
if (marginLeft->GetUnit() == eCSSUnit_Null)
marginLeft->SetAutoValue();
if (marginRight->GetUnit() == eCSSUnit_Null)
marginRight->SetFloatValue(0.0f, eCSSUnit_Pixel);
break;
case NS_STYLE_TEXT_ALIGN_CENTER:
if (margin.mLeft.GetUnit() == eCSSUnit_Null)
margin.mLeft.SetAutoValue();
if (margin.mRight.GetUnit() == eCSSUnit_Null)
margin.mRight.SetAutoValue();
if (marginLeft->GetUnit() == eCSSUnit_Null)
marginLeft->SetAutoValue();
if (marginRight->GetUnit() == eCSSUnit_Null)
marginRight->SetAutoValue();
break;
}
}
}
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) {
// width: integer, percent
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
nsCSSValue* width = aData->ValueForWidth();
if (width->GetUnit() == eCSSUnit_Null) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
if (value && value->Type() == nsAttrValue::eInteger) {
aData->mPositionData->mWidth.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
width->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
} else if (value && value->Type() == nsAttrValue::ePercent) {
aData->mPositionData->mWidth.SetPercentValue(value->GetPercentValue());
width->SetPercentValue(value->GetPercentValue());
}
}
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
nsCSSValue* height = aData->ValueForHeight();
if (height->GetUnit() == eCSSUnit_Null) {
// size: integer
if (noshade) {
// noshade case: size is set using the border
aData->mPositionData->mHeight.SetAutoValue();
height->SetAutoValue();
} else {
// normal case
// the height includes the top and bottom borders that are initially 1px.
@ -221,7 +225,7 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
// removing all but the top border.
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::size);
if (value && value->Type() == nsAttrValue::eInteger) {
aData->mPositionData->mHeight.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
height->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
} // else use default value from html.css
}
}
@ -244,51 +248,57 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
} else {
sizePerSide = 1.0f; // default to a 2px high line
}
nsCSSRect& borderWidth = aData->mMarginData->mBorderWidth;
if (borderWidth.mTop.GetUnit() == eCSSUnit_Null) {
borderWidth.mTop.SetFloatValue(sizePerSide, eCSSUnit_Pixel);
nsCSSValue* borderTopWidth = aData->ValueForBorderTopWidth();
if (borderTopWidth->GetUnit() == eCSSUnit_Null) {
borderTopWidth->SetFloatValue(sizePerSide, eCSSUnit_Pixel);
}
if (allSides) {
if (borderWidth.mRight.GetUnit() == eCSSUnit_Null) {
borderWidth.mRight.SetFloatValue(sizePerSide, eCSSUnit_Pixel);
nsCSSValue* borderRightWidth = aData->ValueForBorderRightWidthValue();
if (borderRightWidth->GetUnit() == eCSSUnit_Null) {
borderRightWidth->SetFloatValue(sizePerSide, eCSSUnit_Pixel);
}
if (borderWidth.mBottom.GetUnit() == eCSSUnit_Null) {
borderWidth.mBottom.SetFloatValue(sizePerSide, eCSSUnit_Pixel);
nsCSSValue* borderBottomWidth = aData->ValueForBorderBottomWidth();
if (borderBottomWidth->GetUnit() == eCSSUnit_Null) {
borderBottomWidth->SetFloatValue(sizePerSide, eCSSUnit_Pixel);
}
if (borderWidth.mLeft.GetUnit() == eCSSUnit_Null) {
borderWidth.mLeft.SetFloatValue(sizePerSide, eCSSUnit_Pixel);
nsCSSValue* borderLeftWidth = aData->ValueForBorderLeftWidthValue();
if (borderLeftWidth->GetUnit() == eCSSUnit_Null) {
borderLeftWidth->SetFloatValue(sizePerSide, eCSSUnit_Pixel);
}
}
nsCSSRect& borderStyle = aData->mMarginData->mBorderStyle;
if (borderStyle.mTop.GetUnit() == eCSSUnit_Null) {
borderStyle.mTop.SetIntValue(NS_STYLE_BORDER_STYLE_SOLID,
eCSSUnit_Enumerated);
nsCSSValue* borderTopStyle = aData->ValueForBorderTopStyle();
if (borderTopStyle->GetUnit() == eCSSUnit_Null) {
borderTopStyle->SetIntValue(NS_STYLE_BORDER_STYLE_SOLID,
eCSSUnit_Enumerated);
}
if (allSides) {
if (borderStyle.mRight.GetUnit() == eCSSUnit_Null) {
borderStyle.mRight.SetIntValue(NS_STYLE_BORDER_STYLE_SOLID,
nsCSSValue* borderRightStyle = aData->ValueForBorderRightStyleValue();
if (borderRightStyle->GetUnit() == eCSSUnit_Null) {
borderRightStyle->SetIntValue(NS_STYLE_BORDER_STYLE_SOLID,
eCSSUnit_Enumerated);
}
nsCSSValue* borderBottomStyle = aData->ValueForBorderBottomStyle();
if (borderBottomStyle->GetUnit() == eCSSUnit_Null) {
borderBottomStyle->SetIntValue(NS_STYLE_BORDER_STYLE_SOLID,
eCSSUnit_Enumerated);
}
if (borderStyle.mBottom.GetUnit() == eCSSUnit_Null) {
borderStyle.mBottom.SetIntValue(NS_STYLE_BORDER_STYLE_SOLID,
eCSSUnit_Enumerated);
}
if (borderStyle.mLeft.GetUnit() == eCSSUnit_Null) {
borderStyle.mLeft.SetIntValue(NS_STYLE_BORDER_STYLE_SOLID,
eCSSUnit_Enumerated);
nsCSSValue* borderLeftStyle = aData->ValueForBorderLeftStyleValue();
if (borderLeftStyle->GetUnit() == eCSSUnit_Null) {
borderLeftStyle->SetIntValue(NS_STYLE_BORDER_STYLE_SOLID,
eCSSUnit_Enumerated);
}
// If it would be noticeable, set the border radius to
// 10000px on all corners; this triggers the clamping to make
// circular ends. This assumes the <hr> isn't larger than
// that in *both* dimensions.
nsCSSCornerSizes& corners = aData->mMarginData->mBorderRadius;
NS_FOR_CSS_FULL_CORNERS(c) {
nsCSSValue& dimen = corners.GetCorner(c);
if (dimen.GetUnit() == eCSSUnit_Null) {
dimen.SetFloatValue(10000.0f, eCSSUnit_Pixel);
for (const nsCSSProperty* props =
nsCSSProps::SubpropertyEntryFor(eCSSProperty_border_radius);
*props != eCSSProperty_UNKNOWN; ++props) {
nsCSSValue* dimen = aData->ValueFor(*props);
if (dimen->GetUnit() == eCSSUnit_Null) {
dimen->SetFloatValue(10000.0f, eCSSUnit_Pixel);
}
}
}
@ -296,10 +306,11 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Color)) {
// color: a color
// (we got the color attribute earlier)
nsCSSValue* colorValue = aData->ValueForColor();
if (colorIsSet &&
aData->mColorData->mColor.GetUnit() == eCSSUnit_Null &&
colorValue->GetUnit() == eCSSUnit_Null &&
aData->mPresContext->UseDocumentColors()) {
aData->mColorData->mColor.SetColorValue(color);
colorValue->SetColorValue(color);
}
}

View File

@ -202,34 +202,40 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
if (NS_STYLE_FRAME_0 == frameborder ||
NS_STYLE_FRAME_NO == frameborder ||
NS_STYLE_FRAME_OFF == frameborder) {
if (aData->mMarginData->mBorderWidth.mLeft.GetUnit() == eCSSUnit_Null)
aData->mMarginData->mBorderWidth.mLeft.SetFloatValue(0.0f, eCSSUnit_Pixel);
if (aData->mMarginData->mBorderWidth.mRight.GetUnit() == eCSSUnit_Null)
aData->mMarginData->mBorderWidth.mRight.SetFloatValue(0.0f, eCSSUnit_Pixel);
if (aData->mMarginData->mBorderWidth.mTop.GetUnit() == eCSSUnit_Null)
aData->mMarginData->mBorderWidth.mTop.SetFloatValue(0.0f, eCSSUnit_Pixel);
if (aData->mMarginData->mBorderWidth.mBottom.GetUnit() == eCSSUnit_Null)
aData->mMarginData->mBorderWidth.mBottom.SetFloatValue(0.0f, eCSSUnit_Pixel);
nsCSSValue* borderLeftWidth = aData->ValueForBorderLeftWidthValue();
if (borderLeftWidth->GetUnit() == eCSSUnit_Null)
borderLeftWidth->SetFloatValue(0.0f, eCSSUnit_Pixel);
nsCSSValue* borderRightWidth = aData->ValueForBorderRightWidthValue();
if (borderRightWidth->GetUnit() == eCSSUnit_Null)
borderRightWidth->SetFloatValue(0.0f, eCSSUnit_Pixel);
nsCSSValue* borderTopWidth = aData->ValueForBorderTopWidth();
if (borderTopWidth->GetUnit() == eCSSUnit_Null)
borderTopWidth->SetFloatValue(0.0f, eCSSUnit_Pixel);
nsCSSValue* borderBottomWidth = aData->ValueForBorderBottomWidth();
if (borderBottomWidth->GetUnit() == eCSSUnit_Null)
borderBottomWidth->SetFloatValue(0.0f, eCSSUnit_Pixel);
}
}
}
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) {
// width: value
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
nsCSSValue* width = aData->ValueForWidth();
if (width->GetUnit() == eCSSUnit_Null) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
if (value && value->Type() == nsAttrValue::eInteger)
aData->mPositionData->mWidth.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
width->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
else if (value && value->Type() == nsAttrValue::ePercent)
aData->mPositionData->mWidth.SetPercentValue(value->GetPercentValue());
width->SetPercentValue(value->GetPercentValue());
}
// height: value
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
nsCSSValue* height = aData->ValueForHeight();
if (height->GetUnit() == eCSSUnit_Null) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::height);
if (value && value->Type() == nsAttrValue::eInteger)
aData->mPositionData->mHeight.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
height->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
else if (value && value->Type() == nsAttrValue::ePercent)
aData->mPositionData->mHeight.SetPercentValue(value->GetPercentValue());
height->SetPercentValue(value->GetPercentValue());
}
}

View File

@ -723,9 +723,8 @@ nsHTMLInputElement::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
if (GetValueChanged()) {
// We don't have our default value anymore. Set our value on
// the clone.
// XXX GetValue should be const
nsAutoString value;
const_cast<nsHTMLInputElement*>(this)->GetValue(value);
GetValueInternal(value);
// SetValueInternal handles setting the VALUE_CHANGED bit for us
it->SetValueInternal(value, PR_FALSE, PR_TRUE);
}
@ -1040,8 +1039,14 @@ nsHTMLInputElement::SetIndeterminate(PRBool aValue)
return SetIndeterminateInternal(aValue, PR_TRUE);
}
NS_IMETHODIMP
NS_IMETHODIMP
nsHTMLInputElement::GetValue(nsAString& aValue)
{
return GetValueInternal(aValue);
}
nsresult
nsHTMLInputElement::GetValueInternal(nsAString& aValue) const
{
nsTextEditorState* state = GetEditorState();
if (state) {
@ -1077,6 +1082,15 @@ nsHTMLInputElement::GetValue(nsAString& aValue)
return NS_OK;
}
bool
nsHTMLInputElement::IsValueEmpty() const
{
nsAutoString value;
GetValueInternal(value);
return value.IsEmpty();
}
NS_IMETHODIMP
nsHTMLInputElement::SetValue(const nsAString& aValue)
{
@ -1377,7 +1391,7 @@ nsHTMLInputElement::SetFiles(const nsCOMArray<nsIDOMFile>& aFiles,
}
const nsCOMArray<nsIDOMFile>&
nsHTMLInputElement::GetFiles()
nsHTMLInputElement::GetFiles() const
{
return mFiles;
}
@ -2590,10 +2604,9 @@ nsHTMLInputElement::HandleTypeChange(PRUint8 aNewType)
}
// Only single line text inputs have a text editor state.
PRBool isNewTypeSingleLine =
IsSingleLineTextControlInternal(PR_FALSE, aNewType);
PRBool isCurrentTypeSingleLine =
IsSingleLineTextControl(PR_FALSE);
bool isNewTypeSingleLine = IsSingleLineTextControl(PR_FALSE, aNewType);
bool isCurrentTypeSingleLine = IsSingleLineTextControl(PR_FALSE, mType);
if (isNewTypeSingleLine && !isCurrentTypeSingleLine) {
FreeData();
mInputData.mState = new nsTextEditorState(this);
@ -3366,20 +3379,9 @@ nsHTMLInputElement::IntrinsicState() const
}
if (PlaceholderApplies() && HasAttr(kNameSpaceID_None, nsGkAtoms::placeholder) &&
!nsContentUtils::IsFocusedContent((nsIContent*)(this))) {
// TODO: we really need a GetValue(...) const method, see bug 585097
nsTextEditorState* edState = GetEditorState();
nsAutoString value;
if (edState) {
edState->GetValue(value, PR_TRUE);
} else {
GetAttr(kNameSpaceID_None, nsGkAtoms::value, value);
}
if (value.IsEmpty()) {
state |= NS_EVENT_STATE_MOZ_PLACEHOLDER;
}
!nsContentUtils::IsFocusedContent((nsIContent*)(this)) &&
IsValueEmpty()) {
state |= NS_EVENT_STATE_MOZ_PLACEHOLDER;
}
if (mForm && !mForm->GetValidity() && IsSubmitControl()) {
@ -3815,7 +3817,7 @@ nsHTMLInputElement::IsTooLong()
}
PRBool
nsHTMLInputElement::IsValueMissing()
nsHTMLInputElement::IsValueMissing() const
{
if (!HasAttr(kNameSpaceID_None, nsGkAtoms::required) ||
!DoesRequiredApply()) {
@ -3827,10 +3829,7 @@ nsHTMLInputElement::IsValueMissing()
return PR_FALSE;
}
nsAutoString value;
NS_ENSURE_SUCCESS(GetValue(value), PR_FALSE);
return value.IsEmpty();
return IsValueEmpty();
}
switch (mType)
@ -3848,14 +3847,14 @@ nsHTMLInputElement::IsValueMissing()
}
PRBool
nsHTMLInputElement::HasTypeMismatch()
nsHTMLInputElement::HasTypeMismatch() const
{
if (mType != NS_FORM_INPUT_EMAIL && mType != NS_FORM_INPUT_URL) {
return PR_FALSE;
}
nsAutoString value;
NS_ENSURE_SUCCESS(GetValue(value), PR_FALSE);
NS_ENSURE_SUCCESS(GetValueInternal(value), PR_FALSE);
if (value.IsEmpty()) {
return PR_FALSE;
@ -3887,7 +3886,7 @@ nsHTMLInputElement::HasTypeMismatch()
}
PRBool
nsHTMLInputElement::HasPatternMismatch()
nsHTMLInputElement::HasPatternMismatch() const
{
nsAutoString pattern;
if (!DoesPatternApply() ||
@ -3896,7 +3895,7 @@ nsHTMLInputElement::HasPatternMismatch()
}
nsAutoString value;
NS_ENSURE_SUCCESS(GetValue(value), PR_FALSE);
NS_ENSURE_SUCCESS(GetValueInternal(value), PR_FALSE);
if (value.IsEmpty()) {
return PR_FALSE;

View File

@ -214,9 +214,8 @@ public:
NS_IMETHOD_(void) InitializeKeyboardEventListeners();
NS_IMETHOD_(void) OnValueChanged(PRBool aNotify);
// nsIFileControlElement
void GetDisplayFileName(nsAString& aFileName) const;
const nsCOMArray<nsIDOMFile>& GetFiles();
const nsCOMArray<nsIDOMFile>& GetFiles() const;
void SetFiles(const nsCOMArray<nsIDOMFile>& aFiles, bool aSetValueChanged);
void SetCheckedChangedInternal(PRBool aCheckedChanged);
@ -271,9 +270,9 @@ public:
// nsIConstraintValidation
PRBool IsTooLong();
PRBool IsValueMissing();
PRBool HasTypeMismatch();
PRBool HasPatternMismatch();
PRBool IsValueMissing() const;
PRBool HasTypeMismatch() const;
PRBool HasPatternMismatch() const;
void UpdateTooLongValidityState();
void UpdateValueMissingValidityState();
void UpdateTypeMismatchValidityState();
@ -390,6 +389,15 @@ protected:
PRBool aUserInput,
PRBool aSetValueChanged);
nsresult GetValueInternal(nsAString& aValue) const;
/**
* Returns whether the current value is the empty string.
*
* @return whether the current value is the empty string.
*/
bool IsValueEmpty() const;
void ClearFiles(bool aSetValueChanged) {
nsCOMArray<nsIDOMFile> files;
SetFiles(files, aSetValueChanged);
@ -433,11 +441,6 @@ protected:
nsGkAtoms::image, eIgnoreCase);
}
virtual PRBool AcceptAutofocus() const
{
return PR_TRUE;
}
/**
* Visit the group of radio buttons this radio belongs to
* @param aVisitor the visitor to visit with
@ -523,7 +526,7 @@ protected:
/**
* Returns if the maxlength attribute applies for the current type.
*/
bool MaxLengthApplies() const { return IsSingleLineTextControlInternal(PR_FALSE, mType); }
bool MaxLengthApplies() const { return IsSingleLineTextControl(false, mType); }
void FreeData();
nsTextEditorState *GetEditorState() const;
@ -542,7 +545,7 @@ protected:
/**
* Returns whether the placeholder attribute applies for the current type.
*/
bool PlaceholderApplies() const { return IsSingleLineTextControlInternal(PR_FALSE, mType); }
bool PlaceholderApplies() const { return IsSingleLineTextControl(false, mType); }
/**
* Set the current default value to the value of the input element.

View File

@ -152,11 +152,12 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
nsRuleData* aData)
{
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(List)) {
if (aData->mListData->mType.GetUnit() == eCSSUnit_Null) {
nsCSSValue* listStyleType = aData->ValueForListStyleType();
if (listStyleType->GetUnit() == eCSSUnit_Null) {
// type: enum
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::type);
if (value && value->Type() == nsAttrValue::eEnum)
aData->mListData->mType.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
listStyleType->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
}
}

View File

@ -1426,7 +1426,7 @@ PRBool nsHTMLMediaElement::ParseAttribute(PRInt32 aNamespaceID,
|| aAttribute == nsGkAtoms::loopend
|| aAttribute == nsGkAtoms::start
|| aAttribute == nsGkAtoms::end) {
return aResult.ParseFloatValue(aValue);
return aResult.ParseDoubleValue(aValue);
}
else if (ParseImageAttribute(aAttribute, aValue, aResult)) {
return PR_TRUE;

View File

@ -199,14 +199,15 @@ static void
MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData)
{
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(List)) {
if (aData->mListData->mType.GetUnit() == eCSSUnit_Null) {
nsCSSValue* listStyleType = aData->ValueForListStyleType();
if (listStyleType->GetUnit() == eCSSUnit_Null) {
// type: enum
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::type);
if (value) {
if (value->Type() == nsAttrValue::eEnum)
aData->mListData->mType.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
listStyleType->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
else
aData->mListData->mType.SetIntValue(NS_STYLE_LIST_STYLE_DECIMAL, eCSSUnit_Enumerated);
listStyleType->SetIntValue(NS_STYLE_LIST_STYLE_DECIMAL, eCSSUnit_Enumerated);
}
}
}

View File

@ -43,9 +43,6 @@
#include "nsRuleData.h"
#include "nsCSSStruct.h"
// XXX wrap, variable, cols, tabstop
class nsHTMLPreElement : public nsGenericHTMLElement,
public nsIDOMHTMLPreElement
{
@ -138,14 +135,9 @@ static void
MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
nsRuleData* aData)
{
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Font)) {
// variable
if (aAttributes->GetAttr(nsGkAtoms::variable))
aData->mFontData->mFamily.SetStringValue(NS_LITERAL_STRING("serif"),
eCSSUnit_Families);
}
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) {
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
nsCSSValue* width = aData->ValueForWidth();
if (width->GetUnit() == eCSSUnit_Null) {
// width: int (html4 attribute == nav4 cols)
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
if (!value || value->Type() != nsAttrValue::eInteger) {
@ -154,14 +146,15 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
}
if (value && value->Type() == nsAttrValue::eInteger)
aData->mPositionData->mWidth.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Char);
width->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Char);
}
}
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Text)) {
if (aData->mTextData->mWhiteSpace.GetUnit() == eCSSUnit_Null) {
nsCSSValue* whiteSpace = aData->ValueForWhiteSpace();
if (whiteSpace->GetUnit() == eCSSUnit_Null) {
// wrap: empty
if (aAttributes->GetAttr(nsGkAtoms::wrap))
aData->mTextData->mWhiteSpace.SetIntValue(NS_STYLE_WHITESPACE_PRE_WRAP, eCSSUnit_Enumerated);
whiteSpace->SetIntValue(NS_STYLE_WHITESPACE_PRE_WRAP, eCSSUnit_Enumerated);
// width: int (html4 attribute == nav4 cols)
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
@ -173,7 +166,7 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
if (value && value->Type() == nsAttrValue::eInteger) {
// Force wrap property on since we want to wrap at a width
// boundary not just a newline.
aData->mTextData->mWhiteSpace.SetIntValue(NS_STYLE_WHITESPACE_PRE_WRAP, eCSSUnit_Enumerated);
whiteSpace->SetIntValue(NS_STYLE_WHITESPACE_PRE_WRAP, eCSSUnit_Enumerated);
}
}
}
@ -185,7 +178,6 @@ NS_IMETHODIMP_(PRBool)
nsHTMLPreElement::IsAttributeMapped(const nsIAtom* aAttribute) const
{
static const MappedAttributeEntry attributes[] = {
{ &nsGkAtoms::variable },
{ &nsGkAtoms::wrap },
{ &nsGkAtoms::cols },
{ &nsGkAtoms::width },

View File

@ -187,9 +187,8 @@ DOMCI_NODE_DATA(HTMLSelectElement, nsHTMLSelectElement)
// QueryInterface implementation for nsHTMLSelectElement
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLSelectElement)
NS_HTML_CONTENT_INTERFACE_TABLE4(nsHTMLSelectElement,
NS_HTML_CONTENT_INTERFACE_TABLE3(nsHTMLSelectElement,
nsIDOMHTMLSelectElement,
nsIDOMHTMLSelectElement_Mozilla_2_0_Branch,
nsISelectElement,
nsIConstraintValidation)
NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLSelectElement,
@ -1270,7 +1269,7 @@ NS_IMPL_BOOL_ATTR(nsHTMLSelectElement, Disabled, disabled)
NS_IMPL_BOOL_ATTR(nsHTMLSelectElement, Multiple, multiple)
NS_IMPL_STRING_ATTR(nsHTMLSelectElement, Name, name)
NS_IMPL_BOOL_ATTR(nsHTMLSelectElement, Required, required)
NS_IMPL_POSITIVE_INT_ATTR_DEFAULT_VALUE(nsHTMLSelectElement, Size, size, 0)
NS_IMPL_NON_NEGATIVE_INT_ATTR_DEFAULT_VALUE(nsHTMLSelectElement, Size, size, 0)
NS_IMPL_INT_ATTR(nsHTMLSelectElement, TabIndex, tabindex)
NS_IMETHODIMP

View File

@ -237,7 +237,7 @@ private:
* Implementation of &lt;select&gt;
*/
class nsHTMLSelectElement : public nsGenericHTMLFormElement,
public nsIDOMHTMLSelectElement_Mozilla_2_0_Branch,
public nsIDOMHTMLSelectElement,
public nsISelectElement,
public nsIConstraintValidation
{
@ -263,9 +263,6 @@ public:
// nsIDOMHTMLSelectElement
NS_DECL_NSIDOMHTMLSELECTELEMENT
// nsIDOMHTMLSelectElement_Mozilla_2_0_Branch
NS_DECL_NSIDOMHTMLSELECTELEMENT_MOZILLA_2_0_BRANCH
// nsIContent
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor);
@ -506,11 +503,6 @@ protected:
void VerifyOptionsArray();
#endif
virtual PRBool AcceptAutofocus() const
{
return PR_TRUE;
}
nsresult SetSelectedIndexInternal(PRInt32 aIndex, PRBool aNotify);
void SetSelectionChanged(PRBool aValue, PRBool aNotify);

View File

@ -340,14 +340,15 @@ DirectoryMenuMapAttributesIntoRule(const nsMappedAttributes* aAttributes,
nsRuleData* aData)
{
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(List)) {
if (aData->mListData->mType.GetUnit() == eCSSUnit_Null) {
nsCSSValue* listStyleType = aData->ValueForListStyleType();
if (listStyleType->GetUnit() == eCSSUnit_Null) {
// type: enum
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::type);
if (value) {
if (value->Type() == nsAttrValue::eEnum) {
aData->mListData->mType.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
listStyleType->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
} else {
aData->mListData->mType.SetIntValue(NS_STYLE_LIST_STYLE_DISC, eCSSUnit_Enumerated);
listStyleType->SetIntValue(NS_STYLE_LIST_STYLE_DISC, eCSSUnit_Enumerated);
}
}
}

View File

@ -137,10 +137,11 @@ static
void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData)
{
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(TableBorder)) {
if (aData->mTableData->mCaptionSide.GetUnit() == eCSSUnit_Null) {
nsCSSValue* captionSide = aData->ValueForCaptionSide();
if (captionSide->GetUnit() == eCSSUnit_Null) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
if (value && value->Type() == nsAttrValue::eEnum)
aData->mTableData->mCaptionSide.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
captionSide->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
}
}

View File

@ -334,44 +334,48 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
{
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) {
// width: value
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
nsCSSValue* width = aData->ValueForWidth();
if (width->GetUnit() == eCSSUnit_Null) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
if (value && value->Type() == nsAttrValue::eInteger) {
if (value->GetIntegerValue() > 0)
aData->mPositionData->mWidth.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
width->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
// else 0 implies auto for compatibility.
}
else if (value && value->Type() == nsAttrValue::ePercent) {
if (value->GetPercentValue() > 0.0f)
aData->mPositionData->mWidth.SetPercentValue(value->GetPercentValue());
width->SetPercentValue(value->GetPercentValue());
// else 0 implies auto for compatibility
}
}
// height: value
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
nsCSSValue* height = aData->ValueForHeight();
if (height->GetUnit() == eCSSUnit_Null) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::height);
if (value && value->Type() == nsAttrValue::eInteger) {
if (value->GetIntegerValue() > 0)
aData->mPositionData->mHeight.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
height->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
// else 0 implies auto for compatibility.
}
else if (value && value->Type() == nsAttrValue::ePercent) {
if (value->GetPercentValue() > 0.0f)
aData->mPositionData->mHeight.SetPercentValue(value->GetPercentValue());
height->SetPercentValue(value->GetPercentValue());
// else 0 implies auto for compatibility
}
}
}
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Text)) {
if (aData->mTextData->mTextAlign.GetUnit() == eCSSUnit_Null) {
nsCSSValue* textAlign = aData->ValueForTextAlign();
if (textAlign->GetUnit() == eCSSUnit_Null) {
// align: enum
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
if (value && value->Type() == nsAttrValue::eEnum)
aData->mTextData->mTextAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
textAlign->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
}
if (aData->mTextData->mWhiteSpace.GetUnit() == eCSSUnit_Null) {
nsCSSValue* whiteSpace = aData->ValueForWhiteSpace();
if (whiteSpace->GetUnit() == eCSSUnit_Null) {
// nowrap: enum
if (aAttributes->GetAttr(nsGkAtoms::nowrap)) {
// See if our width is not a nonzero integer width.
@ -380,18 +384,18 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
if (!value || value->Type() != nsAttrValue::eInteger ||
value->GetIntegerValue() == 0 ||
eCompatibility_NavQuirks != mode) {
aData->mTextData->mWhiteSpace.SetIntValue(NS_STYLE_WHITESPACE_NOWRAP, eCSSUnit_Enumerated);
whiteSpace->SetIntValue(NS_STYLE_WHITESPACE_NOWRAP, eCSSUnit_Enumerated);
}
}
}
}
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(TextReset)) {
if (aData->mTextData->mVerticalAlign.GetUnit() == eCSSUnit_Null) {
nsCSSValue* verticalAlign = aData->ValueForVerticalAlign();
if (verticalAlign->GetUnit() == eCSSUnit_Null) {
// valign: enum
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::valign);
if (value && value->Type() == nsAttrValue::eEnum)
aData->mTextData->mVerticalAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
verticalAlign->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
}
}

View File

@ -152,54 +152,59 @@ nsHTMLTableColElement::ParseAttribute(PRInt32 aNamespaceID,
static
void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData)
{
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Table) &&
aData->mTableData->mSpan.GetUnit() == eCSSUnit_Null) {
// span: int
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::span);
if (value && value->Type() == nsAttrValue::eInteger) {
PRInt32 val = value->GetIntegerValue();
// Note: Do NOT use this code for table cells! The value "0"
// means something special for colspan and rowspan, but for <col
// span> and <colgroup span> it's just disallowed.
if (val > 0) {
aData->mTableData->mSpan.SetIntValue(value->GetIntegerValue(),
eCSSUnit_Integer);
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Table)) {
nsCSSValue *span = aData->ValueForSpan();
if (span->GetUnit() == eCSSUnit_Null) {
// span: int
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::span);
if (value && value->Type() == nsAttrValue::eInteger) {
PRInt32 val = value->GetIntegerValue();
// Note: Do NOT use this code for table cells! The value "0"
// means something special for colspan and rowspan, but for <col
// span> and <colgroup span> it's just disallowed.
if (val > 0) {
span->SetIntValue(value->GetIntegerValue(), eCSSUnit_Integer);
}
}
}
}
if ((aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) &&
aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
// width
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
if (value) {
switch (value->Type()) {
case nsAttrValue::ePercent: {
aData->mPositionData->mWidth.SetPercentValue(value->GetPercentValue());
break;
}
case nsAttrValue::eInteger: {
aData->mPositionData->mWidth.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
break;
}
default:
break;
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) {
nsCSSValue* width = aData->ValueForWidth();
if (width->GetUnit() == eCSSUnit_Null) {
// width
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
if (value) {
switch (value->Type()) {
case nsAttrValue::ePercent: {
width->SetPercentValue(value->GetPercentValue());
break;
}
case nsAttrValue::eInteger: {
width->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
break;
}
default:
break;
}
}
}
}
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Text)) {
if (aData->mTextData->mTextAlign.GetUnit() == eCSSUnit_Null) {
nsCSSValue* textAlign = aData->ValueForTextAlign();
if (textAlign->GetUnit() == eCSSUnit_Null) {
// align: enum
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
if (value && value->Type() == nsAttrValue::eEnum)
aData->mTextData->mTextAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
textAlign->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
}
}
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(TextReset)) {
if (aData->mTextData->mVerticalAlign.GetUnit() == eCSSUnit_Null) {
nsCSSValue* verticalAlign = aData->ValueForVerticalAlign();
if (verticalAlign->GetUnit() == eCSSUnit_Null) {
// valign: enum
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::valign);
if (value && value->Type() == nsAttrValue::eEnum)
aData->mTextData->mVerticalAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
verticalAlign->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
}
}

View File

@ -1063,16 +1063,17 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
if (readDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE_CELL) {
// cellspacing
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::cellspacing);
nsCSSValue* borderSpacing = aData->ValueForBorderSpacing();
if (value && value->Type() == nsAttrValue::eInteger) {
if (aData->mTableData->mBorderSpacing.GetUnit() == eCSSUnit_Null)
aData->mTableData->mBorderSpacing.
if (borderSpacing->GetUnit() == eCSSUnit_Null)
borderSpacing->
SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
}
else if (value && value->Type() == nsAttrValue::ePercent &&
eCompatibility_NavQuirks == mode) {
// in quirks mode, treat a % cellspacing value a pixel value.
if (aData->mTableData->mBorderSpacing.GetUnit() == eCSSUnit_Null)
aData->mTableData->mBorderSpacing.
if (borderSpacing->GetUnit() == eCSSUnit_Null)
borderSpacing->
SetFloatValue(100.0f * value->GetPercentValue(), eCSSUnit_Pixel);
}
}
@ -1082,19 +1083,21 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
if (readDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE_CELL) {
const nsAttrValue* value;
// layout
if (aData->mTableData->mLayout.GetUnit() == eCSSUnit_Null) {
nsCSSValue* tableLayout = aData->ValueForTableLayout();
if (tableLayout->GetUnit() == eCSSUnit_Null) {
value = aAttributes->GetAttr(nsGkAtoms::layout);
if (value && value->Type() == nsAttrValue::eEnum)
aData->mTableData->mLayout.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
tableLayout->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
}
// cols
value = aAttributes->GetAttr(nsGkAtoms::cols);
if (value) {
nsCSSValue* cols = aData->ValueForCols();
if (value->Type() == nsAttrValue::eInteger)
aData->mTableData->mCols.SetIntValue(value->GetIntegerValue(), eCSSUnit_Integer);
cols->SetIntValue(value->GetIntegerValue(), eCSSUnit_Integer);
else // COLS had no value, so it refers to all columns
aData->mTableData->mCols.SetIntValue(NS_STYLE_TABLE_COLS_ALL, eCSSUnit_Enumerated);
cols->SetIntValue(NS_STYLE_TABLE_COLS_ALL, eCSSUnit_Enumerated);
}
}
}
@ -1109,11 +1112,12 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
if (value && value->Type() == nsAttrValue::eEnum) {
if (value->GetEnumValue() == NS_STYLE_TEXT_ALIGN_CENTER ||
value->GetEnumValue() == NS_STYLE_TEXT_ALIGN_MOZ_CENTER) {
nsCSSRect& margin = aData->mMarginData->mMargin;
if (margin.mLeft.GetUnit() == eCSSUnit_Null)
margin.mLeft.SetAutoValue();
if (margin.mRight.GetUnit() == eCSSUnit_Null)
margin.mRight.SetAutoValue();
nsCSSValue* marginLeft = aData->ValueForMarginLeftValue();
if (marginLeft->GetUnit() == eCSSUnit_Null)
marginLeft->SetAutoValue();
nsCSSValue* marginRight = aData->ValueForMarginRightValue();
if (marginRight->GetUnit() == eCSSUnit_Null)
marginRight->SetAutoValue();
}
}
@ -1124,21 +1128,23 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
value = aAttributes->GetAttr(nsGkAtoms::hspace);
if (value && value->Type() == nsAttrValue::eInteger) {
nsCSSRect& margin = aData->mMarginData->mMargin;
if (margin.mLeft.GetUnit() == eCSSUnit_Null)
margin.mLeft.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
if (margin.mRight.GetUnit() == eCSSUnit_Null)
margin.mRight.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
nsCSSValue* marginLeft = aData->ValueForMarginLeftValue();
if (marginLeft->GetUnit() == eCSSUnit_Null)
marginLeft->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
nsCSSValue* marginRight = aData->ValueForMarginRightValue();
if (marginRight->GetUnit() == eCSSUnit_Null)
marginRight->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
}
value = aAttributes->GetAttr(nsGkAtoms::vspace);
if (value && value->Type() == nsAttrValue::eInteger) {
nsCSSRect& margin = aData->mMarginData->mMargin;
if (margin.mTop.GetUnit() == eCSSUnit_Null)
margin.mTop.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
if (margin.mBottom.GetUnit() == eCSSUnit_Null)
margin.mBottom.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
nsCSSValue* marginTop = aData->ValueForMarginTop();
if (marginTop->GetUnit() == eCSSUnit_Null)
marginTop->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
nsCSSValue* marginBottom = aData->ValueForMarginBottom();
if (marginBottom->GetUnit() == eCSSUnit_Null)
marginBottom->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
}
}
}
@ -1166,14 +1172,18 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
// padVal.SetPercentValue(pctVal);
//}
}
if (aData->mMarginData->mPadding.mLeft.GetUnit() == eCSSUnit_Null)
aData->mMarginData->mPadding.mLeft = padVal;
if (aData->mMarginData->mPadding.mRight.GetUnit() == eCSSUnit_Null)
aData->mMarginData->mPadding.mRight = padVal;
if (aData->mMarginData->mPadding.mTop.GetUnit() == eCSSUnit_Null)
aData->mMarginData->mPadding.mTop = padVal;
if (aData->mMarginData->mPadding.mBottom.GetUnit() == eCSSUnit_Null)
aData->mMarginData->mPadding.mBottom = padVal;
nsCSSValue* paddingLeft = aData->ValueForPaddingLeftValue();
if (paddingLeft->GetUnit() == eCSSUnit_Null)
*paddingLeft = padVal;
nsCSSValue* paddingRight = aData->ValueForPaddingRightValue();
if (paddingRight->GetUnit() == eCSSUnit_Null)
*paddingRight = padVal;
nsCSSValue* paddingTop = aData->ValueForPaddingTop();
if (paddingTop->GetUnit() == eCSSUnit_Null)
*paddingTop = padVal;
nsCSSValue* paddingBottom = aData->ValueForPaddingBottom();
if (paddingBottom->GetUnit() == eCSSUnit_Null)
*paddingBottom = padVal;
}
}
}
@ -1183,21 +1193,23 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
if (readDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE_CELL) {
// width: value
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
nsCSSValue* width = aData->ValueForWidth();
if (width->GetUnit() == eCSSUnit_Null) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
if (value && value->Type() == nsAttrValue::eInteger)
aData->mPositionData->mWidth.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
width->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
else if (value && value->Type() == nsAttrValue::ePercent)
aData->mPositionData->mWidth.SetPercentValue(value->GetPercentValue());
width->SetPercentValue(value->GetPercentValue());
}
// height: value
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
nsCSSValue* height = aData->ValueForHeight();
if (height->GetUnit() == eCSSUnit_Null) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::height);
if (value && value->Type() == nsAttrValue::eInteger)
aData->mPositionData->mHeight.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
height->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
else if (value && value->Type() == nsAttrValue::ePercent)
aData->mPositionData->mHeight.SetPercentValue(value->GetPercentValue());
height->SetPercentValue(value->GetPercentValue());
}
}
}
@ -1215,14 +1227,18 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
nscolor color;
if (value && presContext->UseDocumentColors() &&
value->GetColorValue(color)) {
if (aData->mMarginData->mBorderColor.mLeft.GetUnit() == eCSSUnit_Null)
aData->mMarginData->mBorderColor.mLeft.SetColorValue(color);
if (aData->mMarginData->mBorderColor.mRight.GetUnit() == eCSSUnit_Null)
aData->mMarginData->mBorderColor.mRight.SetColorValue(color);
if (aData->mMarginData->mBorderColor.mTop.GetUnit() == eCSSUnit_Null)
aData->mMarginData->mBorderColor.mTop.SetColorValue(color);
if (aData->mMarginData->mBorderColor.mBottom.GetUnit() == eCSSUnit_Null)
aData->mMarginData->mBorderColor.mBottom.SetColorValue(color);
nsCSSValue* borderLeftColor = aData->ValueForBorderLeftColorValue();
if (borderLeftColor->GetUnit() == eCSSUnit_Null)
borderLeftColor->SetColorValue(color);
nsCSSValue* borderRightColor = aData->ValueForBorderRightColorValue();
if (borderRightColor->GetUnit() == eCSSUnit_Null)
borderRightColor->SetColorValue(color);
nsCSSValue* borderTopColor = aData->ValueForBorderTopColor();
if (borderTopColor->GetUnit() == eCSSUnit_Null)
borderTopColor->SetColorValue(color);
nsCSSValue* borderBottomColor = aData->ValueForBorderBottomColor();
if (borderBottomColor->GetUnit() == eCSSUnit_Null)
borderBottomColor->SetColorValue(color);
}
// border
@ -1235,14 +1251,18 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
borderThickness = borderValue->GetIntegerValue();
// by default, set all border sides to the specified width
if (aData->mMarginData->mBorderWidth.mLeft.GetUnit() == eCSSUnit_Null)
aData->mMarginData->mBorderWidth.mLeft.SetFloatValue((float)borderThickness, eCSSUnit_Pixel);
if (aData->mMarginData->mBorderWidth.mRight.GetUnit() == eCSSUnit_Null)
aData->mMarginData->mBorderWidth.mRight.SetFloatValue((float)borderThickness, eCSSUnit_Pixel);
if (aData->mMarginData->mBorderWidth.mTop.GetUnit() == eCSSUnit_Null)
aData->mMarginData->mBorderWidth.mTop .SetFloatValue((float)borderThickness, eCSSUnit_Pixel);
if (aData->mMarginData->mBorderWidth.mBottom.GetUnit() == eCSSUnit_Null)
aData->mMarginData->mBorderWidth.mBottom.SetFloatValue((float)borderThickness, eCSSUnit_Pixel);
nsCSSValue* borderLeftWidth = aData->ValueForBorderLeftWidthValue();
if (borderLeftWidth->GetUnit() == eCSSUnit_Null)
borderLeftWidth->SetFloatValue((float)borderThickness, eCSSUnit_Pixel);
nsCSSValue* borderRightWidth = aData->ValueForBorderRightWidthValue();
if (borderRightWidth->GetUnit() == eCSSUnit_Null)
borderRightWidth->SetFloatValue((float)borderThickness, eCSSUnit_Pixel);
nsCSSValue* borderTopWidth = aData->ValueForBorderTopWidth();
if (borderTopWidth->GetUnit() == eCSSUnit_Null)
borderTopWidth->SetFloatValue((float)borderThickness, eCSSUnit_Pixel);
nsCSSValue* borderBottomWidth = aData->ValueForBorderBottomWidth();
if (borderBottomWidth->GetUnit() == eCSSUnit_Null)
borderBottomWidth->SetFloatValue((float)borderThickness, eCSSUnit_Pixel);
}
}
}

View File

@ -408,28 +408,31 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aD
{
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) {
// height: value
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
nsCSSValue* height = aData->ValueForHeight();
if (height->GetUnit() == eCSSUnit_Null) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::height);
if (value && value->Type() == nsAttrValue::eInteger)
aData->mPositionData->mHeight.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
height->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
else if (value && value->Type() == nsAttrValue::ePercent)
aData->mPositionData->mHeight.SetPercentValue(value->GetPercentValue());
height->SetPercentValue(value->GetPercentValue());
}
}
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Text)) {
if (aData->mTextData->mTextAlign.GetUnit() == eCSSUnit_Null) {
nsCSSValue* textAlign = aData->ValueForTextAlign();
if (textAlign->GetUnit() == eCSSUnit_Null) {
// align: enum
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
if (value && value->Type() == nsAttrValue::eEnum)
aData->mTextData->mTextAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
textAlign->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
}
}
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(TextReset)) {
if (aData->mTextData->mVerticalAlign.GetUnit() == eCSSUnit_Null) {
nsCSSValue* verticalAlign = aData->ValueForVerticalAlign();
if (verticalAlign->GetUnit() == eCSSUnit_Null) {
// valign: enum
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::valign);
if (value && value->Type() == nsAttrValue::eEnum)
aData->mTextData->mVerticalAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
verticalAlign->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
}
}

View File

@ -274,26 +274,29 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aD
{
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) {
// height: value
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
nsCSSValue* height = aData->ValueForHeight();
if (height->GetUnit() == eCSSUnit_Null) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::height);
if (value && value->Type() == nsAttrValue::eInteger)
aData->mPositionData->mHeight.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
height->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
}
}
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Text)) {
if (aData->mTextData->mTextAlign.GetUnit() == eCSSUnit_Null) {
nsCSSValue* textAlign = aData->ValueForTextAlign();
if (textAlign->GetUnit() == eCSSUnit_Null) {
// align: enum
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
if (value && value->Type() == nsAttrValue::eEnum)
aData->mTextData->mTextAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
textAlign->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
}
}
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(TextReset)) {
if (aData->mTextData->mVerticalAlign.GetUnit() == eCSSUnit_Null) {
nsCSSValue* verticalAlign = aData->ValueForVerticalAlign();
if (verticalAlign->GetUnit() == eCSSUnit_Null) {
// valign: enum
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::valign);
if (value && value->Type() == nsAttrValue::eEnum)
aData->mTextData->mVerticalAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
verticalAlign->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
}
}

View File

@ -260,11 +260,6 @@ protected:
PRBool aUserInput);
nsresult GetSelectionRange(PRInt32* aSelectionStart, PRInt32* aSelectionEnd);
virtual PRBool AcceptAutofocus() const
{
return PR_TRUE;
}
/**
* Common method to call from the various mutation observer methods.
* aContent is a content node that's either the one that changed or its
@ -456,13 +451,13 @@ nsHTMLTextAreaElement::IsHTMLFocusable(PRBool aWithMouse,
NS_IMPL_STRING_ATTR(nsHTMLTextAreaElement, AccessKey, accesskey)
NS_IMPL_BOOL_ATTR(nsHTMLTextAreaElement, Autofocus, autofocus)
NS_IMPL_INT_ATTR_DEFAULT_VALUE(nsHTMLTextAreaElement, Cols, cols, 20)
NS_IMPL_UINT_ATTR_NON_ZERO_DEFAULT_VALUE(nsHTMLTextAreaElement, Cols, cols, DEFAULT_COLS)
NS_IMPL_BOOL_ATTR(nsHTMLTextAreaElement, Disabled, disabled)
NS_IMPL_NON_NEGATIVE_INT_ATTR(nsHTMLTextAreaElement, MaxLength, maxlength)
NS_IMPL_STRING_ATTR(nsHTMLTextAreaElement, Name, name)
NS_IMPL_BOOL_ATTR(nsHTMLTextAreaElement, ReadOnly, readonly)
NS_IMPL_BOOL_ATTR(nsHTMLTextAreaElement, Required, required)
NS_IMPL_INT_ATTR_DEFAULT_VALUE(nsHTMLTextAreaElement, Rows, rows, 2)
NS_IMPL_UINT_ATTR_NON_ZERO_DEFAULT_VALUE(nsHTMLTextAreaElement, Rows, rows, DEFAULT_ROWS_TEXTAREA)
NS_IMPL_INT_ATTR(nsHTMLTextAreaElement, TabIndex, tabindex)
NS_IMPL_STRING_ATTR(nsHTMLTextAreaElement, Wrap, wrap)
NS_IMPL_STRING_ATTR(nsHTMLTextAreaElement, Placeholder, placeholder)
@ -641,12 +636,9 @@ nsHTMLTextAreaElement::ParseAttribute(PRInt32 aNamespaceID,
if (aNamespaceID == kNameSpaceID_None) {
if (aAttribute == nsGkAtoms::maxlength) {
return aResult.ParseNonNegativeIntValue(aValue);
}
if (aAttribute == nsGkAtoms::cols) {
return aResult.ParseIntWithBounds(aValue, 0);
}
if (aAttribute == nsGkAtoms::rows) {
return aResult.ParseIntWithBounds(aValue, 0);
} else if (aAttribute == nsGkAtoms::cols ||
aAttribute == nsGkAtoms::rows) {
return aResult.ParsePositiveIntValue(aValue);
}
}
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,

View File

@ -255,6 +255,9 @@ _TEST_FILES = \
test_bug622558.html \
test_bug622597.html \
test_bug636336.html \
test_bug630889.html \
test_bug610212.html \
test_bug633058.html \
$(NULL)
libs:: $(_TEST_FILES)

View File

@ -219,7 +219,7 @@ HTML_TAG("s", ""); // HTMLElement
HTML_TAG("samp", ""); // HTMLElement
HTML_TAG("script", "Script", [], [ "nsIScriptLoaderObserver" ]);
HTML_TAG("section", "") // HTMLElement
HTML_TAG("select", "Select", ["nsIDOMHTMLSelectElement_Mozilla_2_0_Branch"]);
HTML_TAG("select", "Select", ["nsIDOMHTMLSelectElement"]);
HTML_TAG("small", ""); // HTMLElement
HTML_TAG("span", "Span");
HTML_TAG("strike", ""); // HTMLElement

View File

@ -37,8 +37,10 @@ function checkSizeReflection(element, defaultValue)
"The content attribute should containt the previously set value");
element.setAttribute('size', 0);
is(element.size, defaultValue,
"The reflecting IDL attribute should return the default value when content attribute value is invalid");
is(element.size, 0,
"0 should be considered as a valid value");
is(element.getAttribute('size'), 0,
"The content attribute should containt the previously set value");
element.setAttribute('size', 2147483647); /* PR_INT32_MAX */
is(element.size, 2147483647,
@ -92,7 +94,7 @@ function checkSetSizeException(element)
} catch(e) {
caught = true;
}
ok(!caught, "Setting a valid size shouldn't throw an exception");
ok(!caught, "Setting a positive size shouldn't throw an exception");
caught = false;
try {
@ -100,7 +102,7 @@ function checkSetSizeException(element)
} catch(e) {
caught = true;
}
ok(caught, "Setting an invalid size from the IDL should throw an exception");
ok(!caught, "Setting a size to 0 from the IDL shouldn't throw an exception");
caught = false;
try {

View File

@ -0,0 +1,31 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=610212
-->
<head>
<title>Test for Bug 610212</title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="reflect.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=610212">Mozilla Bug 610212</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 610212 **/
var canvas = document.createElement('canvas');
reflectUnsignedInt(canvas, "width", false, 300);
reflectUnsignedInt(canvas, "height", false, 150);
</script>
</pre>
</body>
</html>

View File

@ -0,0 +1,28 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=630889
-->
<head>
<title>Test for Bug 630889</title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="reflect.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=630889">Mozilla Bug 630889</a>
<p id="display"></p>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 630889 **/
var textarea = document.createElement('textarea');
reflectUnsignedInt(textarea, "rows", true, 2);
reflectUnsignedInt(textarea, "cols", true, 20);
</script>
</pre>
</body>
</html>

View File

@ -0,0 +1,66 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=633058
-->
<head>
<title>Test for Bug 633058</title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=633058">Mozilla Bug 633058</a>
<p id="display"></p>
<div id="content">
<input>
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 633058 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var nbExpectedKeyPress = 8;
var inputGotKeyPress = 0;
var divGotKeyPress = 0;
var input = document.getElementsByTagName('input')[0];
var content = document.getElementById('content');
content.addEventListener('keypress', function() {
divGotKeyPress++;
if (divGotKeyPress == nbExpectedKeyPress) {
is(inputGotKeyPress, nbExpectedKeyPress, "input got all keypress events");
is(divGotKeyPress, nbExpectedKeyPress, "div got all keypress events");
SimpleTest.finish();
}
}, false);
input.addEventListener('keypress', function() {
inputGotKeyPress++;
}, false);
input.addEventListener('focus', function() {
input.removeEventListener('focus', arguments.callee, false);
synthesizeKey('VK_UP', {});
synthesizeKey('VK_LEFT', {});
synthesizeKey('VK_RIGHT', {});
synthesizeKey('VK_DOWN', {});
synthesizeKey('VK_BACK_SPACE', {});
synthesizeKey('VK_DELETE', {});
synthesizeKey('VK_ESCAPE', {});
synthesizeKey('VK_RETURN', {});
}, false);
input.focus();
});
</script>
</pre>
</body>
</html>

View File

@ -326,8 +326,10 @@ nsMathMLElement::MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Font)) {
const nsAttrValue* value =
aAttributes->GetAttr(nsGkAtoms::scriptsizemultiplier_);
nsCSSValue* scriptSizeMultiplier =
aData->ValueForScriptSizeMultiplier();
if (value && value->Type() == nsAttrValue::eString &&
aData->mFontData->mScriptSizeMultiplier.GetUnit() == eCSSUnit_Null) {
scriptSizeMultiplier->GetUnit() == eCSSUnit_Null) {
nsAutoString str(value->GetStringValue());
str.CompressWhitespace();
// MathML numbers can't have leading '+'
@ -336,22 +338,22 @@ nsMathMLElement::MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
float floatValue = str.ToFloat(&errorCode);
// Negative scriptsizemultipliers are not parsed
if (NS_SUCCEEDED(errorCode) && floatValue >= 0.0f) {
aData->mFontData->mScriptSizeMultiplier.
SetFloatValue(floatValue, eCSSUnit_Number);
scriptSizeMultiplier->SetFloatValue(floatValue, eCSSUnit_Number);
}
}
}
value = aAttributes->GetAttr(nsGkAtoms::scriptminsize_);
nsCSSValue* scriptMinSize = aData->ValueForScriptMinSize();
if (value && value->Type() == nsAttrValue::eString &&
aData->mFontData->mScriptMinSize.GetUnit() == eCSSUnit_Null) {
ParseNumericValue(value->GetStringValue(),
aData->mFontData->mScriptMinSize, 0);
scriptMinSize->GetUnit() == eCSSUnit_Null) {
ParseNumericValue(value->GetStringValue(), *scriptMinSize, 0);
}
value = aAttributes->GetAttr(nsGkAtoms::scriptlevel_);
nsCSSValue* scriptLevel = aData->ValueForScriptLevel();
if (value && value->Type() == nsAttrValue::eString &&
aData->mFontData->mScriptLevel.GetUnit() == eCSSUnit_Null) {
scriptLevel->GetUnit() == eCSSUnit_Null) {
nsAutoString str(value->GetStringValue());
str.CompressWhitespace();
if (str.Length() > 0) {
@ -364,9 +366,9 @@ nsMathMLElement::MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
// to indicate that the scriptlevel is absolute.
PRUnichar ch = str.CharAt(0);
if (ch == '+' || ch == '-') {
aData->mFontData->mScriptLevel.SetIntValue(intValue, eCSSUnit_Integer);
scriptLevel->SetIntValue(intValue, eCSSUnit_Integer);
} else {
aData->mFontData->mScriptLevel.SetFloatValue(intValue, eCSSUnit_Number);
scriptLevel->SetFloatValue(intValue, eCSSUnit_Number);
}
}
}
@ -378,10 +380,11 @@ nsMathMLElement::MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
parseSizeKeywords = PR_FALSE;
value = aAttributes->GetAttr(nsGkAtoms::fontsize_);
}
nsCSSValue* fontSize = aData->ValueForFontSize();
if (value && value->Type() == nsAttrValue::eString &&
aData->mFontData->mSize.GetUnit() == eCSSUnit_Null) {
fontSize->GetUnit() == eCSSUnit_Null) {
nsAutoString str(value->GetStringValue());
if (!ParseNumericValue(str, aData->mFontData->mSize, 0) &&
if (!ParseNumericValue(str, *fontSize, 0) &&
parseSizeKeywords) {
static const char sizes[3][7] = { "small", "normal", "big" };
static const PRInt32 values[NS_ARRAY_LENGTH(sizes)] = {
@ -391,7 +394,7 @@ nsMathMLElement::MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
str.CompressWhitespace();
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(sizes); ++i) {
if (str.EqualsASCII(sizes[i])) {
aData->mFontData->mSize.SetIntValue(values[i], eCSSUnit_Enumerated);
fontSize->SetIntValue(values[i], eCSSUnit_Enumerated);
break;
}
}
@ -399,10 +402,10 @@ nsMathMLElement::MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
}
value = aAttributes->GetAttr(nsGkAtoms::fontfamily_);
nsCSSValue* fontFamily = aData->ValueForFontFamily();
if (value && value->Type() == nsAttrValue::eString &&
aData->mFontData->mFamily.GetUnit() == eCSSUnit_Null) {
aData->mFontData->mFamily.SetStringValue(value->GetStringValue(),
eCSSUnit_Families);
fontFamily->GetUnit() == eCSSUnit_Null) {
fontFamily->SetStringValue(value->GetStringValue(), eCSSUnit_Families);
}
}
@ -412,10 +415,11 @@ nsMathMLElement::MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
if (!value) {
value = aAttributes->GetAttr(nsGkAtoms::background);
}
if (value && aData->mColorData->mBackColor.GetUnit() == eCSSUnit_Null) {
nsCSSValue* backgroundColor = aData->ValueForBackgroundColor();
if (value && backgroundColor->GetUnit() == eCSSUnit_Null) {
nscolor color;
if (value->GetColorValue(color)) {
aData->mColorData->mBackColor.SetColorValue(color);
backgroundColor->SetColorValue(color);
}
}
}
@ -426,9 +430,10 @@ nsMathMLElement::MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
value = aAttributes->GetAttr(nsGkAtoms::color);
}
nscolor color;
nsCSSValue* colorValue = aData->ValueForColor();
if (value && value->GetColorValue(color) &&
aData->mColorData->mColor.GetUnit() == eCSSUnit_Null) {
aData->mColorData->mColor.SetColorValue(color);
colorValue->GetUnit() == eCSSUnit_Null) {
colorValue->SetColorValue(color);
}
}
}

View File

@ -414,6 +414,7 @@ private:
class nsBuiltinDecoderReader : public nsRunnable {
public:
typedef mozilla::Monitor Monitor;
typedef mozilla::MonitorAutoEnter MonitorAutoEnter;
nsBuiltinDecoderReader(nsBuiltinDecoder* aDecoder);
~nsBuiltinDecoderReader();
@ -443,7 +444,7 @@ public:
// Read header data for all bitstreams in the file. Fills mInfo with
// the data required to present the media. Returns NS_OK on success,
// or NS_ERROR_FAILURE on failure.
virtual nsresult ReadMetadata() = 0;
virtual nsresult ReadMetadata(nsVideoInfo* aInfo) = 0;
// Stores the presentation time of the first frame/sample we'd be
// able to play if we started playback at aOffset, and returns the
@ -463,11 +464,6 @@ public:
PRInt64 aEndTime,
PRInt64 aCurrentTime) = 0;
// Gets presentation info required for playback.
const nsVideoInfo& GetInfo() {
return mInfo;
}
// Queue of audio samples. This queue is threadsafe.
MediaQueue<SoundData> mAudioQueue;
@ -520,7 +516,8 @@ protected:
// Used to seek to media start time.
PRInt64 mDataOffset;
// Stores presentation info required for playback.
// Stores presentation info required for playback. The reader's monitor
// must be held when accessing this.
nsVideoInfo mInfo;
};

View File

@ -417,8 +417,8 @@ void nsBuiltinDecoderStateMachine::AudioLoop()
MonitorAutoEnter mon(mDecoder->GetMonitor());
mAudioCompleted = PR_FALSE;
audioStartTime = mAudioStartTime;
channels = mReader->GetInfo().mAudioChannels;
rate = mReader->GetInfo().mAudioRate;
channels = mInfo.mAudioChannels;
rate = mInfo.mAudioRate;
NS_ASSERTION(audioStartTime != -1, "Should have audio start time by now");
}
while (1) {
@ -712,20 +712,22 @@ void nsBuiltinDecoderStateMachine::StartPlayback()
LOG(PR_LOG_DEBUG, ("%p StartPlayback", mDecoder));
mDecoder->mPlaybackStatistics.Start(TimeStamp::Now());
if (HasAudio()) {
MonitorAutoExit exitMon(mDecoder->GetMonitor());
MonitorAutoEnter audioMon(mAudioMonitor);
if (mAudioStream) {
// We have an audiostream, so it must have been paused the last time
// StopPlayback() was called.
mAudioStream->Resume();
} else {
// No audiostream, create one.
const nsVideoInfo& info = mReader->GetInfo();
mAudioStream = nsAudioStream::AllocateStream();
mAudioStream->Init(info.mAudioChannels,
info.mAudioRate,
MOZ_SOUND_DATA_FORMAT);
mAudioStream->SetVolume(mVolume);
PRInt32 rate = mInfo.mAudioRate;
PRInt32 channels = mInfo.mAudioChannels;
{
MonitorAutoExit exitMon(mDecoder->GetMonitor());
MonitorAutoEnter audioMon(mAudioMonitor);
if (mAudioStream) {
// We have an audiostream, so it must have been paused the last time
// StopPlayback() was called.
mAudioStream->Resume();
} else {
// No audiostream, create one.
mAudioStream = nsAudioStream::AllocateStream();
mAudioStream->Init(channels, rate, MOZ_SOUND_DATA_FORMAT);
mAudioStream->SetVolume(mVolume);
}
}
}
mPlayStartTime = TimeStamp::Now();
@ -1057,8 +1059,12 @@ nsresult nsBuiltinDecoderStateMachine::Run()
VideoData* videoData = FindStartTime();
if (videoData) {
MonitorAutoExit exitMon(mDecoder->GetMonitor());
RenderVideoFrame(videoData, TimeStamp::Now());
nsIntSize display = mInfo.mDisplay;
float aspect = mInfo.mPixelAspectRatio;
{
MonitorAutoExit exitMon(mDecoder->GetMonitor());
RenderVideoFrame(videoData, TimeStamp::Now(), display, aspect);
}
}
// Start the decode threads, so that we can pre buffer the streams.
@ -1082,14 +1088,13 @@ nsresult nsBuiltinDecoderStateMachine::Run()
// setting the default framebuffer size for audioavailable events. Also,
// if there is audio, let the MozAudioAvailable event manager know about
// the metadata.
const nsVideoInfo& info = mReader->GetInfo();
PRUint32 frameBufferLength = info.mAudioChannels * FRAMEBUFFER_LENGTH_PER_CHANNEL;
PRUint32 frameBufferLength = mInfo.mAudioChannels * FRAMEBUFFER_LENGTH_PER_CHANNEL;
nsCOMPtr<nsIRunnable> metadataLoadedEvent =
new nsAudioMetadataEventRunner(mDecoder, info.mAudioChannels,
info.mAudioRate, frameBufferLength);
new nsAudioMetadataEventRunner(mDecoder, mInfo.mAudioChannels,
mInfo.mAudioRate, frameBufferLength);
NS_DispatchToMainThread(metadataLoadedEvent, NS_DISPATCH_NORMAL);
if (HasAudio()) {
mEventManager.Init(info.mAudioChannels, info.mAudioRate);
mEventManager.Init(mInfo.mAudioChannels, mInfo.mAudioRate);
mDecoder->RequestFrameBufferLength(frameBufferLength);
}
@ -1180,7 +1185,12 @@ nsresult nsBuiltinDecoderStateMachine::Run()
if (video) {
NS_ASSERTION(video->mTime <= seekTime && seekTime <= video->mEndTime,
"Seek target should lie inside the first frame after seek");
RenderVideoFrame(video, TimeStamp::Now());
nsIntSize display = mInfo.mDisplay;
float aspect = mInfo.mPixelAspectRatio;
{
MonitorAutoExit exitMon(mDecoder->GetMonitor());
RenderVideoFrame(video, TimeStamp::Now(), display, aspect);
}
mReader->mVideoQueue.PopFront();
nsCOMPtr<nsIRunnable> event =
NS_NewRunnableMethod(mDecoder, &nsBuiltinDecoder::Invalidate);
@ -1336,9 +1346,12 @@ nsresult nsBuiltinDecoderStateMachine::Run()
}
void nsBuiltinDecoderStateMachine::RenderVideoFrame(VideoData* aData,
TimeStamp aTarget)
TimeStamp aTarget,
nsIntSize aDisplaySize,
float aAspectRatio)
{
NS_ASSERTION(IsCurrentThread(mDecoder->mStateMachineThread), "Should be on state machine thread.");
mDecoder->GetMonitor().AssertNotCurrentThreadIn();
if (aData->mDuplicate) {
return;
@ -1346,11 +1359,8 @@ void nsBuiltinDecoderStateMachine::RenderVideoFrame(VideoData* aData,
nsRefPtr<Image> image = aData->mImage;
if (image) {
const nsVideoInfo& info = mReader->GetInfo();
mDecoder->SetVideoData(gfxIntSize(info.mDisplay.width, info.mDisplay.height),
info.mPixelAspectRatio,
image,
aTarget);
mDecoder->SetVideoData(gfxIntSize(aDisplaySize.width, aDisplaySize.height),
aAspectRatio, image, aTarget);
}
}
@ -1460,10 +1470,14 @@ void nsBuiltinDecoderStateMachine::AdvanceFrame()
MsToDuration(currentFrame->mTime - mStartTime);
NS_ASSERTION(currentFrame->mTime >= mStartTime, "Should have positive frame time");
{
MonitorAutoExit exitMon(mDecoder->GetMonitor());
// If we have video, we want to increment the clock in steps of the frame
// duration.
RenderVideoFrame(currentFrame, presTime);
nsIntSize display = mInfo.mDisplay;
float aspect = mInfo.mPixelAspectRatio;
{
MonitorAutoExit exitMon(mDecoder->GetMonitor());
// If we have video, we want to increment the clock in steps of the frame
// duration.
RenderVideoFrame(currentFrame, presTime, display, aspect);
}
}
mDecoder->GetFrameStatistics().NotifyPresentedFrame();
PRInt64 now = DurationToMs(TimeStamp::Now() - mPlayStartTime + mPlayDuration);
@ -1537,9 +1551,10 @@ VideoData* nsBuiltinDecoderStateMachine::FindStartTime()
PRInt64 startTime = 0;
mStartTime = 0;
VideoData* v = nsnull;
PRInt64 dataOffset = mInfo.mDataOffset;
{
MonitorAutoExit exitMon(mDecoder->GetMonitor());
v = mReader->FindStartTime(mReader->GetInfo().mDataOffset, startTime);
v = mReader->FindStartTime(dataOffset, startTime);
}
if (startTime != 0) {
mStartTime = startTime;
@ -1613,11 +1628,12 @@ void nsBuiltinDecoderStateMachine::LoadMetadata()
LOG(PR_LOG_DEBUG, ("Loading Media Headers"));
nsresult res;
nsVideoInfo info;
{
MonitorAutoExit exitMon(mDecoder->GetMonitor());
res = mReader->ReadMetadata();
res = mReader->ReadMetadata(&info);
}
const nsVideoInfo& info = mReader->GetInfo();
mInfo = info;
if (NS_FAILED(res) || (!info.mHasVideo && !info.mHasAudio)) {
mState = DECODER_STATE_SHUTDOWN;

View File

@ -184,14 +184,14 @@ public:
// The decoder monitor must be obtained before calling this.
PRBool HasAudio() const {
mDecoder->GetMonitor().AssertCurrentThreadIn();
return mReader->GetInfo().mHasAudio;
return mInfo.mHasAudio;
}
// This is called on the state machine thread and audio thread.
// The decoder monitor must be obtained before calling this.
PRBool HasVideo() const {
mDecoder->GetMonitor().AssertCurrentThreadIn();
return mReader->GetInfo().mHasVideo;
return mInfo.mHasVideo;
}
// Should be called by main thread.
@ -311,10 +311,11 @@ protected:
void UpdatePlaybackPositionInternal(PRInt64 aTime);
// Performs YCbCr to RGB conversion, and pushes the image down the
// rendering pipeline. Called on the state machine thread.
void RenderVideoFrame(VideoData* aData,
TimeStamp aTarget);
// rendering pipeline. Called on the state machine thread. The decoder
// monitor must not be held when calling this.
void RenderVideoFrame(VideoData* aData, TimeStamp aTarget,
nsIntSize aDisplaySize, float aAspectRatio);
// If we have video, display a video frame if it's time for display has
// arrived, otherwise sleep until it's time for the next sample. Update
// the current frame time as appropriate, and trigger ready state update.
@ -524,6 +525,10 @@ private:
// event manager is accessed from the state machine and audio threads,
// and takes care of synchronizing access to its internal queue.
nsAudioAvailableEventManager mEventManager;
// Stores presentation info required for playback. The decoder monitor
// must be held when accessing this.
nsVideoInfo mInfo;
};
#endif

View File

@ -222,7 +222,7 @@ nsMediaChannelStream::OnStartRequest(nsIRequest* aRequest)
}
if (NS_SUCCEEDED(rv)) {
double duration = durationText.ToFloat(&ec);
double duration = durationText.ToDouble(&ec);
if (ec == NS_OK && duration >= 0) {
mDecoder->SetDuration(PRInt64(NS_round(duration*1000)));
}

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