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

pfeldman at chromium.org pfeldman at chromium.org
Wed Dec 22 16:28:09 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 4ee21ffafb969411e7524bca5925154a29d27cad
Author: pfeldman at chromium.org <pfeldman at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Nov 24 10:11:39 2010 +0000

    2010-11-24  Pavel Feldman  <pfeldman at chromium.org>
    
            Reviewed by Yury Semikhatsky.
    
            Web Inspector: pass style id to front-end as Object, not string.
            https://bugs.webkit.org/show_bug.cgi?id=49971
    
            * inspector/Inspector.idl:
            * inspector/InspectorCSSAgent.cpp:
            (WebCore::InspectorCSSAgent::getStylesForNode2):
            (WebCore::InspectorCSSAgent::getStyleSheetText2):
            (WebCore::InspectorCSSAgent::setPropertyText2):
            (WebCore::InspectorCSSAgent::toggleProperty2):
            (WebCore::InspectorCSSAgent::setRuleSelector2):
            * inspector/InspectorCSSAgent.h:
            * inspector/InspectorStyleSheet.cpp:
            (WebCore::InspectorStyle::buildObjectForStyle):
            (WebCore::InspectorStyleSheet::finalURL):
            (WebCore::InspectorStyleSheet::ruleForId):
            (WebCore::InspectorStyleSheet::buildObjectForStyleSheet):
            (WebCore::InspectorStyleSheet::buildObjectForRule):
            (WebCore::InspectorStyleSheet::text):
            (WebCore::InspectorStyleSheet::ruleOrStyleId):
            (WebCore::InspectorStyleSheetForInlineStyle::InspectorStyleSheetForInlineStyle):
            (WebCore::InspectorStyleSheetForInlineStyle::text):
            * inspector/InspectorStyleSheet.h:
            (WebCore::InspectorCSSId::InspectorCSSId):
            (WebCore::InspectorCSSId::isEmpty):
            (WebCore::InspectorCSSId::styleSheetId):
            (WebCore::InspectorCSSId::ordinal):
            (WebCore::InspectorCSSId::asInspectorValue):
            (WebCore::InspectorStyleSheet::id):
            (WebCore::InspectorStyleSheetForInlineStyle::styleForId):
            * inspector/front-end/CSSStyleModel.js:
            (WebInspector.CSSStyleModel.prototype.setRuleSelector):
            (WebInspector.CSSStyleModel.prototype.addRule):
            (WebInspector.CSSStyleModel.prototype._styleSheetChanged):
            (WebInspector.CSSStyleDeclaration.prototype.insertPropertyAt):
            (WebInspector.CSSProperty.prototype.setText):
            (WebInspector.CSSProperty.prototype.setDisabled.callback):
            (WebInspector.CSSProperty.prototype.setDisabled):
            (WebInspector.CSSStyleSheet.createForId):
            (WebInspector.CSSStyleSheet.prototype.setText):
    
    2010-11-23  Pavel Feldman  <pfeldman at chromium.org>
    
            Reviewed by Yury Semikhatsky.
    
            Web Inspector: pass style id to front-end as Object, not string.
            https://bugs.webkit.org/show_bug.cgi?id=49971
    
            * inspector/styles-new-API.html:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@72652 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 243126a..1a3ecae 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,12 @@
+2010-11-23  Pavel Feldman  <pfeldman at chromium.org>
+
+        Reviewed by Yury Semikhatsky.
+
+        Web Inspector: pass style id to front-end as Object, not string.
+        https://bugs.webkit.org/show_bug.cgi?id=49971
+
+        * inspector/styles-new-API.html:
+
 2010-11-23  Ilya Tikhonovsky  <loislo at chromium.org>
 
         Unreviewed.
diff --git a/LayoutTests/inspector/styles-new-API.html b/LayoutTests/inspector/styles-new-API.html
index 8d6432d..bf5d0b3 100644
--- a/LayoutTests/inspector/styles-new-API.html
+++ b/LayoutTests/inspector/styles-new-API.html
@@ -1,7 +1,7 @@
 <html>
 <head>
 
-<link rel="stylesheet" href="resources/styles-new-API.css" -->
+<link rel="stylesheet" href="resources/styles-new-API.css">
 
 <script src="../http/tests/inspector/inspector-test.js"></script>
 <script src="elements-tests.js"></script>
@@ -112,25 +112,19 @@ function frontend_changeSelector(testController, styleSheet)
     {
         testController.results.push("");
         testController.results.push("=== After selector set ===");
-        frontend_loadAndDumpStyleSheet(testController, frontend_parentStyleSheetId(rule.ruleId), frontend_setStyleText.bind(null, testController));
+        frontend_loadAndDumpStyleSheet(testController, rule.ruleId.styleSheetId, frontend_setStyleText.bind(null, testController));
     }
 
     InspectorBackend.setRuleSelector2(styleSheet.rules[0].ruleId, "html *, body[foo=\"bar\"]", didSetSelector.bind(null, testController));
 }
 
-function frontend_parentStyleSheetId(ruleOrStyleId)
-{
-    return ruleOrStyleId.substring(0, ruleOrStyleId.indexOf(':'));
-}
-
-
 function frontend_setStyleText(testController, styleSheet)
 {
     function didSetStyleText(testController, style)
     {
         testController.results.push("");
         testController.results.push("=== After style text set ===");
-        frontend_loadAndDumpStyleSheet(testController, frontend_parentStyleSheetId(style.styleId), frontend_addRule.bind(null, testController));
+        frontend_loadAndDumpStyleSheet(testController, style.styleId.styleSheetId, frontend_addRule.bind(null, testController));
     }
 
     InspectorBackend.setPropertyText2(styleSheet.rules[0].style.styleId, 0, "", true);
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 9134119..7162c12 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,47 @@
+2010-11-24  Pavel Feldman  <pfeldman at chromium.org>
+
+        Reviewed by Yury Semikhatsky.
+
+        Web Inspector: pass style id to front-end as Object, not string.
+        https://bugs.webkit.org/show_bug.cgi?id=49971
+
+        * inspector/Inspector.idl:
+        * inspector/InspectorCSSAgent.cpp:
+        (WebCore::InspectorCSSAgent::getStylesForNode2):
+        (WebCore::InspectorCSSAgent::getStyleSheetText2):
+        (WebCore::InspectorCSSAgent::setPropertyText2):
+        (WebCore::InspectorCSSAgent::toggleProperty2):
+        (WebCore::InspectorCSSAgent::setRuleSelector2):
+        * inspector/InspectorCSSAgent.h:
+        * inspector/InspectorStyleSheet.cpp:
+        (WebCore::InspectorStyle::buildObjectForStyle):
+        (WebCore::InspectorStyleSheet::finalURL):
+        (WebCore::InspectorStyleSheet::ruleForId):
+        (WebCore::InspectorStyleSheet::buildObjectForStyleSheet):
+        (WebCore::InspectorStyleSheet::buildObjectForRule):
+        (WebCore::InspectorStyleSheet::text):
+        (WebCore::InspectorStyleSheet::ruleOrStyleId):
+        (WebCore::InspectorStyleSheetForInlineStyle::InspectorStyleSheetForInlineStyle):
+        (WebCore::InspectorStyleSheetForInlineStyle::text):
+        * inspector/InspectorStyleSheet.h:
+        (WebCore::InspectorCSSId::InspectorCSSId):
+        (WebCore::InspectorCSSId::isEmpty):
+        (WebCore::InspectorCSSId::styleSheetId):
+        (WebCore::InspectorCSSId::ordinal):
+        (WebCore::InspectorCSSId::asInspectorValue):
+        (WebCore::InspectorStyleSheet::id):
+        (WebCore::InspectorStyleSheetForInlineStyle::styleForId):
+        * inspector/front-end/CSSStyleModel.js:
+        (WebInspector.CSSStyleModel.prototype.setRuleSelector):
+        (WebInspector.CSSStyleModel.prototype.addRule):
+        (WebInspector.CSSStyleModel.prototype._styleSheetChanged):
+        (WebInspector.CSSStyleDeclaration.prototype.insertPropertyAt):
+        (WebInspector.CSSProperty.prototype.setText):
+        (WebInspector.CSSProperty.prototype.setDisabled.callback):
+        (WebInspector.CSSProperty.prototype.setDisabled):
+        (WebInspector.CSSStyleSheet.createForId):
+        (WebInspector.CSSStyleSheet.prototype.setText):
+
 2010-11-24  Sheriff Bot  <webkit.review.bot at gmail.com>
 
         Unreviewed, rolling out r72647.
diff --git a/WebCore/inspector/Inspector.idl b/WebCore/inspector/Inspector.idl
index 29a3ba0..f7acfe9 100644
--- a/WebCore/inspector/Inspector.idl
+++ b/WebCore/inspector/Inspector.idl
@@ -213,10 +213,11 @@ module core {
         [handler=CSS] void getInlineStyleForNode2(in long nodeId, out Value style);
         [handler=CSS] void getAllStyles2(out Array styleSheetIds);
         [handler=CSS] void getStyleSheet2(in String styleSheetId, out Value styleSheet);
+        [handler=CSS] void getStyleSheetText2(in String styleSheetId, out String url, out String text);
         [handler=CSS] void setStyleSheetText2(in String styleSheetId, in String text);
-        [handler=CSS] void setPropertyText2(in String styleId, in long propertyIndex, in String text, in boolean overwrite, out Value style);
-        [handler=CSS] void toggleProperty2(in String styleId, in long propertyIndex, in boolean disable, out Value style);
-        [handler=CSS] void setRuleSelector2(in String ruleId, in String selector, out Value rule);
+        [handler=CSS] void setPropertyText2(in Object styleId, in long propertyIndex, in String text, in boolean overwrite, out Value style);
+        [handler=CSS] void toggleProperty2(in Object styleId, in long propertyIndex, in boolean disable, out Value style);
+        [handler=CSS] void setRuleSelector2(in Object ruleId, in String selector, out Value rule);
         [handler=CSS] void addRule2(in long contextNodeId, in String selector, out Value rule);
         [handler=CSS] void getSupportedCSSProperties(out Array cssProperties);
         [handler=CSS] void querySelectorAll(in long documentId, in String selector, out Array result);
diff --git a/WebCore/inspector/InspectorCSSAgent.cpp b/WebCore/inspector/InspectorCSSAgent.cpp
index abc983e..fd1deb5 100644
--- a/WebCore/inspector/InspectorCSSAgent.cpp
+++ b/WebCore/inspector/InspectorCSSAgent.cpp
@@ -214,7 +214,7 @@ void InspectorCSSAgent::getStylesForNode2(long nodeId, RefPtr<InspectorValue>* r
         if (parentElement->style() && parentElement->style()->length()) {
             InspectorStyleSheetForInlineStyle* styleSheet = asInspectorStyleSheet(parentElement);
             if (styleSheet)
-                parentStyle->setObject("inlineStyle", styleSheet->buildObjectForStyle(styleSheet->styleForId(InspectorCSSId::createFromParts(styleSheet->id(), "0"))));
+                parentStyle->setObject("inlineStyle", styleSheet->buildObjectForStyle(styleSheet->styleForId(InspectorCSSId(styleSheet->id(), 0))));
         }
 
         CSSStyleSelector* parentSelector = parentElement->ownerDocument()->styleSelector();
@@ -276,6 +276,15 @@ void InspectorCSSAgent::getStyleSheet2(const String& styleSheetId, RefPtr<Inspec
     *styleSheetObject = inspectorStyleSheet->buildObjectForStyleSheet();
 }
 
+void InspectorCSSAgent::getStyleSheetText2(const String& styleSheetId, String* url, String* result)
+{
+    InspectorStyleSheet* inspectorStyleSheet = styleSheetForId(styleSheetId);
+    if (!inspectorStyleSheet)
+        return;
+    *url = inspectorStyleSheet->finalURL();
+    inspectorStyleSheet->text(result);
+}
+
 void InspectorCSSAgent::setStyleSheetText2(const String& styleSheetId, const String& text)
 {
     InspectorStyleSheet* inspectorStyleSheet = styleSheetForId(styleSheetId);
@@ -287,7 +296,7 @@ void InspectorCSSAgent::setStyleSheetText2(const String& styleSheetId, const Str
         inspectorStyleSheet->reparseStyleSheet(text);
 }
 
-void InspectorCSSAgent::setPropertyText2(const String& fullStyleId, long propertyIndex, const String& text, bool overwrite, RefPtr<InspectorValue>* result)
+void InspectorCSSAgent::setPropertyText2(const RefPtr<InspectorObject>& fullStyleId, long propertyIndex, const String& text, bool overwrite, RefPtr<InspectorValue>* result)
 {
     InspectorCSSId compoundId(fullStyleId);
     ASSERT(!compoundId.isEmpty());
@@ -301,7 +310,7 @@ void InspectorCSSAgent::setPropertyText2(const String& fullStyleId, long propert
         *result = inspectorStyleSheet->buildObjectForStyle(inspectorStyleSheet->styleForId(compoundId));
 }
 
-void InspectorCSSAgent::toggleProperty2(const String& fullStyleId, long propertyIndex, bool disable, RefPtr<InspectorValue>* result)
+void InspectorCSSAgent::toggleProperty2(const RefPtr<InspectorObject>& fullStyleId, long propertyIndex, bool disable, RefPtr<InspectorValue>* result)
 {
     InspectorCSSId compoundId(fullStyleId);
     ASSERT(!compoundId.isEmpty());
@@ -315,7 +324,7 @@ void InspectorCSSAgent::toggleProperty2(const String& fullStyleId, long property
         *result = inspectorStyleSheet->buildObjectForStyle(inspectorStyleSheet->styleForId(compoundId));
 }
 
-void InspectorCSSAgent::setRuleSelector2(const String& fullRuleId, const String& selector, RefPtr<InspectorValue>* result)
+void InspectorCSSAgent::setRuleSelector2(const RefPtr<InspectorObject>& fullRuleId, const String& selector, RefPtr<InspectorValue>* result)
 {
     InspectorCSSId compoundId(fullRuleId);
     ASSERT(!compoundId.isEmpty());
diff --git a/WebCore/inspector/InspectorCSSAgent.h b/WebCore/inspector/InspectorCSSAgent.h
index 71ca580..6e8f244 100644
--- a/WebCore/inspector/InspectorCSSAgent.h
+++ b/WebCore/inspector/InspectorCSSAgent.h
@@ -65,10 +65,11 @@ public:
     void getComputedStyleForNode2(long nodeId, RefPtr<InspectorValue>* style);
     void getAllStyles2(RefPtr<InspectorArray>* styles);
     void getStyleSheet2(const String& styleSheetId, RefPtr<InspectorValue>* result);
+    void getStyleSheetText2(const String& styleSheetId, String* url, String* result);
     void setStyleSheetText2(const String& styleSheetId, const String& text);
-    void setPropertyText2(const String& styleId, long propertyIndex, const String& text, bool overwrite, RefPtr<InspectorValue>* result);
-    void toggleProperty2(const String& styleId, long propertyIndex, bool disable, RefPtr<InspectorValue>* result);
-    void setRuleSelector2(const String& ruleId, const String& selector, RefPtr<InspectorValue>* result);
+    void setPropertyText2(const RefPtr<InspectorObject>& styleId, long propertyIndex, const String& text, bool overwrite, RefPtr<InspectorValue>* result);
+    void toggleProperty2(const RefPtr<InspectorObject>& styleId, long propertyIndex, bool disable, RefPtr<InspectorValue>* result);
+    void setRuleSelector2(const RefPtr<InspectorObject>& ruleId, const String& selector, RefPtr<InspectorValue>* result);
     void addRule2(const long contextNodeId, const String& selector, RefPtr<InspectorValue>* result);
     void getSupportedCSSProperties(RefPtr<InspectorArray>* result);
     void querySelectorAll(const long nodeId, const String& selector, RefPtr<InspectorArray>* result);
diff --git a/WebCore/inspector/InspectorStyleSheet.cpp b/WebCore/inspector/InspectorStyleSheet.cpp
index 7936b76..0ad3821 100644
--- a/WebCore/inspector/InspectorStyleSheet.cpp
+++ b/WebCore/inspector/InspectorStyleSheet.cpp
@@ -135,7 +135,7 @@ PassRefPtr<InspectorObject> InspectorStyle::buildObjectForStyle() const
 {
     RefPtr<InspectorObject> result = InspectorObject::create();
     if (!m_styleId.isEmpty())
-        result->setString("styleId", m_styleId.asString());
+        result->setValue("styleId", m_styleId.asInspectorValue());
 
     RefPtr<InspectorObject> propertiesObject = InspectorObject::create();
     propertiesObject->setString("width", m_style->getPropertyValue("width"));
@@ -576,6 +576,13 @@ InspectorStyleSheet::~InspectorStyleSheet()
     delete m_parsedStyleSheet;
 }
 
+String InspectorStyleSheet::finalURL() const
+{
+    if (m_pageStyleSheet && !m_pageStyleSheet->finalURL().isEmpty())
+        return m_pageStyleSheet->finalURL().string();
+    return m_documentURL;
+}
+
 void InspectorStyleSheet::reparseStyleSheet(const String& text)
 {
     for (unsigned i = 0, size = m_pageStyleSheet->length(); i < size; ++i)
@@ -648,13 +655,8 @@ CSSStyleRule* InspectorStyleSheet::ruleForId(const InspectorCSSId& id) const
         return 0;
 
     ASSERT(!id.isEmpty());
-    bool ok;
-    unsigned index = id.ordinal().toUInt(&ok);
-    if (!ok)
-        return 0;
-
     ensureFlatRules();
-    return index >= m_flatRules.size() ? 0 : m_flatRules.at(index);
+    return id.ordinal() >= m_flatRules.size() ? 0 : m_flatRules.at(id.ordinal());
 
 }
 
@@ -666,7 +668,7 @@ PassRefPtr<InspectorObject> InspectorStyleSheet::buildObjectForStyleSheet()
 
     RefPtr<InspectorObject> result = InspectorObject::create();
     result->setBoolean("disabled", styleSheet->disabled());
-    result->setString("sourceURL", styleSheet->href());
+    result->setString("sourceURL", finalURL());
     result->setString("title", styleSheet->title());
     RefPtr<CSSRuleList> cssRuleList = CSSRuleList::create(styleSheet, true);
     RefPtr<InspectorArray> cssRules = buildArrayForRuleList(cssRuleList.get());
@@ -692,7 +694,7 @@ PassRefPtr<InspectorObject> InspectorStyleSheet::buildObjectForRule(CSSStyleRule
     result->setString("selectorText", rule->selectorText());
     // "sourceURL" is present only for regular rules, otherwise "origin" should be used in the frontend.
     if (!m_origin.length())
-        result->setString("sourceURL", !styleSheet->href().isEmpty() ? styleSheet->href() : m_documentURL);
+        result->setString("sourceURL", finalURL());
     result->setNumber("sourceLine", rule->sourceLine());
     result->setString("origin", m_origin);
 
@@ -700,7 +702,7 @@ PassRefPtr<InspectorObject> InspectorStyleSheet::buildObjectForRule(CSSStyleRule
     if (canBind()) {
         InspectorCSSId id(ruleId(rule));
         if (!id.isEmpty())
-            result->setString("ruleId", id.asString());
+            result->setValue("ruleId", id.asInspectorValue());
     }
 
     RefPtr<CSSRuleSourceData> sourceData;
@@ -771,6 +773,14 @@ bool InspectorStyleSheet::toggleProperty(const InspectorCSSId& id, unsigned prop
     return success;
 }
 
+bool InspectorStyleSheet::text(String* result) const
+{
+    if (!ensureText())
+        return false;
+    *result = m_parsedStyleSheet->text();
+    return true;
+}
+
 CSSStyleDeclaration* InspectorStyleSheet::styleForId(const InspectorCSSId& id) const
 {
     CSSStyleRule* rule = ruleForId(id);
@@ -808,7 +818,7 @@ InspectorCSSId InspectorStyleSheet::ruleOrStyleId(CSSStyleDeclaration* style) co
 {
     unsigned index = ruleIndexByStyle(style);
     if (index != UINT_MAX)
-        return InspectorCSSId::createFromParts(id(), String::number(index));
+        return InspectorCSSId(id(), index);
     return InspectorCSSId();
 }
 
@@ -840,14 +850,6 @@ bool InspectorStyleSheet::ensureParsedDataReady()
     return ensureText() && ensureSourceData();
 }
 
-bool InspectorStyleSheet::text(String* result) const
-{
-    if (!ensureText())
-        return false;
-    *result = m_parsedStyleSheet->text();
-    return true;
-}
-
 bool InspectorStyleSheet::ensureText() const
 {
     if (!m_parsedStyleSheet)
@@ -1084,14 +1086,19 @@ void InspectorStyleSheet::collectFlatRules(PassRefPtr<CSSRuleList> ruleList, Vec
     }
 }
 
-
 InspectorStyleSheetForInlineStyle::InspectorStyleSheetForInlineStyle(const String& id, Element* element, const String& origin)
     : InspectorStyleSheet(id, 0, origin, "")
     , m_element(element)
     , m_ruleSourceData(0)
 {
     ASSERT(element);
-    m_inspectorStyle = InspectorStyle::create(InspectorCSSId::createFromParts(id, "0"), inlineStyle(), this);
+    m_inspectorStyle = InspectorStyle::create(InspectorCSSId(id, 0), inlineStyle(), this);
+}
+
+bool InspectorStyleSheetForInlineStyle::text(String* result) const
+{
+    *result = m_element->getAttribute("style");
+    return true;
 }
 
 bool InspectorStyleSheetForInlineStyle::setStyleText(CSSStyleDeclaration* style, const String& text)
@@ -1103,12 +1110,6 @@ bool InspectorStyleSheetForInlineStyle::setStyleText(CSSStyleDeclaration* style,
     return !ec;
 }
 
-bool InspectorStyleSheetForInlineStyle::text(String* result) const
-{
-    *result = m_element->getAttribute("style");
-    return true;
-}
-
 Document* InspectorStyleSheetForInlineStyle::ownerDocument() const
 {
     return m_element->document();
@@ -1131,7 +1132,7 @@ bool InspectorStyleSheetForInlineStyle::ensureParsedDataReady()
 
 PassRefPtr<InspectorStyle> InspectorStyleSheetForInlineStyle::inspectorStyleForId(const InspectorCSSId& id)
 {
-    ASSERT_UNUSED(id, id.ordinal() == "0");
+    ASSERT_UNUSED(id, !id.ordinal());
     return m_inspectorStyle;
 }
 
diff --git a/WebCore/inspector/InspectorStyleSheet.h b/WebCore/inspector/InspectorStyleSheet.h
index a0622fe..b649bed 100644
--- a/WebCore/inspector/InspectorStyleSheet.h
+++ b/WebCore/inspector/InspectorStyleSheet.h
@@ -51,28 +51,43 @@ class Node;
 
 class InspectorCSSId {
 public:
-    static InspectorCSSId createFromParts(const String& styleSheetId, const String& ordinal) { return InspectorCSSId(styleSheetId + ":" + ordinal); }
-
     InspectorCSSId() { }
-    explicit InspectorCSSId(const String& id)
+
+    explicit InspectorCSSId(RefPtr<InspectorObject> value)
     {
-        id.split(':', m_idParts);
-        ASSERT(m_idParts.size() == 2);
+        if (!value->getString("styleSheetId", &m_styleSheetId))
+            return;
+        
+        RefPtr<InspectorValue> ordinalValue = value->get("ordinal");
+        if (!ordinalValue || !ordinalValue->asNumber(&m_ordinal))
+            m_styleSheetId = "";
     }
 
-    const String& styleSheetId() const { ASSERT(m_idParts.size() == 2); return m_idParts.at(0); }
-    const String& ordinal() const { ASSERT(m_idParts.size() == 2); return m_idParts.at(1); }
-    bool isEmpty() const { return m_idParts.isEmpty(); }
-    String asString() const
+    InspectorCSSId(const String& styleSheetId, unsigned ordinal)
+        : m_styleSheetId(styleSheetId)
+        , m_ordinal(ordinal)
+    {
+    }
+
+    bool isEmpty() const { return m_styleSheetId.isEmpty(); }
+
+    const String& styleSheetId() const { return m_styleSheetId; }
+    unsigned ordinal() const { return m_ordinal; }
+
+    PassRefPtr<InspectorValue> asInspectorValue() const
     {
         if (isEmpty())
-            return String();
+            return InspectorValue::null();
 
-        return m_idParts.at(0) + ":" + m_idParts.at(1);
+        RefPtr<InspectorObject> result = InspectorObject::create();
+        result->setString("styleSheetId", m_styleSheetId);
+        result->setNumber("ordinal", m_ordinal);
+        return result.release();
     }
 
 private:
-    Vector<String> m_idParts;
+    String m_styleSheetId;
+    unsigned m_ordinal;
 };
 
 struct InspectorStyleProperty {
@@ -156,7 +171,8 @@ public:
     InspectorStyleSheet(const String& id, CSSStyleSheet* pageStyleSheet, const String& origin, const String& documentURL);
     virtual ~InspectorStyleSheet();
 
-    const String& id() const { return m_id; }
+    String id() const { return m_id; }
+    String finalURL() const;
     CSSStyleSheet* pageStyleSheet() const { return m_pageStyleSheet; }
     void reparseStyleSheet(const String&);
     bool setText(const String&);
@@ -169,12 +185,12 @@ public:
     bool setPropertyText(const InspectorCSSId&, unsigned propertyIndex, const String& text, bool overwrite);
     bool toggleProperty(const InspectorCSSId&, unsigned propertyIndex, bool disable);
 
+    virtual bool text(String* result) const;
     virtual CSSStyleDeclaration* styleForId(const InspectorCSSId&) const;
 
 protected:
     bool canBind() const { return m_origin != "userAgent" && m_origin != "user"; }
     InspectorCSSId ruleOrStyleId(CSSStyleDeclaration* style) const;
-    virtual bool text(String* result) const;
     virtual Document* ownerDocument() const;
     virtual RefPtr<CSSRuleSourceData> ruleSourceDataFor(CSSStyleDeclaration* style) const;
     virtual unsigned ruleIndexByStyle(CSSStyleDeclaration*) const;
@@ -221,10 +237,10 @@ public:
     }
 
     InspectorStyleSheetForInlineStyle(const String& id, Element* element, const String& origin);
-    virtual CSSStyleDeclaration* styleForId(const InspectorCSSId& id) const { ASSERT_UNUSED(id, id.ordinal() == "0"); return inlineStyle(); }
+    virtual bool text(String* result) const;
+    virtual CSSStyleDeclaration* styleForId(const InspectorCSSId& id) const { ASSERT_UNUSED(id, !id.ordinal()); return inlineStyle(); }
 
 protected:
-    virtual bool text(String* result) const;
     virtual Document* ownerDocument() const;
     virtual RefPtr<CSSRuleSourceData> ruleSourceDataFor(CSSStyleDeclaration* style) const { ASSERT_UNUSED(style, style == inlineStyle()); return m_ruleSourceData; }
     virtual unsigned ruleIndexByStyle(CSSStyleDeclaration*) const { return 0; }
diff --git a/WebCore/inspector/front-end/CSSStyleModel.js b/WebCore/inspector/front-end/CSSStyleModel.js
index c3429fd..5530f57 100644
--- a/WebCore/inspector/front-end/CSSStyleModel.js
+++ b/WebCore/inspector/front-end/CSSStyleModel.js
@@ -117,7 +117,9 @@ WebInspector.CSSStyleModel.prototype = {
         function checkAffectsCallback(nodeId, successCallback, rulePayload, selectedNodeIds)
         {
             var doesAffectSelectedNode = (selectedNodeIds.indexOf(nodeId) >= 0);
-            successCallback(WebInspector.CSSRule.parsePayload(rulePayload), doesAffectSelectedNode);
+            var rule = WebInspector.CSSRule.parsePayload(rulePayload);
+            successCallback(rule, doesAffectSelectedNode);
+            this._styleSheetChanged(rule.id.styleSheetId);
         }
 
         function callback(nodeId, successCallback, failureCallback, newSelector, rulePayload)
@@ -125,10 +127,10 @@ WebInspector.CSSStyleModel.prototype = {
             if (!rulePayload)
                 failureCallback();
             else
-                InspectorBackend.querySelectorAll(nodeId, newSelector, checkAffectsCallback.bind(null, nodeId, successCallback, rulePayload));
+                InspectorBackend.querySelectorAll(nodeId, newSelector, checkAffectsCallback.bind(this, nodeId, successCallback, rulePayload));
         }
 
-        InspectorBackend.setRuleSelector2(ruleId, newSelector, callback.bind(null, nodeId, successCallback, failureCallback));
+        InspectorBackend.setRuleSelector2(ruleId, newSelector, callback.bind(this, nodeId, successCallback, failureCallback));
     },
 
     addRule: function(nodeId, selector, successCallback, failureCallback)
@@ -136,7 +138,9 @@ WebInspector.CSSStyleModel.prototype = {
         function checkAffectsCallback(nodeId, successCallback, rulePayload, selectedNodeIds)
         {
             var doesAffectSelectedNode = (selectedNodeIds.indexOf(nodeId) >= 0);
-            successCallback(WebInspector.CSSRule.parsePayload(rulePayload), doesAffectSelectedNode);
+            var rule = WebInspector.CSSRule.parsePayload(rulePayload);
+            successCallback(rule, doesAffectSelectedNode);
+            this._styleSheetChanged(rule.id.styleSheetId);
         }
 
         function callback(successCallback, failureCallback, selector, rulePayload)
@@ -145,10 +149,15 @@ WebInspector.CSSStyleModel.prototype = {
                 // Invalid syntax for a selector
                 failureCallback();
             } else
-                InspectorBackend.querySelectorAll(nodeId, selector, checkAffectsCallback.bind(null, nodeId, successCallback, rulePayload));
+                InspectorBackend.querySelectorAll(nodeId, selector, checkAffectsCallback.bind(this, nodeId, successCallback, rulePayload));
         }
 
-        InspectorBackend.addRule2(nodeId, selector, callback.bind(null, successCallback, failureCallback, selector));
+        InspectorBackend.addRule2(nodeId, selector, callback.bind(this, successCallback, failureCallback, selector));
+    },
+
+    _styleSheetChanged: function(styleSheetId)
+    {
+        // FIXME: use InspectorBackend.getStyleSheetText2 here;
     }
 }
 
@@ -312,8 +321,10 @@ WebInspector.CSSStyleDeclaration.prototype = {
 
             if (!payload)
                 userCallback(null);
-            else
+            else {
                 userCallback(WebInspector.CSSStyleDeclaration.parsePayload(payload));
+                WebInspector.cssModel._styleSheetChanged(this.id.styleSheetId);
+            }
         }
 
         InspectorBackend.setPropertyText2(this.id, index, name + ": " + value + ";", false, callback.bind(null, userCallback));
@@ -424,7 +435,7 @@ WebInspector.CSSProperty.prototype = {
     // Replaces "propertyName: propertyValue [!important];" in the stylesheet by an arbitrary propertyText.
     setText: function(propertyText, userCallback)
     {
-        function callback(userCallback, stylePayload)
+        function callback(stylePayload)
         {
             if (stylePayload)
                 this.text = propertyText;
@@ -436,6 +447,7 @@ WebInspector.CSSProperty.prototype = {
             else {
                 var style = WebInspector.CSSStyleDeclaration.parsePayload(stylePayload);
                 userCallback(style);
+                WebInspector.cssModel._styleSheetChanged(style.id.styleSheetId);
             }
         }
 
@@ -443,7 +455,7 @@ WebInspector.CSSProperty.prototype = {
             throw "No ownerStyle for property";
 
         // An index past all the properties adds a new property to the style.
-        InspectorBackend.setPropertyText2(this.ownerStyle.id, this.index, propertyText, this.index < this.ownerStyle.pastLastSourcePropertyIndex(), callback.bind(this, userCallback));
+        InspectorBackend.setPropertyText2(this.ownerStyle.id, this.index, propertyText, this.index < this.ownerStyle.pastLastSourcePropertyIndex(), callback.bind(this));
     },
 
     setValue: function(newValue, userCallback)
@@ -459,7 +471,7 @@ WebInspector.CSSProperty.prototype = {
         if (disabled === this.disabled && userCallback)
             userCallback(this.ownerStyle);
 
-        function callback(userCallback, stylePayload)
+        function callback(stylePayload)
         {
             if (!userCallback)
                 return;
@@ -468,10 +480,11 @@ WebInspector.CSSProperty.prototype = {
             else {
                 var style = WebInspector.CSSStyleDeclaration.parsePayload(stylePayload);
                 userCallback(style);
+                WebInspector.cssModel._styleSheetChanged(this.ownerStyle.id.styleSheetId);
             }
         }
 
-        InspectorBackend.toggleProperty2(this.ownerStyle.id, this.index, disabled, callback.bind(this, userCallback));
+        InspectorBackend.toggleProperty2(this.ownerStyle.id, this.index, disabled, callback.bind(this));
     }
 }
 
@@ -495,14 +508,14 @@ WebInspector.CSSStyleSheet = function(payload)
 
 WebInspector.CSSStyleSheet.createForId = function(styleSheetId, userCallback)
 {
-    function callback(userCallback, styleSheetPayload)
+    function callback(styleSheetPayload)
     {
         if (!styleSheetPayload)
             userCallback(null);
         else
             userCallback(new WebInspector.CSSStyleSheet(styleSheetPayload));
     }
-    InspectorBackend.getStyleSheet2(styleSheetId, callback.bind(this, userCallback));
+    InspectorBackend.getStyleSheet2(styleSheetId, callback.bind(this));
 }
 
 WebInspector.CSSStyleSheet.prototype = {
@@ -513,14 +526,16 @@ WebInspector.CSSStyleSheet.prototype = {
 
     setText: function(newText, userCallback)
     {
-        function callback(userCallback, styleSheetPayload)
+        function callback(styleSheetPayload)
         {
             if (!styleSheetPayload)
                 userCallback(null);
-            else
+            else {
                 userCallback(new WebInspector.CSSStyleSheet(styleSheetPayload));
+                WebInspector.cssModel._styleSheetChanged(this.id);
+            }
         }
 
-        InspectorBackend.setStyleSheetText2(this.id, newText, callback.bind(this, userCallback));
+        InspectorBackend.setStyleSheetText2(this.id, newText, callback.bind(this));
     }
 }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list