Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
| 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) |
| 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. | 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. |
| 7 * All rights reserved. | 7 * All rights reserved. |
| 8 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 8 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
| 9 * | 9 * |
| 10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| (...skipping 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1170 | 1170 |
| 1171 return result; | 1171 return result; |
| 1172 } | 1172 } |
| 1173 | 1173 |
| 1174 bool LayoutBox::MapVisualRectToContainer( | 1174 bool LayoutBox::MapVisualRectToContainer( |
| 1175 const LayoutObject* container_object, | 1175 const LayoutObject* container_object, |
| 1176 const LayoutPoint& container_offset, | 1176 const LayoutPoint& container_offset, |
| 1177 const LayoutObject* ancestor, | 1177 const LayoutObject* ancestor, |
| 1178 VisualRectFlags visual_rect_flags, | 1178 VisualRectFlags visual_rect_flags, |
| 1179 TransformState& transform_state) const { | 1179 TransformState& transform_state) const { |
| 1180 bool preserve3D = container_object->Style()->Preserves3D(); | 1180 bool container_preserve_3d = container_object->Style()->Preserves3D(); |
| 1181 | 1181 |
| 1182 TransformState::TransformAccumulation accumulation = | 1182 TransformState::TransformAccumulation accumulation = |
| 1183 preserve3D ? TransformState::kAccumulateTransform | 1183 container_preserve_3d ? TransformState::kAccumulateTransform |
| 1184 : TransformState::kFlattenTransform; | 1184 : TransformState::kFlattenTransform; |
| 1185 | 1185 |
| 1186 // If there is no transform on this box, adjust for container offset and | 1186 // If there is no transform on this box, adjust for container offset and |
| 1187 // container scrolling, then apply container clip. | 1187 // container scrolling, then apply container clip. |
| 1188 if (!ShouldUseTransformFromContainer(container_object)) { | 1188 if (!ShouldUseTransformFromContainer(container_object)) { |
| 1189 transform_state.MoveBy(container_offset, accumulation); | 1189 transform_state.MoveBy(container_offset, accumulation); |
| 1190 if (container_object->IsBox() && container_object != ancestor && | 1190 if (container_object->IsBox() && container_object != ancestor && |
| 1191 !ToLayoutBox(container_object) | 1191 !ToLayoutBox(container_object) |
| 1192 ->MapScrollingContentsRectToBoxSpace(transform_state, accumulation, | 1192 ->MapScrollingContentsRectToBoxSpace(transform_state, accumulation, |
| 1193 visual_rect_flags)) | 1193 visual_rect_flags)) |
| 1194 return false; | 1194 return false; |
| 1195 return true; | 1195 return true; |
| 1196 } | 1196 } |
| 1197 | 1197 |
| 1198 // Otherwise, apply the following: | 1198 // Otherwise, do the following: |
| 1199 // 1. Transform. | 1199 // 1. Expand for pixel snapping. |
| 1200 // 2. Container offset. | 1200 // 2. Generate transformation matrix combining, in this order |
| 1201 // 3. Container scroll offset. | 1201 // a) transform, |
| 1202 // 4. Perspective applied by container. | 1202 // b) container offset, |
| 1203 // 5. Transform flattening. | 1203 // c) container scroll offset, |
| 1204 // 6. Expansion for pixel snapping. | 1204 // d) perspective applied by container. |
| 1205 // 7. Container clip. | 1205 // 3. Apply transform Transform+flattening. |
| 1206 // 4. Apply container clip. | |
| 1206 | 1207 |
| 1207 // 1. Transform. | 1208 // 1. Expand for pixel snapping. |
| 1209 // Use EnclosingBoundingBox because we cannot properly compute pixel | |
| 1210 // snapping for painted elements within the transform since we don't know | |
| 1211 // the desired subpixel accumulation at this point, and the transform may | |
| 1212 // include a scale. This only makes sense for non-preserve3D. | |
| 1213 if (!StyleRef().Preserves3D()) { | |
|
chrishtr
2017/05/05 16:04:44
Why remove the SPv2 condition here?
Xianzhu
2017/05/05 16:14:51
MapToVisualRectInAncestorSpace() is still used on
Xianzhu
2017/05/05 16:16:02
Correction: with width and height of the inner div
chrishtr
2017/05/05 16:17:19
Ah, right. Ok.
| |
| 1214 transform_state.Flatten(); | |
| 1215 transform_state.SetQuad( | |
| 1216 FloatQuad(transform_state.LastPlanarQuad().EnclosingBoundingBox())); | |
| 1217 } | |
| 1218 | |
| 1219 // 2. Generate transformation matrix. | |
| 1220 // a) Transform. | |
| 1208 TransformationMatrix transform; | 1221 TransformationMatrix transform; |
| 1209 if (Layer() && Layer()->Transform()) | 1222 if (Layer() && Layer()->Transform()) |
| 1210 transform.Multiply(Layer()->CurrentTransform()); | 1223 transform.Multiply(Layer()->CurrentTransform()); |
| 1211 | 1224 |
| 1212 // 2. Container offset. | 1225 // b) Container offset. |
| 1213 transform.PostTranslate(container_offset.X().ToFloat(), | 1226 transform.PostTranslate(container_offset.X().ToFloat(), |
| 1214 container_offset.Y().ToFloat()); | 1227 container_offset.Y().ToFloat()); |
| 1215 | 1228 |
| 1216 // 3. Container scroll offset. | 1229 // c) Container scroll offset. |
| 1217 if (container_object->IsBox() && container_object != ancestor && | 1230 if (container_object->IsBox() && container_object != ancestor && |
| 1218 container_object->HasOverflowClip()) { | 1231 container_object->HasOverflowClip()) { |
| 1219 IntSize offset = -ToLayoutBox(container_object)->ScrolledContentOffset(); | 1232 IntSize offset = -ToLayoutBox(container_object)->ScrolledContentOffset(); |
| 1220 transform.PostTranslate(offset.Width(), offset.Height()); | 1233 transform.PostTranslate(offset.Width(), offset.Height()); |
| 1221 } | 1234 } |
| 1222 | 1235 |
| 1223 // 4. Perspective applied by container. | 1236 // d) Perspective applied by container. |
| 1224 if (container_object && container_object->HasLayer() && | 1237 if (container_object && container_object->HasLayer() && |
| 1225 container_object->Style()->HasPerspective()) { | 1238 container_object->Style()->HasPerspective()) { |
| 1226 // Perspective on the container affects us, so we have to factor it in here. | 1239 // Perspective on the container affects us, so we have to factor it in here. |
| 1227 DCHECK(container_object->HasLayer()); | 1240 DCHECK(container_object->HasLayer()); |
| 1228 FloatPoint perspective_origin = | 1241 FloatPoint perspective_origin = |
| 1229 ToLayoutBoxModelObject(container_object)->Layer()->PerspectiveOrigin(); | 1242 ToLayoutBoxModelObject(container_object)->Layer()->PerspectiveOrigin(); |
| 1230 | 1243 |
| 1231 TransformationMatrix perspective_matrix; | 1244 TransformationMatrix perspective_matrix; |
| 1232 perspective_matrix.ApplyPerspective( | 1245 perspective_matrix.ApplyPerspective( |
| 1233 container_object->Style()->Perspective()); | 1246 container_object->Style()->Perspective()); |
| 1234 perspective_matrix.ApplyTransformOrigin(perspective_origin.X(), | 1247 perspective_matrix.ApplyTransformOrigin(perspective_origin.X(), |
| 1235 perspective_origin.Y(), 0); | 1248 perspective_origin.Y(), 0); |
| 1236 | 1249 |
| 1237 transform = perspective_matrix * transform; | 1250 transform = perspective_matrix * transform; |
| 1238 } | 1251 } |
| 1239 | 1252 |
| 1240 // 5. Transform flattening. | 1253 // 3. Apply transform and flatten. |
| 1241 transform_state.ApplyTransform(transform, accumulation); | 1254 transform_state.ApplyTransform(transform, accumulation); |
| 1255 if (!container_preserve_3d) | |
| 1256 transform_state.Flatten(); | |
| 1242 | 1257 |
| 1243 // 6. Expansion for pixel snapping. | 1258 // 4. Apply container clip. |
| 1244 // Use enclosingBoundingBox because we cannot properly compute pixel | |
| 1245 // snapping for painted elements within the transform since we don't know | |
| 1246 // the desired subpixel accumulation at this point, and the transform may | |
| 1247 // include a scale. | |
| 1248 if (!preserve3D) { | |
| 1249 transform_state.Flatten(); | |
| 1250 transform_state.SetQuad( | |
| 1251 FloatQuad(transform_state.LastPlanarQuad().EnclosingBoundingBox())); | |
| 1252 } | |
| 1253 | |
| 1254 // 7. Container clip. | |
| 1255 if (container_object->IsBox() && container_object != ancestor && | 1259 if (container_object->IsBox() && container_object != ancestor && |
| 1256 container_object->HasClipRelatedProperty()) { | 1260 container_object->HasClipRelatedProperty()) { |
| 1257 return ToLayoutBox(container_object) | 1261 return ToLayoutBox(container_object) |
| 1258 ->ApplyBoxClips(transform_state, accumulation, visual_rect_flags); | 1262 ->ApplyBoxClips(transform_state, accumulation, visual_rect_flags); |
| 1259 } | 1263 } |
| 1260 | 1264 |
| 1261 return true; | 1265 return true; |
| 1262 } | 1266 } |
| 1263 | 1267 |
| 1264 bool LayoutBox::MapScrollingContentsRectToBoxSpace( | 1268 bool LayoutBox::MapScrollingContentsRectToBoxSpace( |
| (...skipping 4635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5900 void LayoutBox::MutableForPainting:: | 5904 void LayoutBox::MutableForPainting:: |
| 5901 SavePreviousContentBoxSizeAndLayoutOverflowRect() { | 5905 SavePreviousContentBoxSizeAndLayoutOverflowRect() { |
| 5902 auto& rare_data = GetLayoutBox().EnsureRareData(); | 5906 auto& rare_data = GetLayoutBox().EnsureRareData(); |
| 5903 rare_data.has_previous_content_box_size_and_layout_overflow_rect_ = true; | 5907 rare_data.has_previous_content_box_size_and_layout_overflow_rect_ = true; |
| 5904 rare_data.previous_content_box_size_ = GetLayoutBox().ContentBoxRect().Size(); | 5908 rare_data.previous_content_box_size_ = GetLayoutBox().ContentBoxRect().Size(); |
| 5905 rare_data.previous_layout_overflow_rect_ = | 5909 rare_data.previous_layout_overflow_rect_ = |
| 5906 GetLayoutBox().LayoutOverflowRect(); | 5910 GetLayoutBox().LayoutOverflowRect(); |
| 5907 } | 5911 } |
| 5908 | 5912 |
| 5909 } // namespace blink | 5913 } // namespace blink |
| OLD | NEW |