Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(511)

Unified Diff: third_party/WebKit/Source/core/layout/LayoutObject.cpp

Issue 2782343002: Store local border box property cache outside ObjectPaintProperties (Closed)
Patch Set: Rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/LayoutObject.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutObject.cpp b/third_party/WebKit/Source/core/layout/LayoutObject.cpp
index 3b45ec3219f895b886987f480d72752fa2bb095e..b5ceda52634926be97d85f95c5b38b42d2187140 100644
--- a/third_party/WebKit/Source/core/layout/LayoutObject.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutObject.cpp
@@ -85,6 +85,7 @@
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/geometry/TransformState.h"
#include "platform/graphics/GraphicsLayer.h"
+#include "platform/graphics/paint/PropertyTreeState.h"
#include "platform/instrumentation/tracing/TracedValue.h"
#include "wtf/allocator/Partitions.h"
#include "wtf/text/StringBuilder.h"
@@ -3552,7 +3553,10 @@ void LayoutObject::setIsBackgroundAttachmentFixedObject(
frameView()->removeBackgroundAttachmentFixedObject(this);
}
-LayoutObject::RarePaintData::RarePaintData() : m_paintProperties(nullptr) {}
+LayoutObject::RarePaintData::RarePaintData()
+ : m_paintProperties(nullptr),
+ m_localBorderBoxProperties(nullptr),
+ m_contentsProperties(nullptr) {}
Xianzhu 2017/03/30 00:41:11 Nit: omit this to use default constructor of uniqu
LayoutObject::RarePaintData::~RarePaintData() {}
@@ -3562,6 +3566,48 @@ ObjectPaintProperties& LayoutObject::RarePaintData::ensurePaintProperties() {
return *m_paintProperties.get();
}
+void LayoutObject::RarePaintData::clearLocalBorderBoxProperties() {
+ m_localBorderBoxProperties = nullptr;
+
+ // The contents properties are based on the border box so we need to clear
+ // the cached value.
+ m_contentsProperties = nullptr;
+}
+
+void LayoutObject::RarePaintData::setLocalBorderBoxProperties(
+ PropertyTreeState& state) {
+ if (!m_localBorderBoxProperties)
+ m_localBorderBoxProperties = WTF::makeUnique<PropertyTreeState>(state);
+ else
+ *m_localBorderBoxProperties = state;
+
+ // The contents properties are based on the border box so we need to clear
+ // the cached value.
+ m_contentsProperties = nullptr;
+}
+
+const PropertyTreeState* LayoutObject::RarePaintData::contentsProperties()
+ const {
+ if (!m_contentsProperties) {
+ if (m_localBorderBoxProperties) {
+ m_contentsProperties = ObjectPaintProperties::contentsProperties(
+ m_localBorderBoxProperties.get(), m_paintProperties.get());
+ }
+ } else {
+#if DCHECK_IS_ON()
+ // Check that the cached contents properties are valid by checking that they
+ // do not change if recalculated.
+ DCHECK(m_localBorderBoxProperties);
+ std::unique_ptr<PropertyTreeState> oldProperties =
+ std::move(m_contentsProperties);
+ m_contentsProperties = ObjectPaintProperties::contentsProperties(
+ m_localBorderBoxProperties.get(), m_paintProperties.get());
+ DCHECK(*m_contentsProperties == *oldProperties);
+#endif
+ }
+ return m_contentsProperties.get();
+}
+
LayoutObject::RarePaintData& LayoutObject::ensureRarePaintData() {
if (!m_rarePaintData)
m_rarePaintData = WTF::makeUnique<RarePaintData>();
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutObject.h ('k') | third_party/WebKit/Source/core/layout/VisualRectMappingTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698