Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(350)

Side by Side Diff: Source/core/inspector/InspectorStyleSheet.h

Issue 198053011: DevTools: [CSS] remove StyleId and RuleId types from protocol.json (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: address @apavlov comments Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010, Google Inc. All rights reserved. 2 * Copyright (C) 2010, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 typedef WillBePersistentHeapVector<RefPtrWillBeMember<CSSRule> > CSSRuleVector; 55 typedef WillBePersistentHeapVector<RefPtrWillBeMember<CSSRule> > CSSRuleVector;
56 typedef String ErrorString; 56 typedef String ErrorString;
57 57
58 class InspectorCSSId { 58 class InspectorCSSId {
59 public: 59 public:
60 InspectorCSSId() 60 InspectorCSSId()
61 : m_ordinal(0) 61 : m_ordinal(0)
62 { 62 {
63 } 63 }
64 64
65 explicit InspectorCSSId(PassRefPtr<JSONObject> value)
66 {
67 if (!value->getString("styleSheetId", &m_styleSheetId))
68 return;
69
70 RefPtr<JSONValue> ordinalValue = value->get("ordinal");
71 if (!ordinalValue || !ordinalValue->asNumber(&m_ordinal))
72 m_styleSheetId = "";
73 }
74
75 InspectorCSSId(const String& styleSheetId, unsigned ordinal) 65 InspectorCSSId(const String& styleSheetId, unsigned ordinal)
76 : m_styleSheetId(styleSheetId) 66 : m_styleSheetId(styleSheetId)
77 , m_ordinal(ordinal) 67 , m_ordinal(ordinal)
78 { 68 {
79 } 69 }
80 70
81 bool isEmpty() const { return m_styleSheetId.isEmpty(); } 71 bool isEmpty() const { return m_styleSheetId.isEmpty(); }
82 72
83 const String& styleSheetId() const { return m_styleSheetId; } 73 const String& styleSheetId() const { return m_styleSheetId; }
84 unsigned ordinal() const { return m_ordinal; } 74 unsigned ordinal() const { return m_ordinal; }
85 75
86 // ID type is either TypeBuilder::CSS::CSSStyleId or TypeBuilder::CSS::CSSRu leId.
87 template<typename ID>
88 PassRefPtr<ID> asProtocolValue() const
89 {
90 if (isEmpty())
91 return nullptr;
92
93 RefPtr<ID> result = ID::create()
94 .setStyleSheetId(m_styleSheetId)
95 .setOrdinal(m_ordinal);
96 return result.release();
97 }
98
99 private: 76 private:
100 String m_styleSheetId; 77 String m_styleSheetId;
101 unsigned m_ordinal; 78 unsigned m_ordinal;
102 }; 79 };
103 80
104 struct InspectorStyleProperty { 81 struct InspectorStyleProperty {
105 ALLOW_ONLY_INLINE_ALLOCATION(); 82 ALLOW_ONLY_INLINE_ALLOCATION();
106 public: 83 public:
107 explicit InspectorStyleProperty(CSSPropertySourceData sourceData) 84 explicit InspectorStyleProperty(CSSPropertySourceData sourceData)
108 : sourceData(sourceData) 85 : sourceData(sourceData)
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 298
322 namespace WTF { 299 namespace WTF {
323 300
324 template <> struct VectorTraits<WebCore::InspectorStyleProperty> : VectorTraitsB ase<WebCore::InspectorStyleProperty> { 301 template <> struct VectorTraits<WebCore::InspectorStyleProperty> : VectorTraitsB ase<WebCore::InspectorStyleProperty> {
325 static const bool canInitializeWithMemset = true; 302 static const bool canInitializeWithMemset = true;
326 static const bool canMoveWithMemcpy = true; 303 static const bool canMoveWithMemcpy = true;
327 }; 304 };
328 305
329 } 306 }
330 #endif // !defined(InspectorStyleSheet_h) 307 #endif // !defined(InspectorStyleSheet_h)
OLDNEW
« no previous file with comments | « LayoutTests/inspector/elements/styles/undo-add-new-rule.html ('k') | Source/core/inspector/InspectorStyleSheet.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698