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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/css/resolver/ElementStyleResources.cpp
diff --git a/third_party/WebKit/Source/core/css/resolver/ElementStyleResources.cpp b/third_party/WebKit/Source/core/css/resolver/ElementStyleResources.cpp
index 78c5335250e14d1948f73e9cb5d2662d7dbad87a..b71e3bcb0e15621898eeeac00dc0ea30472074c6 100644
--- a/third_party/WebKit/Source/core/css/resolver/ElementStyleResources.cpp
+++ b/third_party/WebKit/Source/core/css/resolver/ElementStyleResources.cpp
@@ -28,7 +28,9 @@
#include "core/css/CSSImageValue.h"
#include "core/css/CSSURIValue.h"
#include "core/dom/Document.h"
+#include "core/fetch/ImageResource.h"
#include "core/fetch/ResourceFetcher.h"
+#include "core/frame/Settings.h"
#include "core/layout/svg/ReferenceFilterBuilder.h"
#include "core/style/ComputedStyle.h"
#include "core/style/ContentData.h"
@@ -41,6 +43,8 @@
#include "core/style/StyleImage.h"
#include "core/style/StyleInvalidImage.h"
#include "core/style/StylePendingImage.h"
+#include "platform/Length.h"
+#include "platform/LengthPoint.h"
namespace blink {
@@ -133,10 +137,27 @@ void ElementStyleResources::loadPendingSVGDocuments(ComputedStyle* computedStyle
}
}
+static bool isSprite(const ComputedStyle& style)
+{
+ if (!style.hasBackgroundImage())
+ return false;
+
+ const FillLayer& background = style.backgroundLayers();
+ return (background.xPosition().isFixed() && !background.xPosition().isZero())
+ || (background.yPosition().isFixed() && !background.yPosition().isZero());
+}
+
+static ImageResource::PlaceholderRequestType determinePlaceholderRequestType(const Document& document, const ComputedStyle& style)
+{
+ return document.settings() && document.settings()->fetchImagePlaceholders() && !isSprite(style)
+ ? ImageResource::PlaceholderRequestType::AllowPlaceholder
+ : ImageResource::PlaceholderRequestType::DisallowPlaceholder;
+}
+
StyleImage* ElementStyleResources::loadPendingImage(ComputedStyle* style, StylePendingImage* pendingImage, CrossOriginAttributeValue crossOrigin)
{
if (CSSImageValue* imageValue = pendingImage->cssImageValue())
- return imageValue->cacheImage(*m_document, crossOrigin);
+ return imageValue->cacheImage(*m_document, crossOrigin, determinePlaceholderRequestType(*m_document, *style));
if (CSSPaintValue* paintValue = pendingImage->cssPaintValue()) {
StyleGeneratedImage* image = StyleGeneratedImage::create(*paintValue);
@@ -153,7 +174,7 @@ StyleImage* ElementStyleResources::loadPendingImage(ComputedStyle* style, StyleP
return cursorImageValue->cacheImage(*m_document, m_deviceScaleFactor);
if (CSSImageSetValue* imageSetValue = pendingImage->cssImageSetValue())
- return imageSetValue->cacheImage(*m_document, m_deviceScaleFactor, crossOrigin);
+ return imageSetValue->cacheImage(*m_document, m_deviceScaleFactor, crossOrigin, determinePlaceholderRequestType(*m_document, *style));
ASSERT_NOT_REACHED();
return nullptr;
« 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