Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(563)

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutBox.cpp

Issue 2859483004: Revert of Don't pass subpixel offsets through non-translation transforms (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 container_preserve_3d = container_object->Style()->Preserves3D(); 1180 bool preserve3D = container_object->Style()->Preserves3D();
1181 1181
1182 TransformState::TransformAccumulation accumulation = 1182 TransformState::TransformAccumulation accumulation =
1183 container_preserve_3d ? TransformState::kAccumulateTransform 1183 preserve3D ? 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, do the following: 1198 // Otherwise, apply the following:
1199 // 1. Expand for pixel snapping. 1199 // 1. Transform.
1200 // 2. Generate transformation matrix combining, in this order 1200 // 2. Container offset.
1201 // a) transform, 1201 // 3. Container scroll offset.
1202 // b) container offset, 1202 // 4. Perspective applied by container.
1203 // c) container scroll offset, 1203 // 5. Transform flattening.
1204 // d) perspective applied by container. 1204 // 6. Expansion for pixel snapping.
1205 // 3. Apply transform Transform+flattening. 1205 // 7. Container clip.
1206 // 4. Apply container clip.
1207 1206
1208 // 1. Expand for pixel snapping. 1207 // 1. Transform.
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.
1224 TransformationMatrix transform; 1208 TransformationMatrix transform;
1225 if (Layer() && Layer()->Transform()) 1209 if (Layer() && Layer()->Transform())
1226 transform.Multiply(Layer()->CurrentTransform()); 1210 transform.Multiply(Layer()->CurrentTransform());
1227 1211
1228 // b) Container offset. 1212 // 2. Container offset.
1229 transform.PostTranslate(container_offset.X().ToFloat(), 1213 transform.PostTranslate(container_offset.X().ToFloat(),
1230 container_offset.Y().ToFloat()); 1214 container_offset.Y().ToFloat());
1231 1215
1232 // c) Container scroll offset. 1216 // 3. Container scroll offset.
1233 if (container_object->IsBox() && container_object != ancestor && 1217 if (container_object->IsBox() && container_object != ancestor &&
1234 container_object->HasOverflowClip()) { 1218 container_object->HasOverflowClip()) {
1235 IntSize offset = -ToLayoutBox(container_object)->ScrolledContentOffset(); 1219 IntSize offset = -ToLayoutBox(container_object)->ScrolledContentOffset();
1236 transform.PostTranslate(offset.Width(), offset.Height()); 1220 transform.PostTranslate(offset.Width(), offset.Height());
1237 } 1221 }
1238 1222
1239 // d) Perspective applied by container. 1223 // 4. Perspective applied by container.
1240 if (container_object && container_object->HasLayer() && 1224 if (container_object && container_object->HasLayer() &&
1241 container_object->Style()->HasPerspective()) { 1225 container_object->Style()->HasPerspective()) {
1242 // Perspective on the container affects us, so we have to factor it in here. 1226 // Perspective on the container affects us, so we have to factor it in here.
1243 DCHECK(container_object->HasLayer()); 1227 DCHECK(container_object->HasLayer());
1244 FloatPoint perspective_origin = 1228 FloatPoint perspective_origin =
1245 ToLayoutBoxModelObject(container_object)->Layer()->PerspectiveOrigin(); 1229 ToLayoutBoxModelObject(container_object)->Layer()->PerspectiveOrigin();
1246 1230
1247 TransformationMatrix perspective_matrix; 1231 TransformationMatrix perspective_matrix;
1248 perspective_matrix.ApplyPerspective( 1232 perspective_matrix.ApplyPerspective(
1249 container_object->Style()->Perspective()); 1233 container_object->Style()->Perspective());
1250 perspective_matrix.ApplyTransformOrigin(perspective_origin.X(), 1234 perspective_matrix.ApplyTransformOrigin(perspective_origin.X(),
1251 perspective_origin.Y(), 0); 1235 perspective_origin.Y(), 0);
1252 1236
1253 transform = perspective_matrix * transform; 1237 transform = perspective_matrix * transform;
1254 } 1238 }
1255 1239
1256 // 3. Apply transform and flatten. 1240 // 5. Transform flattening.
1257 transform_state.ApplyTransform(transform, accumulation); 1241 transform_state.ApplyTransform(transform, accumulation);
1258 if (!container_preserve_3d) 1242
1243 // 6. Expansion for pixel snapping.
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) {
1259 transform_state.Flatten(); 1249 transform_state.Flatten();
1250 transform_state.SetQuad(
1251 FloatQuad(transform_state.LastPlanarQuad().EnclosingBoundingBox()));
1252 }
1260 1253
1261 // 4. Apply container clip. 1254 // 7. Container clip.
1262 if (container_object->IsBox() && container_object != ancestor && 1255 if (container_object->IsBox() && container_object != ancestor &&
1263 container_object->HasClipRelatedProperty()) { 1256 container_object->HasClipRelatedProperty()) {
1264 return ToLayoutBox(container_object) 1257 return ToLayoutBox(container_object)
1265 ->ApplyBoxClips(transform_state, accumulation, visual_rect_flags); 1258 ->ApplyBoxClips(transform_state, accumulation, visual_rect_flags);
1266 } 1259 }
1267 1260
1268 return true; 1261 return true;
1269 } 1262 }
1270 1263
1271 bool LayoutBox::MapScrollingContentsRectToBoxSpace( 1264 bool LayoutBox::MapScrollingContentsRectToBoxSpace(
(...skipping 4635 matching lines...) Expand 10 before | Expand all | Expand 10 after
5907 void LayoutBox::MutableForPainting:: 5900 void LayoutBox::MutableForPainting::
5908 SavePreviousContentBoxSizeAndLayoutOverflowRect() { 5901 SavePreviousContentBoxSizeAndLayoutOverflowRect() {
5909 auto& rare_data = GetLayoutBox().EnsureRareData(); 5902 auto& rare_data = GetLayoutBox().EnsureRareData();
5910 rare_data.has_previous_content_box_size_and_layout_overflow_rect_ = true; 5903 rare_data.has_previous_content_box_size_and_layout_overflow_rect_ = true;
5911 rare_data.previous_content_box_size_ = GetLayoutBox().ContentBoxRect().Size(); 5904 rare_data.previous_content_box_size_ = GetLayoutBox().ContentBoxRect().Size();
5912 rare_data.previous_layout_overflow_rect_ = 5905 rare_data.previous_layout_overflow_rect_ =
5913 GetLayoutBox().LayoutOverflowRect(); 5906 GetLayoutBox().LayoutOverflowRect();
5914 } 5907 }
5915 5908
5916 } // namespace blink 5909 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698