Merge m-c to b2ginbound, a=merge

This commit is contained in:
Wes Kocher 2015-06-16 16:53:17 -07:00
Родитель afae1ef0ca 1e9634367f
Коммит 0fa17a5810
14 изменённых файлов: 123 добавлений и 205 удалений

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

@ -184,7 +184,7 @@ Attr::GetValue(nsAString& aValue)
{
Element* element = GetElement();
if (element) {
nsCOMPtr<nsIAtom> nameAtom = mNodeInfo->NameAtom();
nsCOMPtr<nsIAtom> nameAtom = GetNameAtom(element);
element->GetAttr(mNodeInfo->NamespaceID(), nameAtom, aValue);
}
else {
@ -203,7 +203,7 @@ Attr::SetValue(const nsAString& aValue, ErrorResult& aRv)
return;
}
nsCOMPtr<nsIAtom> nameAtom = mNodeInfo->NameAtom();
nsCOMPtr<nsIAtom> nameAtom = GetNameAtom(element);
aRv = element->SetAttr(mNodeInfo->NamespaceID(),
nameAtom,
mNodeInfo->GetPrefixAtom(),

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

@ -1235,9 +1235,7 @@ Element::RemoveAttributeNode(Attr& aAttribute,
}
OwnerDoc()->WarnOnceAbout(nsIDocument::eRemoveAttributeNode);
nsAutoString nameSpaceURI;
aAttribute.NodeInfo()->GetNamespaceURI(nameSpaceURI);
return Attributes()->RemoveNamedItemNS(nameSpaceURI, aAttribute.NodeInfo()->LocalName(), aError);
return Attributes()->RemoveNamedItem(aAttribute.NodeName(), aError);
}
void

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

@ -300,51 +300,46 @@ nsDOMAttributeMap::SetNamedItemInternal(Attr& aAttr,
}
// Get nodeinfo and preexisting attribute (if it exists)
nsRefPtr<NodeInfo> oldNi;
if (!aWithNS) {
nsAutoString name;
aAttr.GetName(name);
oldNi = mContent->GetExistingAttrNameFromQName(name);
}
else {
uint32_t i, count = mContent->GetAttrCount();
for (i = 0; i < count; ++i) {
const nsAttrName* name = mContent->GetAttrNameAt(i);
int32_t attrNS = name->NamespaceID();
nsIAtom* nameAtom = name->LocalName();
// we're purposefully ignoring the prefix.
if (aAttr.NodeInfo()->Equals(nameAtom, attrNS)) {
oldNi = mContent->NodeInfo()->NodeInfoManager()->
GetNodeInfo(nameAtom, name->GetPrefix(), aAttr.NodeInfo()->NamespaceID(),
nsIDOMNode::ATTRIBUTE_NODE);
break;
}
}
}
nsAutoString name;
nsRefPtr<mozilla::dom::NodeInfo> ni;
nsRefPtr<Attr> attr;
// SetNamedItemNS()
if (aWithNS) {
// Return existing attribute, if present
ni = aAttr.NodeInfo();
if (oldNi) {
nsRefPtr<Attr> oldAttr = GetAttribute(oldNi, true);
if (oldAttr == &aAttr) {
return oldAttr.forget();
if (mContent->HasAttr(ni->NamespaceID(), ni->NameAtom())) {
attr = RemoveAttribute(ni);
}
} else { // SetNamedItem()
aAttr.GetName(name);
if (oldAttr) {
attr = RemoveNamedItem(oldNi, aError);
NS_ASSERTION(attr->NodeInfo()->NameAndNamespaceEquals(oldNi),
"RemoveNamedItem() called, attr->NodeInfo() should be equal to oldNi!");
// get node-info of old attribute
ni = mContent->GetExistingAttrNameFromQName(name);
if (ni) {
attr = RemoveAttribute(ni);
}
else {
if (mContent->IsInHTMLDocument() &&
mContent->IsHTMLElement()) {
nsContentUtils::ASCIIToLower(name);
}
rv = mContent->NodeInfo()->NodeInfoManager()->
GetNodeInfo(name, nullptr, kNameSpaceID_None,
nsIDOMNode::ATTRIBUTE_NODE, getter_AddRefs(ni));
if (NS_FAILED(rv)) {
aError.Throw(rv);
return nullptr;
}
// value is already empty
}
}
nsAutoString value;
aAttr.GetValue(value);
nsRefPtr<NodeInfo> ni = aAttr.NodeInfo();
// Add the new attribute to the attribute map before updating
// its value in the element. @see bug 364413.
nsAttrKey attrkey(ni->NamespaceID(), ni->NameAtom());
@ -361,15 +356,6 @@ nsDOMAttributeMap::SetNamedItemInternal(Attr& aAttr,
return attr.forget();
}
already_AddRefed<Attr>
nsDOMAttributeMap::RemoveNamedItem(NodeInfo* aNodeInfo, ErrorResult& aError)
{
nsRefPtr<Attr> attribute = GetAttribute(aNodeInfo, true);
// This removes the attribute node from the attribute map.
aError = mContent->UnsetAttr(aNodeInfo->NamespaceID(), aNodeInfo->NameAtom(), true);
return attribute.forget();
}
NS_IMETHODIMP
nsDOMAttributeMap::RemoveNamedItem(const nsAString& aName,
nsIDOMAttr** aReturn)
@ -395,7 +381,11 @@ nsDOMAttributeMap::RemoveNamedItem(const nsAString& aName, ErrorResult& aError)
return nullptr;
}
return RemoveNamedItem(ni, aError);
nsRefPtr<Attr> attribute = GetAttribute(ni, true);
// This removes the attribute node from the attribute map.
aError = mContent->UnsetAttr(ni->NamespaceID(), ni->NameAtom(), true);
return attribute.forget();
}
@ -493,7 +483,6 @@ nsDOMAttributeMap::GetAttrNodeInfo(const nsAString& aNamespaceURI,
int32_t attrNS = name->NamespaceID();
nsIAtom* nameAtom = name->LocalName();
// we're purposefully ignoring the prefix.
if (nameSpaceID == attrNS &&
nameAtom->Equals(aLocalName)) {
nsRefPtr<mozilla::dom::NodeInfo> ni;
@ -530,7 +519,11 @@ nsDOMAttributeMap::RemoveNamedItemNS(const nsAString& aNamespaceURI,
return nullptr;
}
return RemoveNamedItem(ni, aError);
nsRefPtr<Attr> attr = RemoveAttribute(ni);
mozilla::dom::NodeInfo* attrNi = attr->NodeInfo();
mContent->UnsetAttr(attrNi->NamespaceID(), attrNi->NameAtom(), true);
return attr.forget();
}
uint32_t

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

@ -152,8 +152,6 @@ public:
return SetNamedItemInternal(aAttr, false, aError);
}
already_AddRefed<Attr>
RemoveNamedItem(mozilla::dom::NodeInfo* aNodeInfo, ErrorResult& aError);
already_AddRefed<Attr>
RemoveNamedItem(const nsAString& aName, ErrorResult& aError);
Attr* Item(uint32_t aIndex);

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

@ -260,7 +260,6 @@ skip-if = buildapp == 'mulet'
[test_bug999456.html]
[test_bug1022229.html]
[test_bug1043106.html]
[test_bug1060938.html]
[test_bug1064481.html]
[test_clearTimeoutIntervalNoArg.html]
[test_consoleEmptyStack.html]
@ -666,7 +665,6 @@ skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android' || e1
[test_bug982153.html]
[test_bug1057176.html]
[test_bug1070015.html]
[test_bug1075702.html]
[test_bug1101364.html]
skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android'
[test_bug1163743.html]
@ -789,6 +787,7 @@ skip-if = buildapp == 'mulet' || buildapp == 'b2g'
[test_bug1118689.html]
skip-if = buildapp == 'mulet' || buildapp == 'b2g'
[test_integer_attr_with_leading_zero.html]
[test_getAttribute_after_createAttribute.html]
[test_script_loader_crossorigin_data_url.html]
[test_file_negative_date.html]
[test_nonascii_blob_url.html]

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

@ -1,44 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1060938
-->
<head>
<meta charset="utf-8">
<title> Test for Bug 1060938 </title>
<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=1060938"> Mozilla Bug 1060938 </a>
<p id="display"></p>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 1060938 **/
// test: Element.removeAttributeNode()
parent = document.getElementsByTagName("p")[0];
parent.setAttributeNS("www.test1.com", "ID", "Test1");
parent.setAttributeNS("www.test2.com", "Class", "Test2");
parent.setAttribute("id", "www.test3.com");
parent.className = "www.test4.com";
allAttributes = parent.attributes;
function removeAttr(iter){
var removed_attribute = allAttributes[0];
is(removed_attribute, parent.removeAttributeNode(removed_attribute),
"(" + iter + ")" + " Returned attribute and remove attribute should be same.");
}
removeAttr(1);
removeAttr(2);
removeAttr(3);
removeAttr(4);
</script>
</body>
</html>

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

@ -1,69 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1075702
-->
<head>
<meta charset="utf-8">
<title> Test for Bug 1075702 </title>
<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=1075702"> Mozilla Bug 1075702 </a>
<p id="display"></p>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 1075702 **/
// test: Element.removeAttributeNode()
var a1 = document.createAttribute("aa");
a1.nodeValue = "lowercase";
var a2 = document.createAttribute("AA");
a2.nodeValue = "UPPERCASE";
document.documentElement.setAttributeNode(a1);
document.documentElement.setAttributeNode(a2);
is(document.documentElement.getAttributeNS("", "aa"), null, "Should be NULL!");
is(document.documentElement.getAttributeNS("", "AA"), "UPPERCASE", "Should be UPPERCASE!");
var removedNodeAccordingToEvent;
function mutationHandler(aEvent) {
removedNodeAccordingToEvent = aEvent.relatedNode;
}
var test1 = document.createElement("div");
test1.setAttribute("x", "y");
removedNodeAccordingToEvent = null;
function testremoveNamedItemNS() {
test1.addEventListener("DOMAttrModified", mutationHandler, true);
var removedNodeAccordingToRemoveNamedItemNS = test1.attributes.removeNamedItemNS(null, "x");
test1.removeEventListener("DOMAttrModified", mutationHandler, true);
is(removedNodeAccordingToEvent, removedNodeAccordingToRemoveNamedItemNS, "Node removed according to event is not same as node removed by removeNamedItemNS.");
}
testremoveNamedItemNS();
var test2 = document.createElement("div");
test2.setAttribute("x", "y");
removedNodeAccordingToEvent = null;
function testremoveNamedItem() {
test2.addEventListener("DOMAttrModified", mutationHandler, true);
var removedNodeAccordingToRemoveNamedItem = test2.attributes.removeNamedItem("x");
test2.removeEventListener("DOMAttrModified", mutationHandler, true);
is(removedNodeAccordingToEvent, removedNodeAccordingToRemoveNamedItem, "Node removed according to event is not same as node removed by removeNamedItem.");
}
testremoveNamedItem();
</script>
</body>
</html>

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

@ -27,10 +27,8 @@ function testGetAttribute() {
document.body.setAttributeNode(a1);
document.body.setAttributeNode(a2);
var log = document.getElementById("log");
is(document.body.getAttribute('aa'), null, "Attribute has the localName AA and not aa.");
is(document.body.getAttribute('AA'), null, "Attribute has the localName AA and not aa.");
is(document.body.getAttributeNS("", "aa"), null, "Attribute should have localName AA.");
is(document.body.getAttributeNS("", "AA"), "UPPERCASE", "Attribute should have value UPPERCASE!");
is(document.body.getAttribute('aa'), "UPPERCASE", "Wrong value (1)");
is(document.body.getAttribute('AA'), "UPPERCASE", "Wrong value (2)");
var s = "";
for (var i = 0; i < document.body.attributes.length; ++i) {
@ -42,11 +40,13 @@ function testGetAttribute() {
is(document.body.getAttributeNode("aa"), document.body.getAttributeNode("AA"),
"Wrong node!");
document.body.getAttributeNodeNS("", "AA").nodeValue = "FOO";
is(document.body.getAttributeNS("", "AA"), "FOO", "Wrong value!");
document.body.getAttributeNode("AA").nodeValue = "FOO";
is(document.body.getAttribute("AA"), "FOO", "Wrong value!");
document.body.removeAttributeNode(document.body.getAttributeNodeNS("", "AA"));
document.body.removeAttributeNode(document.body.getAttributeNode("AA"));
ok(!document.body.hasAttribute("AA"), "Should not have attribute!");
ok(!document.body.getAttributeNode("AA"), "Should not have attribute node!");
ok(!document.body.hasAttribute("aa"), "Should not have attribute!");
ok(!document.body.getAttributeNode("aa"), "Should not have attribute node!");
is(a2.nodeValue, "FOO", "Wrong value!");
@ -54,10 +54,10 @@ function testGetAttribute() {
is(a2.nodeValue, "UPPERCASE", "Wrong value!");
document.body.setAttributeNode(a2);
is(document.body.getAttributeNS("", "AA"), "UPPERCASE", "Wrong value!");
ok(document.body.getAttributeNodeNS("", "AA"), "Should have attribute node!");
is(document.body.getAttributeNS("", "aa"), null, "No attribute has the localName aa.");
ok(!document.body.getAttributeNodeNS("", "aa"), "Should not have attribute node!");
is(document.body.getAttribute("AA"), "UPPERCASE", "wrong value!");
ok(document.body.getAttributeNode("AA"), "Should have attribute node!");
is(document.body.getAttribute("aa"), "UPPERCASE", "wrong value!");
ok(document.body.getAttributeNode("aa"), "Should have attribute node!");
}
testGetAttribute();
@ -75,7 +75,7 @@ function testGetAttributeNodeMixedCase() {
var a = div.ownerDocument.createAttribute("mixedCaseAttrib");
a.nodeValue = "x";
div.setAttributeNode(a);
return div.getAttributeNS("", "mixedCaseAttrib");
return div.getAttribute("mixedCaseAttrib");
}
is(testGetAttributeNodeMixedCase(), "x", "(2)");
@ -114,7 +114,7 @@ function testAttribNodeNamePreservesCaseGetNode() {
var a = body.ownerDocument.createAttribute("A");
a.nodeValue = "x";
body.setAttributeNode(a);
a = document.body.getAttributeNodeNS("", "A");
a = document.body.getAttributeNode("A");
if (!a)
return "FAIL";
var result = [ a.name, a.nodeName ];
@ -127,14 +127,14 @@ function testAttribNodeNamePreservesCaseGetNode2() {
var a = body.ownerDocument.createAttribute("B");
a.nodeValue = "x";
body.setAttributeNode(a);
a = document.body.getAttributeNodeNS("", "B");
a = document.body.getAttributeNode("B");
if (!a)
return "FAIL";
// Now create node second time
a = body.ownerDocument.createAttribute("B");
a.nodeValue = "x";
body.setAttributeNode(a);
a = document.body.getAttributeNodeNS("", "B");
a = document.body.getAttributeNode("B");
var result = [ a.name, a.nodeName ];
return result.join(",");
}
@ -158,9 +158,9 @@ attrib.nodeValue = "XXX";
node.setAttributeNode(attrib);
// Note, this is different to what WebKit does
is((new XMLSerializer).serializeToString(node),
"<div xmlns=\"http://www.w3.org/1999/xhtml\" myAttrib=\"XXX\"></div>", "(9)");
is(node.getAttributeNodeNS("", "myAttrib").name, "myAttrib", "(10)");
is(node.getAttributeNodeNS("", "myattrib"), null, "(11)");
"<div xmlns=\"http://www.w3.org/1999/xhtml\" myattrib=\"XXX\"></div>", "(9)");
is(node.getAttributeNode('myAttrib').name, "myAttrib", "(10)");
is(node.getAttributeNode('myattrib').name, "myAttrib", "(11)");
is(attrib.name, "myAttrib", "(12)");
var o = document.createElement("div");

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

@ -0,0 +1,15 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Test for ...</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
var div = document.createElement("div");
var attr = document.createAttribute("FOO");
attr.value = "bar";
div.setAttributeNode(attr);
assert_equals(div.getAttribute("FOO"), "bar");
}, "getAttribute should be able to get an attribute created via createAttribute");
</script>

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

@ -15,7 +15,9 @@ from WebIDL import BuiltinTypes, IDLBuiltinType, IDLNullValue, IDLSequenceType,
from Configuration import NoSuchDescriptorError, getTypesFromDescriptor, getTypesFromDictionary, getTypesFromCallback, getAllTypes, Descriptor, MemberIsUnforgeable
AUTOGENERATED_WARNING_COMMENT = \
"/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n\n"
"/* THIS FILE IS AUTOGENERATED BY Codegen.py - DO NOT EDIT */\n\n"
AUTOGENERATED_WITH_SOURCE_WARNING_COMMENT = \
"/* THIS FILE IS AUTOGENERATED FROM %s BY Codegen.py - DO NOT EDIT */\n\n"
ADDPROPERTY_HOOK_NAME = '_addProperty'
FINALIZE_HOOK_NAME = '_finalize'
OBJECT_MOVED_HOOK_NAME = '_objectMoved'
@ -12708,7 +12710,10 @@ class CGBindingRoot(CGThing):
curr = CGIncludeGuard(prefix, curr)
# Add the auto-generated comment.
curr = CGWrapper(curr, pre=AUTOGENERATED_WARNING_COMMENT)
curr = CGWrapper(
curr,
pre=(AUTOGENERATED_WITH_SOURCE_WARNING_COMMENT %
os.path.basename(webIDLFile)))
# Store the final result.
self.root = curr
@ -15382,7 +15387,10 @@ class CGEventRoot(CGThing):
# And now some include guards
self.root = CGIncludeGuard(interfaceName, self.root)
self.root = CGWrapper(self.root, pre=AUTOGENERATED_WARNING_COMMENT)
self.root = CGWrapper(
self.root,
pre=(AUTOGENERATED_WITH_SOURCE_WARNING_COMMENT %
os.path.basename(descriptor.interface.filename())))
self.root = CGWrapper(self.root, pre=dedent("""
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */

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

@ -424,10 +424,16 @@ GeneratePrototypeGuards(JSContext* cx, IonScript* ion, MacroAssembler& masm, JSO
return;
while (pobj != holder) {
if (pobj->hasUncacheableProto()) {
MOZ_ASSERT(!pobj->isSingleton());
masm.movePtr(ImmGCPtr(pobj), scratchReg);
Address groupAddr(scratchReg, JSObject::offsetOfGroup());
masm.branchPtr(Assembler::NotEqual, groupAddr, ImmGCPtr(pobj->group()), failures);
if (pobj->isSingleton()) {
// Singletons can have their group's |proto| mutated directly.
masm.loadPtr(groupAddr, scratchReg);
Address protoAddr(scratchReg, ObjectGroup::offsetOfProto());
masm.branchPtr(Assembler::NotEqual, protoAddr, ImmGCPtr(pobj->getProto()), failures);
} else {
masm.branchPtr(Assembler::NotEqual, groupAddr, ImmGCPtr(pobj->group()), failures);
}
}
pobj = pobj->getProto();
}

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

@ -263,6 +263,21 @@ ReportWrapperDenial(JSContext* cx, HandleId id, WrapperDenialType type, const ch
return true;
}
bool JSXrayTraits::getOwnPropertyFromWrapperIfSafe(JSContext* cx,
HandleObject wrapper,
HandleId id,
MutableHandle<JSPropertyDescriptor> outDesc)
{
MOZ_ASSERT(js::IsObjectInContextCompartment(wrapper, cx));
RootedObject target(cx, getTargetObject(wrapper));
{
JSAutoCompartment ac(cx, target);
if (!getOwnPropertyFromTargetIfSafe(cx, target, wrapper, id, outDesc))
return false;
}
return JS_WrapPropertyDescriptor(cx, outDesc);
}
bool JSXrayTraits::getOwnPropertyFromTargetIfSafe(JSContext* cx,
HandleObject target,
HandleObject wrapper,
@ -376,12 +391,7 @@ JSXrayTraits::resolveOwnProperty(JSContext* cx, const Wrapper& jsWrapper,
// "should" look like over Xrays, the underlying object is squishy enough
// that it makes sense to just treat them like Objects for Xray purposes.
if (key == JSProto_Object || key == JSProto_Array) {
{
JSAutoCompartment ac(cx, target);
if (!getOwnPropertyFromTargetIfSafe(cx, target, wrapper, id, desc))
return false;
}
return JS_WrapPropertyDescriptor(cx, desc);
return getOwnPropertyFromWrapperIfSafe(cx, wrapper, id, desc);
} else if (IsTypedArrayKey(key)) {
if (IsArrayIndex(GetArrayIndexFromId(cx, id))) {
JS_ReportError(cx, "Accessing TypedArray data over Xrays is slow, and forbidden "
@ -444,10 +454,8 @@ JSXrayTraits::resolveOwnProperty(JSContext* cx, const Wrapper& jsWrapper,
return true;
}
} else if (key == JSProto_RegExp) {
if (id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_LASTINDEX)) {
JSAutoCompartment ac(cx, target);
return getOwnPropertyFromTargetIfSafe(cx, target, wrapper, id, desc);
}
if (id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_LASTINDEX))
return getOwnPropertyFromWrapperIfSafe(cx, wrapper, id, desc);
}
// The rest of this function applies only to prototypes.
@ -493,10 +501,8 @@ JSXrayTraits::resolveOwnProperty(JSContext* cx, const Wrapper& jsWrapper,
}
// Handle the 'lastIndex' property for RegExp prototypes.
if (key == JSProto_RegExp && id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_LASTINDEX)) {
JSAutoCompartment ac(cx, target);
return getOwnPropertyFromTargetIfSafe(cx, target, wrapper, id, desc);
}
if (key == JSProto_RegExp && id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_LASTINDEX))
return getOwnPropertyFromWrapperIfSafe(cx, wrapper, id, desc);
// Grab the JSClass. We require all Xrayable classes to have a ClassSpec.
const js::Class* clasp = js::GetObjectClass(target);

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

@ -313,6 +313,13 @@ public:
return static_cast<JSProtoKey>(key);
}
// Operates in the wrapper compartment.
static bool getOwnPropertyFromWrapperIfSafe(JSContext* cx,
JS::HandleObject wrapper,
JS::HandleId id,
JS::MutableHandle<JSPropertyDescriptor> desc);
// Like the above, but operates in the target compartment.
static bool getOwnPropertyFromTargetIfSafe(JSContext* cx,
JS::HandleObject target,
JS::HandleObject wrapper,

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

@ -5,6 +5,7 @@
#ifndef INDEX_H_
#define INDEX_H_
#include "MediaData.h"
#include "MediaResource.h"
#include "mozilla/Monitor.h"
#include "mp4_demuxer/Interval.h"