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,
// The following non-const functions for ObjectPaintProperties should only
// be called from PaintPropertyTreeBuilder.
ObjectPaintProperties& EnsurePaintProperties() {
return layout_object_.EnsureRarePaintData().EnsurePaintProperties();
return layout_object_.EnsureRarePaintData()
.EnsureFragment()
.EnsurePaintProperties();
}
ObjectPaintProperties* PaintProperties() {
if (auto* paint_data = layout_object_.GetRarePaintData())
......@@ -1818,8 +1820,10 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver,
return nullptr;
}
void ClearPaintProperties() {
if (auto* paint_data = layout_object_.GetRarePaintData())
paint_data->ClearPaintProperties();
if (auto* paint_data = layout_object_.GetRarePaintData()) {
if (auto* fragment = paint_data->Fragment())
fragment->ClearPaintProperties();
}
}
// The following non-const functions for local border box properties should
......
......@@ -56,6 +56,8 @@ blink_core_sources("paint") {
"FirstMeaningfulPaintDetector.h",
"FloatClipRecorder.cpp",
"FloatClipRecorder.h",
"FragmentData.cpp",
"FragmentData.h",
"FramePainter.cpp",
"FramePainter.h",
"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 @@
#include "core/paint/RarePaintData.h"
#include "core/paint/ObjectPaintProperties.h"
#include "core/paint/FragmentData.h"
#include "core/paint/PaintLayer.h"
namespace blink {
......@@ -17,14 +17,10 @@ void RarePaintData::SetLayer(std::unique_ptr<PaintLayer> layer) {
layer_ = std::move(layer);
};
ObjectPaintProperties& RarePaintData::EnsurePaintProperties() {
if (!paint_properties_)
paint_properties_ = ObjectPaintProperties::Create();
return *paint_properties_.get();
}
void RarePaintData::ClearPaintProperties() {
paint_properties_.reset(nullptr);
FragmentData& RarePaintData::EnsureFragment() {
if (!fragment_data_)
fragment_data_ = FragmentData::Create();
return *fragment_data_.get();
}
void RarePaintData::ClearLocalBorderBoxProperties() {
......@@ -41,13 +37,15 @@ void RarePaintData::SetLocalBorderBoxProperties(PropertyTreeState& state) {
PropertyTreeState RarePaintData::ContentsProperties() const {
DCHECK(local_border_box_properties_);
PropertyTreeState contents(*local_border_box_properties_);
if (paint_properties_) {
if (paint_properties_->ScrollTranslation())
contents.SetTransform(paint_properties_->ScrollTranslation());
if (paint_properties_->OverflowClip())
contents.SetClip(paint_properties_->OverflowClip());
else if (paint_properties_->CssClip())
contents.SetClip(paint_properties_->CssClip());
if (fragment_data_) {
if (auto* properties = fragment_data_->PaintProperties()) {
if (properties->ScrollTranslation())
contents.SetTransform(properties->ScrollTranslation());
if (properties->OverflowClip())
contents.SetClip(properties->OverflowClip());
else if (properties->CssClip())
contents.SetClip(properties->CssClip());
}
}
// TODO(chrishtr): cssClipFixedPosition needs to be handled somehow.
......
......@@ -6,13 +6,13 @@
#define RarePaintData_h
#include "core/CoreExport.h"
#include "core/paint/FragmentData.h"
#include "platform/wtf/Allocator.h"
#include "platform/wtf/Noncopyable.h"
namespace blink {
class PropertyTreeState;
class ObjectPaintProperties;
class PaintLayer;
// This is for paint-related data on LayoutObject that is not needed on all
......@@ -28,11 +28,15 @@ class CORE_EXPORT RarePaintData {
PaintLayer* Layer() { return layer_.get(); }
void SetLayer(std::unique_ptr<PaintLayer>);
FragmentData* Fragment() const { return fragment_data_.get(); }
FragmentData& EnsureFragment();
ObjectPaintProperties* PaintProperties() const {
return paint_properties_.get();
if (fragment_data_)
return fragment_data_->PaintProperties();
return nullptr;
}
ObjectPaintProperties& EnsurePaintProperties();
void ClearPaintProperties();
PropertyTreeState* LocalBorderBoxProperties() const {
return local_border_box_properties_.get();
......@@ -52,8 +56,7 @@ class CORE_EXPORT RarePaintData {
// depending on the return value of LayoutBoxModelObject::layerTypeRequired().
std::unique_ptr<PaintLayer> layer_;
// Holds references to the paint property nodes created by this object.
std::unique_ptr<ObjectPaintProperties> paint_properties_;
std::unique_ptr<FragmentData> fragment_data_;
// 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
......
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