Capture CSS parser context
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Apr 2012 02:40:23 +0000 (02:40 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Apr 2012 02:40:23 +0000 (02:40 +0000)
commit071237b8be418aa0c7c2b2647d54000721d115f7
treee25450506e06991053ade01b976622931c176280
parent6de75b8b68d8ca75f56ea9db4d9eb5adbe8bb75b
Capture CSS parser context
https://bugs.webkit.org/show_bug.cgi?id=83998

Source/WebCore:

Reviewed by Andreas Kling.

Currently the CSS parser calls to the Document and StyleSheetInternal objects to get settings, base URL etc.
The required information should be passed in on parser construction instead. The parser should not need to
know about the document at all.

The patch adds CSSParserContext struct that captures the parsing context. StyleSheetInternal saves the
parsing context and reuses it for any further parsing.

If the same stylesheet source is parsed with an identical context then the resulting stylesheet structure will
be identical. This will allow sharing parsed stylesheets in the future.

* css/CSSGrammar.y:
* css/CSSImportRule.cpp:
(WebCore::StyleRuleImport::setCSSStyleSheet):
* css/CSSMediaRule.cpp:
(WebCore::CSSMediaRule::insertRule):
* css/CSSPageRule.cpp:
(WebCore::CSSPageRule::setSelectorText):
* css/CSSParser.cpp:
(WebCore):
(WebCore::strictCSSParserContext):
(WebCore::CSSParserContext::CSSParserContext):
(WebCore::CSSParser::CSSParser):
(WebCore::CSSParser::parseKeyframeRule):
(WebCore::CSSParser::parseValue):
(WebCore::CSSParser::parseSelector):
(WebCore::CSSParser::completeURL):
(WebCore::CSSParser::parseContent):
(WebCore::CSSParser::parseAttr):
(WebCore::CSSParser::parseFillImage):
(WebCore::CSSParser::parseFontFaceSrcURI):
(WebCore::CSSParser::parseFontFaceSrc):
(WebCore::CSSParser::parseBorderImage):
(WebCore::CSSParser::parseImageSet):
(WebCore::CSSParser::parseCustomFilter):
(WebCore::CSSParser::parseFilter):
(WebCore::CSSParser::cssRegionsEnabled):
(WebCore::CSSParser::parseFlowThread):
(WebCore::CSSParser::createMediaRule):
(WebCore::CSSParser::createStyleRule):
(WebCore::CSSParser::createFontFaceRule):
(WebCore::CSSParser::createPageRule):
(WebCore::CSSParser::createKeyframe):
* css/CSSParser.h:
(CSSParser):
(WebCore::CSSParser::inStrictMode):
(WebCore::CSSParser::inQuirksMode):
(WebCore::CSSParser::validUnit):
* css/CSSParserMode.h:
(WebCore):
(CSSParserContext):
* css/CSSRule.h:
(WebCore::CSSRule::parserContext):
(CSSRule):
* css/CSSStyleRule.cpp:
(WebCore::CSSStyleRule::setSelectorText):
* css/CSSStyleSheet.cpp:
(WebCore::StyleSheetInternal::StyleSheetInternal):
(WebCore::StyleSheetInternal::parseString):
(WebCore::StyleSheetInternal::parseStringAtLine):
(WebCore):
(WebCore::StyleSheetInternal::updateBaseURL):
(WebCore::StyleSheetInternal::completeURL):
(WebCore::CSSStyleSheet::insertRule):
* css/CSSStyleSheet.h:
(StyleSheetInternal):
(WebCore::StyleSheetInternal::parserContext):
(WebCore::StyleSheetInternal::charset):
(WebCore::StyleSheetInternal::setFinalURL):
(WebCore::StyleSheetInternal::baseURL):
* css/CSSValuePool.cpp:
* css/StylePropertySet.cpp:
(WebCore::StylePropertySet::parseDeclaration):
* css/WebKitCSSKeyframesRule.cpp:
(WebCore::WebKitCSSKeyframesRule::insertRule):
* dom/Document.cpp:
(WebCore::Document::webkitGetFlowByName):
(WebCore::Document::pageUserSheet):
(WebCore::Document::pageGroupUserSheets):
* dom/Element.cpp:
(WebCore::Element::webkitMatchesSelector):
* dom/Node.cpp:
(WebCore::Node::querySelector):
(WebCore::Node::querySelectorAll):
* dom/ProcessingInstruction.cpp:
(WebCore::ProcessingInstruction::parseStyleSheet):
* dom/StyleElement.cpp:
(WebCore::StyleElement::createSheet):
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::setCSSStyleSheet):
* html/shadow/ContentSelectorQuery.cpp:
(WebCore::ContentSelectorQuery::ContentSelectorQuery):
* inspector/InspectorStyleSheet.cpp:
(WebCore::InspectorStyle::setPropertyText):
(WebCore::InspectorStyleSheet::reparseStyleSheet):
(WebCore::InspectorStyleSheet::ensureSourceData):
(WebCore::InspectorStyleSheetForInlineStyle::getStyleAttributeRanges):

LayoutTests:

Reviewed by Andreas Kling.

Modify the tests so that they don't expect settings changes to apply to already existing stylesheets.

* css3/filters/script-tests/custom-filter-property-parsing.js:
* fast/regions/script-tests/css-regions-disabled.js:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@114217 268f45cc-cd09-0410-ab3c-d52691b4dbfc
27 files changed:
LayoutTests/ChangeLog
LayoutTests/css3/filters/script-tests/custom-filter-property-parsing.js
LayoutTests/fast/regions/script-tests/css-regions-disabled.js
Source/WebCore/ChangeLog
Source/WebCore/css/CSSGrammar.y
Source/WebCore/css/CSSImportRule.cpp
Source/WebCore/css/CSSMediaRule.cpp
Source/WebCore/css/CSSPageRule.cpp
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSParser.h
Source/WebCore/css/CSSParserMode.h
Source/WebCore/css/CSSRule.h
Source/WebCore/css/CSSStyleRule.cpp
Source/WebCore/css/CSSStyleSheet.cpp
Source/WebCore/css/CSSStyleSheet.h
Source/WebCore/css/CSSValuePool.cpp
Source/WebCore/css/StylePropertySet.cpp
Source/WebCore/css/WebKitCSSKeyframesRule.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/ProcessingInstruction.cpp
Source/WebCore/dom/StyleElement.cpp
Source/WebCore/html/HTMLLinkElement.cpp
Source/WebCore/html/shadow/ContentSelectorQuery.cpp
Source/WebCore/inspector/InspectorStyleSheet.cpp
Source/WebKit/chromium/src/WebDocument.cpp