Commit 32d95678 authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

Let LayoutCustomScrollbarPart inherit LayoutReplaced instead of LayoutBlock

Custom scrollbar parts don't have children. They act more like special
replaced elements. Letting LayoutCustomScrollbarPart inherit
LayoutReplaced can reduce cost.

Change-Id: I496aa9c331485a2ff4a0bbe5c9f2b542abce79ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2226924Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774389}
parent 553c123d
......@@ -39,7 +39,7 @@ LayoutCustomScrollbarPart::LayoutCustomScrollbarPart(
ScrollableArea* scrollable_area,
CustomScrollbar* scrollbar,
ScrollbarPart part)
: LayoutBlock(nullptr),
: LayoutReplaced(nullptr, LayoutSize()),
scrollable_area_(scrollable_area),
scrollbar_(scrollbar),
part_(part) {
......@@ -211,28 +211,18 @@ void LayoutCustomScrollbarPart::UpdateScrollbarHeight() {
.Round()));
}
MinMaxSizes LayoutCustomScrollbarPart::PreferredLogicalWidths() const {
return MinMaxSizes();
}
void LayoutCustomScrollbarPart::StyleWillChange(
StyleDifference diff,
const ComputedStyle& new_style) {
LayoutBlock::StyleWillChange(diff, new_style);
void LayoutCustomScrollbarPart::UpdateFromStyle() {
LayoutReplaced::UpdateFromStyle();
SetInline(false);
ClearPositionedState();
SetFloating(false);
}
void LayoutCustomScrollbarPart::StyleDidChange(StyleDifference diff,
const ComputedStyle* old_style) {
LayoutBlock::StyleDidChange(diff, old_style);
// See adjustStyleBeforeSet() above.
DCHECK(!IsOrthogonalWritingModeRoot());
SetInline(false);
ClearPositionedState();
SetFloating(false);
LayoutReplaced::StyleDidChange(diff, old_style);
if (old_style && (diff.NeedsPaintInvalidation() || diff.NeedsLayout()))
SetNeedsPaintInvalidation();
RecordPercentLengthStats();
}
......@@ -264,7 +254,7 @@ void LayoutCustomScrollbarPart::RecordPercentLengthStats() const {
void LayoutCustomScrollbarPart::ImageChanged(WrappedImagePtr image,
CanDeferInvalidation defer) {
SetNeedsPaintInvalidation();
LayoutBlock::ImageChanged(image, defer);
LayoutReplaced::ImageChanged(image, defer);
}
void LayoutCustomScrollbarPart::SetNeedsPaintInvalidation() {
......
......@@ -26,7 +26,7 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LAYOUT_CUSTOM_SCROLLBAR_PART_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LAYOUT_CUSTOM_SCROLLBAR_PART_H_
#include "third_party/blink/renderer/core/layout/layout_block.h"
#include "third_party/blink/renderer/core/layout/layout_replaced.h"
#include "third_party/blink/renderer/core/scroll/scroll_types.h"
namespace blink {
......@@ -34,7 +34,7 @@ namespace blink {
class CustomScrollbar;
class ScrollableArea;
class LayoutCustomScrollbarPart final : public LayoutBlock {
class LayoutCustomScrollbarPart final : public LayoutReplaced {
public:
static LayoutCustomScrollbarPart* CreateAnonymous(Document*,
ScrollableArea*,
......@@ -52,38 +52,34 @@ class LayoutCustomScrollbarPart final : public LayoutBlock {
// Scrollbar parts needs to be rendered at device pixel boundaries.
LayoutUnit MarginTop() const override {
DCHECK(IsIntegerValue(LayoutBlock::MarginTop()));
return LayoutBlock::MarginTop();
DCHECK(IsIntegerValue(LayoutReplaced::MarginTop()));
return LayoutReplaced::MarginTop();
}
LayoutUnit MarginBottom() const override {
DCHECK(IsIntegerValue(LayoutBlock::MarginBottom()));
return LayoutBlock::MarginBottom();
DCHECK(IsIntegerValue(LayoutReplaced::MarginBottom()));
return LayoutReplaced::MarginBottom();
}
LayoutUnit MarginLeft() const override {
DCHECK(IsIntegerValue(LayoutBlock::MarginLeft()));
return LayoutBlock::MarginLeft();
DCHECK(IsIntegerValue(LayoutReplaced::MarginLeft()));
return LayoutReplaced::MarginLeft();
}
LayoutUnit MarginRight() const override {
DCHECK(IsIntegerValue(LayoutBlock::MarginRight()));
return LayoutBlock::MarginRight();
DCHECK(IsIntegerValue(LayoutReplaced::MarginRight()));
return LayoutReplaced::MarginRight();
}
bool IsOfType(LayoutObjectType type) const override {
return type == kLayoutObjectLayoutCustomScrollbarPart ||
LayoutBlock::IsOfType(type);
LayoutReplaced::IsOfType(type);
}
ScrollableArea* GetScrollableArea() const { return scrollable_area_; }
protected:
void StyleWillChange(StyleDifference,
const ComputedStyle& new_style) override;
void StyleDidChange(StyleDifference, const ComputedStyle* old_style) override;
void ImageChanged(WrappedImagePtr, CanDeferInvalidation) override;
private:
LayoutCustomScrollbarPart(ScrollableArea*, CustomScrollbar*, ScrollbarPart);
MinMaxSizes PreferredLogicalWidths() const override;
void UpdateFromStyle() override;
void StyleDidChange(StyleDifference, const ComputedStyle* old_style) override;
void ImageChanged(WrappedImagePtr, CanDeferInvalidation) override;
// Have all padding getters return 0. The important point here is to avoid
// resolving percents against the containing block, since scroll bar corners
......@@ -103,8 +99,6 @@ class LayoutCustomScrollbarPart final : public LayoutBlock {
void SetNeedsPaintInvalidation();
bool AllowsOverflowClip() const override { return false; }
void RecordPercentLengthStats() const;
UntracedMember<ScrollableArea> scrollable_area_;
......
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