Commit ea480b14 authored by Fredrik Söderquist's avatar Fredrik Söderquist Committed by Commit Bot

[CI] Use ToReferenceClipPathOperationOrNull instead of IsReferenceClipPath

Since DEFINE_TYPE_CASTS now provide a To<type>OrNull, we can use that
instead of essentially open-coding the same thing.

Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: I22113ff36a406d0afc17e5ecf37158e1dec1fe8e
Reviewed-on: https://chromium-review.googlesource.com/973376Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#544833}
parent a9d705f7
......@@ -119,11 +119,6 @@ struct SameSizeAsPaintLayer : DisplayItemClient {
static_assert(sizeof(PaintLayer) == sizeof(SameSizeAsPaintLayer),
"PaintLayer should stay small");
bool IsReferenceClipPath(const ClipPathOperation* clip_operation) {
return clip_operation &&
clip_operation->GetType() == ClipPathOperation::REFERENCE;
}
} // namespace
using namespace HTMLNames;
......@@ -191,10 +186,9 @@ PaintLayer::~PaintLayer() {
const ComputedStyle& style = GetLayoutObject().StyleRef();
if (style.HasFilter())
style.Filter().RemoveClient(*rare_data_->resource_info);
if (IsReferenceClipPath(style.ClipPath())) {
ToReferenceClipPathOperation(style.ClipPath())
->RemoveClient(*rare_data_->resource_info);
}
if (auto* reference_clip =
ToReferenceClipPathOperationOrNull(style.ClipPath()))
reference_clip->RemoveClient(*rare_data_->resource_info);
rare_data_->resource_info->ClearLayer();
}
if (GetLayoutObject().GetFrame()) {
......@@ -2935,19 +2929,16 @@ void PaintLayer::UpdateFilters(const ComputedStyle* old_style,
void PaintLayer::UpdateClipPath(const ComputedStyle* old_style,
const ComputedStyle& new_style) {
ClipPathOperation* new_clip_operation = new_style.ClipPath();
ClipPathOperation* old_clip_operation =
old_style ? old_style->ClipPath() : nullptr;
if (!new_clip_operation && !old_clip_operation)
ClipPathOperation* new_clip = new_style.ClipPath();
ClipPathOperation* old_clip = old_style ? old_style->ClipPath() : nullptr;
if (!new_clip && !old_clip)
return;
const bool had_resource_info = ResourceInfo();
if (IsReferenceClipPath(new_clip_operation)) {
ToReferenceClipPathOperation(new_clip_operation)
->AddClient(EnsureResourceInfo());
}
if (had_resource_info && IsReferenceClipPath(old_clip_operation)) {
ToReferenceClipPathOperation(old_clip_operation)
->RemoveClient(*ResourceInfo());
if (auto* reference_clip = ToReferenceClipPathOperationOrNull(new_clip))
reference_clip->AddClient(EnsureResourceInfo());
if (had_resource_info) {
if (auto* old_reference_clip = ToReferenceClipPathOperationOrNull(old_clip))
old_reference_clip->RemoveClient(*ResourceInfo());
}
}
......
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