Skip to content
Permalink
Browse files
2010-06-04 Ilya Tikhonovsky <loislo@chromium.org>
        Reviewed by Pavel Feldman.

        WebInspector: Web Inspector: it would be better to push object properties to JSON string in order of insertion.
        https://bugs.webkit.org/show_bug.cgi?id=40140

        * inspector/InspectorValues.cpp:
        (WebCore::InspectorObject::writeJSON):
        * inspector/InspectorValues.h:
        (WebCore::InspectorObject::setBool):
        (WebCore::InspectorObject::setNumber):
        (WebCore::InspectorObject::setString):
        (WebCore::InspectorObject::set):



Canonical link: https://commits.webkit.org/51711@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@60687 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
loislo committed Jun 4, 2010
1 parent 35cccbf commit 27564c07394f316fede7b0bba60f631bd4c7863a
Showing 3 changed files with 24 additions and 5 deletions.
@@ -1,3 +1,18 @@
2010-06-04 Ilya Tikhonovsky <loislo@chromium.org>

Reviewed by Pavel Feldman.

WebInspector: Web Inspector: it would be better to push object properties to JSON string in order of insertion.
https://bugs.webkit.org/show_bug.cgi?id=40140

* inspector/InspectorValues.cpp:
(WebCore::InspectorObject::writeJSON):
* inspector/InspectorValues.h:
(WebCore::InspectorObject::setBool):
(WebCore::InspectorObject::setNumber):
(WebCore::InspectorObject::setString):
(WebCore::InspectorObject::set):

2010-06-04 Tony Gentilcore <tonyg@chromium.org>

Reviewed by Adam Barth.
@@ -108,7 +108,9 @@ void InspectorString::writeJSON(Vector<UChar>* output) const
void InspectorObject::writeJSON(Vector<UChar>* output) const
{
output->append('{');
for (Dictionary::const_iterator it = m_data.begin(); it != m_data.end(); ++it) {
for (size_t i = 0; i < m_order.size(); ++i) {
Dictionary::const_iterator it = m_data.find(m_order[i]);
ASSERT(it != m_data.end());
if (it != m_data.begin())
output->append(',');
doubleQuoteString(it->first, output);
@@ -145,6 +145,7 @@ class InspectorObject : public InspectorValue {
InspectorObject() : InspectorValue(TypeObject) { }
typedef HashMap<String, RefPtr<InspectorValue> > Dictionary;
Dictionary m_data;
Vector<String> m_order;
};

class InspectorArray : public InspectorValue {
@@ -170,22 +171,23 @@ class InspectorArray : public InspectorValue {

inline void InspectorObject::setBool(const String& name, bool value)
{
m_data.set(name, InspectorBasicValue::create(value));
set(name, InspectorBasicValue::create(value));
}

inline void InspectorObject::setNumber(const String& name, double value)
{
m_data.set(name, InspectorBasicValue::create(value));
set(name, InspectorBasicValue::create(value));
}

inline void InspectorObject::setString(const String& name, const String& value)
{
m_data.set(name, InspectorString::create(value));
set(name, InspectorString::create(value));
}

inline void InspectorObject::set(const String& name, PassRefPtr<InspectorValue> value)
{
m_data.set(name, value);
if (m_data.set(name, value).second)
m_order.append(name);
}

inline void InspectorArray::pushBool(bool value)

0 comments on commit 27564c0

Please sign in to comment.