OLD | NEW |
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 if (i > 0 && currentStep.m_layoutObject == ancestor) { | 75 if (i > 0 && currentStep.m_layoutObject == ancestor) { |
76 #if ENABLE(ASSERT) | 76 #if ENABLE(ASSERT) |
77 foundAncestor = true; | 77 foundAncestor = true; |
78 #endif | 78 #endif |
79 break; | 79 break; |
80 } | 80 } |
81 | 81 |
82 // If this box has a transform, it acts as a fixed position container | 82 // If this box has a transform, it acts as a fixed position container |
83 // for fixed descendants, which prevents the propagation of 'fixed' | 83 // for fixed descendants, which prevents the propagation of 'fixed' |
84 // unless the layer itself is also fixed position. | 84 // unless the layer itself is also fixed position. |
85 if (i && currentStep.m_hasTransform && !currentStep.m_isFixedPosition) | 85 if (i && currentStep.m_flags & HasTransform && !(currentStep.m_flags & I
sFixedPosition)) |
86 inFixed = false; | 86 inFixed = false; |
87 else if (currentStep.m_isFixedPosition) | 87 else if (currentStep.m_flags & IsFixedPosition) |
88 inFixed = true; | 88 inFixed = true; |
89 | 89 |
90 ASSERT(!i == isTopmostLayoutView(currentStep.m_layoutObject)); | 90 ASSERT(!i == isTopmostLayoutView(currentStep.m_layoutObject)); |
91 | 91 |
92 if (!i) { | 92 if (!i) { |
93 // A null container indicates mapping through the root LayoutView, s
o including its transform (the page scale). | 93 // A null container indicates mapping through the root LayoutView, s
o including its transform (the page scale). |
94 if (!ancestor && currentStep.m_transform) | 94 if (!ancestor && currentStep.m_transform) |
95 transformState.applyTransform(*currentStep.m_transform.get()); | 95 transformState.applyTransform(*currentStep.m_transform.get()); |
96 } else { | 96 } else { |
97 TransformState::TransformAccumulation accumulate = currentStep.m_acc
umulatingTransform ? TransformState::AccumulateTransform : TransformState::Flatt
enTransform; | 97 TransformState::TransformAccumulation accumulate = currentStep.m_fla
gs & AccumulatingTransform ? TransformState::AccumulateTransform : TransformStat
e::FlattenTransform; |
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 } | 108 } |
109 | 109 |
110 ASSERT(foundAncestor); | 110 ASSERT(foundAncestor); |
111 transformState.flatten(); | 111 transformState.flatten(); |
112 } | 112 } |
113 | 113 |
114 #ifndef NDEBUG | 114 #ifndef NDEBUG |
115 // Handy function to call from gdb while debugging mismatched point/rect errors. | 115 // Handy function to call from gdb while debugging mismatched point/rect errors. |
116 void LayoutGeometryMap::dumpSteps() const | 116 void LayoutGeometryMap::dumpSteps() const |
117 { | 117 { |
118 fprintf(stderr, "LayoutGeometryMap::dumpSteps accumulatedOffset=%d,%d\n", m_
accumulatedOffset.width().toInt(), m_accumulatedOffset.height().toInt()); | 118 fprintf(stderr, "LayoutGeometryMap::dumpSteps accumulatedOffset=%d,%d\n", m_
accumulatedOffset.width().toInt(), m_accumulatedOffset.height().toInt()); |
119 for (int i = m_mapping.size() - 1; i >= 0; --i) { | 119 for (int i = m_mapping.size() - 1; i >= 0; --i) { |
120 fprintf(stderr, " [%d] %s: offset=%d,%d", i, | 120 fprintf(stderr, " [%d] %s: offset=%d,%d", i, |
121 m_mapping[i].m_layoutObject->debugName().ascii().data(), | 121 m_mapping[i].m_layoutObject->debugName().ascii().data(), |
122 m_mapping[i].m_offset.width().toInt(), | 122 m_mapping[i].m_offset.width().toInt(), |
123 m_mapping[i].m_offset.height().toInt()); | 123 m_mapping[i].m_offset.height().toInt()); |
124 if (m_mapping[i].m_hasTransform) | 124 if (m_mapping[i].m_flags & HasTransform) |
125 fprintf(stderr, " hasTransform"); | 125 fprintf(stderr, " hasTransform"); |
126 fprintf(stderr, "\n"); | 126 fprintf(stderr, "\n"); |
127 } | 127 } |
128 } | 128 } |
129 #endif | 129 #endif |
130 | 130 |
131 FloatQuad LayoutGeometryMap::mapToAncestor(const FloatRect& rect, const LayoutBo
xModelObject* ancestor) const | 131 FloatQuad LayoutGeometryMap::mapToAncestor(const FloatRect& rect, const LayoutBo
xModelObject* ancestor) const |
132 { | 132 { |
133 FloatQuad result; | 133 FloatQuad result; |
134 | 134 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 layer->convertToLayerCoords(ancestorLayer, layerOffset); | 204 layer->convertToLayerCoords(ancestorLayer, layerOffset); |
205 | 205 |
206 // The LayoutView must be pushed first. | 206 // The LayoutView must be pushed first. |
207 if (!m_mapping.size()) { | 207 if (!m_mapping.size()) { |
208 ASSERT(ancestorLayer->layoutObject()->isLayoutView()); | 208 ASSERT(ancestorLayer->layoutObject()->isLayoutView()); |
209 pushMappingsToAncestor(ancestorLayer->layoutObject(), 0); | 209 pushMappingsToAncestor(ancestorLayer->layoutObject(), 0); |
210 } | 210 } |
211 | 211 |
212 TemporaryChange<size_t> positionChange(m_insertionPosition, m_mapping.si
ze()); | 212 TemporaryChange<size_t> positionChange(m_insertionPosition, m_mapping.si
ze()); |
213 bool accumulatingTransform = layer->layoutObject()->style()->preserves3D
() || ancestorLayer->layoutObject()->style()->preserves3D(); | 213 bool accumulatingTransform = layer->layoutObject()->style()->preserves3D
() || ancestorLayer->layoutObject()->style()->preserves3D(); |
214 push(layoutObject, toLayoutSize(layerOffset), accumulatingTransform, /*i
sNonUniform*/ false, /*isFixedPosition*/ false, /*hasTransform*/ false); | 214 push(layoutObject, toLayoutSize(layerOffset), accumulatingTransform ? Ac
cumulatingTransform : 0); |
215 return; | 215 return; |
216 } | 216 } |
217 const LayoutBoxModelObject* ancestorLayoutObject = ancestorLayer ? ancestorL
ayer->layoutObject() : 0; | 217 const LayoutBoxModelObject* ancestorLayoutObject = ancestorLayer ? ancestorL
ayer->layoutObject() : 0; |
218 pushMappingsToAncestor(layoutObject, ancestorLayoutObject); | 218 pushMappingsToAncestor(layoutObject, ancestorLayoutObject); |
219 } | 219 } |
220 | 220 |
221 void LayoutGeometryMap::push(const LayoutObject* layoutObject, const LayoutSize&
offsetFromContainer, bool accumulatingTransform, bool isNonUniform, bool isFixe
dPosition, bool hasTransform, LayoutSize offsetForFixedPosition) | 221 void LayoutGeometryMap::push(const LayoutObject* layoutObject, const LayoutSize&
offsetFromContainer, GeometryInfoFlags flags, LayoutSize offsetForFixedPosition
) |
222 { | 222 { |
223 LAYOUT_GEOMETRY_MAP_LOG("LayoutGeometryMap::push %p %d,%d isNonUniform=%d\n"
, layoutObject, offsetFromContainer.width().toInt(), offsetFromContainer.height(
).toInt(), isNonUniform); | 223 LAYOUT_GEOMETRY_MAP_LOG("LayoutGeometryMap::push %p %d,%d isNonUniform=%d\n"
, layoutObject, offsetFromContainer.width().toInt(), offsetFromContainer.height(
).toInt(), isNonUniform); |
224 | 224 |
225 ASSERT(m_insertionPosition != kNotFound); | 225 ASSERT(m_insertionPosition != kNotFound); |
226 ASSERT(!layoutObject->isLayoutView() || !m_insertionPosition || m_mapCoordin
atesFlags & TraverseDocumentBoundaries); | 226 ASSERT(!layoutObject->isLayoutView() || !m_insertionPosition || m_mapCoordin
atesFlags & TraverseDocumentBoundaries); |
227 ASSERT(offsetForFixedPosition.isZero() || layoutObject->isLayoutView()); | 227 ASSERT(offsetForFixedPosition.isZero() || layoutObject->isLayoutView()); |
228 | 228 |
229 m_mapping.insert(m_insertionPosition, LayoutGeometryMapStep(layoutObject, ac
cumulatingTransform, isNonUniform, isFixedPosition, hasTransform)); | 229 m_mapping.insert(m_insertionPosition, LayoutGeometryMapStep(layoutObject, fl
ags)); |
230 | 230 |
231 LayoutGeometryMapStep& step = m_mapping[m_insertionPosition]; | 231 LayoutGeometryMapStep& step = m_mapping[m_insertionPosition]; |
232 step.m_offset = offsetFromContainer; | 232 step.m_offset = offsetFromContainer; |
233 step.m_offsetForFixedPosition = offsetForFixedPosition; | 233 step.m_offsetForFixedPosition = offsetForFixedPosition; |
234 | 234 |
235 stepInserted(step); | 235 stepInserted(step); |
236 } | 236 } |
237 | 237 |
238 void LayoutGeometryMap::push(const LayoutObject* layoutObject, const Transformat
ionMatrix& t, bool accumulatingTransform, bool isNonUniform, bool isFixedPositio
n, bool hasTransform, LayoutSize offsetForFixedPosition) | 238 void LayoutGeometryMap::push(const LayoutObject* layoutObject, const Transformat
ionMatrix& t, GeometryInfoFlags flags, LayoutSize offsetForFixedPosition) |
239 { | 239 { |
240 ASSERT(m_insertionPosition != kNotFound); | 240 ASSERT(m_insertionPosition != kNotFound); |
241 ASSERT(!layoutObject->isLayoutView() || !m_insertionPosition || m_mapCoordin
atesFlags & TraverseDocumentBoundaries); | 241 ASSERT(!layoutObject->isLayoutView() || !m_insertionPosition || m_mapCoordin
atesFlags & TraverseDocumentBoundaries); |
242 ASSERT(offsetForFixedPosition.isZero() || layoutObject->isLayoutView()); | 242 ASSERT(offsetForFixedPosition.isZero() || layoutObject->isLayoutView()); |
243 | 243 |
244 m_mapping.insert(m_insertionPosition, LayoutGeometryMapStep(layoutObject, ac
cumulatingTransform, isNonUniform, isFixedPosition, hasTransform)); | 244 m_mapping.insert(m_insertionPosition, LayoutGeometryMapStep(layoutObject, fl
ags)); |
245 | 245 |
246 LayoutGeometryMapStep& step = m_mapping[m_insertionPosition]; | 246 LayoutGeometryMapStep& step = m_mapping[m_insertionPosition]; |
247 step.m_offsetForFixedPosition = offsetForFixedPosition; | 247 step.m_offsetForFixedPosition = offsetForFixedPosition; |
248 | 248 |
249 if (!t.isIntegerTranslation()) | 249 if (!t.isIntegerTranslation()) |
250 step.m_transform = TransformationMatrix::create(t); | 250 step.m_transform = TransformationMatrix::create(t); |
251 else | 251 else |
252 step.m_offset = LayoutSize(t.e(), t.f()); | 252 step.m_offset = LayoutSize(t.e(), t.f()); |
253 | 253 |
254 stepInserted(step); | 254 stepInserted(step); |
(...skipping 12 matching lines...) Expand all Loading... |
267 void LayoutGeometryMap::popMappingsToAncestor(const PaintLayer* ancestorLayer) | 267 void LayoutGeometryMap::popMappingsToAncestor(const PaintLayer* ancestorLayer) |
268 { | 268 { |
269 const LayoutBoxModelObject* ancestorLayoutObject = ancestorLayer ? ancestorL
ayer->layoutObject() : 0; | 269 const LayoutBoxModelObject* ancestorLayoutObject = ancestorLayer ? ancestorL
ayer->layoutObject() : 0; |
270 popMappingsToAncestor(ancestorLayoutObject); | 270 popMappingsToAncestor(ancestorLayoutObject); |
271 } | 271 } |
272 | 272 |
273 void LayoutGeometryMap::stepInserted(const LayoutGeometryMapStep& step) | 273 void LayoutGeometryMap::stepInserted(const LayoutGeometryMapStep& step) |
274 { | 274 { |
275 m_accumulatedOffset += step.m_offset; | 275 m_accumulatedOffset += step.m_offset; |
276 | 276 |
277 if (step.m_isNonUniform) | 277 if (step.m_flags & IsNonUniform) |
278 ++m_nonUniformStepsCount; | 278 ++m_nonUniformStepsCount; |
279 | 279 |
280 if (step.m_transform) | 280 if (step.m_transform) |
281 ++m_transformedStepsCount; | 281 ++m_transformedStepsCount; |
282 | 282 |
283 if (step.m_isFixedPosition) | 283 if (step.m_flags & IsFixedPosition) |
284 ++m_fixedStepsCount; | 284 ++m_fixedStepsCount; |
285 } | 285 } |
286 | 286 |
287 void LayoutGeometryMap::stepRemoved(const LayoutGeometryMapStep& step) | 287 void LayoutGeometryMap::stepRemoved(const LayoutGeometryMapStep& step) |
288 { | 288 { |
289 m_accumulatedOffset -= step.m_offset; | 289 m_accumulatedOffset -= step.m_offset; |
290 | 290 |
291 if (step.m_isNonUniform) { | 291 if (step.m_flags & IsNonUniform) { |
292 ASSERT(m_nonUniformStepsCount); | 292 ASSERT(m_nonUniformStepsCount); |
293 --m_nonUniformStepsCount; | 293 --m_nonUniformStepsCount; |
294 } | 294 } |
295 | 295 |
296 if (step.m_transform) { | 296 if (step.m_transform) { |
297 ASSERT(m_transformedStepsCount); | 297 ASSERT(m_transformedStepsCount); |
298 --m_transformedStepsCount; | 298 --m_transformedStepsCount; |
299 } | 299 } |
300 | 300 |
301 if (step.m_isFixedPosition) { | 301 if (step.m_flags & IsFixedPosition) { |
302 ASSERT(m_fixedStepsCount); | 302 ASSERT(m_fixedStepsCount); |
303 --m_fixedStepsCount; | 303 --m_fixedStepsCount; |
304 } | 304 } |
305 } | 305 } |
306 | 306 |
307 #if ENABLE(ASSERT) | 307 #if ENABLE(ASSERT) |
308 bool LayoutGeometryMap::isTopmostLayoutView(const LayoutObject* layoutObject) co
nst | 308 bool LayoutGeometryMap::isTopmostLayoutView(const LayoutObject* layoutObject) co
nst |
309 { | 309 { |
310 if (!layoutObject->isLayoutView()) | 310 if (!layoutObject->isLayoutView()) |
311 return false; | 311 return false; |
312 | 312 |
313 // If we're not working with multiple LayoutViews, then any view is consider
ed | 313 // If we're not working with multiple LayoutViews, then any view is consider
ed |
314 // "topmost" (to preserve original behavior). | 314 // "topmost" (to preserve original behavior). |
315 if (!(m_mapCoordinatesFlags & TraverseDocumentBoundaries)) | 315 if (!(m_mapCoordinatesFlags & TraverseDocumentBoundaries)) |
316 return true; | 316 return true; |
317 | 317 |
318 return layoutObject->frame()->isMainFrame(); | 318 return layoutObject->frame()->isMainFrame(); |
319 } | 319 } |
320 #endif | 320 #endif |
321 | 321 |
322 } // namespace blink | 322 } // namespace blink |
OLD | NEW |