Commit d0c71466 authored by gyuyoung.kim@samsung.com's avatar gyuyoung.kim@samsung.com
Browse files

Generate toCSSFooValue() for CSSImageValue

https://bugs.webkit.org/show_bug.cgi?id=122051

Reviewed by Andreas Kling.

Clean up static_cast<CSSImageValue*> type casts. It will help to
detect bad cast as well as improve code readability.

Removed unnecessary local variables as well.

No new tests, no behavior changes.

* css/CSSCrossfadeValue.cpp:
(WebCore::subimageKnownToBeOpaque):
* css/CSSCursorImageValue.cpp:
(WebCore::CSSCursorImageValue::~CSSCursorImageValue):
(WebCore::CSSCursorImageValue::updateIfSVGCursorIsUsed):
(WebCore::CSSCursorImageValue::cachedImage):
(WebCore::CSSCursorImageValue::isSVGCursor):
* css/CSSImageGeneratorValue.cpp:
(WebCore::CSSImageGeneratorValue::subimageIsPending):
(WebCore::CSSImageGeneratorValue::cachedImageForCSSValue):
* css/CSSImageSetValue.cpp:
(WebCore::CSSImageSetValue::fillImageSet):
* css/CSSImageValue.h:
* css/CSSValue.cpp:
(WebCore::CSSValue::destroy):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::applyProperty):
(WebCore::StyleResolver::styleImage):
* page/PageSerializer.cpp:
(WebCore::PageSerializer::retrieveResourcesForProperties):
* rendering/style/StylePendingImage.h:
(WebCore::StylePendingImage::data):
(WebCore::StylePendingImage::cssImageValue):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156601 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 00e249e3
2013-09-28 Gyuyoung Kim <gyuyoung.kim@samsung.com>
Generate toCSSFooValue() for CSSImageValue
https://bugs.webkit.org/show_bug.cgi?id=122051
Reviewed by Andreas Kling.
Clean up static_cast<CSSImageValue*> type casts. It will help to
detect bad cast as well as improve code readability.
Removed unnecessary local variables as well.
No new tests, no behavior changes.
* css/CSSCrossfadeValue.cpp:
(WebCore::subimageKnownToBeOpaque):
* css/CSSCursorImageValue.cpp:
(WebCore::CSSCursorImageValue::~CSSCursorImageValue):
(WebCore::CSSCursorImageValue::updateIfSVGCursorIsUsed):
(WebCore::CSSCursorImageValue::cachedImage):
(WebCore::CSSCursorImageValue::isSVGCursor):
* css/CSSImageGeneratorValue.cpp:
(WebCore::CSSImageGeneratorValue::subimageIsPending):
(WebCore::CSSImageGeneratorValue::cachedImageForCSSValue):
* css/CSSImageSetValue.cpp:
(WebCore::CSSImageSetValue::fillImageSet):
* css/CSSImageValue.h:
* css/CSSValue.cpp:
(WebCore::CSSValue::destroy):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::applyProperty):
(WebCore::StyleResolver::styleImage):
* page/PageSerializer.cpp:
(WebCore::PageSerializer::retrieveResourcesForProperties):
* rendering/style/StylePendingImage.h:
(WebCore::StylePendingImage::data):
(WebCore::StylePendingImage::cssImageValue):
2013-09-28 Mark Rowe <mrowe@apple.com>
 
WebCore fails to build with newer versions of clang.
......@@ -47,7 +47,7 @@ static inline double blendFunc(double from, double to, double progress)
static bool subimageKnownToBeOpaque(CSSValue* value, const RenderObject* renderer)
{
if (value->isImageValue())
return static_cast<CSSImageValue*>(value)->knownToBeOpaque(renderer);
return toCSSImageValue(value)->knownToBeOpaque(renderer);
if (value->isImageGeneratorValue())
return static_cast<CSSImageGeneratorValue*>(value)->knownToBeOpaque(renderer);
......
......@@ -75,12 +75,11 @@ CSSCursorImageValue::~CSSCursorImageValue()
HashSet<SVGElement*>::const_iterator it = m_referencedElements.begin();
HashSet<SVGElement*>::const_iterator end = m_referencedElements.end();
String url = static_cast<CSSImageValue*>(m_imageValue.get())->url();
for (; it != end; ++it) {
SVGElement* referencedElement = *it;
referencedElement->cursorImageValueRemoved();
if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(url, referencedElement->document()))
if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(toCSSImageValue(m_imageValue.get())->url(), referencedElement->document()))
cursorElement->removeClient(referencedElement);
}
#endif
......@@ -110,8 +109,7 @@ bool CSSCursorImageValue::updateIfSVGCursorIsUsed(Element* element)
if (!isSVGCursor())
return false;
String url = static_cast<CSSImageValue*>(m_imageValue.get())->url();
if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(url, element->document())) {
if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(toCSSImageValue(m_imageValue.get())->url(), element->document())) {
// FIXME: This will override hot spot specified in CSS, which is probably incorrect.
SVGLengthContext lengthContext(0);
m_hasHotSpot = true;
......@@ -150,9 +148,8 @@ StyleImage* CSSCursorImageValue::cachedImage(CachedResourceLoader* loader)
// to change the URL of the CSSImageValue (which would then change behavior like cssText),
// we create an alternate CSSImageValue to use.
if (isSVGCursor() && loader && loader->document()) {
RefPtr<CSSImageValue> imageValue = static_cast<CSSImageValue*>(m_imageValue.get());
// FIXME: This will fail if the <cursor> element is in a shadow DOM (bug 59827)
if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(imageValue->url(), *loader->document())) {
if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(toCSSImageValue(m_imageValue.get())->url(), *loader->document())) {
RefPtr<CSSImageValue> svgImageValue = CSSImageValue::create(cursorElement->href());
StyleCachedImage* cachedImage = svgImageValue->cachedImage(loader);
m_image = cachedImage;
......@@ -162,7 +159,7 @@ StyleImage* CSSCursorImageValue::cachedImage(CachedResourceLoader* loader)
#endif
if (m_imageValue->isImageValue())
m_image = static_cast<CSSImageValue*>(m_imageValue.get())->cachedImage(loader);
m_image = toCSSImageValue(m_imageValue.get())->cachedImage(loader);
}
if (m_image && m_image->isCachedImage())
......@@ -189,8 +186,7 @@ StyleImage* CSSCursorImageValue::cachedOrPendingImage(Document& document)
bool CSSCursorImageValue::isSVGCursor() const
{
if (m_imageValue->isImageValue()) {
RefPtr<CSSImageValue> imageValue = static_cast<CSSImageValue*>(m_imageValue.get());
URL kurl(ParsedURLString, imageValue->url());
URL kurl(ParsedURLString, toCSSImageValue(m_imageValue.get())->url());
return kurl.hasFragmentIdentifier();
}
return false;
......
......@@ -237,7 +237,7 @@ void CSSImageGeneratorValue::loadSubimages(CachedResourceLoader* cachedResourceL
bool CSSImageGeneratorValue::subimageIsPending(CSSValue* value)
{
if (value->isImageValue())
return static_cast<CSSImageValue*>(value)->cachedOrPendingImage()->isPendingImage();
return toCSSImageValue(value)->cachedOrPendingImage()->isPendingImage();
if (value->isImageGeneratorValue())
return static_cast<CSSImageGeneratorValue*>(value)->isPending();
......@@ -256,7 +256,7 @@ CachedImage* CSSImageGeneratorValue::cachedImageForCSSValue(CSSValue* value, Cac
return 0;
if (value->isImageValue()) {
StyleCachedImage* styleCachedImage = static_cast<CSSImageValue*>(value)->cachedImage(cachedResourceLoader);
StyleCachedImage* styleCachedImage = toCSSImageValue(value)->cachedImage(cachedResourceLoader);
if (!styleCachedImage)
return 0;
......
......@@ -61,8 +61,7 @@ void CSSImageSetValue::fillImageSet()
size_t i = 0;
while (i < length) {
CSSValue* imageValue = item(i);
ASSERT_WITH_SECURITY_IMPLICATION(imageValue->isImageValue());
String imageURL = static_cast<CSSImageValue*>(imageValue)->url();
String imageURL = toCSSImageValue(imageValue)->url();
++i;
ASSERT_WITH_SECURITY_IMPLICATION(i < length);
......
......@@ -68,6 +68,8 @@ private:
AtomicString m_initiatorName;
};
CSS_VALUE_TYPE_CASTS(ImageValue)
} // namespace WebCore
#endif // CSSImageValue_h
......@@ -416,7 +416,7 @@ void CSSValue::destroy()
delete static_cast<CSSCrossfadeValue*>(this);
return;
case ImageClass:
delete static_cast<CSSImageValue*>(this);
delete toCSSImageValue(this);
return;
case InheritedClass:
delete static_cast<CSSInheritedValue*>(this);
......
......@@ -2172,7 +2172,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value)
}
if (item->isImageValue()) {
state.style()->setContent(cachedOrPendingFromValue(CSSPropertyContent, static_cast<CSSImageValue*>(item)), didSet);
state.style()->setContent(cachedOrPendingFromValue(CSSPropertyContent, toCSSImageValue(item)), didSet);
didSet = true;
continue;
}
......@@ -3093,7 +3093,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value)
PassRefPtr<StyleImage> StyleResolver::styleImage(CSSPropertyID property, CSSValue* value)
{
if (value->isImageValue())
return cachedOrPendingFromValue(property, static_cast<CSSImageValue*>(value));
return cachedOrPendingFromValue(property, toCSSImageValue(value));
if (value->isImageGeneratorValue()) {
if (value->isGradientValue())
......
......@@ -332,8 +332,7 @@ void PageSerializer::retrieveResourcesForProperties(const StylePropertySet* styl
if (!cssValue->isImageValue())
continue;
CSSImageValue* imageValue = static_cast<CSSImageValue*>(cssValue.get());
StyleImage* styleImage = imageValue->cachedOrPendingImage();
StyleImage* styleImage = toCSSImageValue(cssValue.get())->cachedOrPendingImage();
// Non cached-images are just place-holders and do not contain data.
if (!styleImage || !styleImage->isCachedImage())
continue;
......
......@@ -45,10 +45,10 @@ class StylePendingImage : public StyleImage {
public:
static PassRefPtr<StylePendingImage> create(CSSValue* value) { return adoptRef(new StylePendingImage(value)); }
virtual WrappedImagePtr data() const { return static_cast<CSSImageValue*>(m_value); }
virtual WrappedImagePtr data() const { return toCSSImageValue(m_value); }
virtual PassRefPtr<CSSValue> cssValue() const { return m_value; }
CSSImageValue* cssImageValue() const { return m_value->isImageValue() ? static_cast<CSSImageValue*>(m_value) : 0; }
CSSImageValue* cssImageValue() const { return m_value->isImageValue() ? toCSSImageValue(m_value) : 0; }
CSSImageGeneratorValue* cssImageGeneratorValue() const { return m_value->isImageGeneratorValue() ? static_cast<CSSImageGeneratorValue*>(m_value) : 0; }
CSSCursorImageValue* cssCursorImageValue() const { return m_value->isCursorImageValue() ? static_cast<CSSCursorImageValue*>(m_value) : 0; }
#if ENABLE(CSS_IMAGE_SET)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment