Closed Bug 487023 Opened 16 years ago Closed 15 years ago

Refactor IsCaseSensitive() into non-virtual inline IsHTML()

Categories

(Core :: DOM: Core & HTML, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: hsivonen, Assigned: dzbarsky)

References

Details

Attachments

(2 files)

nsIDocument has virtual PRBool IsCaseSensitive(). The common usage patterns for this method really is that !IsCaseSensitive() means that the document is an HTML document for the purposes of HTML5. Therefore, it would be more intuitive to have a method IsHTML() that returned the negation of what IsCaseSensitive() now returns.

Moreover, it seems useless that this method is virtual. I seems to me that it could be marginally better for perf to make it a non-virtual inline and to hoist mIsRegularHTML from nsHTMLDocument to nsIDocument.

Also, IsXHTML() on nsHTMLDocument is redundant with IsCaseSensitive() and should probably be refactored into !IsHTML().

Marking as depending on bug 468708, because merge conflicts with landing that one would not be nice.
Component: Content → DOM
QA Contact: content → general
Attached patch PatchSplinter Review
Attachment #391265 - Flags: review?
Attachment #391265 - Flags: review? → review?(hsivonen)
Comment on attachment 391265 [details] [diff] [review]
Patch

>  // XXXbz should mIsRegularHTML be reset if someone manually calls
> // SetContentType() on this document?

Per HTML5, the only way to change the HTMLness flag is to call document.open() on a Document object.

> if (IsHTML())
>   return nsStyleSet::eHTMLPresHintSheet;

I'd use curly braces around the second line even though it is a single-statement block.

> if (IsHTML())
>   rv = GetElementsByTagName(NS_LITERAL_STRING("frameset"),
>  getter_AddRefs(nodeList));
> else

Curly braces would be good here, too.

With those curly braces, r=hsivonen. Thanks for fixing this!
Attachment #391265 - Flags: review?(hsivonen) → review+
Comment on attachment 391265 [details] [diff] [review]
Patch

Actually, I'm not sure if I'm authorized to grant an r+ on this code. I'll check.
Attachment #391265 - Flags: review+ → review?(hsivonen)
Comment on attachment 391265 [details] [diff] [review]
Patch

I checked. You should still get an sr from a content module peer before pushing to m-c.
Attachment #391265 - Flags: review?(hsivonen) → review+
Attachment #391265 - Flags: superreview?(jst)
Attachment #391265 - Flags: superreview?(jst) → superreview+
Pushed http://hg.mozilla.org/mozilla-central/rev/2f27256aa154
Assignee: nobody → dzbarsky
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: