Diff
Modified: trunk/Source/WebCore/ChangeLog (163384 => 163385)
--- trunk/Source/WebCore/ChangeLog 2014-02-04 17:56:11 UTC (rev 163384)
+++ trunk/Source/WebCore/ChangeLog 2014-02-04 18:00:11 UTC (rev 163385)
@@ -1,3 +1,37 @@
+2014-02-03 Zan Dobersek <zdober...@igalia.com>
+
+ Manage MediaQuery and MediaQueryExp classes through std::unique_ptr instead of OwnPtr
+ https://bugs.webkit.org/show_bug.cgi?id=128117
+
+ Reviewed by Darin Adler.
+
+ Replace uses of OwnPtr for the MediaQuery and MediaQueryExp classes with std::unique_ptr.
+
+ * css/CSSGrammar.y.in:
+ * css/CSSParser.cpp:
+ (WebCore::CSSParser::parseMediaQuery):
+ * css/CSSParser.h:
+ * css/MediaList.cpp:
+ (WebCore::MediaQuerySet::parse):
+ (WebCore::MediaQuerySet::add):
+ (WebCore::MediaQuerySet::remove):
+ (WebCore::MediaQuerySet::addMediaQuery):
+ (WebCore::MediaList::item):
+ (WebCore::reportMediaQueryWarningIfNeeded):
+ * css/MediaList.h:
+ (WebCore::MediaQuerySet::queryVector):
+ * css/MediaQuery.cpp:
+ (WebCore::MediaQuery::MediaQuery):
+ * css/MediaQuery.h:
+ (WebCore::MediaQuery::expressions):
+ (WebCore::MediaQuery::copy):
+ * css/MediaQueryEvaluator.cpp:
+ (WebCore::MediaQueryEvaluator::eval):
+ * css/MediaQueryExp.cpp:
+ (WebCore::MediaQueryExp::MediaQueryExp):
+ * css/MediaQueryExp.h:
+ (WebCore::MediaQueryExp::copy):
+
2014-02-04 Tamas Gergely <tgergely.u-sze...@partner.samsung.com>
Remove SVG_DOM_OBJC_BINDINGS after r161638.
Modified: trunk/Source/WebCore/css/CSSGrammar.y.in (163384 => 163385)
--- trunk/Source/WebCore/css/CSSGrammar.y.in 2014-02-04 17:56:11 UTC (rev 163384)
+++ trunk/Source/WebCore/css/CSSGrammar.y.in 2014-02-04 18:00:11 UTC (rev 163385)
@@ -210,7 +210,7 @@
%type <mediaQueryExp> media_query_exp
%destructor { delete $$; } media_query_exp
-%union { Vector<OwnPtr<MediaQueryExp>>* mediaQueryExpList; }
+%union { Vector<std::unique_ptr<MediaQueryExp>>* mediaQueryExpList; }
%type <mediaQueryExpList> media_query_exp_list maybe_and_media_query_exp_list
%destructor { delete $$; } media_query_exp_list maybe_and_media_query_exp_list
@@ -326,7 +326,7 @@
}
;
-webkit_mediaquery: WEBKIT_MEDIAQUERY_SYM WHITESPACE maybe_space media_query '}' { parser->m_mediaQuery = adoptPtr($4); } ;
+webkit_mediaquery: WEBKIT_MEDIAQUERY_SYM WHITESPACE maybe_space media_query '}' { parser->m_mediaQuery = std::move(std::unique_ptr<MediaQuery>($4)); } ;
webkit_selector:
WEBKIT_SELECTOR_SYM '{' maybe_space selector_list '}' {
@@ -503,28 +503,28 @@
// Create empty media query _expression_ and continue parsing media query.
OwnPtr<CSSParserValueList> mediaValue = adoptPtr($7);
if ($1 != MediaQuery::None)
- $$ = MediaQueryExp::create(emptyString(), nullptr).leakPtr();
+ $$ = new MediaQueryExp(emptyString(), nullptr);
else {
$5.lower();
- $$ = MediaQueryExp::create($5, mediaValue.get()).leakPtr();
+ $$ = new MediaQueryExp($5, mediaValue.get());
}
}
;
media_query_exp_list:
media_query_exp {
- $$ = new Vector<OwnPtr<MediaQueryExp>>;
- $$->append(adoptPtr($1));
+ $$ = new Vector<std::unique_ptr<MediaQueryExp>>;
+ $$->append(std::unique_ptr<MediaQueryExp>($1));
}
| media_query_exp_list maybe_space MEDIA_AND maybe_space media_query_exp {
$$ = $1;
- $$->append(adoptPtr($5));
+ $$->append(std::unique_ptr<MediaQueryExp>($5));
}
;
maybe_and_media_query_exp_list:
/*empty*/ {
- $$ = new Vector<OwnPtr<MediaQueryExp>>;
+ $$ = new Vector<std::unique_ptr<MediaQueryExp>>;
}
| MEDIA_AND maybe_space media_query_exp_list {
$$ = $3;
@@ -545,12 +545,12 @@
media_query:
media_query_exp_list {
- $$ = new MediaQuery(MediaQuery::None, "all", adoptPtr($1));
+ $$ = new MediaQuery(MediaQuery::None, "all", std::unique_ptr<Vector<std::unique_ptr<MediaQueryExp>>>($1));
}
|
maybe_media_restrictor maybe_space IDENT maybe_space maybe_and_media_query_exp_list {
$3.lower();
- $$ = new MediaQuery($1, $3, adoptPtr($5));
+ $$ = new MediaQuery($1, $3, std::unique_ptr<Vector<std::unique_ptr<MediaQueryExp>>>($5));
}
;
@@ -559,14 +559,14 @@
media_list:
media_query {
$$ = MediaQuerySet::create().leakRef();
- $$->addMediaQuery(adoptPtr($1));
+ $$->addMediaQuery(std::unique_ptr<MediaQuery>($1));
parser->updateLastMediaLine($$);
}
| media_list ',' maybe_space media_query {
$$ = $1;
- OwnPtr<MediaQuery> mediaQuery = adoptPtr($4);
+ std::unique_ptr<MediaQuery> mediaQuery($4);
if ($$) {
- $$->addMediaQuery(mediaQuery.release());
+ $$->addMediaQuery(std::move(mediaQuery));
parser->updateLastMediaLine($$);
}
}
Modified: trunk/Source/WebCore/css/CSSParser.cpp (163384 => 163385)
--- trunk/Source/WebCore/css/CSSParser.cpp 2014-02-04 17:56:11 UTC (rev 163384)
+++ trunk/Source/WebCore/css/CSSParser.cpp 2014-02-04 18:00:11 UTC (rev 163385)
@@ -1455,7 +1455,7 @@
return ok;
}
-PassOwnPtr<MediaQuery> CSSParser::parseMediaQuery(const String& string)
+std::unique_ptr<MediaQuery> CSSParser::parseMediaQuery(const String& string)
{
if (string.isEmpty())
return nullptr;
@@ -1467,7 +1467,7 @@
setupParser("@-webkit-mediaquery ", string, "} ");
cssyyparse(this);
- return m_mediaQuery.release();
+ return std::move(m_mediaQuery);
}
static inline void filterProperties(bool important, const CSSParser::ParsedPropertyVector& input, Vector<CSSProperty, 256>& output, size_t& unusedEntries, std::bitset<numCSSProperties>& seenProperties)
Modified: trunk/Source/WebCore/css/CSSParser.h (163384 => 163385)
--- trunk/Source/WebCore/css/CSSParser.h 2014-02-04 17:56:11 UTC (rev 163384)
+++ trunk/Source/WebCore/css/CSSParser.h 2014-02-04 18:00:11 UTC (rev 163385)
@@ -94,7 +94,7 @@
PassRefPtr<CSSPrimitiveValue> parseValidPrimitive(CSSValueID ident, CSSParserValue*);
bool parseDeclaration(MutableStyleProperties*, const String&, PassRefPtr<CSSRuleSourceData>, StyleSheetContents* contextStyleSheet);
static PassRef<ImmutableStyleProperties> parseInlineStyleDeclaration(const String&, Element*);
- PassOwnPtr<MediaQuery> parseMediaQuery(const String&);
+ std::unique_ptr<MediaQuery> parseMediaQuery(const String&);
void addPropertyWithPrefixingVariant(CSSPropertyID, PassRefPtr<CSSValue>, bool important, bool implicit = false);
void addProperty(CSSPropertyID, PassRefPtr<CSSValue>, bool important, bool implicit = false);
@@ -337,7 +337,7 @@
StyleSheetContents* m_styleSheet;
RefPtr<StyleRuleBase> m_rule;
RefPtr<StyleKeyframe> m_keyframe;
- OwnPtr<MediaQuery> m_mediaQuery;
+ std::unique_ptr<MediaQuery> m_mediaQuery;
OwnPtr<CSSParserValueList> m_valueList;
#if ENABLE(CSS3_CONDITIONAL_RULES)
bool m_supportsCondition;
Modified: trunk/Source/WebCore/css/MediaList.cpp (163384 => 163385)
--- trunk/Source/WebCore/css/MediaList.cpp 2014-02-04 17:56:11 UTC (rev 163384)
+++ trunk/Source/WebCore/css/MediaList.cpp 2014-02-04 18:00:11 UTC (rev 163385)
@@ -125,7 +125,7 @@
{
CSSParser parser(CSSStrictMode);
- Vector<OwnPtr<MediaQuery>> result;
+ Vector<std::unique_ptr<MediaQuery>> result;
Vector<String> list;
mediaString.split(',', list);
for (unsigned i = 0; i < list.size(); ++i) {
@@ -135,16 +135,16 @@
return false;
continue;
}
- OwnPtr<MediaQuery> mediaQuery = parser.parseMediaQuery(medium);
+ std::unique_ptr<MediaQuery> mediaQuery = parser.parseMediaQuery(medium);
if (!mediaQuery) {
if (!m_fallbackToDescriptor)
return false;
String mediaDescriptor = parseMediaDescriptor(medium);
if (mediaDescriptor.isNull())
continue;
- mediaQuery = adoptPtr(new MediaQuery(MediaQuery::None, mediaDescriptor, nullptr));
+ mediaQuery = std::make_unique<MediaQuery>(MediaQuery::None, mediaDescriptor, nullptr);
}
- result.append(mediaQuery.release());
+ result.append(std::move(mediaQuery));
}
// ",,,," falls straight through, but is not valid unless fallback
if (!m_fallbackToDescriptor && list.isEmpty()) {
@@ -152,7 +152,7 @@
if (!strippedMediaString.isEmpty())
return false;
}
- m_queries.swap(result);
+ m_queries = std::move(result);
return true;
}
@@ -160,16 +160,16 @@
{
CSSParser parser(CSSStrictMode);
- OwnPtr<MediaQuery> parsedQuery = parser.parseMediaQuery(queryString);
+ std::unique_ptr<MediaQuery> parsedQuery = parser.parseMediaQuery(queryString);
if (!parsedQuery && m_fallbackToDescriptor) {
String medium = parseMediaDescriptor(queryString);
if (!medium.isNull())
- parsedQuery = adoptPtr(new MediaQuery(MediaQuery::None, medium, nullptr));
+ parsedQuery = std::make_unique<MediaQuery>(MediaQuery::None, medium, nullptr);
}
if (!parsedQuery)
return false;
- m_queries.append(parsedQuery.release());
+ m_queries.append(std::move(parsedQuery));
return true;
}
@@ -177,11 +177,11 @@
{
CSSParser parser(CSSStrictMode);
- OwnPtr<MediaQuery> parsedQuery = parser.parseMediaQuery(queryStringToRemove);
+ std::unique_ptr<MediaQuery> parsedQuery = parser.parseMediaQuery(queryStringToRemove);
if (!parsedQuery && m_fallbackToDescriptor) {
String medium = parseMediaDescriptor(queryStringToRemove);
if (!medium.isNull())
- parsedQuery = adoptPtr(new MediaQuery(MediaQuery::None, medium, nullptr));
+ parsedQuery = std::make_unique<MediaQuery>(MediaQuery::None, medium, nullptr);
}
if (!parsedQuery)
return false;
@@ -196,9 +196,9 @@
return false;
}
-void MediaQuerySet::addMediaQuery(PassOwnPtr<MediaQuery> mediaQuery)
+void MediaQuerySet::addMediaQuery(std::unique_ptr<MediaQuery> mediaQuery)
{
- m_queries.append(mediaQuery);
+ m_queries.append(std::move(mediaQuery));
}
String MediaQuerySet::mediaText() const
@@ -249,7 +249,7 @@
String MediaList::item(unsigned index) const
{
- const Vector<OwnPtr<MediaQuery>>& queries = m_mediaQueries->queryVector();
+ auto& queries = m_mediaQueries->queryVector();
if (index < queries.size())
return queries[index]->cssText();
return String();
@@ -318,7 +318,7 @@
if (!mediaQuerySet || !document)
return;
- const Vector<OwnPtr<MediaQuery>>& mediaQueries = mediaQuerySet->queryVector();
+ auto& mediaQueries = mediaQuerySet->queryVector();
const size_t queryCount = mediaQueries.size();
if (!queryCount)
@@ -328,7 +328,7 @@
const MediaQuery* query = mediaQueries[i].get();
String mediaType = query->mediaType();
if (!query->ignored() && !equalIgnoringCase(mediaType, "print")) {
- const Vector<OwnPtr<MediaQueryExp>>& expressions = query->expressions();
+ auto& expressions = query->expressions();
for (size_t j = 0; j < expressions.size(); ++j) {
const MediaQueryExp* exp = expressions.at(j).get();
if (exp->mediaFeature() == MediaFeatureNames::resolutionMediaFeature || exp->mediaFeature() == MediaFeatureNames::max_resolutionMediaFeature || exp->mediaFeature() == MediaFeatureNames::min_resolutionMediaFeature) {
Modified: trunk/Source/WebCore/css/MediaList.h (163384 => 163385)
--- trunk/Source/WebCore/css/MediaList.h 2014-02-04 17:56:11 UTC (rev 163384)
+++ trunk/Source/WebCore/css/MediaList.h 2014-02-04 18:00:11 UTC (rev 163385)
@@ -22,6 +22,7 @@
#define MediaList_h
#include "ExceptionCode.h"
+#include <memory>
#include <wtf/Forward.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
@@ -56,9 +57,9 @@
bool add(const String&);
bool remove(const String&);
- void addMediaQuery(PassOwnPtr<MediaQuery>);
+ void addMediaQuery(std::unique_ptr<MediaQuery>);
- const Vector<OwnPtr<MediaQuery>>& queryVector() const { return m_queries; }
+ const Vector<std::unique_ptr<MediaQuery>>& queryVector() const { return m_queries; }
int lastLine() const { return m_lastLine; }
void setLastLine(int lastLine) { m_lastLine = lastLine; }
@@ -74,7 +75,7 @@
unsigned m_fallbackToDescriptor : 1; // true if failed media query parsing should fallback to media description parsing.
signed m_lastLine : 31;
- Vector<OwnPtr<MediaQuery>> m_queries;
+ Vector<std::unique_ptr<MediaQuery>> m_queries;
};
class MediaList : public RefCounted<MediaList> {
Modified: trunk/Source/WebCore/css/MediaQuery.cpp (163384 => 163385)
--- trunk/Source/WebCore/css/MediaQuery.cpp 2014-02-04 17:56:11 UTC (rev 163384)
+++ trunk/Source/WebCore/css/MediaQuery.cpp 2014-02-04 18:00:11 UTC (rev 163385)
@@ -72,18 +72,18 @@
return result.toString();
}
-MediaQuery::MediaQuery(Restrictor r, const String& mediaType, PassOwnPtr<ExpressionVector> exprs)
+MediaQuery::MediaQuery(Restrictor r, const String& mediaType, std::unique_ptr<ExpressionVector> exprs)
: m_restrictor(r)
, m_mediaType(mediaType.lower())
- , m_expressions(exprs)
+ , m_expressions(std::move(exprs))
, m_ignored(false)
{
if (!m_expressions) {
- m_expressions = adoptPtr(new ExpressionVector);
+ m_expressions = std::make_unique<ExpressionVector>();
return;
}
- std::sort(m_expressions->begin(), m_expressions->end(), [](const OwnPtr<MediaQueryExp>& a, const OwnPtr<MediaQueryExp>& b) {
+ std::sort(m_expressions->begin(), m_expressions->end(), [](const std::unique_ptr<MediaQueryExp>& a, const std::unique_ptr<MediaQueryExp>& b) {
return codePointCompare(a->serialize(), b->serialize()) < 0;
});
@@ -105,12 +105,12 @@
MediaQuery::MediaQuery(const MediaQuery& o)
: m_restrictor(o.m_restrictor)
, m_mediaType(o.m_mediaType)
- , m_expressions(adoptPtr(new ExpressionVector(o.m_expressions->size())))
+ , m_expressions(std::make_unique<ExpressionVector>(o.m_expressions->size()))
, m_ignored(o.m_ignored)
, m_serializationCache(o.m_serializationCache)
{
for (unsigned i = 0; i < m_expressions->size(); ++i)
- (*m_expressions)[i] = o.m_expressions->at(i)->copy();
+ (*m_expressions)[i] = std::move(o.m_expressions->at(i)->copy());
}
MediaQuery::~MediaQuery()
Modified: trunk/Source/WebCore/css/MediaQuery.h (163384 => 163385)
--- trunk/Source/WebCore/css/MediaQuery.h 2014-02-04 17:56:11 UTC (rev 163384)
+++ trunk/Source/WebCore/css/MediaQuery.h 2014-02-04 18:00:11 UTC (rev 163385)
@@ -29,7 +29,7 @@
#ifndef MediaQuery_h
#define MediaQuery_h
-#include <wtf/PassOwnPtr.h>
+#include <memory>
#include <wtf/Vector.h>
#include <wtf/text/StringHash.h>
#include <wtf/text/WTFString.h>
@@ -44,26 +44,25 @@
Only, Not, None
};
- typedef Vector<OwnPtr<MediaQueryExp>> ExpressionVector;
+ typedef Vector<std::unique_ptr<MediaQueryExp>> ExpressionVector;
- MediaQuery(Restrictor, const String& mediaType, PassOwnPtr<Vector<OwnPtr<MediaQueryExp>>> exprs);
+ MediaQuery(Restrictor, const String& mediaType, std::unique_ptr<Vector<std::unique_ptr<MediaQueryExp>>> exprs);
+ MediaQuery(const MediaQuery&);
~MediaQuery();
Restrictor restrictor() const { return m_restrictor; }
- const Vector<OwnPtr<MediaQueryExp>>& expressions() const { return *m_expressions; }
+ const Vector<std::unique_ptr<MediaQueryExp>>& expressions() const { return *m_expressions; }
String mediaType() const { return m_mediaType; }
bool operator==(const MediaQuery& other) const;
String cssText() const;
bool ignored() const { return m_ignored; }
- PassOwnPtr<MediaQuery> copy() const { return adoptPtr(new MediaQuery(*this)); }
+ std::unique_ptr<MediaQuery> copy() const { return std::make_unique<MediaQuery>(*this); }
private:
- MediaQuery(const MediaQuery&);
-
Restrictor m_restrictor;
String m_mediaType;
- OwnPtr<ExpressionVector> m_expressions;
+ std::unique_ptr<ExpressionVector> m_expressions;
bool m_ignored;
String m_serializationCache;
Modified: trunk/Source/WebCore/css/MediaQueryEvaluator.cpp (163384 => 163385)
--- trunk/Source/WebCore/css/MediaQueryEvaluator.cpp 2014-02-04 17:56:11 UTC (rev 163384)
+++ trunk/Source/WebCore/css/MediaQueryEvaluator.cpp 2014-02-04 18:00:11 UTC (rev 163385)
@@ -134,7 +134,7 @@
if (!querySet)
return true;
- const Vector<OwnPtr<MediaQuery>>& queries = querySet->queryVector();
+ auto& queries = querySet->queryVector();
if (!queries.size())
return true; // empty query list evaluates to true
@@ -147,7 +147,7 @@
continue;
if (mediaTypeMatch(query->mediaType())) {
- const Vector<OwnPtr<MediaQueryExp>>& expressions = query->expressions();
+ auto& expressions = query->expressions();
// iterate through expressions, stop if any of them eval to false
// (AND semantics)
size_t j = 0;
Modified: trunk/Source/WebCore/css/MediaQueryExp.cpp (163384 => 163385)
--- trunk/Source/WebCore/css/MediaQueryExp.cpp 2014-02-04 17:56:11 UTC (rev 163384)
+++ trunk/Source/WebCore/css/MediaQueryExp.cpp 2014-02-04 18:00:11 UTC (rev 163385)
@@ -154,7 +154,7 @@
|| mediaFeature == MediaFeatureNames::resolutionMediaFeature;
}
-inline MediaQueryExp::MediaQueryExp(const AtomicString& mediaFeature, CSSParserValueList* valueList)
+MediaQueryExp::MediaQueryExp(const AtomicString& mediaFeature, CSSParserValueList* valueList)
: m_mediaFeature(mediaFeature)
, m_value(0)
, m_isValid(false)
@@ -222,11 +222,6 @@
m_isValid = true;
}
-PassOwnPtr<MediaQueryExp> MediaQueryExp::create(const AtomicString& mediaFeature, CSSParserValueList* values)
-{
- return adoptPtr(new MediaQueryExp(mediaFeature, values));
-}
-
MediaQueryExp::~MediaQueryExp()
{
}
Modified: trunk/Source/WebCore/css/MediaQueryExp.h (163384 => 163385)
--- trunk/Source/WebCore/css/MediaQueryExp.h 2014-02-04 17:56:11 UTC (rev 163384)
+++ trunk/Source/WebCore/css/MediaQueryExp.h 2014-02-04 18:00:11 UTC (rev 163385)
@@ -31,7 +31,7 @@
#include "CSSValue.h"
#include "MediaFeatureNames.h"
-#include <wtf/PassOwnPtr.h>
+#include <memory>
#include <wtf/RefPtr.h>
#include <wtf/text/AtomicString.h>
@@ -41,7 +41,7 @@
class MediaQueryExp {
WTF_MAKE_FAST_ALLOCATED;
public:
- static PassOwnPtr<MediaQueryExp> create(const AtomicString& mediaFeature, CSSParserValueList* values);
+ MediaQueryExp(const AtomicString& mediaFeature, CSSParserValueList* values);
~MediaQueryExp();
AtomicString mediaFeature() const { return m_mediaFeature; }
@@ -70,11 +70,9 @@
String serialize() const;
- PassOwnPtr<MediaQueryExp> copy() const { return adoptPtr(new MediaQueryExp(*this)); }
+ std::unique_ptr<MediaQueryExp> copy() const { return std::make_unique<MediaQueryExp>(*this); }
private:
- MediaQueryExp(const AtomicString& mediaFeature, CSSParserValueList* values);
-
AtomicString m_mediaFeature;
RefPtr<CSSValue> m_value;
bool m_isValid;