<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[208886] trunk/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/208886">208886</a></dd>
<dt>Author</dt> <dd>hyatt@apple.com</dd>
<dt>Date</dt> <dd>2016-11-18 11:09:13 -0800 (Fri, 18 Nov 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>[CSS Parser] Hook up InspectorStyleSheet to the new CSS parser.
https://bugs.webkit.org/show_bug.cgi?id=164886
Reviewed by Dean Jackson.
* css/CSSGrammar.y.in:
Get rid of the CSSRuleSourceData type enum, since StyleRule's type
enum is exactly the same.
* css/CSSPropertySourceData.cpp:
(WebCore::CSSPropertySourceData::CSSPropertySourceData):
* css/CSSPropertySourceData.h:
Add a concept of disabled to CSSPropertySourceData. This is used for
commented out properties.
(WebCore::CSSRuleSourceData::create):
(WebCore::CSSRuleSourceData::createUnknown):
(WebCore::CSSRuleSourceData::CSSRuleSourceData):
Get rid of the CSSRuleSourceData type enum, since StyleRule's type
enum is exactly the same.
* css/parser/CSSParser.cpp:
(WebCore::CSSParserContext::CSSParserContext):
(WebCore::CSSParser::parseSheetForInspector):
(WebCore::CSSParser::parseDeclarationForInspector):
(WebCore::CSSParser::markSupportsRuleHeaderStart):
(WebCore::CSSParser::markRuleHeaderStart):
(WebCore::CSSParser::markPropertyEnd):
* css/parser/CSSParser.h:
Add functions that represent the new API for inspector sheet
and declaration parsing. Patch the old parse code to use StyleRule::Type
now that the CSSRuleSourceData type is gone.
* css/parser/CSSParserObserver.h:
Tweak the API for our memory management.
* inspector/InspectorStyleSheet.cpp:
(flattenSourceData):
(WebCore::parserContextForDocument):
(WebCore::StyleSheetHandler::StyleSheetHandler):
(WebCore::StyleSheetHandler::startRuleHeader):
(WebCore::StyleSheetHandler::setRuleHeaderEnd):
(WebCore::StyleSheetHandler::endRuleHeader):
(WebCore::StyleSheetHandler::observeSelector):
(WebCore::StyleSheetHandler::startRuleBody):
(WebCore::StyleSheetHandler::endRuleBody):
(WebCore::StyleSheetHandler::popRuleData):
(WebCore::fixUnparsedProperties):
(WebCore::StyleSheetHandler::fixUnparsedPropertyRanges):
(WebCore::StyleSheetHandler::observeProperty):
(WebCore::StyleSheetHandler::observeComment):
(WebCore::InspectorStyle::populateAllProperties):
(WebCore::isValidSelectorListString):
(WebCore::InspectorStyleSheet::ensureSourceData):
(WebCore::InspectorStyleSheetForInlineStyle::ensureParsedDataReady):
(WebCore::InspectorStyleSheetForInlineStyle::ruleSourceData):
(WebCore::createCSSParser): Deleted.
(WebCore::InspectorStyleSheetForInlineStyle::getStyleAttributeRanges): Deleted.
* inspector/InspectorStyleSheet.h:
(WebCore::InspectorStyleProperty::setRawTextFromStyleDeclaration):
Add the new implementation. This involves duplicating most of the old
parser code for this into a new class, StyleSheetHandler, that implements
the observer interface and builds up the same data structures as the old
parser did in response to the callbacks.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecssCSSGrammaryin">trunk/Source/WebCore/css/CSSGrammar.y.in</a></li>
<li><a href="#trunkSourceWebCorecssCSSPropertySourceDatacpp">trunk/Source/WebCore/css/CSSPropertySourceData.cpp</a></li>
<li><a href="#trunkSourceWebCorecssCSSPropertySourceDatah">trunk/Source/WebCore/css/CSSPropertySourceData.h</a></li>
<li><a href="#trunkSourceWebCorecssparserCSSParsercpp">trunk/Source/WebCore/css/parser/CSSParser.cpp</a></li>
<li><a href="#trunkSourceWebCorecssparserCSSParserh">trunk/Source/WebCore/css/parser/CSSParser.h</a></li>
<li><a href="#trunkSourceWebCorecssparserCSSParserObserverh">trunk/Source/WebCore/css/parser/CSSParserObserver.h</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorStyleSheetcpp">trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorStyleSheeth">trunk/Source/WebCore/inspector/InspectorStyleSheet.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (208885 => 208886)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-11-18 18:57:17 UTC (rev 208885)
+++ trunk/Source/WebCore/ChangeLog        2016-11-18 19:09:13 UTC (rev 208886)
</span><span class="lines">@@ -1,3 +1,70 @@
</span><ins>+2016-11-18 Dave Hyatt <hyatt@apple.com>
+
+ [CSS Parser] Hook up InspectorStyleSheet to the new CSS parser.
+ https://bugs.webkit.org/show_bug.cgi?id=164886
+
+ Reviewed by Dean Jackson.
+
+ * css/CSSGrammar.y.in:
+ Get rid of the CSSRuleSourceData type enum, since StyleRule's type
+ enum is exactly the same.
+
+ * css/CSSPropertySourceData.cpp:
+ (WebCore::CSSPropertySourceData::CSSPropertySourceData):
+ * css/CSSPropertySourceData.h:
+ Add a concept of disabled to CSSPropertySourceData. This is used for
+ commented out properties.
+
+ (WebCore::CSSRuleSourceData::create):
+ (WebCore::CSSRuleSourceData::createUnknown):
+ (WebCore::CSSRuleSourceData::CSSRuleSourceData):
+ Get rid of the CSSRuleSourceData type enum, since StyleRule's type
+ enum is exactly the same.
+
+ * css/parser/CSSParser.cpp:
+ (WebCore::CSSParserContext::CSSParserContext):
+ (WebCore::CSSParser::parseSheetForInspector):
+ (WebCore::CSSParser::parseDeclarationForInspector):
+ (WebCore::CSSParser::markSupportsRuleHeaderStart):
+ (WebCore::CSSParser::markRuleHeaderStart):
+ (WebCore::CSSParser::markPropertyEnd):
+ * css/parser/CSSParser.h:
+ Add functions that represent the new API for inspector sheet
+ and declaration parsing. Patch the old parse code to use StyleRule::Type
+ now that the CSSRuleSourceData type is gone.
+
+ * css/parser/CSSParserObserver.h:
+ Tweak the API for our memory management.
+
+ * inspector/InspectorStyleSheet.cpp:
+ (flattenSourceData):
+ (WebCore::parserContextForDocument):
+ (WebCore::StyleSheetHandler::StyleSheetHandler):
+ (WebCore::StyleSheetHandler::startRuleHeader):
+ (WebCore::StyleSheetHandler::setRuleHeaderEnd):
+ (WebCore::StyleSheetHandler::endRuleHeader):
+ (WebCore::StyleSheetHandler::observeSelector):
+ (WebCore::StyleSheetHandler::startRuleBody):
+ (WebCore::StyleSheetHandler::endRuleBody):
+ (WebCore::StyleSheetHandler::popRuleData):
+ (WebCore::fixUnparsedProperties):
+ (WebCore::StyleSheetHandler::fixUnparsedPropertyRanges):
+ (WebCore::StyleSheetHandler::observeProperty):
+ (WebCore::StyleSheetHandler::observeComment):
+ (WebCore::InspectorStyle::populateAllProperties):
+ (WebCore::isValidSelectorListString):
+ (WebCore::InspectorStyleSheet::ensureSourceData):
+ (WebCore::InspectorStyleSheetForInlineStyle::ensureParsedDataReady):
+ (WebCore::InspectorStyleSheetForInlineStyle::ruleSourceData):
+ (WebCore::createCSSParser): Deleted.
+ (WebCore::InspectorStyleSheetForInlineStyle::getStyleAttributeRanges): Deleted.
+ * inspector/InspectorStyleSheet.h:
+ (WebCore::InspectorStyleProperty::setRawTextFromStyleDeclaration):
+ Add the new implementation. This involves duplicating most of the old
+ parser code for this into a new class, StyleSheetHandler, that implements
+ the observer interface and builds up the same data structures as the old
+ parser did in response to the callbacks.
+
</ins><span class="cx"> 2016-11-18 Dan Bernstein <mitz@apple.com>
</span><span class="cx">
</span><span class="cx"> Tried to fix some non-macOS builds.
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSGrammaryin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSGrammar.y.in (208885 => 208886)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSGrammar.y.in        2016-11-18 18:57:17 UTC (rev 208885)
+++ trunk/Source/WebCore/css/CSSGrammar.y.in        2016-11-18 19:09:13 UTC (rev 208886)
</span><span class="lines">@@ -516,7 +516,7 @@
</span><span class="cx">
</span><span class="cx"> before_import_rule:
</span><span class="cx"> /* empty */ {
</span><del>- parser->markRuleHeaderStart(CSSRuleSourceData::IMPORT_RULE);
</del><ins>+ parser->markRuleHeaderStart(StyleRule::Import);
</ins><span class="cx"> }
</span><span class="cx"> ;
</span><span class="cx">
</span><span class="lines">@@ -654,7 +654,7 @@
</span><span class="cx">
</span><span class="cx"> before_media_rule:
</span><span class="cx"> /* empty */ {
</span><del>- parser->markRuleHeaderStart(CSSRuleSourceData::MEDIA_RULE);
</del><ins>+ parser->markRuleHeaderStart(StyleRule::Media);
</ins><span class="cx"> }
</span><span class="cx"> ;
</span><span class="cx">
</span><span class="lines">@@ -699,7 +699,7 @@
</span><span class="cx">
</span><span class="cx"> before_supports_rule:
</span><span class="cx"> /* empty */ {
</span><del>- parser->markRuleHeaderStart(CSSRuleSourceData::SUPPORTS_RULE);
</del><ins>+ parser->markRuleHeaderStart(StyleRule::Supports);
</ins><span class="cx"> parser->markSupportsRuleHeaderStart();
</span><span class="cx"> }
</span><span class="cx"> ;
</span><span class="lines">@@ -767,7 +767,7 @@
</span><span class="cx">
</span><span class="cx"> before_keyframes_rule:
</span><span class="cx"> /* empty */ {
</span><del>- parser->markRuleHeaderStart(CSSRuleSourceData::KEYFRAMES_RULE);
</del><ins>+ parser->markRuleHeaderStart(StyleRule::Keyframe);
</ins><span class="cx"> }
</span><span class="cx"> ;
</span><span class="cx">
</span><span class="lines">@@ -829,7 +829,7 @@
</span><span class="cx">
</span><span class="cx"> before_page_rule:
</span><span class="cx"> /* empty */ {
</span><del>- parser->markRuleHeaderStart(CSSRuleSourceData::PAGE_RULE);
</del><ins>+ parser->markRuleHeaderStart(StyleRule::Page);
</ins><span class="cx"> }
</span><span class="cx"> ;
</span><span class="cx">
</span><span class="lines">@@ -942,7 +942,7 @@
</span><span class="cx">
</span><span class="cx"> before_font_face_rule:
</span><span class="cx"> /* empty */ {
</span><del>- parser->markRuleHeaderStart(CSSRuleSourceData::FONT_FACE_RULE);
</del><ins>+ parser->markRuleHeaderStart(StyleRule::FontFace);
</ins><span class="cx"> }
</span><span class="cx"> ;
</span><span class="cx">
</span><span class="lines">@@ -965,7 +965,7 @@
</span><span class="cx"> before_viewport_rule:
</span><span class="cx"> /* empty */ {
</span><span class="cx"> parser->markViewportRuleBodyStart();
</span><del>- parser->markRuleHeaderStart(CSSRuleSourceData::VIEWPORT_RULE);
</del><ins>+ parser->markRuleHeaderStart(StyleRule::Viewport);
</ins><span class="cx"> }
</span><span class="cx"> ;
</span><span class="cx">
</span><span class="lines">@@ -991,7 +991,7 @@
</span><span class="cx">
</span><span class="cx"> before_region_rule:
</span><span class="cx"> /* empty */ {
</span><del>- parser->markRuleHeaderStart(CSSRuleSourceData::REGION_RULE);
</del><ins>+ parser->markRuleHeaderStart(StyleRule::Region);
</ins><span class="cx"> }
</span><span class="cx"> ;
</span><span class="cx">
</span><span class="lines">@@ -1024,7 +1024,7 @@
</span><span class="cx">
</span><span class="cx"> before_selector_list:
</span><span class="cx"> {
</span><del>- parser->markRuleHeaderStart(CSSRuleSourceData::STYLE_RULE);
</del><ins>+ parser->markRuleHeaderStart(StyleRule::Style);
</ins><span class="cx"> parser->markSelectorStart();
</span><span class="cx"> }
</span><span class="cx"> ;
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSPropertySourceDatacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSPropertySourceData.cpp (208885 => 208886)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSPropertySourceData.cpp        2016-11-18 18:57:17 UTC (rev 208885)
+++ trunk/Source/WebCore/css/CSSPropertySourceData.cpp        2016-11-18 19:09:13 UTC (rev 208886)
</span><span class="lines">@@ -55,10 +55,11 @@
</span><span class="cx"> return end - start;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-CSSPropertySourceData::CSSPropertySourceData(const String& name, const String& value, bool important, bool parsedOk, const SourceRange& range)
</del><ins>+CSSPropertySourceData::CSSPropertySourceData(const String& name, const String& value, bool important, bool disabled, bool parsedOk, const SourceRange& range)
</ins><span class="cx"> : name(name)
</span><span class="cx"> , value(value)
</span><span class="cx"> , important(important)
</span><ins>+ , disabled(disabled)
</ins><span class="cx"> , parsedOk(parsedOk)
</span><span class="cx"> , range(range)
</span><span class="cx"> {
</span><span class="lines">@@ -68,6 +69,7 @@
</span><span class="cx"> : name(other.name)
</span><span class="cx"> , value(other.value)
</span><span class="cx"> , important(other.important)
</span><ins>+ , disabled(other.disabled)
</ins><span class="cx"> , parsedOk(other.parsedOk)
</span><span class="cx"> , range(other.range)
</span><span class="cx"> {
</span><span class="lines">@@ -77,6 +79,7 @@
</span><span class="cx"> : name(emptyString())
</span><span class="cx"> , value(emptyString())
</span><span class="cx"> , important(false)
</span><ins>+ , disabled(false)
</ins><span class="cx"> , parsedOk(false)
</span><span class="cx"> , range(SourceRange(0, 0))
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSPropertySourceDatah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSPropertySourceData.h (208885 => 208886)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSPropertySourceData.h        2016-11-18 18:57:17 UTC (rev 208885)
+++ trunk/Source/WebCore/css/CSSPropertySourceData.h        2016-11-18 19:09:13 UTC (rev 208886)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx">
</span><span class="cx"> #pragma once
</span><span class="cx">
</span><ins>+#include "StyleRule.h"
</ins><span class="cx"> #include <utility>
</span><span class="cx"> #include <wtf/Forward.h>
</span><span class="cx"> #include <wtf/HashMap.h>
</span><span class="lines">@@ -51,7 +52,7 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> struct CSSPropertySourceData {
</span><del>- CSSPropertySourceData(const String& name, const String& value, bool important, bool parsedOk, const SourceRange& range);
</del><ins>+ CSSPropertySourceData(const String& name, const String& value, bool important, bool disabled, bool parsedOk, const SourceRange&);
</ins><span class="cx"> CSSPropertySourceData(const CSSPropertySourceData& other);
</span><span class="cx"> CSSPropertySourceData();
</span><span class="cx">
</span><span class="lines">@@ -61,6 +62,7 @@
</span><span class="cx"> String name;
</span><span class="cx"> String value;
</span><span class="cx"> bool important;
</span><ins>+ bool disabled;
</ins><span class="cx"> bool parsedOk;
</span><span class="cx"> SourceRange range;
</span><span class="cx"> };
</span><span class="lines">@@ -79,21 +81,7 @@
</span><span class="cx"> typedef Vector<SourceRange> SelectorRangeList;
</span><span class="cx">
</span><span class="cx"> struct CSSRuleSourceData : public RefCounted<CSSRuleSourceData> {
</span><del>- enum Type {
- UNKNOWN_RULE,
- STYLE_RULE,
- IMPORT_RULE,
- MEDIA_RULE,
- FONT_FACE_RULE,
- PAGE_RULE,
- KEYFRAMES_RULE,
- REGION_RULE,
- HOST_RULE,
- VIEWPORT_RULE,
- SUPPORTS_RULE,
- };
-
- static Ref<CSSRuleSourceData> create(Type type)
</del><ins>+ static Ref<CSSRuleSourceData> create(StyleRule::Type type)
</ins><span class="cx"> {
</span><span class="cx"> return adoptRef(*new CSSRuleSourceData(type));
</span><span class="cx"> }
</span><span class="lines">@@ -100,17 +88,17 @@
</span><span class="cx">
</span><span class="cx"> static Ref<CSSRuleSourceData> createUnknown()
</span><span class="cx"> {
</span><del>- return adoptRef(*new CSSRuleSourceData(UNKNOWN_RULE));
</del><ins>+ return adoptRef(*new CSSRuleSourceData(StyleRule::Unknown));
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- CSSRuleSourceData(Type type)
</del><ins>+ CSSRuleSourceData(StyleRule::Type type)
</ins><span class="cx"> : type(type)
</span><span class="cx"> {
</span><del>- if (type == STYLE_RULE || type == FONT_FACE_RULE || type == PAGE_RULE)
</del><ins>+ if (type == StyleRule::Style || type == StyleRule::FontFace || type == StyleRule::Page)
</ins><span class="cx"> styleSourceData = CSSStyleSourceData::create();
</span><span class="cx"> }
</span><span class="cx">
</span><del>- Type type;
</del><ins>+ StyleRule::Type type;
</ins><span class="cx">
</span><span class="cx"> // Range of the selector list in the enclosing source.
</span><span class="cx"> SourceRange ruleHeaderRange;
</span></span></pre></div>
<a id="trunkSourceWebCorecssparserCSSParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/parser/CSSParser.cpp (208885 => 208886)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/parser/CSSParser.cpp        2016-11-18 18:57:17 UTC (rev 208885)
+++ trunk/Source/WebCore/css/parser/CSSParser.cpp        2016-11-18 19:09:13 UTC (rev 208886)
</span><span class="lines">@@ -58,6 +58,7 @@
</span><span class="cx"> #include "CSSPageRule.h"
</span><span class="cx"> #include "CSSParserFastPaths.h"
</span><span class="cx"> #include "CSSParserImpl.h"
</span><ins>+#include "CSSParserObserver.h"
</ins><span class="cx"> #include "CSSPendingSubstitutionValue.h"
</span><span class="cx"> #include "CSSPrimitiveValue.h"
</span><span class="cx"> #include "CSSPrimitiveValueMappings.h"
</span><span class="lines">@@ -392,6 +393,11 @@
</span><span class="cx"> m_logErrors = false;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void CSSParser::parseSheetForInspector(const CSSParserContext& context, StyleSheetContents* sheet, const String& string, CSSParserObserver& observer)
+{
+ return CSSParserImpl::parseStyleSheetForInspector(string, context, sheet, observer);
+}
+
</ins><span class="cx"> RefPtr<StyleRuleBase> CSSParser::parseRule(StyleSheetContents* sheet, const String& string)
</span><span class="cx"> {
</span><span class="cx"> if (m_context.useNewParser && m_context.mode != UASheetMode)
</span><span class="lines">@@ -1515,6 +1521,11 @@
</span><span class="cx"> return ok;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void CSSParser::parseDeclarationForInspector(const CSSParserContext& context, const String& string, CSSParserObserver& observer)
+{
+ CSSParserImpl::parseDeclarationListForInspector(string, context, observer);
+}
+
</ins><span class="cx"> static inline void filterProperties(bool important, const ParsedPropertyVector& input, Vector<CSSProperty, 256>& output, size_t& unusedEntries, std::bitset<numCSSProperties>& seenProperties, HashSet<AtomicString>& seenCustomProperties)
</span><span class="cx"> {
</span><span class="cx"> // Add properties in reverse order so that highest priority definitions are reached first. Duplicate definitions can then be ignored when found.
</span><span class="lines">@@ -12925,7 +12936,7 @@
</span><span class="cx"> if (!m_supportsRuleDataStack)
</span><span class="cx"> m_supportsRuleDataStack = std::make_unique<RuleSourceDataList>();
</span><span class="cx">
</span><del>- auto data = CSSRuleSourceData::create(CSSRuleSourceData::SUPPORTS_RULE);
</del><ins>+ auto data = CSSRuleSourceData::create(StyleRule::Supports);
</ins><span class="cx"> data->ruleHeaderRange.start = tokenStartOffset();
</span><span class="cx"> m_supportsRuleDataStack->append(WTFMove(data));
</span><span class="cx"> }
</span><span class="lines">@@ -13325,7 +13336,7 @@
</span><span class="cx"> fixUnparsedProperties<UChar>(m_dataStart16.get() + m_parsedTextPrefixLength, ruleData);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void CSSParser::markRuleHeaderStart(CSSRuleSourceData::Type ruleType)
</del><ins>+void CSSParser::markRuleHeaderStart(StyleRule::Type ruleType)
</ins><span class="cx"> {
</span><span class="cx"> if (!isExtractingSourceData())
</span><span class="cx"> return;
</span><span class="lines">@@ -13450,7 +13461,7 @@
</span><span class="cx"> // The property range is relative to the declaration start offset.
</span><span class="cx"> SourceRange& topRuleBodyRange = m_currentRuleDataStack->last()->ruleBodyRange;
</span><span class="cx"> m_currentRuleDataStack->last()->styleSourceData->propertyData.append(
</span><del>- CSSPropertySourceData(name, value, isImportantFound, isPropertyParsed, SourceRange(start - topRuleBodyRange.start, end - topRuleBodyRange.start)));
</del><ins>+ CSSPropertySourceData(name, value, isImportantFound, false, isPropertyParsed, SourceRange(start - topRuleBodyRange.start, end - topRuleBodyRange.start)));
</ins><span class="cx"> }
</span><span class="cx"> resetPropertyRange();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorecssparserCSSParserh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/parser/CSSParser.h (208885 => 208886)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/parser/CSSParser.h        2016-11-18 18:57:17 UTC (rev 208885)
+++ trunk/Source/WebCore/css/parser/CSSParser.h        2016-11-18 19:09:13 UTC (rev 208886)
</span><span class="lines">@@ -50,6 +50,7 @@
</span><span class="cx"> class AnimationParseContext;
</span><span class="cx"> class CSSBorderImageSliceValue;
</span><span class="cx"> class CSSContentDistributionValue;
</span><ins>+class CSSParserObserver;
</ins><span class="cx"> class CSSPrimitiveValue;
</span><span class="cx"> class CSSSelectorList;
</span><span class="cx"> class CSSValue;
</span><span class="lines">@@ -132,6 +133,9 @@
</span><span class="cx"> RefPtr<StyleKeyframe> parseKeyframeRule(StyleSheetContents*, const String&);
</span><span class="cx"> bool parseSupportsCondition(const String&);
</span><span class="cx">
</span><ins>+ static void parseSheetForInspector(const CSSParserContext&, StyleSheetContents*, const String&, CSSParserObserver&);
+ static void parseDeclarationForInspector(const CSSParserContext&, const String&, CSSParserObserver&);
+
</ins><span class="cx"> static ParseResult parseValue(MutableStyleProperties&, CSSPropertyID, const String&, bool important, const CSSParserContext&, StyleSheetContents*);
</span><span class="cx"> static ParseResult parseCustomPropertyValue(MutableStyleProperties&, const AtomicString& propertyName, const String&, bool important, const CSSParserContext&, StyleSheetContents* contextStyleSheet);
</span><span class="cx">
</span><span class="lines">@@ -141,6 +145,7 @@
</span><span class="cx"> static RefPtr<CSSValueList> parseFontFaceValue(const AtomicString&);
</span><span class="cx"> RefPtr<CSSPrimitiveValue> parseValidPrimitive(CSSValueID ident, ValueWithCalculation&);
</span><span class="cx">
</span><ins>+ // FIXME-NEWPARSER: Can remove the last two arguments once the new parser is turned on.
</ins><span class="cx"> WEBCORE_EXPORT bool parseDeclaration(MutableStyleProperties&, const String&, RefPtr<CSSRuleSourceData>&&, StyleSheetContents* contextStyleSheet);
</span><span class="cx"> static Ref<ImmutableStyleProperties> parseInlineStyleDeclaration(const String&, Element*);
</span><span class="cx">
</span><span class="lines">@@ -456,7 +461,7 @@
</span><span class="cx"> RuleSourceDataList* m_ruleSourceDataResult { nullptr };
</span><span class="cx">
</span><span class="cx"> void fixUnparsedPropertyRanges(CSSRuleSourceData&);
</span><del>- void markRuleHeaderStart(CSSRuleSourceData::Type);
</del><ins>+ void markRuleHeaderStart(StyleRule::Type);
</ins><span class="cx"> void markRuleHeaderEnd();
</span><span class="cx">
</span><span class="cx"> void startNestedSelectorList() { ++m_nestedSelectorLevel; }
</span></span></pre></div>
<a id="trunkSourceWebCorecssparserCSSParserObserverh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/parser/CSSParserObserver.h (208885 => 208886)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/parser/CSSParserObserver.h        2016-11-18 18:57:17 UTC (rev 208885)
+++ trunk/Source/WebCore/css/parser/CSSParserObserver.h        2016-11-18 19:09:13 UTC (rev 208886)
</span><span class="lines">@@ -42,11 +42,6 @@
</span><span class="cx"> virtual void endRuleBody(unsigned offset) = 0;
</span><span class="cx"> virtual void observeProperty(unsigned startOffset, unsigned endOffset, bool isImportant, bool isParsed) = 0;
</span><span class="cx"> virtual void observeComment(unsigned startOffset, unsigned endOffset) = 0;
</span><del>- // FIXME: Unused, should be removed
- virtual void startMediaQueryExp(unsigned offset) = 0;
- virtual void endMediaQueryExp(unsigned offset) = 0;
- virtual void startMediaQuery() = 0;
- virtual void endMediaQuery() = 0;
</del><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorStyleSheetcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp (208885 => 208886)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp        2016-11-18 18:57:17 UTC (rev 208885)
+++ trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp        2016-11-18 19:09:13 UTC (rev 208886)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #include "CSSKeyframesRule.h"
</span><span class="cx"> #include "CSSMediaRule.h"
</span><span class="cx"> #include "CSSParser.h"
</span><ins>+#include "CSSParserObserver.h"
</ins><span class="cx"> #include "CSSPropertyNames.h"
</span><span class="cx"> #include "CSSPropertySourceData.h"
</span><span class="cx"> #include "CSSRule.h"
</span><span class="lines">@@ -100,11 +101,11 @@
</span><span class="cx"> static void flattenSourceData(RuleSourceDataList& dataList, RuleSourceDataList& target)
</span><span class="cx"> {
</span><span class="cx"> for (auto& data : dataList) {
</span><del>- if (data->type == CSSRuleSourceData::STYLE_RULE)
</del><ins>+ if (data->type == WebCore::StyleRule::Style)
</ins><span class="cx"> target.append(data.copyRef());
</span><del>- else if (data->type == CSSRuleSourceData::MEDIA_RULE)
</del><ins>+ else if (data->type == WebCore::StyleRule::Media)
</ins><span class="cx"> flattenSourceData(data->childRules, target);
</span><del>- else if (data->type == CSSRuleSourceData::SUPPORTS_RULE)
</del><ins>+ else if (data->type == WebCore::StyleRule::Supports)
</ins><span class="cx"> flattenSourceData(data->childRules, target);
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -136,6 +137,247 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><ins>+static CSSParserContext parserContextForDocument(Document* document)
+{
+ return document ? CSSParserContext(*document) : strictCSSParserContext();
+}
+
+class StyleSheetHandler : public CSSParserObserver {
+public:
+ StyleSheetHandler(const String& parsedText, Document* document, RuleSourceDataList* result)
+ : m_parsedText(parsedText)
+ , m_document(document)
+ , m_ruleSourceDataResult(result)
+ {
+ ASSERT(m_ruleSourceDataResult);
+ }
+
+private:
+ void startRuleHeader(StyleRule::Type, unsigned) override;
+ void endRuleHeader(unsigned) override;
+ void observeSelector(unsigned startOffset, unsigned endOffset) override;
+ void startRuleBody(unsigned) override;
+ void endRuleBody(unsigned) override;
+ void observeProperty(unsigned startOffset, unsigned endOffset, bool isImportant, bool isParsed) override;
+ void observeComment(unsigned startOffset, unsigned endOffset) override;
+
+ Ref<CSSRuleSourceData> popRuleData();
+ template <typename CharacterType> inline void setRuleHeaderEnd(const CharacterType*, unsigned);
+ void fixUnparsedPropertyRanges(CSSRuleSourceData*);
+
+ const String& m_parsedText;
+ Document* m_document;
+
+ RuleSourceDataList m_currentRuleDataStack;
+ RefPtr<CSSRuleSourceData> m_currentRuleData;
+ RuleSourceDataList* m_ruleSourceDataResult { nullptr };
+};
+
+void StyleSheetHandler::startRuleHeader(StyleRule::Type type, unsigned offset)
+{
+ // Pop off data for a previous invalid rule.
+ if (m_currentRuleData)
+ m_currentRuleDataStack.removeLast();
+
+ auto data = CSSRuleSourceData::create(type);
+ data->ruleHeaderRange.start = offset;
+ m_currentRuleData = data.copyRef();
+ m_currentRuleDataStack.append(WTFMove(data));
+}
+
+template <typename CharacterType> inline void StyleSheetHandler::setRuleHeaderEnd(const CharacterType* dataStart, unsigned listEndOffset)
+{
+ while (listEndOffset > 1) {
+ if (isHTMLSpace<CharacterType>(*(dataStart + listEndOffset - 1)))
+ --listEndOffset;
+ else
+ break;
+ }
+
+ m_currentRuleDataStack.last()->ruleHeaderRange.end = listEndOffset;
+ if (!m_currentRuleDataStack.last()->selectorRanges.isEmpty())
+ m_currentRuleDataStack.last()->selectorRanges.last().end = listEndOffset;
+}
+
+void StyleSheetHandler::endRuleHeader(unsigned offset)
+{
+ ASSERT(!m_currentRuleDataStack.isEmpty());
+
+ if (m_parsedText.is8Bit())
+ setRuleHeaderEnd<LChar>(m_parsedText.characters8(), offset);
+ else
+ setRuleHeaderEnd<UChar>(m_parsedText.characters16(), offset);
+}
+
+void StyleSheetHandler::observeSelector(unsigned startOffset, unsigned endOffset)
+{
+ ASSERT(m_currentRuleDataStack.size());
+ m_currentRuleDataStack.last()->selectorRanges.append(SourceRange(startOffset, endOffset));
+}
+
+void StyleSheetHandler::startRuleBody(unsigned offset)
+{
+ m_currentRuleData = nullptr;
+ ASSERT(!m_currentRuleDataStack.isEmpty());
+
+ // Skip the rule body opening brace.
+ if (m_parsedText[offset] == '{')
+ ++offset;
+
+ m_currentRuleDataStack.last()->ruleBodyRange.start = offset;
+}
+
+void StyleSheetHandler::endRuleBody(unsigned offset)
+{
+ ASSERT(!m_currentRuleDataStack.isEmpty());
+ m_currentRuleDataStack.last()->ruleBodyRange.end = offset;
+ auto rule = popRuleData();
+ fixUnparsedPropertyRanges(rule.ptr());
+ if (m_currentRuleDataStack.isEmpty())
+ m_ruleSourceDataResult->append(WTFMove(rule));
+ else
+ m_currentRuleDataStack.last()->childRules.append(WTFMove(rule));
+}
+
+Ref<CSSRuleSourceData> StyleSheetHandler::popRuleData()
+{
+ ASSERT(!m_currentRuleDataStack.isEmpty());
+ m_currentRuleData = nullptr;
+ auto data = WTFMove(m_currentRuleDataStack.last());
+ m_currentRuleDataStack.removeLast();
+ return data;
+}
+
+template <typename CharacterType>
+static inline void fixUnparsedProperties(const CharacterType* characters, CSSRuleSourceData* ruleData)
+{
+ Vector<CSSPropertySourceData>& propertyData = ruleData->styleSourceData->propertyData;
+ unsigned size = propertyData.size();
+ if (!size)
+ return;
+
+ unsigned styleStart = ruleData->ruleBodyRange.start;
+
+ CSSPropertySourceData* nextData = &(propertyData.at(0));
+ for (unsigned i = 0; i < size; ++i) {
+ CSSPropertySourceData* currentData = nextData;
+ nextData = i < size - 1 ? &(propertyData.at(i + 1)) : nullptr;
+
+ if (currentData->parsedOk)
+ continue;
+ if (currentData->range.end > 0 && characters[styleStart + currentData->range.end - 1] == ';')
+ continue;
+
+ unsigned propertyEnd;
+ if (!nextData)
+ propertyEnd = ruleData->ruleBodyRange.end - 1;
+ else
+ propertyEnd = styleStart + nextData->range.start - 1;
+
+ while (isHTMLSpace<CharacterType>(characters[propertyEnd]))
+ --propertyEnd;
+
+ // propertyEnd points at the last property text character.
+ unsigned newPropertyEnd = propertyEnd + styleStart + 1;
+ if (currentData->range.end != newPropertyEnd) {
+ currentData->range.end = newPropertyEnd;
+ unsigned valueStart = styleStart + currentData->range.start + currentData->name.length();
+ while (valueStart < propertyEnd && characters[valueStart] != ':')
+ ++valueStart;
+
+ // Shift past the ':'.
+ if (valueStart < propertyEnd)
+ ++valueStart;
+
+ while (valueStart < propertyEnd && isHTMLSpace<CharacterType>(characters[valueStart]))
+ ++valueStart;
+
+ // Need to exclude the trailing ';' from the property value.
+ currentData->value = String(characters + valueStart, propertyEnd - valueStart + (characters[propertyEnd] == ';' ? 0 : 1));
+ }
+ }
+}
+
+void StyleSheetHandler::fixUnparsedPropertyRanges(CSSRuleSourceData* ruleData)
+{
+ if (!ruleData->styleSourceData)
+ return;
+
+ if (m_parsedText.is8Bit()) {
+ fixUnparsedProperties<LChar>(m_parsedText.characters8(), ruleData);
+ return;
+ }
+
+ fixUnparsedProperties<UChar>(m_parsedText.characters16(), ruleData);
+}
+
+void StyleSheetHandler::observeProperty(unsigned startOffset, unsigned endOffset, bool isImportant, bool isParsed)
+{
+ if (m_currentRuleDataStack.isEmpty() || !m_currentRuleDataStack.last()->styleSourceData)
+ return;
+
+ ASSERT(endOffset <= m_parsedText.length());
+
+ // Include semicolon in the property text.
+ if (endOffset < m_parsedText.length() && m_parsedText[endOffset] == ';')
+ ++endOffset;
+
+ ASSERT(startOffset < endOffset);
+ String propertyString = m_parsedText.substring(startOffset, endOffset - startOffset).stripWhiteSpace();
+ if (propertyString.endsWith(';'))
+ propertyString = propertyString.left(propertyString.length() - 1);
+ size_t colonIndex = propertyString.find(':');
+ ASSERT(colonIndex != notFound);
+
+ String name = propertyString.left(colonIndex).stripWhiteSpace();
+ String value = propertyString.substring(colonIndex + 1, propertyString.length()).stripWhiteSpace();
+
+ // FIXME-NEWPARSER: The property range is relative to the declaration start offset, but no
+ // good reason for it, and it complicates fixUnparsedProperties.
+ SourceRange& topRuleBodyRange = m_currentRuleDataStack.last()->ruleBodyRange;
+ m_currentRuleDataStack.last()->styleSourceData->propertyData.append(CSSPropertySourceData(name, value, isImportant, false, isParsed, SourceRange(startOffset - topRuleBodyRange.start, endOffset - topRuleBodyRange.start)));
+}
+
+void StyleSheetHandler::observeComment(unsigned startOffset, unsigned endOffset)
+{
+ ASSERT(endOffset <= m_parsedText.length());
+
+ if (m_currentRuleDataStack.isEmpty() || !m_currentRuleDataStack.last()->ruleHeaderRange.end || !m_currentRuleDataStack.last()->styleSourceData)
+ return;
+
+ // The lexer is not inside a property AND it is scanning a declaration-aware
+ // rule body.
+ String commentText = m_parsedText.substring(startOffset, endOffset - startOffset);
+
+ ASSERT(commentText.startsWith("/*"));
+ commentText = commentText.substring(2);
+
+ // Require well-formed comments.
+ if (!commentText.endsWith("*/"))
+ return;
+ commentText = commentText.substring(0, commentText.length() - 2).stripWhiteSpace();
+ if (commentText.isEmpty())
+ return;
+
+ // FIXME: Use the actual rule type rather than STYLE_RULE?
+ RuleSourceDataList sourceData;
+
+ StyleSheetHandler handler(commentText, m_document, &sourceData);
+ CSSParser::parseDeclarationForInspector(parserContextForDocument(m_document), commentText, handler);
+ Vector<CSSPropertySourceData>& commentPropertyData = sourceData.first()->styleSourceData->propertyData;
+ if (commentPropertyData.size() != 1)
+ return;
+ CSSPropertySourceData& propertyData = commentPropertyData.at(0);
+ bool parsedOk = propertyData.parsedOk || propertyData.name.startsWith("-moz-") || propertyData.name.startsWith("-o-") || propertyData.name.startsWith("-webkit-") || propertyData.name.startsWith("-ms-");
+ if (!parsedOk || propertyData.range.length() != commentText.length())
+ return;
+
+ // FIXME-NEWPARSER: The property range is relative to the declaration start offset, but no
+ // good reason for it, and it complicates fixUnparsedProperties.
+ SourceRange& topRuleBodyRange = m_currentRuleDataStack.last()->ruleBodyRange;
+ m_currentRuleDataStack.last()->styleSourceData->propertyData.append(CSSPropertySourceData(propertyData.name, propertyData.value, false, true, true, SourceRange(startOffset - topRuleBodyRange.start, endOffset - topRuleBodyRange.start)));
+}
+
</ins><span class="cx"> enum MediaListSource {
</span><span class="cx"> MediaListSourceLinkedSheet,
</span><span class="cx"> MediaListSourceInlineSheet,
</span><span class="lines">@@ -273,11 +515,6 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static std::unique_ptr<CSSParser> createCSSParser(Document* document)
-{
- return std::make_unique<CSSParser>(document ? CSSParserContext(*document) : strictCSSParserContext());
-}
-
</del><span class="cx"> Ref<InspectorStyle> InspectorStyle::create(const InspectorCSSId& styleId, RefPtr<CSSStyleDeclaration>&& style, InspectorStyleSheet* parentStyleSheet)
</span><span class="cx"> {
</span><span class="cx"> return adoptRef(*new InspectorStyle(styleId, WTFMove(style), parentStyleSheet));
</span><span class="lines">@@ -363,7 +600,7 @@
</span><span class="cx"> ASSERT(!styleDeclarationOrException.hasException());
</span><span class="cx"> String styleDeclaration = styleDeclarationOrException.hasException() ? emptyString() : styleDeclarationOrException.releaseReturnValue();
</span><span class="cx"> for (auto& sourceData : *sourcePropertyData) {
</span><del>- InspectorStyleProperty p(sourceData, true, false);
</del><ins>+ InspectorStyleProperty p(sourceData, true, sourceData.disabled);
</ins><span class="cx"> p.setRawTextFromStyleDeclaration(styleDeclaration);
</span><span class="cx"> result->append(p);
</span><span class="cx"> sourcePropertyNames.add(lowercasePropertyName(sourceData.name));
</span><span class="lines">@@ -373,7 +610,7 @@
</span><span class="cx"> for (int i = 0, size = m_style->length(); i < size; ++i) {
</span><span class="cx"> String name = m_style->item(i);
</span><span class="cx"> if (sourcePropertyNames.add(lowercasePropertyName(name)))
</span><del>- result->append(InspectorStyleProperty(CSSPropertySourceData(name, m_style->getPropertyValue(name), !m_style->getPropertyPriority(name).isEmpty(), true, SourceRange()), false, false));
</del><ins>+ result->append(InspectorStyleProperty(CSSPropertySourceData(name, m_style->getPropertyValue(name), !m_style->getPropertyPriority(name).isEmpty(), false, true, SourceRange()), false, false));
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -635,7 +872,8 @@
</span><span class="cx"> static bool isValidSelectorListString(const String& selector, Document* document)
</span><span class="cx"> {
</span><span class="cx"> CSSSelectorList selectorList;
</span><del>- createCSSParser(document)->parseSelector(selector, selectorList);
</del><ins>+ CSSParser parser(parserContextForDocument(document));
+ parser.parseSelector(selector, selectorList);
</ins><span class="cx"> return selectorList.isValid();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1089,7 +1327,13 @@
</span><span class="cx">
</span><span class="cx"> RefPtr<StyleSheetContents> newStyleSheet = StyleSheetContents::create();
</span><span class="cx"> auto ruleSourceDataResult = std::make_unique<RuleSourceDataList>();
</span><del>- createCSSParser(m_pageStyleSheet->ownerDocument())->parseSheet(newStyleSheet.get(), m_parsedStyleSheet->text(), TextPosition(), ruleSourceDataResult.get(), false);
</del><ins>+
+ CSSParserContext context(parserContextForDocument(m_pageStyleSheet->ownerDocument()));
+ if (context.useNewParser) {
+ StyleSheetHandler handler(m_parsedStyleSheet->text(), m_pageStyleSheet->ownerDocument(), ruleSourceDataResult.get());
+ CSSParser::parseSheetForInspector(context, newStyleSheet.get(), m_parsedStyleSheet->text(), handler);
+ } else
+ CSSParser(context).parseSheet(newStyleSheet.get(), m_parsedStyleSheet->text(), TextPosition(), ruleSourceDataResult.get(), false);
</ins><span class="cx"> m_parsedStyleSheet->setSourceData(WTFMove(ruleSourceDataResult));
</span><span class="cx"> return m_parsedStyleSheet->hasSourceData();
</span><span class="cx"> }
</span><span class="lines">@@ -1295,11 +1539,10 @@
</span><span class="cx"> if (m_ruleSourceData)
</span><span class="cx"> return true;
</span><span class="cx">
</span><del>- m_ruleSourceData = CSSRuleSourceData::create(CSSRuleSourceData::STYLE_RULE);
- bool success = getStyleAttributeRanges(m_ruleSourceData.get());
- if (!success)
</del><ins>+ if (!m_element->isStyledElement())
</ins><span class="cx"> return false;
</span><span class="cx">
</span><ins>+ m_ruleSourceData = ruleSourceData();
</ins><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1319,20 +1562,27 @@
</span><span class="cx"> return m_element->getAttribute("style").string();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool InspectorStyleSheetForInlineStyle::getStyleAttributeRanges(CSSRuleSourceData* result) const
</del><ins>+Ref<CSSRuleSourceData> InspectorStyleSheetForInlineStyle::ruleSourceData() const
</ins><span class="cx"> {
</span><del>- if (!m_element->isStyledElement())
- return false;
-
</del><span class="cx"> if (m_styleText.isEmpty()) {
</span><ins>+ auto result = CSSRuleSourceData::create(StyleRule::Style);
</ins><span class="cx"> result->ruleBodyRange.start = 0;
</span><span class="cx"> result->ruleBodyRange.end = 0;
</span><del>- return true;
</del><ins>+ return result;
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+ CSSParserContext context(parserContextForDocument(&m_element->document()));
+ if (context.useNewParser) {
+ RuleSourceDataList ruleSourceDataResult;
+ StyleSheetHandler handler(m_styleText, &m_element->document(), &ruleSourceDataResult);
+ CSSParser::parseDeclarationForInspector(context, m_styleText, handler);
+ return WTFMove(ruleSourceDataResult.first());
+ }
+
+ auto result = CSSRuleSourceData::create(StyleRule::Style);
</ins><span class="cx"> auto tempDeclaration = MutableStyleProperties::create();
</span><del>- createCSSParser(&m_element->document())->parseDeclaration(tempDeclaration, m_styleText, result, nullptr);
- return true;
</del><ins>+ CSSParser(context).parseDeclaration(tempDeclaration, m_styleText, result.ptr(), nullptr);
+ return result;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorStyleSheeth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorStyleSheet.h (208885 => 208886)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorStyleSheet.h        2016-11-18 18:57:17 UTC (rev 208885)
+++ trunk/Source/WebCore/inspector/InspectorStyleSheet.h        2016-11-18 19:09:13 UTC (rev 208886)
</span><span class="lines">@@ -251,7 +251,7 @@
</span><span class="cx"> private:
</span><span class="cx"> CSSStyleDeclaration* inlineStyle() const;
</span><span class="cx"> const String& elementStyleText() const;
</span><del>- bool getStyleAttributeRanges(CSSRuleSourceData* result) const;
</del><ins>+ Ref<CSSRuleSourceData> ruleSourceData() const;
</ins><span class="cx">
</span><span class="cx"> RefPtr<Element> m_element;
</span><span class="cx"> RefPtr<CSSRuleSourceData> m_ruleSourceData;
</span></span></pre>
</div>
</div>
</body>
</html>