| OLD | NEW |
| 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 19 matching lines...) Expand all Loading... |
| 30 PassRefPtrWillBeRawPtr<MediaQueryList> MediaQueryList::create(PassRefPtrWillBeRa
wPtr<MediaQueryMatcher> matcher, PassRefPtrWillBeRawPtr<MediaQuerySet> media) | 30 PassRefPtrWillBeRawPtr<MediaQueryList> MediaQueryList::create(PassRefPtrWillBeRa
wPtr<MediaQueryMatcher> matcher, PassRefPtrWillBeRawPtr<MediaQuerySet> media) |
| 31 { | 31 { |
| 32 return adoptRefWillBeNoop(new MediaQueryList(matcher, media)); | 32 return adoptRefWillBeNoop(new MediaQueryList(matcher, media)); |
| 33 } | 33 } |
| 34 | 34 |
| 35 MediaQueryList::MediaQueryList(PassRefPtrWillBeRawPtr<MediaQueryMatcher> matcher
, PassRefPtrWillBeRawPtr<MediaQuerySet> media) | 35 MediaQueryList::MediaQueryList(PassRefPtrWillBeRawPtr<MediaQueryMatcher> matcher
, PassRefPtrWillBeRawPtr<MediaQuerySet> media) |
| 36 : m_matcher(matcher) | 36 : m_matcher(matcher) |
| 37 , m_media(media) | 37 , m_media(media) |
| 38 , m_matchesDirty(true) | 38 , m_matchesDirty(true) |
| 39 , m_matches(false) | 39 , m_matches(false) |
| 40 , m_alwaysUpdate(false) |
| 40 { | 41 { |
| 41 m_matcher->addMediaQueryList(this); | 42 m_matcher->addMediaQueryList(this); |
| 42 updateMatches(); | 43 updateMatches(); |
| 43 } | 44 } |
| 44 | 45 |
| 45 MediaQueryList::~MediaQueryList() | 46 MediaQueryList::~MediaQueryList() |
| 46 { | 47 { |
| 47 #if !ENABLE(OILPAN) | 48 #if !ENABLE(OILPAN) |
| 48 m_matcher->removeMediaQueryList(this); | 49 m_matcher->removeMediaQueryList(this); |
| 49 #endif | 50 #endif |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 if (!updateMatches()) | 93 if (!updateMatches()) |
| 93 return; | 94 return; |
| 94 for (ListenerList::const_iterator it = m_listeners.begin(), end = m_listener
s.end(); it != end; ++it) { | 95 for (ListenerList::const_iterator it = m_listeners.begin(), end = m_listener
s.end(); it != end; ++it) { |
| 95 listenersToNotify->append(*it); | 96 listenersToNotify->append(*it); |
| 96 } | 97 } |
| 97 } | 98 } |
| 98 | 99 |
| 99 bool MediaQueryList::updateMatches() | 100 bool MediaQueryList::updateMatches() |
| 100 { | 101 { |
| 101 m_matchesDirty = false; | 102 m_matchesDirty = false; |
| 102 if (m_matches != m_matcher->evaluate(m_media.get())) { | 103 if (m_alwaysUpdate || m_matches != m_matcher->evaluate(m_media.get())) { |
| 103 m_matches = !m_matches; | 104 m_matches = !m_matches; |
| 104 return true; | 105 return true; |
| 105 } | 106 } |
| 106 return false; | 107 return false; |
| 107 } | 108 } |
| 108 | 109 |
| 109 bool MediaQueryList::matches() | 110 bool MediaQueryList::matches() |
| 110 { | 111 { |
| 111 updateMatches(); | 112 updateMatches(); |
| 112 return m_matches; | 113 return m_matches; |
| 113 } | 114 } |
| 114 | 115 |
| 115 void MediaQueryList::trace(Visitor* visitor) | 116 void MediaQueryList::trace(Visitor* visitor) |
| 116 { | 117 { |
| 117 visitor->trace(m_matcher); | 118 visitor->trace(m_matcher); |
| 118 visitor->trace(m_media); | 119 visitor->trace(m_media); |
| 119 visitor->trace(m_listeners); | 120 visitor->trace(m_listeners); |
| 120 } | 121 } |
| 121 | 122 |
| 122 } | 123 } |
| OLD | NEW |