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

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

Issue 2710113002: DO NOT SUBMIT really old prototype of sprite recognition for image replacement
Patch Set: Created 3 years, 10 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
4 * Copyright (C) 2013 Google Inc. All rights reserved. 4 * Copyright (C) 2013 Google Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 10 matching lines...) Expand all
21 */ 21 */
22 22
23 #include "core/css/resolver/ElementStyleResources.h" 23 #include "core/css/resolver/ElementStyleResources.h"
24 24
25 #include "core/CSSPropertyNames.h" 25 #include "core/CSSPropertyNames.h"
26 #include "core/css/CSSCursorImageValue.h" 26 #include "core/css/CSSCursorImageValue.h"
27 #include "core/css/CSSGradientValue.h" 27 #include "core/css/CSSGradientValue.h"
28 #include "core/css/CSSImageValue.h" 28 #include "core/css/CSSImageValue.h"
29 #include "core/css/CSSURIValue.h" 29 #include "core/css/CSSURIValue.h"
30 #include "core/dom/Document.h" 30 #include "core/dom/Document.h"
31 #include "core/fetch/ImageResource.h"
31 #include "core/fetch/ResourceFetcher.h" 32 #include "core/fetch/ResourceFetcher.h"
33 #include "core/frame/Settings.h"
32 #include "core/layout/svg/ReferenceFilterBuilder.h" 34 #include "core/layout/svg/ReferenceFilterBuilder.h"
33 #include "core/style/ComputedStyle.h" 35 #include "core/style/ComputedStyle.h"
34 #include "core/style/ContentData.h" 36 #include "core/style/ContentData.h"
35 #include "core/style/CursorData.h" 37 #include "core/style/CursorData.h"
36 #include "core/style/FillLayer.h" 38 #include "core/style/FillLayer.h"
37 #include "core/style/FilterOperation.h" 39 #include "core/style/FilterOperation.h"
38 #include "core/style/StyleFetchedImage.h" 40 #include "core/style/StyleFetchedImage.h"
39 #include "core/style/StyleFetchedImageSet.h" 41 #include "core/style/StyleFetchedImageSet.h"
40 #include "core/style/StyleGeneratedImage.h" 42 #include "core/style/StyleGeneratedImage.h"
41 #include "core/style/StyleImage.h" 43 #include "core/style/StyleImage.h"
42 #include "core/style/StyleInvalidImage.h" 44 #include "core/style/StyleInvalidImage.h"
43 #include "core/style/StylePendingImage.h" 45 #include "core/style/StylePendingImage.h"
46 #include "platform/Length.h"
47 #include "platform/LengthPoint.h"
44 48
45 namespace blink { 49 namespace blink {
46 50
47 ElementStyleResources::ElementStyleResources(Document& document, float deviceSca leFactor) 51 ElementStyleResources::ElementStyleResources(Document& document, float deviceSca leFactor)
48 : m_document(&document) 52 : m_document(&document)
49 , m_deviceScaleFactor(deviceScaleFactor) 53 , m_deviceScaleFactor(deviceScaleFactor)
50 { 54 {
51 } 55 }
52 56
53 StyleImage* ElementStyleResources::styleImage(CSSPropertyID property, const CSSV alue& value) 57 StyleImage* ElementStyleResources::styleImage(CSSPropertyID property, const CSSV alue& value)
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 DocumentResource* resource = value->load(*m_document); 130 DocumentResource* resource = value->load(*m_document);
127 if (!resource) 131 if (!resource)
128 continue; 132 continue;
129 133
130 // Stash the DocumentResource on the reference filter. 134 // Stash the DocumentResource on the reference filter.
131 ReferenceFilterBuilder::setDocumentResourceReference(referenceFilter , new DocumentResourceReference(resource)); 135 ReferenceFilterBuilder::setDocumentResourceReference(referenceFilter , new DocumentResourceReference(resource));
132 } 136 }
133 } 137 }
134 } 138 }
135 139
140 static bool isSprite(const ComputedStyle& style)
141 {
142 if (!style.hasBackgroundImage())
143 return false;
144
145 const FillLayer& background = style.backgroundLayers();
146 return (background.xPosition().isFixed() && !background.xPosition().isZero() )
147 || (background.yPosition().isFixed() && !background.yPosition().isZero() );
148 }
149
150 static ImageResource::PlaceholderRequestType determinePlaceholderRequestType(con st Document& document, const ComputedStyle& style)
151 {
152 return document.settings() && document.settings()->fetchImagePlaceholders() && !isSprite(style)
153 ? ImageResource::PlaceholderRequestType::AllowPlaceholder
154 : ImageResource::PlaceholderRequestType::DisallowPlaceholder;
155 }
156
136 StyleImage* ElementStyleResources::loadPendingImage(ComputedStyle* style, StyleP endingImage* pendingImage, CrossOriginAttributeValue crossOrigin) 157 StyleImage* ElementStyleResources::loadPendingImage(ComputedStyle* style, StyleP endingImage* pendingImage, CrossOriginAttributeValue crossOrigin)
137 { 158 {
138 if (CSSImageValue* imageValue = pendingImage->cssImageValue()) 159 if (CSSImageValue* imageValue = pendingImage->cssImageValue())
139 return imageValue->cacheImage(*m_document, crossOrigin); 160 return imageValue->cacheImage(*m_document, crossOrigin, determinePlaceho lderRequestType(*m_document, *style));
140 161
141 if (CSSPaintValue* paintValue = pendingImage->cssPaintValue()) { 162 if (CSSPaintValue* paintValue = pendingImage->cssPaintValue()) {
142 StyleGeneratedImage* image = StyleGeneratedImage::create(*paintValue); 163 StyleGeneratedImage* image = StyleGeneratedImage::create(*paintValue);
143 style->addPaintImage(image); 164 style->addPaintImage(image);
144 return image; 165 return image;
145 } 166 }
146 167
147 if (CSSImageGeneratorValue* imageGeneratorValue = pendingImage->cssImageGene ratorValue()) { 168 if (CSSImageGeneratorValue* imageGeneratorValue = pendingImage->cssImageGene ratorValue()) {
148 imageGeneratorValue->loadSubimages(*m_document); 169 imageGeneratorValue->loadSubimages(*m_document);
149 return StyleGeneratedImage::create(*imageGeneratorValue); 170 return StyleGeneratedImage::create(*imageGeneratorValue);
150 } 171 }
151 172
152 if (CSSCursorImageValue* cursorImageValue = pendingImage->cssCursorImageValu e()) 173 if (CSSCursorImageValue* cursorImageValue = pendingImage->cssCursorImageValu e())
153 return cursorImageValue->cacheImage(*m_document, m_deviceScaleFactor); 174 return cursorImageValue->cacheImage(*m_document, m_deviceScaleFactor);
154 175
155 if (CSSImageSetValue* imageSetValue = pendingImage->cssImageSetValue()) 176 if (CSSImageSetValue* imageSetValue = pendingImage->cssImageSetValue())
156 return imageSetValue->cacheImage(*m_document, m_deviceScaleFactor, cross Origin); 177 return imageSetValue->cacheImage(*m_document, m_deviceScaleFactor, cross Origin, determinePlaceholderRequestType(*m_document, *style));
157 178
158 ASSERT_NOT_REACHED(); 179 ASSERT_NOT_REACHED();
159 return nullptr; 180 return nullptr;
160 } 181 }
161 182
162 void ElementStyleResources::loadPendingImages(ComputedStyle* style) 183 void ElementStyleResources::loadPendingImages(ComputedStyle* style)
163 { 184 {
164 // We must loop over the properties and then look at the style to see if 185 // We must loop over the properties and then look at the style to see if
165 // a pending image exists, and only load that image. For example: 186 // a pending image exists, and only load that image. For example:
166 // 187 //
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 } 273 }
253 } 274 }
254 275
255 void ElementStyleResources::loadPendingResources(ComputedStyle* computedStyle) 276 void ElementStyleResources::loadPendingResources(ComputedStyle* computedStyle)
256 { 277 {
257 loadPendingImages(computedStyle); 278 loadPendingImages(computedStyle);
258 loadPendingSVGDocuments(computedStyle); 279 loadPendingSVGDocuments(computedStyle);
259 } 280 }
260 281
261 } // namespace blink 282 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSImageValue.cpp ('k') | third_party/WebKit/Source/core/fetch/ImageResource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698