CSSImageValue.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * (C) 1999-2003 Lars Knoll (knoll@kde.org)
  3. * Copyright (C) 2004, 2005, 2006, 2008, 2012 Apple Inc. All rights reserved.
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Library General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Library General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Library General Public License
  16. * along with this library; see the file COPYING.LIB. If not, write to
  17. * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18. * Boston, MA 02110-1301, USA.
  19. */
  20. #ifndef CSSImageValue_h
  21. #define CSSImageValue_h
  22. #include "CSSValue.h"
  23. #include <wtf/RefPtr.h>
  24. namespace WebCore {
  25. class CachedResourceLoader;
  26. class Element;
  27. class StyleCachedImage;
  28. class StyleImage;
  29. class RenderObject;
  30. class CSSImageValue : public CSSValue {
  31. public:
  32. static PassRefPtr<CSSImageValue> create(const String& url) { return adoptRef(new CSSImageValue(url)); }
  33. static PassRefPtr<CSSImageValue> create(const String& url, StyleImage* image) { return adoptRef(new CSSImageValue(url, image)); }
  34. ~CSSImageValue();
  35. StyleCachedImage* cachedImage(CachedResourceLoader*);
  36. // Returns a StyleCachedImage if the image is cached already, otherwise a StylePendingImage.
  37. StyleImage* cachedOrPendingImage();
  38. const String& url() { return m_url; }
  39. String customCssText() const;
  40. PassRefPtr<CSSValue> cloneForCSSOM() const;
  41. bool hasFailedOrCanceledSubresources() const;
  42. bool equals(const CSSImageValue&) const;
  43. bool knownToBeOpaque(const RenderObject*) const;
  44. void setInitiator(const AtomicString& name) { m_initiatorName = name; }
  45. private:
  46. explicit CSSImageValue(const String& url);
  47. CSSImageValue(const String& url, StyleImage*);
  48. void detachPendingImage();
  49. String m_url;
  50. RefPtr<StyleImage> m_image;
  51. bool m_accessedImage;
  52. AtomicString m_initiatorName;
  53. };
  54. } // namespace WebCore
  55. #endif // CSSImageValue_h