Bug 1213842 - :lang() should not fall back to HTTP headers if empty lang attribute is specified; r=bz

This commit is contained in:
Aryeh Gregor 2015-10-13 14:08:30 +03:00
parent 03c8ae97d1
commit db4fe4bcfb
4 changed files with 6 additions and 16 deletions

View File

@ -911,11 +911,11 @@ public:
mozilla::dom::Element* GetEditingHost();
/**
* Determing language. Look at the nearest ancestor element that has a lang
* Determining language. Look at the nearest ancestor element that has a lang
* attribute in the XML namespace or is an HTML/SVG element and has a lang in
* no namespace attribute.
* no namespace attribute. Returns false if no language was specified.
*/
void GetLang(nsAString& aResult) const {
bool GetLang(nsAString& aResult) const {
for (const nsIContent* content = this; content; content = content->GetParent()) {
if (content->GetAttrCount() > 0) {
// xml:lang has precedence over lang on HTML elements (see
@ -930,10 +930,11 @@ public:
NS_ASSERTION(hasAttr || aResult.IsEmpty(),
"GetAttr that returns false should not make string non-empty");
if (hasAttr) {
return;
return true;
}
}
}
return false;
}
// Overloaded from nsINode

View File

@ -1884,8 +1884,7 @@ static bool SelectorMatches(Element* aElement,
// from the parent we have to be prepared to look at all parent
// nodes. The language itself is encoded in the LANG attribute.
nsAutoString language;
aElement->GetLang(language);
if (!language.IsEmpty()) {
if (aElement->GetLang(language)) {
if (!nsStyleUtil::DashMatchCompare(language,
nsDependentString(pseudoClass->u.mString),
nsASCIICaseInsensitiveStringComparator())) {

View File

@ -1,5 +0,0 @@
[the-lang-attribute-009.html]
type: testharness
[If the HTTP header contains a language declaration but the html element uses an empty lang value, the UA will not recognize the language declared in the HTTP header.]
expected: FAIL

View File

@ -1,5 +0,0 @@
[the-lang-attribute-010.html]
type: testharness
[If the meta Content-Language element contains a language declaration but the html element uses an empty lang value, the UA will not recognize the language declared in the meta Content-Language element.]
expected: FAIL