| 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 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1167 | 1167 |
| 1168 return result; | 1168 return result; |
| 1169 } | 1169 } |
| 1170 | 1170 |
| 1171 bool LayoutBox::MapVisualRectToContainer( | 1171 bool LayoutBox::MapVisualRectToContainer( |
| 1172 const LayoutObject* container_object, | 1172 const LayoutObject* container_object, |
| 1173 const LayoutPoint& container_offset, | 1173 const LayoutPoint& container_offset, |
| 1174 const LayoutObject* ancestor, | 1174 const LayoutObject* ancestor, |
| 1175 VisualRectFlags visual_rect_flags, | 1175 VisualRectFlags visual_rect_flags, |
| 1176 TransformState& transform_state) const { | 1176 TransformState& transform_state) const { |
| 1177 bool preserve3D = container_object->Style()->Preserves3D(); | 1177 bool container_preserve_3d = container_object->Style()->Preserves3D(); |
| 1178 | 1178 |
| 1179 TransformState::TransformAccumulation accumulation = | 1179 TransformState::TransformAccumulation accumulation = |
| 1180 preserve3D ? TransformState::kAccumulateTransform | 1180 container_preserve_3d ? TransformState::kAccumulateTransform |
| 1181 : TransformState::kFlattenTransform; | 1181 : TransformState::kFlattenTransform; |
| 1182 | 1182 |
| 1183 // If there is no transform on this box, adjust for container offset and | 1183 // If there is no transform on this box, adjust for container offset and |
| 1184 // container scrolling, then apply container clip. | 1184 // container scrolling, then apply container clip. |
| 1185 if (!ShouldUseTransformFromContainer(container_object)) { | 1185 if (!ShouldUseTransformFromContainer(container_object)) { |
| 1186 transform_state.MoveBy(container_offset, accumulation); | 1186 transform_state.MoveBy(container_offset, accumulation); |
| 1187 if (container_object->IsBox() && container_object != ancestor && | 1187 if (container_object->IsBox() && container_object != ancestor && |
| 1188 !ToLayoutBox(container_object) | 1188 !ToLayoutBox(container_object) |
| 1189 ->MapScrollingContentsRectToBoxSpace(transform_state, accumulation, | 1189 ->MapScrollingContentsRectToBoxSpace(transform_state, accumulation, |
| 1190 visual_rect_flags)) | 1190 visual_rect_flags)) |
| 1191 return false; | 1191 return false; |
| 1192 return true; | 1192 return true; |
| 1193 } | 1193 } |
| 1194 | 1194 |
| 1195 // Otherwise, apply the following: | 1195 // Otherwise, do the following: |
| 1196 // 1. Transform. | 1196 // 1. Expand for pixel snapping. |
| 1197 // 2. Container offset. | 1197 // 2. Generate transformation matrix combining, in this order |
| 1198 // 3. Container scroll offset. | 1198 // a) transform, |
| 1199 // 4. Perspective applied by container. | 1199 // b) container offset, |
| 1200 // 5. Transform flattening. | 1200 // c) container scroll offset, |
| 1201 // 6. Expansion for pixel snapping. | 1201 // d) perspective applied by container. |
| 1202 // 7. Container clip. | 1202 // 3. Apply transform Transform+flattening. |
| 1203 // 4. Apply container clip. |
| 1203 | 1204 |
| 1204 // 1. Transform. | 1205 // 1. Expand for pixel snapping. |
| 1206 // Use EnclosingBoundingBox because we cannot properly compute pixel |
| 1207 // snapping for painted elements within the transform since we don't know |
| 1208 // the desired subpixel accumulation at this point, and the transform may |
| 1209 // include a scale. This only makes sense for non-preserve3D. |
| 1210 if (!StyleRef().Preserves3D()) { |
| 1211 transform_state.Flatten(); |
| 1212 transform_state.SetQuad( |
| 1213 FloatQuad(transform_state.LastPlanarQuad().EnclosingBoundingBox())); |
| 1214 } |
| 1215 |
| 1216 // 2. Generate transformation matrix. |
| 1217 // a) Transform. |
| 1205 TransformationMatrix transform; | 1218 TransformationMatrix transform; |
| 1206 if (Layer() && Layer()->Transform()) | 1219 if (Layer() && Layer()->Transform()) |
| 1207 transform.Multiply(Layer()->CurrentTransform()); | 1220 transform.Multiply(Layer()->CurrentTransform()); |
| 1208 | 1221 |
| 1209 // 2. Container offset. | 1222 // b) Container offset. |
| 1210 transform.PostTranslate(container_offset.X().ToFloat(), | 1223 transform.PostTranslate(container_offset.X().ToFloat(), |
| 1211 container_offset.Y().ToFloat()); | 1224 container_offset.Y().ToFloat()); |
| 1212 | 1225 |
| 1213 // 3. Container scroll offset. | 1226 // c) Container scroll offset. |
| 1214 if (container_object->IsBox() && container_object != ancestor && | 1227 if (container_object->IsBox() && container_object != ancestor && |
| 1215 container_object->HasOverflowClip()) { | 1228 container_object->HasOverflowClip()) { |
| 1216 IntSize offset = -ToLayoutBox(container_object)->ScrolledContentOffset(); | 1229 IntSize offset = -ToLayoutBox(container_object)->ScrolledContentOffset(); |
| 1217 transform.PostTranslate(offset.Width(), offset.Height()); | 1230 transform.PostTranslate(offset.Width(), offset.Height()); |
| 1218 } | 1231 } |
| 1219 | 1232 |
| 1220 // 4. Perspective applied by container. | 1233 // d) Perspective applied by container. |
| 1221 if (container_object && container_object->HasLayer() && | 1234 if (container_object && container_object->HasLayer() && |
| 1222 container_object->Style()->HasPerspective()) { | 1235 container_object->Style()->HasPerspective()) { |
| 1223 // Perspective on the container affects us, so we have to factor it in here. | 1236 // Perspective on the container affects us, so we have to factor it in here. |
| 1224 DCHECK(container_object->HasLayer()); | 1237 DCHECK(container_object->HasLayer()); |
| 1225 FloatPoint perspective_origin = | 1238 FloatPoint perspective_origin = |
| 1226 ToLayoutBoxModelObject(container_object)->Layer()->PerspectiveOrigin(); | 1239 ToLayoutBoxModelObject(container_object)->Layer()->PerspectiveOrigin(); |
| 1227 | 1240 |
| 1228 TransformationMatrix perspective_matrix; | 1241 TransformationMatrix perspective_matrix; |
| 1229 perspective_matrix.ApplyPerspective( | 1242 perspective_matrix.ApplyPerspective( |
| 1230 container_object->Style()->Perspective()); | 1243 container_object->Style()->Perspective()); |
| 1231 perspective_matrix.ApplyTransformOrigin(perspective_origin.X(), | 1244 perspective_matrix.ApplyTransformOrigin(perspective_origin.X(), |
| 1232 perspective_origin.Y(), 0); | 1245 perspective_origin.Y(), 0); |
| 1233 | 1246 |
| 1234 transform = perspective_matrix * transform; | 1247 transform = perspective_matrix * transform; |
| 1235 } | 1248 } |
| 1236 | 1249 |
| 1237 // 5. Transform flattening. | 1250 // 3. Apply transform and flatten. |
| 1238 transform_state.ApplyTransform(transform, accumulation); | 1251 transform_state.ApplyTransform(transform, accumulation); |
| 1252 if (!container_preserve_3d) |
| 1253 transform_state.Flatten(); |
| 1239 | 1254 |
| 1240 // 6. Expansion for pixel snapping. | 1255 // 4. Apply container clip. |
| 1241 // Use enclosingBoundingBox because we cannot properly compute pixel | |
| 1242 // snapping for painted elements within the transform since we don't know | |
| 1243 // the desired subpixel accumulation at this point, and the transform may | |
| 1244 // include a scale. | |
| 1245 if (!preserve3D) { | |
| 1246 transform_state.Flatten(); | |
| 1247 transform_state.SetQuad( | |
| 1248 FloatQuad(transform_state.LastPlanarQuad().EnclosingBoundingBox())); | |
| 1249 } | |
| 1250 | |
| 1251 // 7. Container clip. | |
| 1252 if (container_object->IsBox() && container_object != ancestor && | 1256 if (container_object->IsBox() && container_object != ancestor && |
| 1253 container_object->HasClipRelatedProperty()) { | 1257 container_object->HasClipRelatedProperty()) { |
| 1254 return ToLayoutBox(container_object) | 1258 return ToLayoutBox(container_object) |
| 1255 ->ApplyBoxClips(transform_state, accumulation, visual_rect_flags); | 1259 ->ApplyBoxClips(transform_state, accumulation, visual_rect_flags); |
| 1256 } | 1260 } |
| 1257 | 1261 |
| 1258 return true; | 1262 return true; |
| 1259 } | 1263 } |
| 1260 | 1264 |
| 1261 bool LayoutBox::MapScrollingContentsRectToBoxSpace( | 1265 bool LayoutBox::MapScrollingContentsRectToBoxSpace( |
| (...skipping 4638 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 |