Bug 969201 - HTMLLinkElement sizes attribute, f=ms2ger, r=bz

This commit is contained in:
Andrea Marchesini 2014-04-17 12:50:54 +01:00
parent 3a7fcff936
commit d848197189
7 changed files with 53 additions and 6 deletions

View File

@ -998,6 +998,7 @@ GK_ATOM(showresizer, "showresizer")
GK_ATOM(simple, "simple")
GK_ATOM(single, "single")
GK_ATOM(size, "size")
GK_ATOM(sizes, "sizes")
GK_ATOM(sizemode, "sizemode")
GK_ATOM(sizetopopup, "sizetopopup")
GK_ATOM(slider, "slider")

View File

@ -196,10 +196,16 @@ HTMLLinkElement::ParseAttribute(int32_t aNamespaceID,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aNamespaceID == kNameSpaceID_None &&
aAttribute == nsGkAtoms::crossorigin) {
ParseCORSValue(aValue, aResult);
return true;
if (aNamespaceID == kNameSpaceID_None) {
if (aAttribute == nsGkAtoms::crossorigin) {
ParseCORSValue(aValue, aResult);
return true;
}
if (aAttribute == nsGkAtoms::sizes) {
aResult.ParseAtomArray(aValue);
return true;
}
}
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,

View File

@ -109,6 +109,10 @@ public:
{
SetHTMLAttr(nsGkAtoms::hreflang, aHreflang, aRv);
}
nsDOMSettableTokenList* Sizes()
{
return GetTokenList(nsGkAtoms::sizes);
}
// XPCOM GetType is fine.
void SetType(const nsAString& aType, ErrorResult& aRv)
{

View File

@ -3154,6 +3154,7 @@ static nsIAtom** sPropertiesToTraverseAndUnlink[] =
&nsGkAtoms::itemref,
&nsGkAtoms::itemprop,
&nsGkAtoms::sandbox,
&nsGkAtoms::sizes,
nullptr
};

View File

@ -448,6 +448,7 @@ skip-if = buildapp == 'b2g' || e10s # b2g(multiple concurrent window.open()s fai
[test_imageSrcSet.html]
[test_li_attributes_reflection.html]
[test_link_attributes_reflection.html]
[test_link_sizes.html]
[test_map_attributes_reflection.html]
[test_meta_attributes_reflection.html]
[test_mod_attributes_reflection.html]

View File

@ -0,0 +1,35 @@
<!doctype html>
<html>
<head>
<title>Test link.sizes attribute</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" sizes="16x16 24x24 32x32 48x48">
</head>
<body>
<pre id="test">
<script>
var links = document.getElementsByTagName('link');
for (var i = 0; i < links.length; ++i) {
var link = links[i];
ok("sizes" in link, "link.sizes exists");
if (link.rel == 'shortcut icon') {
is(link.sizes.value, "16x16 24x24 32x32 48x48", 'link.sizes.value correct value');
is(link.sizes.length, 4, 'link.sizes.length correct value');
ok(link.sizes.contains('32x32'), 'link.sizes.contains() works');
link.sizes.add('64x64');
is(link.sizes.length, 5, 'link.sizes.length correct value');
link.sizes.remove('64x64');
is(link.sizes.length, 4, 'link.sizes.length correct value');
is(link.sizes + "", "16x16 24x24 32x32 48x48", 'link.sizes stringify correct value');
} else {
is(link.sizes.value, "", 'link.sizes correct value');
}
}
</script>
</pre>
</body>
</html>

View File

@ -28,8 +28,7 @@ interface HTMLLinkElement : HTMLElement {
attribute DOMString hreflang;
[SetterThrows, Pure]
attribute DOMString type;
// Not supported yet:
// [PutForwards=value] readonly attribute DOMSettableTokenList sizes;
[PutForwards=value] readonly attribute DOMSettableTokenList sizes;
};
HTMLLinkElement implements LinkStyle;