[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

apavlov at chromium.org apavlov at chromium.org
Wed Dec 22 13:30:07 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 12706417cd5b5d7dfb6c184c4e3044f74789fd82
Author: apavlov at chromium.org <apavlov at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Sep 17 14:37:27 2010 +0000

    2010-09-15  Alexander Pavlov  <apavlov at chromium.org>
    
            Reviewed by Pavel Feldman.
    
            Provide source-based properties for style declarations to CSSParser clients
    
            This change:
            - Enables InspectorCSSStore to extract CSS stylesheet text for all source-based stylesheets,
              even with the resource tracking turned off.
            - Adds to CSSParser a capability of source-related style declaration data extraction:
              * Start/end source offsets for a declaration, relative to the parent stylesheet start or the "style" attribute value.
              * Start/end source offsets for CSS properties, relative to the declaration start.
              * CSS property data: name, value, priority, WebCore parsability (i.e. if the property is understood by WebCore).
            - Provides the extracted data to the WebInspector frontend via InspectorDOMAgent::getStyleSourceData().
            https://bugs.webkit.org/show_bug.cgi?id=44949
    
            WebCore:
            * WebCore.gypi:
            * WebCore.pro:
            * WebCore.vcproj/WebCore.vcproj:
            * WebCore.xcodeproj/project.pbxproj:
            * css/CSSGrammar.y:
            * css/CSSMutableStyleDeclaration.h:
            (WebCore::CSSMutableStyleDeclaration::node):
            * css/CSSParser.cpp:
            (WebCore::CSSParser::CSSParser):
            (WebCore::CSSParser::parseSheet):
            (WebCore::CSSParser::parseDeclaration):
            (WebCore::CSSParser::createStyleRule):
            (WebCore::CSSParser::markRuleBodyStart):
            (WebCore::CSSParser::markPropertyStart):
            (WebCore::CSSParser::markPropertyEnd):
            * css/CSSParser.h:
            (WebCore::CSSParser::resetPropertyMarks):
            * css/CSSPropertySourceData.cpp: Added.
            (WebCore::SourceRange::SourceRange):
            (WebCore::SourceRange::operator=):
            (WebCore::CSSPropertySourceData::CSSPropertySourceData):
            (WebCore::CSSPropertySourceData::operator=):
            (WebCore::CSSPropertySourceData::toString):
            (WebCore::CSSPropertySourceData::hash):
            (WebCore::CSSPropertySourceData::init):
            * css/CSSPropertySourceData.h: Added.
            (WebCore::CSSPropertySourceData::~CSSPropertySourceData):
            (WebCore::CSSStyleSourceData::create):
            * inspector/Inspector.idl:
            * inspector/InspectorCSSStore.cpp:
            (WebCore::InspectorCSSStore::reset):
            (WebCore::InspectorCSSStore::styleSheetText):
            (WebCore::InspectorCSSStore::resourceStyleSheetText):
            (WebCore::InspectorCSSStore::inlineStyleSheetText):
            (WebCore::InspectorCSSStore::getStyleSourceData):
            (WebCore::InspectorCSSStore::extractRanges):
            (WebCore::InspectorCSSStore::getStyleAttributeRanges):
            (WebCore::InspectorCSSStore::getParentStyleSheet):
            (WebCore::InspectorCSSStore::inlineStyleElement):
            * inspector/InspectorCSSStore.h:
            * inspector/InspectorController.cpp:
            (WebCore::InspectorController::resourceContentForURL):
            * inspector/InspectorController.h:
            * inspector/InspectorDOMAgent.cpp:
            (WebCore::InspectorDOMAgent::getStyleSourceData):
            (WebCore::InspectorDOMAgent::buildObjectForStyle):
            * inspector/InspectorDOMAgent.h:
    
            LayoutTests:
            * inspector/resources/styles-source-offsets.css:
            (body):
            (/* comment before selector */body.main1/* comment after selector */):
            (body.main2):
            * inspector/styles-source-offsets-expected.txt:
            * inspector/styles-source-offsets.html:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67704 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 32e1d0d..b8eb320 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,17 @@
+2010-09-15  Alexander Pavlov  <apavlov at chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Provide source-based properties for style declarations to CSSParser clients
+        https://bugs.webkit.org/show_bug.cgi?id=44949
+
+        * inspector/resources/styles-source-offsets.css:
+        (body):
+        (/* comment before selector */body.main1/* comment after selector */):
+        (body.main2):
+        * inspector/styles-source-offsets-expected.txt:
+        * inspector/styles-source-offsets.html:
+
 2010-09-17  Alejandro G. Castro  <alex at igalia.com>
 
         Unreviewed, GTK+ rebaselines.
diff --git a/LayoutTests/inspector/resources/styles-source-offsets.css b/LayoutTests/inspector/resources/styles-source-offsets.css
index ef69ee6..45210e3 100644
--- a/LayoutTests/inspector/resources/styles-source-offsets.css
+++ b/LayoutTests/inspector/resources/styles-source-offsets.css
@@ -1,7 +1,14 @@
 body {
     font-size: 12px;
+    foo: bar !
+
+    important /* !important property not recognized by WebCore */;
+    height: 100% !important;
+    colorz: "!important";
+    important:!important;
+    color: "badcolor" ! important /* good property with strange value */;
 }
 
-/* comment before selector */body.main1/* comment after selector */{/* comment */color: #000;}/* comment */
+/* comment before selector */body.main1/* comment after selector */{/* comment */color: #F00BAA;zoo:moo /* not an !important unrecognized property */}/* comment */
 
-body.main2{background: green;}
+body.main2{background: green /* value !important comment */ !important /* no semicolon, very !important */}
diff --git a/LayoutTests/inspector/styles-source-offsets-expected.txt b/LayoutTests/inspector/styles-source-offsets-expected.txt
index dda67ad..e4d33d8 100644
--- a/LayoutTests/inspector/styles-source-offsets-expected.txt
+++ b/LayoutTests/inspector/styles-source-offsets-expected.txt
@@ -1,7 +1,23 @@
-Tests that proper start/end offset positions are reported for CSS rule bodies.
+Tests that proper data and start/end offset positions are reported for CSS style declarations and properties.
 
-body: [5-28]
-body.main1: [98-124]
-body.main2: [150-169]
-body {&    font-size: 12px;&}&&/* comment before selector */body.main1/* comment after selector */{/* comment */color: #000;}/* comment */&&body.main2{background: green;}&
+body: [6-266]
+['font-size':'12px'] @[5-21]
+['foo':'bar !
+
+    important /* !important property not recognized by WebCore */' !important non-parsed] @[26-104]
+['height':'100% !important' !important] @[109-133]
+['colorz':'"!important"' non-parsed] @[138-159]
+['important':'' non-parsed] @[164-174]
+['color':'"badcolor" ! important /* good property with strange value */' !important] @[190-259]
+body.main1: [337-418]
+['color':'#F00BAA'] @[13-28]
+['zoo':'moo /* not an !important unrecognized property */' non-parsed] @[28-81]
+body.main2: [445-540]
+['background':'green /* value !important comment */ !important /* no semicolon, very !important */' !important] @[0-95]
+body.mainpage: [17-149]
+['text-decoration':'none'] @[5-27]
+['badproperty':'1badvalue1' non-parsed] @[107-131]
+element.style: [0-31]
+['font-weight':'normal'] @[0-20]
+['width':'80%'] @[21-31]
 
diff --git a/LayoutTests/inspector/styles-source-offsets.html b/LayoutTests/inspector/styles-source-offsets.html
index d840f43..fcf928f 100644
--- a/LayoutTests/inspector/styles-source-offsets.html
+++ b/LayoutTests/inspector/styles-source-offsets.html
@@ -35,55 +35,43 @@ function frontend_runTest(testController)
         function stylesCallback(testController, styles)
         {
             var matchedCSSRules = styles.matchedCSSRules;
-            var parentStyleSheetId = matchedCSSRules[0].style.parentStyleSheetId;
-            if (!parentStyleSheetId) {
-                testController.results.push("BAD STYLESHEET ID: " + parentStyleSheetId);
-                testController.notifyDone(testController.results);
-                return;
+            for (var i = 0; i < matchedCSSRules.length; ++i) {
+                var rule = matchedCSSRules[i];
+                InspectorBackend.getStyleSourceData(rule.style.id, frontend_styleDataReceived.bind(null, testController, rule, false));
             }
-            InspectorBackend.getRuleRanges(parentStyleSheetId, frontend_ruleRangesReceived.bind(null, testController, parentStyleSheetId, matchedCSSRules));
+            InspectorBackend.getStyleSourceData(styles.inlineStyle.id, frontend_styleDataReceived.bind(null, testController, styles.inlineStyle, true));
         }
         InspectorBackend.getStyles(WebInspector.domAgent.document.body.id, true, stylesCallback.bind(null, testController));
     });
 }
 
-function frontend_ruleRangesReceived(testController, styleSheetId, matchedCSSRules, ruleRanges)
+function frontend_styleDataReceived(testController, ruleOrStyle, shouldBail, data)
 {
-    for (var i = 0; i < matchedCSSRules.length; ++i) {
-        var rule = matchedCSSRules[i];
-        testController.results.push(rule.selectorText + ": [" + ruleRanges[rule.style.id].bodyRange.start + "-" + ruleRanges[rule.style.id].bodyRange.end + "]");
+    var isRule = !!(ruleOrStyle.style);
+    testController.results.push((isRule ? ruleOrStyle.selectorText : "element.style") + ": [" + data.bodyRange.start + "-" + data.bodyRange.end + "]");
+    for (var i = 0; i < data.propertyData.length; ++i) {
+        var propertyDatum = data.propertyData[i];
+        testController.results.push("['" + propertyDatum.name + "':'" + propertyDatum.value + "'" + (propertyDatum.important ? " !important" : "") + (propertyDatum.parsed ? "" : " non-parsed") +"] @[" + propertyDatum.start + "-" + propertyDatum.end + "]");
     }
-    InspectorBackend.getStyleSheet(styleSheetId, frontend_handleStyleSheet.bind(null, testController));
-}
-
-function frontend_handleStyleSheet(testController, styleSheet)
-{
-    var url = styleSheet.href;
-    if (url !== "") {
-        var resource = WebInspector.resourceURLMap[url];
-        if (!resource) {
-            testController.results.push("NO RESOURCE FOR URL: " + url);
-            testController.notifyDone(testController.results);
-            return;
-        }
-        WebInspector.getResourceContent(resource.identifier, frontend_styleSheetTextReceived.bind(null, testController));
-    } else {
-        testController.results.push("EMPTY STYLESHEET HREF");
+    if (shouldBail)
         testController.notifyDone(testController.results);
-    }
 }
 
-function frontend_styleSheetTextReceived(testController, styleSheetText)
-{
-    testController.results.push(styleSheetText.replace(/\n/g, "&"));
-    testController.notifyDone(testController.results);
-}
 </script>
+
+<style>
+
+body.mainpage {
+    text-decoration: none; /* at least one valid property is necessary for WebCore to match a rule */
+    badproperty: 1badvalue1;
+}
+
+</style>
 </head>
 
-<body class="main1 main2" onload="onload()">
+<body class="main1 main2 mainpage" onload="onload()" style="font-weight: normal; width: 80%">
 <p>
-Tests that proper start/end offset positions are reported for CSS rule bodies.
+Tests that proper data and start/end offset positions are reported for CSS style declarations and properties.
 </p>
 
 </body>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 9bae248..22035e7 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,67 @@
+2010-09-15  Alexander Pavlov  <apavlov at chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Provide source-based properties for style declarations to CSSParser clients
+
+        This change:
+        - Enables InspectorCSSStore to extract CSS stylesheet text for all source-based stylesheets,
+          even with the resource tracking turned off.
+        - Adds to CSSParser a capability of source-related style declaration data extraction:
+          * Start/end source offsets for a declaration, relative to the parent stylesheet start or the "style" attribute value.
+          * Start/end source offsets for CSS properties, relative to the declaration start.
+          * CSS property data: name, value, priority, WebCore parsability (i.e. if the property is understood by WebCore).
+        - Provides the extracted data to the WebInspector frontend via InspectorDOMAgent::getStyleSourceData().
+        https://bugs.webkit.org/show_bug.cgi?id=44949
+
+        * WebCore.gypi:
+        * WebCore.pro:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * css/CSSGrammar.y:
+        * css/CSSMutableStyleDeclaration.h:
+        (WebCore::CSSMutableStyleDeclaration::node):
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::CSSParser):
+        (WebCore::CSSParser::parseSheet):
+        (WebCore::CSSParser::parseDeclaration):
+        (WebCore::CSSParser::createStyleRule):
+        (WebCore::CSSParser::markRuleBodyStart):
+        (WebCore::CSSParser::markPropertyStart):
+        (WebCore::CSSParser::markPropertyEnd):
+        * css/CSSParser.h:
+        (WebCore::CSSParser::resetPropertyMarks):
+        * css/CSSPropertySourceData.cpp: Added.
+        (WebCore::SourceRange::SourceRange):
+        (WebCore::SourceRange::operator=):
+        (WebCore::CSSPropertySourceData::CSSPropertySourceData):
+        (WebCore::CSSPropertySourceData::operator=):
+        (WebCore::CSSPropertySourceData::toString):
+        (WebCore::CSSPropertySourceData::hash):
+        (WebCore::CSSPropertySourceData::init):
+        * css/CSSPropertySourceData.h: Added.
+        (WebCore::CSSPropertySourceData::~CSSPropertySourceData):
+        (WebCore::CSSStyleSourceData::create):
+        * inspector/Inspector.idl:
+        * inspector/InspectorCSSStore.cpp:
+        (WebCore::InspectorCSSStore::reset):
+        (WebCore::InspectorCSSStore::styleSheetText):
+        (WebCore::InspectorCSSStore::resourceStyleSheetText):
+        (WebCore::InspectorCSSStore::inlineStyleSheetText):
+        (WebCore::InspectorCSSStore::getStyleSourceData):
+        (WebCore::InspectorCSSStore::extractRanges):
+        (WebCore::InspectorCSSStore::getStyleAttributeRanges):
+        (WebCore::InspectorCSSStore::getParentStyleSheet):
+        (WebCore::InspectorCSSStore::inlineStyleElement):
+        * inspector/InspectorCSSStore.h:
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::resourceContentForURL):
+        * inspector/InspectorController.h:
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::getStyleSourceData):
+        (WebCore::InspectorDOMAgent::buildObjectForStyle):
+        * inspector/InspectorDOMAgent.h:
+
 2010-09-17  Alexander Pavlov  <apavlov at chromium.org>
 
         Reviewed by Pavel Feldman.
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index 123b8ed..1ded06f 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -1010,6 +1010,8 @@
             'css/CSSProperty.h',
             'css/CSSPropertyLonghand.cpp',
             'css/CSSPropertyLonghand.h',
+            'css/CSSPropertySourceData.cpp',
+            'css/CSSPropertySourceData.h',
             'css/CSSQuirkPrimitiveValue.h',
             'css/CSSReflectValue.cpp',
             'css/CSSReflectValue.h',
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index b4051b1..8998355 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -629,6 +629,7 @@ SOURCES += \
     css/CSSPrimitiveValue.cpp \
     css/CSSProperty.cpp \
     css/CSSPropertyLonghand.cpp \
+    css/CSSPropertySourceData.cpp \
     css/CSSReflectValue.cpp \
     css/CSSRule.cpp \
     css/CSSRuleList.cpp \
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index 5b7da6e..0c360ce 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -29405,6 +29405,14 @@
 				>
 			</File>
 			<File
+				RelativePath="..\css\CSSPropertySourceData.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\css\CSSPropertySourceData.h"
+				>
+			</File>
+			<File
 				RelativePath="..\css\CSSQuirkPrimitiveValue.h"
 				>
 			</File>
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index 0eda462..1d91ed7 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -1453,6 +1453,8 @@
 		81BE20D311F4BC3200915DFA /* JSIDBCursor.h in Headers */ = {isa = PBXBuildFile; fileRef = 81BE20A811F4B66F00915DFA /* JSIDBCursor.h */; };
 		82B658981189E39200E052A1 /* InspectorCSSStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 82B658971189E39200E052A1 /* InspectorCSSStore.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		82B6589A1189E47600E052A1 /* InspectorCSSStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 82B658991189E47600E052A1 /* InspectorCSSStore.cpp */; };
+		82E3D8DE122EA0D1003AE5BC /* CSSPropertySourceData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 82E3D8DC122EA0D1003AE5BC /* CSSPropertySourceData.cpp */; };
+		82E3D8DF122EA0D1003AE5BC /* CSSPropertySourceData.h in Headers */ = {isa = PBXBuildFile; fileRef = 82E3D8DD122EA0D1003AE5BC /* CSSPropertySourceData.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		8419D2A7120D92D000141F8F /* SVGPathByteStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 8419D2A4120D92D000141F8F /* SVGPathByteStream.h */; };
 		8419D2A8120D92D000141F8F /* SVGPathByteStreamBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8419D2A5120D92D000141F8F /* SVGPathByteStreamBuilder.cpp */; };
 		8419D2A9120D92D000141F8F /* SVGPathByteStreamBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 8419D2A6120D92D000141F8F /* SVGPathByteStreamBuilder.h */; };
@@ -7409,6 +7411,8 @@
 		81BE20A811F4B66F00915DFA /* JSIDBCursor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSIDBCursor.h; sourceTree = "<group>"; };
 		82B658971189E39200E052A1 /* InspectorCSSStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorCSSStore.h; sourceTree = "<group>"; };
 		82B658991189E47600E052A1 /* InspectorCSSStore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorCSSStore.cpp; sourceTree = "<group>"; };
+		82E3D8DC122EA0D1003AE5BC /* CSSPropertySourceData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSPropertySourceData.cpp; sourceTree = "<group>"; };
+		82E3D8DD122EA0D1003AE5BC /* CSSPropertySourceData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSPropertySourceData.h; sourceTree = "<group>"; };
 		8419D2A4120D92D000141F8F /* SVGPathByteStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPathByteStream.h; sourceTree = "<group>"; };
 		8419D2A5120D92D000141F8F /* SVGPathByteStreamBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGPathByteStreamBuilder.cpp; sourceTree = "<group>"; };
 		8419D2A6120D92D000141F8F /* SVGPathByteStreamBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPathByteStreamBuilder.h; sourceTree = "<group>"; };
@@ -17063,6 +17067,8 @@
 				0F6ECD440F252F3700BDE271 /* CSSPropertyLonghand.cpp */,
 				0F6ECD430F252F3700BDE271 /* CSSPropertyLonghand.h */,
 				BCEA4789097CAAC80094C9E4 /* CSSPropertyNames.in */,
+				82E3D8DC122EA0D1003AE5BC /* CSSPropertySourceData.cpp */,
+				82E3D8DD122EA0D1003AE5BC /* CSSPropertySourceData.h */,
 				A80E6CC00A1989CA007FB8C5 /* CSSQuirkPrimitiveValue.h */,
 				9362640A0DE1137D009D5A00 /* CSSReflectionDirection.h */,
 				BC5A12DD0DC0414800C9AFAD /* CSSReflectValue.cpp */,
@@ -20560,6 +20566,7 @@
 				893C47A81238908B002B3D86 /* FileWriterCallback.h in Headers */,
 				893C47B81238A099002B3D86 /* JSFileCallback.h in Headers */,
 				893C47BC1238A0A9002B3D86 /* JSFileWriterCallback.h in Headers */,
+				82E3D8DF122EA0D1003AE5BC /* CSSPropertySourceData.h in Headers */,
 				8A309C9F123950BE00CB9204 /* NestingLevelIncrementer.h in Headers */,
 				93E2A307123E9DC0009FE12A /* HTMLParserIdioms.h in Headers */,
 			);
@@ -23036,6 +23043,7 @@
 				A622A8FC122C44A600A785B3 /* BindingSecurityBase.cpp in Sources */,
 				893C47B71238A099002B3D86 /* JSFileCallback.cpp in Sources */,
 				893C47BB1238A0A9002B3D86 /* JSFileWriterCallback.cpp in Sources */,
+				82E3D8DE122EA0D1003AE5BC /* CSSPropertySourceData.cpp in Sources */,
 				93E2A306123E9DC0009FE12A /* HTMLParserIdioms.cpp in Sources */,
 				893C47DF123EF4A9002B3D86 /* JSDirectoryEntryCustom.cpp in Sources */,
 				893C47CC123EEBA2002B3D86 /* JSEntryCustom.cpp in Sources */,
diff --git a/WebCore/css/CSSGrammar.y b/WebCore/css/CSSGrammar.y
index 86a2f7c..c55f998 100644
--- a/WebCore/css/CSSGrammar.y
+++ b/WebCore/css/CSSGrammar.y
@@ -314,7 +314,7 @@ webkit_keyframe_rule:
 ;
 
 webkit_decls:
-    WEBKIT_DECLS_SYM '{' maybe_space declaration_list '}' {
+    WEBKIT_DECLS_SYM '{' maybe_space_before_declaration declaration_list '}' {
         /* can be empty */
     }
 ;
@@ -903,8 +903,15 @@ unary_operator:
   | '+' { $$ = 1; }
   ;
 
+maybe_space_before_declaration:
+    maybe_space {
+        CSSParser* p = static_cast<CSSParser*>(parser);
+        p->markPropertyStart();
+    }
+  ;
+
 ruleset:
-    selector_list '{' maybe_space declaration_list closing_brace {
+    selector_list '{' maybe_space_before_declaration declaration_list closing_brace {
         CSSParser* p = static_cast<CSSParser*>(parser);
         $$ = p->createStyleRule($1);
     }
@@ -1355,6 +1362,8 @@ declaration_list:
 
 decl_list:
     declaration ';' maybe_space {
+        CSSParser* p = static_cast<CSSParser*>(parser);
+        p->markPropertyStart();
         $$ = $1;
     }
     | declaration invalid_block_list maybe_space {
@@ -1364,12 +1373,16 @@ decl_list:
         $$ = false;
     }
     | error ';' maybe_space {
+        CSSParser* p = static_cast<CSSParser*>(parser);
+        p->markPropertyStart();
         $$ = false;
     }
     | error invalid_block_list error ';' maybe_space {
         $$ = false;
     }
     | decl_list declaration ';' maybe_space {
+        CSSParser* p = static_cast<CSSParser*>(parser);
+        p->markPropertyStart();
         $$ = $1;
         if ($2)
             $$ = $2;
@@ -1386,15 +1399,21 @@ declaration:
     property ':' maybe_space expr prio {
         $$ = false;
         CSSParser* p = static_cast<CSSParser*>(parser);
+        bool isPropertyParsed = false;
         if ($1 && $4) {
             p->m_valueList = p->sinkFloatingValueList($4);
             int oldParsedProperties = p->m_numParsedProperties;
             $$ = p->parseValue($1, $5);
-            if (!$$)
+            if (!$$) {
+                if (static_cast<int>(p->m_numParsedProperties) == oldParsedProperties)
+                    isPropertyParsed = true;
                 p->rollbackLastProperties(p->m_numParsedProperties - oldParsedProperties);
+            } else
+                isPropertyParsed = true;
             delete p->m_valueList;
             p->m_valueList = 0;
         }
+        p->markPropertyEnd($5, isPropertyParsed);
     }
     |
     variable_reference maybe_space {
@@ -1417,11 +1436,15 @@ declaration:
         /* The default movable type template has letter-spacing: .none;  Handle this by looking for
         error tokens at the start of an expr, recover the expr and then treat as an error, cleaning
         up and deleting the shifted expr.  */
+        CSSParser* p = static_cast<CSSParser*>(parser);
+        p->markPropertyEnd(false, false);
         $$ = false;
     }
     |
     property ':' maybe_space expr prio error {
         /* When we encounter something like p {color: red !important fail;} we should drop the declaration */
+        CSSParser* p = static_cast<CSSParser*>(parser);
+        p->markPropertyEnd(false, false);
         $$ = false;
     }
     |
@@ -1432,11 +1455,15 @@ declaration:
     |
     property ':' maybe_space {
         /* div { font-family: } Just reduce away this property with no value. */
+        CSSParser* p = static_cast<CSSParser*>(parser);
+        p->markPropertyEnd(false, false);
         $$ = false;
     }
     |
     property ':' maybe_space error {
         /* if we come across rules with invalid values like this case: p { weight: *; }, just discard the rule */
+        CSSParser* p = static_cast<CSSParser*>(parser);
+        p->markPropertyEnd(false, false);
         $$ = false;
     }
     |
diff --git a/WebCore/css/CSSMutableStyleDeclaration.h b/WebCore/css/CSSMutableStyleDeclaration.h
index f7759f4..d629bcf 100644
--- a/WebCore/css/CSSMutableStyleDeclaration.h
+++ b/WebCore/css/CSSMutableStyleDeclaration.h
@@ -83,6 +83,8 @@ public:
 
     void setNode(Node* node) { m_node = node; }
 
+    Node* node() const { return m_node; }
+
     virtual bool isMutableStyleDeclaration() const { return true; }
 
     virtual String cssText() const;
diff --git a/WebCore/css/CSSParser.cpp b/WebCore/css/CSSParser.cpp
index c3c3149..11e8e6e 100644
--- a/WebCore/css/CSSParser.cpp
+++ b/WebCore/css/CSSParser.cpp
@@ -44,6 +44,7 @@
 #include "CSSPrimitiveValue.h"
 #include "CSSProperty.h"
 #include "CSSPropertyNames.h"
+#include "CSSPropertySourceData.h"
 #include "CSSQuirkPrimitiveValue.h"
 #include "CSSReflectValue.h"
 #include "CSSRuleList.h"
@@ -147,7 +148,10 @@ CSSParser::CSSParser(bool strictParsing)
     , m_defaultNamespace(starAtom)
     , m_ruleBodyStartOffset(0)
     , m_ruleBodyEndOffset(0)
-    , m_ruleRanges(0)
+    , m_propertyStartOffset(UINT_MAX)
+    , m_propertyEndOffset(UINT_MAX)
+    , m_ruleRangeMap(0)
+    , m_currentStyleData(0)
     , m_data(0)
     , yy_start(1)
     , m_lineNumber(0)
@@ -159,6 +163,7 @@ CSSParser::CSSParser(bool strictParsing)
 #if YYDEBUG > 0
     cssyydebug = 1;
 #endif
+    CSSPropertySourceData::init();
 }
 
 CSSParser::~CSSParser()
@@ -221,16 +226,19 @@ void CSSParser::setupParser(const char* prefix, const String& string, const char
     resetRuleBodyMarks();
 }
 
-void CSSParser::parseSheet(CSSStyleSheet* sheet, const String& string, int startLineNumber, StyleRuleRanges* ruleRangeMap)
+void CSSParser::parseSheet(CSSStyleSheet* sheet, const String& string, int startLineNumber, StyleRuleRangeMap* ruleRangeMap)
 {
     m_styleSheet = sheet;
     m_defaultNamespace = starAtom; // Reset the default namespace.
-    m_ruleRanges = ruleRangeMap;
+    m_ruleRangeMap = ruleRangeMap;
+    if (ruleRangeMap)
+        m_currentStyleData = CSSStyleSourceData::create();
 
     m_lineNumber = startLineNumber;
     setupParser("", string, "");
     cssyyparse(this);
-    m_ruleRanges = 0;
+    m_ruleRangeMap = 0;
+    m_currentStyleData = 0;
     m_rule = 0;
 }
 
@@ -327,10 +335,14 @@ void CSSParser::parseSelector(const String& string, Document* doc, CSSSelectorLi
     m_selectorListForParseSelector = 0;
 }
 
-bool CSSParser::parseDeclaration(CSSMutableStyleDeclaration* declaration, const String& string)
+bool CSSParser::parseDeclaration(CSSMutableStyleDeclaration* declaration, const String& string, CSSStyleSourceData* styleSourceData)
 {
+    // Length of the "@-webkit-decls{" prefix.
+    static const unsigned prefixLength = 15;
+
     ASSERT(!declaration->stylesheet() || declaration->stylesheet()->isCSSStyleSheet());
     m_styleSheet = static_cast<CSSStyleSheet*>(declaration->stylesheet());
+    m_currentStyleData = styleSourceData;
 
     setupParser("@-webkit-decls{", string, "} ");
     cssyyparse(this);
@@ -345,6 +357,17 @@ bool CSSParser::parseDeclaration(CSSMutableStyleDeclaration* declaration, const
         clearProperties();
     }
 
+    if (m_currentStyleData) {
+        m_currentStyleData->styleBodyRange.start = 0;
+        m_currentStyleData->styleBodyRange.end = string.length();
+        for (Vector<CSSPropertySourceData>::iterator it = m_currentStyleData->propertyData.begin(); it != m_currentStyleData->propertyData.end(); ++it) {
+            (*it).range.start -= prefixLength;
+            (*it).range.end -= prefixLength;
+        }
+    }
+
+    if (!m_ruleRangeMap)
+        m_currentStyleData = 0;
     return ok;
 }
 
@@ -5429,8 +5452,12 @@ CSSRule* CSSParser::createStyleRule(Vector<CSSSelector*>* selectors)
         rule->setDeclaration(CSSMutableStyleDeclaration::create(rule.get(), m_parsedProperties, m_numParsedProperties));
         result = rule.get();
         m_parsedStyleObjects.append(rule.release());
-        if (m_ruleRanges)
-            m_ruleRanges->set(result, std::pair<unsigned, unsigned>(m_ruleBodyStartOffset, m_ruleBodyEndOffset));
+        if (m_ruleRangeMap) {
+            ASSERT(m_currentStyleData);
+            m_currentStyleData->styleBodyRange = SourceRange(m_ruleBodyStartOffset, m_ruleBodyEndOffset);
+            m_ruleRangeMap->set(result, m_currentStyleData.release());
+            m_currentStyleData = CSSStyleSourceData::create();
+        }
     }
     resetRuleBodyMarks();
     clearProperties();
@@ -5683,7 +5710,9 @@ void CSSParser::updateLastSelectorLineAndPosition()
 void CSSParser::markRuleBodyStart()
 {
     unsigned offset = yytext - m_data;
-    if (!m_ruleBodyStartOffset || offset < m_ruleBodyStartOffset)
+    if (*yytext == '{')
+        ++offset; // Skip the rule body opening brace.
+    if (offset > m_ruleBodyStartOffset)
         m_ruleBodyStartOffset = offset;
 }
 
@@ -5694,6 +5723,39 @@ void CSSParser::markRuleBodyEnd()
         m_ruleBodyEndOffset = offset;
 }
 
+void CSSParser::markPropertyStart()
+{
+    unsigned offset = yytext - m_data;
+    m_propertyStartOffset = offset;
+}
+
+void CSSParser::markPropertyEnd(bool isImportantFound, bool isPropertyParsed)
+{
+    unsigned offset = yytext - m_data;
+    if (*yytext == ';') // Include semicolon into the property text.
+        ++offset;
+    m_propertyEndOffset = offset;
+    if (m_propertyStartOffset != UINT_MAX && m_currentStyleData) {
+        // This stuff is only executed when the style data retrieval is requested by client.
+        const unsigned start = m_propertyStartOffset;
+        const unsigned end = m_propertyEndOffset;
+        ASSERT(start < end);
+        String propertyString = String(m_data + start, end - start).stripWhiteSpace();
+        if (propertyString.endsWith(";", true))
+            propertyString = propertyString.left(propertyString.length() - 1);
+        Vector<String> propertyComponents;
+        size_t colonIndex = propertyString.find(":");
+        ASSERT(colonIndex != notFound);
+
+        String name = propertyString.left(colonIndex).stripWhiteSpace();
+        String value = propertyString.substring(colonIndex + 1, propertyString.length()).stripWhiteSpace();
+        // The property range is relative to the declaration start offset.
+        m_currentStyleData->propertyData.append(
+            CSSPropertySourceData(name, value, isImportantFound, isPropertyParsed, SourceRange(m_propertyStartOffset - m_ruleBodyStartOffset, m_propertyEndOffset - m_ruleBodyStartOffset)));
+    }
+    resetPropertyMarks();
+}
+
 static int cssPropertyID(const UChar* propertyName, unsigned length)
 {
     if (!length)
diff --git a/WebCore/css/CSSParser.h b/WebCore/css/CSSParser.h
index 47f0bed..f8b24df 100644
--- a/WebCore/css/CSSParser.h
+++ b/WebCore/css/CSSParser.h
@@ -25,6 +25,7 @@
 
 #include "Color.h"
 #include "CSSParserValues.h"
+#include "CSSPropertySourceData.h"
 #include "CSSSelectorList.h"
 #include "MediaQuery.h"
 #include <wtf/HashMap.h>
@@ -55,18 +56,16 @@ namespace WebCore {
 
     class CSSParser {
     public:
-        typedef HashMap<CSSStyleRule*, std::pair<unsigned, unsigned> > StyleRuleRanges;
-
         CSSParser(bool strictParsing = true);
         ~CSSParser();
 
-        void parseSheet(CSSStyleSheet*, const String&, int startLineNumber = 0, StyleRuleRanges* ruleRangeMap = 0);
+        void parseSheet(CSSStyleSheet*, const String&, int startLineNumber = 0, StyleRuleRangeMap* ruleRangeMap = 0);
         PassRefPtr<CSSRule> parseRule(CSSStyleSheet*, const String&);
         PassRefPtr<CSSRule> parseKeyframeRule(CSSStyleSheet*, const String&);
         bool parseValue(CSSMutableStyleDeclaration*, int propId, const String&, bool important);
         static bool parseColor(RGBA32& color, const String&, bool strict = false);
         bool parseColor(CSSMutableStyleDeclaration*, const String&);
-        bool parseDeclaration(CSSMutableStyleDeclaration*, const String&);
+        bool parseDeclaration(CSSMutableStyleDeclaration*, const String&, CSSStyleSourceData* styleSourceData = 0);
         bool parseMediaQuery(MediaList*, const String&);
 
         Document* document() const;
@@ -244,10 +243,16 @@ namespace WebCore {
         // tokenizer methods and data
         unsigned m_ruleBodyStartOffset;
         unsigned m_ruleBodyEndOffset;
-        StyleRuleRanges* m_ruleRanges;
+        unsigned m_propertyStartOffset;
+        unsigned m_propertyEndOffset;
+        StyleRuleRangeMap* m_ruleRangeMap;
+        RefPtr<CSSStyleSourceData> m_currentStyleData;
         void markRuleBodyStart();
         void markRuleBodyEnd();
+        void markPropertyStart();
+        void markPropertyEnd(bool isImportantFound, bool isPropertyParsed);
         void resetRuleBodyMarks() { m_ruleBodyStartOffset = m_ruleBodyEndOffset = 0; }
+        void resetPropertyMarks() { m_propertyStartOffset = m_propertyEndOffset = UINT_MAX; }
         int lex(void* yylval);
         int token() { return yyTok; }
         UChar* text(int* length);
diff --git a/WebCore/inspector/Inspector.idl b/WebCore/inspector/Inspector.idl
index 05c53ad..7dad9af 100644
--- a/WebCore/inspector/Inspector.idl
+++ b/WebCore/inspector/Inspector.idl
@@ -182,7 +182,7 @@ module core {
         [handler=DOM] void getInlineStyle(in long nodeId, out Value style);
         [handler=DOM] void getComputedStyle(in long nodeId, out Value style);
         [handler=DOM] void getStyleSheet(in long styleSheetId, out Object styleSheet);
-        [handler=DOM] void getRuleRanges(in long styleSheetId, out Value ranges);
+        [handler=DOM] void getStyleSourceData(in long styleSheetId, out Object styleSourceData);
         [handler=DOM] void applyStyleText(in long styleId, in String styleText, in String propertyName, out boolean success, out Value style, out Array changedProperties);
         [handler=DOM] void setStyleText(in long styleId, in String styleText, out boolean success);
         [handler=DOM] void setStyleProperty(in long styleId, in String name, in String value, out boolean success);
diff --git a/WebCore/inspector/InspectorCSSStore.cpp b/WebCore/inspector/InspectorCSSStore.cpp
index c2dc4f1..b019860 100644
--- a/WebCore/inspector/InspectorCSSStore.cpp
+++ b/WebCore/inspector/InspectorCSSStore.cpp
@@ -37,11 +37,18 @@
 #include "CSSStyleDeclaration.h"
 #include "CSSStyleRule.h"
 #include "CSSStyleSheet.h"
+#include "CachedResource.h"
+#include "DocumentLoader.h"
+#include "Element.h"
+#include "Frame.h"
 #include "HTMLHeadElement.h"
 #include "InspectorController.h"
 #include "InspectorResource.h"
+#include "Node.h"
 #include "PlatformString.h"
+#include "SharedBuffer.h"
 #include "StyleSheetList.h"
+#include "TextEncoding.h"
 
 namespace WebCore {
 
@@ -67,6 +74,7 @@ void InspectorCSSStore::reset()
     m_styleSheetToOffsets.clear();
     m_styleSheetToId.clear();
     m_idToStyleSheet.clear();
+    m_idToStyleSheetText.clear();
     m_idToDisabledStyle.clear();
     m_documentNodeToInspectorStyleSheetMap.clear();
 
@@ -104,48 +112,145 @@ CSSStyleSheet* InspectorCSSStore::inspectorStyleSheet(Document* ownerDocument, b
     return inspectorStyleSheet;
 }
 
-HashMap<long, SourceRange> InspectorCSSStore::getRuleRanges(CSSStyleSheet* styleSheet)
+String InspectorCSSStore::styleSheetText(long styleSheetId)
 {
+    IdToStyleSheetTextMap::iterator it = m_idToStyleSheetText.find(styleSheetId);
+    if (it != m_idToStyleSheetText.end())
+        return it->second;
+
+    CSSStyleSheet* styleSheet = styleSheetForId(styleSheetId);
+    if (!styleSheet)
+        return String();
+
+    String result;
+    bool success = false;
+    Node* ownerNode = styleSheet->ownerNode();
+    if (ownerNode && ownerNode->nodeType() == Node::ELEMENT_NODE) {
+        Element* ownerElement = static_cast<Element*>(ownerNode);
+        if (ownerElement->tagName().lower() == "style") {
+            result = inlineStyleSheetText(styleSheet);
+            success = true;
+        }
+    }
+    if (!success)
+        success = resourceStyleSheetText(styleSheet, &result);
+
+    if (success)
+        m_idToStyleSheetText.set(styleSheetId, result);
+    return result;
+}
+
+bool InspectorCSSStore::resourceStyleSheetText(CSSStyleSheet* styleSheet, String* result)
+{
+    return m_inspectorController->resourceContentForURL(styleSheet->finalURL(), styleSheet->document(), result);
+}
+
+String InspectorCSSStore::inlineStyleSheetText(CSSStyleSheet* styleSheet)
+{
+    Node* ownerNode = styleSheet->ownerNode();
+    if (!ownerNode || ownerNode->nodeType() != Node::ELEMENT_NODE || m_styleSheetToId.find(styleSheet) == m_styleSheetToId.end())
+        return String();
+    Element* ownerElement = static_cast<Element*>(ownerNode);
+    if (ownerElement->tagName().lower() != "style")
+        return String();
+    return ownerElement->innerText();
+}
+
+
+// All ranges are: [start; end) (start - inclusive, end - exclusive).
+bool InspectorCSSStore::getStyleSourceData(CSSStyleDeclaration* style, RefPtr<CSSStyleSourceData>* result)
+{
+    if (!style)
+        return false;
+
+    Element* element = inlineStyleElement(style);
+    if (element) {
+        // Inline: style="...".
+        RefPtr<CSSStyleSourceData> styleSourceData = CSSStyleSourceData::create();
+        bool success = getStyleAttributeRanges(element, &styleSourceData);
+        if (!success)
+            return false;
+        *result = styleSourceData;
+        return true;
+    }
+
+    CSSStyleSheet* styleSheet = getParentStyleSheet(style);
     if (!styleSheet)
-        return HashMap<long, SourceRange>();
-    RefPtr<CSSRuleList> originalRuleList = CSSRuleList::create(styleSheet, false);
+        return false;
+
+    Vector<RefPtr<CSSStyleSourceData> >* rangesVector = 0;
     StyleSheetToOffsetsMap::iterator it = m_styleSheetToOffsets.find(styleSheet);
-    Vector<SourceRange>* offsetVector = 0;
     if (it == m_styleSheetToOffsets.end()) {
-        InspectorResource* resource = m_inspectorController->resourceForURL(styleSheet->finalURL().string());
-        if (resource) {
-            offsetVector = new Vector<SourceRange>;
+        String text = styleSheetText(bindStyleSheet(styleSheet));
+        if (!text.isEmpty()) {
             RefPtr<CSSStyleSheet> newStyleSheet = CSSStyleSheet::create(styleSheet->ownerNode());
             CSSParser p;
-            CSSParser::StyleRuleRanges ruleRangeMap;
-            p.parseSheet(newStyleSheet.get(), resource->sourceString(), 0, &ruleRangeMap);
-            for (unsigned i = 0, length = newStyleSheet->length(); i < length; ++i) {
-                CSSStyleRule* rule = asCSSStyleRule(newStyleSheet->item(i));
-                if (!rule)
-                    continue;
-                HashMap<CSSStyleRule*, std::pair<unsigned, unsigned> >::iterator it = ruleRangeMap.find(rule);
-                if (it != ruleRangeMap.end())
-                    offsetVector->append(it->second);
-            }
-            m_styleSheetToOffsets.set(styleSheet, offsetVector);
+            StyleRuleRangeMap ruleRangeMap;
+            p.parseSheet(newStyleSheet.get(), text, 0, &ruleRangeMap);
+            rangesVector = new Vector<RefPtr<CSSStyleSourceData> >;
+            extractRanges(newStyleSheet.get(), ruleRangeMap, rangesVector);
+            m_styleSheetToOffsets.set(styleSheet, rangesVector);
         }
     } else
-        offsetVector = it->second;
-    if (!offsetVector)
-        return HashMap<long, SourceRange>();
+        rangesVector = it->second;
+    if (!rangesVector)
+        return false;
 
     unsigned ruleIndex = 0;
-    HashMap<long, SourceRange> result;
     for (unsigned i = 0, length = styleSheet->length(); i < length; ++i) {
-        ASSERT(ruleIndex < offsetVector->size());
         CSSStyleRule* rule = asCSSStyleRule(styleSheet->item(i));
         if (!rule)
             continue;
-        // This maps the style id to the rule body range.
-        result.set(bindStyle(rule->style()), offsetVector->at(ruleIndex));
+        if (rule->style() == style) {
+            ASSERT(ruleIndex < rangesVector->size());
+            *result = rangesVector->at(ruleIndex);
+            return true;
+        }
         ruleIndex++;
     }
-    return result;
+    return false;
+}
+
+void InspectorCSSStore::extractRanges(CSSStyleSheet* styleSheet, const StyleRuleRangeMap& ruleRangeMap, Vector<RefPtr<CSSStyleSourceData> >* rangesVector)
+{
+    for (unsigned i = 0, length = styleSheet->length(); i < length; ++i) {
+        CSSStyleRule* rule = asCSSStyleRule(styleSheet->item(i));
+        if (!rule)
+            continue;
+        StyleRuleRangeMap::const_iterator it = ruleRangeMap.find(rule);
+        if (it != ruleRangeMap.end())
+            rangesVector->append(it->second);
+    }
+}
+
+bool InspectorCSSStore::getStyleAttributeRanges(Node* node, RefPtr<CSSStyleSourceData>* result)
+{
+    if (!node || !node->isStyledElement())
+        return false;
+
+    String styleText = static_cast<StyledElement*>(node)->getAttribute("style");
+    if (styleText.isEmpty()) {
+        (*result)->styleBodyRange.start = 0;
+        (*result)->styleBodyRange.end = 0;
+        return true;
+    }
+
+    RefPtr<CSSMutableStyleDeclaration> tempDeclaration = CSSMutableStyleDeclaration::create();
+    CSSParser p;
+    p.parseDeclaration(tempDeclaration.get(), styleText, result->get());
+    return true;
+}
+
+CSSStyleSheet* InspectorCSSStore::getParentStyleSheet(CSSStyleDeclaration* style)
+{
+    if (!style)
+        return 0;
+
+    StyleSheet* styleSheet = style->stylesheet();
+    if (styleSheet && styleSheet->isCSSStyleSheet())
+        return static_cast<CSSStyleSheet*>(styleSheet);
+
+    return 0;
 }
 
 CSSStyleRule* InspectorCSSStore::asCSSStyleRule(StyleBase* styleBase)
@@ -217,6 +322,17 @@ long InspectorCSSStore::bindRule(CSSStyleRule* rule)
     return id;
 }
 
+// static
+Element* InspectorCSSStore::inlineStyleElement(CSSStyleDeclaration* style)
+{
+    if (!style || !style->isMutableStyleDeclaration())
+        return 0;
+    Node* node = static_cast<CSSMutableStyleDeclaration*>(style)->node();
+    if (!node || !node->isStyledElement() || static_cast<StyledElement*>(node)->getInlineStyleDecl() != style)
+        return 0;
+    return static_cast<Element*>(node);
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(INSPECTOR)
diff --git a/WebCore/inspector/InspectorCSSStore.h b/WebCore/inspector/InspectorCSSStore.h
index 82de622..9b329df 100644
--- a/WebCore/inspector/InspectorCSSStore.h
+++ b/WebCore/inspector/InspectorCSSStore.h
@@ -29,46 +29,54 @@
 #ifndef InspectorCSSStore_h
 #define InspectorCSSStore_h
 
+#include "CSSPropertySourceData.h"
+#include "Cache.h"
+
 #include <wtf/Forward.h>
 #include <wtf/HashMap.h>
 #include <wtf/RefPtr.h>
-#include <wtf/text/StringHash.h>
 
 namespace WebCore {
 
-class Document;
-class InspectorController;
 class CSSMutableStyleDeclaration;
 class CSSStyleDeclaration;
 class CSSRuleList;
 class CSSStyleRule;
 class CSSStyleSheet;
+class Document;
+class Element;
+class InspectorController;
+class Node;
 class StyleBase;
 
 typedef std::pair<String, String> PropertyValueAndPriority;
-typedef std::pair<unsigned, unsigned> SourceRange;
 typedef HashMap<String, PropertyValueAndPriority> DisabledStyleDeclaration;
 typedef HashMap<CSSStyleDeclaration*, long> StyleToIdMap;
 typedef HashMap<long, RefPtr<CSSStyleDeclaration> > IdToStyleMap;
 typedef HashMap<CSSStyleRule*, long> RuleToIdMap;
 typedef HashMap<long, RefPtr<CSSStyleRule> > IdToRuleMap;
-typedef HashMap<CSSStyleSheet*, Vector<SourceRange>* > StyleSheetToOffsetsMap;
+typedef HashMap<CSSStyleSheet*, Vector<RefPtr<CSSStyleSourceData> >* > StyleSheetToOffsetsMap;
 typedef HashMap<CSSStyleSheet*, long> StyleSheetToIdMap;
 typedef HashMap<long, RefPtr<CSSStyleSheet> > IdToStyleSheetMap;
+typedef HashMap<long, String> IdToStyleSheetTextMap;
 typedef HashMap<long, DisabledStyleDeclaration> IdToDisabledStyleMap;
 typedef HashMap<RefPtr<Document>, RefPtr<CSSStyleSheet> > DocumentToStyleSheetMap;
 
 class InspectorCSSStore {
 
 public:
+    static CSSStyleSheet* getParentStyleSheet(CSSStyleDeclaration*);
+    static Element* inlineStyleElement(CSSStyleDeclaration*);
+
     InspectorCSSStore(InspectorController* inspectorController);
     ~InspectorCSSStore();
     void reset();
-    HashMap<long, SourceRange> getRuleRanges(CSSStyleSheet*);
+    bool getStyleSourceData(CSSStyleDeclaration*, RefPtr<CSSStyleSourceData>* result);
     CSSStyleDeclaration* styleForId(long styleId);
     CSSStyleSheet* styleSheetForId(long styleSheetId);
     CSSStyleRule* ruleForId(long styleRuleId);
     DisabledStyleDeclaration* disabledStyleForId(long styleId, bool createIfAbsent);
+    String styleSheetText(long styleSheetId);
     CSSStyleSheet* inspectorStyleSheet(Document* ownerDocument, bool createIfAbsent);
     void removeDocument(Document*);
 
@@ -78,6 +86,10 @@ public:
 
 private:
     static CSSStyleRule* asCSSStyleRule(StyleBase*);
+    String inlineStyleSheetText(CSSStyleSheet*);
+    bool resourceStyleSheetText(CSSStyleSheet*, String* result);
+    void extractRanges(CSSStyleSheet*, const StyleRuleRangeMap&, Vector<RefPtr<CSSStyleSourceData> >* rangesVector);
+    bool getStyleAttributeRanges(Node* parentNode, RefPtr<CSSStyleSourceData>* result);
 
     StyleToIdMap m_styleToId;
     IdToStyleMap m_idToStyle;
@@ -85,8 +97,9 @@ private:
     IdToRuleMap m_idToRule;
     StyleSheetToOffsetsMap m_styleSheetToOffsets;
     StyleSheetToIdMap m_styleSheetToId;
-    IdToStyleSheetMap m_idToStyleSheet;
     IdToDisabledStyleMap m_idToDisabledStyle;
+    IdToStyleSheetMap m_idToStyleSheet;
+    IdToStyleSheetTextMap m_idToStyleSheetText;
     DocumentToStyleSheetMap m_documentNodeToInspectorStyleSheetMap;
 
     InspectorController* m_inspectorController;
diff --git a/WebCore/inspector/InspectorController.cpp b/WebCore/inspector/InspectorController.cpp
index d76ea12..070f34b 100644
--- a/WebCore/inspector/InspectorController.cpp
+++ b/WebCore/inspector/InspectorController.cpp
@@ -33,6 +33,7 @@
 #if ENABLE(INSPECTOR)
 
 #include "CachedResource.h"
+#include "CachedResourceLoader.h"
 #include "Chrome.h"
 #include "Console.h"
 #include "ConsoleMessage.h"
@@ -1989,6 +1990,49 @@ void InspectorController::getResourceContent(unsigned long identifier, String* c
     *content = resource ? resource->sourceString() : String();
 }
 
+bool InspectorController::resourceContentForURL(const KURL& url, Document* frameDocument, String* result)
+{
+    if (!frameDocument)
+        return false;
+
+    String textEncodingName;
+    RefPtr<SharedBuffer> buffer;
+    if (equalIgnoringFragmentIdentifier(url, frameDocument->frame()->loader()->documentLoader()->requestURL())) {
+        textEncodingName = frameDocument->inputEncoding();
+        buffer = frameDocument->frame()->loader()->provisionalDocumentLoader()->mainResourceData();
+    } else {
+        const String& urlString = url.string();
+        CachedResource* cachedResource = frameDocument->cachedResourceLoader()->cachedResource(urlString);
+        if (!cachedResource)
+            cachedResource = cache()->resourceForURL(urlString);
+
+        ASSERT(cachedResource); // FIXME(apavlov): This might be too aggressive.
+
+        bool isUnpurgeable = true;
+        if (cachedResource->isPurgeable()) {
+            // If the resource is purgeable then make it unpurgeable to get
+            // its data. This might fail, in which case we return an
+            // empty String.
+            if (!cachedResource->makePurgeable(false))
+                isUnpurgeable = false;
+        }
+        if (isUnpurgeable) {
+            textEncodingName = cachedResource->encoding();
+            buffer = cachedResource->data();
+        }
+    }
+
+    if (buffer) {
+        TextEncoding encoding(textEncodingName);
+        if (!encoding.isValid())
+            encoding = WindowsLatin1Encoding();
+        *result = encoding.decode(buffer->data(), buffer->size());
+        return true;
+    }
+
+    return false;
+}
+
 void InspectorController::reloadPage()
 {
     m_inspectedPage->mainFrame()->redirectScheduler()->scheduleRefresh(true);
diff --git a/WebCore/inspector/InspectorController.h b/WebCore/inspector/InspectorController.h
index fda8c24..d5b18ba 100644
--- a/WebCore/inspector/InspectorController.h
+++ b/WebCore/inspector/InspectorController.h
@@ -226,6 +226,7 @@ public:
 
     const ResourcesMap& resources() const { return m_resources; }
     InspectorResource* resourceForURL(const String& url);
+    bool resourceContentForURL(const KURL& url, Document* loaderDocument, String* result);
     bool hasFrontend() const { return m_frontend; }
 
     void drawNodeHighlight(GraphicsContext&) const;
diff --git a/WebCore/inspector/InspectorDOMAgent.cpp b/WebCore/inspector/InspectorDOMAgent.cpp
index ddd71f9..36b448f 100644
--- a/WebCore/inspector/InspectorDOMAgent.cpp
+++ b/WebCore/inspector/InspectorDOMAgent.cpp
@@ -37,6 +37,7 @@
 #include "CSSComputedStyleDeclaration.h"
 #include "CSSMutableStyleDeclaration.h"
 #include "CSSPropertyNames.h"
+#include "CSSPropertySourceData.h"
 #include "CSSRule.h"
 #include "CSSRuleList.h"
 #include "CSSStyleRule.h"
@@ -1191,26 +1192,34 @@ void InspectorDOMAgent::getStyleSheet(long styleSheetId, RefPtr<InspectorObject>
         *styleSheetObject = buildObjectForStyleSheet(styleSheet->document(), styleSheet);
 }
 
-void InspectorDOMAgent::getRuleRanges(long styleSheetId, RefPtr<InspectorValue>* ruleRange)
+void InspectorDOMAgent::getStyleSourceData(long styleId, RefPtr<InspectorObject>* dataObject)
 {
-    CSSStyleSheet* styleSheet = cssStore()->styleSheetForId(styleSheetId);
-    if (styleSheet && styleSheet->document()) {
-        HashMap<long, SourceRange> ruleRanges = cssStore()->getRuleRanges(styleSheet);
-        if (!ruleRanges.size())
-            return;
-        RefPtr<InspectorObject> result = InspectorObject::create();
-        for (HashMap<long, SourceRange>::iterator it = ruleRanges.begin(); it != ruleRanges.end(); ++it) {
-            if (it->second.second) {
-                RefPtr<InspectorObject> ruleRange = InspectorObject::create();
-                result->setObject(String::number(it->first).utf8().data(), ruleRange);
-                RefPtr<InspectorObject> bodyRange = InspectorObject::create();
-                ruleRange->setObject("bodyRange", bodyRange);
-                bodyRange->setNumber("start", it->second.first);
-                bodyRange->setNumber("end", it->second.second);
-            }
-        }
-        *ruleRange = result.release();
+    CSSStyleDeclaration* style = cssStore()->styleForId(styleId);
+    if (!style)
+        return;
+    RefPtr<CSSStyleSourceData> sourceData = CSSStyleSourceData::create();
+    bool success = cssStore()->getStyleSourceData(style, &sourceData);
+    if (!success)
+        return;
+    RefPtr<InspectorObject> result = InspectorObject::create();
+    RefPtr<InspectorObject> bodyRange = InspectorObject::create();
+    result->setObject("bodyRange", bodyRange);
+    bodyRange->setNumber("start", sourceData->styleBodyRange.start);
+    bodyRange->setNumber("end", sourceData->styleBodyRange.end);
+    RefPtr<InspectorArray> propertyRanges = InspectorArray::create();
+    result->setArray("propertyData", propertyRanges);
+    Vector<CSSPropertySourceData>& propertyData = sourceData->propertyData;
+    for (Vector<CSSPropertySourceData>::iterator it = propertyData.begin(); it != propertyData.end(); ++it) {
+        RefPtr<InspectorObject> propertyRange = InspectorObject::create();
+        propertyRange->setString("name", it->name);
+        propertyRange->setString("value", it->value);
+        propertyRange->setBoolean("important", it->important);
+        propertyRange->setBoolean("parsed", it->parsedOk);
+        propertyRange->setNumber("start", it->range.start);
+        propertyRange->setNumber("end", it->range.end);
+        propertyRanges->pushObject(propertyRange);
     }
+    *dataObject = result.release();
 }
 
 void InspectorDOMAgent::getInlineStyle(long nodeId, RefPtr<InspectorValue>* style)
@@ -1469,7 +1478,7 @@ PassRefPtr<InspectorObject> InspectorDOMAgent::buildObjectForStyle(CSSStyleDecla
     if (bind) {
         long styleId = cssStore()->bindStyle(style);
         result->setNumber("id", styleId);
-        CSSStyleSheet* parentStyleSheet = getParentStyleSheet(style);
+        CSSStyleSheet* parentStyleSheet = InspectorCSSStore::getParentStyleSheet(style);
         if (parentStyleSheet)
             result->setNumber("parentStyleSheetId", cssStore()->bindStyleSheet(parentStyleSheet));
 
@@ -1681,20 +1690,6 @@ PassRefPtr<InspectorArray> InspectorDOMAgent::toArray(const Vector<String>& data
     return result.release();
 }
 
-CSSStyleSheet* InspectorDOMAgent::getParentStyleSheet(CSSStyleDeclaration* style)
-{
-    CSSStyleSheet* parentStyleSheet = style->parentRule() ? style->parentRule()->parentStyleSheet() : 0;
-    if (!parentStyleSheet) {
-        StyleBase* parent = style->parent();
-        if (parent && parent->isCSSStyleSheet()) {
-            parentStyleSheet = static_cast<CSSStyleSheet*>(parent);
-            if (!parentStyleSheet->length())
-                return 0;
-        }
-    }
-    return parentStyleSheet;
-}
-
 void InspectorDOMAgent::onMatchJobsTimer(Timer<InspectorDOMAgent>*)
 {
     if (!m_pendingMatchJobs.size()) {
diff --git a/WebCore/inspector/InspectorDOMAgent.h b/WebCore/inspector/InspectorDOMAgent.h
index 9751e8e..7a9f6bc 100644
--- a/WebCore/inspector/InspectorDOMAgent.h
+++ b/WebCore/inspector/InspectorDOMAgent.h
@@ -123,7 +123,7 @@ namespace WebCore {
         void getInlineStyle(long nodeId, RefPtr<InspectorValue>* styles);
         void getComputedStyle(long nodeId, RefPtr<InspectorValue>* styles);
         void getStyleSheet(long styleSheetId, RefPtr<InspectorObject>* styleSheetObject);
-        void getRuleRanges(long styleSheetId, RefPtr<InspectorValue>* ruleRange);
+        void getStyleSourceData(long styleId, RefPtr<InspectorObject>* dataObject);
         void applyStyleText(long styleId, const String& styleText, const String& propertyName, bool* success, RefPtr<InspectorValue>* styleObject, RefPtr<InspectorArray>* changedProperties);
         void setStyleText(long styleId, const String& cssText, bool* success);
         void setStyleProperty(long styleId, const String& name, const String& value, bool* success);
@@ -148,7 +148,6 @@ namespace WebCore {
         void copyNode(long nodeId);
 
     private:
-        static CSSStyleSheet* getParentStyleSheet(CSSStyleDeclaration*);
         void startListening(Document* document);
         void stopListening(Document* document);
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list