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, and it's |
| 1213 // applicable only for SPv1 paint invalidation use cases when the slow-path |
| 1214 // is used to map visual rect/location. |
| 1215 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled() && |
| 1216 !StyleRef().Preserves3D()) { |
| 1217 transform_state.Flatten(); |
| 1218 transform_state.SetQuad( |
| 1219 FloatQuad(transform_state.LastPlanarQuad().EnclosingBoundingBox())); |
| 1220 } |
| 1221 |
| 1222 // 2. Generate transformation matrix. |
| 1223 // a) Transform. |
1208 TransformationMatrix transform; | 1224 TransformationMatrix transform; |
1209 if (Layer() && Layer()->Transform()) | 1225 if (Layer() && Layer()->Transform()) |
1210 transform.Multiply(Layer()->CurrentTransform()); | 1226 transform.Multiply(Layer()->CurrentTransform()); |
1211 | 1227 |
1212 // 2. Container offset. | 1228 // b) Container offset. |
1213 transform.PostTranslate(container_offset.X().ToFloat(), | 1229 transform.PostTranslate(container_offset.X().ToFloat(), |
1214 container_offset.Y().ToFloat()); | 1230 container_offset.Y().ToFloat()); |
1215 | 1231 |
1216 // 3. Container scroll offset. | 1232 // c) Container scroll offset. |
1217 if (container_object->IsBox() && container_object != ancestor && | 1233 if (container_object->IsBox() && container_object != ancestor && |
1218 container_object->HasOverflowClip()) { | 1234 container_object->HasOverflowClip()) { |
1219 IntSize offset = -ToLayoutBox(container_object)->ScrolledContentOffset(); | 1235 IntSize offset = -ToLayoutBox(container_object)->ScrolledContentOffset(); |
1220 transform.PostTranslate(offset.Width(), offset.Height()); | 1236 transform.PostTranslate(offset.Width(), offset.Height()); |
1221 } | 1237 } |
1222 | 1238 |
1223 // 4. Perspective applied by container. | 1239 // d) Perspective applied by container. |
1224 if (container_object && container_object->HasLayer() && | 1240 if (container_object && container_object->HasLayer() && |
1225 container_object->Style()->HasPerspective()) { | 1241 container_object->Style()->HasPerspective()) { |
1226 // Perspective on the container affects us, so we have to factor it in here. | 1242 // Perspective on the container affects us, so we have to factor it in here. |
1227 DCHECK(container_object->HasLayer()); | 1243 DCHECK(container_object->HasLayer()); |
1228 FloatPoint perspective_origin = | 1244 FloatPoint perspective_origin = |
1229 ToLayoutBoxModelObject(container_object)->Layer()->PerspectiveOrigin(); | 1245 ToLayoutBoxModelObject(container_object)->Layer()->PerspectiveOrigin(); |
1230 | 1246 |
1231 TransformationMatrix perspective_matrix; | 1247 TransformationMatrix perspective_matrix; |
1232 perspective_matrix.ApplyPerspective( | 1248 perspective_matrix.ApplyPerspective( |
1233 container_object->Style()->Perspective()); | 1249 container_object->Style()->Perspective()); |
1234 perspective_matrix.ApplyTransformOrigin(perspective_origin.X(), | 1250 perspective_matrix.ApplyTransformOrigin(perspective_origin.X(), |
1235 perspective_origin.Y(), 0); | 1251 perspective_origin.Y(), 0); |
1236 | 1252 |
1237 transform = perspective_matrix * transform; | 1253 transform = perspective_matrix * transform; |
1238 } | 1254 } |
1239 | 1255 |
1240 // 5. Transform flattening. | 1256 // 3. Apply transform and flatten. |
1241 transform_state.ApplyTransform(transform, accumulation); | 1257 transform_state.ApplyTransform(transform, accumulation); |
| 1258 if (!container_preserve_3d) |
| 1259 transform_state.Flatten(); |
1242 | 1260 |
1243 // 6. Expansion for pixel snapping. | 1261 // 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 && | 1262 if (container_object->IsBox() && container_object != ancestor && |
1256 container_object->HasClipRelatedProperty()) { | 1263 container_object->HasClipRelatedProperty()) { |
1257 return ToLayoutBox(container_object) | 1264 return ToLayoutBox(container_object) |
1258 ->ApplyBoxClips(transform_state, accumulation, visual_rect_flags); | 1265 ->ApplyBoxClips(transform_state, accumulation, visual_rect_flags); |
1259 } | 1266 } |
1260 | 1267 |
1261 return true; | 1268 return true; |
1262 } | 1269 } |
1263 | 1270 |
1264 bool LayoutBox::MapScrollingContentsRectToBoxSpace( | 1271 bool LayoutBox::MapScrollingContentsRectToBoxSpace( |
(...skipping 4635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5900 void LayoutBox::MutableForPainting:: | 5907 void LayoutBox::MutableForPainting:: |
5901 SavePreviousContentBoxSizeAndLayoutOverflowRect() { | 5908 SavePreviousContentBoxSizeAndLayoutOverflowRect() { |
5902 auto& rare_data = GetLayoutBox().EnsureRareData(); | 5909 auto& rare_data = GetLayoutBox().EnsureRareData(); |
5903 rare_data.has_previous_content_box_size_and_layout_overflow_rect_ = true; | 5910 rare_data.has_previous_content_box_size_and_layout_overflow_rect_ = true; |
5904 rare_data.previous_content_box_size_ = GetLayoutBox().ContentBoxRect().Size(); | 5911 rare_data.previous_content_box_size_ = GetLayoutBox().ContentBoxRect().Size(); |
5905 rare_data.previous_layout_overflow_rect_ = | 5912 rare_data.previous_layout_overflow_rect_ = |
5906 GetLayoutBox().LayoutOverflowRect(); | 5913 GetLayoutBox().LayoutOverflowRect(); |
5907 } | 5914 } |
5908 | 5915 |
5909 } // namespace blink | 5916 } // namespace blink |
OLD | NEW |