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