| 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 29 matching lines...) Expand all Loading... |
| 40 , m_transformedStepsCount(0) | 40 , m_transformedStepsCount(0) |
| 41 , m_fixedStepsCount(0) | 41 , m_fixedStepsCount(0) |
| 42 , m_mapCoordinatesFlags(flags) | 42 , m_mapCoordinatesFlags(flags) |
| 43 { | 43 { |
| 44 } | 44 } |
| 45 | 45 |
| 46 LayoutGeometryMap::~LayoutGeometryMap() | 46 LayoutGeometryMap::~LayoutGeometryMap() |
| 47 { | 47 { |
| 48 } | 48 } |
| 49 | 49 |
| 50 void LayoutGeometryMap::mapToContainer(TransformState& transformState, const Lay
outLayerModelObject* container) const | 50 void LayoutGeometryMap::mapToContainer(TransformState& transformState, const Ren
derBoxModelObject* container) const |
| 51 { | 51 { |
| 52 // If the mapping includes something like columns, we have to go via rendere
rs. | 52 // If the mapping includes something like columns, we have to go via rendere
rs. |
| 53 if (hasNonUniformStep()) { | 53 if (hasNonUniformStep()) { |
| 54 m_mapping.last().m_renderer->mapLocalToContainer(container, transformSta
te, ApplyContainerFlip | m_mapCoordinatesFlags); | 54 m_mapping.last().m_renderer->mapLocalToContainer(container, transformSta
te, ApplyContainerFlip | m_mapCoordinatesFlags); |
| 55 transformState.flatten(); | 55 transformState.flatten(); |
| 56 return; | 56 return; |
| 57 } | 57 } |
| 58 | 58 |
| 59 bool inFixed = false; | 59 bool inFixed = false; |
| 60 #if ENABLE(ASSERT) | 60 #if ENABLE(ASSERT) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 if (inFixed && !currentStep.m_offsetForFixedPosition.isZero()) { | 97 if (inFixed && !currentStep.m_offsetForFixedPosition.isZero()) { |
| 98 ASSERT(currentStep.m_renderer->isRenderView()); | 98 ASSERT(currentStep.m_renderer->isRenderView()); |
| 99 transformState.move(currentStep.m_offsetForFixedPosition); | 99 transformState.move(currentStep.m_offsetForFixedPosition); |
| 100 } | 100 } |
| 101 } | 101 } |
| 102 | 102 |
| 103 ASSERT(foundContainer); | 103 ASSERT(foundContainer); |
| 104 transformState.flatten(); | 104 transformState.flatten(); |
| 105 } | 105 } |
| 106 | 106 |
| 107 FloatPoint LayoutGeometryMap::mapToContainer(const FloatPoint& p, const LayoutLa
yerModelObject* container) const | 107 FloatPoint LayoutGeometryMap::mapToContainer(const FloatPoint& p, const RenderBo
xModelObject* container) const |
| 108 { | 108 { |
| 109 FloatPoint result; | 109 FloatPoint result; |
| 110 | 110 |
| 111 if (!hasFixedPositionStep() && !hasTransformStep() && !hasNonUniformStep() &
& (!container || (m_mapping.size() && container == m_mapping[0].m_renderer))) { | 111 if (!hasFixedPositionStep() && !hasTransformStep() && !hasNonUniformStep() &
& (!container || (m_mapping.size() && container == m_mapping[0].m_renderer))) { |
| 112 result = p + m_accumulatedOffset; | 112 result = p + m_accumulatedOffset; |
| 113 } else { | 113 } else { |
| 114 TransformState transformState(TransformState::ApplyTransformDirection, p
); | 114 TransformState transformState(TransformState::ApplyTransformDirection, p
); |
| 115 mapToContainer(transformState, container); | 115 mapToContainer(transformState, container); |
| 116 result = transformState.lastPlanarPoint(); | 116 result = transformState.lastPlanarPoint(); |
| 117 } | 117 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 142 fprintf(stderr, "LayoutGeometryMap::dumpSteps accumulatedOffset=%d,%d\n", m_
accumulatedOffset.width().toInt(), m_accumulatedOffset.height().toInt()); | 142 fprintf(stderr, "LayoutGeometryMap::dumpSteps accumulatedOffset=%d,%d\n", m_
accumulatedOffset.width().toInt(), m_accumulatedOffset.height().toInt()); |
| 143 for (int i = m_mapping.size() - 1; i >= 0; --i) { | 143 for (int i = m_mapping.size() - 1; i >= 0; --i) { |
| 144 fprintf(stderr, " [%d] %s: offset=%d,%d", i, m_mapping[i].m_renderer->de
bugName().ascii().data(), m_mapping[i].m_offset.width().toInt(), m_mapping[i].m_
offset.height().toInt()); | 144 fprintf(stderr, " [%d] %s: offset=%d,%d", i, m_mapping[i].m_renderer->de
bugName().ascii().data(), m_mapping[i].m_offset.width().toInt(), m_mapping[i].m_
offset.height().toInt()); |
| 145 if (m_mapping[i].m_hasTransform) | 145 if (m_mapping[i].m_hasTransform) |
| 146 fprintf(stderr, " hasTransform"); | 146 fprintf(stderr, " hasTransform"); |
| 147 fprintf(stderr, "\n"); | 147 fprintf(stderr, "\n"); |
| 148 } | 148 } |
| 149 } | 149 } |
| 150 #endif | 150 #endif |
| 151 | 151 |
| 152 FloatQuad LayoutGeometryMap::mapToContainer(const FloatRect& rect, const LayoutL
ayerModelObject* container) const | 152 FloatQuad LayoutGeometryMap::mapToContainer(const FloatRect& rect, const RenderB
oxModelObject* container) const |
| 153 { | 153 { |
| 154 FloatQuad result; | 154 FloatQuad result; |
| 155 | 155 |
| 156 if (!hasFixedPositionStep() && !hasTransformStep() && !hasNonUniformStep() &
& (!container || (m_mapping.size() && container == m_mapping[0].m_renderer))) { | 156 if (!hasFixedPositionStep() && !hasTransformStep() && !hasNonUniformStep() &
& (!container || (m_mapping.size() && container == m_mapping[0].m_renderer))) { |
| 157 result = rect; | 157 result = rect; |
| 158 result.move(m_accumulatedOffset); | 158 result.move(m_accumulatedOffset); |
| 159 } else { | 159 } else { |
| 160 TransformState transformState(TransformState::ApplyTransformDirection, r
ect.center(), rect); | 160 TransformState transformState(TransformState::ApplyTransformDirection, r
ect.center(), rect); |
| 161 mapToContainer(transformState, container); | 161 mapToContainer(transformState, container); |
| 162 result = transformState.lastPlanarQuad(); | 162 result = transformState.lastPlanarQuad(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 176 // Inspector creates renderers with negative width <https://bugs.web
kit.org/show_bug.cgi?id=87194>. | 176 // Inspector creates renderers with negative width <https://bugs.web
kit.org/show_bug.cgi?id=87194>. |
| 177 // Taking FloatQuad bounds avoids spurious assertions because of tha
t. | 177 // Taking FloatQuad bounds avoids spurious assertions because of tha
t. |
| 178 ASSERT(enclosingIntRect(rendererMappedResult) == enclosingIntRect(re
sult.boundingBox())); | 178 ASSERT(enclosingIntRect(rendererMappedResult) == enclosingIntRect(re
sult.boundingBox())); |
| 179 } | 179 } |
| 180 } | 180 } |
| 181 #endif | 181 #endif |
| 182 | 182 |
| 183 return result; | 183 return result; |
| 184 } | 184 } |
| 185 | 185 |
| 186 void LayoutGeometryMap::pushMappingsToAncestor(const LayoutObject* renderer, con
st LayoutLayerModelObject* ancestorRenderer) | 186 void LayoutGeometryMap::pushMappingsToAncestor(const LayoutObject* renderer, con
st RenderBoxModelObject* ancestorRenderer) |
| 187 { | 187 { |
| 188 // We need to push mappings in reverse order here, so do insertions rather t
han appends. | 188 // We need to push mappings in reverse order here, so do insertions rather t
han appends. |
| 189 TemporaryChange<size_t> positionChange(m_insertionPosition, m_mapping.size()
); | 189 TemporaryChange<size_t> positionChange(m_insertionPosition, m_mapping.size()
); |
| 190 do { | 190 do { |
| 191 renderer = renderer->pushMappingToContainer(ancestorRenderer, *this); | 191 renderer = renderer->pushMappingToContainer(ancestorRenderer, *this); |
| 192 } while (renderer && renderer != ancestorRenderer); | 192 } while (renderer && renderer != ancestorRenderer); |
| 193 | 193 |
| 194 ASSERT(m_mapping.isEmpty() || isTopmostRenderView(m_mapping[0].m_renderer)); | 194 ASSERT(m_mapping.isEmpty() || isTopmostRenderView(m_mapping[0].m_renderer)); |
| 195 } | 195 } |
| 196 | 196 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 if (!m_mapping.size()) { | 232 if (!m_mapping.size()) { |
| 233 ASSERT(ancestorLayer->renderer()->isRenderView()); | 233 ASSERT(ancestorLayer->renderer()->isRenderView()); |
| 234 pushMappingsToAncestor(ancestorLayer->renderer(), 0); | 234 pushMappingsToAncestor(ancestorLayer->renderer(), 0); |
| 235 } | 235 } |
| 236 | 236 |
| 237 TemporaryChange<size_t> positionChange(m_insertionPosition, m_mapping.si
ze()); | 237 TemporaryChange<size_t> positionChange(m_insertionPosition, m_mapping.si
ze()); |
| 238 bool accumulatingTransform = layer->renderer()->style()->preserves3D() |
| ancestorLayer->renderer()->style()->preserves3D(); | 238 bool accumulatingTransform = layer->renderer()->style()->preserves3D() |
| ancestorLayer->renderer()->style()->preserves3D(); |
| 239 push(renderer, toLayoutSize(layerOffset), accumulatingTransform, /*isNon
Uniform*/ false, /*isFixedPosition*/ false, /*hasTransform*/ false); | 239 push(renderer, toLayoutSize(layerOffset), accumulatingTransform, /*isNon
Uniform*/ false, /*isFixedPosition*/ false, /*hasTransform*/ false); |
| 240 return; | 240 return; |
| 241 } | 241 } |
| 242 const LayoutLayerModelObject* ancestorRenderer = ancestorLayer ? ancestorLay
er->renderer() : 0; | 242 const RenderBoxModelObject* ancestorRenderer = ancestorLayer ? ancestorLayer
->renderer() : 0; |
| 243 pushMappingsToAncestor(renderer, ancestorRenderer); | 243 pushMappingsToAncestor(renderer, ancestorRenderer); |
| 244 } | 244 } |
| 245 | 245 |
| 246 void LayoutGeometryMap::push(const LayoutObject* renderer, const LayoutSize& off
setFromContainer, bool accumulatingTransform, bool isNonUniform, bool isFixedPos
ition, bool hasTransform, LayoutSize offsetForFixedPosition) | 246 void LayoutGeometryMap::push(const LayoutObject* renderer, const LayoutSize& off
setFromContainer, bool accumulatingTransform, bool isNonUniform, bool isFixedPos
ition, bool hasTransform, LayoutSize offsetForFixedPosition) |
| 247 { | 247 { |
| 248 // fprintf(stderr, "LayoutGeometryMap::push %p %d,%d isNonUniform=%d\n", rend
erer, offsetFromContainer.width().toInt(), offsetFromContainer.height().toInt(),
isNonUniform); | 248 // fprintf(stderr, "LayoutGeometryMap::push %p %d,%d isNonUniform=%d\n", rend
erer, offsetFromContainer.width().toInt(), offsetFromContainer.height().toInt(),
isNonUniform); |
| 249 | 249 |
| 250 ASSERT(m_insertionPosition != kNotFound); | 250 ASSERT(m_insertionPosition != kNotFound); |
| 251 ASSERT(!renderer->isRenderView() || !m_insertionPosition || m_mapCoordinates
Flags & TraverseDocumentBoundaries); | 251 ASSERT(!renderer->isRenderView() || !m_insertionPosition || m_mapCoordinates
Flags & TraverseDocumentBoundaries); |
| 252 ASSERT(offsetForFixedPosition.isZero() || renderer->isRenderView()); | 252 ASSERT(offsetForFixedPosition.isZero() || renderer->isRenderView()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 272 step.m_offsetForFixedPosition = offsetForFixedPosition; | 272 step.m_offsetForFixedPosition = offsetForFixedPosition; |
| 273 | 273 |
| 274 if (!t.isIntegerTranslation()) | 274 if (!t.isIntegerTranslation()) |
| 275 step.m_transform = adoptPtr(new TransformationMatrix(t)); | 275 step.m_transform = adoptPtr(new TransformationMatrix(t)); |
| 276 else | 276 else |
| 277 step.m_offset = LayoutSize(t.e(), t.f()); | 277 step.m_offset = LayoutSize(t.e(), t.f()); |
| 278 | 278 |
| 279 stepInserted(step); | 279 stepInserted(step); |
| 280 } | 280 } |
| 281 | 281 |
| 282 void LayoutGeometryMap::popMappingsToAncestor(const LayoutLayerModelObject* ance
storRenderer) | 282 void LayoutGeometryMap::popMappingsToAncestor(const RenderBoxModelObject* ancest
orRenderer) |
| 283 { | 283 { |
| 284 ASSERT(m_mapping.size()); | 284 ASSERT(m_mapping.size()); |
| 285 | 285 |
| 286 while (m_mapping.size() && m_mapping.last().m_renderer != ancestorRenderer)
{ | 286 while (m_mapping.size() && m_mapping.last().m_renderer != ancestorRenderer)
{ |
| 287 stepRemoved(m_mapping.last()); | 287 stepRemoved(m_mapping.last()); |
| 288 m_mapping.removeLast(); | 288 m_mapping.removeLast(); |
| 289 } | 289 } |
| 290 } | 290 } |
| 291 | 291 |
| 292 void LayoutGeometryMap::popMappingsToAncestor(const Layer* ancestorLayer) | 292 void LayoutGeometryMap::popMappingsToAncestor(const Layer* ancestorLayer) |
| 293 { | 293 { |
| 294 const LayoutLayerModelObject* ancestorRenderer = ancestorLayer ? ancestorLay
er->renderer() : 0; | 294 const RenderBoxModelObject* ancestorRenderer = ancestorLayer ? ancestorLayer
->renderer() : 0; |
| 295 popMappingsToAncestor(ancestorRenderer); | 295 popMappingsToAncestor(ancestorRenderer); |
| 296 } | 296 } |
| 297 | 297 |
| 298 void LayoutGeometryMap::stepInserted(const LayoutGeometryMapStep& step) | 298 void LayoutGeometryMap::stepInserted(const LayoutGeometryMapStep& step) |
| 299 { | 299 { |
| 300 m_accumulatedOffset += step.m_offset; | 300 m_accumulatedOffset += step.m_offset; |
| 301 | 301 |
| 302 if (step.m_isNonUniform) | 302 if (step.m_isNonUniform) |
| 303 ++m_nonUniformStepsCount; | 303 ++m_nonUniformStepsCount; |
| 304 | 304 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 // If we're not working with multiple RenderViews, then any view is consider
ed | 338 // If we're not working with multiple RenderViews, then any view is consider
ed |
| 339 // "topmost" (to preserve original behavior). | 339 // "topmost" (to preserve original behavior). |
| 340 if (!(m_mapCoordinatesFlags & TraverseDocumentBoundaries)) | 340 if (!(m_mapCoordinatesFlags & TraverseDocumentBoundaries)) |
| 341 return true; | 341 return true; |
| 342 | 342 |
| 343 return renderer->frame()->isMainFrame(); | 343 return renderer->frame()->isMainFrame(); |
| 344 } | 344 } |
| 345 #endif | 345 #endif |
| 346 | 346 |
| 347 } // namespace blink | 347 } // namespace blink |
| OLD | NEW |