Chromium Code Reviews| Index: third_party/WebKit/Source/core/css/cssom/CSSStyleImageValue.h |
| diff --git a/third_party/WebKit/Source/core/css/cssom/CSSStyleImageValue.h b/third_party/WebKit/Source/core/css/cssom/CSSStyleImageValue.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ea41d13a18773446a6fb9cfb195a99d89a43abbd |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/core/css/cssom/CSSStyleImageValue.h |
| @@ -0,0 +1,87 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CSSStyleImageValue_h |
| +#define CSSStyleImageValue_h |
| + |
| +#include "core/css/CSSImageValue.h" |
| +#include "core/css/cssom/CSSResourceValue.h" |
| +#include "core/fetch/ImageResource.h" |
| +#include "core/style/StyleImage.h" |
| + |
| + |
| +namespace blink { |
| + |
| +class CORE_EXPORT CSSStyleImageValue : public CSSResourceValue { |
| + WTF_MAKE_NONCOPYABLE(CSSStyleImageValue); |
| + DEFINE_WRAPPERTYPEINFO(); |
| +public: |
| + virtual ~CSSStyleImageValue() { } |
| + |
| + double intrinsicWidth(bool& isNull) |
| + { |
| + isNull = isCachePending(); |
| + if (isNull) |
| + return 0; |
| + return imageLayoutSize().width().toDouble(); |
| + } |
| + |
| + double intrinsicHeight(bool& isNull) |
| + { |
| + isNull = isCachePending(); |
| + if (isNull) |
| + return 0; |
| + return imageLayoutSize().height().toDouble(); |
| + } |
| + |
| + double intrinsicRatio(bool& isNull) |
|
meade_UTC10
2016/08/04 07:00:54
Can the body of these methods be moved into a .cpp
anthonyhkf
2016/08/04 23:59:03
Done.
|
| + { |
| + isNull = isCachePending(); |
| + if (isNull) { |
| + return 0; |
| + } |
| + if (intrinsicHeight(isNull) == 0) { |
| + isNull = true; |
| + return 0; |
| + } |
| + return intrinsicWidth(isNull) / intrinsicHeight(isNull); |
| + } |
| + |
| + DEFINE_INLINE_VIRTUAL_TRACE() |
| + { |
| + visitor->trace(m_imageValue); |
| + CSSStyleValue::trace(visitor); |
| + CSSResourceValue::trace(visitor); |
| + } |
| + |
| +protected: |
| + |
| + CSSStyleImageValue() { } |
|
meade_UTC10
2016/08/04 07:00:54
I don't think this empty constructor is needed?
anthonyhkf
2016/08/04 23:59:03
Done.
|
| + |
| + CSSStyleImageValue(const CSSImageValue* imageValue) |
| + : m_imageValue(imageValue) |
| + { |
| + } |
| + |
| + Member<const CSSImageValue> m_imageValue; |
| + |
| + virtual LayoutSize imageLayoutSize() const |
| + { |
| + DCHECK(!m_imageValue->isCachePending()); |
| + return m_imageValue->cachedImage()->cachedImage()->imageSize(DoNotRespectImageOrientation, 1, ImageResource::IntrinsicSize); |
| + } |
| + |
| + virtual bool isCachePending() const { return m_imageValue->isCachePending(); } |
| + |
| + Resource::Status status() const override |
| + { |
| + if (isCachePending()) |
| + return Resource::Status::NotStarted; |
| + return m_imageValue->cachedImage()->cachedImage()->getStatus(); |
| + } |
| +}; |
| + |
| +} // namespace blink |
| + |
| +#endif // CSSResourceValue_h |