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

Side by Side Diff: Source/core/dom/CSSSelectorWatch.h

Issue 69543002: Abstract away some of the complexity in CSSSelectorWatch by using HashCountedSet (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 16 matching lines...) Expand all
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef CSSSelectorWatch_h 31 #ifndef CSSSelectorWatch_h
32 #define CSSSelectorWatch_h 32 #define CSSSelectorWatch_h
33 33
34 #include "core/css/StyleRule.h" 34 #include "core/css/StyleRule.h"
35 #include "core/dom/DocumentSupplementable.h" 35 #include "core/dom/DocumentSupplementable.h"
36 #include "platform/Timer.h" 36 #include "platform/Timer.h"
37 #include "wtf/HashCountedSet.h"
37 #include "wtf/HashSet.h" 38 #include "wtf/HashSet.h"
38 #include "wtf/RefPtr.h" 39 #include "wtf/RefPtr.h"
39 #include "wtf/Vector.h" 40 #include "wtf/Vector.h"
40 #include "wtf/WeakPtr.h" 41 #include "wtf/WeakPtr.h"
41 #include "wtf/text/WTFString.h" 42 #include "wtf/text/WTFString.h"
42 43
43 namespace WebCore { 44 namespace WebCore {
44 45
45 class CSSSelectorWatch : public DocumentSupplement { 46 class CSSSelectorWatch : public DocumentSupplement {
46 public: 47 public:
47 virtual ~CSSSelectorWatch() { } 48 virtual ~CSSSelectorWatch() { }
48 49
49 static CSSSelectorWatch& from(Document&); 50 static CSSSelectorWatch& from(Document&);
50 51
51 void watchCSSSelectors(const Vector<String>& selectors); 52 void watchCSSSelectors(const Vector<String>& selectors);
52 const Vector<RefPtr<StyleRule> >& watchedCallbackSelectors() const { return m_watchedCallbackSelectors; } 53 const Vector<RefPtr<StyleRule> >& watchedCallbackSelectors() const { return m_watchedCallbackSelectors; }
53 54
54 void updateSelectorMatches(const Vector<String>& removedSelectors, const Vec tor<String>& addedSelectors); 55 void updateSelectorMatches(const Vector<String>& removedSelectors, const Vec tor<String>& addedSelectors);
55 56
56 private: 57 private:
57 CSSSelectorWatch(Document&); 58 CSSSelectorWatch(Document&);
58 void callbackSelectorChangeTimerFired(Timer<CSSSelectorWatch>*); 59 void callbackSelectorChangeTimerFired(Timer<CSSSelectorWatch>*);
59 60
60 Document& m_document; 61 Document& m_document;
61 62
62 Vector<RefPtr<StyleRule> > m_watchedCallbackSelectors; 63 Vector<RefPtr<StyleRule> > m_watchedCallbackSelectors;
63 64
64 // Maps a CSS selector string with a -webkit-callback property to the number 65 // Maps a CSS selector string with a -webkit-callback property to the number
65 // of matching RenderStyle objects in this document. 66 // of matching RenderStyle objects in this document.
66 HashMap<String, int> m_matchingCallbackSelectors; 67 HashCountedSet<String> m_matchingCallbackSelectors;
67 // Selectors are relative to m_matchingCallbackSelectors's contents at 68 // Selectors are relative to m_matchingCallbackSelectors's contents at
68 // the previous call to selectorMatchChanged. 69 // the previous call to selectorMatchChanged.
69 HashSet<String> m_addedSelectors; 70 HashSet<String> m_addedSelectors;
70 HashSet<String> m_removedSelectors; 71 HashSet<String> m_removedSelectors;
71 72
72 Timer<CSSSelectorWatch> m_callbackSelectorChangeTimer; 73 Timer<CSSSelectorWatch> m_callbackSelectorChangeTimer;
73 74
74 // When an element is reparented, the new location's style is evaluated afte r the expriation of the relayout timer. 75 // When an element is reparented, the new location's style is evaluated afte r the expriation of the relayout timer.
75 // We don't want to send redundant callbacks to the embedder, so this counte r lets us wait another time around the event loop. 76 // We don't want to send redundant callbacks to the embedder, so this counte r lets us wait another time around the event loop.
76 int m_timerExpirations; 77 int m_timerExpirations;
77 }; 78 };
78 79
79 } // namespace WebCore 80 } // namespace WebCore
80 81
81 #endif // CSSSelectorWatch_h 82 #endif // CSSSelectorWatch_h
OLDNEW
« no previous file with comments | « no previous file | Source/core/dom/CSSSelectorWatch.cpp » ('j') | Source/core/dom/CSSSelectorWatch.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698