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

Side by Side Diff: Source/core/css/MediaQueryList.h

Issue 214383008: Rework MediaQueryMatcher to batch up listener notification (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 Nokia Corporation and/or its subsidiary(-ies) 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 20 matching lines...) Expand all
31 class MediaQueryEvaluator; 31 class MediaQueryEvaluator;
32 class MediaQueryMatcher; 32 class MediaQueryMatcher;
33 class MediaQuerySet; 33 class MediaQuerySet;
34 34
35 // MediaQueryList interface is specified at http://dev.w3.org/csswg/cssom-view/# the-mediaquerylist-interface 35 // MediaQueryList interface is specified at http://dev.w3.org/csswg/cssom-view/# the-mediaquerylist-interface
36 // The objects of this class are returned by window.matchMedia. They may be used to 36 // The objects of this class are returned by window.matchMedia. They may be used to
37 // retrieve the current value of the given media query and to add/remove listene rs that 37 // retrieve the current value of the given media query and to add/remove listene rs that
38 // will be called whenever the value of the query changes. 38 // will be called whenever the value of the query changes.
39 39
40 class MediaQueryList FINAL : public RefCountedWillBeGarbageCollected<MediaQueryL ist> { 40 class MediaQueryList FINAL : public RefCountedWillBeGarbageCollected<MediaQueryL ist> {
41 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(MediaQueryList);
42 public: 41 public:
43 static PassRefPtrWillBeRawPtr<MediaQueryList> create(PassRefPtrWillBeRawPtr< MediaQueryMatcher>, PassRefPtrWillBeRawPtr<MediaQuerySet>, bool); 42 static PassRefPtrWillBeRawPtr<MediaQueryList> create(PassRefPtrWillBeRawPtr< MediaQueryMatcher>, PassRefPtrWillBeRawPtr<MediaQuerySet>);
44 String media() const; 43 String media() const;
45 bool matches(); 44 bool matches();
46 45
47 void addListener(PassRefPtrWillBeRawPtr<MediaQueryListListener>); 46 void addListener(PassRefPtrWillBeRawPtr<MediaQueryListListener>);
48 void removeListener(PassRefPtrWillBeRawPtr<MediaQueryListListener>); 47 void removeListener(PassRefPtrWillBeRawPtr<MediaQueryListListener>);
49 48
50 bool evaluate(MediaQueryEvaluator*); 49 void mediaChanged(WillBeHeapVector<RefPtrWillBeMember<MediaQueryListListener > > toNotify);
51 50
52 void trace(Visitor*); 51 void trace(Visitor*);
53 52
53 void documentDetached();
54
54 private: 55 private:
55 MediaQueryList(PassRefPtrWillBeRawPtr<MediaQueryMatcher>, PassRefPtrWillBeRa wPtr<MediaQuerySet>, bool matches); 56 MediaQueryList(PassRefPtrWillBeRawPtr<MediaQueryMatcher>, PassRefPtrWillBeRa wPtr<MediaQuerySet>);
56 void setMatches(bool); 57 ~MediaQueryList();
58
59 bool updateMatches();
57 60
58 RefPtrWillBeMember<MediaQueryMatcher> m_matcher; 61 RefPtrWillBeMember<MediaQueryMatcher> m_matcher;
59 RefPtrWillBeMember<MediaQuerySet> m_media; 62 RefPtrWillBeMember<MediaQuerySet> m_media;
60 unsigned m_evaluationRound; // Indicates if the query has been evaluated aft er the last style selector change. 63
61 unsigned m_changeRound; // Used to know if the query has changed in the last style selector change. 64 // FIXME: This should be a HeapListHashSet when oilpan supports it.
65 ListHashSet<RefPtrWillBePersistent<MediaQueryListListener> > m_listeners;
66
67 bool m_matchesDirty;
62 bool m_matches; 68 bool m_matches;
63 }; 69 };
64 70
65 } 71 }
66 72
67 #endif // MediaQueryList_h 73 #endif // MediaQueryList_h
OLDNEW
« no previous file with comments | « no previous file | Source/core/css/MediaQueryList.cpp » ('j') | Source/core/css/MediaQueryMatcher.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698