Index: Source/platform/graphics/paint/DisplayItemPropertyTreeBuilder.cpp |
diff --git a/Source/platform/graphics/paint/DisplayItemPropertyTreeBuilder.cpp b/Source/platform/graphics/paint/DisplayItemPropertyTreeBuilder.cpp |
index 6689f124037802d870a86390a1182af0ef09209d..b444544da138fea75b3aa6fcbc52c189c7f3e4f5 100644 |
--- a/Source/platform/graphics/paint/DisplayItemPropertyTreeBuilder.cpp |
+++ b/Source/platform/graphics/paint/DisplayItemPropertyTreeBuilder.cpp |
@@ -5,9 +5,11 @@ |
#include "config.h" |
#include "platform/graphics/paint/DisplayItemPropertyTreeBuilder.h" |
+#include "platform/RuntimeEnabledFeatures.h" |
#include "platform/graphics/paint/DisplayItem.h" |
#include "platform/graphics/paint/DisplayItemClipTree.h" |
#include "platform/graphics/paint/DisplayItemTransformTree.h" |
+#include "platform/graphics/paint/FixedPositionDisplayItem.h" |
#include "platform/graphics/paint/ScrollDisplayItem.h" |
#include "platform/graphics/paint/Transform3DDisplayItem.h" |
#include "platform/graphics/paint/TransformDisplayItem.h" |
@@ -56,6 +58,8 @@ void DisplayItemPropertyTreeBuilder::processDisplayItem(const DisplayItem& displ |
processBeginItem(displayItem); |
else if (displayItem.isEnd()) |
processEndItem(displayItem); |
+ else if (displayItem.type() == DisplayItem::FixedPositionContainer) |
+ processAnchorItem(displayItem); |
m_currentIndex++; |
} |
@@ -63,12 +67,15 @@ namespace { |
enum TransformKind { NotATransform = 0, Only2DTranslation, RequiresTransformNode }; |
enum ClipKind { NotAClip = 0, RequiresClipNode }; |
+enum SpecialKind { NotSpecial = 0, IsFixedPosition }; |
struct BeginDisplayItemClassification { |
TransformKind transformKind = NotATransform; |
TransformationMatrix matrix; |
ClipKind clipKind = NotAClip; |
FloatRect clipRect; |
+ SpecialKind specialKind = NotSpecial; |
+ DisplayItemClient anchorKey; |
}; |
// Classifies a begin display item based on how it affects the property trees. |
@@ -91,6 +98,9 @@ static BeginDisplayItemClassification classifyBeginItem(const DisplayItem& begin |
const IntSize& offset = beginScroll.currentOffset(); |
result.matrix.translate(-offset.width(), -offset.height()); |
result.transformKind = Only2DTranslation; |
+ } else if (type == DisplayItem::BeginFixedPosition) { |
+ result.specialKind = IsFixedPosition; |
+ result.anchorKey = static_cast<const BeginFixedPositionDisplayItem&>(beginDisplayItem).anchor(); |
} |
return result; |
} |
@@ -101,7 +111,7 @@ void DisplayItemPropertyTreeBuilder::processBeginItem(const DisplayItem& display |
{ |
BeginDisplayItemClassification classification = classifyBeginItem(displayItem); |
- if (!classification.transformKind && !classification.clipKind) { |
+ if (!classification.transformKind && !classification.clipKind && !classification.specialKind) { |
currentState().ignoredBeginCount++; |
return; |
} |
@@ -137,6 +147,23 @@ void DisplayItemPropertyTreeBuilder::processBeginItem(const DisplayItem& display |
break; |
} |
+ switch (classification.specialKind) { |
+ case NotSpecial: |
+ break; |
+ case IsFixedPosition: |
+ BuilderState referredState(m_anchors.get(classification.anchorKey)); |
+ newState.transformNode = referredState.transformNode; |
+ newState.offset = referredState.offset; |
+ newState.clipNode = referredState.clipNode; |
+ { |
+ // Note: This is only temporarily workaround before we implement true |
+ // transform-tree-based rasterization. |
+ ASSERT(currentState().transformNode == newState.transformNode); |
+ static_cast<const BeginFixedPositionDisplayItem&>(displayItem).setCounterScroll(newState.offset - currentState().offset); |
+ } |
+ break; |
+ } |
+ |
m_stateStack.append(newState); |
} |
@@ -153,6 +180,14 @@ void DisplayItemPropertyTreeBuilder::processEndItem(const DisplayItem& displayIt |
} |
} |
+void DisplayItemPropertyTreeBuilder::processAnchorItem(const DisplayItem& displayItem) |
+{ |
+ ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
+ // Anchors can duplicate when we have reflection or fragments. |
+ // We can't assert uniqueness here. However we may assume the most recent one is valid. |
+ m_anchors.set(displayItem.client(), currentState()); |
+} |
+ |
void DisplayItemPropertyTreeBuilder::finishRange() |
{ |
// Don't emit an empty range record. |