Commit f0fb947a authored by Xida Chen's avatar Xida Chen Committed by Commit Bot

[Code health] Using CompositorPaintWorkletInput::PropertyKeys in Blink

Right now we have places in Blink that uses
std::vector<std::pair<std::string, CompositorElementId>, which is
exactly the CompositorPaintWorkletInput::PropertyKeys.

This CL makes changes to those places, no behavior change is introduced.

Bug: None
Change-Id: I16b60f258ad54a7ae807d222a2472d9eeedcb67b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1768894Reviewed-by: default avatarStephen McGruer <smcgruer@chromium.org>
Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Commit-Queue: Xida Chen <xidachen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#690950}
parent c0d72e74
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "third_party/blink/renderer/core/layout/layout_object.h" #include "third_party/blink/renderer/core/layout/layout_object.h"
#include "third_party/blink/renderer/core/page/page.h" #include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/platform/graphics/image.h" #include "third_party/blink/renderer/platform/graphics/image.h"
#include "third_party/blink/renderer/platform/graphics/platform_paint_worklet_layer_painter.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h" #include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
namespace blink { namespace blink {
...@@ -102,8 +103,7 @@ scoped_refptr<Image> CSSPaintValue::GetImage( ...@@ -102,8 +103,7 @@ scoped_refptr<Image> CSSPaintValue::GetImage(
Vector<AtomicString> custom_properties = Vector<AtomicString> custom_properties =
generator_->CustomInvalidationProperties(); generator_->CustomInvalidationProperties();
float zoom = layout_object.StyleRef().EffectiveZoom(); float zoom = layout_object.StyleRef().EffectiveZoom();
std::vector<std::pair<std::string, CompositorElementId>> CompositorPaintWorkletInput::PropertyKeys input_property_keys;
input_property_keys;
auto style_data = PaintWorkletStylePropertyMap::BuildCrossThreadData( auto style_data = PaintWorkletStylePropertyMap::BuildCrossThreadData(
document, layout_object.UniqueId(), style, native_properties, document, layout_object.UniqueId(), style, native_properties,
custom_properties, input_property_keys); custom_properties, input_property_keys);
......
...@@ -81,13 +81,13 @@ bool BuildNativeValues(const ComputedStyle& style, ...@@ -81,13 +81,13 @@ bool BuildNativeValues(const ComputedStyle& style,
return true; return true;
} }
bool BuildCustomValues(const Document& document, bool BuildCustomValues(
UniqueObjectId unique_object_id, const Document& document,
const ComputedStyle& style, UniqueObjectId unique_object_id,
const Vector<AtomicString>& custom_properties, const ComputedStyle& style,
PaintWorkletStylePropertyMap::CrossThreadData& data, const Vector<AtomicString>& custom_properties,
std::vector<std::pair<std::string, CompositorElementId>>& PaintWorkletStylePropertyMap::CrossThreadData& data,
input_property_keys) { CompositorPaintWorkletInput::PropertyKeys& input_property_keys) {
DCHECK(IsMainThread()); DCHECK(IsMainThread());
for (const auto& property_name : custom_properties) { for (const auto& property_name : custom_properties) {
CSSPropertyRef ref(property_name, document); CSSPropertyRef ref(property_name, document);
...@@ -128,8 +128,7 @@ PaintWorkletStylePropertyMap::BuildCrossThreadData( ...@@ -128,8 +128,7 @@ PaintWorkletStylePropertyMap::BuildCrossThreadData(
const ComputedStyle& style, const ComputedStyle& style,
const Vector<CSSPropertyID>& native_properties, const Vector<CSSPropertyID>& native_properties,
const Vector<AtomicString>& custom_properties, const Vector<AtomicString>& custom_properties,
std::vector<std::pair<std::string, CompositorElementId>>& CompositorPaintWorkletInput::PropertyKeys& input_property_keys) {
input_property_keys) {
DCHECK(IsMainThread()); DCHECK(IsMainThread());
PaintWorkletStylePropertyMap::CrossThreadData data; PaintWorkletStylePropertyMap::CrossThreadData data;
data.ReserveCapacityForSize(native_properties.size() + data.ReserveCapacityForSize(native_properties.size() +
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "third_party/blink/renderer/core/css/cssom/cross_thread_style_value.h" #include "third_party/blink/renderer/core/css/cssom/cross_thread_style_value.h"
#include "third_party/blink/renderer/core/css/cssom/style_property_map_read_only.h" #include "third_party/blink/renderer/core/css/cssom/style_property_map_read_only.h"
#include "third_party/blink/renderer/platform/graphics/compositor_element_id.h" #include "third_party/blink/renderer/platform/graphics/compositor_element_id.h"
#include "third_party/blink/renderer/platform/graphics/platform_paint_worklet_layer_painter.h"
#include "third_party/blink/renderer/platform/wtf/vector.h" #include "third_party/blink/renderer/platform/wtf/vector.h"
namespace blink { namespace blink {
...@@ -41,8 +42,7 @@ class CORE_EXPORT PaintWorkletStylePropertyMap ...@@ -41,8 +42,7 @@ class CORE_EXPORT PaintWorkletStylePropertyMap
const ComputedStyle&, const ComputedStyle&,
const Vector<CSSPropertyID>& native_properties, const Vector<CSSPropertyID>& native_properties,
const Vector<AtomicString>& custom_properties, const Vector<AtomicString>& custom_properties,
std::vector<std::pair<std::string, CompositorElementId>>& CompositorPaintWorkletInput::PropertyKeys& input_property_keys);
input_property_ids);
static CrossThreadData CopyCrossThreadData(const CrossThreadData& data); static CrossThreadData CopyCrossThreadData(const CrossThreadData& data);
......
...@@ -154,7 +154,7 @@ TEST_F(PaintWorkletStylePropertyMapTest, CreateSupportedCrossThreadData) { ...@@ -154,7 +154,7 @@ TEST_F(PaintWorkletStylePropertyMapTest, CreateSupportedCrossThreadData) {
Node* node = PageNode(); Node* node = PageNode();
Vector<std::unique_ptr<CrossThreadStyleValue>> input_arguments; Vector<std::unique_ptr<CrossThreadStyleValue>> input_arguments;
std::vector<std::pair<std::string, CompositorElementId>> input_property_keys; CompositorPaintWorkletInput::PropertyKeys input_property_keys;
auto data = PaintWorkletStylePropertyMap::BuildCrossThreadData( auto data = PaintWorkletStylePropertyMap::BuildCrossThreadData(
GetDocument(), node->GetLayoutObject()->UniqueId(), GetDocument(), node->GetLayoutObject()->UniqueId(),
node->ComputedStyleRef(), native_properties, custom_properties, node->ComputedStyleRef(), native_properties, custom_properties,
...@@ -196,7 +196,7 @@ TEST_F(PaintWorkletStylePropertyMapTest, UnsupportedCrossThreadData) { ...@@ -196,7 +196,7 @@ TEST_F(PaintWorkletStylePropertyMapTest, UnsupportedCrossThreadData) {
Node* node = PageNode(); Node* node = PageNode();
Vector<std::unique_ptr<CrossThreadStyleValue>> input_arguments; Vector<std::unique_ptr<CrossThreadStyleValue>> input_arguments;
std::vector<std::pair<std::string, CompositorElementId>> input_property_keys; CompositorPaintWorkletInput::PropertyKeys input_property_keys;
auto data1 = PaintWorkletStylePropertyMap::BuildCrossThreadData( auto data1 = PaintWorkletStylePropertyMap::BuildCrossThreadData(
GetDocument(), node->GetLayoutObject()->UniqueId(), GetDocument(), node->GetLayoutObject()->UniqueId(),
node->ComputedStyleRef(), native_properties1, custom_properties1, node->ComputedStyleRef(), native_properties1, custom_properties1,
......
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