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

Side by Side Diff: third_party/WebKit/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: Merge with master and skip anonymous containing blocks for sticky container. Created 4 years, 10 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 if (currentStep.m_transform) 98 if (currentStep.m_transform)
99 transformState.applyTransform(*currentStep.m_transform.get(), ac cumulate); 99 transformState.applyTransform(*currentStep.m_transform.get(), ac cumulate);
100 else 100 else
101 transformState.move(currentStep.m_offset.width(), currentStep.m_ offset.height(), accumulate); 101 transformState.move(currentStep.m_offset.width(), currentStep.m_ offset.height(), accumulate);
102 } 102 }
103 103
104 if (inFixed && !currentStep.m_offsetForFixedPosition.isZero()) { 104 if (inFixed && !currentStep.m_offsetForFixedPosition.isZero()) {
105 ASSERT(currentStep.m_layoutObject->isLayoutView()); 105 ASSERT(currentStep.m_layoutObject->isLayoutView());
106 transformState.move(currentStep.m_offsetForFixedPosition); 106 transformState.move(currentStep.m_offsetForFixedPosition);
107 } 107 }
108 if (!currentStep.m_offsetForStickyPosition.isZero()) {
109 ASSERT(currentStep.m_layoutObject->style()->position() == StickyPosi tion);
110 transformState.move(currentStep.m_offsetForStickyPosition);
111 }
108 } 112 }
109 113
110 ASSERT(foundAncestor); 114 ASSERT(foundAncestor);
111 transformState.flatten(); 115 transformState.flatten();
112 } 116 }
113 117
114 #ifndef NDEBUG 118 #ifndef NDEBUG
115 // Handy function to call from gdb while debugging mismatched point/rect errors. 119 // Handy function to call from gdb while debugging mismatched point/rect errors.
116 void LayoutGeometryMap::dumpSteps() const 120 void LayoutGeometryMap::dumpSteps() const
117 { 121 {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 215
212 TemporaryChange<size_t> positionChange(m_insertionPosition, m_mapping.si ze()); 216 TemporaryChange<size_t> positionChange(m_insertionPosition, m_mapping.si ze());
213 bool accumulatingTransform = layer->layoutObject()->style()->preserves3D () || ancestorLayer->layoutObject()->style()->preserves3D(); 217 bool accumulatingTransform = layer->layoutObject()->style()->preserves3D () || ancestorLayer->layoutObject()->style()->preserves3D();
214 push(layoutObject, toLayoutSize(layerOffset), accumulatingTransform, /*i sNonUniform*/ false, /*isFixedPosition*/ false, /*hasTransform*/ false); 218 push(layoutObject, toLayoutSize(layerOffset), accumulatingTransform, /*i sNonUniform*/ false, /*isFixedPosition*/ false, /*hasTransform*/ false);
215 return; 219 return;
216 } 220 }
217 const LayoutBoxModelObject* ancestorLayoutObject = ancestorLayer ? ancestorL ayer->layoutObject() : 0; 221 const LayoutBoxModelObject* ancestorLayoutObject = ancestorLayer ? ancestorL ayer->layoutObject() : 0;
218 pushMappingsToAncestor(layoutObject, ancestorLayoutObject); 222 pushMappingsToAncestor(layoutObject, ancestorLayoutObject);
219 } 223 }
220 224
221 void LayoutGeometryMap::push(const LayoutObject* layoutObject, const LayoutSize& offsetFromContainer, bool accumulatingTransform, bool isNonUniform, bool isFixe dPosition, bool hasTransform, LayoutSize offsetForFixedPosition) 225 void LayoutGeometryMap::push(const LayoutObject* layoutObject, const LayoutSize& offsetFromContainer, bool accumulatingTransform, bool isNonUniform, bool isFixe dPosition, bool hasTransform, LayoutSize offsetForFixedPosition, LayoutSize offs etForStickyPosition)
222 { 226 {
223 LAYOUT_GEOMETRY_MAP_LOG("LayoutGeometryMap::push %p %d,%d isNonUniform=%d\n" , layoutObject, offsetFromContainer.width().toInt(), offsetFromContainer.height( ).toInt(), isNonUniform); 227 LAYOUT_GEOMETRY_MAP_LOG("LayoutGeometryMap::push %p %d,%d isNonUniform=%d\n" , layoutObject, offsetFromContainer.width().toInt(), offsetFromContainer.height( ).toInt(), isNonUniform);
224 228
225 ASSERT(m_insertionPosition != kNotFound); 229 ASSERT(m_insertionPosition != kNotFound);
226 ASSERT(!layoutObject->isLayoutView() || !m_insertionPosition || m_mapCoordin atesFlags & TraverseDocumentBoundaries); 230 ASSERT(!layoutObject->isLayoutView() || !m_insertionPosition || m_mapCoordin atesFlags & TraverseDocumentBoundaries);
227 ASSERT(offsetForFixedPosition.isZero() || layoutObject->isLayoutView()); 231 ASSERT(offsetForFixedPosition.isZero() || layoutObject->isLayoutView());
232 ASSERT(offsetForStickyPosition.isZero() || layoutObject->style()->position() == StickyPosition);
228 233
229 m_mapping.insert(m_insertionPosition, LayoutGeometryMapStep(layoutObject, ac cumulatingTransform, isNonUniform, isFixedPosition, hasTransform)); 234 m_mapping.insert(m_insertionPosition, LayoutGeometryMapStep(layoutObject, ac cumulatingTransform, isNonUniform, isFixedPosition, hasTransform));
230 235
231 LayoutGeometryMapStep& step = m_mapping[m_insertionPosition]; 236 LayoutGeometryMapStep& step = m_mapping[m_insertionPosition];
232 step.m_offset = offsetFromContainer; 237 step.m_offset = offsetFromContainer;
233 step.m_offsetForFixedPosition = offsetForFixedPosition; 238 step.m_offsetForFixedPosition = offsetForFixedPosition;
239 step.m_offsetForStickyPosition = offsetForStickyPosition;
234 240
235 stepInserted(step); 241 stepInserted(step);
236 } 242 }
237 243
238 void LayoutGeometryMap::push(const LayoutObject* layoutObject, const Transformat ionMatrix& t, bool accumulatingTransform, bool isNonUniform, bool isFixedPositio n, bool hasTransform, LayoutSize offsetForFixedPosition) 244 void LayoutGeometryMap::push(const LayoutObject* layoutObject, const Transformat ionMatrix& t, bool accumulatingTransform, bool isNonUniform, bool isFixedPositio n, bool hasTransform, LayoutSize offsetForFixedPosition, LayoutSize offsetForSti ckyPosition)
239 { 245 {
240 ASSERT(m_insertionPosition != kNotFound); 246 ASSERT(m_insertionPosition != kNotFound);
241 ASSERT(!layoutObject->isLayoutView() || !m_insertionPosition || m_mapCoordin atesFlags & TraverseDocumentBoundaries); 247 ASSERT(!layoutObject->isLayoutView() || !m_insertionPosition || m_mapCoordin atesFlags & TraverseDocumentBoundaries);
242 ASSERT(offsetForFixedPosition.isZero() || layoutObject->isLayoutView()); 248 ASSERT(offsetForFixedPosition.isZero() || layoutObject->isLayoutView());
249 ASSERT(offsetForStickyPosition.isZero() || layoutObject->style()->position() == StickyPosition);
243 250
244 m_mapping.insert(m_insertionPosition, LayoutGeometryMapStep(layoutObject, ac cumulatingTransform, isNonUniform, isFixedPosition, hasTransform)); 251 m_mapping.insert(m_insertionPosition, LayoutGeometryMapStep(layoutObject, ac cumulatingTransform, isNonUniform, isFixedPosition, hasTransform));
245 252
246 LayoutGeometryMapStep& step = m_mapping[m_insertionPosition]; 253 LayoutGeometryMapStep& step = m_mapping[m_insertionPosition];
247 step.m_offsetForFixedPosition = offsetForFixedPosition; 254 step.m_offsetForFixedPosition = offsetForFixedPosition;
255 step.m_offsetForStickyPosition = offsetForStickyPosition;
248 256
249 if (!t.isIntegerTranslation()) 257 if (!t.isIntegerTranslation())
250 step.m_transform = adoptPtr(new TransformationMatrix(t)); 258 step.m_transform = adoptPtr(new TransformationMatrix(t));
251 else 259 else
252 step.m_offset = LayoutSize(t.e(), t.f()); 260 step.m_offset = LayoutSize(t.e(), t.f());
253 261
254 stepInserted(step); 262 stepInserted(step);
255 } 263 }
256 264
257 void LayoutGeometryMap::popMappingsToAncestor(const LayoutBoxModelObject* ancest orLayoutObject) 265 void LayoutGeometryMap::popMappingsToAncestor(const LayoutBoxModelObject* ancest orLayoutObject)
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 // If we're not working with multiple LayoutViews, then any view is consider ed 321 // If we're not working with multiple LayoutViews, then any view is consider ed
314 // "topmost" (to preserve original behavior). 322 // "topmost" (to preserve original behavior).
315 if (!(m_mapCoordinatesFlags & TraverseDocumentBoundaries)) 323 if (!(m_mapCoordinatesFlags & TraverseDocumentBoundaries))
316 return true; 324 return true;
317 325
318 return layoutObject->frame()->isMainFrame(); 326 return layoutObject->frame()->isMainFrame();
319 } 327 }
320 #endif 328 #endif
321 329
322 } // namespace blink 330 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698