Diff
Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog (205585 => 205586)
--- releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog 2016-09-08 06:02:15 UTC (rev 205585)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog 2016-09-08 06:31:44 UTC (rev 205586)
@@ -1,3 +1,114 @@
+2016-08-30 Antti Koivisto <an...@apple.com>
+
+ Remove StylePendingImage
+ https://bugs.webkit.org/show_bug.cgi?id=161245
+
+ Reviewed by Andreas Kling.
+
+ Instances of this confusing type are used as placeholders during style resolution.
+ We can get rid of it and make "pending" a state of StyleImage. This simplies the code and
+ will allow further improvements.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * css/CSSCrossfadeValue.cpp:
+ (WebCore::CSSCrossfadeValue::isPending):
+ (WebCore::CSSCrossfadeValue::blend):
+ * css/CSSCrossfadeValue.h:
+ * css/CSSCursorImageValue.cpp:
+ (WebCore::CSSCursorImageValue::CSSCursorImageValue):
+ (WebCore::CSSCursorImageValue::~CSSCursorImageValue):
+
+ Save the original URL since the underlying CSSImageValue may change.
+
+ (WebCore::CSSCursorImageValue::updateCursorElement):
+ (WebCore::CSSCursorImageValue::cursorElementRemoved):
+ (WebCore::CSSCursorImageValue::cursorElementChanged):
+ (WebCore::CSSCursorImageValue::loadImage):
+ (WebCore::CSSCursorImageValue::styleImage):
+ (WebCore::CSSCursorImageValue::isSVGCursor):
+ (WebCore::CSSCursorImageValue::cachedImageURL):
+ (WebCore::CSSCursorImageValue::updateCachedImage):
+ (WebCore::CSSCursorImageValue::detachPendingImage): Deleted.
+ (WebCore::CSSCursorImageValue::cachedImage): Deleted.
+ (WebCore::CSSCursorImageValue::cachedOrPendingImage): Deleted.
+ (WebCore::CSSCursorImageValue::clearCachedImage): Deleted.
+ * css/CSSCursorImageValue.h:
+ * css/CSSFilterImageValue.cpp:
+ (WebCore::CSSFilterImageValue::isPending):
+ * css/CSSFilterImageValue.h:
+ * css/CSSImageGeneratorValue.cpp:
+ (WebCore::CSSImageGeneratorValue::isPending):
+ (WebCore::CSSImageGeneratorValue::subimageIsPending):
+ (WebCore::CSSImageGeneratorValue::cachedImageForCSSValue):
+ * css/CSSImageGeneratorValue.h:
+ * css/CSSImageSetValue.cpp:
+ (WebCore::CSSImageSetValue::~CSSImageSetValue):
+ (WebCore::CSSImageSetValue::loadBestFitImage):
+ (WebCore::CSSImageSetValue::styleImage):
+ (WebCore::CSSImageSetValue::traverseSubresources):
+ (WebCore::CSSImageSetValue::detachPendingImage): Deleted.
+ (WebCore::CSSImageSetValue::bestFitImage): Deleted.
+ (WebCore::CSSImageSetValue::cachedOrPendingImageSet): Deleted.
+ * css/CSSImageSetValue.h:
+ * css/CSSImageValue.cpp:
+ (WebCore::CSSImageValue::CSSImageValue):
+ (WebCore::CSSImageValue::~CSSImageValue):
+ (WebCore::CSSImageValue::isPending):
+ (WebCore::CSSImageValue::styleImage):
+ (WebCore::CSSImageValue::loadImage):
+ (WebCore::CSSImageValue::traverseSubresources):
+ (WebCore::CSSImageValue::detachPendingImage): Deleted.
+ (WebCore::CSSImageValue::cachedOrPendingImage): Deleted.
+ (WebCore::CSSImageValue::cachedImage): Deleted.
+ * css/CSSImageValue.h:
+ (WebCore::CSSImageValue::create):
+ * css/StyleResolver.cpp:
+ (WebCore::StyleResolver::cachedOrPendingFromValue):
+ (WebCore::StyleResolver::generatedOrPendingFromValue):
+ (WebCore::StyleResolver::setOrPendingFromValue):
+ (WebCore::StyleResolver::cursorOrPendingFromValue):
+ * page/PageSerializer.cpp:
+ (WebCore::PageSerializer::retrieveResourcesForProperties):
+ * page/animation/CSSPropertyAnimation.cpp:
+ (WebCore::blendFilter):
+ (WebCore::crossfadeBlend):
+ * rendering/RenderImageResourceStyleImage.cpp:
+ (WebCore::RenderImageResourceStyleImage::image):
+ * rendering/shapes/ShapeOutsideInfo.cpp:
+ (WebCore::ShapeOutsideInfo::createShapeForImage):
+ * rendering/style/StyleCachedImage.cpp:
+ (WebCore::StyleCachedImage::StyleCachedImage):
+ (WebCore::StyleCachedImage::~StyleCachedImage):
+ (WebCore::StyleCachedImage::setCachedImage):
+ (WebCore::StyleCachedImage::cssValue):
+ (WebCore::StyleCachedImage::canRender):
+ (WebCore::StyleCachedImage::isPending):
+ (WebCore::StyleCachedImage::isLoaded):
+ (WebCore::StyleCachedImage::errorOccurred):
+ (WebCore::StyleCachedImage::imageSize):
+ (WebCore::StyleCachedImage::imageHasRelativeWidth):
+ (WebCore::StyleCachedImage::imageHasRelativeHeight):
+ (WebCore::StyleCachedImage::computeIntrinsicDimensions):
+ (WebCore::StyleCachedImage::usesImageContainerSize):
+ (WebCore::StyleCachedImage::setContainerSizeForRenderer):
+ (WebCore::StyleCachedImage::addClient):
+ (WebCore::StyleCachedImage::removeClient):
+ (WebCore::StyleCachedImage::image):
+ (WebCore::StyleCachedImage::knownToBeOpaque):
+ * rendering/style/StyleCachedImage.h:
+ * rendering/style/StyleGeneratedImage.cpp:
+ (WebCore::StyleGeneratedImage::isPending):
+ * rendering/style/StyleGeneratedImage.h:
+ * rendering/style/StyleImage.h:
+ (WebCore::StyleImage::isCachedImage):
+ (WebCore::StyleImage::StyleImage):
+ (WebCore::StyleImage::canRender): Deleted.
+ (WebCore::StyleImage::isPendingImage): Deleted.
+ * rendering/style/StylePendingImage.h: Removed.
+ * style/StylePendingResources.cpp:
+ (WebCore::Style::loadPendingImage):
+ (WebCore::Style::loadPendingImages):
+
2016-08-29 Alex Christensen <achristen...@webkit.org>
Fix Windows build after r205161
Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/WebCore.xcodeproj/project.pbxproj (205585 => 205586)
--- releases/WebKitGTK/webkit-2.14/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-09-08 06:02:15 UTC (rev 205585)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-09-08 06:31:44 UTC (rev 205586)
@@ -503,7 +503,6 @@
0F97A658155DA81E00FADD4C /* DisplayRefreshMonitorIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F97A657155DA81E00FADD4C /* DisplayRefreshMonitorIOS.mm */; };
0FA24D79162DF91900A3F4C0 /* GraphicsLayerUpdater.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FA24D77162DF91900A3F4C0 /* GraphicsLayerUpdater.cpp */; };
0FA24D7A162DF91900A3F4C0 /* GraphicsLayerUpdater.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FA24D78162DF91900A3F4C0 /* GraphicsLayerUpdater.h */; settings = {ATTRIBUTES = (Private, ); }; };
- 0FA6F96F1BCF614A0031EE70 /* StylePendingImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FA6F96E1BCF614A0031EE70 /* StylePendingImage.h */; };
0FA88EBD16A8D1BD00F99984 /* ScrollingStateFrameScrollingNodeMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0FA88EBC16A8D1BD00F99984 /* ScrollingStateFrameScrollingNodeMac.mm */; };
0FB6252E18DE1B1500A07C05 /* GeometryUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FB6252C18DE1B1500A07C05 /* GeometryUtilities.cpp */; };
0FB6252F18DE1B1500A07C05 /* GeometryUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FB6252D18DE1B1500A07C05 /* GeometryUtilities.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -7276,7 +7275,6 @@
0F97A657155DA81E00FADD4C /* DisplayRefreshMonitorIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DisplayRefreshMonitorIOS.mm; sourceTree = "<group>"; };
0FA24D77162DF91900A3F4C0 /* GraphicsLayerUpdater.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsLayerUpdater.cpp; sourceTree = "<group>"; };
0FA24D78162DF91900A3F4C0 /* GraphicsLayerUpdater.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsLayerUpdater.h; sourceTree = "<group>"; };
- 0FA6F96E1BCF614A0031EE70 /* StylePendingImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StylePendingImage.h; sourceTree = "<group>"; };
0FA88EBC16A8D1BD00F99984 /* ScrollingStateFrameScrollingNodeMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollingStateFrameScrollingNodeMac.mm; sourceTree = "<group>"; };
0FB6252C18DE1B1500A07C05 /* GeometryUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GeometryUtilities.cpp; sourceTree = "<group>"; };
0FB6252D18DE1B1500A07C05 /* GeometryUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeometryUtilities.h; sourceTree = "<group>"; };
@@ -21192,7 +21190,6 @@
BC5EB7280E81DE8100B25965 /* StyleMarqueeData.h */,
BC5EB74B0E81E06700B25965 /* StyleMultiColData.cpp */,
BC5EB74C0E81E06700B25965 /* StyleMultiColData.h */,
- 0FA6F96E1BCF614A0031EE70 /* StylePendingImage.h */,
BC2272E10E82EE9B00E7F975 /* StyleRareInheritedData.cpp */,
BC2272E20E82EE9B00E7F975 /* StyleRareInheritedData.h */,
BC2272BA0E82EAAE00E7F975 /* StyleRareNonInheritedData.cpp */,
@@ -26361,7 +26358,6 @@
BC5EB72A0E81DE8100B25965 /* StyleMarqueeData.h in Headers */,
0FF50272102BA96A0066F39A /* StyleMedia.h in Headers */,
BC5EB74E0E81E06700B25965 /* StyleMultiColData.h in Headers */,
- 0FA6F96F1BCF614A0031EE70 /* StylePendingImage.h in Headers */,
E4DACE6A1D12E10B0075980F /* StylePendingResources.h in Headers */,
A80E6DFC0A199067007FB8C5 /* StyleProperties.h in Headers */,
E1B25107152A0BB00069B779 /* StylePropertyShorthand.h in Headers */,
Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSCrossfadeValue.cpp (205585 => 205586)
--- releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSCrossfadeValue.cpp 2016-09-08 06:02:15 UTC (rev 205585)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSCrossfadeValue.cpp 2016-09-08 06:31:44 UTC (rev 205586)
@@ -110,7 +110,7 @@
fromImageSize.height() * inversePercentage + toImageSize.height() * percentage);
}
-bool CSSCrossfadeValue::isPending()
+bool CSSCrossfadeValue::isPending() const
{
return CSSImageGeneratorValue::subimageIsPending(m_fromValue)
|| CSSImageGeneratorValue::subimageIsPending(m_toValue);
@@ -199,12 +199,9 @@
ASSERT(equalInputImages(from));
if (!m_cachedToImage || !m_cachedFromImage)
return nullptr;
- RefPtr<StyleCachedImage> toStyledImage = StyleCachedImage::create(m_cachedToImage.get());
- RefPtr<StyleCachedImage> fromStyledImage = StyleCachedImage::create(m_cachedFromImage.get());
+ auto fromImageValue = CSSImageValue::create(*m_cachedFromImage);
+ auto toImageValue = CSSImageValue::create(*m_cachedToImage);
- auto fromImageValue = CSSImageValue::create(m_cachedFromImage->url(), fromStyledImage.get());
- auto toImageValue = CSSImageValue::create(m_cachedToImage->url(), toStyledImage.get());
-
double fromPercentage = from.m_percentageValue->getDoubleValue();
if (from.m_percentageValue->isPercentage())
fromPercentage /= 100.0;
Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSCrossfadeValue.h (205585 => 205586)
--- releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSCrossfadeValue.h 2016-09-08 06:02:15 UTC (rev 205585)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSCrossfadeValue.h 2016-09-08 06:31:44 UTC (rev 205586)
@@ -57,7 +57,7 @@
FloatSize fixedSize(const RenderElement*);
bool isPrefixed() const { return m_isPrefixed; }
- bool isPending();
+ bool isPending() const;
bool knownToBeOpaque(const RenderElement*) const;
void loadSubimages(CachedResourceLoader&, const ResourceLoaderOptions&);
Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSCursorImageValue.cpp (205585 => 205586)
--- releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSCursorImageValue.cpp 2016-09-08 06:02:15 UTC (rev 205585)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSCursorImageValue.cpp 2016-09-08 06:31:44 UTC (rev 205586)
@@ -28,7 +28,6 @@
#include "CachedResourceLoader.h"
#include "StyleCachedImage.h"
#include "StyleImage.h"
-#include "StylePendingImage.h"
#include "SVGCursorElement.h"
#include "SVGLengthContext.h"
#include "SVGNames.h"
@@ -46,18 +45,12 @@
, m_hasHotSpot(hasHotSpot)
, m_hotSpot(hotSpot)
{
+ if (is<CSSImageValue>(m_imageValue.get()))
+ m_originalURL = { ParsedURLString, downcast<CSSImageValue>(m_imageValue.get()).url() };
}
-inline void CSSCursorImageValue::detachPendingImage()
-{
- if (is<StylePendingImage>(m_image.get()))
- downcast<StylePendingImage>(*m_image).detachFromCSSValue();
-}
-
CSSCursorImageValue::~CSSCursorImageValue()
{
- detachPendingImage();
-
for (auto* element : m_cursorElements)
element->removeClient(*this);
}
@@ -77,10 +70,10 @@
SVGCursorElement* CSSCursorImageValue::updateCursorElement(const Document& document)
{
- if (!isSVGCursor())
+ if (!m_originalURL.hasFragmentIdentifier())
return nullptr;
- auto* element = SVGURIReference::targetElementFromIRIString(downcast<CSSImageValue>(m_imageValue.get()).url(), document);
+ auto* element = SVGURIReference::targetElementFromIRIString(m_originalURL, document);
if (!is<SVGCursorElement>(element))
return nullptr;
@@ -95,13 +88,10 @@
void CSSCursorImageValue::cursorElementRemoved(SVGCursorElement& cursorElement)
{
m_cursorElements.remove(&cursorElement);
- clearCachedImage();
}
void CSSCursorImageValue::cursorElementChanged(SVGCursorElement& cursorElement)
{
- clearCachedImage();
-
// FIXME: This will override hot spot specified in CSS, which is probably incorrect.
SVGLengthContext lengthContext(nullptr);
m_hasHotSpot = true;
@@ -112,73 +102,34 @@
m_hotSpot.setY(static_cast<int>(y));
}
-StyleImage* CSSCursorImageValue::cachedImage(CachedResourceLoader& loader, const ResourceLoaderOptions& options)
+void CSSCursorImageValue::loadImage(CachedResourceLoader& loader, const ResourceLoaderOptions& options)
{
- if (is<CSSImageSetValue>(m_imageValue.get()))
- return downcast<CSSImageSetValue>(m_imageValue.get()).bestFitImage(loader, options);
-
- auto* cursorElement = loader.document() ? updateCursorElement(*loader.document()) : nullptr;
-
- if (!m_isImageValid) {
- m_isImageValid = true;
- // For SVG images we need to lazily substitute in the correct URL. Rather than attempt
- // to change the URL of the CSSImageValue (which would then change behavior like cssText),
- // we create an alternate CSSImageValue to use.
- if (cursorElement) {
- detachPendingImage();
- Ref<CSSImageValue> svgImageValue(CSSImageValue::create(cursorElement->href()));
- StyleCachedImage* cachedImage = svgImageValue->cachedImage(loader, options);
- m_image = cachedImage;
- return cachedImage;
- }
-
- if (is<CSSImageValue>(m_imageValue.get())) {
- detachPendingImage();
- m_image = downcast<CSSImageValue>(m_imageValue.get()).cachedImage(loader, options);
- }
+ if (is<CSSImageSetValue>(m_imageValue.get())) {
+ downcast<CSSImageSetValue>(m_imageValue.get()).loadBestFitImage(loader, options);
+ return;
}
- if (is<StyleCachedImage>(m_image.get()))
- return downcast<StyleCachedImage>(m_image.get());
-
- return nullptr;
+ downcast<CSSImageValue>(m_imageValue.get()).loadImage(loader, options);
}
-StyleImage* CSSCursorImageValue::cachedOrPendingImage(const Document& document)
+StyleCachedImage& CSSCursorImageValue::styleImage(const Document& document)
{
// Need to delegate completely so that changes in device scale factor can be handled appropriately.
+ StyleCachedImage* styleImage;
if (is<CSSImageSetValue>(m_imageValue.get()))
- return downcast<CSSImageSetValue>(m_imageValue.get()).cachedOrPendingImageSet(document);
-
- if (!m_image)
- m_image = StylePendingImage::create(this);
-
- return m_image.get();
-}
-
-bool CSSCursorImageValue::isSVGCursor() const
-{
- if (is<CSSImageValue>(m_imageValue.get())) {
- URL kurl(ParsedURLString, downcast<CSSImageValue>(m_imageValue.get()).url());
- return kurl.hasFragmentIdentifier();
+ styleImage = &downcast<CSSImageSetValue>(m_imageValue.get()).styleImage(document);
+ else {
+ if (auto* cursorElement = updateCursorElement(document)) {
+ if (cursorElement->href() != downcast<CSSImageValue>(m_imageValue.get()).url())
+ m_imageValue = CSSImageValue::create(cursorElement->href());
+ }
+ styleImage = &downcast<CSSImageValue>(m_imageValue.get()).styleImage();
}
- return false;
-}
+ styleImage->setCSSValue(*this);
-String CSSCursorImageValue::cachedImageURL()
-{
- if (!is<StyleCachedImage>(m_image.get()))
- return String();
- return downcast<StyleCachedImage>(*m_image).cachedImage()->url();
+ return *styleImage;
}
-void CSSCursorImageValue::clearCachedImage()
-{
- detachPendingImage();
- m_image = nullptr;
- m_isImageValid = false;
-}
-
bool CSSCursorImageValue::equals(const CSSCursorImageValue& other) const
{
return m_hasHotSpot ? other.m_hasHotSpot && m_hotSpot == other.m_hotSpot : !other.m_hasHotSpot
Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSCursorImageValue.h (205585 => 205586)
--- releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSCursorImageValue.h 2016-09-08 06:02:15 UTC (rev 205585)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSCursorImageValue.h 2016-09-08 06:31:44 UTC (rev 205586)
@@ -31,6 +31,7 @@
class Element;
class SVGCursorElement;
class SVGElement;
+class StyleCachedImage;
class CSSCursorImageValue final : public CSSValue {
public:
@@ -52,9 +53,8 @@
String customCSSText() const;
- SVGCursorElement* updateCursorElement(const Document&);
- StyleImage* cachedImage(CachedResourceLoader&, const ResourceLoaderOptions&);
- StyleImage* cachedOrPendingImage(const Document&);
+ void loadImage(CachedResourceLoader&, const ResourceLoaderOptions&);
+ StyleCachedImage& styleImage(const Document&);
void removeReferencedElement(SVGElement*);
@@ -66,18 +66,13 @@
private:
CSSCursorImageValue(Ref<CSSValue>&& imageValue, bool hasHotSpot, const IntPoint& hotSpot);
- void detachPendingImage();
+ SVGCursorElement* updateCursorElement(const Document&);
- bool isSVGCursor() const;
- String cachedImageURL();
- void clearCachedImage();
-
+ URL m_originalURL;
Ref<CSSValue> m_imageValue;
bool m_hasHotSpot;
IntPoint m_hotSpot;
- RefPtr<StyleImage> m_image;
- bool m_isImageValid { false };
HashSet<SVGCursorElement*> m_cursorElements;
};
Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSFilterImageValue.cpp (205585 => 205586)
--- releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSFilterImageValue.cpp 2016-09-08 06:02:15 UTC (rev 205585)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSFilterImageValue.cpp 2016-09-08 06:31:44 UTC (rev 205586)
@@ -73,7 +73,7 @@
return cachedImage->imageForRenderer(renderer)->size();
}
-bool CSSFilterImageValue::isPending()
+bool CSSFilterImageValue::isPending() const
{
return CSSImageGeneratorValue::subimageIsPending(m_imageValue);
}
Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSFilterImageValue.h (205585 => 205586)
--- releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSFilterImageValue.h 2016-09-08 06:02:15 UTC (rev 205585)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSFilterImageValue.h 2016-09-08 06:31:44 UTC (rev 205586)
@@ -59,7 +59,7 @@
bool isFixedSize() const { return true; }
FloatSize fixedSize(const RenderElement*);
- bool isPending();
+ bool isPending() const;
bool knownToBeOpaque(const RenderElement*) const;
void loadSubimages(CachedResourceLoader&, const ResourceLoaderOptions&);
Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSImageGeneratorValue.cpp (205585 => 205586)
--- releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSImageGeneratorValue.cpp 2016-09-08 06:02:15 UTC (rev 205585)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSImageGeneratorValue.cpp 2016-09-08 06:31:44 UTC (rev 205586)
@@ -167,7 +167,7 @@
return FloatSize();
}
-bool CSSImageGeneratorValue::isPending()
+bool CSSImageGeneratorValue::isPending() const
{
switch (classType()) {
case CrossfadeClass:
@@ -232,10 +232,10 @@
}
}
-bool CSSImageGeneratorValue::subimageIsPending(CSSValue& value)
+bool CSSImageGeneratorValue::subimageIsPending(const CSSValue& value)
{
if (is<CSSImageValue>(value))
- return downcast<CSSImageValue>(value).cachedOrPendingImage().isPendingImage();
+ return downcast<CSSImageValue>(value).isPending();
if (is<CSSImageGeneratorValue>(value))
return downcast<CSSImageGeneratorValue>(value).isPending();
@@ -251,11 +251,9 @@
CachedImage* CSSImageGeneratorValue::cachedImageForCSSValue(CSSValue& value, CachedResourceLoader& cachedResourceLoader, const ResourceLoaderOptions& options)
{
if (is<CSSImageValue>(value)) {
- StyleCachedImage* styleCachedImage = downcast<CSSImageValue>(value).cachedImage(cachedResourceLoader, options);
- if (!styleCachedImage)
- return nullptr;
-
- return styleCachedImage->cachedImage();
+ auto& imageValue = downcast<CSSImageValue>(value);
+ imageValue.loadImage(cachedResourceLoader, options);
+ return imageValue.styleImage().cachedImage();
}
if (is<CSSImageGeneratorValue>(value)) {
Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSImageGeneratorValue.h (205585 => 205586)
--- releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSImageGeneratorValue.h 2016-09-08 06:02:15 UTC (rev 205585)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSImageGeneratorValue.h 2016-09-08 06:31:44 UTC (rev 205586)
@@ -54,7 +54,7 @@
bool isFixedSize() const;
FloatSize fixedSize(const RenderElement*);
- bool isPending();
+ bool isPending() const;
bool knownToBeOpaque(const RenderElement*) const;
void loadSubimages(CachedResourceLoader&, const ResourceLoaderOptions&);
@@ -68,7 +68,7 @@
// Helper functions for Crossfade and Filter.
static CachedImage* cachedImageForCSSValue(CSSValue&, CachedResourceLoader&, const ResourceLoaderOptions&);
- static bool subimageIsPending(CSSValue&);
+ static bool subimageIsPending(const CSSValue&);
private:
class CachedGeneratedImage {
Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSImageSetValue.cpp (205585 => 205586)
--- releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSImageSetValue.cpp 2016-09-08 06:02:15 UTC (rev 205585)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSImageSetValue.cpp 2016-09-08 06:31:44 UTC (rev 205586)
@@ -36,7 +36,6 @@
#include "Document.h"
#include "Page.h"
#include "StyleCachedImage.h"
-#include "StylePendingImage.h"
#include <wtf/text/StringBuilder.h>
namespace WebCore {
@@ -48,18 +47,10 @@
{
}
-inline void CSSImageSetValue::detachPendingImage()
-{
- if (is<StylePendingImage>(m_image.get()))
- downcast<StylePendingImage>(*m_image).detachFromCSSValue();
-}
-
CSSImageSetValue::~CSSImageSetValue()
{
- detachPendingImage();
-
- if (is<StyleCachedImage>(m_image.get()))
- downcast<StyleCachedImage>(*m_image).detachFromCSSValue();
+ if (m_image)
+ m_image->detachFromCSSValue();
}
void CSSImageSetValue::fillImageSet()
@@ -98,7 +89,7 @@
return image;
}
-StyleCachedImage* CSSImageSetValue::bestFitImage(CachedResourceLoader& loader, const ResourceLoaderOptions& options)
+void CSSImageSetValue::loadBestFitImage(CachedResourceLoader& loader, const ResourceLoaderOptions& options)
{
Document* document = loader.document();
if (Page* page = document->page())
@@ -109,32 +100,29 @@
if (!m_imagesInSet.size())
fillImageSet();
- if (!m_accessedBestFitImage) {
- // FIXME: In the future, we want to take much more than deviceScaleFactor into acount here.
- // All forms of scale should be included: Page::pageScaleFactor(), Frame::pageZoomFactor(),
- // and any CSS transforms. https://bugs.webkit.org/show_bug.cgi?id=81698
- ImageWithScale image = bestImageForScaleFactor();
- CachedResourceRequest request(ResourceRequest(document->completeURL(image.imageURL)), options);
- request.setInitiator(cachedResourceRequestInitiators().css);
- if (options.mode == FetchOptions::Mode::Cors) {
- ASSERT(document->securityOrigin());
- updateRequestForAccessControl(request.mutableResourceRequest(), *document->securityOrigin(), options.allowCredentials);
- }
- if (CachedResourceHandle<CachedImage> cachedImage = loader.requestImage(request)) {
- detachPendingImage();
- m_image = StyleCachedImage::createForImageSet(cachedImage.get(), image.scaleFactor, *this);
- m_accessedBestFitImage = true;
- }
+ if (m_accessedBestFitImage)
+ return;
+ // FIXME: In the future, we want to take much more than deviceScaleFactor into acount here.
+ // All forms of scale should be included: Page::pageScaleFactor(), Frame::pageZoomFactor(),
+ // and any CSS transforms. https://bugs.webkit.org/show_bug.cgi?id=81698
+ ImageWithScale image = bestImageForScaleFactor();
+ CachedResourceRequest request(ResourceRequest(document->completeURL(image.imageURL)), options);
+ request.setInitiator(cachedResourceRequestInitiators().css);
+ if (options.mode == FetchOptions::Mode::Cors) {
+ ASSERT(document->securityOrigin());
+ updateRequestForAccessControl(request.mutableResourceRequest(), *document->securityOrigin(), options.allowCredentials);
}
-
- return is<StyleCachedImage>(m_image.get()) ? downcast<StyleCachedImage>(m_image.get()) : nullptr;
+ if (CachedResourceHandle<CachedImage> cachedImage = loader.requestImage(request)) {
+ styleImage(*document).setCachedImage(*cachedImage, image.scaleFactor);
+ m_accessedBestFitImage = true;
+ }
}
-StyleImage* CSSImageSetValue::cachedOrPendingImageSet(const Document& document)
+StyleCachedImage& CSSImageSetValue::styleImage(const Document& document)
{
if (!m_image)
- m_image = StylePendingImage::create(this);
- else if (!m_image->isPendingImage()) {
+ m_image = StyleCachedImage::create(*this);
+ else if (!m_image->isPending()) {
float deviceScaleFactor = 1;
if (Page* page = document.page())
deviceScaleFactor = page->deviceScaleFactor();
@@ -142,11 +130,12 @@
// If the deviceScaleFactor has changed, we may not have the best image loaded, so we have to re-assess.
if (deviceScaleFactor != m_scaleFactor) {
m_accessedBestFitImage = false;
- m_image = StylePendingImage::create(this);
+ m_image->detachFromCSSValue();
+ m_image = StyleCachedImage::create(*this);
}
}
- return m_image.get();
+ return *m_image;
}
String CSSImageSetValue::customCSSText() const
@@ -181,10 +170,11 @@
bool CSSImageSetValue::traverseSubresources(const std::function<bool (const CachedResource&)>& handler) const
{
- if (!is<StyleCachedImage>(m_image.get()))
+ if (!m_image)
return false;
- CachedImage* cachedResource = downcast<StyleCachedImage>(*m_image).cachedImage();
- ASSERT(cachedResource);
+ CachedImage* cachedResource = m_image->cachedImage();
+ if (!cachedResource)
+ return false;
return handler(*cachedResource);
}
Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSImageSetValue.h (205585 => 205586)
--- releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSImageSetValue.h 2016-09-08 06:02:15 UTC (rev 205585)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSImageSetValue.h 2016-09-08 06:31:44 UTC (rev 205586)
@@ -45,11 +45,9 @@
}
~CSSImageSetValue();
- StyleCachedImage* bestFitImage(CachedResourceLoader&, const ResourceLoaderOptions&);
+ void loadBestFitImage(CachedResourceLoader&, const ResourceLoaderOptions&);
+ StyleCachedImage& styleImage(const Document&);
- // Returns a StyleCachedImage if the best fit image has been cached already, otherwise a StylePendingImage.
- StyleImage* cachedOrPendingImageSet(const Document&);
-
String customCSSText() const;
bool isPending() const { return !m_accessedBestFitImage; }
@@ -70,11 +68,10 @@
CSSImageSetValue();
CSSImageSetValue(const CSSImageSetValue& cloneFrom);
- void detachPendingImage();
void fillImageSet();
static inline bool compareByScaleFactor(ImageWithScale first, ImageWithScale second) { return first.scaleFactor < second.scaleFactor; }
- RefPtr<StyleImage> m_image;
+ RefPtr<StyleCachedImage> m_image;
bool m_accessedBestFitImage;
// This represents the scale factor that we used to find the best fit image. It does not necessarily
Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSImageValue.cpp (205585 => 205586)
--- releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSImageValue.cpp 2016-09-08 06:02:15 UTC (rev 205585)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSImageValue.cpp 2016-09-08 06:31:44 UTC (rev 205586)
@@ -33,7 +33,6 @@
#include "Element.h"
#include "MemoryCache.h"
#include "StyleCachedImage.h"
-#include "StylePendingImage.h"
namespace WebCore {
@@ -44,63 +43,62 @@
{
}
-CSSImageValue::CSSImageValue(const String& url, StyleImage* image)
+CSSImageValue::CSSImageValue(CachedImage& image)
: CSSValue(ImageClass)
- , m_url(url)
- , m_image(image)
+ , m_url(image.url())
+ , m_image(StyleCachedImage::create(*this))
, m_accessedImage(true)
{
+ m_image->setCachedImage(image);
}
-inline void CSSImageValue::detachPendingImage()
+
+CSSImageValue::~CSSImageValue()
{
- if (is<StylePendingImage>(m_image.get()))
- downcast<StylePendingImage>(*m_image).detachFromCSSValue();
+ if (m_image)
+ m_image->detachFromCSSValue();
}
-CSSImageValue::~CSSImageValue()
+bool CSSImageValue::isPending() const
{
- detachPendingImage();
+ return !m_image || !m_image->cachedImage();
}
-StyleImage& CSSImageValue::cachedOrPendingImage()
+StyleCachedImage& CSSImageValue::styleImage()
{
if (!m_image)
- m_image = StylePendingImage::create(this);
+ m_image = StyleCachedImage::create(*this);
return *m_image;
}
-StyleCachedImage* CSSImageValue::cachedImage(CachedResourceLoader& loader, const ResourceLoaderOptions& options)
+void CSSImageValue::loadImage(CachedResourceLoader& loader, const ResourceLoaderOptions& options)
{
- if (!m_accessedImage) {
- m_accessedImage = true;
+ if (m_accessedImage)
+ return;
+ m_accessedImage = true;
- CachedResourceRequest request(ResourceRequest(loader.document()->completeURL(m_url)), options);
- if (m_initiatorName.isEmpty())
- request.setInitiator(cachedResourceRequestInitiators().css);
- else
- request.setInitiator(m_initiatorName);
+ CachedResourceRequest request(ResourceRequest(loader.document()->completeURL(m_url)), options);
+ if (m_initiatorName.isEmpty())
+ request.setInitiator(cachedResourceRequestInitiators().css);
+ else
+ request.setInitiator(m_initiatorName);
- if (options.mode == FetchOptions::Mode::Cors) {
- ASSERT(loader.document()->securityOrigin());
- updateRequestForAccessControl(request.mutableResourceRequest(), *loader.document()->securityOrigin(), options.allowCredentials);
- }
- if (CachedResourceHandle<CachedImage> cachedImage = loader.requestImage(request)) {
- detachPendingImage();
- m_image = StyleCachedImage::create(cachedImage.get());
- }
+ if (options.mode == FetchOptions::Mode::Cors) {
+ ASSERT(loader.document()->securityOrigin());
+ updateRequestForAccessControl(request.mutableResourceRequest(), *loader.document()->securityOrigin(), options.allowCredentials);
}
-
- return is<StyleCachedImage>(m_image.get()) ? downcast<StyleCachedImage>(m_image.get()) : nullptr;
+ if (CachedResourceHandle<CachedImage> cachedImage = loader.requestImage(request))
+ styleImage().setCachedImage(*cachedImage);
}
bool CSSImageValue::traverseSubresources(const std::function<bool (const CachedResource&)>& handler) const
{
- if (!is<StyleCachedImage>(m_image.get()))
+ if (!m_image)
return false;
- CachedResource* cachedResource = downcast<StyleCachedImage>(*m_image).cachedImage();
- ASSERT(cachedResource);
+ CachedResource* cachedResource = m_image->cachedImage();
+ if (!cachedResource)
+ return false;
return handler(*cachedResource);
}
Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSImageValue.h (205585 => 205586)
--- releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSImageValue.h 2016-09-08 06:02:15 UTC (rev 205585)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/css/CSSImageValue.h 2016-09-08 06:31:44 UTC (rev 205586)
@@ -26,10 +26,10 @@
namespace WebCore {
+class CachedImage;
class CachedResourceLoader;
class Element;
class StyleCachedImage;
-class StyleImage;
class RenderElement;
struct ResourceLoaderOptions;
@@ -36,12 +36,12 @@
class CSSImageValue final : public CSSValue {
public:
static Ref<CSSImageValue> create(const String& url) { return adoptRef(*new CSSImageValue(url)); }
- static Ref<CSSImageValue> create(const String& url, StyleImage* image) { return adoptRef(*new CSSImageValue(url, image)); }
+ static Ref<CSSImageValue> create(CachedImage& image) { return adoptRef(*new CSSImageValue(image)); }
~CSSImageValue();
- StyleCachedImage* cachedImage(CachedResourceLoader&, const ResourceLoaderOptions&);
- // Returns a StyleCachedImage if the image is cached already, otherwise a StylePendingImage.
- StyleImage& cachedOrPendingImage();
+ bool isPending() const;
+ void loadImage(CachedResourceLoader&, const ResourceLoaderOptions&);
+ StyleCachedImage& styleImage();
const String& url() const { return m_url; }
@@ -59,11 +59,10 @@
private:
explicit CSSImageValue(const String& url);
- CSSImageValue(const String& url, StyleImage*);
- void detachPendingImage();
+ explicit CSSImageValue(CachedImage&);
String m_url;
- RefPtr<StyleImage> m_image;
+ RefPtr<StyleCachedImage> m_image;
bool m_accessedImage;
AtomicString m_initiatorName;
};
Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/css/StyleResolver.cpp (205585 => 205586)
--- releases/WebKitGTK/webkit-2.14/Source/WebCore/css/StyleResolver.cpp 2016-09-08 06:02:15 UTC (rev 205585)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/css/StyleResolver.cpp 2016-09-08 06:31:44 UTC (rev 205586)
@@ -123,7 +123,6 @@
#include "StyleCachedImage.h"
#include "StyleFontSizeFunctions.h"
#include "StyleGeneratedImage.h"
-#include "StylePendingImage.h"
#include "StyleProperties.h"
#include "StylePropertyShorthand.h"
#include "StyleRule.h"
@@ -1723,8 +1722,8 @@
Ref<StyleImage> StyleResolver::cachedOrPendingFromValue(CSSPropertyID property, CSSImageValue& value)
{
- Ref<StyleImage> image = value.cachedOrPendingImage();
- if (image->isPendingImage())
+ Ref<StyleImage> image = value.styleImage();
+ if (image->isPending())
m_state.ensurePendingResources().pendingImages.set(property, &value);
return image;
}
@@ -1735,28 +1734,26 @@
// FilterImage needs to calculate FilterOperations.
downcast<CSSFilterImageValue>(value).createFilterOperations(this);
}
+ if (value.isPending())
+ m_state.ensurePendingResources().pendingImages.set(property, &value);
- if (value.isPending()) {
- m_state.ensurePendingResources().pendingImages.set(property, &value);
- return StylePendingImage::create(&value);
- }
return StyleGeneratedImage::create(value);
}
RefPtr<StyleImage> StyleResolver::setOrPendingFromValue(CSSPropertyID property, CSSImageSetValue& value)
{
- RefPtr<StyleImage> image = value.cachedOrPendingImageSet(document());
- if (image && image->isPendingImage())
+ auto& image = value.styleImage(document());
+ if (image.isPending())
m_state.ensurePendingResources().pendingImages.set(property, &value);
- return image;
+ return ℑ
}
RefPtr<StyleImage> StyleResolver::cursorOrPendingFromValue(CSSPropertyID property, CSSCursorImageValue& value)
{
- RefPtr<StyleImage> image = value.cachedOrPendingImage(document());
- if (image && image->isPendingImage())
+ auto& image = value.styleImage(document());
+ if (image.isPending())
m_state.ensurePendingResources().pendingImages.set(property, &value);
- return image;
+ return ℑ
}
#if ENABLE(IOS_TEXT_AUTOSIZING)
Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/page/PageSerializer.cpp (205585 => 205586)
--- releases/WebKitGTK/webkit-2.14/Source/WebCore/page/PageSerializer.cpp 2016-09-08 06:02:15 UTC (rev 205585)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/page/PageSerializer.cpp 2016-09-08 06:31:44 UTC (rev 205586)
@@ -331,13 +331,12 @@
if (!is<CSSImageValue>(*cssValue))
continue;
- auto& styleImage = downcast<CSSImageValue>(*cssValue).cachedOrPendingImage();
- // Non cached-images are just place-holders and do not contain data.
- if (!is<StyleCachedImage>(styleImage))
+ auto& styleImage = downcast<CSSImageValue>(*cssValue).styleImage();
+
+ auto* image = styleImage.cachedImage();
+ if (!image)
continue;
- CachedImage* image = downcast<StyleCachedImage>(styleImage).cachedImage();
-
URL url = ""
addImageToResources(image, nullptr, url);
}
Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/page/animation/CSSPropertyAnimation.cpp (205585 => 205586)
--- releases/WebKitGTK/webkit-2.14/Source/WebCore/page/animation/CSSPropertyAnimation.cpp 2016-09-08 06:02:15 UTC (rev 205585)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/page/animation/CSSPropertyAnimation.cpp 2016-09-08 06:31:44 UTC (rev 205586)
@@ -225,8 +225,7 @@
ASSERT(image);
FilterOperations filterResult = blendFilterOperations(anim, from, to, progress);
- RefPtr<StyleCachedImage> styledImage = StyleCachedImage::create(image);
- auto imageValue = CSSImageValue::create(image->url(), styledImage.get());
+ auto imageValue = CSSImageValue::create(*image);
auto filterValue = ComputedStyleExtractor::valueForFilter(anim->renderer()->style(), filterResult, DoNotAdjustPixelValues);
auto result = CSSFilterImageValue::create(WTFMove(imageValue), WTFMove(filterValue));
@@ -290,8 +289,8 @@
if (progress == 1)
return toStyleImage;
- auto fromImageValue = CSSImageValue::create(fromStyleImage->cachedImage()->url(), fromStyleImage);
- auto toImageValue = CSSImageValue::create(toStyleImage->cachedImage()->url(), toStyleImage);
+ auto fromImageValue = CSSImageValue::create(*fromStyleImage->cachedImage());
+ auto toImageValue = CSSImageValue::create(*toStyleImage->cachedImage());
auto percentageValue = CSSPrimitiveValue::create(progress, CSSPrimitiveValue::CSS_NUMBER);
auto crossfadeValue = CSSCrossfadeValue::create(WTFMove(fromImageValue), WTFMove(toImageValue), WTFMove(percentageValue));
Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/RenderImageResourceStyleImage.cpp (205585 => 205586)
--- releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/RenderImageResourceStyleImage.cpp 2016-09-08 06:02:15 UTC (rev 205585)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/RenderImageResourceStyleImage.cpp 2016-09-08 06:31:44 UTC (rev 205586)
@@ -63,7 +63,7 @@
RefPtr<Image> RenderImageResourceStyleImage::image(int width, int height) const
{
// Generated content may trigger calls to image() while we're still pending, don't assert but gracefully exit.
- if (m_styleImage->isPendingImage())
+ if (m_styleImage->isPending())
return nullptr;
return m_styleImage->image(m_renderer, IntSize(width, height));
}
Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp (205585 => 205586)
--- releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp 2016-09-08 06:02:15 UTC (rev 205585)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp 2016-09-08 06:31:44 UTC (rev 205586)
@@ -156,7 +156,7 @@
? downcast<RenderImage>(m_renderer).replacedContentRect(m_renderer.intrinsicSize())
: LayoutRect(LayoutPoint(), imageSize);
- ASSERT(!styleImage->isPendingImage());
+ ASSERT(!styleImage->isPending());
RefPtr<Image> image = styleImage->image(const_cast<RenderBox*>(&m_renderer), imageSize);
return Shape::createRasterShape(image.get(), shapeImageThreshold, imageRect, marginRect, writingMode, margin);
}
Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/style/StyleCachedImage.cpp (205585 => 205586)
--- releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/style/StyleCachedImage.cpp 2016-09-08 06:02:15 UTC (rev 205585)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/style/StyleCachedImage.cpp 2016-09-08 06:31:44 UTC (rev 205586)
@@ -30,44 +30,63 @@
namespace WebCore {
-StyleCachedImage::StyleCachedImage(CachedImage* image, float scaleFactor, CSSImageSetValue* cssValue)
- : m_image(image)
- , m_scaleFactor(scaleFactor)
- , m_cssImageSetValue(cssValue)
+StyleCachedImage::StyleCachedImage(CSSValue& cssValue)
+ : m_cssValue(&cssValue)
{
m_isCachedImage = true;
- m_image->addClient(this);
}
StyleCachedImage::~StyleCachedImage()
{
- m_image->removeClient(this);
+ if (m_image)
+ m_image->removeClient(this);
}
+void StyleCachedImage::setCachedImage(CachedImage& image, float scaleFactor)
+{
+ ASSERT(!m_image);
+ m_image = ℑ
+ m_image->addClient(this);
+ m_scaleFactor = scaleFactor;
+}
+
PassRefPtr<CSSValue> StyleCachedImage::cssValue() const
{
- if (m_cssImageSetValue)
- return const_cast<CSSImageSetValue*>(m_cssImageSetValue);
+ if (m_cssValue)
+ return m_cssValue;
return CSSPrimitiveValue::create(m_image->url(), CSSPrimitiveValue::CSS_URI);
}
bool StyleCachedImage::canRender(const RenderObject* renderer, float multiplier) const
{
+ if (!m_image)
+ return false;
return m_image->canRender(renderer, multiplier);
}
+bool StyleCachedImage::isPending() const
+{
+ return !m_image;
+}
+
bool StyleCachedImage::isLoaded() const
{
+ if (!m_image)
+ return false;
return m_image->isLoaded();
}
bool StyleCachedImage::errorOccurred() const
{
+ if (!m_image)
+ return false;
return m_image->errorOccurred();
}
FloatSize StyleCachedImage::imageSize(const RenderElement* renderer, float multiplier) const
{
+ if (!m_image)
+ return { };
FloatSize size = m_image->imageSizeForRenderer(renderer, multiplier);
size.scale(1 / m_scaleFactor);
return size;
@@ -75,41 +94,57 @@
bool StyleCachedImage::imageHasRelativeWidth() const
{
+ if (!m_image)
+ return false;
return m_image->imageHasRelativeWidth();
}
bool StyleCachedImage::imageHasRelativeHeight() const
{
+ if (!m_image)
+ return false;
return m_image->imageHasRelativeHeight();
}
void StyleCachedImage::computeIntrinsicDimensions(const RenderElement*, Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio)
{
+ if (!m_image)
+ return;
m_image->computeIntrinsicDimensions(intrinsicWidth, intrinsicHeight, intrinsicRatio);
}
bool StyleCachedImage::usesImageContainerSize() const
{
+ if (!m_image)
+ return false;
return m_image->usesImageContainerSize();
}
void StyleCachedImage::setContainerSizeForRenderer(const RenderElement* renderer, const FloatSize& imageContainerSize, float imageContainerZoomFactor)
{
+ if (!m_image)
+ return;
m_image->setContainerSizeForRenderer(renderer, LayoutSize(imageContainerSize), imageContainerZoomFactor);
}
void StyleCachedImage::addClient(RenderElement* renderer)
{
+ if (!m_image)
+ return;
m_image->addClient(renderer);
}
void StyleCachedImage::removeClient(RenderElement* renderer)
{
+ if (!m_image)
+ return;
m_image->removeClient(renderer);
}
RefPtr<Image> StyleCachedImage::image(RenderElement* renderer, const FloatSize&) const
{
+ if (!m_image)
+ return nullptr;
return m_image->imageForRenderer(renderer);
}
@@ -120,6 +155,8 @@
bool StyleCachedImage::knownToBeOpaque(const RenderElement* renderer) const
{
+ if (!m_image)
+ return false;
return m_image->currentFrameKnownToBeOpaque(renderer);
}
Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/style/StyleCachedImage.h (205585 => 205586)
--- releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/style/StyleCachedImage.h 2016-09-08 06:02:15 UTC (rev 205585)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/style/StyleCachedImage.h 2016-09-08 06:31:44 UTC (rev 205586)
@@ -30,26 +30,28 @@
namespace WebCore {
-class CSSImageSetValue;
+class CSSValue;
class CachedImage;
class StyleCachedImage final : public StyleImage, private CachedImageClient {
WTF_MAKE_FAST_ALLOCATED;
public:
- static Ref<StyleCachedImage> create(CachedImage* image) { return adoptRef(*new StyleCachedImage(image, 1, nullptr)); }
- static Ref<StyleCachedImage> createForImageSet(CachedImage* image, float scaleFactor, CSSImageSetValue& cssValue) { return adoptRef(*new StyleCachedImage(image, scaleFactor, &cssValue)); }
+ static Ref<StyleCachedImage> create(CSSValue& cssValue) { return adoptRef(*new StyleCachedImage(cssValue)); }
virtual ~StyleCachedImage();
CachedImage* cachedImage() const override { return m_image.get(); }
- void detachFromCSSValue() { m_cssImageSetValue = nullptr; }
+ void detachFromCSSValue() { m_cssValue = nullptr; }
+ void setCSSValue(CSSValue& value) { m_cssValue = &value; }
-private:
+ void setCachedImage(CachedImage&, float scaleFactor = 1);
+
WrappedImagePtr data() const override { return m_image.get(); }
PassRefPtr<CSSValue> cssValue() const override;
bool canRender(const RenderObject*, float multiplier) const override;
+ bool isPending() const override;
bool isLoaded() const override;
bool errorOccurred() const override;
FloatSize imageSize(const RenderElement*, float multiplier) const override;
@@ -64,11 +66,12 @@
float imageScaleFactor() const override;
bool knownToBeOpaque(const RenderElement*) const override;
- StyleCachedImage(CachedImage*, float scaleFactor, CSSImageSetValue*);
+private:
+ StyleCachedImage(CSSValue&);
+ CSSValue* m_cssValue;
+ float m_scaleFactor { 1 };
CachedResourceHandle<CachedImage> m_image;
- float m_scaleFactor;
- CSSImageSetValue* m_cssImageSetValue; // Not retained; it owns us.
};
} // namespace WebCore
Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/style/StyleGeneratedImage.cpp (205585 => 205586)
--- releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/style/StyleGeneratedImage.cpp 2016-09-08 06:02:15 UTC (rev 205585)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/style/StyleGeneratedImage.cpp 2016-09-08 06:31:44 UTC (rev 205586)
@@ -42,6 +42,11 @@
return const_cast<CSSImageGeneratorValue*>(m_imageGeneratorValue.ptr());
}
+bool StyleGeneratedImage::isPending() const
+{
+ return m_imageGeneratorValue->isPending();
+}
+
FloatSize StyleGeneratedImage::imageSize(const RenderElement* renderer, float multiplier) const
{
if (m_fixedSize) {
Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/style/StyleGeneratedImage.h (205585 => 205586)
--- releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/style/StyleGeneratedImage.h 2016-09-08 06:02:15 UTC (rev 205585)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/style/StyleGeneratedImage.h 2016-09-08 06:31:44 UTC (rev 205586)
@@ -45,6 +45,7 @@
PassRefPtr<CSSValue> cssValue() const override;
+ bool isPending() const override;
FloatSize imageSize(const RenderElement*, float multiplier) const override;
bool imageHasRelativeWidth() const override { return !m_fixedSize; }
bool imageHasRelativeHeight() const override { return !m_fixedSize; }
Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/style/StyleImage.h (205585 => 205586)
--- releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/style/StyleImage.h 2016-09-08 06:02:15 UTC (rev 205585)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/style/StyleImage.h 2016-09-08 06:31:44 UTC (rev 205586)
@@ -47,12 +47,13 @@
bool operator==(const StyleImage& other) const
{
- return data() == other.data();
+ return &other == this || (data() && data() == other.data());
}
virtual PassRefPtr<CSSValue> cssValue() const = 0;
virtual bool canRender(const RenderObject*, float /*multiplier*/) const { return true; }
+ virtual bool isPending() const = 0;
virtual bool isLoaded() const { return true; }
virtual bool errorOccurred() const { return false; }
virtual FloatSize imageSize(const RenderElement*, float multiplier) const = 0;
@@ -70,18 +71,15 @@
virtual CachedImage* cachedImage() const { return 0; }
ALWAYS_INLINE bool isCachedImage() const { return m_isCachedImage; }
- ALWAYS_INLINE bool isPendingImage() const { return m_isPendingImage; }
ALWAYS_INLINE bool isGeneratedImage() const { return m_isGeneratedImage; }
protected:
StyleImage()
: m_isCachedImage(false)
- , m_isPendingImage(false)
, m_isGeneratedImage(false)
{
}
bool m_isCachedImage : 1;
- bool m_isPendingImage : 1;
bool m_isGeneratedImage : 1;
};
Deleted: releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/style/StylePendingImage.h (205585 => 205586)
--- releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/style/StylePendingImage.h 2016-09-08 06:02:15 UTC (rev 205585)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/style/StylePendingImage.h 2016-09-08 06:31:44 UTC (rev 205586)
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef StylePendingImage_h
-#define StylePendingImage_h
-
-#include "CSSCursorImageValue.h"
-#include "CSSImageGeneratorValue.h"
-#include "CSSImageSetValue.h"
-#include "CSSImageValue.h"
-#include "StyleImage.h"
-
-namespace WebCore {
-
-// StylePendingImage is a placeholder StyleImage that is entered into the RenderStyle during
-// style resolution, in order to avoid loading images that are not referenced by the final style.
-// They should never exist in a RenderStyle after it has been returned from the style selector.
-
-class StylePendingImage final : public StyleImage {
-public:
- static Ref<StylePendingImage> create(CSSValue* value) { return adoptRef(*new StylePendingImage(value)); }
-
- CSSImageValue* cssImageValue() const { return is<CSSImageValue>(m_value) ? downcast<CSSImageValue>(m_value) : nullptr; }
- CSSImageGeneratorValue* cssImageGeneratorValue() const { return is<CSSImageGeneratorValue>(m_value) ? static_cast<CSSImageGeneratorValue*>(m_value) : nullptr; }
- CSSCursorImageValue* cssCursorImageValue() const { return is<CSSCursorImageValue>(m_value) ? downcast<CSSCursorImageValue>(m_value) : nullptr; }
- CSSImageSetValue* cssImageSetValue() const { return is<CSSImageSetValue>(m_value) ? downcast<CSSImageSetValue>(m_value) : nullptr; }
-
- void detachFromCSSValue() { m_value = nullptr; }
-
-private:
- WrappedImagePtr data() const override { return const_cast<StylePendingImage*>(this); }
-
- PassRefPtr<CSSValue> cssValue() const override { return m_value; }
-
- FloatSize imageSize(const RenderElement*, float /*multiplier*/) const override { return FloatSize(); }
- bool imageHasRelativeWidth() const override { return false; }
- bool imageHasRelativeHeight() const override { return false; }
- void computeIntrinsicDimensions(const RenderElement*, Length& /* intrinsicWidth */ , Length& /* intrinsicHeight */, FloatSize& /* intrinsicRatio */) override { }
- bool usesImageContainerSize() const override { return false; }
- void setContainerSizeForRenderer(const RenderElement*, const FloatSize&, float) override { }
- void addClient(RenderElement*) override { }
- void removeClient(RenderElement*) override { }
-
- RefPtr<Image> image(RenderElement*, const FloatSize&) const override
- {
- ASSERT_NOT_REACHED();
- return nullptr;
- }
-
- bool knownToBeOpaque(const RenderElement*) const override { return false; }
-
- StylePendingImage(CSSValue* value)
- : m_value(value)
- {
- m_isPendingImage = true;
- }
-
- CSSValue* m_value; // Not retained; it owns us.
-};
-
-} // namespace WebCore
-
-SPECIALIZE_TYPE_TRAITS_STYLE_IMAGE(StylePendingImage, isPendingImage)
-
-#endif // StylePendingImage_h
Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/style/StylePendingResources.cpp (205585 => 205586)
--- releases/WebKitGTK/webkit-2.14/Source/WebCore/style/StylePendingResources.cpp 2016-09-08 06:02:15 UTC (rev 205585)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/style/StylePendingResources.cpp 2016-09-08 06:31:44 UTC (rev 205586)
@@ -26,6 +26,10 @@
#include "config.h"
#include "StylePendingResources.h"
+#include "CSSCursorImageValue.h"
+#include "CSSImageGeneratorValue.h"
+#include "CSSImageSetValue.h"
+#include "CSSImageValue.h"
#include "CachedResourceLoader.h"
#include "CachedSVGDocumentReference.h"
#include "ContentData.h"
@@ -36,7 +40,6 @@
#include "SVGURIReference.h"
#include "StyleCachedImage.h"
#include "StyleGeneratedImage.h"
-#include "StylePendingImage.h"
#include "TransformFunctions.h"
namespace WebCore {
@@ -43,9 +46,11 @@
namespace Style {
enum class LoadPolicy { Normal, ShapeOutside };
-static RefPtr<StyleImage> loadPendingImage(Document& document, const StyleImage& image, const Element* element, LoadPolicy loadPolicy = LoadPolicy::Normal)
+static void loadPendingImage(Document& document, const StyleImage* styleImage, const Element* element, LoadPolicy loadPolicy = LoadPolicy::Normal)
{
- auto& pendingImage = downcast<StylePendingImage>(image);
+ if (!styleImage || !styleImage->isPending())
+ return;
+
ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
options.contentSecurityPolicyImposition = element && element->isInUserAgentShadowTree() ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck;
@@ -55,21 +60,26 @@
options.allowCredentials = DoNotAllowStoredCredentials;
}
- if (auto imageValue = pendingImage.cssImageValue())
- return imageValue->cachedImage(document.cachedResourceLoader(), options);
+ auto cssValue = const_cast<StyleImage*>(styleImage)->cssValue();
+ if (is<CSSImageValue>(cssValue.get())) {
+ downcast<CSSImageValue>(*cssValue).loadImage(document.cachedResourceLoader(), options);
+ return;
+ };
- if (auto imageGeneratorValue = pendingImage.cssImageGeneratorValue()) {
- imageGeneratorValue->loadSubimages(document.cachedResourceLoader(), options);
- return StyleGeneratedImage::create(*imageGeneratorValue);
- }
+ if (is<CSSImageSetValue>(cssValue.get())) {
+ downcast<CSSImageSetValue>(*cssValue).loadBestFitImage(document.cachedResourceLoader(), options);
+ return;
+ };
- if (auto cursorImageValue = pendingImage.cssCursorImageValue())
- return cursorImageValue->cachedImage(document.cachedResourceLoader(), options);
+ if (is<CSSImageGeneratorValue>(cssValue.get())) {
+ downcast<CSSImageGeneratorValue>(*cssValue).loadSubimages(document.cachedResourceLoader(), options);
+ return;
+ };
- if (auto imageSetValue = pendingImage.cssImageSetValue())
- return imageSetValue->bestFitImage(document.cachedResourceLoader(), options);
-
- return nullptr;
+ if (is<CSSCursorImageValue>(cssValue.get())) {
+ downcast<CSSCursorImageValue>(*cssValue).loadImage(document.cachedResourceLoader(), options);
+ return;
+ };
}
static void loadPendingImages(const PendingResources& pendingResources, Document& document, RenderStyle& style, const Element* element)
@@ -77,82 +87,52 @@
for (auto currentProperty : pendingResources.pendingImages.keys()) {
switch (currentProperty) {
case CSSPropertyBackgroundImage: {
- for (FillLayer* backgroundLayer = &style.ensureBackgroundLayers(); backgroundLayer; backgroundLayer = backgroundLayer->next()) {
- auto* styleImage = backgroundLayer->image();
- if (is<StylePendingImage>(styleImage))
- backgroundLayer->setImage(loadPendingImage(document, *styleImage, element));
- }
+ for (auto* backgroundLayer = &style.ensureBackgroundLayers(); backgroundLayer; backgroundLayer = backgroundLayer->next())
+ loadPendingImage(document, backgroundLayer->image(), element);
break;
}
case CSSPropertyContent: {
- for (ContentData* contentData = const_cast<ContentData*>(style.contentData()); contentData; contentData = contentData->next()) {
+ for (auto* contentData = const_cast<ContentData*>(style.contentData()); contentData; contentData = contentData->next()) {
if (is<ImageContentData>(*contentData)) {
auto& styleImage = downcast<ImageContentData>(*contentData).image();
- if (is<StylePendingImage>(styleImage)) {
- if (auto loadedImage = loadPendingImage(document, styleImage, element))
- downcast<ImageContentData>(*contentData).setImage(WTFMove(loadedImage));
- }
+ loadPendingImage(document, &styleImage, element);
}
}
break;
}
case CSSPropertyCursor: {
- if (CursorList* cursorList = style.cursors()) {
- for (size_t i = 0; i < cursorList->size(); ++i) {
- CursorData& currentCursor = cursorList->at(i);
- auto* styleImage = currentCursor.image();
- if (is<StylePendingImage>(styleImage))
- currentCursor.setImage(loadPendingImage(document, *styleImage, element));
- }
+ if (auto* cursorList = style.cursors()) {
+ for (size_t i = 0; i < cursorList->size(); ++i)
+ loadPendingImage(document, cursorList->at(i).image(), element);
}
break;
}
case CSSPropertyListStyleImage: {
- auto* styleImage = style.listStyleImage();
- if (is<StylePendingImage>(styleImage))
- style.setListStyleImage(loadPendingImage(document, *styleImage, element));
+ loadPendingImage(document, style.listStyleImage(), element);
break;
}
case CSSPropertyBorderImageSource: {
- auto* styleImage = style.borderImageSource();
- if (is<StylePendingImage>(styleImage))
- style.setBorderImageSource(loadPendingImage(document, *styleImage, element));
+ loadPendingImage(document, style.borderImageSource(), element);
break;
}
case CSSPropertyWebkitBoxReflect: {
- if (StyleReflection* reflection = style.boxReflect()) {
- const NinePieceImage& maskImage = reflection->mask();
- auto* styleImage = maskImage.image();
- if (is<StylePendingImage>(styleImage)) {
- auto loadedImage = loadPendingImage(document, *styleImage, element);
- reflection->setMask(NinePieceImage(WTFMove(loadedImage), maskImage.imageSlices(), maskImage.fill(), maskImage.borderSlices(), maskImage.outset(), maskImage.horizontalRule(), maskImage.verticalRule()));
- }
- }
+ if (auto* reflection = style.boxReflect())
+ loadPendingImage(document, reflection->mask().image(), element);
break;
}
case CSSPropertyWebkitMaskBoxImageSource: {
- auto* styleImage = style.maskBoxImageSource();
- if (is<StylePendingImage>(styleImage))
- style.setMaskBoxImageSource(loadPendingImage(document, *styleImage, element));
+ loadPendingImage(document, style.maskBoxImageSource(), element);
break;
}
case CSSPropertyWebkitMaskImage: {
- for (FillLayer* maskLayer = &style.ensureMaskLayers(); maskLayer; maskLayer = maskLayer->next()) {
- auto* styleImage = maskLayer->image();
- if (is<StylePendingImage>(styleImage))
- maskLayer->setImage(loadPendingImage(document, *styleImage, element));
- }
+ for (auto* maskLayer = &style.ensureMaskLayers(); maskLayer; maskLayer = maskLayer->next())
+ loadPendingImage(document, maskLayer->image(), element);
break;
}
#if ENABLE(CSS_SHAPES)
case CSSPropertyWebkitShapeOutside: {
- if (!style.shapeOutside())
- return;
-
- StyleImage* image = style.shapeOutside()->image();
- if (is<StylePendingImage>(image))
- style.shapeOutside()->setImage(loadPendingImage(document, *image, element, LoadPolicy::ShapeOutside));
-
+ if (style.shapeOutside())
+ loadPendingImage(document, style.shapeOutside()->image(), element, LoadPolicy::ShapeOutside);
break;
}
#endif