CSS JIT: add support for the pseudo classes :hover and :active
authorbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 May 2014 00:15:18 +0000 (00:15 +0000)
committerbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 May 2014 00:15:18 +0000 (00:15 +0000)
commitd2d0b61e0e0e6a387986e7dd9a326b3f6755f970
tree0ebba380e674ad27a2ac76ed95a6f7ba8bf3c37b
parent4463eed9a72707e3b50a862d558a8319ce0c3c35
CSS JIT: add support for the pseudo classes :hover and :active
https://bugs.webkit.org/show_bug.cgi?id=133295

Reviewed by Andreas Kling.

This patch adds compilation support for :hover and :active. The code generation of both of them is trivial,
most of the patch is improving the infrastructure and safety.

The document compatibility mode is moved to its own typed enum. This ensure the values are exclusives and
the native type is known (unsigned char here). The values are changes to binary flags to take advantage of
test-and-branch on ARM64 (not used explicitely, it is automatically generated by the MacroAssembler).

The other important refactoring is the code updating the flags on RenderStyle::NonInheritedFlags.
The code was duplicated in some places so it is move into its own function addFlagToElementStyleFromContext().

The generators themself are very simple. First we check the quirks-mode exceptions, that is generally excluded
at compile time because the conditions are almost never met, even in strict mode.
Then we have two cases: style resolution and query selector. Almost everything is just function calls.

* cssjit/SelectorCompiler.cpp:
(WebCore::SelectorCompiler::SelectorFragment::SelectorFragment):
(WebCore::SelectorCompiler::addPseudoClassType):
(WebCore::SelectorCompiler::SelectorCodeGenerator::addFlagToElementStyleFromContext):
(WebCore::SelectorCompiler::fragmentOnlyMatchesLinksInQuirksMode):
(WebCore::SelectorCompiler::getDocument):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateSpecialFailureInQuirksModeForActiveAndHoverIfNeeded):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementMatching):
(WebCore::SelectorCompiler::elementIsActive):
(WebCore::SelectorCompiler::elementIsActiveForStyleResolution):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementIsActive):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementIsFirstChild):
(WebCore::SelectorCompiler::elementIsHovered):
(WebCore::SelectorCompiler::elementIsHoveredForStyleResolution):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementIsHovered):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementIsLastChild):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementIsOnlyChild):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementIsNthChild):
* dom/Document.cpp:
(WebCore::Document::Document):
(WebCore::Document::setCompatibilityMode):
(WebCore::Document::implicitOpen):
(WebCore::Document::cloneDataFromDocument):
* dom/Document.h:
(WebCore::Document::compatibilityModeMemoryOffset):
(WebCore::Document::inQuirksMode):
(WebCore::Document::inLimitedQuirksMode):
(WebCore::Document::inNoQuirksMode):
(WebCore::Document::compatibilityMode): Deleted.
* html/ImageDocument.cpp:
(WebCore::ImageDocument::ImageDocument):
* html/MediaDocument.cpp:
(WebCore::MediaDocument::MediaDocument):
* html/PluginDocument.cpp:
(WebCore::PluginDocument::PluginDocument):
* html/TextDocument.cpp:
(WebCore::TextDocument::TextDocument):
* html/parser/HTMLConstructionSite.cpp:
(WebCore::HTMLConstructionSite::setDefaultCompatibilityMode):
(WebCore::HTMLConstructionSite::setCompatibilityMode):
(WebCore::HTMLConstructionSite::setCompatibilityModeFromDoctype):
(WebCore::HTMLConstructionSite::insertDoctype):
* html/parser/HTMLConstructionSite.h:
* loader/DocumentWriter.cpp:
(WebCore::DocumentWriter::replaceDocument):
* loader/SinkDocument.cpp:
(WebCore::SinkDocument::SinkDocument):
* page/ios/FrameIOS.mm:
(WebCore::Frame::initWithSimpleHTMLDocument):
* rendering/style/RenderStyle.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169478 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
Source/WebCore/ChangeLog
Source/WebCore/cssjit/SelectorCompiler.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/html/ImageDocument.cpp
Source/WebCore/html/MediaDocument.cpp
Source/WebCore/html/PluginDocument.cpp
Source/WebCore/html/TextDocument.cpp
Source/WebCore/html/parser/HTMLConstructionSite.cpp
Source/WebCore/html/parser/HTMLConstructionSite.h
Source/WebCore/loader/DocumentWriter.cpp
Source/WebCore/loader/SinkDocument.cpp
Source/WebCore/page/ios/FrameIOS.mm
Source/WebCore/rendering/style/RenderStyle.h