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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 m_nonUniformStepsCount(0), | 45 m_nonUniformStepsCount(0), |
46 m_transformedStepsCount(0), | 46 m_transformedStepsCount(0), |
47 m_fixedStepsCount(0), | 47 m_fixedStepsCount(0), |
48 m_mapCoordinatesFlags(flags) {} | 48 m_mapCoordinatesFlags(flags) {} |
49 | 49 |
50 LayoutGeometryMap::~LayoutGeometryMap() {} | 50 LayoutGeometryMap::~LayoutGeometryMap() {} |
51 | 51 |
52 void LayoutGeometryMap::mapToAncestor( | 52 void LayoutGeometryMap::mapToAncestor( |
53 TransformState& transformState, | 53 TransformState& transformState, |
54 const LayoutBoxModelObject* ancestor) const { | 54 const LayoutBoxModelObject* ancestor) const { |
55 // If the mapping includes something like columns, we have to go via layoutObj
ects. | 55 // If the mapping includes something like columns, we have to go via |
| 56 // layoutObjects. |
56 if (hasNonUniformStep()) { | 57 if (hasNonUniformStep()) { |
57 m_mapping.last().m_layoutObject->mapLocalToAncestor( | 58 m_mapping.last().m_layoutObject->mapLocalToAncestor( |
58 ancestor, transformState, ApplyContainerFlip | m_mapCoordinatesFlags); | 59 ancestor, transformState, ApplyContainerFlip | m_mapCoordinatesFlags); |
59 transformState.flatten(); | 60 transformState.flatten(); |
60 return; | 61 return; |
61 } | 62 } |
62 | 63 |
63 bool inFixed = false; | 64 bool inFixed = false; |
64 #if ENABLE(ASSERT) | 65 #if ENABLE(ASSERT) |
65 bool foundAncestor = !ancestor || (m_mapping.size() && | 66 bool foundAncestor = !ancestor || (m_mapping.size() && |
66 m_mapping[0].m_layoutObject == ancestor); | 67 m_mapping[0].m_layoutObject == ancestor); |
67 #endif | 68 #endif |
68 | 69 |
69 for (int i = m_mapping.size() - 1; i >= 0; --i) { | 70 for (int i = m_mapping.size() - 1; i >= 0; --i) { |
70 const LayoutGeometryMapStep& currentStep = m_mapping[i]; | 71 const LayoutGeometryMapStep& currentStep = m_mapping[i]; |
71 | 72 |
72 // If container is the root LayoutView (step 0) we want to apply its fixed p
osition offset. | 73 // If container is the root LayoutView (step 0) we want to apply its fixed |
| 74 // position offset. |
73 if (i > 0 && currentStep.m_layoutObject == ancestor) { | 75 if (i > 0 && currentStep.m_layoutObject == ancestor) { |
74 #if ENABLE(ASSERT) | 76 #if ENABLE(ASSERT) |
75 foundAncestor = true; | 77 foundAncestor = true; |
76 #endif | 78 #endif |
77 break; | 79 break; |
78 } | 80 } |
79 | 81 |
80 // 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 |
81 // for fixed descendants, which prevents the propagation of 'fixed' | 83 // for fixed descendants, which prevents the propagation of 'fixed' |
82 // unless the layer itself is also fixed position. | 84 // unless the layer itself is also fixed position. |
83 if (i && currentStep.m_flags & ContainsFixedPosition && | 85 if (i && currentStep.m_flags & ContainsFixedPosition && |
84 !(currentStep.m_flags & IsFixedPosition)) | 86 !(currentStep.m_flags & IsFixedPosition)) |
85 inFixed = false; | 87 inFixed = false; |
86 else if (currentStep.m_flags & IsFixedPosition) | 88 else if (currentStep.m_flags & IsFixedPosition) |
87 inFixed = true; | 89 inFixed = true; |
88 | 90 |
89 ASSERT(!i == isTopmostLayoutView(currentStep.m_layoutObject)); | 91 ASSERT(!i == isTopmostLayoutView(currentStep.m_layoutObject)); |
90 | 92 |
91 if (!i) { | 93 if (!i) { |
92 // A null container indicates mapping through the root LayoutView, so incl
uding its transform (the page scale). | 94 // A null container indicates mapping through the root LayoutView, so |
| 95 // including its transform (the page scale). |
93 if (!ancestor && currentStep.m_transform) | 96 if (!ancestor && currentStep.m_transform) |
94 transformState.applyTransform(*currentStep.m_transform.get()); | 97 transformState.applyTransform(*currentStep.m_transform.get()); |
95 } else { | 98 } else { |
96 TransformState::TransformAccumulation accumulate = | 99 TransformState::TransformAccumulation accumulate = |
97 currentStep.m_flags & AccumulatingTransform | 100 currentStep.m_flags & AccumulatingTransform |
98 ? TransformState::AccumulateTransform | 101 ? TransformState::AccumulateTransform |
99 : TransformState::FlattenTransform; | 102 : TransformState::FlattenTransform; |
100 if (currentStep.m_transform) | 103 if (currentStep.m_transform) |
101 transformState.applyTransform(*currentStep.m_transform.get(), | 104 transformState.applyTransform(*currentStep.m_transform.get(), |
102 accumulate); | 105 accumulate); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 155 |
153 #if ENABLE(ASSERT) | 156 #if ENABLE(ASSERT) |
154 if (m_mapping.size() > 0) { | 157 if (m_mapping.size() > 0) { |
155 const LayoutObject* lastLayoutObject = m_mapping.last().m_layoutObject; | 158 const LayoutObject* lastLayoutObject = m_mapping.last().m_layoutObject; |
156 | 159 |
157 FloatRect layoutObjectMappedResult = | 160 FloatRect layoutObjectMappedResult = |
158 lastLayoutObject | 161 lastLayoutObject |
159 ->localToAncestorQuad(rect, ancestor, m_mapCoordinatesFlags) | 162 ->localToAncestorQuad(rect, ancestor, m_mapCoordinatesFlags) |
160 .boundingBox(); | 163 .boundingBox(); |
161 | 164 |
162 // Inspector creates layoutObjects with negative width <https://bugs.webkit.
org/show_bug.cgi?id=87194>. | 165 // Inspector creates layoutObjects with negative width |
| 166 // <https://bugs.webkit.org/show_bug.cgi?id=87194>. |
163 // Taking FloatQuad bounds avoids spurious assertions because of that. | 167 // Taking FloatQuad bounds avoids spurious assertions because of that. |
164 ASSERT(enclosingIntRect(layoutObjectMappedResult) == | 168 ASSERT(enclosingIntRect(layoutObjectMappedResult) == |
165 enclosingIntRect(result.boundingBox()) || | 169 enclosingIntRect(result.boundingBox()) || |
166 layoutObjectMappedResult.mayNotHaveExactIntRectRepresentation() || | 170 layoutObjectMappedResult.mayNotHaveExactIntRectRepresentation() || |
167 result.boundingBox().mayNotHaveExactIntRectRepresentation()); | 171 result.boundingBox().mayNotHaveExactIntRectRepresentation()); |
168 } | 172 } |
169 #endif | 173 #endif |
170 | 174 |
171 return result; | 175 return result; |
172 } | 176 } |
173 | 177 |
174 void LayoutGeometryMap::pushMappingsToAncestor( | 178 void LayoutGeometryMap::pushMappingsToAncestor( |
175 const LayoutObject* layoutObject, | 179 const LayoutObject* layoutObject, |
176 const LayoutBoxModelObject* ancestorLayoutObject) { | 180 const LayoutBoxModelObject* ancestorLayoutObject) { |
177 // We need to push mappings in reverse order here, so do insertions rather tha
n appends. | 181 // We need to push mappings in reverse order here, so do insertions rather |
| 182 // than appends. |
178 AutoReset<size_t> positionChange(&m_insertionPosition, m_mapping.size()); | 183 AutoReset<size_t> positionChange(&m_insertionPosition, m_mapping.size()); |
179 do { | 184 do { |
180 layoutObject = | 185 layoutObject = |
181 layoutObject->pushMappingToContainer(ancestorLayoutObject, *this); | 186 layoutObject->pushMappingToContainer(ancestorLayoutObject, *this); |
182 } while (layoutObject && layoutObject != ancestorLayoutObject); | 187 } while (layoutObject && layoutObject != ancestorLayoutObject); |
183 | 188 |
184 ASSERT(m_mapping.isEmpty() || | 189 ASSERT(m_mapping.isEmpty() || |
185 isTopmostLayoutView(m_mapping[0].m_layoutObject)); | 190 isTopmostLayoutView(m_mapping[0].m_layoutObject)); |
186 } | 191 } |
187 | 192 |
(...skipping 19 matching lines...) Expand all Loading... |
207 void LayoutGeometryMap::pushMappingsToAncestor( | 212 void LayoutGeometryMap::pushMappingsToAncestor( |
208 const PaintLayer* layer, | 213 const PaintLayer* layer, |
209 const PaintLayer* ancestorLayer) { | 214 const PaintLayer* ancestorLayer) { |
210 const LayoutObject* layoutObject = layer->layoutObject(); | 215 const LayoutObject* layoutObject = layer->layoutObject(); |
211 | 216 |
212 bool crossDocument = | 217 bool crossDocument = |
213 ancestorLayer && | 218 ancestorLayer && |
214 layer->layoutObject()->frame() != ancestorLayer->layoutObject()->frame(); | 219 layer->layoutObject()->frame() != ancestorLayer->layoutObject()->frame(); |
215 ASSERT(!crossDocument || m_mapCoordinatesFlags & TraverseDocumentBoundaries); | 220 ASSERT(!crossDocument || m_mapCoordinatesFlags & TraverseDocumentBoundaries); |
216 | 221 |
217 // We have to visit all the layoutObjects to detect flipped blocks. This might
defeat the gains | 222 // We have to visit all the layoutObjects to detect flipped blocks. This might |
218 // from mapping via layers. | 223 // defeat the gains from mapping via layers. |
219 bool canConvertInLayerTree = | 224 bool canConvertInLayerTree = |
220 (ancestorLayer && !crossDocument) | 225 (ancestorLayer && !crossDocument) |
221 ? canMapBetweenLayoutObjects(layer->layoutObject(), | 226 ? canMapBetweenLayoutObjects(layer->layoutObject(), |
222 ancestorLayer->layoutObject()) | 227 ancestorLayer->layoutObject()) |
223 : false; | 228 : false; |
224 | 229 |
225 LAYOUT_GEOMETRY_MAP_LOG( | 230 LAYOUT_GEOMETRY_MAP_LOG( |
226 "LayoutGeometryMap::pushMappingsToAncestor from layer %p to layer %p, " | 231 "LayoutGeometryMap::pushMappingsToAncestor from layer %p to layer %p, " |
227 "canConvertInLayerTree=%d\n", | 232 "canConvertInLayerTree=%d\n", |
228 layer, ancestorLayer, canConvertInLayerTree); | 233 layer, ancestorLayer, canConvertInLayerTree); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 // If we're not working with multiple LayoutViews, then any view is considered | 369 // If we're not working with multiple LayoutViews, then any view is considered |
365 // "topmost" (to preserve original behavior). | 370 // "topmost" (to preserve original behavior). |
366 if (!(m_mapCoordinatesFlags & TraverseDocumentBoundaries)) | 371 if (!(m_mapCoordinatesFlags & TraverseDocumentBoundaries)) |
367 return true; | 372 return true; |
368 | 373 |
369 return layoutObject->frame()->isMainFrame(); | 374 return layoutObject->frame()->isMainFrame(); |
370 } | 375 } |
371 #endif | 376 #endif |
372 | 377 |
373 } // namespace blink | 378 } // namespace blink |
OLD | NEW |