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

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

Issue 170283019: Change various helper classes to transition types to get CSSValue entirely onto the gc heap. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase and revert member to persistent in StorageEvent 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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> {
zerny-chromium 2014/03/05 06:38:40 +Finalized or remove the destructor.
wibling-chromium 2014/03/05 08:09:42 As you mentioned off-line yourself this is okay as
41 public: 42 public:
42 static PassRefPtr<MediaQuerySet> create() 43 static PassRefPtrWillBeRawPtr<MediaQuerySet> create()
43 { 44 {
44 return adoptRef(new MediaQuerySet()); 45 return adoptRefWillBeNoop(new MediaQuerySet());
45 } 46 }
46 static PassRefPtr<MediaQuerySet> create(const String& mediaString); 47 static PassRefPtrWillBeRawPtr<MediaQuerySet> create(const String& mediaStrin g);
47 ~MediaQuerySet(); 48 ~MediaQuerySet();
48 49
49 bool set(const String&); 50 bool set(const String&);
50 bool add(const String&); 51 bool add(const String&);
51 bool remove(const String&); 52 bool remove(const String&);
52 53
53 void addMediaQuery(PassOwnPtr<MediaQuery>); 54 void addMediaQuery(PassOwnPtrWillBeRawPtr<MediaQuery>);
54 55
55 const Vector<OwnPtr<MediaQuery> >& queryVector() const { return m_queries; } 56 const WillBeHeapVector<OwnPtrWillBeMember<MediaQuery> >& queryVector() const { return m_queries; }
56 57
57 String mediaText() const; 58 String mediaText() const;
58 59
59 PassRefPtr<MediaQuerySet> copy() const { return adoptRef(new MediaQuerySet(* this)); } 60 PassRefPtrWillBeRawPtr<MediaQuerySet> copy() const { return adoptRefWillBeNo op(new MediaQuerySet(*this)); }
61
62 void trace(Visitor*);
60 63
61 private: 64 private:
62 MediaQuerySet(); 65 MediaQuerySet();
63 MediaQuerySet(const MediaQuerySet&); 66 MediaQuerySet(const MediaQuerySet&);
64 67
65 Vector<OwnPtr<MediaQuery> > m_queries; 68 WillBeHeapVector<OwnPtrWillBeMember<MediaQuery> > m_queries;
66 }; 69 };
67 70
68 class MediaList : public RefCounted<MediaList> { 71 class MediaList : public RefCountedWillBeGarbageCollectedFinalized<MediaList> {
69 public: 72 public:
70 static PassRefPtr<MediaList> create(MediaQuerySet* mediaQueries, CSSStyleShe et* parentSheet) 73 static PassRefPtrWillBeRawPtr<MediaList> create(MediaQuerySet* mediaQueries, CSSStyleSheet* parentSheet)
71 { 74 {
72 return adoptRef(new MediaList(mediaQueries, parentSheet)); 75 return adoptRefWillBeNoop(new MediaList(mediaQueries, parentSheet));
73 } 76 }
74 static PassRefPtr<MediaList> create(MediaQuerySet* mediaQueries, CSSRule* pa rentRule) 77 static PassRefPtrWillBeRawPtr<MediaList> create(MediaQuerySet* mediaQueries, CSSRule* parentRule)
75 { 78 {
76 return adoptRef(new MediaList(mediaQueries, parentRule)); 79 return adoptRefWillBeNoop(new MediaList(mediaQueries, parentRule));
77 } 80 }
78 81
79 ~MediaList(); 82 ~MediaList();
80 83
81 unsigned length() const { return m_mediaQueries->queryVector().size(); } 84 unsigned length() const { return m_mediaQueries->queryVector().size(); }
82 String item(unsigned index) const; 85 String item(unsigned index) const;
83 void deleteMedium(const String& oldMedium, ExceptionState&); 86 void deleteMedium(const String& oldMedium, ExceptionState&);
84 void appendMedium(const String& newMedium, ExceptionState&); 87 void appendMedium(const String& newMedium, ExceptionState&);
85 88
86 String mediaText() const { return m_mediaQueries->mediaText(); } 89 String mediaText() const { return m_mediaQueries->mediaText(); }
87 void setMediaText(const String&); 90 void setMediaText(const String&);
88 91
89 // Not part of CSSOM. 92 // Not part of CSSOM.
90 CSSRule* parentRule() const { return m_parentRule; } 93 CSSRule* parentRule() const { return m_parentRule; }
91 CSSStyleSheet* parentStyleSheet() const { return m_parentStyleSheet; } 94 CSSStyleSheet* parentStyleSheet() const { return m_parentStyleSheet; }
92 void clearParentStyleSheet() { ASSERT(m_parentStyleSheet); m_parentStyleShee t = 0; } 95 void clearParentStyleSheet() { ASSERT(m_parentStyleSheet); m_parentStyleShee t = 0; }
93 void clearParentRule() { ASSERT(m_parentRule); m_parentRule = 0; } 96 void clearParentRule() { ASSERT(m_parentRule); m_parentRule = nullptr; }
94 const MediaQuerySet* queries() const { return m_mediaQueries.get(); } 97 const MediaQuerySet* queries() const { return m_mediaQueries.get(); }
95 98
96 void reattach(MediaQuerySet*); 99 void reattach(MediaQuerySet*);
97 100
101 void trace(Visitor*);
102
98 private: 103 private:
99 MediaList(); 104 MediaList();
100 MediaList(MediaQuerySet*, CSSStyleSheet* parentSheet); 105 MediaList(MediaQuerySet*, CSSStyleSheet* parentSheet);
101 MediaList(MediaQuerySet*, CSSRule* parentRule); 106 MediaList(MediaQuerySet*, CSSRule* parentRule);
102 107
103 RefPtr<MediaQuerySet> m_mediaQueries; 108 RefPtrWillBeMember<MediaQuerySet> m_mediaQueries;
109 // Cleared in ~CSSStyleSheet destructor.
104 CSSStyleSheet* m_parentStyleSheet; 110 CSSStyleSheet* m_parentStyleSheet;
105 // Cleared in the ~CSSMediaRule and ~CSSImportRule destructors. 111 // Cleared in the ~CSSMediaRule and ~CSSImportRule destructors when oilpan i s not enabled.
106 CSSRule* m_parentRule; 112 RawPtrWillBeMember<CSSRule> m_parentRule;
107 }; 113 };
108 114
109 // 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.
110 void reportMediaQueryWarningIfNeeded(Document*, const MediaQuerySet*); 116 void reportMediaQueryWarningIfNeeded(Document*, const MediaQuerySet*);
111 117
112 } // namespace 118 } // namespace
113 119
114 #endif 120 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698