Have one canonical source for a document's language

ASSIGNED
Assigned to

Status

()

ASSIGNED
7 years ago
4 years ago

People

(Reporter: jwatt, Assigned: jwatt)

Tracking

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Assignee)

Description

7 years ago
While fixing bug 416581, I noticed that nsStyleFont::nsStyleFont(nsPresContext*) constructs its mFont using the language-from-charset under the GetDefaultFont call, but then under Init() it prefers to set mLanguage to the content-language obtained from nsIDocument::GetContentLanguage. These could be different things.

Seems like we should have one canonical source for a document's language. A method GetLanguage() on nsIDocument would be good. We could then clean up the callers of the current two sources:
  
https://mxr.mozilla.org/mozilla-central/ident?i=GetLanguageFromCharset
https://mxr.mozilla.org/mozilla-central/ident?i=GetContentLanguage
(Assignee)

Comment 1

7 years ago
We could also have nsIContent::GetLang fall back to returning nsIDocument::GetLanguage if none of the elements along the parent chain have an 'xml:lang' or 'lang' attribute. As long as nsIDocument::GetLanguage is consistent with the HTML5 rules:

http://www.w3.org/TR/html5/elements.html#the-lang-and-xml:lang-attributes
You need to log in before you can comment on or make changes to this bug.