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

Unified Diff: Source/core/layout/LayoutGeometryMap.cpp

Issue 1308273010: Adapt and reland old position sticky implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix style errors and remaining layout tests. Created 5 years, 3 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: Source/core/layout/LayoutGeometryMap.cpp
diff --git a/Source/core/layout/LayoutGeometryMap.cpp b/Source/core/layout/LayoutGeometryMap.cpp
index c7dedbb93608fdde59e22e4b9feead9d1eb39cfe..dbe32b493f15382fdf9dafef31452a3d78e42d71 100644
--- a/Source/core/layout/LayoutGeometryMap.cpp
+++ b/Source/core/layout/LayoutGeometryMap.cpp
@@ -38,7 +38,7 @@ LayoutGeometryMap::LayoutGeometryMap(MapCoordinatesFlags flags)
: m_insertionPosition(kNotFound)
, m_nonUniformStepsCount(0)
, m_transformedStepsCount(0)
- , m_fixedStepsCount(0)
+ , m_viewportConstrainedStepsCount(0)
, m_mapCoordinatesFlags(flags)
{
}
@@ -64,7 +64,7 @@ void LayoutGeometryMap::mapToContainer(TransformState& transformState, const Lay
for (int i = m_mapping.size() - 1; i >= 0; --i) {
const LayoutGeometryMapStep& currentStep = m_mapping[i];
- // If container is the root LayoutView (step 0) we want to apply its fixed position offset.
+ // If container is the root LayoutView (step 0) we want to apply its viewport constrained position offset.
if (i > 0 && currentStep.m_layoutObject == container) {
#if ENABLE(ASSERT)
foundContainer = true;
@@ -72,12 +72,13 @@ void LayoutGeometryMap::mapToContainer(TransformState& transformState, const Lay
break;
}
- // If this box has a transform, it acts as a fixed position container
- // for fixed descendants, which prevents the propagation of 'fixed'
- // unless the layer itself is also fixed position.
- if (i && currentStep.m_hasTransform && !currentStep.m_isFixedPosition)
+ // If this box has a transform, it acts as a viewport constrained position container
+ // for viewport constrained descendants, which prevents the propagation of viewport constrained
+ // unless the layer itself is also a viewport constrained position.
+ // TODO(flackr): Verify how fixed and sticky elements should interact with each other.
flackr 2015/09/15 21:13:11 My assumption is that this code should only apply
+ if (i && currentStep.m_hasTransform && !currentStep.m_isViewportConstrained)
inFixed = false;
- else if (currentStep.m_isFixedPosition)
+ else if (currentStep.m_isViewportConstrained)
inFixed = true;
ASSERT(!i == isTopmostLayoutView(currentStep.m_layoutObject));
@@ -94,9 +95,9 @@ void LayoutGeometryMap::mapToContainer(TransformState& transformState, const Lay
transformState.move(currentStep.m_offset.width(), currentStep.m_offset.height(), accumulate);
}
- if (inFixed && !currentStep.m_offsetForFixedPosition.isZero()) {
+ if (inFixed && !currentStep.m_offsetForViewportConstrained.isZero()) {
ASSERT(currentStep.m_layoutObject->isLayoutView());
- transformState.move(currentStep.m_offsetForFixedPosition);
+ transformState.move(currentStep.m_offsetForViewportConstrained);
}
}
@@ -108,7 +109,7 @@ FloatPoint LayoutGeometryMap::mapToContainer(const FloatPoint& p, const LayoutBo
{
FloatPoint result;
- if (!hasFixedPositionStep() && !hasTransformStep() && !hasNonUniformStep() && (!container || (m_mapping.size() && container == m_mapping[0].m_layoutObject))) {
+ if (!hasViewportConstrainedStep() && !hasTransformStep() && !hasNonUniformStep() && (!container || (m_mapping.size() && container == m_mapping[0].m_layoutObject))) {
result = p + m_accumulatedOffset;
} else {
TransformState transformState(TransformState::ApplyTransformDirection, p);
@@ -156,7 +157,7 @@ FloatQuad LayoutGeometryMap::mapToContainer(const FloatRect& rect, const LayoutB
{
FloatQuad result;
- if (!hasFixedPositionStep() && !hasTransformStep() && !hasNonUniformStep() && (!container || (m_mapping.size() && container == m_mapping[0].m_layoutObject))) {
+ if (!hasViewportConstrainedStep() && !hasTransformStep() && !hasNonUniformStep() && (!container || (m_mapping.size() && container == m_mapping[0].m_layoutObject))) {
result = rect;
result.move(m_accumulatedOffset);
} else {
@@ -239,40 +240,40 @@ void LayoutGeometryMap::pushMappingsToAncestor(const DeprecatedPaintLayer* layer
TemporaryChange<size_t> positionChange(m_insertionPosition, m_mapping.size());
bool accumulatingTransform = layer->layoutObject()->style()->preserves3D() || ancestorLayer->layoutObject()->style()->preserves3D();
- push(layoutObject, toLayoutSize(layerOffset), accumulatingTransform, /*isNonUniform*/ false, /*isFixedPosition*/ false, /*hasTransform*/ false);
+ push(layoutObject, toLayoutSize(layerOffset), accumulatingTransform, /*isNonUniform*/ false, /*isViewportConstrained*/ false, /*hasTransform*/ false);
return;
}
const LayoutBoxModelObject* ancestorLayoutObject = ancestorLayer ? ancestorLayer->layoutObject() : 0;
pushMappingsToAncestor(layoutObject, ancestorLayoutObject);
}
-void LayoutGeometryMap::push(const LayoutObject* layoutObject, const LayoutSize& offsetFromContainer, bool accumulatingTransform, bool isNonUniform, bool isFixedPosition, bool hasTransform, LayoutSize offsetForFixedPosition)
+void LayoutGeometryMap::push(const LayoutObject* layoutObject, const LayoutSize& offsetFromContainer, bool accumulatingTransform, bool isNonUniform, bool isViewportConstrained, bool hasTransform, LayoutSize offsetForViewportConstrained)
{
// fprintf(stderr, "LayoutGeometryMap::push %p %d,%d isNonUniform=%d\n", layoutObject, offsetFromContainer.width().toInt(), offsetFromContainer.height().toInt(), isNonUniform);
ASSERT(m_insertionPosition != kNotFound);
ASSERT(!layoutObject->isLayoutView() || !m_insertionPosition || m_mapCoordinatesFlags & TraverseDocumentBoundaries);
- ASSERT(offsetForFixedPosition.isZero() || layoutObject->isLayoutView());
+ ASSERT(offsetForViewportConstrained.isZero() || layoutObject->isLayoutView());
- m_mapping.insert(m_insertionPosition, LayoutGeometryMapStep(layoutObject, accumulatingTransform, isNonUniform, isFixedPosition, hasTransform));
+ m_mapping.insert(m_insertionPosition, LayoutGeometryMapStep(layoutObject, accumulatingTransform, isNonUniform, isViewportConstrained, hasTransform));
LayoutGeometryMapStep& step = m_mapping[m_insertionPosition];
step.m_offset = offsetFromContainer;
- step.m_offsetForFixedPosition = offsetForFixedPosition;
+ step.m_offsetForViewportConstrained = offsetForViewportConstrained;
stepInserted(step);
}
-void LayoutGeometryMap::push(const LayoutObject* layoutObject, const TransformationMatrix& t, bool accumulatingTransform, bool isNonUniform, bool isFixedPosition, bool hasTransform, LayoutSize offsetForFixedPosition)
+void LayoutGeometryMap::push(const LayoutObject* layoutObject, const TransformationMatrix& t, bool accumulatingTransform, bool isNonUniform, bool isViewportConstrained, bool hasTransform, LayoutSize offsetForViewportConstrained)
{
ASSERT(m_insertionPosition != kNotFound);
ASSERT(!layoutObject->isLayoutView() || !m_insertionPosition || m_mapCoordinatesFlags & TraverseDocumentBoundaries);
- ASSERT(offsetForFixedPosition.isZero() || layoutObject->isLayoutView());
+ ASSERT(offsetForViewportConstrained.isZero() || layoutObject->isLayoutView());
- m_mapping.insert(m_insertionPosition, LayoutGeometryMapStep(layoutObject, accumulatingTransform, isNonUniform, isFixedPosition, hasTransform));
+ m_mapping.insert(m_insertionPosition, LayoutGeometryMapStep(layoutObject, accumulatingTransform, isNonUniform, isViewportConstrained, hasTransform));
LayoutGeometryMapStep& step = m_mapping[m_insertionPosition];
- step.m_offsetForFixedPosition = offsetForFixedPosition;
+ step.m_offsetForViewportConstrained = offsetForViewportConstrained;
if (!t.isIntegerTranslation())
step.m_transform = adoptPtr(new TransformationMatrix(t));
@@ -308,8 +309,8 @@ void LayoutGeometryMap::stepInserted(const LayoutGeometryMapStep& step)
if (step.m_transform)
++m_transformedStepsCount;
- if (step.m_isFixedPosition)
- ++m_fixedStepsCount;
+ if (step.m_isViewportConstrained)
+ ++m_viewportConstrainedStepsCount;
}
void LayoutGeometryMap::stepRemoved(const LayoutGeometryMapStep& step)
@@ -326,9 +327,9 @@ void LayoutGeometryMap::stepRemoved(const LayoutGeometryMapStep& step)
--m_transformedStepsCount;
}
- if (step.m_isFixedPosition) {
- ASSERT(m_fixedStepsCount);
- --m_fixedStepsCount;
+ if (step.m_isViewportConstrained) {
+ ASSERT(m_viewportConstrainedStepsCount);
+ --m_viewportConstrainedStepsCount;
}
}

Powered by Google App Engine
This is Rietveld 408576698