<!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  &lt;hyatt@apple.com&gt;
+
+        [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  &lt;mitz@apple.com&gt;
</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-&gt;markRuleHeaderStart(CSSRuleSourceData::IMPORT_RULE);
</del><ins>+        parser-&gt;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-&gt;markRuleHeaderStart(CSSRuleSourceData::MEDIA_RULE);
</del><ins>+        parser-&gt;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-&gt;markRuleHeaderStart(CSSRuleSourceData::SUPPORTS_RULE);
</del><ins>+        parser-&gt;markRuleHeaderStart(StyleRule::Supports);
</ins><span class="cx">         parser-&gt;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-&gt;markRuleHeaderStart(CSSRuleSourceData::KEYFRAMES_RULE);
</del><ins>+        parser-&gt;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-&gt;markRuleHeaderStart(CSSRuleSourceData::PAGE_RULE);
</del><ins>+        parser-&gt;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-&gt;markRuleHeaderStart(CSSRuleSourceData::FONT_FACE_RULE);
</del><ins>+        parser-&gt;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-&gt;markViewportRuleBodyStart();
</span><del>-        parser-&gt;markRuleHeaderStart(CSSRuleSourceData::VIEWPORT_RULE);
</del><ins>+        parser-&gt;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-&gt;markRuleHeaderStart(CSSRuleSourceData::REGION_RULE);
</del><ins>+        parser-&gt;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-&gt;markRuleHeaderStart(CSSRuleSourceData::STYLE_RULE);
</del><ins>+        parser-&gt;markRuleHeaderStart(StyleRule::Style);
</ins><span class="cx">         parser-&gt;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&amp; name, const String&amp; value, bool important, bool parsedOk, const SourceRange&amp; range)
</del><ins>+CSSPropertySourceData::CSSPropertySourceData(const String&amp; name, const String&amp; value, bool important, bool disabled, bool parsedOk, const SourceRange&amp; 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 &quot;StyleRule.h&quot;
</ins><span class="cx"> #include &lt;utility&gt;
</span><span class="cx"> #include &lt;wtf/Forward.h&gt;
</span><span class="cx"> #include &lt;wtf/HashMap.h&gt;
</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&amp; name, const String&amp; value, bool important, bool parsedOk, const SourceRange&amp; range);
</del><ins>+    CSSPropertySourceData(const String&amp; name, const String&amp; value, bool important, bool disabled, bool parsedOk, const SourceRange&amp;);
</ins><span class="cx">     CSSPropertySourceData(const CSSPropertySourceData&amp; 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&lt;SourceRange&gt; SelectorRangeList;
</span><span class="cx"> 
</span><span class="cx"> struct CSSRuleSourceData : public RefCounted&lt;CSSRuleSourceData&gt; {
</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&lt;CSSRuleSourceData&gt; create(Type type)
</del><ins>+    static Ref&lt;CSSRuleSourceData&gt; 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&lt;CSSRuleSourceData&gt; 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 &quot;CSSPageRule.h&quot;
</span><span class="cx"> #include &quot;CSSParserFastPaths.h&quot;
</span><span class="cx"> #include &quot;CSSParserImpl.h&quot;
</span><ins>+#include &quot;CSSParserObserver.h&quot;
</ins><span class="cx"> #include &quot;CSSPendingSubstitutionValue.h&quot;
</span><span class="cx"> #include &quot;CSSPrimitiveValue.h&quot;
</span><span class="cx"> #include &quot;CSSPrimitiveValueMappings.h&quot;
</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&amp; context, StyleSheetContents* sheet, const String&amp; string, CSSParserObserver&amp; observer)
+{
+    return CSSParserImpl::parseStyleSheetForInspector(string, context, sheet, observer);
+}
+
</ins><span class="cx"> RefPtr&lt;StyleRuleBase&gt; CSSParser::parseRule(StyleSheetContents* sheet, const String&amp; string)
</span><span class="cx"> {
</span><span class="cx">     if (m_context.useNewParser &amp;&amp; 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&amp; context, const String&amp; string, CSSParserObserver&amp; observer)
+{
+    CSSParserImpl::parseDeclarationListForInspector(string, context, observer);
+}
+
</ins><span class="cx"> static inline void filterProperties(bool important, const ParsedPropertyVector&amp; input, Vector&lt;CSSProperty, 256&gt;&amp; output, size_t&amp; unusedEntries, std::bitset&lt;numCSSProperties&gt;&amp; seenProperties, HashSet&lt;AtomicString&gt;&amp; 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&lt;RuleSourceDataList&gt;();
</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-&gt;ruleHeaderRange.start = tokenStartOffset();
</span><span class="cx">     m_supportsRuleDataStack-&gt;append(WTFMove(data));
</span><span class="cx"> }
</span><span class="lines">@@ -13325,7 +13336,7 @@
</span><span class="cx">     fixUnparsedProperties&lt;UChar&gt;(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&amp; topRuleBodyRange = m_currentRuleDataStack-&gt;last()-&gt;ruleBodyRange;
</span><span class="cx">         m_currentRuleDataStack-&gt;last()-&gt;styleSourceData-&gt;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&lt;StyleKeyframe&gt; parseKeyframeRule(StyleSheetContents*, const String&amp;);
</span><span class="cx">     bool parseSupportsCondition(const String&amp;);
</span><span class="cx"> 
</span><ins>+    static void parseSheetForInspector(const CSSParserContext&amp;, StyleSheetContents*, const String&amp;, CSSParserObserver&amp;);
+    static void parseDeclarationForInspector(const CSSParserContext&amp;, const String&amp;, CSSParserObserver&amp;);
+
</ins><span class="cx">     static ParseResult parseValue(MutableStyleProperties&amp;, CSSPropertyID, const String&amp;, bool important, const CSSParserContext&amp;, StyleSheetContents*);
</span><span class="cx">     static ParseResult parseCustomPropertyValue(MutableStyleProperties&amp;, const AtomicString&amp; propertyName, const String&amp;, bool important, const CSSParserContext&amp;, StyleSheetContents* contextStyleSheet);
</span><span class="cx"> 
</span><span class="lines">@@ -141,6 +145,7 @@
</span><span class="cx">     static RefPtr&lt;CSSValueList&gt; parseFontFaceValue(const AtomicString&amp;);
</span><span class="cx">     RefPtr&lt;CSSPrimitiveValue&gt; parseValidPrimitive(CSSValueID ident, ValueWithCalculation&amp;);
</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&amp;, const String&amp;, RefPtr&lt;CSSRuleSourceData&gt;&amp;&amp;, StyleSheetContents* contextStyleSheet);
</span><span class="cx">     static Ref&lt;ImmutableStyleProperties&gt; parseInlineStyleDeclaration(const String&amp;, 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&amp;);
</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 &quot;CSSKeyframesRule.h&quot;
</span><span class="cx"> #include &quot;CSSMediaRule.h&quot;
</span><span class="cx"> #include &quot;CSSParser.h&quot;
</span><ins>+#include &quot;CSSParserObserver.h&quot;
</ins><span class="cx"> #include &quot;CSSPropertyNames.h&quot;
</span><span class="cx"> #include &quot;CSSPropertySourceData.h&quot;
</span><span class="cx"> #include &quot;CSSRule.h&quot;
</span><span class="lines">@@ -100,11 +101,11 @@
</span><span class="cx"> static void flattenSourceData(RuleSourceDataList&amp; dataList, RuleSourceDataList&amp; target)
</span><span class="cx"> {
</span><span class="cx">     for (auto&amp; data : dataList) {
</span><del>-        if (data-&gt;type == CSSRuleSourceData::STYLE_RULE)
</del><ins>+        if (data-&gt;type == WebCore::StyleRule::Style)
</ins><span class="cx">             target.append(data.copyRef());
</span><del>-        else if (data-&gt;type == CSSRuleSourceData::MEDIA_RULE)
</del><ins>+        else if (data-&gt;type == WebCore::StyleRule::Media)
</ins><span class="cx">             flattenSourceData(data-&gt;childRules, target);
</span><del>-        else if (data-&gt;type == CSSRuleSourceData::SUPPORTS_RULE)
</del><ins>+        else if (data-&gt;type == WebCore::StyleRule::Supports)
</ins><span class="cx">             flattenSourceData(data-&gt;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&amp; 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&lt;CSSRuleSourceData&gt; popRuleData();
+    template &lt;typename CharacterType&gt; inline void setRuleHeaderEnd(const CharacterType*, unsigned);
+    void fixUnparsedPropertyRanges(CSSRuleSourceData*);
+    
+    const String&amp; m_parsedText;
+    Document* m_document;
+    
+    RuleSourceDataList m_currentRuleDataStack;
+    RefPtr&lt;CSSRuleSourceData&gt; 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-&gt;ruleHeaderRange.start = offset;
+    m_currentRuleData = data.copyRef();
+    m_currentRuleDataStack.append(WTFMove(data));
+}
+
+template &lt;typename CharacterType&gt; inline void StyleSheetHandler::setRuleHeaderEnd(const CharacterType* dataStart, unsigned listEndOffset)
+{
+    while (listEndOffset &gt; 1) {
+        if (isHTMLSpace&lt;CharacterType&gt;(*(dataStart + listEndOffset - 1)))
+            --listEndOffset;
+        else
+            break;
+    }
+
+    m_currentRuleDataStack.last()-&gt;ruleHeaderRange.end = listEndOffset;
+    if (!m_currentRuleDataStack.last()-&gt;selectorRanges.isEmpty())
+        m_currentRuleDataStack.last()-&gt;selectorRanges.last().end = listEndOffset;
+}
+
+void StyleSheetHandler::endRuleHeader(unsigned offset)
+{
+    ASSERT(!m_currentRuleDataStack.isEmpty());
+    
+    if (m_parsedText.is8Bit())
+        setRuleHeaderEnd&lt;LChar&gt;(m_parsedText.characters8(), offset);
+    else
+        setRuleHeaderEnd&lt;UChar&gt;(m_parsedText.characters16(), offset);
+}
+
+void StyleSheetHandler::observeSelector(unsigned startOffset, unsigned endOffset)
+{
+    ASSERT(m_currentRuleDataStack.size());
+    m_currentRuleDataStack.last()-&gt;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()-&gt;ruleBodyRange.start = offset;
+}
+
+void StyleSheetHandler::endRuleBody(unsigned offset)
+{
+    ASSERT(!m_currentRuleDataStack.isEmpty());
+    m_currentRuleDataStack.last()-&gt;ruleBodyRange.end = offset;
+    auto rule = popRuleData();
+    fixUnparsedPropertyRanges(rule.ptr());
+    if (m_currentRuleDataStack.isEmpty())
+        m_ruleSourceDataResult-&gt;append(WTFMove(rule));
+    else
+        m_currentRuleDataStack.last()-&gt;childRules.append(WTFMove(rule));
+}
+
+Ref&lt;CSSRuleSourceData&gt; StyleSheetHandler::popRuleData()
+{
+    ASSERT(!m_currentRuleDataStack.isEmpty());
+    m_currentRuleData = nullptr;
+    auto data = WTFMove(m_currentRuleDataStack.last());
+    m_currentRuleDataStack.removeLast();
+    return data;
+}
+
+template &lt;typename CharacterType&gt;
+static inline void fixUnparsedProperties(const CharacterType* characters, CSSRuleSourceData* ruleData)
+{
+    Vector&lt;CSSPropertySourceData&gt;&amp; propertyData = ruleData-&gt;styleSourceData-&gt;propertyData;
+    unsigned size = propertyData.size();
+    if (!size)
+        return;
+    
+    unsigned styleStart = ruleData-&gt;ruleBodyRange.start;
+    
+    CSSPropertySourceData* nextData = &amp;(propertyData.at(0));
+    for (unsigned i = 0; i &lt; size; ++i) {
+        CSSPropertySourceData* currentData = nextData;
+        nextData = i &lt; size - 1 ? &amp;(propertyData.at(i + 1)) : nullptr;
+        
+        if (currentData-&gt;parsedOk)
+            continue;
+        if (currentData-&gt;range.end &gt; 0 &amp;&amp; characters[styleStart + currentData-&gt;range.end - 1] == ';')
+            continue;
+        
+        unsigned propertyEnd;
+        if (!nextData)
+            propertyEnd = ruleData-&gt;ruleBodyRange.end - 1;
+        else
+            propertyEnd = styleStart + nextData-&gt;range.start - 1;
+        
+        while (isHTMLSpace&lt;CharacterType&gt;(characters[propertyEnd]))
+            --propertyEnd;
+        
+        // propertyEnd points at the last property text character.
+        unsigned newPropertyEnd = propertyEnd + styleStart + 1;
+        if (currentData-&gt;range.end != newPropertyEnd) {
+            currentData-&gt;range.end = newPropertyEnd;
+            unsigned valueStart = styleStart + currentData-&gt;range.start + currentData-&gt;name.length();
+            while (valueStart &lt; propertyEnd &amp;&amp; characters[valueStart] != ':')
+                ++valueStart;
+            
+            // Shift past the ':'.
+            if (valueStart &lt; propertyEnd)
+                ++valueStart;
+
+            while (valueStart &lt; propertyEnd &amp;&amp; isHTMLSpace&lt;CharacterType&gt;(characters[valueStart]))
+                ++valueStart;
+            
+            // Need to exclude the trailing ';' from the property value.
+            currentData-&gt;value = String(characters + valueStart, propertyEnd - valueStart + (characters[propertyEnd] == ';' ? 0 : 1));
+        }
+    }
+}
+
+void StyleSheetHandler::fixUnparsedPropertyRanges(CSSRuleSourceData* ruleData)
+{
+    if (!ruleData-&gt;styleSourceData)
+        return;
+    
+    if (m_parsedText.is8Bit()) {
+        fixUnparsedProperties&lt;LChar&gt;(m_parsedText.characters8(), ruleData);
+        return;
+    }
+    
+    fixUnparsedProperties&lt;UChar&gt;(m_parsedText.characters16(), ruleData);
+}
+
+void StyleSheetHandler::observeProperty(unsigned startOffset, unsigned endOffset, bool isImportant, bool isParsed)
+{
+    if (m_currentRuleDataStack.isEmpty() || !m_currentRuleDataStack.last()-&gt;styleSourceData)
+        return;
+    
+    ASSERT(endOffset &lt;= m_parsedText.length());
+    
+    // Include semicolon in the property text.
+    if (endOffset &lt; m_parsedText.length() &amp;&amp; m_parsedText[endOffset] == ';')
+        ++endOffset;
+    
+    ASSERT(startOffset &lt; 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&amp; topRuleBodyRange = m_currentRuleDataStack.last()-&gt;ruleBodyRange;
+    m_currentRuleDataStack.last()-&gt;styleSourceData-&gt;propertyData.append(CSSPropertySourceData(name, value, isImportant, false, isParsed, SourceRange(startOffset - topRuleBodyRange.start, endOffset - topRuleBodyRange.start)));
+}
+
+void StyleSheetHandler::observeComment(unsigned startOffset, unsigned endOffset)
+{
+    ASSERT(endOffset &lt;= m_parsedText.length());
+
+    if (m_currentRuleDataStack.isEmpty() || !m_currentRuleDataStack.last()-&gt;ruleHeaderRange.end || !m_currentRuleDataStack.last()-&gt;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(&quot;/*&quot;));
+    commentText = commentText.substring(2);
+    
+    // Require well-formed comments.
+    if (!commentText.endsWith(&quot;*/&quot;))
+        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, &amp;sourceData);
+    CSSParser::parseDeclarationForInspector(parserContextForDocument(m_document), commentText, handler);
+    Vector&lt;CSSPropertySourceData&gt;&amp; commentPropertyData = sourceData.first()-&gt;styleSourceData-&gt;propertyData;
+    if (commentPropertyData.size() != 1)
+        return;
+    CSSPropertySourceData&amp; propertyData = commentPropertyData.at(0);
+    bool parsedOk = propertyData.parsedOk || propertyData.name.startsWith(&quot;-moz-&quot;) || propertyData.name.startsWith(&quot;-o-&quot;) || propertyData.name.startsWith(&quot;-webkit-&quot;) || propertyData.name.startsWith(&quot;-ms-&quot;);
+    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&amp; topRuleBodyRange = m_currentRuleDataStack.last()-&gt;ruleBodyRange;
+    m_currentRuleDataStack.last()-&gt;styleSourceData-&gt;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&lt;CSSParser&gt; createCSSParser(Document* document)
-{
-    return std::make_unique&lt;CSSParser&gt;(document ? CSSParserContext(*document) : strictCSSParserContext());
-}
-
</del><span class="cx"> Ref&lt;InspectorStyle&gt; InspectorStyle::create(const InspectorCSSId&amp; styleId, RefPtr&lt;CSSStyleDeclaration&gt;&amp;&amp; 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&amp; 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-&gt;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-&gt;length(); i &lt; size; ++i) {
</span><span class="cx">         String name = m_style-&gt;item(i);
</span><span class="cx">         if (sourcePropertyNames.add(lowercasePropertyName(name)))
</span><del>-            result-&gt;append(InspectorStyleProperty(CSSPropertySourceData(name, m_style-&gt;getPropertyValue(name), !m_style-&gt;getPropertyPriority(name).isEmpty(), true, SourceRange()), false, false));
</del><ins>+            result-&gt;append(InspectorStyleProperty(CSSPropertySourceData(name, m_style-&gt;getPropertyValue(name), !m_style-&gt;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&amp; selector, Document* document)
</span><span class="cx"> {
</span><span class="cx">     CSSSelectorList selectorList;
</span><del>-    createCSSParser(document)-&gt;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&lt;StyleSheetContents&gt; newStyleSheet = StyleSheetContents::create();
</span><span class="cx">     auto ruleSourceDataResult = std::make_unique&lt;RuleSourceDataList&gt;();
</span><del>-    createCSSParser(m_pageStyleSheet-&gt;ownerDocument())-&gt;parseSheet(newStyleSheet.get(), m_parsedStyleSheet-&gt;text(), TextPosition(), ruleSourceDataResult.get(), false);
</del><ins>+    
+    CSSParserContext context(parserContextForDocument(m_pageStyleSheet-&gt;ownerDocument()));
+    if (context.useNewParser) {
+        StyleSheetHandler handler(m_parsedStyleSheet-&gt;text(), m_pageStyleSheet-&gt;ownerDocument(), ruleSourceDataResult.get());
+        CSSParser::parseSheetForInspector(context, newStyleSheet.get(), m_parsedStyleSheet-&gt;text(), handler);
+    } else
+        CSSParser(context).parseSheet(newStyleSheet.get(), m_parsedStyleSheet-&gt;text(), TextPosition(), ruleSourceDataResult.get(), false);
</ins><span class="cx">     m_parsedStyleSheet-&gt;setSourceData(WTFMove(ruleSourceDataResult));
</span><span class="cx">     return m_parsedStyleSheet-&gt;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-&gt;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-&gt;getAttribute(&quot;style&quot;).string();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool InspectorStyleSheetForInlineStyle::getStyleAttributeRanges(CSSRuleSourceData* result) const
</del><ins>+Ref&lt;CSSRuleSourceData&gt; InspectorStyleSheetForInlineStyle::ruleSourceData() const
</ins><span class="cx"> {
</span><del>-    if (!m_element-&gt;isStyledElement())
-        return false;
-
</del><span class="cx">     if (m_styleText.isEmpty()) {
</span><ins>+        auto result = CSSRuleSourceData::create(StyleRule::Style);
</ins><span class="cx">         result-&gt;ruleBodyRange.start = 0;
</span><span class="cx">         result-&gt;ruleBodyRange.end = 0;
</span><del>-        return true;
</del><ins>+        return result;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    CSSParserContext context(parserContextForDocument(&amp;m_element-&gt;document()));
+    if (context.useNewParser) {
+        RuleSourceDataList ruleSourceDataResult;
+        StyleSheetHandler handler(m_styleText, &amp;m_element-&gt;document(), &amp;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(&amp;m_element-&gt;document())-&gt;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&amp; elementStyleText() const;
</span><del>-    bool getStyleAttributeRanges(CSSRuleSourceData* result) const;
</del><ins>+    Ref&lt;CSSRuleSourceData&gt; ruleSourceData() const;
</ins><span class="cx"> 
</span><span class="cx">     RefPtr&lt;Element&gt; m_element;
</span><span class="cx">     RefPtr&lt;CSSRuleSourceData&gt; m_ruleSourceData;
</span></span></pre>
</div>
</div>

</body>
</html>