Commit 23f34f4e authored by chrishtr's avatar chrishtr Committed by Commit bot

Introduce FragmentData, and put ObjectPaintProperties into it

This is a step towards supporting multicol in SPv2.

BUG=648274
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2

Review-Url: https://codereview.chromium.org/2844803007
Cr-Commit-Position: refs/heads/master@{#468207}
parent 276cc56b
...@@ -1810,7 +1810,9 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, ...@@ -1810,7 +1810,9 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver,
// The following non-const functions for ObjectPaintProperties should only // The following non-const functions for ObjectPaintProperties should only
// be called from PaintPropertyTreeBuilder. // be called from PaintPropertyTreeBuilder.
ObjectPaintProperties& EnsurePaintProperties() { ObjectPaintProperties& EnsurePaintProperties() {
return layout_object_.EnsureRarePaintData().EnsurePaintProperties(); return layout_object_.EnsureRarePaintData()
.EnsureFragment()
.EnsurePaintProperties();
} }
ObjectPaintProperties* PaintProperties() { ObjectPaintProperties* PaintProperties() {
if (auto* paint_data = layout_object_.GetRarePaintData()) if (auto* paint_data = layout_object_.GetRarePaintData())
...@@ -1818,8 +1820,10 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, ...@@ -1818,8 +1820,10 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver,
return nullptr; return nullptr;
} }
void ClearPaintProperties() { void ClearPaintProperties() {
if (auto* paint_data = layout_object_.GetRarePaintData()) if (auto* paint_data = layout_object_.GetRarePaintData()) {
paint_data->ClearPaintProperties(); if (auto* fragment = paint_data->Fragment())
fragment->ClearPaintProperties();
}
} }
// The following non-const functions for local border box properties should // The following non-const functions for local border box properties should
......
...@@ -56,6 +56,8 @@ blink_core_sources("paint") { ...@@ -56,6 +56,8 @@ blink_core_sources("paint") {
"FirstMeaningfulPaintDetector.h", "FirstMeaningfulPaintDetector.h",
"FloatClipRecorder.cpp", "FloatClipRecorder.cpp",
"FloatClipRecorder.h", "FloatClipRecorder.h",
"FragmentData.cpp",
"FragmentData.h",
"FramePainter.cpp", "FramePainter.cpp",
"FramePainter.h", "FramePainter.h",
"FrameSetPainter.cpp", "FrameSetPainter.cpp",
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "core/paint/FragmentData.h"
#include "core/paint/ObjectPaintProperties.h"
namespace blink {
ObjectPaintProperties& FragmentData::EnsurePaintProperties() {
if (!paint_properties_)
paint_properties_ = ObjectPaintProperties::Create();
return *paint_properties_.get();
}
void FragmentData::ClearPaintProperties() {
paint_properties_.reset(nullptr);
}
} // namespace blink
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FragmentData_h
#define FragmentData_h
#include "core/paint/ObjectPaintProperties.h"
namespace blink {
class ObjectPaintProperties;
// Represents the data for a particular fragment of a LayoutObject.
// Only LayoutObjects with a self-painting PaintLayer may have more than one
// FragmentDeta, and even then only when they are inside of multicol.
// See README.md.
class CORE_EXPORT FragmentData {
public:
static std::unique_ptr<FragmentData> Create() {
return WTF::WrapUnique(new FragmentData());
}
ObjectPaintProperties* PaintProperties() const {
return paint_properties_.get();
}
ObjectPaintProperties& EnsurePaintProperties();
void ClearPaintProperties();
FragmentData* NextFragment() { return next_fragment_.get(); }
private:
// Holds references to the paint property nodes created by this object.
std::unique_ptr<ObjectPaintProperties> paint_properties_;
std::unique_ptr<FragmentData> next_fragment_;
};
} // namespace blink
#endif // FragmentData_h
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "core/paint/RarePaintData.h" #include "core/paint/RarePaintData.h"
#include "core/paint/ObjectPaintProperties.h" #include "core/paint/FragmentData.h"
#include "core/paint/PaintLayer.h" #include "core/paint/PaintLayer.h"
namespace blink { namespace blink {
...@@ -17,14 +17,10 @@ void RarePaintData::SetLayer(std::unique_ptr<PaintLayer> layer) { ...@@ -17,14 +17,10 @@ void RarePaintData::SetLayer(std::unique_ptr<PaintLayer> layer) {
layer_ = std::move(layer); layer_ = std::move(layer);
}; };
ObjectPaintProperties& RarePaintData::EnsurePaintProperties() { FragmentData& RarePaintData::EnsureFragment() {
if (!paint_properties_) if (!fragment_data_)
paint_properties_ = ObjectPaintProperties::Create(); fragment_data_ = FragmentData::Create();
return *paint_properties_.get(); return *fragment_data_.get();
}
void RarePaintData::ClearPaintProperties() {
paint_properties_.reset(nullptr);
} }
void RarePaintData::ClearLocalBorderBoxProperties() { void RarePaintData::ClearLocalBorderBoxProperties() {
...@@ -41,13 +37,15 @@ void RarePaintData::SetLocalBorderBoxProperties(PropertyTreeState& state) { ...@@ -41,13 +37,15 @@ void RarePaintData::SetLocalBorderBoxProperties(PropertyTreeState& state) {
PropertyTreeState RarePaintData::ContentsProperties() const { PropertyTreeState RarePaintData::ContentsProperties() const {
DCHECK(local_border_box_properties_); DCHECK(local_border_box_properties_);
PropertyTreeState contents(*local_border_box_properties_); PropertyTreeState contents(*local_border_box_properties_);
if (paint_properties_) { if (fragment_data_) {
if (paint_properties_->ScrollTranslation()) if (auto* properties = fragment_data_->PaintProperties()) {
contents.SetTransform(paint_properties_->ScrollTranslation()); if (properties->ScrollTranslation())
if (paint_properties_->OverflowClip()) contents.SetTransform(properties->ScrollTranslation());
contents.SetClip(paint_properties_->OverflowClip()); if (properties->OverflowClip())
else if (paint_properties_->CssClip()) contents.SetClip(properties->OverflowClip());
contents.SetClip(paint_properties_->CssClip()); else if (properties->CssClip())
contents.SetClip(properties->CssClip());
}
} }
// TODO(chrishtr): cssClipFixedPosition needs to be handled somehow. // TODO(chrishtr): cssClipFixedPosition needs to be handled somehow.
......
...@@ -6,13 +6,13 @@ ...@@ -6,13 +6,13 @@
#define RarePaintData_h #define RarePaintData_h
#include "core/CoreExport.h" #include "core/CoreExport.h"
#include "core/paint/FragmentData.h"
#include "platform/wtf/Allocator.h" #include "platform/wtf/Allocator.h"
#include "platform/wtf/Noncopyable.h" #include "platform/wtf/Noncopyable.h"
namespace blink { namespace blink {
class PropertyTreeState; class PropertyTreeState;
class ObjectPaintProperties;
class PaintLayer; class PaintLayer;
// This is for paint-related data on LayoutObject that is not needed on all // This is for paint-related data on LayoutObject that is not needed on all
...@@ -28,11 +28,15 @@ class CORE_EXPORT RarePaintData { ...@@ -28,11 +28,15 @@ class CORE_EXPORT RarePaintData {
PaintLayer* Layer() { return layer_.get(); } PaintLayer* Layer() { return layer_.get(); }
void SetLayer(std::unique_ptr<PaintLayer>); void SetLayer(std::unique_ptr<PaintLayer>);
FragmentData* Fragment() const { return fragment_data_.get(); }
FragmentData& EnsureFragment();
ObjectPaintProperties* PaintProperties() const { ObjectPaintProperties* PaintProperties() const {
return paint_properties_.get(); if (fragment_data_)
return fragment_data_->PaintProperties();
return nullptr;
} }
ObjectPaintProperties& EnsurePaintProperties();
void ClearPaintProperties();
PropertyTreeState* LocalBorderBoxProperties() const { PropertyTreeState* LocalBorderBoxProperties() const {
return local_border_box_properties_.get(); return local_border_box_properties_.get();
...@@ -52,8 +56,7 @@ class CORE_EXPORT RarePaintData { ...@@ -52,8 +56,7 @@ class CORE_EXPORT RarePaintData {
// depending on the return value of LayoutBoxModelObject::layerTypeRequired(). // depending on the return value of LayoutBoxModelObject::layerTypeRequired().
std::unique_ptr<PaintLayer> layer_; std::unique_ptr<PaintLayer> layer_;
// Holds references to the paint property nodes created by this object. std::unique_ptr<FragmentData> fragment_data_;
std::unique_ptr<ObjectPaintProperties> paint_properties_;
// This is a complete set of property nodes that should be used as a // This is a complete set of property nodes that should be used as a
// starting point to paint a LayoutObject. This data is cached because some // starting point to paint a LayoutObject. This data is cached because some
......
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