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

Unified Diff: Source/core/css/MediaQueryMatcher.h

Issue 348893004: Rework MediaQueryMatcher to batch up listener notification (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: now with it Created 6 years, 6 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
« no previous file with comments | « Source/core/css/MediaQueryListListener.cpp ('k') | Source/core/css/MediaQueryMatcher.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/MediaQueryMatcher.h
diff --git a/Source/core/css/MediaQueryMatcher.h b/Source/core/css/MediaQueryMatcher.h
index abe862883b5c963708cf613ee92361dfff554b2f..35855325c0bbcd4314fa4b38406c9021bcc06cb8 100644
--- a/Source/core/css/MediaQueryMatcher.h
+++ b/Source/core/css/MediaQueryMatcher.h
@@ -38,50 +38,34 @@ class MediaQuerySet;
// whenever it is needed and to call the listeners if the corresponding query has changed.
// The listeners must be called in the very same order in which they have been added.
-class MediaQueryMatcher FINAL : public RefCountedWillBeGarbageCollected<MediaQueryMatcher> {
+class MediaQueryMatcher FINAL : public RefCountedWillBeGarbageCollectedFinalized<MediaQueryMatcher> {
DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(MediaQueryMatcher);
public:
- static PassRefPtrWillBeRawPtr<MediaQueryMatcher> create(Document* document) { return adoptRefWillBeNoop(new MediaQueryMatcher(document)); }
- void documentDestroyed();
+ static PassRefPtrWillBeRawPtr<MediaQueryMatcher> create(Document& document) { return adoptRefWillBeNoop(new MediaQueryMatcher(document)); }
+ void documentDetached();
- void addListener(PassRefPtrWillBeRawPtr<MediaQueryListListener>, PassRefPtrWillBeRawPtr<MediaQueryList>);
- void removeListener(MediaQueryListListener*, MediaQueryList*);
+ void addMediaQueryList(MediaQueryList*);
+ void removeMediaQueryList(MediaQueryList*);
PassRefPtrWillBeRawPtr<MediaQueryList> matchMedia(const String&);
- unsigned evaluationRound() const { return m_evaluationRound; }
- void styleResolverChanged();
+ void mediaFeaturesChanged();
bool evaluate(const MediaQuerySet*);
void trace(Visitor*);
private:
- class Listener FINAL : public NoBaseWillBeGarbageCollected<Listener> {
- public:
- Listener(PassRefPtrWillBeRawPtr<MediaQueryListListener>, PassRefPtrWillBeRawPtr<MediaQueryList>);
- void evaluate(MediaQueryEvaluator*);
+ explicit MediaQueryMatcher(Document&);
- MediaQueryListListener* listener() { return m_listener.get(); }
- MediaQueryList* query() { return m_query.get(); }
-
- void trace(Visitor*);
-
- private:
- RefPtrWillBeMember<MediaQueryListListener> m_listener;
- RefPtrWillBeMember<MediaQueryList> m_query;
- };
-
- MediaQueryMatcher(Document*);
- PassOwnPtr<MediaQueryEvaluator> prepareEvaluator() const;
AtomicString mediaType() const;
+ PassOwnPtr<MediaQueryEvaluator> createEvaluator() const;
+
RawPtrWillBeMember<Document> m_document;
- WillBeHeapVector<OwnPtrWillBeMember<Listener> > m_listeners;
+ OwnPtr<MediaQueryEvaluator> m_evaluator;
- // This value is incremented at style selector changes.
- // It is used to avoid evaluating queries more then once and to make sure
- // that a media query result change is notified exactly once.
- unsigned m_evaluationRound;
+ typedef WillBeHeapLinkedHashSet<RawPtrWillBeWeakMember<MediaQueryList> > MediaQueryListSet;
+ MediaQueryListSet m_mediaLists;
};
}
« no previous file with comments | « Source/core/css/MediaQueryListListener.cpp ('k') | Source/core/css/MediaQueryMatcher.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698