import changes from rmottola/Arctic-Fox:

- Bug 945584: Part 1 - Style support for scroll snapping attributes, - Implemented style support for new attributes:   - scroll-snap-type   - scroll-snap-type-x   - scroll-snap-type-y   - scroll-snap-points-x   - scroll-snap-points-y   - scroll-snap-destination   - scroll-snap-coordinate (02fe3bb49)
- Bug 945584: Part 2 - Add CSS scroll snapping attributes to ScrollbarStyles (v10 Patch) (7ffff307b)
- Bug 945584: Part 3 - Enable cancellation of OSX synthesized mousewheel scrolling events (v2 Patch), (124e19201)
- Bug 945584: Part 4 - Add scroll snapping preferences (v3 Patch), - Added preferences to allow trackpad and mousewheel flinging between snap points to be tuned: - layout.css.scroll-snap.prediction-max-velocity - layout.css.scroll-snap.prediction-sensitivity (64d44c6ca)
- Bug 945584: Part 5 - Implement ScrollVelocityQueue (v4 Patch), - Implemented ScrollVelocityQueue class to calculate the velocity of a scroll   when given periodic samples of scroll position. - Added BasePoint::Clamp to simplify code. (bca79b509)
- Inactive subframes-in-subframes add event regions to the wrong layer. (bug 1139213, r=tn) (c5ad5ede0)
- Bug 1075702 - Fixed implementation of Element.setAttributeNode(). (8e5cdb94d)
- Bug 1134968. If JS_NewObjectWithGivenProto is passed a null parent and null proto, use the context's current global as the parent. (82810e810)
- Bug 990907 - Add a flag on nsIScrollableFrame to indicate if it is actively being scrolled by APZ. (3eb29e60b)
This commit is contained in:
2019-02-17 15:11:13 +08:00
parent aa57295df4
commit 6f8a6a3d3a
39 changed files with 1093 additions and 130 deletions
+46 -39
View File
@@ -317,46 +317,51 @@ nsDOMAttributeMap::SetNamedItemInternal(Attr& aAttr,
}
// Get nodeinfo and preexisting attribute (if it exists)
nsAutoString name;
nsRefPtr<mozilla::dom::NodeInfo> ni;
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;
}
}
}
nsRefPtr<Attr> attr;
// SetNamedItemNS()
if (aWithNS) {
// Return existing attribute, if present
ni = aAttr.NodeInfo();
if (mContent->HasAttr(ni->NamespaceID(), ni->NameAtom())) {
attr = RemoveAttribute(ni);
if (oldNi) {
nsRefPtr<Attr> oldAttr = GetAttribute(oldNi, true);
if (oldAttr == &aAttr) {
return oldAttr.forget();
}
} else { // SetNamedItem()
aAttr.GetName(name);
// get node-info of old attribute
ni = mContent->GetExistingAttrNameFromQName(name);
if (ni) {
attr = RemoveAttribute(ni);
}
else {
if (mContent->IsInHTMLDocument() &&
mContent->IsHTML()) {
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
if (oldAttr) {
attr = RemoveNamedItem(oldNi, aError);
NS_ASSERTION(attr->NodeInfo()->NameAndNamespaceEquals(oldNi),
"RemoveNamedItem() called, attr->NodeInfo() should be equal to oldNi!");
}
}
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());
@@ -374,6 +379,15 @@ 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)
@@ -399,11 +413,7 @@ nsDOMAttributeMap::RemoveNamedItem(const nsAString& aName, ErrorResult& aError)
return nullptr;
}
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();
return RemoveNamedItem(ni, aError);
}
@@ -501,6 +511,7 @@ 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;
@@ -537,11 +548,7 @@ nsDOMAttributeMap::RemoveNamedItemNS(const nsAString& aNamespaceURI,
return nullptr;
}
nsRefPtr<Attr> attr = RemoveAttribute(ni);
mozilla::dom::NodeInfo* attrNi = attr->NodeInfo();
mContent->UnsetAttr(attrNi->NamespaceID(), attrNi->NameAtom(), true);
return attr.forget();
return RemoveNamedItem(ni, aError);
}
uint32_t