15c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)/* 25c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Copyright (C) 2010 Apple Inc. All rights reserved. 35c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 45c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without 55c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * modification, are permitted provided that the following conditions 65c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * are met: 75c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 1. Redistributions of source code must retain the above copyright 85c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * notice, this list of conditions and the following disclaimer. 95c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 2. Redistributions in binary form must reproduce the above copyright 105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * notice, this list of conditions and the following disclaimer in the 115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * documentation and/or other materials provided with the distribution. 125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2302772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) */ 255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#ifndef StylePendingImage_h 275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#define StylePendingImage_h 285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "core/css/CSSCursorImageValue.h" 30197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "core/css/CSSImageGeneratorValue.h" 311e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)#include "core/css/CSSImageSetValue.h" 32a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch#include "core/css/CSSImageValue.h" 33e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch#include "core/rendering/style/StyleImage.h" 34e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch#include "platform/graphics/Image.h" 355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 36c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink { 375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 38a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch// StylePendingImage is a placeholder StyleImage that is entered into the RenderStyle during 395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// style resolution, in order to avoid loading images that are not referenced by the final style. 40197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch// They should never exist in a RenderStyle after it has been returned from the style selector. 417242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci 42a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdochclass StylePendingImage FINAL : public StyleImage { 43a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdochpublic: 44a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch static PassRefPtr<StylePendingImage> create(CSSValue* value) { return adoptRef(new StylePendingImage(value)); } 45a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch 46a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch virtual WrappedImagePtr data() const OVERRIDE { return m_value; } 47a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch 48a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch virtual PassRefPtrWillBeRawPtr<CSSValue> cssValue() const OVERRIDE { return m_value; } 49a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch CSSImageValue* cssImageValue() const { return m_value->isImageValue() ? toCSSImageValue(m_value) : 0; } 50a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch CSSImageGeneratorValue* cssImageGeneratorValue() const { return m_value->isImageGeneratorValue() ? toCSSImageGeneratorValue(m_value) : 0; } 51a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch CSSCursorImageValue* cssCursorImageValue() const { return m_value->isCursorImageValue() ? toCSSCursorImageValue(m_value) : 0; } 52a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch CSSImageSetValue* cssImageSetValue() const { return m_value->isImageSetValue() ? toCSSImageSetValue(m_value) : 0; } 53a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch 54a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch virtual LayoutSize imageSize(const RenderObject*, float /*multiplier*/) const OVERRIDE { return LayoutSize(); } 555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) virtual bool imageHasRelativeWidth() const OVERRIDE { return false; } 56a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch virtual bool imageHasRelativeHeight() const OVERRIDE { return false; } 57a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch virtual void computeIntrinsicDimensions(const RenderObject*, Length& /* intrinsicWidth */ , Length& /* intrinsicHeight */, FloatSize& /* intrinsicRatio */) OVERRIDE { } 58a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch virtual bool usesImageContainerSize() const OVERRIDE { return false; } 59a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch virtual void setContainerSizeForRenderer(const RenderObject*, const IntSize&, float) OVERRIDE { } 60a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch virtual void addClient(RenderObject*) OVERRIDE { } 61a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch virtual void removeClient(RenderObject*) OVERRIDE { } 625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) virtual PassRefPtr<Image> image(RenderObject*, const IntSize&) const OVERRIDE 63a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch { 645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) ASSERT_NOT_REACHED(); 65a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch return nullptr; 66a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch } 67a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch virtual bool knownToBeOpaque(const RenderObject*) const OVERRIDE { return false; } 68a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch 69a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdochprivate: 70a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch StylePendingImage(CSSValue* value) 71a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch : m_value(value) 725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) { 73c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) m_isPendingImage = true; 745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 76 CSSValue* m_value; // Not retained; it owns us. 77}; 78 79DEFINE_STYLE_IMAGE_TYPE_CASTS(StylePendingImage, isPendingImage()); 80 81} 82#endif 83