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

Side by Side Diff: Source/core/css/MediaQuery.cpp

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 * CSS Media Query 2 * CSS Media Query
3 * 3 *
4 * Copyright (C) 2005, 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>. 4 * Copyright (C) 2005, 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>.
5 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 5 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 } 61 }
62 62
63 result.append(m_expressions->at(0)->serialize()); 63 result.append(m_expressions->at(0)->serialize());
64 for (size_t i = 1; i < m_expressions->size(); ++i) { 64 for (size_t i = 1; i < m_expressions->size(); ++i) {
65 result.append(" and "); 65 result.append(" and ");
66 result.append(m_expressions->at(i)->serialize()); 66 result.append(m_expressions->at(i)->serialize());
67 } 67 }
68 return result.toString(); 68 return result.toString();
69 } 69 }
70 70
71 static bool expressionCompare(const OwnPtr<MediaQueryExp>& a, const OwnPtr<Media QueryExp>& b) 71 static bool expressionCompare(const OwnPtrWillBeMember<MediaQueryExp>& a, const OwnPtrWillBeMember<MediaQueryExp>& b)
72 { 72 {
73 return codePointCompare(a->serialize(), b->serialize()) < 0; 73 return codePointCompare(a->serialize(), b->serialize()) < 0;
74 } 74 }
75 75
76 MediaQuery::MediaQuery(Restrictor r, const AtomicString& mediaType, PassOwnPtr<E xpressionVector> expressions) 76 MediaQuery::MediaQuery(Restrictor r, const AtomicString& mediaType, PassOwnPtrWi llBeRawPtr<ExpressionHeapVector> expressions)
77 : m_restrictor(r) 77 : m_restrictor(r)
78 , m_mediaType(mediaType.lower()) 78 , m_mediaType(mediaType.lower())
79 , m_expressions(expressions) 79 , m_expressions(expressions)
80 { 80 {
81 if (!m_expressions) { 81 if (!m_expressions) {
82 m_expressions = adoptPtr(new ExpressionVector); 82 m_expressions = adoptPtrWillBeNoop(new ExpressionHeapVector);
83 return; 83 return;
84 } 84 }
85 85
86 nonCopyingSort(m_expressions->begin(), m_expressions->end(), expressionCompa re); 86 nonCopyingSort(m_expressions->begin(), m_expressions->end(), expressionCompa re);
87 87
88 // Remove all duplicated expressions. 88 // Remove all duplicated expressions.
89 MediaQueryExp* key = 0; 89 MediaQueryExp* key = 0;
90 for (int i = m_expressions->size() - 1; i >= 0; --i) { 90 for (int i = m_expressions->size() - 1; i >= 0; --i) {
91 MediaQueryExp* exp = m_expressions->at(i).get(); 91 MediaQueryExp* exp = m_expressions->at(i).get();
92 92
93 if (key && *exp == *key) 93 if (key && *exp == *key)
94 m_expressions->remove(i); 94 m_expressions->remove(i);
95 else 95 else
96 key = exp; 96 key = exp;
97 } 97 }
98 } 98 }
99 99
100 MediaQuery::MediaQuery(const MediaQuery& o) 100 MediaQuery::MediaQuery(const MediaQuery& o)
101 : m_restrictor(o.m_restrictor) 101 : m_restrictor(o.m_restrictor)
102 , m_mediaType(o.m_mediaType) 102 , m_mediaType(o.m_mediaType)
103 , m_expressions(adoptPtr(new ExpressionVector(o.m_expressions->size()))) 103 , m_expressions(adoptPtrWillBeNoop(new ExpressionHeapVector(o.m_expressions- >size())))
104 , m_serializationCache(o.m_serializationCache) 104 , m_serializationCache(o.m_serializationCache)
105 { 105 {
106 for (unsigned i = 0; i < m_expressions->size(); ++i) 106 for (unsigned i = 0; i < m_expressions->size(); ++i)
107 (*m_expressions)[i] = o.m_expressions->at(i)->copy(); 107 (*m_expressions)[i] = o.m_expressions->at(i)->copy();
108 } 108 }
109 109
110 MediaQuery::~MediaQuery() 110 MediaQuery::~MediaQuery()
111 { 111 {
112 } 112 }
113 113
114 // http://dev.w3.org/csswg/cssom/#compare-media-queries 114 // http://dev.w3.org/csswg/cssom/#compare-media-queries
115 bool MediaQuery::operator==(const MediaQuery& other) const 115 bool MediaQuery::operator==(const MediaQuery& other) const
116 { 116 {
117 return cssText() == other.cssText(); 117 return cssText() == other.cssText();
118 } 118 }
119 119
120 // http://dev.w3.org/csswg/cssom/#serialize-a-list-of-media-queries 120 // http://dev.w3.org/csswg/cssom/#serialize-a-list-of-media-queries
121 String MediaQuery::cssText() const 121 String MediaQuery::cssText() const
122 { 122 {
123 if (m_serializationCache.isNull()) 123 if (m_serializationCache.isNull())
124 const_cast<MediaQuery*>(this)->m_serializationCache = serialize(); 124 const_cast<MediaQuery*>(this)->m_serializationCache = serialize();
125 125
126 return m_serializationCache; 126 return m_serializationCache;
127 } 127 }
128 128
129 void MediaQuery::trace(Visitor* visitor)
130 {
131 // We don't support tracing of vectors of OwnPtrs (ie. OwnPtr<Vector<OwnPtr< MediaQuery> > >).
132 // Since this is a transitional object we are just ifdef'ing it out when oil pan is not enabled.
133 #if ENABLE(OILPAN)
134 visitor->trace(m_expressions);
135 #endif
129 } 136 }
137
138 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698