Bug 115755 - Devirtualize Document class type checking
Summary: Devirtualize Document class type checking
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Ryosuke Niwa
Depends on:
Reported: 2013-05-07 13:50 PDT by Ryosuke Niwa
Modified: 2016-11-02 14:50 PDT (History)
13 users (show)

See Also:

Cleanup (12.00 KB, patch)
2013-05-07 16:26 PDT, Ryosuke Niwa
benjamin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryosuke Niwa 2013-05-07 13:50:48 PDT
Devirtualize Document class type checking

Document has a bunch of virtual bool is*Document() methods on it, but it also has
two bools for XHTML and HTML documents which is silly. We can merge them all
together into an enum of values and devirtualize the type checking methods.

This patch introduces the DocumentClass enum that is used to signal what subclass
of Document, or HTMLDocument, is being implemented.
Comment 1 Ryosuke Niwa 2013-05-07 16:26:00 PDT
Created attachment 200991 [details]
Comment 2 Benjamin Poulain 2013-05-07 16:37:54 PDT
Comment on attachment 200991 [details]

View in context: https://bugs.webkit.org/attachment.cgi?id=200991&action=review

> Source/WebCore/dom/Document.h:1486
> +    unsigned m_documentClasses;

I would just use a uchar8_t here. That way it fits on a word with the 3 boolean bellow.

> Source/WebCore/html/HTMLDocument.h:78
> +    HTMLDocument(Frame*, const KURL&, unsigned documentClasses = HTMLDocumentClass);

I think it should have a default of 0.

Otherwise, an caller may think passing something else override the HTMLDocumentClass. Which is not true because the constructor does the right thing.
Comment 3 Ryosuke Niwa 2013-05-07 18:59:29 PDT
Committed r149705: <http://trac.webkit.org/changeset/149705>