Commit 15c53e90 authored by anthonyhkf's avatar anthonyhkf Committed by Commit bot

[Typed-OM] Add CSSURLImageValue

Spec: https://drafts.css-houdini.org/css-typed-om/#cssurlimagevalue

BUG=545318

Review-Url: https://codereview.chromium.org/2208283002
Cr-Commit-Position: refs/heads/master@{#413386}
parent 565bd2b7
...@@ -123,6 +123,9 @@ CONSOLE MESSAGE: line 137: getter x ...@@ -123,6 +123,9 @@ CONSOLE MESSAGE: line 137: getter x
CONSOLE MESSAGE: line 137: getter y CONSOLE MESSAGE: line 137: getter y
CONSOLE MESSAGE: line 137: getter z CONSOLE MESSAGE: line 137: getter z
CONSOLE MESSAGE: line 137: method constructor CONSOLE MESSAGE: line 137: method constructor
CONSOLE MESSAGE: line 137: interface CSSURLImageValue : CSSImageValue
CONSOLE MESSAGE: line 137: getter url
CONSOLE MESSAGE: line 137: method constructor
CONSOLE MESSAGE: line 137: interface CSSVariableReferenceValue CONSOLE MESSAGE: line 137: interface CSSVariableReferenceValue
CONSOLE MESSAGE: line 137: getter fallback CONSOLE MESSAGE: line 137: getter fallback
CONSOLE MESSAGE: line 137: getter variable CONSOLE MESSAGE: line 137: getter variable
......
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script>
test(function() {
var bg = new CSSURLImageValue("http://localhost");
assert_equals(bg.state, "unloaded");
}, "Can construct a new CSSURLImageValue object with url");
</script>
...@@ -660,6 +660,10 @@ interface CSSTranslation : CSSTransformComponent ...@@ -660,6 +660,10 @@ interface CSSTranslation : CSSTransformComponent
getter y getter y
getter z getter z
method constructor method constructor
interface CSSURLImageValue : CSSImageValue
attribute @@toStringTag
getter url
method constructor
interface CSSVariableReferenceValue interface CSSVariableReferenceValue
attribute @@toStringTag attribute @@toStringTag
getter fallback getter fallback
......
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
'css/cssom/CSSTransformComponent.idl', 'css/cssom/CSSTransformComponent.idl',
'css/cssom/CSSTransformValue.idl', 'css/cssom/CSSTransformValue.idl',
'css/cssom/CSSTranslation.idl', 'css/cssom/CSSTranslation.idl',
'css/cssom/CSSURLImageValue.idl',
'css/cssom/CSSVariableReferenceValue.idl', 'css/cssom/CSSVariableReferenceValue.idl',
'css/cssom/StylePropertyMap.idl', 'css/cssom/StylePropertyMap.idl',
'dom/ArrayBuffer.idl', 'dom/ArrayBuffer.idl',
...@@ -1397,6 +1398,7 @@ ...@@ -1397,6 +1398,7 @@
'css/cssom/CSSTransformValue.h', 'css/cssom/CSSTransformValue.h',
'css/cssom/CSSTranslation.cpp', 'css/cssom/CSSTranslation.cpp',
'css/cssom/CSSTranslation.h', 'css/cssom/CSSTranslation.h',
'css/cssom/CSSURLImageValue.h',
'css/cssom/CSSUnsupportedStyleValue.cpp', 'css/cssom/CSSUnsupportedStyleValue.cpp',
'css/cssom/CSSUnsupportedStyleValue.h', 'css/cssom/CSSUnsupportedStyleValue.h',
'css/cssom/ComputedStylePropertyMap.cpp', 'css/cssom/ComputedStylePropertyMap.cpp',
...@@ -4065,6 +4067,7 @@ ...@@ -4065,6 +4067,7 @@
'css/cssom/CSSResourceValueTest.cpp', 'css/cssom/CSSResourceValueTest.cpp',
'css/cssom/CSSStyleImageValueTest.cpp', 'css/cssom/CSSStyleImageValueTest.cpp',
'css/cssom/CSSTokenStreamValueTest.cpp', 'css/cssom/CSSTokenStreamValueTest.cpp',
'css/cssom/CSSURLImageValueTest.cpp',
'css/cssom/CSSVariableReferenceValueTest.cpp', 'css/cssom/CSSVariableReferenceValueTest.cpp',
'css/cssom/FilteredComputedStylePropertyMapTest.cpp', 'css/cssom/FilteredComputedStylePropertyMapTest.cpp',
'css/invalidation/InvalidationSetTest.cpp', 'css/invalidation/InvalidationSetTest.cpp',
......
...@@ -32,6 +32,7 @@ public: ...@@ -32,6 +32,7 @@ public:
SimpleLengthType, SimpleLengthType,
TokenStreamType, TokenStreamType,
TransformType, TransformType,
URLImageType,
}; };
virtual ~CSSStyleValue() { } virtual ~CSSStyleValue() { }
......
// 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 CSSURLImageValue_h
#define CSSURLImageValue_h
#include "core/css/cssom/CSSStyleImageValue.h"
namespace blink {
class CORE_EXPORT CSSURLImageValue final : public CSSStyleImageValue {
WTF_MAKE_NONCOPYABLE(CSSURLImageValue);
DEFINE_WRAPPERTYPEINFO();
public:
static CSSURLImageValue* create(const AtomicString& url)
{
return new CSSURLImageValue(CSSImageValue::create(url));
}
static CSSURLImageValue* create(const CSSImageValue* imageValue)
{
return new CSSURLImageValue(imageValue);
}
StyleValueType type() const override { return URLImageType; }
const CSSValue* toCSSValue() const { return m_imageValue.get(); }
const String& url() const { return m_imageValue->url(); }
private:
explicit CSSURLImageValue(const CSSImageValue* imageValue)
: CSSStyleImageValue(imageValue)
{
}
};
} // namespace blink
#endif // CSSResourceValue_h
// 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.
[
Constructor(DOMString url),
Exposed=(Window,PaintWorklet),
RuntimeEnabled=CSSTypedOM
] interface CSSURLImageValue : CSSImageValue {
readonly attribute DOMString url;
};
// 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.
#include "core/css/cssom/CSSURLImageValue.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace blink {
namespace {
void checkNullURLImageValue(CSSURLImageValue* urlImageValue)
{
EXPECT_EQ(urlImageValue->state(), "unloaded");
bool isNull;
EXPECT_EQ(urlImageValue->intrinsicWidth(isNull), 0);
EXPECT_EQ(urlImageValue->intrinsicHeight(isNull), 0);
EXPECT_EQ(urlImageValue->intrinsicRatio(isNull), 0);
EXPECT_TRUE(isNull);
}
TEST(CSSURLImageValueTest, CreateURLImageValueFromURL)
{
checkNullURLImageValue(CSSURLImageValue::create("http://localhost"));
}
TEST(CSSURLImageValueTest, CreateURLImageValueFromImageValue)
{
checkNullURLImageValue(CSSURLImageValue::create(CSSImageValue::create("http://localhost")));
}
} // namespace
} // namespace blink
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