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

Unified Diff: third_party/WebKit/Source/core/style/StyleVariableData.h

Issue 1858553002: Refactor StyleVariableData to fallback on root map for performance reasons. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/style/StyleVariableData.h
diff --git a/third_party/WebKit/Source/core/style/StyleVariableData.h b/third_party/WebKit/Source/core/style/StyleVariableData.h
index 98d465517ebf3485d3c35a9dd209ea5687c0cbda..3db5528ca13ddb46fb3f60b468de902b4e02e143 100644
--- a/third_party/WebKit/Source/core/style/StyleVariableData.h
+++ b/third_party/WebKit/Source/core/style/StyleVariableData.h
@@ -16,25 +16,30 @@ namespace blink {
class StyleVariableData : public RefCounted<StyleVariableData> {
public:
static PassRefPtr<StyleVariableData> create() { return adoptRef(new StyleVariableData()); }
- PassRefPtr<StyleVariableData> copy() const { return adoptRef(new StyleVariableData(*this)); }
+
+ PassRefPtr<StyleVariableData> copy() { return adoptRef(new StyleVariableData(*this)); }
bool operator==(const StyleVariableData& other) const;
bool operator!=(const StyleVariableData& other) const { return !(*this == other); }
void setVariable(const AtomicString& name, PassRefPtr<CSSVariableData> value) { m_data.set(name, value); }
- CSSVariableData* getVariable(const AtomicString& name) const { return m_data.get(name); }
- void removeVariable(const AtomicString& name) { return m_data.remove(name); }
+ CSSVariableData* getVariable(const AtomicString& name) const;
+ void removeVariable(const AtomicString& name) { return setVariable(name, nullptr); }
// This map will contain null pointers if variables are invalid due to
// cycles or referencing invalid variables without using a fallback.
- const HashMap<AtomicString, RefPtr<CSSVariableData>>* getVariables() const { return &m_data; }
+ // Note that this method is slow as a new map is constructed.
+ std::unique_ptr<HashMap<AtomicString, RefPtr<CSSVariableData>>> getVariables() const;
private:
- StyleVariableData() = default;
- StyleVariableData(const StyleVariableData& other) : RefCounted<StyleVariableData>(), m_data(other.m_data) { }
+ StyleVariableData()
+ : m_root(nullptr)
+ { }
+ StyleVariableData(StyleVariableData& other);
friend class CSSVariableResolver;
HashMap<AtomicString, RefPtr<CSSVariableData>> m_data;
+ RefPtr<StyleVariableData> m_root;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698