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

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

Issue 214383008: Rework MediaQueryMatcher to batch up listener notification (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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: Source/core/css/MediaQueryMatcher.h
diff --git a/Source/core/css/MediaQueryMatcher.h b/Source/core/css/MediaQueryMatcher.h
index c8c066934a8d9423212d53cf270532fb63edf0a1..3e71052ed4376f78310c1e834cc1312908834f33 100644
--- a/Source/core/css/MediaQueryMatcher.h
+++ b/Source/core/css/MediaQueryMatcher.h
@@ -42,47 +42,33 @@ class MediaQuerySet;
class MediaQueryMatcher FINAL : public RefCountedWillBeGarbageCollected<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 addListener(PassRefPtrWillBeRawPtr<MediaQueryListListener>, PassRefPtrWillBeRawPtr<MediaQueryList>);
- void removeListener(MediaQueryListListener*, MediaQueryList*);
+ void documentDetached();
+
+ void addMediaQueryList(MediaQueryList*);
+ void removeMediaQueryList(MediaQueryList*);
PassRefPtrWillBeRawPtr<MediaQueryList> matchMedia(const String&);
- unsigned evaluationRound() const { return m_evaluationRound; }
- void styleResolverChanged();
+ void mediaChanged();
+
bool evaluate(const MediaQuerySet*);
void trace(Visitor*);
private:
- class Listener FINAL : public NoBaseWillBeGarbageCollected<Listener> {
- public:
- Listener(PassRefPtrWillBeRawPtr<MediaQueryListListener>, PassRefPtrWillBeRawPtr<MediaQueryList>);
- void evaluate(ScriptState*, MediaQueryEvaluator*);
-
- 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;
+ explicit MediaQueryMatcher(Document&);
AtomicString mediaType() const;
+ PassOwnPtr<MediaQueryEvaluator> createEvaluator() const;
+
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;
+ // FIXME: This should a HeapListHashSet.
+ typedef ListHashSet<RawPtrWillBeMember<MediaQueryList> > MediaQueryListSet;
+ MediaQueryListSet m_mediaLists;
};
}

Powered by Google App Engine
This is Rietveld 408576698