<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[179476] trunk/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/179476">179476</a></dd>
<dt>Author</dt> <dd>darin@apple.com</dd>
<dt>Date</dt> <dd>2015-02-02 10:12:32 -0800 (Mon, 02 Feb 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>REGRESSION (<a href="http://trac.webkit.org/projects/webkit/changeset/170576">r170576</a>): Storage leaks in parsing of CSS image sizes
https://bugs.webkit.org/show_bug.cgi?id=141026
Reviewed by Anders Carlsson.
* css/CSSGrammar.y.in: Fixed all the shift/reduce conflicts caused
by the ENABLE_PICTURE_SIZES code by removing all the redundant
maybe_space which caused them. Rearranged the productions for
ENABLE_PICTURE_SIZES to tighten up the code quite a bit. Changed
the code to build up the source size vector as a Vector instead of
a special class, and use the SourceSize struct from inside the
CSSParser class.'
* css/CSSParser.cpp:
(WebCore::CSSParser::setupParser): Changed this to take a StringView.
In the future we can change all the parsing functions to take StringView,
since they don't work with the String in place.
(WebCore::CSSParser::parseSizesAttribute): Changed to return a vector
of SourceSize instead of a SourceSizeList. This is better because it's
a real CSS data structure that does not contain a CSSParserValue.
(WebCore::CSSParser::sourceSize): Added. Helper that creates a
SourceSize, mapping parser data structures into real CSS ones.
* css/CSSParser.h: Updated for changes above.
* css/MediaQuery.cpp:
(WebCore::MediaQuery::MediaQuery): Use std::make_unique and the copy
constructor directly instead of using a MediaQuery::copy function.
* css/MediaQueryExp.cpp: Streamlined the class a little bit.
* css/MediaQueryExp.h: Removed unneeded includes. Moved functions out
of the class body so the class is easier to read. Removed the unneeded
copy function.
* css/SourceSizeList.cpp:
(WebCore::SourceSize::match): Changed to use WTF::move instead
of releasing and then re-creating the unique_ptr.
(WebCore::computeLength): Added a comment to explain this function
is using an incorrect strategy. Also added some type checking code
to handle cases where a null or non-primitive CSS value might be
returned. Probably dead code, but we don't want to risk a bad cast.
Worthe cleaning up when we fix the strategy.
(WebCore::SourceSizeList::getEffectiveSize): Updated since the
vector now contains actual SourceSize objects rather than pointers
to SourceSize objects on the heap.
* css/SourceSizeList.h: Changed the CSSParserValue argument to be
an rvalue reference to make it clearer that we take ownership of it
when it's moved in. Added a move constructor and a destructor. Added
comments explaining that it's not correct design to use a
CSSParserValue here, outside the parser. Changed SourceSizeList's
append function to move a SourceSize in rather than a unique_ptr.
Made getEffectiveSize private. Moved the various inline functions to
the bottom of the file to make the class definitions easier to read.
* css/SourceSizeList.cpp: Made almost everything about this private
to this source file instead of public in the header.
(WebCore::match): Made this a free function instead of a member function
and made it take the media query expression as an argument.
(WebCore::computeLength): Changed the argument type to CSSValue*,
rather than using CSSParserValue here outside the parser.
(WebCore::parseSizesAttribute): Streamlined and simplified this.
Now that the parser builds the list in the correct order, there was
no need to iterate backwards any more so we could use a modern for
loop.
* css/SourceSizeList.h: Removed almost everything in this header.
* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::parseAttribute): Call the
parseSizesAttribute function as free function since it's no longer
a member of a SourceSizeList class.
* html/parser/HTMLPreloadScanner.cpp:
(WebCore::TokenPreloadScanner::StartTagScanner::processAttributes):
Ditto.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecssCSSGrammaryin">trunk/Source/WebCore/css/CSSGrammar.y.in</a></li>
<li><a href="#trunkSourceWebCorecssCSSParsercpp">trunk/Source/WebCore/css/CSSParser.cpp</a></li>
<li><a href="#trunkSourceWebCorecssCSSParserh">trunk/Source/WebCore/css/CSSParser.h</a></li>
<li><a href="#trunkSourceWebCorecssMediaQuerycpp">trunk/Source/WebCore/css/MediaQuery.cpp</a></li>
<li><a href="#trunkSourceWebCorecssMediaQueryExpcpp">trunk/Source/WebCore/css/MediaQueryExp.cpp</a></li>
<li><a href="#trunkSourceWebCorecssMediaQueryExph">trunk/Source/WebCore/css/MediaQueryExp.h</a></li>
<li><a href="#trunkSourceWebCorecssSourceSizeListcpp">trunk/Source/WebCore/css/SourceSizeList.cpp</a></li>
<li><a href="#trunkSourceWebCorecssSourceSizeListh">trunk/Source/WebCore/css/SourceSizeList.h</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLImageElementcpp">trunk/Source/WebCore/html/HTMLImageElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlparserHTMLPreloadScannercpp">trunk/Source/WebCore/html/parser/HTMLPreloadScanner.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (179475 => 179476)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-02-02 17:06:19 UTC (rev 179475)
+++ trunk/Source/WebCore/ChangeLog        2015-02-02 18:12:32 UTC (rev 179476)
</span><span class="lines">@@ -1,5 +1,85 @@
</span><span class="cx"> 2015-02-02 Darin Adler <darin@apple.com>
</span><span class="cx">
</span><ins>+ REGRESSION (r170576): Storage leaks in parsing of CSS image sizes
+ https://bugs.webkit.org/show_bug.cgi?id=141026
+
+ Reviewed by Anders Carlsson.
+
+ * css/CSSGrammar.y.in: Fixed all the shift/reduce conflicts caused
+ by the ENABLE_PICTURE_SIZES code by removing all the redundant
+ maybe_space which caused them. Rearranged the productions for
+ ENABLE_PICTURE_SIZES to tighten up the code quite a bit. Changed
+ the code to build up the source size vector as a Vector instead of
+ a special class, and use the SourceSize struct from inside the
+ CSSParser class.'
+
+ * css/CSSParser.cpp:
+ (WebCore::CSSParser::setupParser): Changed this to take a StringView.
+ In the future we can change all the parsing functions to take StringView,
+ since they don't work with the String in place.
+ (WebCore::CSSParser::parseSizesAttribute): Changed to return a vector
+ of SourceSize instead of a SourceSizeList. This is better because it's
+ a real CSS data structure that does not contain a CSSParserValue.
+ (WebCore::CSSParser::sourceSize): Added. Helper that creates a
+ SourceSize, mapping parser data structures into real CSS ones.
+
+ * css/CSSParser.h: Updated for changes above.
+
+ * css/MediaQuery.cpp:
+ (WebCore::MediaQuery::MediaQuery): Use std::make_unique and the copy
+ constructor directly instead of using a MediaQuery::copy function.
+
+ * css/MediaQueryExp.cpp: Streamlined the class a little bit.
+ * css/MediaQueryExp.h: Removed unneeded includes. Moved functions out
+ of the class body so the class is easier to read. Removed the unneeded
+ copy function.
+
+ * css/SourceSizeList.cpp:
+ (WebCore::SourceSize::match): Changed to use WTF::move instead
+ of releasing and then re-creating the unique_ptr.
+ (WebCore::computeLength): Added a comment to explain this function
+ is using an incorrect strategy. Also added some type checking code
+ to handle cases where a null or non-primitive CSS value might be
+ returned. Probably dead code, but we don't want to risk a bad cast.
+ Worthe cleaning up when we fix the strategy.
+ (WebCore::SourceSizeList::getEffectiveSize): Updated since the
+ vector now contains actual SourceSize objects rather than pointers
+ to SourceSize objects on the heap.
+
+ * css/SourceSizeList.h: Changed the CSSParserValue argument to be
+ an rvalue reference to make it clearer that we take ownership of it
+ when it's moved in. Added a move constructor and a destructor. Added
+ comments explaining that it's not correct design to use a
+ CSSParserValue here, outside the parser. Changed SourceSizeList's
+ append function to move a SourceSize in rather than a unique_ptr.
+ Made getEffectiveSize private. Moved the various inline functions to
+ the bottom of the file to make the class definitions easier to read.
+
+
+ * css/SourceSizeList.cpp: Made almost everything about this private
+ to this source file instead of public in the header.
+ (WebCore::match): Made this a free function instead of a member function
+ and made it take the media query expression as an argument.
+ (WebCore::computeLength): Changed the argument type to CSSValue*,
+ rather than using CSSParserValue here outside the parser.
+ (WebCore::parseSizesAttribute): Streamlined and simplified this.
+ Now that the parser builds the list in the correct order, there was
+ no need to iterate backwards any more so we could use a modern for
+ loop.
+
+ * css/SourceSizeList.h: Removed almost everything in this header.
+
+ * html/HTMLImageElement.cpp:
+ (WebCore::HTMLImageElement::parseAttribute): Call the
+ parseSizesAttribute function as free function since it's no longer
+ a member of a SourceSizeList class.
+
+ * html/parser/HTMLPreloadScanner.cpp:
+ (WebCore::TokenPreloadScanner::StartTagScanner::processAttributes):
+ Ditto.
+
+2015-02-02 Darin Adler <darin@apple.com>
+
</ins><span class="cx"> Fix some leaks found by the leak bot
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=141149
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSGrammaryin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSGrammar.y.in (179475 => 179476)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSGrammar.y.in        2015-02-02 17:06:19 UTC (rev 179475)
+++ trunk/Source/WebCore/css/CSSGrammar.y.in        2015-02-02 18:12:32 UTC (rev 179476)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * Copyright (C) 2002-2003 Lars Knoll (knoll@kde.org)
</span><del>- * Copyright (C) 2004-2014 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2004-2015 Apple Inc. All rights reserved.
</ins><span class="cx"> * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com)
</span><span class="cx"> * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
</span><span class="cx"> * Copyright (C) 2012 Intel Corporation. All rights reserved.
</span><span class="lines">@@ -104,18 +104,10 @@
</span><span class="cx"> %}
</span><span class="cx">
</span><span class="cx"> #if ENABLE_CSS_GRID_LAYOUT
</span><del>-#if ENABLE_PICTURE_SIZES
-%expect 36
-#else
</del><span class="cx"> %expect 32
</span><del>-#endif
</del><span class="cx"> #else
</span><del>-#if ENABLE_PICTURE_SIZES
-%expect 35
-#else
</del><span class="cx"> %expect 31
</span><span class="cx"> #endif
</span><del>-#endif
</del><span class="cx">
</span><span class="cx"> %nonassoc LOWEST_PREC
</span><span class="cx">
</span><span class="lines">@@ -265,23 +257,21 @@
</span><span class="cx"> %type <mediaQueryRestrictor> maybe_media_restrictor
</span><span class="cx">
</span><span class="cx"> %union { MediaQueryExp* mediaQueryExp; }
</span><del>-%type <mediaQueryExp> media_query_exp
-%destructor { delete $$; } media_query_exp
</del><ins>+%type <mediaQueryExp> media_query_exp base_media_query_exp
+%destructor { delete $$; } media_query_exp base_media_query_exp
</ins><span class="cx">
</span><span class="cx"> #if ENABLE_PICTURE_SIZES
</span><del>-%union { MediaQueryExp* mediaCondition; }
-%type <mediaQueryExp> media_condition
-%destructor { delete $$; } media_condition
</del><span class="cx">
</span><del>-%union { SourceSize* sourceSize; }
-%type <sourceSize> source_size
-%destructor { delete $$; } source_size
-
-%union { SourceSizeList* sourceSizeList; }
</del><ins>+%union { Vector<CSSParser::SourceSize>* sourceSizeList; }
</ins><span class="cx"> %type <sourceSizeList> source_size_list
</span><span class="cx"> %destructor { delete $$; } source_size_list
</span><span class="cx">
</span><ins>+%type <mediaQueryExp> maybe_source_media_query_exp
+%destructor { delete $$; } maybe_source_media_query_exp
+
</ins><span class="cx"> %type <value> source_size_length
</span><ins>+%destructor { destroy($$); } source_size_length
+
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> %union { Vector<std::unique_ptr<MediaQueryExp>>* mediaQueryExpList; }
</span><span class="lines">@@ -298,12 +288,12 @@
</span><span class="cx"> %type <keyframeRuleList> keyframes_rule
</span><span class="cx"> %destructor { delete $$; } keyframes_rule
</span><span class="cx">
</span><del>-// These two parser values never need to be destroyed because they are never functions or value lists.
-%type <value> key unary_term
</del><ins>+// These parser values never need to be destroyed because they are never functions or value lists.
+%type <value> calc_func_term key unary_term
</ins><span class="cx">
</span><span class="cx"> // These parser values need to be destroyed because they might be functions.
</span><del>-%type <value> calc_func_term calc_function function min_or_max_function term
-%destructor { destroy($$); } calc_func_term calc_function function min_or_max_function term
</del><ins>+%type <value> calc_function function min_or_max_function term
+%destructor { destroy($$); } calc_function function min_or_max_function term
</ins><span class="cx">
</span><span class="cx"> %union { CSSPropertyID id; }
</span><span class="cx"> %type <id> property
</span><span class="lines">@@ -334,10 +324,13 @@
</span><span class="cx"> %destructor { delete $$; } calc_func_expr calc_func_expr_list calc_func_paren_expr expr key_list maybe_media_value valid_calc_func_expr valid_expr
</span><span class="cx">
</span><span class="cx"> #if ENABLE_CSS_SELECTORS_LEVEL4
</span><ins>+
</ins><span class="cx"> %type <string> lang_range
</span><ins>+
</ins><span class="cx"> %union { Vector<CSSParserString>* stringList; }
</span><span class="cx"> %type <stringList> comma_separated_lang_ranges
</span><span class="cx"> %destructor { delete $$; } comma_separated_lang_ranges
</span><ins>+
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> %type <string> min_or_max
</span><span class="lines">@@ -348,11 +341,13 @@
</span><span class="cx"> %type <location> error_location
</span><span class="cx">
</span><span class="cx"> #if ENABLE_CSS_GRID_LAYOUT
</span><ins>+
</ins><span class="cx"> %type <valueList> ident_list
</span><span class="cx"> %destructor { delete $$; } ident_list
</span><span class="cx">
</span><span class="cx"> %type <value> track_names_list
</span><span class="cx"> %destructor { destroy($$); } track_names_list
</span><ins>+
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> %token SUPPORTS_AND
</span><span class="lines">@@ -577,55 +572,50 @@
</span><span class="cx"> maybe_media_value: /*empty*/ { $$ = nullptr; } | ':' maybe_space expr maybe_space { $$ = $3; } ;
</span><span class="cx">
</span><span class="cx"> #if ENABLE_PICTURE_SIZES
</span><del>-media_condition:
- maybe_space '(' maybe_space IDENT maybe_space maybe_media_value ')' maybe_space {
- std::unique_ptr<CSSParserValueList> mediaValue($6);
- $4.lower();
- $$ = new MediaQueryExp($4, mediaValue.get());
</del><ins>+
+webkit_source_size_list:
+ WEBKIT_SIZESATTR_SYM WHITESPACE source_size_list maybe_space '}' {
+ parser->m_sourceSizeList = std::unique_ptr<Vector<CSSParser::SourceSize>>($3);
</ins><span class="cx"> }
</span><span class="cx"> ;
</span><span class="cx">
</span><del>-webkit_source_size_list:
- WEBKIT_SIZESATTR_SYM WHITESPACE source_size_list '}' { parser->m_sourceSizeList = std::unique_ptr<SourceSizeList>($3); };
-
</del><span class="cx"> source_size_list:
</span><del>- maybe_space source_size maybe_space {
- $$ = new SourceSizeList();
- $$->append(std::unique_ptr<SourceSize>($2));
</del><ins>+ maybe_source_media_query_exp source_size_length {
+ $$ = new Vector<CSSParser::SourceSize>;
+ $$->append(parser->sourceSize(std::unique_ptr<MediaQueryExp>($1), $2));
</ins><span class="cx"> }
</span><del>- | maybe_space source_size maybe_space ',' maybe_space source_size_list maybe_space {
- $$ = $6;
- $$->append(std::unique_ptr<SourceSize>($2));
- };
-
-source_size_length:
- unary_term {
</del><ins>+ | source_size_list maybe_space ',' maybe_space maybe_source_media_query_exp source_size_length {
</ins><span class="cx"> $$ = $1;
</span><ins>+ $$->append(parser->sourceSize(std::unique_ptr<MediaQueryExp>($5), $6));
</ins><span class="cx"> }
</span><del>- | calc_function {
- $$ = $1;
- };
</del><ins>+ ;
</ins><span class="cx">
</span><del>-source_size:
- media_condition source_size_length {
- $$ = new SourceSize(std::unique_ptr<MediaQueryExp>($1), $2);
</del><ins>+maybe_source_media_query_exp:
+ /* empty */ {
+ $$ = new MediaQueryExp;
</ins><span class="cx"> }
</span><del>- | source_size_length {
- $$ = new SourceSize(std::make_unique<MediaQueryExp>(emptyString(), nullptr), $1);
- };
</del><ins>+ | base_media_query_exp maybe_space;
+
+source_size_length: unary_term | calc_function;
+
</ins><span class="cx"> #endif
</span><span class="cx">
</span><ins>+base_media_query_exp: '(' maybe_space IDENT maybe_space maybe_media_value ')' {
+ std::unique_ptr<CSSParserValueList> mediaValue($5);
+ $3.lower();
+ $$ = new MediaQueryExp($3, mediaValue.get());
+ }
+ ;
+
</ins><span class="cx"> media_query_exp:
</span><del>- maybe_media_restrictor maybe_space '(' maybe_space IDENT maybe_space maybe_media_value ')' maybe_space {
- // If restrictor is specified, media query expression is invalid.
- // Create empty media query expression and continue parsing media query.
- std::unique_ptr<CSSParserValueList> mediaValue($7);
- if ($1 != MediaQuery::None)
- $$ = new MediaQueryExp(emptyString(), nullptr);
- else {
- $5.lower();
- $$ = new MediaQueryExp($5, mediaValue.get());
- }
</del><ins>+ maybe_media_restrictor maybe_space base_media_query_exp maybe_space {
+ if ($1 != MediaQuery::None) {
+ // If restrictor is specified, media query expression is invalid.
+ // Create empty media query expression and continue parsing media query.
+ delete $3;
+ $$ = new MediaQueryExp;
+ } else
+ $$ = $3;
</ins><span class="cx"> }
</span><span class="cx"> ;
</span><span class="cx">
</span><span class="lines">@@ -1915,4 +1905,3 @@
</span><span class="cx"> ;
</span><span class="cx">
</span><span class="cx"> %%
</span><del>-
</del></span></pre></div>
<a id="trunkSourceWebCorecssCSSParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSParser.cpp (179475 => 179476)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSParser.cpp        2015-02-02 17:06:19 UTC (rev 179475)
+++ trunk/Source/WebCore/css/CSSParser.cpp        2015-02-02 18:12:32 UTC (rev 179476)
</span><span class="lines">@@ -377,7 +377,7 @@
</span><span class="cx"> makeLower(characters16(), characters16(), length());
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void CSSParser::setupParser(const char* prefix, unsigned prefixLength, const String& string, const char* suffix, unsigned suffixLength)
</del><ins>+void CSSParser::setupParser(const char* prefix, unsigned prefixLength, StringView string, const char* suffix, unsigned suffixLength)
</ins><span class="cx"> {
</span><span class="cx"> m_parsedTextPrefixLength = prefixLength;
</span><span class="cx"> unsigned stringLength = string.length();
</span><span class="lines">@@ -1480,18 +1480,43 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if ENABLE(PICTURE_SIZES)
</span><del>-std::unique_ptr<SourceSizeList> CSSParser::parseSizesAttribute(const String& string)
</del><ins>+
+Vector<CSSParser::SourceSize> CSSParser::parseSizesAttribute(StringView string)
</ins><span class="cx"> {
</span><ins>+ Vector<SourceSize> result;
+
</ins><span class="cx"> if (string.isEmpty())
</span><del>- return nullptr;
</del><ins>+ return result;
</ins><span class="cx">
</span><del>- ASSERT(!m_sourceSizeList.get());
</del><ins>+ ASSERT(!m_sourceSizeList);
</ins><span class="cx">
</span><span class="cx"> setupParser("@-webkit-sizesattr ", string, "}");
</span><span class="cx"> cssyyparse(this);
</span><span class="cx">
</span><del>- return WTF::move(m_sourceSizeList);
</del><ins>+ if (!m_sourceSizeList)
+ return result;
+
+ result = WTF::move(*m_sourceSizeList);
+ m_sourceSizeList = nullptr;
+ return result;
</ins><span class="cx"> }
</span><ins>+
+CSSParser::SourceSize CSSParser::sourceSize(std::unique_ptr<MediaQueryExp>&& expression, CSSParserValue& parserValue)
+{
+ RefPtr<CSSValue> value;
+ if (isCalculation(parserValue)) {
+ auto* args = parserValue.function->args.get();
+ if (args && args->size())
+ value = CSSCalcValue::create(parserValue.function->name, *args, CalculationRangeNonNegative);
+ }
+ if (!value)
+ value = parserValue.createCSSValue();
+ // FIXME: Using a named local for the result here to work around an MSVC bug.
+ // With the other compilers, this works without explicitly stating the type name SourceSize or using a local.
+ SourceSize result { WTF::move(expression), value };
+ return result;
+}
+
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> static inline void filterProperties(bool important, const CSSParser::ParsedPropertyVector& input, Vector<CSSProperty, 256>& output, size_t& unusedEntries, std::bitset<numCSSProperties>& seenProperties)
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSParserh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSParser.h (179475 => 179476)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSParser.h        2015-02-02 17:06:19 UTC (rev 179475)
+++ trunk/Source/WebCore/css/CSSParser.h        2015-02-02 18:12:32 UTC (rev 179476)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * Copyright (C) 2003 Lars Knoll (knoll@kde.org)
</span><del>- * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2004-2010, 2015 Apple Inc. All rights reserved.
</ins><span class="cx"> * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
</span><span class="cx"> * Copyright (C) 2009 - 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
</span><span class="cx"> *
</span><span class="lines">@@ -117,9 +117,6 @@
</span><span class="cx"> bool parseDeclaration(MutableStyleProperties*, const String&, PassRefPtr<CSSRuleSourceData>, StyleSheetContents* contextStyleSheet);
</span><span class="cx"> static Ref<ImmutableStyleProperties> parseInlineStyleDeclaration(const String&, Element*);
</span><span class="cx"> std::unique_ptr<MediaQuery> parseMediaQuery(const String&);
</span><del>-#if ENABLE(PICTURE_SIZES)
- std::unique_ptr<SourceSizeList> parseSizesAttribute(const String&);
-#endif
</del><span class="cx">
</span><span class="cx"> void addPropertyWithPrefixingVariant(CSSPropertyID, PassRefPtr<CSSValue>, bool important, bool implicit = false);
</span><span class="cx"> void addProperty(CSSPropertyID, PassRefPtr<CSSValue>, bool important, bool implicit = false);
</span><span class="lines">@@ -138,6 +135,15 @@
</span><span class="cx">
</span><span class="cx"> PassRefPtr<CSSValue> parseBackgroundColor();
</span><span class="cx">
</span><ins>+#if ENABLE(PICTURE_SIZES)
+ struct SourceSize {
+ std::unique_ptr<MediaQueryExp> expression;
+ RefPtr<CSSValue> length;
+ };
+ Vector<SourceSize> parseSizesAttribute(StringView);
+ SourceSize sourceSize(std::unique_ptr<MediaQueryExp>&&, CSSParserValue&);
+#endif
+
</ins><span class="cx"> // FIXME: Maybe these two methods could be combined into one.
</span><span class="cx"> bool parseMaskImage(CSSParserValueList&, RefPtr<CSSValue>&);
</span><span class="cx"> bool parseFillImage(CSSParserValueList&, RefPtr<CSSValue>&);
</span><span class="lines">@@ -366,7 +372,7 @@
</span><span class="cx"> RefPtr<StyleKeyframe> m_keyframe;
</span><span class="cx"> std::unique_ptr<MediaQuery> m_mediaQuery;
</span><span class="cx"> #if ENABLE(PICTURE_SIZES)
</span><del>- std::unique_ptr<SourceSizeList> m_sourceSizeList;
</del><ins>+ std::unique_ptr<Vector<SourceSize>> m_sourceSizeList;
</ins><span class="cx"> #endif
</span><span class="cx"> std::unique_ptr<CSSParserValueList> m_valueList;
</span><span class="cx"> bool m_supportsCondition;
</span><span class="lines">@@ -514,11 +520,11 @@
</span><span class="cx"> void recheckAtKeyword(const UChar* str, int len);
</span><span class="cx">
</span><span class="cx"> template<unsigned prefixLength, unsigned suffixLength>
</span><del>- inline void setupParser(const char (&prefix)[prefixLength], const String& string, const char (&suffix)[suffixLength])
</del><ins>+ void setupParser(const char (&prefix)[prefixLength], StringView string, const char (&suffix)[suffixLength])
</ins><span class="cx"> {
</span><span class="cx"> setupParser(prefix, prefixLength - 1, string, suffix, suffixLength - 1);
</span><span class="cx"> }
</span><del>- void setupParser(const char* prefix, unsigned prefixLength, const String&, const char* suffix, unsigned suffixLength);
</del><ins>+ void setupParser(const char* prefix, unsigned prefixLength, StringView, const char* suffix, unsigned suffixLength);
</ins><span class="cx"> bool inShorthand() const { return m_inParseShorthand; }
</span><span class="cx">
</span><span class="cx"> bool validateWidth(ValueWithCalculation&);
</span></span></pre></div>
<a id="trunkSourceWebCorecssMediaQuerycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/MediaQuery.cpp (179475 => 179476)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/MediaQuery.cpp        2015-02-02 17:06:19 UTC (rev 179475)
+++ trunk/Source/WebCore/css/MediaQuery.cpp        2015-02-02 18:12:32 UTC (rev 179476)
</span><span class="lines">@@ -110,7 +110,7 @@
</span><span class="cx"> , m_serializationCache(o.m_serializationCache)
</span><span class="cx"> {
</span><span class="cx"> for (unsigned i = 0; i < m_expressions->size(); ++i)
</span><del>- (*m_expressions)[i] = o.m_expressions->at(i)->copy();
</del><ins>+ (*m_expressions)[i] = std::make_unique<MediaQueryExp>(*o.m_expressions->at(i));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> MediaQuery::~MediaQuery()
</span></span></pre></div>
<a id="trunkSourceWebCorecssMediaQueryExpcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/MediaQueryExp.cpp (179475 => 179476)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/MediaQueryExp.cpp        2015-02-02 17:06:19 UTC (rev 179475)
+++ trunk/Source/WebCore/css/MediaQueryExp.cpp        2015-02-02 18:12:32 UTC (rev 179476)
</span><span class="lines">@@ -1,9 +1,7 @@
</span><span class="cx"> /*
</span><del>- * CSS Media Query
- *
</del><span class="cx"> * Copyright (C) 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>.
</span><span class="cx"> * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
</span><del>- * Copyright (C) 2013 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="cx"> * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -162,8 +160,6 @@
</span><span class="cx">
</span><span class="cx"> MediaQueryExp::MediaQueryExp(const AtomicString& mediaFeature, CSSParserValueList* valueList)
</span><span class="cx"> : m_mediaFeature(mediaFeature)
</span><del>- , m_value(0)
- , m_isValid(false)
</del><span class="cx"> {
</span><span class="cx"> // Initialize media query expression that must have 1 or more values.
</span><span class="cx"> if (valueList) {
</span><span class="lines">@@ -228,10 +224,6 @@
</span><span class="cx"> m_isValid = true;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-MediaQueryExp::~MediaQueryExp()
-{
-}
-
</del><span class="cx"> String MediaQueryExp::serialize() const
</span><span class="cx"> {
</span><span class="cx"> if (!m_serializationCache.isNull())
</span><span class="lines">@@ -246,7 +238,7 @@
</span><span class="cx"> }
</span><span class="cx"> result.append(')');
</span><span class="cx">
</span><del>- const_cast<MediaQueryExp*>(this)->m_serializationCache = result.toString();
</del><ins>+ m_serializationCache = result.toString();
</ins><span class="cx"> return m_serializationCache;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorecssMediaQueryExph"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/MediaQueryExp.h (179475 => 179476)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/MediaQueryExp.h        2015-02-02 17:06:19 UTC (rev 179475)
+++ trunk/Source/WebCore/css/MediaQueryExp.h        2015-02-02 18:12:32 UTC (rev 179476)
</span><span class="lines">@@ -1,8 +1,7 @@
</span><span class="cx"> /*
</span><del>- * CSS Media Query
- *
</del><span class="cx"> * Copyright (C) 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>.
</span><span class="cx"> * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
</span><ins>+ * Copyright (C) 2015 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="cx"> * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -32,53 +31,70 @@
</span><span class="cx"> #include "CSSValue.h"
</span><span class="cx"> #include "MediaFeatureNames.h"
</span><span class="cx"> #include <memory>
</span><del>-#include <wtf/RefPtr.h>
</del><span class="cx"> #include <wtf/text/AtomicString.h>
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><ins>+
</ins><span class="cx"> class CSSParserValueList;
</span><span class="cx">
</span><span class="cx"> class MediaQueryExp {
</span><span class="cx"> WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><del>- MediaQueryExp(const AtomicString& mediaFeature, CSSParserValueList* values);
- ~MediaQueryExp();
</del><ins>+ explicit MediaQueryExp(const AtomicString& mediaFeature = emptyAtom, CSSParserValueList* values = nullptr);
</ins><span class="cx">
</span><del>- AtomicString mediaFeature() const { return m_mediaFeature; }
</del><ins>+ const AtomicString& mediaFeature() const;
+ CSSValue* value() const;
</ins><span class="cx">
</span><del>- CSSValue* value() const { return m_value.get(); }
</del><ins>+ bool isValid() const;
+ bool isViewportDependent() const;
</ins><span class="cx">
</span><del>- bool operator==(const MediaQueryExp& other) const
- {
- return (other.m_mediaFeature == m_mediaFeature)
- && ((!other.m_value && !m_value)
- || (other.m_value && m_value && other.m_value->equals(*m_value)));
- }
-
- bool isValid() const { return m_isValid; }
-
- bool isViewportDependent() const { return m_mediaFeature == MediaFeatureNames::widthMediaFeature
- || m_mediaFeature == MediaFeatureNames::heightMediaFeature
- || m_mediaFeature == MediaFeatureNames::min_widthMediaFeature
- || m_mediaFeature == MediaFeatureNames::min_heightMediaFeature
- || m_mediaFeature == MediaFeatureNames::max_widthMediaFeature
- || m_mediaFeature == MediaFeatureNames::max_heightMediaFeature
- || m_mediaFeature == MediaFeatureNames::orientationMediaFeature
- || m_mediaFeature == MediaFeatureNames::aspect_ratioMediaFeature
- || m_mediaFeature == MediaFeatureNames::min_aspect_ratioMediaFeature
- || m_mediaFeature == MediaFeatureNames::max_aspect_ratioMediaFeature; }
-
</del><span class="cx"> String serialize() const;
</span><span class="cx">
</span><del>- std::unique_ptr<MediaQueryExp> copy() const { return std::make_unique<MediaQueryExp>(*this); }
</del><ins>+ bool operator==(const MediaQueryExp&) const;
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> AtomicString m_mediaFeature;
</span><span class="cx"> RefPtr<CSSValue> m_value;
</span><del>- bool m_isValid;
- String m_serializationCache;
</del><ins>+ bool m_isValid { false };
+ mutable String m_serializationCache;
</ins><span class="cx"> };
</span><span class="cx">
</span><ins>+inline const AtomicString& MediaQueryExp::mediaFeature() const
+{
+ return m_mediaFeature;
+}
+
+inline CSSValue* MediaQueryExp::value() const
+{
+ return m_value.get();
+}
+
+inline bool MediaQueryExp::operator==(const MediaQueryExp& other) const
+{
+ return (other.m_mediaFeature == m_mediaFeature)
+ && ((!other.m_value && !m_value)
+ || (other.m_value && m_value && other.m_value->equals(*m_value)));
+}
+
+inline bool MediaQueryExp::isValid() const
+{
+ return m_isValid;
+}
+
+inline bool MediaQueryExp::isViewportDependent() const
+{
+ return m_mediaFeature == MediaFeatureNames::widthMediaFeature
+ || m_mediaFeature == MediaFeatureNames::heightMediaFeature
+ || m_mediaFeature == MediaFeatureNames::min_widthMediaFeature
+ || m_mediaFeature == MediaFeatureNames::min_heightMediaFeature
+ || m_mediaFeature == MediaFeatureNames::max_widthMediaFeature
+ || m_mediaFeature == MediaFeatureNames::max_heightMediaFeature
+ || m_mediaFeature == MediaFeatureNames::orientationMediaFeature
+ || m_mediaFeature == MediaFeatureNames::aspect_ratioMediaFeature
+ || m_mediaFeature == MediaFeatureNames::min_aspect_ratioMediaFeature
+ || m_mediaFeature == MediaFeatureNames::max_aspect_ratioMediaFeature;
+}
+
</ins><span class="cx"> } // namespace
</span><span class="cx">
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCorecssSourceSizeListcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/SourceSizeList.cpp (179475 => 179476)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/SourceSizeList.cpp        2015-02-02 17:06:19 UTC (rev 179475)
+++ trunk/Source/WebCore/css/SourceSizeList.cpp        2015-02-02 18:12:32 UTC (rev 179476)
</span><span class="lines">@@ -1,5 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * Copyright (C) 2014 Yoav Weiss <yoav@yoav.ws>
</span><ins>+ * Copyright (C) 2015 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * This library is free software; you can redistribute it and/or
</span><span class="cx"> * modify it under the terms of the GNU Library General Public
</span><span class="lines">@@ -22,23 +23,31 @@
</span><span class="cx">
</span><span class="cx"> #include "CSSParser.h"
</span><span class="cx"> #include "CSSToLengthConversionData.h"
</span><del>-#include "Document.h"
</del><span class="cx"> #include "MediaList.h"
</span><span class="cx"> #include "MediaQuery.h"
</span><span class="cx"> #include "MediaQueryEvaluator.h"
</span><del>-#include "RenderObject.h"
</del><ins>+#include "MediaQueryExp.h"
</ins><span class="cx"> #include "RenderStyle.h"
</span><span class="cx"> #include "RenderView.h"
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-#if ENABLE(PICTURE_SIZES)
-bool SourceSize::match(RenderStyle& style, Frame* frame)
</del><ins>+#if !ENABLE(PICTURE_SIZES)
+
+unsigned parseSizesAttribute(StringView, RenderView*, Frame*)
</ins><span class="cx"> {
</span><del>- if (m_mediaExp->mediaFeature().isEmpty())
</del><ins>+ return 0;
+}
+
+#else
+
+static bool match(std::unique_ptr<MediaQueryExp>&& expression, RenderStyle& style, Frame* frame)
+{
+ if (expression->mediaFeature().isEmpty())
</ins><span class="cx"> return true;
</span><ins>+
</ins><span class="cx"> auto expList = std::make_unique<Vector<std::unique_ptr<MediaQueryExp>>>();
</span><del>- expList->append(m_mediaExp.release());
</del><ins>+ expList->append(WTF::move(expression));
</ins><span class="cx">
</span><span class="cx"> RefPtr<MediaQuerySet> mediaQuerySet = MediaQuerySet::create();
</span><span class="cx"> mediaQuerySet->addMediaQuery(std::make_unique<MediaQuery>(MediaQuery::None, "all", WTF::move(expList)));
</span><span class="lines">@@ -47,60 +56,28 @@
</span><span class="cx"> return mediaQueryEvaluator.eval(mediaQuerySet.get());
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static unsigned computeLength(CSSParserValue& value, RenderStyle& style, RenderView* view)
</del><ins>+static unsigned computeLength(CSSValue* value, RenderStyle& style, RenderView* view)
</ins><span class="cx"> {
</span><span class="cx"> CSSToLengthConversionData conversionData(&style, &style, view);
</span><del>- if (CSSParser::isCalculation(value)) {
- CSSParserValueList* args = value.function->args.get();
- if (args && args->size()) {
- RefPtr<CSSCalcValue> calcValue = CSSCalcValue::create(value.function->name, *args, CalculationRangeNonNegative);
- Length length(calcValue->createCalculationValue(conversionData));
- RefPtr<CSSPrimitiveValue> primitiveValue = CSSPrimitiveValue::create(length, &style);
- return primitiveValue->computeLength<unsigned>(conversionData);
- }
</del><ins>+ if (is<CSSPrimitiveValue>(value))
+ return downcast<CSSPrimitiveValue>(*value).computeLength<unsigned>(conversionData);
+ if (is<CSSCalcValue>(value)) {
+ Length length(downcast<CSSCalcValue>(*value).createCalculationValue(conversionData));
+ return CSSPrimitiveValue::create(length, &style)->computeLength<unsigned>(conversionData);
</ins><span class="cx"> }
</span><del>- RefPtr<CSSValue> cssValue = value.createCSSValue();
- RefPtr<CSSPrimitiveValue> primitiveValue = downcast<CSSPrimitiveValue>(cssValue.get());
- return primitiveValue->computeLength<unsigned>(conversionData);
</del><ins>+ return 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-static unsigned defaultValue(RenderStyle& style, RenderView* view)
</del><ins>+unsigned parseSizesAttribute(StringView sizesAttribute, RenderView* view, Frame* frame)
</ins><span class="cx"> {
</span><del>- const unsigned defaultSizesAttributeValueInVW = 100;
-
- CSSParserValue value;
- value.id = CSSValueInvalid;
- value.isInt = true;
- value.fValue = defaultSizesAttributeValueInVW;
- value.unit = CSSPrimitiveValue::CSS_VW;
-
- return computeLength(value, style, view);
-}
-
-unsigned SourceSize::length(RenderStyle& style, RenderView* view)
-{
- return computeLength(m_length, style, view);
-}
-
-unsigned SourceSizeList::parseSizesAttribute(const String& sizesAttribute, RenderView* view, Frame* frame)
-{
</del><span class="cx"> if (!view)
</span><span class="cx"> return 0;
</span><del>- CSSParser parser(CSSStrictMode);
- std::unique_ptr<SourceSizeList> sourceSizeList = parser.parseSizesAttribute(sizesAttribute);
- if (!sourceSizeList)
- return defaultValue(view->style(), view);
- return sourceSizeList->getEffectiveSize(view->style(), view, frame);
-}
-
-unsigned SourceSizeList::getEffectiveSize(RenderStyle& style, RenderView* view, Frame* frame)
-{
- for (int i = m_list.size() - 1; i >= 0; --i) {
- SourceSize* sourceSize = m_list[i].get();
- if (sourceSize->match(style, frame))
- return sourceSize->length(style, view);
</del><ins>+ RenderStyle& style = view->style();
+ for (auto& sourceSize : CSSParser(CSSStrictMode).parseSizesAttribute(sizesAttribute)) {
+ if (match(WTF::move(sourceSize.expression), style, frame))
+ return computeLength(sourceSize.length.get(), style, view);
</ins><span class="cx"> }
</span><del>- return defaultValue(style, view);
</del><ins>+ return computeLength(CSSPrimitiveValue::create(100, CSSPrimitiveValue::CSS_VW).ptr(), style, view);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCorecssSourceSizeListh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/SourceSizeList.h (179475 => 179476)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/SourceSizeList.h        2015-02-02 17:06:19 UTC (rev 179475)
+++ trunk/Source/WebCore/css/SourceSizeList.h        2015-02-02 18:12:32 UTC (rev 179476)
</span><span class="lines">@@ -1,5 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * Copyright (C) 2014 Yoav Weiss <yoav@yoav.ws>
</span><ins>+ * Copyright (C) 2015 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * This library is free software; you can redistribute it and/or
</span><span class="cx"> * modify it under the terms of the GNU Library General Public
</span><span class="lines">@@ -20,51 +21,15 @@
</span><span class="cx"> #ifndef SourceSizeList_h
</span><span class="cx"> #define SourceSizeList_h
</span><span class="cx">
</span><del>-#if ENABLE(PICTURE_SIZES)
</del><ins>+#include <wtf/Forward.h>
</ins><span class="cx">
</span><del>-#include "CSSParserValues.h"
-#include "MediaQueryExp.h"
-#include <memory>
-
</del><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-class RenderStyle;
-class RenderView;
</del><span class="cx"> class Frame;
</span><ins>+class RenderView;
</ins><span class="cx">
</span><del>-class SourceSize {
-public:
- SourceSize(std::unique_ptr<MediaQueryExp> mediaExp, const CSSParserValue& length)
- : m_mediaExp(WTF::move(mediaExp))
- , m_length(length)
- {
- }
</del><ins>+unsigned parseSizesAttribute(StringView sizesAttribute, RenderView*, Frame*);
</ins><span class="cx">
</span><del>- bool match(RenderStyle&, Frame*);
- unsigned length(RenderStyle&, RenderView*);
-
-private:
- std::unique_ptr<MediaQueryExp> m_mediaExp;
- CSSParserValue m_length;
-};
-
-class SourceSizeList {
-public:
- void append(std::unique_ptr<SourceSize> sourceSize)
- {
- m_list.append(WTF::move(sourceSize));
- }
-
- static unsigned parseSizesAttribute(const String& sizesAttribute, RenderView*, Frame*);
- unsigned getEffectiveSize(RenderStyle&, RenderView*, Frame*);
-
-private:
- Vector<std::unique_ptr<SourceSize>> m_list;
-};
-
</del><span class="cx"> } // namespace WebCore
</span><span class="cx">
</span><del>-#endif // ENABLE(PICTURE_SIZES)
-
</del><span class="cx"> #endif // SourceSizeList_h
</span><del>-
</del></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLImageElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLImageElement.cpp (179475 => 179476)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLImageElement.cpp        2015-02-02 17:06:19 UTC (rev 179475)
+++ trunk/Source/WebCore/html/HTMLImageElement.cpp        2015-02-02 18:12:32 UTC (rev 179476)
</span><span class="lines">@@ -143,10 +143,7 @@
</span><span class="cx"> if (is<RenderImage>(renderer()))
</span><span class="cx"> downcast<RenderImage>(*renderer()).updateAltText();
</span><span class="cx"> } else if (name == srcAttr || name == srcsetAttr) {
</span><del>- unsigned sourceSize = 0;
-#if ENABLE(PICTURE_SIZES)
- sourceSize = SourceSizeList::parseSizesAttribute(fastGetAttribute(sizesAttr), document().renderView(), document().frame());
-#endif
</del><ins>+ unsigned sourceSize = parseSizesAttribute(fastGetAttribute(sizesAttr).string(), document().renderView(), document().frame());
</ins><span class="cx"> ImageCandidate candidate = bestFitSourceForImageAttributes(document().deviceScaleFactor(), fastGetAttribute(srcAttr), fastGetAttribute(srcsetAttr), sourceSize);
</span><span class="cx"> setBestFitURLAndDPRFromImageCandidate(candidate);
</span><span class="cx"> m_imageLoader.updateFromElementIgnoringPreviousError();
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLPreloadScannercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLPreloadScanner.cpp (179475 => 179476)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLPreloadScanner.cpp        2015-02-02 17:06:19 UTC (rev 179475)
+++ trunk/Source/WebCore/html/parser/HTMLPreloadScanner.cpp        2015-02-02 18:12:32 UTC (rev 179476)
</span><span class="lines">@@ -107,12 +107,7 @@
</span><span class="cx">
</span><span class="cx"> // Resolve between src and srcSet if we have them.
</span><span class="cx"> if (!m_srcSetAttribute.isEmpty()) {
</span><del>- unsigned sourceSize = 0;
-#if ENABLE(PICTURE_SIZES)
- sourceSize = SourceSizeList::parseSizesAttribute(m_sizesAttribute, document.renderView(), document.frame());
-#else
- UNUSED_PARAM(document);
-#endif
</del><ins>+ unsigned sourceSize = parseSizesAttribute(m_sizesAttribute, document.renderView(), document.frame());
</ins><span class="cx"> ImageCandidate imageCandidate = bestFitSourceForImageAttributes(m_deviceScaleFactor, m_urlToLoad, m_srcSetAttribute, sourceSize);
</span><span class="cx"> setUrlToLoad(imageCandidate.string.toString(), true);
</span><span class="cx"> }
</span></span></pre>
</div>
</div>
</body>
</html>