Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2004, 2006, 2008, 2009, 2010, 2012 Apple Inc. All rights reserv ed. | 3 * Copyright (C) 2004, 2006, 2008, 2009, 2010, 2012 Apple Inc. All rights reserv ed. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
| 14 * | 14 * |
| 15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
| 16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
| 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
| 19 */ | 19 */ |
| 20 | 20 |
| 21 #ifndef MediaList_h | 21 #ifndef MediaList_h |
| 22 #define MediaList_h | 22 #define MediaList_h |
| 23 | 23 |
| 24 #include "core/dom/ExceptionCode.h" | 24 #include "core/dom/ExceptionCode.h" |
| 25 #include "heap/Handle.h" | |
| 25 #include "wtf/Forward.h" | 26 #include "wtf/Forward.h" |
| 26 #include "wtf/PassRefPtr.h" | 27 #include "wtf/PassRefPtr.h" |
| 27 #include "wtf/RefCounted.h" | 28 #include "wtf/RefCounted.h" |
| 28 #include "wtf/Vector.h" | 29 #include "wtf/Vector.h" |
| 29 #include "wtf/text/WTFString.h" | 30 #include "wtf/text/WTFString.h" |
| 30 | 31 |
| 31 namespace WebCore { | 32 namespace WebCore { |
| 32 | 33 |
| 33 class CSSRule; | 34 class CSSRule; |
| 34 class CSSStyleSheet; | 35 class CSSStyleSheet; |
| 35 class Document; | 36 class Document; |
| 36 class ExceptionState; | 37 class ExceptionState; |
| 37 class MediaList; | 38 class MediaList; |
| 38 class MediaQuery; | 39 class MediaQuery; |
| 39 | 40 |
| 40 class MediaQuerySet : public RefCounted<MediaQuerySet> { | 41 class MediaQuerySet : public RefCountedWillBeGarbageCollected<MediaQuerySet> { |
| 42 DECLARE_GC_INFO; | |
| 41 public: | 43 public: |
| 42 static PassRefPtr<MediaQuerySet> create() | 44 static PassRefPtrWillBeRawPtr<MediaQuerySet> create() |
| 43 { | 45 { |
| 44 return adoptRef(new MediaQuerySet()); | 46 return adoptRefWillBeNoop(new MediaQuerySet()); |
| 45 } | 47 } |
| 46 static PassRefPtr<MediaQuerySet> create(const String& mediaString); | 48 static PassRefPtrWillBeRawPtr<MediaQuerySet> create(const String& mediaStrin g); |
| 47 ~MediaQuerySet(); | 49 ~MediaQuerySet(); |
| 48 | 50 |
| 49 bool set(const String&); | 51 bool set(const String&); |
| 50 bool add(const String&); | 52 bool add(const String&); |
| 51 bool remove(const String&); | 53 bool remove(const String&); |
| 52 | 54 |
| 53 void addMediaQuery(PassOwnPtr<MediaQuery>); | 55 void addMediaQuery(PassOwnPtrWillBeRawPtr<MediaQuery>); |
| 54 | 56 |
| 55 const Vector<OwnPtr<MediaQuery> >& queryVector() const { return m_queries; } | 57 const WillBeHeapVector<OwnPtrWillBeMember<MediaQuery> >& queryVector() const { return m_queries; } |
| 56 | 58 |
| 57 String mediaText() const; | 59 String mediaText() const; |
| 58 | 60 |
| 59 PassRefPtr<MediaQuerySet> copy() const { return adoptRef(new MediaQuerySet(* this)); } | 61 PassRefPtrWillBeRawPtr<MediaQuerySet> copy() const { return adoptRefWillBeNo op(new MediaQuerySet(*this)); } |
| 62 | |
| 63 void trace(Visitor*); | |
| 60 | 64 |
| 61 private: | 65 private: |
| 62 MediaQuerySet(); | 66 MediaQuerySet(); |
| 63 MediaQuerySet(const MediaQuerySet&); | 67 MediaQuerySet(const MediaQuerySet&); |
| 64 | 68 |
| 65 Vector<OwnPtr<MediaQuery> > m_queries; | 69 WillBeHeapVector<OwnPtrWillBeMember<MediaQuery> > m_queries; |
| 66 }; | 70 }; |
| 67 | 71 |
| 68 class MediaList : public RefCounted<MediaList> { | 72 class MediaList : public RefCountedWillBeGarbageCollectedFinalized<MediaList> { |
| 73 DECLARE_GC_INFO; | |
| 69 public: | 74 public: |
| 70 static PassRefPtr<MediaList> create(MediaQuerySet* mediaQueries, CSSStyleShe et* parentSheet) | 75 static PassRefPtrWillBeRawPtr<MediaList> create(MediaQuerySet* mediaQueries, CSSStyleSheet* parentSheet) |
| 71 { | 76 { |
| 72 return adoptRef(new MediaList(mediaQueries, parentSheet)); | 77 return adoptRefWillBeNoop(new MediaList(mediaQueries, parentSheet)); |
| 73 } | 78 } |
| 74 static PassRefPtr<MediaList> create(MediaQuerySet* mediaQueries, CSSRule* pa rentRule) | 79 static PassRefPtrWillBeRawPtr<MediaList> create(MediaQuerySet* mediaQueries, CSSRule* parentRule) |
| 75 { | 80 { |
| 76 return adoptRef(new MediaList(mediaQueries, parentRule)); | 81 return adoptRefWillBeNoop(new MediaList(mediaQueries, parentRule)); |
| 77 } | 82 } |
| 78 | 83 |
| 79 ~MediaList(); | 84 ~MediaList(); |
| 80 | 85 |
| 81 unsigned length() const { return m_mediaQueries->queryVector().size(); } | 86 unsigned length() const { return m_mediaQueries->queryVector().size(); } |
| 82 String item(unsigned index) const; | 87 String item(unsigned index) const; |
| 83 void deleteMedium(const String& oldMedium, ExceptionState&); | 88 void deleteMedium(const String& oldMedium, ExceptionState&); |
| 84 void appendMedium(const String& newMedium, ExceptionState&); | 89 void appendMedium(const String& newMedium, ExceptionState&); |
| 85 | 90 |
| 86 String mediaText() const { return m_mediaQueries->mediaText(); } | 91 String mediaText() const { return m_mediaQueries->mediaText(); } |
| 87 void setMediaText(const String&); | 92 void setMediaText(const String&); |
| 88 | 93 |
| 89 // Not part of CSSOM. | 94 // Not part of CSSOM. |
| 90 CSSRule* parentRule() const { return m_parentRule; } | 95 CSSRule* parentRule() const { return m_parentRule; } |
| 91 CSSStyleSheet* parentStyleSheet() const { return m_parentStyleSheet; } | 96 CSSStyleSheet* parentStyleSheet() const { return m_parentStyleSheet; } |
| 92 void clearParentStyleSheet() { ASSERT(m_parentStyleSheet); m_parentStyleShee t = 0; } | 97 void clearParentStyleSheet() { ASSERT(m_parentStyleSheet); m_parentStyleShee t = 0; } |
| 93 void clearParentRule() { ASSERT(m_parentRule); m_parentRule = 0; } | 98 void clearParentRule() { ASSERT(m_parentRule); m_parentRule = 0; } |
| 94 const MediaQuerySet* queries() const { return m_mediaQueries.get(); } | 99 const MediaQuerySet* queries() const { return m_mediaQueries.get(); } |
| 95 | 100 |
| 96 void reattach(MediaQuerySet*); | 101 void reattach(MediaQuerySet*); |
| 97 | 102 |
| 103 void trace(Visitor*); | |
| 104 | |
| 98 private: | 105 private: |
| 99 MediaList(); | 106 MediaList(); |
| 100 MediaList(MediaQuerySet*, CSSStyleSheet* parentSheet); | 107 MediaList(MediaQuerySet*, CSSStyleSheet* parentSheet); |
| 101 MediaList(MediaQuerySet*, CSSRule* parentRule); | 108 MediaList(MediaQuerySet*, CSSRule* parentRule); |
| 102 | 109 |
| 103 RefPtr<MediaQuerySet> m_mediaQueries; | 110 RefPtrWillBeMember<MediaQuerySet> m_mediaQueries; |
| 104 CSSStyleSheet* m_parentStyleSheet; | 111 CSSStyleSheet* m_parentStyleSheet; |
| 105 CSSRule* m_parentRule; | 112 CSSRule* m_parentRule; |
|
haraken
2014/02/21 01:02:36
The lifetime of these raw pointers are a bit compl
wibling-chromium
2014/02/21 08:43:08
Yes, I will investigate it a bit further.
wibling-chromium
2014/02/25 12:07:28
From what I can tell there are three callers to Me
haraken
2014/02/25 12:09:57
Got it, thanks!
| |
| 106 }; | 113 }; |
| 107 | 114 |
| 108 // Adds message to inspector console whenever dpi or dpcm values are used for "s creen" media. | 115 // Adds message to inspector console whenever dpi or dpcm values are used for "s creen" media. |
| 109 void reportMediaQueryWarningIfNeeded(Document*, const MediaQuerySet*); | 116 void reportMediaQueryWarningIfNeeded(Document*, const MediaQuerySet*); |
| 110 | 117 |
| 111 } // namespace | 118 } // namespace |
| 112 | 119 |
| 113 #endif | 120 #endif |
| OLD | NEW |