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

Side by Side Diff: third_party/WebKit/Source/core/css/CSSImageSetValue.cpp

Issue 2392343005: Reflow comments in core/css (Closed)
Patch Set: Revert clang-format Created 4 years, 2 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 ImageWithScale image; 62 ImageWithScale image;
63 image.imageURL = imageURL; 63 image.imageURL = imageURL;
64 image.referrer = SecurityPolicy::generateReferrer( 64 image.referrer = SecurityPolicy::generateReferrer(
65 imageValue.referrer().referrerPolicy, KURL(ParsedURLString, imageURL), 65 imageValue.referrer().referrerPolicy, KURL(ParsedURLString, imageURL),
66 imageValue.referrer().referrer); 66 imageValue.referrer().referrer);
67 image.scaleFactor = scaleFactor; 67 image.scaleFactor = scaleFactor;
68 m_imagesInSet.append(image); 68 m_imagesInSet.append(image);
69 ++i; 69 ++i;
70 } 70 }
71 71
72 // Sort the images so that they are stored in order from lowest resolution to highest. 72 // Sort the images so that they are stored in order from lowest resolution to
73 // highest.
73 std::sort(m_imagesInSet.begin(), m_imagesInSet.end(), 74 std::sort(m_imagesInSet.begin(), m_imagesInSet.end(),
74 CSSImageSetValue::compareByScaleFactor); 75 CSSImageSetValue::compareByScaleFactor);
75 } 76 }
76 77
77 CSSImageSetValue::ImageWithScale CSSImageSetValue::bestImageForScaleFactor( 78 CSSImageSetValue::ImageWithScale CSSImageSetValue::bestImageForScaleFactor(
78 float scaleFactor) { 79 float scaleFactor) {
79 ImageWithScale image; 80 ImageWithScale image;
80 size_t numberOfImages = m_imagesInSet.size(); 81 size_t numberOfImages = m_imagesInSet.size();
81 for (size_t i = 0; i < numberOfImages; ++i) { 82 for (size_t i = 0; i < numberOfImages; ++i) {
82 image = m_imagesInSet.at(i); 83 image = m_imagesInSet.at(i);
(...skipping 13 matching lines...) Expand all
96 } 97 }
97 98
98 StyleImage* CSSImageSetValue::cacheImage( 99 StyleImage* CSSImageSetValue::cacheImage(
99 const Document& document, 100 const Document& document,
100 float deviceScaleFactor, 101 float deviceScaleFactor,
101 CrossOriginAttributeValue crossOrigin) { 102 CrossOriginAttributeValue crossOrigin) {
102 if (!m_imagesInSet.size()) 103 if (!m_imagesInSet.size())
103 fillImageSet(); 104 fillImageSet();
104 105
105 if (isCachePending(deviceScaleFactor)) { 106 if (isCachePending(deviceScaleFactor)) {
106 // FIXME: In the future, we want to take much more than deviceScaleFactor in to acount here. 107 // FIXME: In the future, we want to take much more than deviceScaleFactor
107 // All forms of scale should be included: Page::pageScaleFactor(), LocalFram e::pageZoomFactor(), 108 // into acount here. All forms of scale should be included:
108 // and any CSS transforms. https://bugs.webkit.org/show_bug.cgi?id=81698 109 // Page::pageScaleFactor(), LocalFrame::pageZoomFactor(), and any CSS
110 // transforms. https://bugs.webkit.org/show_bug.cgi?id=81698
109 ImageWithScale image = bestImageForScaleFactor(deviceScaleFactor); 111 ImageWithScale image = bestImageForScaleFactor(deviceScaleFactor);
110 FetchRequest request(ResourceRequest(document.completeURL(image.imageURL)), 112 FetchRequest request(ResourceRequest(document.completeURL(image.imageURL)),
111 FetchInitiatorTypeNames::css); 113 FetchInitiatorTypeNames::css);
112 request.mutableResourceRequest().setHTTPReferrer(image.referrer); 114 request.mutableResourceRequest().setHTTPReferrer(image.referrer);
113 115
114 if (crossOrigin != CrossOriginAttributeNotSet) 116 if (crossOrigin != CrossOriginAttributeNotSet)
115 request.setCrossOriginAccessControl(document.getSecurityOrigin(), 117 request.setCrossOriginAccessControl(document.getSecurityOrigin(),
116 crossOrigin); 118 crossOrigin);
117 119
118 if (ImageResource* cachedImage = 120 if (ImageResource* cachedImage =
(...skipping 19 matching lines...) Expand all
138 result.append(", "); 140 result.append(", ");
139 141
140 const CSSValue& imageValue = item(i); 142 const CSSValue& imageValue = item(i);
141 result.append(imageValue.cssText()); 143 result.append(imageValue.cssText());
142 result.append(' '); 144 result.append(' ');
143 145
144 ++i; 146 ++i;
145 ASSERT_WITH_SECURITY_IMPLICATION(i < length); 147 ASSERT_WITH_SECURITY_IMPLICATION(i < length);
146 const CSSValue& scaleFactorValue = item(i); 148 const CSSValue& scaleFactorValue = item(i);
147 result.append(scaleFactorValue.cssText()); 149 result.append(scaleFactorValue.cssText());
148 // FIXME: Eventually the scale factor should contain it's own unit http://wk b.ug/100120. 150 // FIXME: Eventually the scale factor should contain it's own unit
151 // http://wkb.ug/100120.
149 // For now 'x' is hard-coded in the parser, so we hard-code it here too. 152 // For now 'x' is hard-coded in the parser, so we hard-code it here too.
150 result.append('x'); 153 result.append('x');
151 154
152 ++i; 155 ++i;
153 } 156 }
154 157
155 result.append(')'); 158 result.append(')');
156 return result.toString(); 159 return result.toString();
157 } 160 }
158 161
(...skipping 13 matching lines...) Expand all
172 CSSImageSetValue* CSSImageSetValue::valueWithURLsMadeAbsolute() { 175 CSSImageSetValue* CSSImageSetValue::valueWithURLsMadeAbsolute() {
173 CSSImageSetValue* value = CSSImageSetValue::create(); 176 CSSImageSetValue* value = CSSImageSetValue::create();
174 for (auto& item : *this) 177 for (auto& item : *this)
175 item->isImageValue() 178 item->isImageValue()
176 ? value->append(*toCSSImageValue(*item).valueWithURLMadeAbsolute()) 179 ? value->append(*toCSSImageValue(*item).valueWithURLMadeAbsolute())
177 : value->append(*item); 180 : value->append(*item);
178 return value; 181 return value;
179 } 182 }
180 183
181 } // namespace blink 184 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSImageGeneratorValue.h ('k') | third_party/WebKit/Source/core/css/CSSImportRule.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698