WebKit Bugzilla
Attachment 357243 Details for
Bug 192671
: CSS Typed OM should expose attributeStyleMap
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-192671-20181213115619.patch (text/plain), 35.37 KB, created by
Justin Michaud
on 2018-12-13 11:56:19 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Justin Michaud
Created:
2018-12-13 11:56:19 PST
Size:
35.37 KB
patch
obsolete
>Subversion Revision: 239171 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index c7c333bbc491e236532813334d0f41a531b75075..fb52340e7c9da6482f886198eda87d49b9b80160 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,45 @@ >+2018-12-13 Justin Michaud <justin_michaud@apple.com> >+ >+ CSS Typed OM should expose attributeStyleMap >+ https://bugs.webkit.org/show_bug.cgi?id=192671 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Test: css-typedom/attributeStyleMap.html >+ >+ * CMakeLists.txt: >+ * DerivedSources.make: >+ * Sources.txt: >+ * WebCore.xcodeproj/project.pbxproj: >+ * bindings/js/WebCoreBuiltinNames.h: >+ * css/ElementCSSInlineStyle.idl: >+ * css/typedom/StylePropertyMap.h: Copied from Source/WebCore/css/typedom/StylePropertyMapReadOnly.h. >+ * css/typedom/StylePropertyMap.idl: Added. >+ * css/typedom/StylePropertyMapReadOnly.cpp: Added. >+ (WebCore::StylePropertyMapReadOnly::StylePropertyMapReadOnly): >+ (WebCore::StylePropertyMapReadOnly::reifyValue): >+ (WebCore::StylePropertyMapReadOnly::get const): >+ * css/typedom/StylePropertyMapReadOnly.h: >+ (WebCore::StylePropertyMapReadOnly::create): >+ (WebCore::StylePropertyMapReadOnly::StylePropertyMapReadOnly): >+ (WebCore::StylePropertyMapReadOnly::get const): Deleted. >+ * css/typedom/TypedOMCSSImageValue.h: >+ * dom/Element.h: >+ * dom/ElementRareData.cpp: >+ * dom/ElementRareData.h: >+ (WebCore::ElementRareData::attributeStyleMap): >+ (WebCore::ElementRareData::setAttributeStyleMap): >+ * dom/StyledElement.cpp: >+ (WebCore::extractInlineProperty): >+ (WebCore::StyledElement::attributeStyleMap): >+ * dom/StyledElement.h: >+ * html/canvas/CanvasRenderingContext2DBase.cpp: >+ (WebCore::size): >+ (WebCore::CanvasRenderingContext2DBase::drawImage): >+ * platform/graphics/CustomPaintImage.cpp: >+ (WebCore::extractComputedProperty): >+ (WebCore::CustomPaintImage::doCustomPaint): >+ > 2018-12-13 Eric Carlson <eric.carlson@apple.com> > > [MediaStream] Calculate width or height when constraints contain only the other >diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt >index 0bdd29cde1808c25d5ce8a165455584786066fba..194cc68b9da56842f69d9eb8037631a1a7c7d7cb 100644 >--- a/Source/WebCore/CMakeLists.txt >+++ b/Source/WebCore/CMakeLists.txt >@@ -601,12 +601,13 @@ set(WebCore_NON_SVG_IDL_FILES > css/StyleSheet.idl > css/StyleSheetList.idl > >+ css/typedom/StylePropertyMap.idl >+ css/typedom/StylePropertyMapReadOnly.idl > css/typedom/TypedOMCSSImageValue.idl > css/typedom/TypedOMCSSNumericValue.idl > css/typedom/TypedOMCSSStyleValue.idl > css/typedom/TypedOMCSSUnitValue.idl > css/typedom/TypedOMCSSUnparsedValue.idl >- css/typedom/StylePropertyMapReadOnly.idl > > css/WebKitCSSMatrix.idl > css/WebKitCSSViewportRule.idl >diff --git a/Source/WebCore/DerivedSources.make b/Source/WebCore/DerivedSources.make >index f6f7e3516ae7465882cfbf30512754d9434637e6..9e7109830ecdceeea0925e83a9f1c09da151d7ce 100644 >--- a/Source/WebCore/DerivedSources.make >+++ b/Source/WebCore/DerivedSources.make >@@ -510,6 +510,7 @@ JS_BINDING_IDLS = \ > $(WebCore)/css/StyleMedia.idl \ > $(WebCore)/css/StyleSheet.idl \ > $(WebCore)/css/StyleSheetList.idl \ >+ $(WebCore)/css/typedom/StylePropertyMap.idl \ > $(WebCore)/css/typedom/StylePropertyMapReadOnly.idl \ > $(WebCore)/css/typedom/TypedOMCSSImageValue.idl \ > $(WebCore)/css/typedom/TypedOMCSSNumericValue.idl \ >diff --git a/Source/WebCore/Sources.txt b/Source/WebCore/Sources.txt >index b4bdb25b5170687440ba663f06a09bec401e0e2f..99220406529c1fe910d3c575691d02b52d2279c0 100644 >--- a/Source/WebCore/Sources.txt >+++ b/Source/WebCore/Sources.txt >@@ -721,6 +721,8 @@ css/parser/MediaQueryParser.cpp > css/parser/SizesAttributeParser.cpp > css/parser/SizesCalcParser.cpp > >+css/typedom/StylePropertyMapReadOnly.cpp >+ > cssjit/SelectorCompiler.cpp > > dom/AbortController.cpp >@@ -3184,6 +3186,7 @@ JSStorage.cpp > JSStorageEvent.cpp > JSStringCallback.cpp > JSStyleMedia.cpp >+JSStylePropertyMap.cpp > JSStylePropertyMapReadOnly.cpp > JSStyleSheet.cpp > JSStyleSheetList.cpp >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index edeb4a8e7d6ea6e694b80609e0974a092395da51..d4de76ad2e798fb7775ed90f10f5cfa3e90ff6d7 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -1382,6 +1382,7 @@ > 4BAFD0D921921EA000C0AB64 /* TypedOMCSSUnparsedValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BAFD0D821921EA000C0AB64 /* TypedOMCSSUnparsedValue.h */; }; > 4BAFD0E0219220AB00C0AB64 /* TypedOMCSSNumericValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BAFD0DF219220AB00C0AB64 /* TypedOMCSSNumericValue.h */; }; > 4BAFD0E1219242A000C0AB64 /* TypedOMCSSUnitValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BAFD0DD2192209200C0AB64 /* TypedOMCSSUnitValue.h */; }; >+ 4BD781BF21C1965F00D9703E /* StylePropertyMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BD781BE21C1965F00D9703E /* StylePropertyMap.h */; }; > 4BDA3FFE2151B6F500FD6604 /* DOMCSSCustomPropertyDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BDA3FF82151B6F200FD6604 /* DOMCSSCustomPropertyDescriptor.h */; }; > 4BDA3FFF2151B6F500FD6604 /* DOMCSSRegisterCustomProperty.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BDA3FF92151B6F300FD6604 /* DOMCSSRegisterCustomProperty.h */; }; > 4BDA40012151B6F500FD6604 /* CSSRegisteredCustomProperty.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BDA3FFB2151B6F400FD6604 /* CSSRegisteredCustomProperty.h */; settings = {ATTRIBUTES = (Private, ); }; }; >@@ -7919,6 +7920,9 @@ > 4BAFD0DD2192209200C0AB64 /* TypedOMCSSUnitValue.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; path = TypedOMCSSUnitValue.h; sourceTree = "<group>"; }; > 4BAFD0DF219220AB00C0AB64 /* TypedOMCSSNumericValue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TypedOMCSSNumericValue.h; sourceTree = "<group>"; }; > 4BAFD0E22192604D00C0AB64 /* JSTypedOMCSSStyleValueCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSTypedOMCSSStyleValueCustom.cpp; sourceTree = "<group>"; }; >+ 4BD781BC21C1964800D9703E /* StylePropertyMap.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = StylePropertyMap.idl; sourceTree = "<group>"; }; >+ 4BD781BE21C1965F00D9703E /* StylePropertyMap.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StylePropertyMap.h; sourceTree = "<group>"; }; >+ 4BD781C521C1D67700D9703E /* StylePropertyMapReadOnly.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StylePropertyMapReadOnly.cpp; sourceTree = "<group>"; }; > 4BDA3FF52151B6F000FD6604 /* DOMCSSRegisterCustomProperty.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DOMCSSRegisterCustomProperty.idl; sourceTree = "<group>"; }; > 4BDA3FF72151B6F100FD6604 /* DOMCSSRegisterCustomProperty.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMCSSRegisterCustomProperty.cpp; sourceTree = "<group>"; }; > 4BDA3FF82151B6F200FD6604 /* DOMCSSCustomPropertyDescriptor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMCSSCustomPropertyDescriptor.h; sourceTree = "<group>"; }; >@@ -18142,6 +18146,9 @@ > 4BAFD0DA21921EAD00C0AB64 /* typedom */ = { > isa = PBXGroup; > children = ( >+ 4BD781BE21C1965F00D9703E /* StylePropertyMap.h */, >+ 4BD781BC21C1964800D9703E /* StylePropertyMap.idl */, >+ 4BD781C521C1D67700D9703E /* StylePropertyMapReadOnly.cpp */, > 4BAFD0CE2190F9B400C0AB64 /* StylePropertyMapReadOnly.h */, > 4BAFD0D02190F9C200C0AB64 /* StylePropertyMapReadOnly.idl */, > 4B43864F219CD56100F8D3C5 /* TypedOMCSSImageValue.h */, >@@ -31138,6 +31145,7 @@ > BC5EB74E0E81E06700B25965 /* StyleMultiColData.h in Headers */, > E4DACE6A1D12E10B0075980F /* StylePendingResources.h in Headers */, > A80E6DFC0A199067007FB8C5 /* StyleProperties.h in Headers */, >+ 4BD781BF21C1965F00D9703E /* StylePropertyMap.h in Headers */, > 4BAFD0CF2190F9B500C0AB64 /* StylePropertyMapReadOnly.h in Headers */, > E1B25107152A0BB00069B779 /* StylePropertyShorthand.h in Headers */, > 83C05A5B1A686212007E5DEA /* StylePropertyShorthandFunctions.h in Headers */, >diff --git a/Source/WebCore/bindings/js/WebCoreBuiltinNames.h b/Source/WebCore/bindings/js/WebCoreBuiltinNames.h >index e0b397f3ddd643e7e4e13fc9853e5e01d1b1fcf1..bef18c3325bc55781861579e772bb2859531e892 100644 >--- a/Source/WebCore/bindings/js/WebCoreBuiltinNames.h >+++ b/Source/WebCore/bindings/js/WebCoreBuiltinNames.h >@@ -177,6 +177,7 @@ namespace WebCore { > macro(SpectreGadget) \ > macro(StaticRange) \ > macro(StylePropertyMapReadOnly) \ >+ macro(StylePropertyMap) \ > macro(VRDisplay) \ > macro(VRDisplayCapabilities) \ > macro(VRDisplayEvent) \ >diff --git a/Source/WebCore/css/ElementCSSInlineStyle.idl b/Source/WebCore/css/ElementCSSInlineStyle.idl >index cfe72396f60381023c4b1da788d05d6725d36224..2f039217f1b45771204f2beb629a999eb9c77abf 100644 >--- a/Source/WebCore/css/ElementCSSInlineStyle.idl >+++ b/Source/WebCore/css/ElementCSSInlineStyle.idl >@@ -29,4 +29,5 @@ > NoInterfaceObject, > ] interface ElementCSSInlineStyle { > [ImplementedAs=cssomStyle, PutForwards=cssText] readonly attribute CSSStyleDeclaration style; // FIXME: Should be [SameObject]. >+ [SameObject, EnabledAtRuntime=CSSTypedOM, Conditional=CSS_TYPED_OM] readonly attribute StylePropertyMap attributeStyleMap; > }; >diff --git a/Source/WebCore/css/typedom/StylePropertyMap.h b/Source/WebCore/css/typedom/StylePropertyMap.h >new file mode 100644 >index 0000000000000000000000000000000000000000..8e57fd175f527747b65398005aa39cf8e01d6ad2 >--- /dev/null >+++ b/Source/WebCore/css/typedom/StylePropertyMap.h >@@ -0,0 +1,53 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(CSS_TYPED_OM) >+ >+#include "StylePropertyMapReadOnly.h" >+#include <wtf/HashMap.h> >+#include <wtf/RefCounted.h> >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+class StylePropertyMap final : public StylePropertyMapReadOnly { >+public: >+ static Ref<StylePropertyMap> create(UniqueRef<StylePropertyMapImpl>&& impl) >+ { >+ return adoptRef(*new StylePropertyMap(WTFMove(impl))); >+ } >+ >+private: >+ explicit StylePropertyMap(UniqueRef<StylePropertyMapImpl>&& impl) >+ : StylePropertyMapReadOnly(WTFMove(impl)) >+ { >+ } >+}; >+ >+} // namespace WebCore >+ >+#endif >diff --git a/Source/WebCore/css/typedom/StylePropertyMap.idl b/Source/WebCore/css/typedom/StylePropertyMap.idl >new file mode 100644 >index 0000000000000000000000000000000000000000..88a02d8498e339a00472428ac46855590a2926b4 >--- /dev/null >+++ b/Source/WebCore/css/typedom/StylePropertyMap.idl >@@ -0,0 +1,33 @@ >+/* >+* Copyright (C) 2018 Apple Inc. All rights reserved. >+* >+* Redistribution and use in source and binary forms, with or without >+* modification, are permitted provided that the following conditions >+* are met: >+* 1. Redistributions of source code must retain the above copyright >+* notice, this list of conditions and the following disclaimer. >+* 2. Redistributions in binary form must reproduce the above copyright >+* notice, this list of conditions and the following disclaimer in the >+* documentation and/or other materials provided with the distribution. >+* >+* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+*/ >+ >+[ >+ EnabledAtRuntime=CSSTypedOM, >+ Conditional=CSS_TYPED_OM, >+ Exposed=(Window), >+ ImplementationLacksVTable, >+ JSGenerateToJSObject >+] interface StylePropertyMap : StylePropertyMapReadOnly { >+}; >diff --git a/Source/WebCore/css/typedom/StylePropertyMapReadOnly.cpp b/Source/WebCore/css/typedom/StylePropertyMapReadOnly.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..43d9d37f88a278a67ae67d5986e30f53f5fa4215 >--- /dev/null >+++ b/Source/WebCore/css/typedom/StylePropertyMapReadOnly.cpp >@@ -0,0 +1,83 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above >+ * copyright notice, this list of conditions and the following >+ * disclaimer. >+ * 2. Redistributions in binary form must reproduce the above >+ * copyright notice, this list of conditions and the following >+ * disclaimer in the documentation and/or other materials >+ * provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER âAS ISâ AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE >+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, >+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR >+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF >+ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF >+ * SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "StylePropertyMapReadOnly.h" >+ >+#if ENABLE(CSS_TYPED_OM) >+ >+#include "CSSImageValue.h" >+#include "StyledElement.h" >+#include "TypedOMCSSImageValue.h" >+#include "TypedOMCSSUnitValue.h" >+#include "TypedOMCSSUnparsedValue.h" >+#include <wtf/HashMap.h> >+ >+namespace WebCore { >+ >+struct HashMapStylePropertyMapImpl final : public StylePropertyMapReadOnly::StylePropertyMapImpl { >+ explicit HashMapStylePropertyMapImpl(HashMap<String, RefPtr<TypedOMCSSStyleValue>>&& map) >+ : m_map(WTFMove(map)) >+ { >+ } >+ >+ RefPtr<TypedOMCSSStyleValue> get(const String& property) const override { return makeRefPtr(m_map.get(property)); } >+ >+ HashMap<String, RefPtr<TypedOMCSSStyleValue>> m_map; >+}; >+ >+StylePropertyMapReadOnly::StylePropertyMapReadOnly(HashMap<String, RefPtr<TypedOMCSSStyleValue>>&& map) >+ : StylePropertyMapReadOnly(makeUniqueRef<HashMapStylePropertyMapImpl>(WTFMove(map))) >+{ >+} >+ >+RefPtr<TypedOMCSSStyleValue> StylePropertyMapReadOnly::reifyValue(CSSValue* value, Document& document, Element*) >+{ >+ if (!value) >+ return nullptr; >+ >+ // FIXME: Properly reify all length values. >+ if (is<CSSPrimitiveValue>(*value) && downcast<CSSPrimitiveValue>(*value).primitiveType() == CSSPrimitiveValue::CSS_PX) >+ return TypedOMCSSUnitValue::create(downcast<CSSPrimitiveValue>(*value).doubleValue(), "px"); >+ >+ if (is<CSSImageValue>(*value)) >+ return TypedOMCSSImageValue::create(downcast<CSSImageValue>(*value), document); >+ >+ // FIXME: should use raw TypedOMCSSStyleValue >+ return TypedOMCSSUnparsedValue::create(value->cssText()); >+} >+ >+RefPtr<TypedOMCSSStyleValue> StylePropertyMapReadOnly::get(const String& property) const >+{ >+ return m_impl->get(property); >+} >+ >+} // namespace WebCore >+ >+#endif >diff --git a/Source/WebCore/css/typedom/StylePropertyMapReadOnly.h b/Source/WebCore/css/typedom/StylePropertyMapReadOnly.h >index 1b15154230d743451362cbbceea6b6d9a83c6a9b..7fa69bf405aa4ac5100f1096cc4f851fabc42397 100644 >--- a/Source/WebCore/css/typedom/StylePropertyMapReadOnly.h >+++ b/Source/WebCore/css/typedom/StylePropertyMapReadOnly.h >@@ -27,29 +27,47 @@ > > #if ENABLE(CSS_TYPED_OM) > >-#include "TypedOMCSSStyleValue.h" >-#include <wtf/HashMap.h> > #include <wtf/RefCounted.h> >+#include <wtf/UniqueRef.h> > #include <wtf/text/WTFString.h> > > namespace WebCore { >+class CSSValue; >+class Document; >+class Element; >+class StyledElement; >+class TypedOMCSSStyleValue; > > class StylePropertyMapReadOnly : public RefCounted<StylePropertyMapReadOnly> { > public: >- static Ref<StylePropertyMapReadOnly> create(HashMap<String, Ref<TypedOMCSSStyleValue>>&& map) >+ struct StylePropertyMapImpl { >+ virtual ~StylePropertyMapImpl() = default; >+ virtual RefPtr<TypedOMCSSStyleValue> get(const String& property) const = 0; >+ }; >+ >+ static Ref<StylePropertyMapReadOnly> create(HashMap<String, RefPtr<TypedOMCSSStyleValue>>&& map) > { > return adoptRef(*new StylePropertyMapReadOnly(WTFMove(map))); > } > >- TypedOMCSSStyleValue* get(String property) const { return m_map.get(property); } >+ static Ref<StylePropertyMapReadOnly> create(UniqueRef<StylePropertyMapImpl>&& impl) >+ { >+ return adoptRef(*new StylePropertyMapReadOnly(WTFMove(impl))); >+ } > >-private: >- explicit StylePropertyMapReadOnly(HashMap<String, Ref<TypedOMCSSStyleValue>>&& map) >- : m_map(WTFMove(map)) >+ static RefPtr<TypedOMCSSStyleValue> reifyValue(CSSValue*, Document&, Element* = nullptr); >+ RefPtr<TypedOMCSSStyleValue> get(const String& property) const; >+ >+protected: >+ explicit StylePropertyMapReadOnly(HashMap<String, RefPtr<TypedOMCSSStyleValue>>&&); >+ >+ explicit StylePropertyMapReadOnly(UniqueRef<StylePropertyMapImpl>&& impl) >+ : m_impl(WTFMove(impl)) > { > } > >- HashMap<String, Ref<TypedOMCSSStyleValue>> m_map; >+private: >+ UniqueRef<StylePropertyMapImpl> m_impl; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/css/typedom/TypedOMCSSImageValue.h b/Source/WebCore/css/typedom/TypedOMCSSImageValue.h >index 892d2c6040af9415d93f485f1b162960090c1955..28c2b1ae6dc3c13b24f68171475a9fca0b8c91ee 100644 >--- a/Source/WebCore/css/typedom/TypedOMCSSImageValue.h >+++ b/Source/WebCore/css/typedom/TypedOMCSSImageValue.h >@@ -39,27 +39,27 @@ namespace WebCore { > > class TypedOMCSSImageValue final : public TypedOMCSSStyleValue { > public: >- static Ref<TypedOMCSSImageValue> create(CSSImageValue& cssValue, RenderElement& renderer) >+ static Ref<TypedOMCSSImageValue> create(CSSImageValue& cssValue, Document& document) > { >- return adoptRef(*new TypedOMCSSImageValue(cssValue, renderer)); >+ return adoptRef(*new TypedOMCSSImageValue(cssValue, document)); > } > > String toString() final { return m_cssValue->cssText(); } > > CachedImage* image() { return m_cssValue->cachedImage(); } >- const RenderElement* renderer() const { return m_renderer.get(); } >+ Document* document() const { return m_document.get(); } > > private: >- TypedOMCSSImageValue(CSSImageValue& cssValue, RenderElement& renderer) >+ TypedOMCSSImageValue(CSSImageValue& cssValue, Document& document) > : m_cssValue(makeRef(cssValue)) >- , m_renderer(makeWeakPtr(renderer)) >+ , m_document(makeWeakPtr(document)) > { > } > > bool isImageValue() final { return true; } > > Ref<CSSImageValue> m_cssValue; >- WeakPtr<RenderElement> m_renderer; >+ WeakPtr<Document> m_document; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/dom/Element.h b/Source/WebCore/dom/Element.h >index bc6eba852548670077f3888bb20bcc0ac9f6f5a0..7b638069e3ee93576473113225b36732779d43be 100644 >--- a/Source/WebCore/dom/Element.h >+++ b/Source/WebCore/dom/Element.h >@@ -606,6 +606,9 @@ protected: > > static ExceptionOr<void> mergeWithNextTextNode(Text&); > >+ ElementRareData* elementRareData() const; >+ ElementRareData& ensureElementRareData(); >+ > private: > Frame* documentFrameWithNonNullView() const; > >@@ -691,9 +694,6 @@ private: > > void createUniqueElementData(); > >- ElementRareData* elementRareData() const; >- ElementRareData& ensureElementRareData(); >- > void detachAllAttrNodesFromElement(); > void detachAttrNodeFromElementWithValue(Attr*, const AtomicString& value); > >diff --git a/Source/WebCore/dom/ElementRareData.cpp b/Source/WebCore/dom/ElementRareData.cpp >index 6cfa8096d3f58407dd0a86cc73f8f7e0c360e579..4dd60eb84f63d12fe814e36c35cc501224cc9711 100644 >--- a/Source/WebCore/dom/ElementRareData.cpp >+++ b/Source/WebCore/dom/ElementRareData.cpp >@@ -47,6 +47,9 @@ struct SameSizeAsElementRareData : NodeRareData { > #if ENABLE(INTERSECTION_OBSERVER) > void* intersectionObserverData; > #endif >+#if ENABLE(CSS_TYPED_OM) >+ void* typedOMData; >+#endif > > }; > >diff --git a/Source/WebCore/dom/ElementRareData.h b/Source/WebCore/dom/ElementRareData.h >index e9a03b93b475f1e1d73bb47fd02760425bfb5981..fe80e331d5cb210ba7b05d219278a037591b939f 100644 >--- a/Source/WebCore/dom/ElementRareData.h >+++ b/Source/WebCore/dom/ElementRareData.h >@@ -30,6 +30,7 @@ > #include "PseudoElement.h" > #include "RenderElement.h" > #include "ShadowRoot.h" >+#include "StylePropertyMap.h" > > namespace WebCore { > >@@ -127,6 +128,11 @@ public: > void setIntersectionObserverData(std::unique_ptr<IntersectionObserverData>&& data) { m_intersectionObserverData = WTFMove(data); } > #endif > >+#if ENABLE(CSS_TYPED_OM) >+ StylePropertyMap* attributeStyleMap() { return m_attributeStyleMap.get(); } >+ void setAttributeStyleMap(Ref<StylePropertyMap>&& map) { m_attributeStyleMap = WTFMove(map); } >+#endif >+ > #if DUMP_NODE_STATISTICS > OptionSet<UseType> useTypes() const > { >@@ -202,6 +208,10 @@ private: > RefPtr<PseudoElement> m_beforePseudoElement; > RefPtr<PseudoElement> m_afterPseudoElement; > >+#if ENABLE(CSS_TYPED_OM) >+ RefPtr<StylePropertyMap> m_attributeStyleMap; >+#endif >+ > void releasePseudoElement(PseudoElement*); > }; > >diff --git a/Source/WebCore/dom/StyledElement.cpp b/Source/WebCore/dom/StyledElement.cpp >index f52363625f264d246007bd1ae04b13c9cf198e9c..4e500de765bfa99bd55a73e843e3150c34ed5c71 100644 >--- a/Source/WebCore/dom/StyledElement.cpp >+++ b/Source/WebCore/dom/StyledElement.cpp >@@ -25,20 +25,26 @@ > #include "StyledElement.h" > > #include "AttributeChangeInvalidation.h" >+#include "CSSComputedStyleDeclaration.h" > #include "CSSImageValue.h" > #include "CSSParser.h" >+#include "CSSPrimitiveValue.h" >+#include "CSSPropertyParser.h" > #include "CSSStyleSheet.h" > #include "CSSValuePool.h" > #include "CachedResource.h" > #include "ContentSecurityPolicy.h" > #include "DOMTokenList.h" >+#include "ElementRareData.h" > #include "HTMLElement.h" > #include "HTMLParserIdioms.h" > #include "InspectorInstrumentation.h" > #include "PropertySetCSSStyleDeclaration.h" > #include "ScriptableDocumentParser.h" > #include "StyleProperties.h" >+#include "StylePropertyMap.h" > #include "StyleResolver.h" >+#include "TypedOMCSSUnparsedValue.h" > #include <wtf/HashFunctions.h> > #include <wtf/IsoMallocInlines.h> > >@@ -70,6 +76,55 @@ CSSStyleDeclaration& StyledElement::cssomStyle() > return ensureMutableInlineStyle().ensureInlineCSSStyleDeclaration(*this); > } > >+#if ENABLE(CSS_TYPED_OM) >+ >+static RefPtr<TypedOMCSSStyleValue> extractInlineProperty(const String& name, StyledElement& element) >+{ >+ RefPtr<CSSValue> value; >+ >+ if (auto* style = element.inlineStyle()) { >+ if (isCustomPropertyName(name)) { >+ value = element.inlineStyle()->getCustomPropertyCSSValue(name); >+ if (!value) { >+ auto* registered = element.document().getCSSRegisteredCustomPropertySet().get(name); >+ if (registered && registered->initialValue()) >+ value = registered->initialValueCopy(); >+ else >+ return TypedOMCSSUnparsedValue::create(emptyString()); >+ } >+ } else { >+ CSSPropertyID propertyID = cssPropertyID(name); >+ if (!propertyID) >+ return nullptr; >+ value = element.inlineStyle()->getPropertyCSSValue(propertyID); >+ } >+ } >+ >+ return StylePropertyMapReadOnly::reifyValue(value.get(), element.document(), &element); >+} >+ >+struct StyledElementInlineStylePropertyMapImpl final : public StylePropertyMapReadOnly::StylePropertyMapImpl { >+ explicit StyledElementInlineStylePropertyMapImpl(StyledElement& element) >+ : m_element(makeRef(element)) >+ { >+ } >+ >+ RefPtr<TypedOMCSSStyleValue> get(const String& property) const override >+ { >+ return extractInlineProperty(property, m_element.get()); >+ } >+ >+ Ref<StyledElement> m_element; >+}; >+ >+StylePropertyMap& StyledElement::attributeStyleMap() >+{ >+ if (!ensureElementRareData().attributeStyleMap()) >+ elementRareData()->setAttributeStyleMap(StylePropertyMap::create(makeUniqueRef<StyledElementInlineStylePropertyMapImpl>(*this))); >+ return *elementRareData()->attributeStyleMap(); >+} >+#endif >+ > MutableStyleProperties& StyledElement::ensureMutableInlineStyle() > { > RefPtr<StyleProperties>& inlineStyle = ensureUniqueElementData().m_inlineStyle; >diff --git a/Source/WebCore/dom/StyledElement.h b/Source/WebCore/dom/StyledElement.h >index 0349fd55c090f06940a5fc929c00437b798345c8..1af494aab7764b0d6f0f930787cfc13e0fa3c7a8 100644 >--- a/Source/WebCore/dom/StyledElement.h >+++ b/Source/WebCore/dom/StyledElement.h >@@ -35,6 +35,7 @@ class Attribute; > class MutableStyleProperties; > class PropertySetCSSStyleDeclaration; > class StyleProperties; >+class StylePropertyMap; > > class StyledElement : public Element { > WTF_MAKE_ISO_ALLOCATED(StyledElement); >@@ -57,6 +58,9 @@ public: > void synchronizeStyleAttributeInternal() const { StyledElement::synchronizeStyleAttributeInternal(const_cast<StyledElement*>(this)); } > > WEBCORE_EXPORT CSSStyleDeclaration& cssomStyle(); >+#if ENABLE(CSS_TYPED_OM) >+ StylePropertyMap& attributeStyleMap(); >+#endif > > const StyleProperties* presentationAttributeStyle() const; > virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStyleProperties&) { } >diff --git a/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp b/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp >index c139a026914d995de2a126f91167476806bdf6c2..8383b0d3499f2d411ab784ebe28b624d85e05377 100644 >--- a/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp >+++ b/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp >@@ -1442,10 +1442,11 @@ static inline FloatSize size(HTMLVideoElement& video) > #if ENABLE(CSS_TYPED_OM) > static inline FloatSize size(TypedOMCSSImageValue& image) > { >- LayoutSize size; >- if (auto* cachedImage = image.image()) >- size = cachedImage->imageSizeForRenderer(image.renderer(), 1.0f); // FIXME: Not sure about this, see fixme in size(HTMLImageElement&...) >- return size; >+ auto* cachedImage = image.image(); >+ if (!cachedImage) >+ return FloatSize(); >+ >+ return cachedImage->imageSizeForRenderer(nullptr, 1.0f); > } > #endif > >@@ -1512,13 +1513,12 @@ ExceptionOr<void> CanvasRenderingContext2DBase::drawImage(HTMLImageElement& imag > #if ENABLE(CSS_TYPED_OM) > ExceptionOr<void> CanvasRenderingContext2DBase::drawImage(TypedOMCSSImageValue& image, const FloatRect& srcRect, const FloatRect& dstRect) > { >- auto* renderer = image.renderer(); > auto* cachedImage = image.image(); >- if (!renderer || !cachedImage) >+ if (!cachedImage || !image.document()) > return { }; > FloatRect imageRect = FloatRect(FloatPoint(), size(image)); > >- auto result = drawImage(renderer->document(), cachedImage, renderer, imageRect, srcRect, dstRect, state().globalComposite, state().globalBlend); >+ auto result = drawImage(*image.document(), cachedImage, nullptr, imageRect, srcRect, dstRect, state().globalComposite, state().globalBlend); > > if (!result.hasException()) > checkOrigin(image); >diff --git a/Source/WebCore/platform/graphics/CustomPaintImage.cpp b/Source/WebCore/platform/graphics/CustomPaintImage.cpp >index b8f930c81a0a00bc427501a21de714017f66168a..156b24ca4e22067b76cd17d77aa033a714017991 100644 >--- a/Source/WebCore/platform/graphics/CustomPaintImage.cpp >+++ b/Source/WebCore/platform/graphics/CustomPaintImage.cpp >@@ -57,6 +57,31 @@ CustomPaintImage::CustomPaintImage(PaintWorkletGlobalScope::PaintDefinition& def > > CustomPaintImage::~CustomPaintImage() = default; > >+ >+static RefPtr<TypedOMCSSStyleValue> extractComputedProperty(const String& name, Element& element) >+{ >+ ComputedStyleExtractor extractor(&element); >+ >+ RefPtr<CSSValue> value; >+ if (isCustomPropertyName(name)) { >+ value = extractor.customPropertyValue(name); >+ if (!value) { >+ auto* registered = element.document().getCSSRegisteredCustomPropertySet().get(name); >+ if (registered && registered->initialValue()) >+ value = registered->initialValueCopy(); >+ else >+ return TypedOMCSSUnparsedValue::create(emptyString()); >+ } >+ } else { >+ CSSPropertyID propertyID = cssPropertyID(name); >+ if (!propertyID) >+ return nullptr; >+ value = extractor.propertyValue(propertyID, DoNotUpdateLayout); >+ } >+ >+ return StylePropertyMapReadOnly::reifyValue(value.get(), element.document(), &element); >+} >+ > ImageDrawResult CustomPaintImage::doCustomPaint(GraphicsContext& destContext, const FloatSize& destSize) > { > if (!m_element || !m_element->element() || !m_paintDefinition) >@@ -82,32 +107,11 @@ ImageDrawResult CustomPaintImage::doCustomPaint(GraphicsContext& destContext, co > return ImageDrawResult::DidNothing; > auto context = contextOrException.releaseReturnValue(); > >- HashMap<String, Ref<TypedOMCSSStyleValue>> propertyValues; >- ComputedStyleExtractor extractor(m_element->element()); >- >- for (auto& name : m_inputProperties) { >- RefPtr<CSSValue> value; >- if (isCustomPropertyName(name)) >- value = extractor.customPropertyValue(name); >- else { >- CSSPropertyID propertyID = cssPropertyID(name); >- if (!propertyID) >- return ImageDrawResult::DidNothing; >- value = extractor.propertyValue(propertyID, DoNotUpdateLayout); >- } >- >- if (!value) { >- propertyValues.add(name, TypedOMCSSUnparsedValue::create(emptyString())); >- continue; >- } >+ HashMap<String, RefPtr<TypedOMCSSStyleValue>> propertyValues; > >- // FIXME: Properly reify all length values. >- if (is<CSSPrimitiveValue>(*value) && downcast<CSSPrimitiveValue>(*value).primitiveType() == CSSPrimitiveValue::CSS_PX) >- propertyValues.add(name, TypedOMCSSUnitValue::create(downcast<CSSPrimitiveValue>(*value).doubleValue(), "px")); >- else if (is<CSSImageValue>(*value)) >- propertyValues.add(name, TypedOMCSSImageValue::create(downcast<CSSImageValue>(*value), *m_element)); >- else >- propertyValues.add(name, TypedOMCSSUnparsedValue::create(value->cssText())); >+ if (auto* element = m_element->element()) { >+ for (auto& name : m_inputProperties) >+ propertyValues.add(name, extractComputedProperty(name, *element)); > } > > auto size = CSSPaintSize::create(destSize.width(), destSize.height()); >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index fc660cd3292734e120aa41ed9f5baa9dbf919b19..74dc964bc35566e79b67ad96405b19e8aceec470 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,14 @@ >+2018-12-13 Justin Michaud <justin_michaud@apple.com> >+ >+ CSS Typed OM should expose attributeStyleMap >+ https://bugs.webkit.org/show_bug.cgi?id=192671 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * css-typedom/attributeStyleMap-expected.txt: Added. >+ * css-typedom/attributeStyleMap.html: Added. >+ * fast/css-custom-paint/properties.html: >+ > 2018-12-13 Eric Carlson <eric.carlson@apple.com> > > [MediaStream] Calculate width or height when constraints contain only the other >diff --git a/LayoutTests/css-typedom/attributeStyleMap-expected.txt b/LayoutTests/css-typedom/attributeStyleMap-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..5063bde42e5c2dc74f6ae408646bc163922044a2 >--- /dev/null >+++ b/LayoutTests/css-typedom/attributeStyleMap-expected.txt >@@ -0,0 +1,4 @@ >+ >+PASS test that element.attributeStyleMap exists >+PASS test that element.attributeStyleMap has a valid width value >+ >diff --git a/LayoutTests/css-typedom/attributeStyleMap.html b/LayoutTests/css-typedom/attributeStyleMap.html >new file mode 100644 >index 0000000000000000000000000000000000000000..2842db189f5d37971d0d5cb436163a40be39565c >--- /dev/null >+++ b/LayoutTests/css-typedom/attributeStyleMap.html >@@ -0,0 +1,21 @@ >+<!DOCTYPE html><!-- webkit-test-runner [ experimental:CSSTypedOMEnabled=true ] --> >+<script src="../resources/testharness.js"></script> >+<script src="../resources/testharnessreport.js"></script> >+<meta name="author" title="Justin Michaud" href="mailto:justin_michaud@webkit.org"> >+<meta name="assert" content="Test element.attributeStyleMap basics"> >+<link rel="help" content="https://drafts.css-houdini.org/css-typed-om-1/"> >+ >+<div id="el" style = "width: 150px; height: 10em; --my-prop: hello;"></div> >+ >+<script> >+ test(function() { >+ assert_true(!!el.attributeStyleMap); >+ assert_true(el.attributeStyleMap instanceof StylePropertyMap); >+ }, 'test that element.attributeStyleMap exists'); >+ >+ test(function() { >+ assert_true(el.attributeStyleMap.get('width') instanceof CSSUnitValue); >+ assert_equals(el.attributeStyleMap.get('width').value, 150); >+ assert_equals(el.attributeStyleMap.get('width').unit, 'px'); >+ }, 'test that element.attributeStyleMap has a valid width value'); >+</script> >diff --git a/LayoutTests/fast/css-custom-paint/properties.html b/LayoutTests/fast/css-custom-paint/properties.html >index d9a4655b1ffa458d4ffc8db9795748f29bb00209..6c978867961b490c01c716b97a03784ee3e6d982 100644 >--- a/LayoutTests/fast/css-custom-paint/properties.html >+++ b/LayoutTests/fast/css-custom-paint/properties.html >@@ -12,10 +12,17 @@ > --my-prop:helloworld1; > --my-registered-prop:helloworld2; > } >+ >+ .paint2 { >+ background-image: paint(my-paint,150px,helloworld1,initialValueProp); >+ width: 150px; >+ height: 150px; >+ --my-prop:helloworld1; >+ } > </style> > > <div class="paint"></div> >-<div class="paint"></div> >+<div class="paint2"></div> > > <script id="code" type="text/worklet"> > class MyPaint {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 192671
:
357241
|
357243
|
357272
|
357280
|
357282
|
357286
|
357287
|
357289
|
357296
|
357298
|
357343
|
357345
|
357347
|
357368
|
357538
|
357539
|
357574