https://bugs.webkit.org/show_bug.cgi?id=44788, implement HTML5-compliant doctype...
authorhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Aug 2010 20:29:34 +0000 (20:29 +0000)
committerhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Aug 2010 20:29:34 +0000 (20:29 +0000)
Reviewed by Simon Fraser.

WebCore:

Rename the various modes to match the HTML5 specification:
    ParseMode -> CompatibilityMode
    CompatMode -> QuirksMode
    AlmostStrictMode -> LimitedQuirksMode
    StrictMode -> NoQuirksMode

Remove the htmlHacks() accessor from RenderStyle and make rendering code just go to the document
instead.  This makes switching modes avoid forcing all RenderStyles to detect as changed.

Clean up user stylesheets to minimize style recalculation when the mode is switched.

Fix bugs with the propagation of correct modes in the HTML5 parser.  Make sure the
dummy document created for fragment parsing properly inherits the real document's CompatibilityMode.
Make sure the tree builder properly changes the insertion mode to "BeforeHTML" after handling
a doctype token.

determineParseMode -> setCompatibilityModeFromDoctype, and it now implements the HTML5 algorithm
precisely.

* WebCore.exp.in:
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::styleForDocument):
(WebCore::CSSStyleSelector::applyProperty):
(WebCore::CSSStyleSelector::fontSizeForKeyword):
* dom/ClassNodeList.cpp:
(WebCore::ClassNodeList::ClassNodeList):
* dom/DecodedDataDocumentParser.cpp:
(WebCore::DecodedDataDocumentParser::appendBytes):
* dom/Document.cpp:
(WebCore::Document::Document):
(WebCore::Document::setCompatibilityMode):
(WebCore::Document::setDocType):
(WebCore::Document::unscheduleStyleRecalc):
(WebCore::Document::recalcStyle):
(WebCore::Document::updateStyleIfNeeded):
(WebCore::Document::createStyleSelector):
(WebCore::Document::implicitOpen):
(WebCore::Document::pageUserSheet):
(WebCore::Document::clearPageUserSheet):
(WebCore::Document::updatePageUserSheet):
(WebCore::Document::pageGroupUserSheets):
(WebCore::Document::clearPageGroupUserSheets):
(WebCore::Document::updatePageGroupUserSheets):
(WebCore::Document::findAnchor):
* dom/Document.h:
(WebCore::Document::):
(WebCore::Document::setCompatibilityModeFromDoctype):
(WebCore::Document::lockCompatibilityMode):
(WebCore::Document::compatibilityMode):
(WebCore::Document::inQuirksMode):
(WebCore::Document::inLimitedQuirksMode):
(WebCore::Document::inNoQuirksMode):
* dom/Element.cpp:
(WebCore::Element::clientWidth):
(WebCore::Element::clientHeight):
(WebCore::Element::webkitMatchesSelector):
* dom/NamedNodeMap.cpp:
(WebCore::NamedNodeMap::setClass):
* dom/Node.cpp:
(WebCore::Node::querySelector):
(WebCore::Node::querySelectorAll):
* dom/OptionElement.cpp:
(WebCore::OptionElement::collectOptionLabelOrText):
* dom/SelectorNodeList.cpp:
(WebCore::createSelectorNodeList):
* dom/StyleElement.cpp:
(WebCore::StyleElement::createSheet):
* dom/StyledElement.cpp:
(WebCore::StyledElement::createInlineStyleDecl):
(WebCore::StyledElement::parseMappedAttribute):
* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplaceSelectionCommand::shouldRemoveEndBR):
* html/HTMLBodyElement.cpp:
(WebCore::HTMLBodyElement::createLinkDecl):
* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::getContext):
* html/HTMLConstructionSite.cpp:
(WebCore::HTMLConstructionSite::insertDoctype):
* html/HTMLDocument.cpp:
(WebCore::HTMLDocument::HTMLDocument):
(WebCore::HTMLDocument::compatMode):
(WebCore::HTMLDocument::setCompatibilityModeFromDoctype):
* html/HTMLDocument.h:
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::setCSSStyleSheet):
* html/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::HTMLTreeBuilder):
(WebCore::HTMLTreeBuilder::FragmentParsingContext::FragmentParsingContext):
(WebCore::HTMLTreeBuilder::processDoctypeToken):
(WebCore::HTMLTreeBuilder::processStartTagForInBody):
(WebCore::HTMLTreeBuilder::defaultForInitial):
* html/HTMLViewSourceDocument.cpp:
(WebCore::HTMLViewSourceDocument::HTMLViewSourceDocument):
* loader/DocumentWriter.cpp:
(WebCore::DocumentWriter::replaceDocument):
(WebCore::DocumentWriter::reportDataReceived):
* loader/DocumentWriter.h:
* loader/ImageDocument.cpp:
(WebCore::ImageDocument::ImageDocument):
* loader/MediaDocument.cpp:
(WebCore::MediaDocument::MediaDocument):
* loader/PluginDocument.cpp:
(WebCore::PluginDocument::PluginDocument):
* loader/SinkDocument.cpp:
(WebCore::SinkDocument::SinkDocument):
* loader/TextDocument.cpp:
(WebCore::TextDocument::TextDocument):
* page/Page.cpp:
(WebCore::Page::userStyleSheetLocationChanged):
* page/PageGroup.cpp:
(WebCore::PageGroup::resetUserStyleCacheInAllFrames):
* page/Settings.cpp:
(WebCore::Settings::Settings):
(WebCore::Settings::setEnforceCSSMIMETypeInNoQuirksMode):
* page/Settings.h:
(WebCore::Settings::enforceCSSMIMETypeInNoQuirksMode):
* rendering/AutoTableLayout.cpp:
(WebCore::AutoTableLayout::recalcColumn):
* rendering/FixedTableLayout.cpp:
(WebCore::FixedTableLayout::calcPrefWidths):
* rendering/InlineFlowBox.cpp:
(WebCore::InlineFlowBox::paintBoxDecorations):
(WebCore::InlineFlowBox::paintMask):
(WebCore::InlineFlowBox::paintTextDecorations):
* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::paint):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::isSelfCollapsingBlock):
(WebCore::RenderBlock::collapseMargins):
(WebCore::RenderBlock::handleBottomOfBlock):
(WebCore::RenderBlock::calcInlinePrefWidths):
(WebCore::RenderBlock::calcBlockPrefWidths):
* rendering/RenderBlockLineLayout.cpp:
(WebCore::createInlineBoxForRenderer):
(WebCore::RenderBlock::findNextLineBreak):
* rendering/RenderBox.cpp:
(WebCore::RenderBox::calcPercentageHeight):
(WebCore::RenderBox::calcAbsoluteHorizontal):
(WebCore::RenderBox::calcAbsoluteHorizontalReplaced):
* rendering/RenderBox.h:
(WebCore::RenderBox::stretchesToViewHeight):
* rendering/RenderListItem.cpp:
(WebCore::getParentOfFirstLineBox):
* rendering/RenderTable.cpp:
(WebCore::RenderTable::layout):
* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::calcRowHeight):
* rendering/RootInlineBox.cpp:
(WebCore::RootInlineBox::verticallyAlignBoxes):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::diff):
* rendering/style/RenderStyle.h:
(WebCore::):
(WebCore::InheritedFlags::setBitDefaults):

WebKit/mac:

Rename the various modes to match the HTML5 specification:
    ParseMode -> CompatibilityMode
    CompatMode -> QuirksMode
    AlmostStrictMode -> LimitedQuirksMode
    StrictMode -> NoQuirksMode

Remove the htmlHacks() accessor from RenderStyle and make rendering code just go to the document
instead.  This makes switching modes avoid forcing all RenderStyles to detect as changed.

Clean up user stylesheets to minimize style recalculation when the mode is switched.

Fix bugs with the propagation of correct modes in the HTML5 parser.  Make sure the
dummy document created for fragment parsing properly inherits the real document's CompatibilityMode.
Make sure the tree builder properly changes the insertion mode to "BeforeHTML" after handling
a doctype token.

determineParseMode -> setCompatibilityModeFromDoctype, and it now implements the HTML5 algorithm
precisely.

* WebView/WebView.mm:
(-[WebView _preferencesChangedNotification:]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@66247 268f45cc-cd09-0410-ab3c-d52691b4dbfc

52 files changed:
LayoutTests/fast/dom/Document/document-write-doctype-expected.txt
LayoutTests/fast/dom/Document/script-tests/document-write-doctype.js
WebCore/ChangeLog
WebCore/WebCore.exp.in
WebCore/css/CSSStyleSelector.cpp
WebCore/dom/ClassNodeList.cpp
WebCore/dom/DecodedDataDocumentParser.cpp
WebCore/dom/Document.cpp
WebCore/dom/Document.h
WebCore/dom/Element.cpp
WebCore/dom/NamedNodeMap.cpp
WebCore/dom/Node.cpp
WebCore/dom/OptionElement.cpp
WebCore/dom/SelectorNodeList.cpp
WebCore/dom/StyleElement.cpp
WebCore/dom/StyledElement.cpp
WebCore/editing/ReplaceSelectionCommand.cpp
WebCore/html/HTMLBodyElement.cpp
WebCore/html/HTMLCanvasElement.cpp
WebCore/html/HTMLConstructionSite.cpp
WebCore/html/HTMLDocument.cpp
WebCore/html/HTMLDocument.h
WebCore/html/HTMLLinkElement.cpp
WebCore/html/HTMLTreeBuilder.cpp
WebCore/html/HTMLViewSourceDocument.cpp
WebCore/loader/DocumentWriter.cpp
WebCore/loader/DocumentWriter.h
WebCore/loader/ImageDocument.cpp
WebCore/loader/MediaDocument.cpp
WebCore/loader/PluginDocument.cpp
WebCore/loader/SinkDocument.cpp
WebCore/loader/TextDocument.cpp
WebCore/page/Page.cpp
WebCore/page/PageGroup.cpp
WebCore/page/Settings.cpp
WebCore/page/Settings.h
WebCore/rendering/AutoTableLayout.cpp
WebCore/rendering/FixedTableLayout.cpp
WebCore/rendering/InlineFlowBox.cpp
WebCore/rendering/InlineTextBox.cpp
WebCore/rendering/RenderBlock.cpp
WebCore/rendering/RenderBlockLineLayout.cpp
WebCore/rendering/RenderBox.cpp
WebCore/rendering/RenderBox.h
WebCore/rendering/RenderListItem.cpp
WebCore/rendering/RenderTable.cpp
WebCore/rendering/RenderTableSection.cpp
WebCore/rendering/RootInlineBox.cpp
WebCore/rendering/style/RenderStyle.cpp
WebCore/rendering/style/RenderStyle.h
WebKit/mac/ChangeLog
WebKit/mac/WebView/WebView.mm

index cd8d7ae..76698c7 100644 (file)
@@ -15,9 +15,9 @@ ensure that document.open clears the document but does not change the document p
 PASS iframeDocument is iframe.contentWindow.document
 document.open should also clear the document and reset the doctype)
 PASS treeAsString(iframeDocument) is "#document"
-PASS iframeDocument.compatMode is "BackCompat"
-document.write of "" should leave the document in quirksmode and add no content to the document
-PASS iframeDocument.compatMode is "BackCompat"
+PASS iframeDocument.compatMode is "CSS1Compat"
+document.write of "" should leave the document in no-quirks mode and add no content to the document
+PASS iframeDocument.compatMode is "CSS1Compat"
 PASS treeAsString(iframeDocument) is "#document"
 document.write calls can change the doctype until an <html> is created
 PASS iframeDocument.compatMode is "CSS1Compat"
index 48b6a66..db8b994 100644 (file)
@@ -49,11 +49,11 @@ debug("ensure that document.open clears the document but does not change the doc
 shouldBe("iframeDocument", "iframe.contentWindow.document");
 debug("document.open should also clear the document and reset the doctype)")
 shouldBeEqualToString("treeAsString(iframeDocument)", "#document");
-shouldBeEqualToString("iframeDocument.compatMode", "BackCompat");
+shouldBeEqualToString("iframeDocument.compatMode", "CSS1Compat");
 
-debug("document.write of \"\" should leave the document in quirksmode and add no content to the document")
+debug("document.write of \"\" should leave the document in no-quirks mode and add no content to the document")
 iframeDocument.write("");
-shouldBeEqualToString("iframeDocument.compatMode", "BackCompat");
+shouldBeEqualToString("iframeDocument.compatMode", "CSS1Compat");
 shouldBeEqualToString("treeAsString(iframeDocument)", "#document");
 
 debug("document.write calls can change the doctype until an &lt;html> is created")
index 8298f74..8c898e0 100644 (file)
@@ -1,3 +1,164 @@
+2010-08-27  David Hyatt  <hyatt@apple.com>
+
+        Reviewed by Simon Fraser.
+
+        https://bugs.webkit.org/show_bug.cgi?id=44788, implement HTML5-compliant doctype switching.
+
+        Rename the various modes to match the HTML5 specification:
+            ParseMode -> CompatibilityMode
+            CompatMode -> QuirksMode
+            AlmostStrictMode -> LimitedQuirksMode
+            StrictMode -> NoQuirksMode
+            
+        Remove the htmlHacks() accessor from RenderStyle and make rendering code just go to the document
+        instead.  This makes switching modes avoid forcing all RenderStyles to detect as changed.
+        
+        Clean up user stylesheets to minimize style recalculation when the mode is switched.
+        
+        Fix bugs with the propagation of correct modes in the HTML5 parser.  Make sure the
+        dummy document created for fragment parsing properly inherits the real document's CompatibilityMode.
+        Make sure the tree builder properly changes the insertion mode to "BeforeHTML" after handling
+        a doctype token.
+        
+        determineParseMode -> setCompatibilityModeFromDoctype, and it now implements the HTML5 algorithm
+        precisely.
+        
+        * WebCore.exp.in:
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::styleForDocument):
+        (WebCore::CSSStyleSelector::applyProperty):
+        (WebCore::CSSStyleSelector::fontSizeForKeyword):
+        * dom/ClassNodeList.cpp:
+        (WebCore::ClassNodeList::ClassNodeList):
+        * dom/DecodedDataDocumentParser.cpp:
+        (WebCore::DecodedDataDocumentParser::appendBytes):
+        * dom/Document.cpp:
+        (WebCore::Document::Document):
+        (WebCore::Document::setCompatibilityMode):
+        (WebCore::Document::setDocType):
+        (WebCore::Document::unscheduleStyleRecalc):
+        (WebCore::Document::recalcStyle):
+        (WebCore::Document::updateStyleIfNeeded):
+        (WebCore::Document::createStyleSelector):
+        (WebCore::Document::implicitOpen):
+        (WebCore::Document::pageUserSheet):
+        (WebCore::Document::clearPageUserSheet):
+        (WebCore::Document::updatePageUserSheet):
+        (WebCore::Document::pageGroupUserSheets):
+        (WebCore::Document::clearPageGroupUserSheets):
+        (WebCore::Document::updatePageGroupUserSheets):
+        (WebCore::Document::findAnchor):
+        * dom/Document.h:
+        (WebCore::Document::):
+        (WebCore::Document::setCompatibilityModeFromDoctype):
+        (WebCore::Document::lockCompatibilityMode):
+        (WebCore::Document::compatibilityMode):
+        (WebCore::Document::inQuirksMode):
+        (WebCore::Document::inLimitedQuirksMode):
+        (WebCore::Document::inNoQuirksMode):
+        * dom/Element.cpp:
+        (WebCore::Element::clientWidth):
+        (WebCore::Element::clientHeight):
+        (WebCore::Element::webkitMatchesSelector):
+        * dom/NamedNodeMap.cpp:
+        (WebCore::NamedNodeMap::setClass):
+        * dom/Node.cpp:
+        (WebCore::Node::querySelector):
+        (WebCore::Node::querySelectorAll):
+        * dom/OptionElement.cpp:
+        (WebCore::OptionElement::collectOptionLabelOrText):
+        * dom/SelectorNodeList.cpp:
+        (WebCore::createSelectorNodeList):
+        * dom/StyleElement.cpp:
+        (WebCore::StyleElement::createSheet):
+        * dom/StyledElement.cpp:
+        (WebCore::StyledElement::createInlineStyleDecl):
+        (WebCore::StyledElement::parseMappedAttribute):
+        * editing/ReplaceSelectionCommand.cpp:
+        (WebCore::ReplaceSelectionCommand::shouldRemoveEndBR):
+        * html/HTMLBodyElement.cpp:
+        (WebCore::HTMLBodyElement::createLinkDecl):
+        * html/HTMLCanvasElement.cpp:
+        (WebCore::HTMLCanvasElement::getContext):
+        * html/HTMLConstructionSite.cpp:
+        (WebCore::HTMLConstructionSite::insertDoctype):
+        * html/HTMLDocument.cpp:
+        (WebCore::HTMLDocument::HTMLDocument):
+        (WebCore::HTMLDocument::compatMode):
+        (WebCore::HTMLDocument::setCompatibilityModeFromDoctype):
+        * html/HTMLDocument.h:
+        * html/HTMLLinkElement.cpp:
+        (WebCore::HTMLLinkElement::setCSSStyleSheet):
+        * html/HTMLTreeBuilder.cpp:
+        (WebCore::HTMLTreeBuilder::HTMLTreeBuilder):
+        (WebCore::HTMLTreeBuilder::FragmentParsingContext::FragmentParsingContext):
+        (WebCore::HTMLTreeBuilder::processDoctypeToken):
+        (WebCore::HTMLTreeBuilder::processStartTagForInBody):
+        (WebCore::HTMLTreeBuilder::defaultForInitial):
+        * html/HTMLViewSourceDocument.cpp:
+        (WebCore::HTMLViewSourceDocument::HTMLViewSourceDocument):
+        * loader/DocumentWriter.cpp:
+        (WebCore::DocumentWriter::replaceDocument):
+        (WebCore::DocumentWriter::reportDataReceived):
+        * loader/DocumentWriter.h:
+        * loader/ImageDocument.cpp:
+        (WebCore::ImageDocument::ImageDocument):
+        * loader/MediaDocument.cpp:
+        (WebCore::MediaDocument::MediaDocument):
+        * loader/PluginDocument.cpp:
+        (WebCore::PluginDocument::PluginDocument):
+        * loader/SinkDocument.cpp:
+        (WebCore::SinkDocument::SinkDocument):
+        * loader/TextDocument.cpp:
+        (WebCore::TextDocument::TextDocument):
+        * page/Page.cpp:
+        (WebCore::Page::userStyleSheetLocationChanged):
+        * page/PageGroup.cpp:
+        (WebCore::PageGroup::resetUserStyleCacheInAllFrames):
+        * page/Settings.cpp:
+        (WebCore::Settings::Settings):
+        (WebCore::Settings::setEnforceCSSMIMETypeInNoQuirksMode):
+        * page/Settings.h:
+        (WebCore::Settings::enforceCSSMIMETypeInNoQuirksMode):
+        * rendering/AutoTableLayout.cpp:
+        (WebCore::AutoTableLayout::recalcColumn):
+        * rendering/FixedTableLayout.cpp:
+        (WebCore::FixedTableLayout::calcPrefWidths):
+        * rendering/InlineFlowBox.cpp:
+        (WebCore::InlineFlowBox::paintBoxDecorations):
+        (WebCore::InlineFlowBox::paintMask):
+        (WebCore::InlineFlowBox::paintTextDecorations):
+        * rendering/InlineTextBox.cpp:
+        (WebCore::InlineTextBox::paint):
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::isSelfCollapsingBlock):
+        (WebCore::RenderBlock::collapseMargins):
+        (WebCore::RenderBlock::handleBottomOfBlock):
+        (WebCore::RenderBlock::calcInlinePrefWidths):
+        (WebCore::RenderBlock::calcBlockPrefWidths):
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::createInlineBoxForRenderer):
+        (WebCore::RenderBlock::findNextLineBreak):
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::calcPercentageHeight):
+        (WebCore::RenderBox::calcAbsoluteHorizontal):
+        (WebCore::RenderBox::calcAbsoluteHorizontalReplaced):
+        * rendering/RenderBox.h:
+        (WebCore::RenderBox::stretchesToViewHeight):
+        * rendering/RenderListItem.cpp:
+        (WebCore::getParentOfFirstLineBox):
+        * rendering/RenderTable.cpp:
+        (WebCore::RenderTable::layout):
+        * rendering/RenderTableSection.cpp:
+        (WebCore::RenderTableSection::calcRowHeight):
+        * rendering/RootInlineBox.cpp:
+        (WebCore::RootInlineBox::verticallyAlignBoxes):
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::RenderStyle::diff):
+        * rendering/style/RenderStyle.h:
+        (WebCore::):
+        (WebCore::InheritedFlags::setBitDefaults):
+
 2010-08-27  Gavin Barraclough  <barraclough@apple.com>
 
         Reviewed by Oliver Hunt.
index e1b7c22..02b217a 100644 (file)
@@ -733,7 +733,7 @@ __ZN7WebCore8Settings31setShrinksStandaloneImagesToFitEb
 __ZN7WebCore8Settings32setAcceleratedCompositingEnabledEb
 __ZN7WebCore8Settings32setNeedsAdobeFrameReloadingQuirkEb
 __ZN7WebCore8Settings33setDownloadableBinaryFontsEnabledEb
-__ZN7WebCore8Settings33setEnforceCSSMIMETypeInStrictModeEb
+__ZN7WebCore8Settings35setEnforceCSSMIMETypeInNoQuirksModeEb
 __ZN7WebCore8Settings34setLocalFileContentSniffingEnabledEb
 __ZN7WebCore8Settings35setAllowUniversalAccessFromFileURLsEb
 __ZN7WebCore8Settings35setExperimentalNotificationsEnabledEb
index 70bf1dd..a595888 100644 (file)
@@ -1138,8 +1138,6 @@ PassRefPtr<RenderStyle> CSSStyleSelector::styleForDocument(Document* document)
 
     documentStyle->setFontDescription(fontDescription);
     documentStyle->font().update(0);
-    if (document->inCompatMode())
-        documentStyle->setHtmlHacks(true); // enable html specific rendering tricks
         
     return documentStyle.release();
 }
@@ -4083,10 +4081,10 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
                     fontDescription.setKeywordSize(primitiveValue->getIdent() - CSSValueXxSmall + 1);
                     break;
                 case CSSValueLarger:
-                    size = largerFontSize(oldSize, m_style->htmlHacks());
+                    size = largerFontSize(oldSize, m_checker.m_document->inQuirksMode());
                     break;
                 case CSSValueSmaller:
-                    size = smallerFontSize(oldSize, m_style->htmlHacks());
+                    size = smallerFontSize(oldSize, m_checker.m_document->inQuirksMode());
                     break;
                 default:
                     return;
@@ -6312,7 +6310,7 @@ float CSSStyleSelector::fontSizeForKeyword(Document* document, int keyword, bool
     if (!settings)
         return 1.0f;
 
-    bool quirksMode = document->inCompatMode();
+    bool quirksMode = document->inQuirksMode();
     int mediumSize = fixed ? settings->defaultFixedFontSize() : settings->defaultFontSize();
     if (mediumSize >= fontSizeTableMin && mediumSize <= fontSizeTableMax) {
         // Look up the entry in the table.
index d482359..60d668b 100644 (file)
@@ -37,7 +37,7 @@ namespace WebCore {
 
 ClassNodeList::ClassNodeList(PassRefPtr<Node> rootNode, const String& classNames)
     : DynamicNodeList(rootNode)
-    , m_classNames(classNames, m_rootNode->document()->inCompatMode())
+    , m_classNames(classNames, m_rootNode->document()->inQuirksMode())
     , m_originalClassNames(classNames)
 {
 }
index 51cc847..39bf8e4 100644 (file)
@@ -50,7 +50,7 @@ void DecodedDataDocumentParser::appendBytes(DocumentWriter* writer , const char*
     if (decoded.isEmpty())
         return;
 
-    writer->reportDataRecieved();
+    writer->reportDataReceived();
 
     append(decoded);
 }
index 87db378..9e3c487 100644 (file)
@@ -353,6 +353,8 @@ private:
 
 Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML)
     : ContainerNode(0)
+    , m_compatibilityMode(NoQuirksMode)
+    , m_compatibilityModeLocked(false)
     , m_domTreeVersion(0)
     , m_styleSheets(StyleSheetList::create(this))
     , m_styleRecalcTimer(this, &Document::styleRecalcTimerFired)
@@ -424,8 +426,6 @@ Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML)
     m_bParsing = false;
     m_wellFormed = false;
 
-    setParseMode(Strict);
-
     m_textColor = Color::black;
     m_listenerTypes = 0;
     setInDocument();
@@ -581,6 +581,20 @@ void Document::destroyAllWrapperCaches()
 }
 #endif
 
+void Document::setCompatibilityMode(CompatibilityMode mode)
+{
+    if (m_compatibilityModeLocked || mode == m_compatibilityMode)
+        return;
+    ASSERT(!documentElement() && !m_styleSheets->length());
+    bool wasInQuirksMode = inQuirksMode();
+    m_compatibilityMode = mode;
+    if (inQuirksMode() != wasInQuirksMode) {
+        // All user stylesheets have to reparse using the different mode.
+        clearPageUserSheet();
+        clearPageGroupUserSheets();
+    }
+}
+
 void Document::resetLinkColor()
 {
     m_linkColor = Color(0, 0, 238);
@@ -599,14 +613,10 @@ void Document::resetActiveLinkColor()
 void Document::setDocType(PassRefPtr<DocumentType> docType)
 {
     // This should never be called more than once.
-    // Note: This is not a public DOM method and can only be called by the parser.
     ASSERT(!m_docType || !docType);
-    if (m_docType && docType)
-        return;
     m_docType = docType;
     if (m_docType)
         m_docType->setDocument(this);
-    determineParseMode();
 }
 
 DOMImplementation* Document::implementation() const
@@ -1394,6 +1404,7 @@ void Document::unscheduleStyleRecalc()
         documentsThatNeedStyleRecalc->remove(this);
 
     m_styleRecalcTimer.stop();
+    m_pendingStyleRecalcShouldForce = false;
 }
 
 void Document::styleRecalcTimerFired(Timer<Document>*)
@@ -1431,6 +1442,9 @@ void Document::recalcStyle(StyleChange change)
     ASSERT(!renderer() || renderArena());
     if (!renderer() || !renderArena())
         goto bail_out;
+    
+    if (m_pendingStyleRecalcShouldForce)
+        change = Force;
 
     if (change == Force) {
         // style selector may set this again during recalc
@@ -1488,9 +1502,7 @@ void Document::updateStyleIfNeeded()
     if (m_frame)
         m_frame->animation()->beginAnimationUpdate();
         
-    recalcStyle(m_pendingStyleRecalcShouldForce ? Force : NoChange);
-    
-    m_pendingStyleRecalcShouldForce = false;
+    recalcStyle(NoChange);
 
     // Tell the animation controller that updateStyleIfNeeded is finished and it can do any post-processing
     if (m_frame)
@@ -1623,7 +1635,7 @@ void Document::createStyleSelector()
     if (Settings* docSettings = settings())
         matchAuthorAndUserStyles = docSettings->authorAndUserStylesEnabled();
     m_styleSelector.set(new CSSStyleSelector(this, m_styleSheets.get(), m_mappedElementSheet.get(), pageUserSheet(), pageGroupUserSheets(), 
-                                             !inCompatMode(), matchAuthorAndUserStyles));
+                                             !inQuirksMode(), matchAuthorAndUserStyles));
 }
 
 void Document::attach()
@@ -1846,6 +1858,8 @@ void Document::implicitOpen()
 
     removeChildren();
 
+    setCompatibilityMode(NoQuirksMode);
+
     m_parser = createParser();
     setParsing(true);
 
@@ -2222,14 +2236,23 @@ CSSStyleSheet* Document::pageUserSheet()
     // Parse the sheet and cache it.
     m_pageUserSheet = CSSStyleSheet::createInline(this, settings()->userStyleSheetLocation());
     m_pageUserSheet->setIsUserStyleSheet(true);
-    m_pageUserSheet->parseString(userSheetText, !inCompatMode());
+    m_pageUserSheet->parseString(userSheetText, !inQuirksMode());
     return m_pageUserSheet.get();
 }
 
 void Document::clearPageUserSheet()
 {
-    m_pageUserSheet = 0;
-    styleSelectorChanged(DeferRecalcStyle);
+    if (m_pageUserSheet) {
+        m_pageUserSheet = 0;
+        styleSelectorChanged(DeferRecalcStyle);
+    }
+}
+
+void Document::updatePageUserSheet()
+{
+    clearPageUserSheet();
+    if (pageUserSheet())
+        styleSelectorChanged(RecalcStyleImmediately);
 }
 
 const Vector<RefPtr<CSSStyleSheet> >* Document::pageGroupUserSheets() const
@@ -2259,7 +2282,7 @@ const Vector<RefPtr<CSSStyleSheet> >* Document::pageGroupUserSheets() const
                 continue;
             RefPtr<CSSStyleSheet> parsedSheet = CSSStyleSheet::createInline(const_cast<Document*>(this), sheet->url());
             parsedSheet->setIsUserStyleSheet(sheet->level() == UserStyleSheet::UserLevel);
-            parsedSheet->parseString(sheet->source(), !inCompatMode());
+            parsedSheet->parseString(sheet->source(), !inQuirksMode());
             if (!m_pageGroupUserSheets)
                 m_pageGroupUserSheets.set(new Vector<RefPtr<CSSStyleSheet> >);
             m_pageGroupUserSheets->append(parsedSheet.release());
@@ -2271,9 +2294,18 @@ const Vector<RefPtr<CSSStyleSheet> >* Document::pageGroupUserSheets() const
 
 void Document::clearPageGroupUserSheets()
 {
-    m_pageGroupUserSheets.clear();
     m_pageGroupUserSheetCacheValid = false;
-    styleSelectorChanged(DeferRecalcStyle);
+    if (m_pageGroupUserSheets && m_pageGroupUserSheets->size()) {
+        m_pageGroupUserSheets->clear();
+        styleSelectorChanged(DeferRecalcStyle);
+    }
+}
+
+void Document::updatePageGroupUserSheets()
+{
+    clearPageGroupUserSheets();
+    if (pageGroupUserSheets() && pageGroupUserSheets()->size())
+        styleSelectorChanged(RecalcStyleImmediately);
 }
 
 CSSStyleSheet* Document::elementSheet()
@@ -4517,7 +4549,7 @@ Element* Document::findAnchor(const String& name)
     for (Node* node = this; node; node = node->traverseNextNode()) {
         if (node->hasTagName(aTag)) {
             HTMLAnchorElement* anchor = static_cast<HTMLAnchorElement*>(node);
-            if (inCompatMode()) {
+            if (inQuirksMode()) {
                 // Quirks mode, case insensitive comparison of names.
                 if (equalIgnoringCase(anchor->name(), name))
                     return anchor;
index 79db798..3381bea 100644 (file)
@@ -553,9 +553,11 @@ public:
 
     CSSStyleSheet* pageUserSheet();
     void clearPageUserSheet();
+    void updatePageUserSheet();
 
     const Vector<RefPtr<CSSStyleSheet> >* pageGroupUserSheets() const;
     void clearPageGroupUserSheets();
+    void updatePageGroupUserSheets();
 
     CSSStyleSheet* elementSheet();
     CSSStyleSheet* mappedElementSheet();
@@ -572,14 +574,16 @@ public:
     
     bool paginated() const { return printing() || paginatedForScreen(); }
 
-    enum ParseMode { Compat, AlmostStrict, Strict };
+    enum CompatibilityMode { QuirksMode, LimitedQuirksMode, NoQuirksMode };
 
-    void setParseMode(ParseMode m) { m_parseMode = m; }
-    ParseMode parseMode() const { return m_parseMode; }
+    virtual void setCompatibilityModeFromDoctype() { }
+    void setCompatibilityMode(CompatibilityMode m);
+    void lockCompatibilityMode() { m_compatibilityModeLocked = true; }
+    CompatibilityMode compatibilityMode() const { return m_compatibilityMode; }
 
-    bool inCompatMode() const { return m_parseMode == Compat; }
-    bool inAlmostStrictMode() const { return m_parseMode == AlmostStrict; }
-    bool inStrictMode() const { return m_parseMode == Strict; }
+    bool inQuirksMode() const { return m_compatibilityMode == QuirksMode; }
+    bool inLimitedQuirksMode() const { return m_compatibilityMode == LimitedQuirksMode; }
+    bool inNoQuirksMode() const { return m_compatibilityMode == NoQuirksMode; }
     
     void setParsing(bool);
     bool parsing() const { return m_bParsing; }
@@ -1015,7 +1019,6 @@ private:
 
     virtual bool isDocument() const { return true; }
     virtual void removedLastRef();
-    virtual void determineParseMode() { }
 
     virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
 
@@ -1103,7 +1106,8 @@ private:
 
     bool m_ignoreAutofocus;
 
-    ParseMode m_parseMode;
+    CompatibilityMode m_compatibilityMode;
+    bool m_compatibilityModeLocked; // This is cheaper than making setCompatibilityMode virtual.
 
     Color m_textColor;
 
index 26bca23..abe3da3 100644 (file)
@@ -367,9 +367,9 @@ int Element::clientWidth()
 
     // When in strict mode, clientWidth for the document element should return the width of the containing frame.
     // When in quirks mode, clientWidth for the body element should return the width of the containing frame.
-    bool inCompatMode = document()->inCompatMode();
-    if ((!inCompatMode && document()->documentElement() == this) ||
-        (inCompatMode && isHTMLElement() && document()->body() == this)) {
+    bool inQuirksMode = document()->inQuirksMode();
+    if ((!inQuirksMode && document()->documentElement() == this) ||
+        (inQuirksMode && isHTMLElement() && document()->body() == this)) {
         if (FrameView* view = document()->view()) {
             if (RenderView* renderView = document()->renderView())
                 return adjustForAbsoluteZoom(view->layoutWidth(), renderView);
@@ -387,10 +387,10 @@ int Element::clientHeight()
 
     // When in strict mode, clientHeight for the document element should return the height of the containing frame.
     // When in quirks mode, clientHeight for the body element should return the height of the containing frame.
-    bool inCompatMode = document()->inCompatMode();     
+    bool inQuirksMode = document()->inQuirksMode();     
 
-    if ((!inCompatMode && document()->documentElement() == this) ||
-        (inCompatMode && isHTMLElement() && document()->body() == this)) {
+    if ((!inQuirksMode && document()->documentElement() == this) ||
+        (inQuirksMode && isHTMLElement() && document()->body() == this)) {
         if (FrameView* view = document()->view()) {
             if (RenderView* renderView = document()->renderView())
                 return adjustForAbsoluteZoom(view->layoutHeight(), renderView);
@@ -1498,7 +1498,7 @@ bool Element::webkitMatchesSelector(const String& selector, ExceptionCode& ec)
         return false;
     }
 
-    bool strictParsing = !document()->inCompatMode();
+    bool strictParsing = !document()->inQuirksMode();
     CSSParser p(strictParsing);
 
     CSSSelectorList selectorList;
index 7c9298a..bc56f7e 100644 (file)
@@ -309,7 +309,7 @@ void NamedNodeMap::setClass(const String& classStr)
         return;
     }
 
-    m_classNames.set(classStr, element()->document()->inCompatMode()); 
+    m_classNames.set(classStr, element()->document()->inQuirksMode()); 
 }
 
 int NamedNodeMap::declCount() const
index f4a81ed..bf24b58 100644 (file)
@@ -1641,7 +1641,7 @@ PassRefPtr<Element> Node::querySelector(const String& selectors, ExceptionCode&
         ec = SYNTAX_ERR;
         return 0;
     }
-    bool strictParsing = !document()->inCompatMode();
+    bool strictParsing = !document()->inQuirksMode();
     CSSParser p(strictParsing);
 
     CSSSelectorList querySelectorList;
@@ -1688,7 +1688,7 @@ PassRefPtr<NodeList> Node::querySelectorAll(const String& selectors, ExceptionCo
         ec = SYNTAX_ERR;
         return 0;
     }
-    bool strictParsing = !document()->inCompatMode();
+    bool strictParsing = !document()->inQuirksMode();
     CSSParser p(strictParsing);
 
     CSSSelectorList querySelectorList;
index 1de5fa4..240a8fc 100644 (file)
@@ -73,7 +73,7 @@ String OptionElement::collectOptionLabelOrText(const OptionElementData& data, co
     String text;
 
     // WinIE does not use the label attribute, so as a quirk, we ignore it.
-    if (!document->inCompatMode())
+    if (!document->inQuirksMode())
         text = data.label();
     if (text.isEmpty())
         text = collectOptionInnerText(element);
index 5beaaee..039a29f 100644 (file)
@@ -46,7 +46,7 @@ PassRefPtr<StaticNodeList> createSelectorNodeList(Node* rootNode, const CSSSelec
     Vector<RefPtr<Node> > nodes;
     Document* document = rootNode->document();
     CSSSelector* onlySelector = querySelectorList.hasOneSelector() ? querySelectorList.first() : 0;
-    bool strictParsing = !document->inCompatMode();
+    bool strictParsing = !document->inQuirksMode();
 
     CSSStyleSelector::SelectorChecker selectorChecker(document, strictParsing);
 
index 8dc2489..c3a7300 100644 (file)
@@ -137,7 +137,7 @@ void StyleElement::createSheet(Element* e, int startLineNumber, const String& te
             document->addPendingSheet();
             m_loading = true;
             m_sheet = CSSStyleSheet::create(e, String(), KURL(), document->inputEncoding());
-            m_sheet->parseStringAtLine(text, !document->inCompatMode(), startLineNumber);
+            m_sheet->parseStringAtLine(text, !document->inQuirksMode(), startLineNumber);
             m_sheet->setMedia(mediaList.get());
             m_sheet->setTitle(e->title());
             m_loading = false;
index 9b22f1d..a158e2e 100644 (file)
@@ -126,7 +126,7 @@ void StyledElement::createInlineStyleDecl()
     m_inlineStyleDecl = CSSMutableStyleDeclaration::create();
     m_inlineStyleDecl->setParent(document()->elementSheet());
     m_inlineStyleDecl->setNode(this);
-    m_inlineStyleDecl->setStrictParsing(isHTMLElement() && !document()->inCompatMode());
+    m_inlineStyleDecl->setStrictParsing(isHTMLElement() && !document()->inQuirksMode());
 }
 
 void StyledElement::destroyInlineStyleDecl()
@@ -234,7 +234,7 @@ void StyledElement::parseMappedAttribute(Attribute* attr)
         if (attributeMap()) {
             if (attr->isNull())
                 attributeMap()->setIdForStyleResolution(nullAtom);
-            else if (document()->inCompatMode())
+            else if (document()->inQuirksMode())
                 attributeMap()->setIdForStyleResolution(attr->value().lower());
             else
                 attributeMap()->setIdForStyleResolution(attr->value());
index d497f30..a042230 100644 (file)
@@ -1115,7 +1115,7 @@ bool ReplaceSelectionCommand::shouldRemoveEndBR(Node* endBR, const VisiblePositi
         return false;
     
     // Remove the br if it is collapsed away and so is unnecessary.
-    if (!document()->inStrictMode() && isEndOfBlock(visiblePos) && !isStartOfParagraph(visiblePos))
+    if (!document()->inNoQuirksMode() && isEndOfBlock(visiblePos) && !isStartOfParagraph(visiblePos))
         return true;
         
     // A br that was originally holding a line open should be displaced by inserted content or turned into a line break.
index 38463ec..9877aa6 100644 (file)
@@ -68,7 +68,7 @@ void HTMLBodyElement::createLinkDecl()
     m_linkDecl = CSSMutableStyleDeclaration::create();
     m_linkDecl->setParent(document()->elementSheet());
     m_linkDecl->setNode(this);
-    m_linkDecl->setStrictParsing(!document()->inCompatMode());
+    m_linkDecl->setStrictParsing(!document()->inQuirksMode());
 }
 
 bool HTMLBodyElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
index 7463551..d398bfd 100644 (file)
@@ -146,7 +146,7 @@ CanvasRenderingContext* HTMLCanvasElement::getContext(const String& type, Canvas
             if (Settings* settings = document()->settings())
                 usesDashbardCompatibilityMode = settings->usesDashboardBackwardCompatibilityMode();
 #endif
-            m_context = adoptPtr(new CanvasRenderingContext2D(this, document()->inCompatMode(), usesDashbardCompatibilityMode));
+            m_context = adoptPtr(new CanvasRenderingContext2D(this, document()->inQuirksMode(), usesDashbardCompatibilityMode));
 #if ENABLE(ACCELERATED_2D_CANVAS) && USE(ACCELERATED_COMPOSITING)
             if (m_context) {
                 // Need to make sure a RenderLayer and compositing layer get created for the Canvas
index 8735cd2..b45ec6e 100644 (file)
@@ -203,10 +203,11 @@ void HTMLConstructionSite::insertDoctype(AtomicHTMLToken& token)
 {
     ASSERT(token.type() == HTMLToken::DOCTYPE);
     attach(m_document, DocumentType::create(m_document, token.name(), String::adopt(token.publicIdentifier()), String::adopt(token.systemIdentifier())));
-    // FIXME: Move quirks mode detection from DocumentType element to here.
-    notImplemented();
+    
     if (token.forceQuirks())
-        m_document->setParseMode(Document::Compat);
+        m_document->setCompatibilityMode(Document::QuirksMode);
+    else
+        m_document->setCompatibilityModeFromDoctype();
 }
 
 void HTMLConstructionSite::insertComment(AtomicHTMLToken& token)
index 01538df..d68a8cc 100644 (file)
@@ -84,7 +84,6 @@ HTMLDocument::HTMLDocument(Frame* frame, const KURL& url)
     : Document(frame, url, false, true)
 {
     clearXMLVersion();
-    setParseMode(Compat);
 }
 
 HTMLDocument::~HTMLDocument()
@@ -139,7 +138,7 @@ void HTMLDocument::setDesignMode(const String& value)
 
 String HTMLDocument::compatMode() const
 {
-    return inCompatMode() ? "BackCompat" : "CSS1Compat";
+    return inQuirksMode() ? "BackCompat" : "CSS1Compat";
 }
 
 Element* HTMLDocument::activeElement()
@@ -343,65 +342,97 @@ void HTMLDocument::removeExtraNamedItem(const AtomicString& name)
     removeItemFromMap(m_extraNamedItemCounts, name);
 }
 
-void HTMLDocument::determineParseMode()
+void HTMLDocument::setCompatibilityModeFromDoctype()
 {
-    // FIXME: It's terrible that this code runs separately and isn't just built in to the
-    // HTML tokenizer/parser.
-
-    // This code more or less mimics Mozilla's implementation (specifically the
-    // doctype parsing implemented by David Baron in Mozilla's nsParser.cpp).
-    //
-    // There are three possible parse modes:
-    // COMPAT - quirks mode emulates WinIE and NS4.  CSS parsing is also relaxed in this mode, e.g., unit types can
+    // There are three possible compatibility modes:
+    // Quirks - quirks mode emulates WinIE and NS4.  CSS parsing is also relaxed in this mode, e.g., unit types can
     // be omitted from numbers.
-    // ALMOST STRICT - This mode is identical to strict mode except for its treatment of line-height in the inline box model.  For
-    // now (until the inline box model is re-written), this mode is identical to STANDARDS mode.
-    // STRICT - no quirks apply.  Web pages will obey the specifications to the letter.
-    bool wasInCompatMode = inCompatMode();
+    // Limited Quirks - This mode is identical to no-quirks mode except for its treatment of line-height in the inline box model.  
+    // No Quirks - no quirks apply.  Web pages will obey the specifications to the letter.
     DocumentType* docType = doctype();
-    if (!docType || !equalIgnoringCase(docType->name(), "html"))
-        // No doctype found at all or the doctype is not HTML.  Default to quirks mode and Html4.
-        setParseMode(Compat);
-    else if (!doctype()->systemId().isEmpty() && equalIgnoringCase(docType->systemId(), "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd"))
-        // Assume quirks mode for this particular system ID.  In the HTML5 spec, this is the only
-        // system identifier that is examined.
-        setParseMode(Compat);
-    else if (docType->publicId().isEmpty())
-        // A doctype without a public ID means use strict mode.
-        setParseMode(Strict);
-    else {
-        // We have to check a list of public IDs to see what we
-        // should do.
-        String lowerPubID = docType->publicId().lower();
-        CString pubIDStr = lowerPubID.latin1();
-       
-        // Look up the entry in our gperf-generated table.
-        const PubIDInfo* doctypeEntry = findDoctypeEntry(pubIDStr.data(), pubIDStr.length());
-        if (!doctypeEntry)
-            // The DOCTYPE is not in the list.  Assume strict mode.
-            setParseMode(Strict);
-        else {
-            switch (docType->systemId().isEmpty() ?
-                    doctypeEntry->mode_if_no_sysid :
-                    doctypeEntry->mode_if_sysid) {
-                case PubIDInfo::eQuirks3:
-                case PubIDInfo::eQuirks:
-                    setParseMode(Compat);
-                    break;
-                case PubIDInfo::eAlmostStandards:
-                    setParseMode(AlmostStrict);
-                    break;
-                 default:
-                    ASSERT(false);
-            }
-        }
+    if (!docType)
+        return;
+
+    // Check for Quirks Mode.
+    const String& publicId = docType->publicId();
+    if (docType->name() != "html"
+        || publicId.startsWith("+//Silmaril//dtd html Pro v0r11 19970101//", false)
+        || publicId.startsWith("-//AdvaSoft Ltd//DTD HTML 3.0 asWedit + extensions//", false)
+        || publicId.startsWith("-//AS//DTD HTML 3.0 asWedit + extensions//", false)
+        || publicId.startsWith("-//IETF//DTD HTML 2.0 Level 1//", false)
+        || publicId.startsWith("-//IETF//DTD HTML 2.0 Level 2//", false)
+        || publicId.startsWith("-//IETF//DTD HTML 2.0 Strict Level 1//", false)
+        || publicId.startsWith("-//IETF//DTD HTML 2.0 Strict Level 2//", false)
+        || publicId.startsWith("-//IETF//DTD HTML 2.0 Strict//", false)
+        || publicId.startsWith("-//IETF//DTD HTML 2.0//", false)
+        || publicId.startsWith("-//IETF//DTD HTML 2.1E//", false)
+        || publicId.startsWith("-//IETF//DTD HTML 3.0//", false)
+        || publicId.startsWith("-//IETF//DTD HTML 3.2 Final//", false)
+        || publicId.startsWith("-//IETF//DTD HTML 3.2//", false)
+        || publicId.startsWith("-//IETF//DTD HTML 3//", false)
+        || publicId.startsWith("-//IETF//DTD HTML Level 0//", false)
+        || publicId.startsWith("-//IETF//DTD HTML Level 1//", false)
+        || publicId.startsWith("-//IETF//DTD HTML Level 2//", false)
+        || publicId.startsWith("-//IETF//DTD HTML Level 3//", false)
+        || publicId.startsWith("-//IETF//DTD HTML Strict Level 0//", false)
+        || publicId.startsWith("-//IETF//DTD HTML Strict Level 1//", false)
+        || publicId.startsWith("-//IETF//DTD HTML Strict Level 2//", false)
+        || publicId.startsWith("-//IETF//DTD HTML Strict Level 3//", false)
+        || publicId.startsWith("-//IETF//DTD HTML Strict//", false)
+        || publicId.startsWith("-//IETF//DTD HTML//", false)
+        || publicId.startsWith("-//Metrius//DTD Metrius Presentational//", false)
+        || publicId.startsWith("-//Microsoft//DTD Internet Explorer 2.0 HTML Strict//", false)
+        || publicId.startsWith("-//Microsoft//DTD Internet Explorer 2.0 HTML//", false)
+        || publicId.startsWith("-//Microsoft//DTD Internet Explorer 2.0 Tables//", false)
+        || publicId.startsWith("-//Microsoft//DTD Internet Explorer 3.0 HTML Strict//", false)
+        || publicId.startsWith("-//Microsoft//DTD Internet Explorer 3.0 HTML//", false)
+        || publicId.startsWith("-//Microsoft//DTD Internet Explorer 3.0 Tables//", false)
+        || publicId.startsWith("-//Netscape Comm. Corp.//DTD HTML//", false)
+        || publicId.startsWith("-//Netscape Comm. Corp.//DTD Strict HTML//", false)
+        || publicId.startsWith("-//O'Reilly and Associates//DTD HTML 2.0//", false)
+        || publicId.startsWith("-//O'Reilly and Associates//DTD HTML Extended 1.0//", false)
+        || publicId.startsWith("-//O'Reilly and Associates//DTD HTML Extended Relaxed 1.0//", false)
+        || publicId.startsWith("-//SoftQuad Software//DTD HoTMetaL PRO 6.0::19990601::extensions to HTML 4.0//", false)
+        || publicId.startsWith("-//SoftQuad//DTD HoTMetaL PRO 4.0::19971010::extensions to HTML 4.0//", false)
+        || publicId.startsWith("-//Spyglass//DTD HTML 2.0 Extended//", false)
+        || publicId.startsWith("-//SQ//DTD HTML 2.0 HoTMetaL + extensions//", false)
+        || publicId.startsWith("-//Sun Microsystems Corp.//DTD HotJava HTML//", false)
+        || publicId.startsWith("-//Sun Microsystems Corp.//DTD HotJava Strict HTML//", false)
+        || publicId.startsWith("-//W3C//DTD HTML 3 1995-03-24//", false)
+        || publicId.startsWith("-//W3C//DTD HTML 3.2 Draft//", false)
+        || publicId.startsWith("-//W3C//DTD HTML 3.2 Final//", false)
+        || publicId.startsWith("-//W3C//DTD HTML 3.2//", false)
+        || publicId.startsWith("-//W3C//DTD HTML 3.2S Draft//", false)
+        || publicId.startsWith("-//W3C//DTD HTML 4.0 Frameset//", false)
+        || publicId.startsWith("-//W3C//DTD HTML 4.0 Transitional//", false)
+        || publicId.startsWith("-//W3C//DTD HTML Experimental 19960712//", false)
+        || publicId.startsWith("-//W3C//DTD HTML Experimental 970421//", false)
+        || publicId.startsWith("-//W3C//DTD W3 HTML//", false)
+        || publicId.startsWith("-//W3O//DTD W3 HTML 3.0//", false)
+        || equalIgnoringCase(publicId, "-//W3O//DTD W3 HTML Strict 3.0//EN//")
+        || publicId.startsWith("-//WebTechs//DTD Mozilla HTML 2.0//", false)
+        || publicId.startsWith("-//WebTechs//DTD Mozilla HTML//", false)
+        || equalIgnoringCase(publicId, "-/W3C/DTD HTML 4.0 Transitional/EN")
+        || equalIgnoringCase(publicId, "HTML")
+        || equalIgnoringCase(docType->systemId(), "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd")
+        || (docType->systemId().isEmpty() && publicId.startsWith("-//W3C//DTD HTML 4.01 Frameset//", false))
+        || (docType->systemId().isEmpty() && publicId.startsWith("-//W3C//DTD HTML 4.01 Transitional//", false))) {
+        setCompatibilityMode(QuirksMode);
+        return;
     }
-    
-    if (inCompatMode() != wasInCompatMode) {
-        clearPageUserSheet();
-        clearPageGroupUserSheets();
-        styleSelectorChanged(RecalcStyleImmediately);
+
+    // Check for Limited Quirks Mode.
+    if (publicId.startsWith("-//W3C//DTD XHTML 1.0 Frameset//", false)
+        || publicId.startsWith("-//W3C//DTD XHTML 1.0 Transitional//", false)
+        || (!docType->systemId().isEmpty() && publicId.startsWith("-//W3C//DTD HTML 4.01 Frameset//", false))
+        || (!docType->systemId().isEmpty() && publicId.startsWith("-//W3C//DTD HTML 4.01 Transitional//", false))) {
+        setCompatibilityMode(LimitedQuirksMode);
+        return;
     }
+
+    // Otherwise we are No Quirks Mode.
+    setCompatibilityMode(NoQuirksMode);
+    return;
 }
 
 void HTMLDocument::clear()
index b10a4ed..5dbe627 100644 (file)
@@ -51,6 +51,7 @@ public:
     void setDesignMode(const String&);
 
     String compatMode() const;
+    virtual void setCompatibilityModeFromDoctype();
 
     Element* activeElement();
     bool hasFocus();
@@ -87,7 +88,6 @@ private:
 
     virtual bool isFrameSet() const;
     virtual PassRefPtr<DocumentParser> createParser();
-    virtual void determineParseMode();
 
     void addItemToMap(HashCountedSet<AtomicStringImpl*>&, const AtomicString&);
     void removeItemFromMap(HashCountedSet<AtomicStringImpl*>&, const AtomicString&);
index 87054d1..11512d9 100644 (file)
@@ -270,7 +270,7 @@ void HTMLLinkElement::setCSSStyleSheet(const String& href, const KURL& baseURL,
 {
     m_sheet = CSSStyleSheet::create(this, href, baseURL, charset);
 
-    bool strictParsing = !document()->inCompatMode();
+    bool strictParsing = !document()->inQuirksMode();
     bool enforceMIMEType = strictParsing;
     bool crossOriginCSS = false;
     bool validMIMEType = false;
@@ -278,7 +278,7 @@ void HTMLLinkElement::setCSSStyleSheet(const String& href, const KURL& baseURL,
 
     // Check to see if we should enforce the MIME type of the CSS resource in strict mode.
     // Running in iWeb 2 is one example of where we don't want to - <rdar://problem/6099748>
-    if (enforceMIMEType && document()->page() && !document()->page()->settings()->enforceCSSMIMETypeInStrictMode())
+    if (enforceMIMEType && document()->page() && !document()->page()->settings()->enforceCSSMIMETypeInNoQuirksMode())
         enforceMIMEType = false;
 
 #if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD)
index 693dc63..868f967 100644 (file)
@@ -397,7 +397,7 @@ HTMLTreeBuilder::HTMLTreeBuilder(HTMLTokenizer* tokenizer, DocumentFragment* fra
     if (contextElement) {
         // Steps 4.2-4.6 of the HTML5 Fragment Case parsing algorithm:
         // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#fragment-case
-        m_document->setParseMode(contextElement->document()->parseMode());
+        m_document->setCompatibilityMode(contextElement->document()->compatibilityMode());
         processFakeStartTag(htmlTag);
         resetInsertionModeAppropriately();
         m_tree.setForm(closestFormAncestor(contextElement));
@@ -431,6 +431,7 @@ HTMLTreeBuilder::FragmentParsingContext::FragmentParsingContext(DocumentFragment
     , m_contextElement(contextElement)
     , m_scriptingPermission(scriptingPermission)
 {
+    m_dummyDocumentForFragmentParsing->setCompatibilityMode(fragment->document()->compatibilityMode());
 }
 
 Document* HTMLTreeBuilder::FragmentParsingContext::document() const
@@ -534,6 +535,7 @@ void HTMLTreeBuilder::processDoctypeToken(AtomicHTMLToken& token)
     ASSERT(token.type() == HTMLToken::DOCTYPE);
     if (m_insertionMode == InitialMode) {
         m_tree.insertDoctype(token);
+        setInsertionMode(BeforeHTMLMode);
         return;
     }
     if (m_insertionMode == InTableTextMode) {
@@ -923,7 +925,7 @@ void HTMLTreeBuilder::processStartTagForInBody(AtomicHTMLToken& token)
         return;
     }
     if (token.name() == tableTag) {
-        if (m_document->parseMode() != Document::Compat && m_tree.openElements()->inButtonScope(pTag))
+        if (!m_document->inQuirksMode() && m_tree.openElements()->inButtonScope(pTag))
             processFakeEndTag(pTag);
         m_tree.insertHTMLElement(token);
         m_framesetOk = false;
@@ -2692,6 +2694,8 @@ void HTMLTreeBuilder::processEndOfFile(AtomicHTMLToken& token)
 void HTMLTreeBuilder::defaultForInitial()
 {
     notImplemented();
+    if (!m_fragmentContext.fragment())
+        m_document->setCompatibilityMode(Document::QuirksMode);
     // FIXME: parse error
     setInsertionMode(BeforeHTMLMode);
 }
index b307ea2..f268192 100644 (file)
@@ -51,6 +51,8 @@ HTMLViewSourceDocument::HTMLViewSourceDocument(Frame* frame, const KURL& url, co
     , m_type(mimeType)
 {
     setUsesBeforeAfterRules(true);
+    setCompatibilityMode(QuirksMode);
+    lockCompatibilityMode();
 }
 
 PassRefPtr<DocumentParser> HTMLViewSourceDocument::createParser()
index d99f340..cd82d6e 100644 (file)
@@ -72,7 +72,7 @@ void DocumentWriter::replaceDocument(const String& source)
     if (!source.isNull()) {
         if (!m_receivedData) {
             m_receivedData = true;
-            m_frame->document()->setParseMode(Document::Strict);
+            m_frame->document()->setCompatibilityMode(Document::NoQuirksMode);
         }
 
         // FIXME: This should call DocumentParser::appendBytes instead of append
@@ -179,7 +179,7 @@ TextResourceDecoder* DocumentWriter::createDecoderIfNeeded()
     return m_decoder.get();
 }
 
-void DocumentWriter::reportDataRecieved()
+void DocumentWriter::reportDataReceived()
 {
     ASSERT(m_decoder);
     if (!m_receivedData) {
index b1007ef..531a632 100644 (file)
@@ -69,7 +69,7 @@ public:
 
     // Exposed for DoucmentParser::appendBytes
     TextResourceDecoder* createDecoderIfNeeded();
-    void reportDataRecieved();
+    void reportDataReceived();
 
 private:
     PassRefPtr<Document> createDocument(const KURL&);
index a1a9f80..702ed9d 100644 (file)
@@ -177,7 +177,8 @@ ImageDocument::ImageDocument(Frame* frame, const KURL& url)
     , m_didShrinkImage(false)
     , m_shouldShrinkImage(shouldShrinkToFit())
 {
-    setParseMode(Compat);
+    setCompatibilityMode(QuirksMode);
+    lockCompatibilityMode();
 }
     
 PassRefPtr<DocumentParser> ImageDocument::createParser()
index dd58581..77c3d1f 100644 (file)
@@ -113,7 +113,8 @@ MediaDocument::MediaDocument(Frame* frame, const KURL& url)
     : HTMLDocument(frame, url)
     , m_replaceMediaElementTimer(this, &MediaDocument::replaceMediaElementTimerFired)
 {
-    setParseMode(Compat);
+    setCompatibilityMode(QuirksMode);
+    lockCompatibilityMode();
 }
 
 MediaDocument::~MediaDocument()
index ae036d3..08e6fae 100644 (file)
@@ -135,7 +135,8 @@ void PluginDocumentParser::appendBytes(DocumentWriter*, const char*, int, bool)
 PluginDocument::PluginDocument(Frame* frame, const KURL& url)
     : HTMLDocument(frame, url)
 {
-    setParseMode(Compat);
+    setCompatibilityMode(QuirksMode);
+    lockCompatibilityMode();
 }
     
 PassRefPtr<DocumentParser> PluginDocument::createParser()
index 262d318..47535dc 100644 (file)
@@ -50,7 +50,8 @@ private:
 SinkDocument::SinkDocument(Frame* frame, const KURL& url)
     : HTMLDocument(frame, url)
 {
-    setParseMode(Compat);
+    setCompatibilityMode(QuirksMode);
+    lockCompatibilityMode();
 }
 
 PassRefPtr<DocumentParser> SinkDocument::createParser()
index 5e2b774..4b09a9e 100644 (file)
@@ -202,6 +202,8 @@ bool TextDocumentParser::finishWasCalled()
 TextDocument::TextDocument(Frame* frame, const KURL& url)
     : HTMLDocument(frame, url)
 {
+    setCompatibilityMode(QuirksMode);
+    lockCompatibilityMode();
 }
 
 PassRefPtr<DocumentParser> TextDocument::createParser()
index 3c95a35..f692cb9 100644 (file)
@@ -639,7 +639,7 @@ void Page::userStyleSheetLocationChanged()
     
     for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext()) {
         if (frame->document())
-            frame->document()->clearPageUserSheet();
+            frame->document()->updatePageUserSheet();
     }
 }
 
index aecd550..4c9403b 100644 (file)
@@ -363,7 +363,7 @@ void PageGroup::resetUserStyleCacheInAllFrames()
     HashSet<Page*>::const_iterator end = m_pages.end();
     for (HashSet<Page*>::const_iterator it = m_pages.begin(); it != end; ++it) {
         for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()->traverseNext())
-            frame->document()->clearPageGroupUserSheets();
+            frame->document()->updatePageGroupUserSheets();
     }
 #endif
 }
index 51a30fb..866b45a 100644 (file)
@@ -109,7 +109,7 @@ Settings::Settings(Page* page)
     , m_inApplicationChromeMode(false)
     , m_offlineWebApplicationCacheEnabled(false)
     , m_shouldPaintCustomScrollbars(false)
-    , m_enforceCSSMIMETypeInStrictMode(true)
+    , m_enforceCSSMIMETypeInNoQuirksMode(true)
     , m_usesEncodingDetector(false)
     , m_allowScriptsToCloseWindows(false)
     , m_editingBehaviorType(
@@ -504,9 +504,9 @@ void Settings::setZoomMode(ZoomMode mode)
     setNeedsReapplyStylesInAllFrames(m_page);
 }
 
-void Settings::setEnforceCSSMIMETypeInStrictMode(bool enforceCSSMIMETypeInStrictMode)
+void Settings::setEnforceCSSMIMETypeInNoQuirksMode(bool enforceCSSMIMETypeInNoQuirksMode)
 {
-    m_enforceCSSMIMETypeInStrictMode = enforceCSSMIMETypeInStrictMode;
+    m_enforceCSSMIMETypeInNoQuirksMode = enforceCSSMIMETypeInNoQuirksMode;
 }
 
 #if USE(SAFARI_THEME)
index 029a0a3..7c6b8c9 100644 (file)
@@ -252,8 +252,8 @@ namespace WebCore {
         void setZoomMode(ZoomMode);
         ZoomMode zoomMode() const { return m_zoomMode; }
         
-        void setEnforceCSSMIMETypeInStrictMode(bool);
-        bool enforceCSSMIMETypeInStrictMode() { return m_enforceCSSMIMETypeInStrictMode; }
+        void setEnforceCSSMIMETypeInNoQuirksMode(bool);
+        bool enforceCSSMIMETypeInNoQuirksMode() { return m_enforceCSSMIMETypeInNoQuirksMode; }
 
         void setMaximumDecodedImageSize(size_t size) { m_maximumDecodedImageSize = size; }
         size_t maximumDecodedImageSize() const { return m_maximumDecodedImageSize; }
@@ -386,7 +386,7 @@ namespace WebCore {
         bool m_inApplicationChromeMode : 1;
         bool m_offlineWebApplicationCacheEnabled : 1;
         bool m_shouldPaintCustomScrollbars : 1;
-        bool m_enforceCSSMIMETypeInStrictMode : 1;
+        bool m_enforceCSSMIMETypeInNoQuirksMode : 1;
         bool m_usesEncodingDetector : 1;
         bool m_allowScriptsToCloseWindows : 1;
         unsigned m_editingBehaviorType : 1;
index a064f2a..d72102d 100644 (file)
@@ -140,7 +140,7 @@ void AutoTableLayout::recalcColumn(int effCol)
 
     // Nav/IE weirdness
     if (l.width.isFixed()) {
-        if (m_table->style()->htmlHacks() && l.maxWidth > l.width.value() && fixedContributor != maxContributor) {
+        if (m_table->document()->inQuirksMode() && l.maxWidth > l.width.value() && fixedContributor != maxContributor) {
             l.width = Length();
             fixedContributor = 0;
         }
index 4d6b88c..b5ff971 100644 (file)
@@ -223,7 +223,7 @@ void FixedTableLayout::calcPrefWidths(int& minWidth, int& maxWidth)
     // In this example, the two inner tables should be as large as the outer table. 
     // We can achieve this effect by making the maxwidth of fixed tables with percentage
     // widths be infinite.
-    if (m_table->style()->htmlHacks() && m_table->style()->width().isPercent() 
+    if (m_table->document()->inQuirksMode() && m_table->style()->width().isPercent() 
         && maxWidth < TABLE_MAX_WIDTH)
         maxWidth = TABLE_MAX_WIDTH;
 }
index dfe7561..a71b796 100644 (file)
@@ -761,8 +761,8 @@ void InlineFlowBox::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty)
     int h = height();
 
     // Constrain our background/border painting to the line top and bottom if necessary.
-    bool strictMode = renderer()->document()->inStrictMode();
-    if (!hasTextChildren() && !strictMode) {
+    bool noQuirksMode = renderer()->document()->inNoQuirksMode();
+    if (!hasTextChildren() && !noQuirksMode) {
         RootInlineBox* rootBox = root();
         int bottom = min(rootBox->lineBottom(), y + h);
         y = max(rootBox->lineTop(), y);
@@ -837,8 +837,8 @@ void InlineFlowBox::paintMask(PaintInfo& paintInfo, int tx, int ty)
     int h = height();
 
     // Constrain our background/border painting to the line top and bottom if necessary.
-    bool strictMode = renderer()->document()->inStrictMode();
-    if (!hasTextChildren() && !strictMode) {
+    bool noQuirksMode = renderer()->document()->inNoQuirksMode();
+    if (!hasTextChildren() && !noQuirksMode) {
         RootInlineBox* rootBox = root();
         int bottom = min(rootBox->lineBottom(), y + h);
         y = max(rootBox->lineTop(), y);
@@ -922,7 +922,7 @@ void InlineFlowBox::paintTextDecorations(PaintInfo& paintInfo, int tx, int ty, b
 {
     // Paint text decorations like underlines/overlines. We only do this if we aren't in quirks mode (i.e., in
     // almost-strict mode or strict mode).
-    if (renderer()->style()->htmlHacks() || !paintInfo.shouldPaintWithinRoot(renderer()) ||
+    if (renderer()->document()->inQuirksMode() || !paintInfo.shouldPaintWithinRoot(renderer()) ||
         renderer()->style()->visibility() != VISIBLE)
         return;
     
index cb4fdb8..e64ddde 100644 (file)
@@ -547,7 +547,7 @@ void InlineTextBox::paint(PaintInfo& paintInfo, int tx, int ty)
     }
 
     // Paint decorations
-    if (d != TDNONE && paintInfo.phase != PaintPhaseSelection && styleToUse->htmlHacks()) {
+    if (d != TDNONE && paintInfo.phase != PaintPhaseSelection && renderer()->document()->inQuirksMode()) {
         context->setStrokeColor(styleToUse->visitedDependentColor(CSSPropertyColor), styleToUse->colorSpace());
         paintDecoration(context, tx, ty, d, textShadow);
     }
index 0fc279e..04d8fd0 100644 (file)
@@ -1038,7 +1038,7 @@ bool RenderBlock::isSelfCollapsingBlock() const
         return false;
 
     bool hasAutoHeight = style()->height().isAuto();
-    if (style()->height().isPercent() && !style()->htmlHacks()) {
+    if (style()->height().isPercent() && !document()->inQuirksMode()) {
         hasAutoHeight = true;
         for (RenderBlock* cb = containingBlock(); !cb->isRenderView(); cb = cb->containingBlock()) {
             if (cb->style()->height().isFixed() || cb->isTableCell())
@@ -1470,7 +1470,7 @@ int RenderBlock::collapseMargins(RenderBox* child, MarginInfo& marginInfo)
         // This child is collapsing with the top of the
         // block.  If it has larger margin values, then we need to update
         // our own maximal values.
-        if (!style()->htmlHacks() || !marginInfo.quirkContainer() || !topQuirk)
+        if (!document()->inQuirksMode() || !marginInfo.quirkContainer() || !topQuirk)
             setMaxTopMargins(max(posTop, maxTopPosMargin()), max(negTop, maxTopNegMargin()));
 
         // The minute any of the margins involved isn't a quirk, don't
@@ -1522,7 +1522,7 @@ int RenderBlock::collapseMargins(RenderBox* child, MarginInfo& marginInfo)
         }
         else if (!marginInfo.atTopOfBlock() ||
             (!marginInfo.canCollapseTopWithChildren()
-             && (!style()->htmlHacks() || !marginInfo.quirkContainer() || !marginInfo.topQuirk()))) {
+             && (!document()->inQuirksMode() || !marginInfo.quirkContainer() || !marginInfo.topQuirk()))) {
             // We're collapsing with a previous sibling's margins and not
             // with the top of the block.
             setHeight(height() + max(marginInfo.posMargin(), posTop) - max(marginInfo.negMargin(), negTop));
@@ -1675,7 +1675,7 @@ void RenderBlock::handleBottomOfBlock(int top, int bottom, MarginInfo& marginInf
 
     // If we can't collapse with children then go ahead and add in the bottom margin.
     if (!marginInfo.canCollapseWithBottom() && !marginInfo.canCollapseWithTop()
-        && (!style()->htmlHacks() || !marginInfo.quirkContainer() || !marginInfo.bottomQuirk()))
+        && (!document()->inQuirksMode() || !marginInfo.quirkContainer() || !marginInfo.bottomQuirk()))
         setHeight(height() + marginInfo.margin());
         
     // Now add in our bottom border/padding.
@@ -4578,7 +4578,7 @@ void RenderBlock::calcInlinePrefWidths()
     // Firefox and Opera will allow a table cell to grow to fit an image inside it under
     // very specific cirucumstances (in order to match common WinIE renderings). 
     // Not supporting the quirk has caused us to mis-render some real sites. (See Bugzilla 10517.) 
-    bool allowImagesToBreak = !style()->htmlHacks() || !isTableCell() || !style()->width().isIntrinsicOrAuto();
+    bool allowImagesToBreak = !document()->inQuirksMode() || !isTableCell() || !style()->width().isIntrinsicOrAuto();
 
     bool autoWrap, oldAutoWrap;
     autoWrap = oldAutoWrap = style()->autoWrap();
@@ -4907,7 +4907,7 @@ void RenderBlock::calcBlockPrefWidths()
         // of 100px because of the table.
         // We can achieve this effect by making the maxwidth of blocks that contain tables
         // with percentage widths be infinite (as long as they are not inside a table cell).
-        if (style()->htmlHacks() && child->style()->width().isPercent() &&
+        if (document()->inQuirksMode() && child->style()->width().isPercent() &&
             !isTableCell() && child->isTable() && m_maxPrefWidth < BLOCK_MAX_WIDTH) {
             RenderBlock* cb = containingBlock();
             while (!cb->isRenderView() && !cb->isTableCell())
index 6b06a12..c2d2114 100644 (file)
@@ -187,7 +187,7 @@ static inline InlineBox* createInlineBoxForRenderer(RenderObject* obj, bool isRo
         // We only treat a box as text for a <br> if we are on a line by ourself or in strict mode
         // (Note the use of strict mode.  In "almost strict" mode, we don't treat the box for <br> as text.)
         if (obj->isBR())
-            textBox->setIsText(isOnlyRun || obj->document()->inStrictMode());
+            textBox->setIsText(isOnlyRun || obj->document()->inNoQuirksMode());
         return textBox;
     }
     
@@ -1395,7 +1395,7 @@ InlineIterator RenderBlock::findNextLineBreak(InlineBidiResolver& resolver, bool
     // Firefox and Opera will allow a table cell to grow to fit an image inside it under
     // very specific circumstances (in order to match common WinIE renderings). 
     // Not supporting the quirk has caused us to mis-render some real sites. (See Bugzilla 10517.) 
-    bool allowImagesToBreak = !style()->htmlHacks() || !isTableCell() || !style()->width().isIntrinsicOrAuto();
+    bool allowImagesToBreak = !document()->inQuirksMode() || !isTableCell() || !style()->width().isIntrinsicOrAuto();
 
     EWhiteSpace currWS = style()->whiteSpace();
     EWhiteSpace lastWS = currWS;
index 664335a..5e92315 100644 (file)
@@ -1550,7 +1550,7 @@ int RenderBox::calcPercentageHeight(const Length& height)
     int result = -1;
     bool skippedAutoHeightContainingBlock = false;
     RenderBlock* cb = containingBlock();
-    if (style()->htmlHacks()) {
+    if (document()->inQuirksMode()) {
         // In quirks mode, blocks with auto height are skipped, and we keep looking for an enclosing
         // block that may have a specified height and then use it.  In strict mode, this violates the
         // specification, which states that percentage heights just revert to auto if the containing
@@ -1599,7 +1599,7 @@ int RenderBox::calcPercentageHeight(const Length& height)
         result = cb->calcPercentageHeight(cb->style()->height());
         if (result != -1)
             result = cb->calcContentBoxHeight(result);
-    } else if (cb->isRenderView() || (cb->isBody() && style()->htmlHacks()) || isPositionedWithSpecifiedHeight) {
+    } else if (cb->isRenderView() || (cb->isBody() && document()->inQuirksMode()) || isPositionedWithSpecifiedHeight) {
         // Don't allow this to affect the block' height() member variable, since this
         // can get called while the block is still laying out its kids.
         int oldHeight = cb->height();
@@ -1832,7 +1832,7 @@ void RenderBox::calcAbsoluteHorizontal()
 
     // To match WinIE, in quirks mode use the parent's 'direction' property
     // instead of the the container block's.
-    TextDirection containerDirection = (style()->htmlHacks()) ? parent()->style()->direction() : containerBlock->style()->direction();
+    TextDirection containerDirection = (document()->inQuirksMode()) ? parent()->style()->direction() : containerBlock->style()->direction();
 
     const int bordersPlusPadding = borderAndPaddingWidth();
     const Length marginLeft = style()->marginLeft();
@@ -2368,7 +2368,7 @@ void RenderBox::calcAbsoluteHorizontalReplaced()
 
     // To match WinIE, in quirks mode use the parent's 'direction' property
     // instead of the the container block's.
-    TextDirection containerDirection = (style()->htmlHacks()) ? parent()->style()->direction() : containerBlock->style()->direction();
+    TextDirection containerDirection = (document()->inQuirksMode()) ? parent()->style()->direction() : containerBlock->style()->direction();
 
     // Variables to solve.
     Length left = style()->left();
index d20eb84..f582d67 100644 (file)
@@ -217,7 +217,7 @@ public:
 
     bool stretchesToViewHeight() const
     {
-        return style()->htmlHacks() && style()->height().isAuto() && !isFloatingOrPositioned() && (isRoot() || isBody());
+        return document()->inQuirksMode() && style()->height().isAuto() && !isFloatingOrPositioned() && (isRoot() || isBody());
     }
 
     virtual IntSize intrinsicSize() const { return IntSize(); }
index f861467..2366a34 100644 (file)
@@ -150,6 +150,7 @@ static RenderObject* getParentOfFirstLineBox(RenderBlock* curr, RenderObject* ma
     if (!firstChild)
         return 0;
 
+    bool inQuirksMode = curr->document()->inQuirksMode();
     for (RenderObject* currChild = firstChild; currChild; currChild = currChild->nextSibling()) {
         if (currChild == marker)
             continue;
@@ -163,7 +164,7 @@ static RenderObject* getParentOfFirstLineBox(RenderBlock* curr, RenderObject* ma
         if (currChild->isTable() || !currChild->isRenderBlock())
             break;
 
-        if (curr->isListItem() && currChild->style()->htmlHacks() && currChild->node() &&
+        if (curr->isListItem() && inQuirksMode && currChild->node() &&
             (currChild->node()->hasTagName(ulTag)|| currChild->node()->hasTagName(olTag)))
             break;
 
index bd36ae8..af1016a 100644 (file)
@@ -333,7 +333,7 @@ void RenderTable::layout()
             toRenderTableSection(child)->layoutRows(child == m_firstBody ? max(0, th - calculatedHeight) : 0);
     }
 
-    if (!m_firstBody && th > calculatedHeight && !style()->htmlHacks()) {
+    if (!m_firstBody && th > calculatedHeight && !document()->inQuirksMode()) {
         // Completely empty tables (with no sections or anything) should at least honor specified height
         // in strict mode.
         setHeight(height() + th);
index 5ee72b5..bf74fed 100644 (file)
@@ -349,7 +349,7 @@ int RenderTableSection::calcRowHeight()
             // Explicit heights use the border box in quirks mode.  In strict mode do the right
             // thing and actually add in the border and padding.
             ch = cell->style()->height().calcValue(0) + 
-                (cell->style()->htmlHacks() ? 0 : (adjustedPaddingTop + adjustedPaddingBottom +
+                (document()->inQuirksMode() ? 0 : (adjustedPaddingTop + adjustedPaddingBottom +
                                                    cell->borderTop() + cell->borderBottom()));
             ch = max(ch, adjustedHeight);
 
index bec288c..e8f24b5 100644 (file)
@@ -215,14 +215,10 @@ int RootInlineBox::verticallyAlignBoxes(int heightOfBlock, GlyphOverflowAndFallb
     int maxAscent = 0;
     int maxDescent = 0;
 
-    // Figure out if we're in strict mode.  Note that we can't simply use !style()->htmlHacks(),
-    // because that would match almost strict mode as well.
-    RenderObject* curr = renderer();
-    while (curr && !curr->node())
-        curr = curr->container();
-    bool strictMode = (curr && curr->document()->inStrictMode());
+    // Figure out if we're in no-quirks mode.
+    bool noQuirksMode = renderer()->document()->inNoQuirksMode();
 
-    computeLogicalBoxHeights(maxPositionTop, maxPositionBottom, maxAscent, maxDescent, strictMode, textBoxDataMap);
+    computeLogicalBoxHeights(maxPositionTop, maxPositionBottom, maxAscent, maxDescent, noQuirksMode, textBoxDataMap);
 
     if (maxAscent + maxDescent < max(maxPositionTop, maxPositionBottom))
         adjustMaxAscentAndDescent(maxAscent, maxDescent, maxPositionTop, maxPositionBottom);
@@ -230,8 +226,8 @@ int RootInlineBox::verticallyAlignBoxes(int heightOfBlock, GlyphOverflowAndFallb
     int maxHeight = maxAscent + maxDescent;
     int lineTop = heightOfBlock;
     int lineBottom = heightOfBlock;
-    placeBoxesVertically(heightOfBlock, maxHeight, maxAscent, strictMode, lineTop, lineBottom);
-    computeVerticalOverflow(lineTop, lineBottom, strictMode, textBoxDataMap);
+    placeBoxesVertically(heightOfBlock, maxHeight, maxAscent, noQuirksMode, lineTop, lineBottom);
+    computeVerticalOverflow(lineTop, lineBottom, noQuirksMode, textBoxDataMap);
     setLineTopBottomPositions(lineTop, lineBottom);
     
     heightOfBlock += maxHeight;
index aaccbf7..6c925b2 100644 (file)
@@ -403,7 +403,6 @@ StyleDifference RenderStyle::diff(const RenderStyle* other, unsigned& changedCon
         inherited->vertical_border_spacing != other->inherited->vertical_border_spacing ||
         inherited_flags._box_direction != other->inherited_flags._box_direction ||
         inherited_flags._visuallyOrdered != other->inherited_flags._visuallyOrdered ||
-        inherited_flags._htmlHacks != other->inherited_flags._htmlHacks ||
         noninherited_flags._position != other->noninherited_flags._position ||
         noninherited_flags._floating != other->noninherited_flags._floating ||
         noninherited_flags._originalDisplay != other->noninherited_flags._originalDisplay)
index e86c5e2..2363a9e 100644 (file)
@@ -178,7 +178,6 @@ protected:
                    (_white_space == other._white_space) &&
                    (_box_direction == other._box_direction) &&
                    (_visuallyOrdered == other._visuallyOrdered) &&
-                   (_htmlHacks == other._htmlHacks) &&
                    (_force_backgrounds_to_white == other._force_backgrounds_to_white) &&
                    (_pointerEvents == other._pointerEvents) &&
                    (_insideLink == other._insideLink);
@@ -203,7 +202,6 @@ protected:
         
         // non CSS2 inherited
         bool _visuallyOrdered : 1;
-        bool _htmlHacks : 1;
         bool _force_backgrounds_to_white : 1;
         unsigned _pointerEvents : 4; // EPointerEvents
         unsigned _insideLink : 2; // EInsideLink
@@ -279,7 +277,6 @@ protected:
         inherited_flags._border_collapse = initialBorderCollapse();
         inherited_flags._white_space = initialWhiteSpace();
         inherited_flags._visuallyOrdered = initialVisuallyOrdered();
-        inherited_flags._htmlHacks=false;
         inherited_flags._box_direction = initialBoxDirection();
         inherited_flags._force_backgrounds_to_white = false;
         inherited_flags._pointerEvents = initialPointerEvents();
@@ -924,9 +921,6 @@ public:
     bool forceBackgroundsToWhite() const { return inherited_flags._force_backgrounds_to_white; }
     void setForceBackgroundsToWhite(bool b=true) { inherited_flags._force_backgrounds_to_white = b; }
 
-    bool htmlHacks() const { return inherited_flags._htmlHacks; }
-    void setHtmlHacks(bool b=true) { inherited_flags._htmlHacks = b; }
-
     bool hasAutoZIndex() const { return m_box->hasAutoZIndex(); }
     void setHasAutoZIndex() { SET_VAR(m_box, m_hasAutoZIndex, true); SET_VAR(m_box, m_zIndex, 0) }
     int zIndex() const { return m_box->zIndex(); }
index 5369081..56f96b5 100644 (file)
@@ -1,3 +1,31 @@
+2010-08-27  David Hyatt  <hyatt@apple.com>
+
+        Reviewed by Simon Fraser.
+
+        https://bugs.webkit.org/show_bug.cgi?id=44788, implement HTML5-compliant doctype switching.
+
+        Rename the various modes to match the HTML5 specification:
+            ParseMode -> CompatibilityMode
+            CompatMode -> QuirksMode
+            AlmostStrictMode -> LimitedQuirksMode
+            StrictMode -> NoQuirksMode
+            
+        Remove the htmlHacks() accessor from RenderStyle and make rendering code just go to the document
+        instead.  This makes switching modes avoid forcing all RenderStyles to detect as changed.
+        
+        Clean up user stylesheets to minimize style recalculation when the mode is switched.
+        
+        Fix bugs with the propagation of correct modes in the HTML5 parser.  Make sure the
+        dummy document created for fragment parsing properly inherits the real document's CompatibilityMode.
+        Make sure the tree builder properly changes the insertion mode to "BeforeHTML" after handling
+        a doctype token.
+        
+        determineParseMode -> setCompatibilityModeFromDoctype, and it now implements the HTML5 algorithm
+        precisely.
+
+        * WebView/WebView.mm:
+        (-[WebView _preferencesChangedNotification:]):
+
 2010-08-27  Yury Semikhatsky  <yurys@chromium.org>
 
         Reviewed by Pavel Feldman.
index 2d3dbfa..322dd45 100644 (file)
@@ -1425,7 +1425,7 @@ static bool fastDocumentTeardownEnabled()
     settings->setZoomMode([preferences zoomsTextOnly] ? ZoomTextOnly : ZoomPage);
     settings->setJavaScriptCanAccessClipboard([preferences javaScriptCanAccessClipboard]);
     settings->setXSSAuditorEnabled([preferences isXSSAuditorEnabled]);
-    settings->setEnforceCSSMIMETypeInStrictMode(!WKAppVersionCheckLessThan(@"com.apple.iWeb", -1, 2.1));
+    settings->setEnforceCSSMIMETypeInNoQuirksMode(!WKAppVersionCheckLessThan(@"com.apple.iWeb", -1, 2.1));
     settings->setDNSPrefetchingEnabled([preferences isDNSPrefetchingEnabled]);
     
     // FIXME: Enabling accelerated compositing when WebGL is enabled causes tests to fail on Leopard which expect HW compositing to be disabled.