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

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

Issue 2727093002: Account for perspective and preserve-3d in mapToVisualRectInAncestorSpace (Closed)
Patch Set: none Created 3 years, 9 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) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc.
7 * All rights reserved. 7 * All rights reserved.
8 * Copyright (C) 2009 Google Inc. All rights reserved. 8 * Copyright (C) 2009 Google Inc. All rights reserved.
9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. 9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved.
10 * (http://www.torchmobile.com/) 10 * (http://www.torchmobile.com/)
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 1270
1271 LayoutRect LayoutObject::localVisualRect() const { 1271 LayoutRect LayoutObject::localVisualRect() const {
1272 NOTREACHED(); 1272 NOTREACHED();
1273 return LayoutRect(); 1273 return LayoutRect();
1274 } 1274 }
1275 1275
1276 bool LayoutObject::mapToVisualRectInAncestorSpace( 1276 bool LayoutObject::mapToVisualRectInAncestorSpace(
1277 const LayoutBoxModelObject* ancestor, 1277 const LayoutBoxModelObject* ancestor,
1278 LayoutRect& rect, 1278 LayoutRect& rect,
1279 VisualRectFlags visualRectFlags) const { 1279 VisualRectFlags visualRectFlags) const {
1280 TransformState transformState(TransformState::ApplyTransformDirection,
1281 FloatQuad(FloatRect(rect)));
1282 bool retval = mapToVisualRectInAncestorSpaceInternal(ancestor, transformState,
1283 visualRectFlags);
1284 transformState.flatten();
1285 rect = LayoutRect(transformState.lastPlanarQuad().boundingBox());
1286 return retval;
1287 }
1288
1289 bool LayoutObject::mapToVisualRectInAncestorSpaceInternal(
1290 const LayoutBoxModelObject* ancestor,
1291 TransformState& transformState,
1292 VisualRectFlags visualRectFlags) const {
1280 // For any layout object that doesn't override this method (the main example 1293 // For any layout object that doesn't override this method (the main example
1281 // is LayoutText), the rect is assumed to be in the parent's coordinate space, 1294 // is LayoutText), the rect is assumed to be in the parent's coordinate space,
1282 // except for container flip. 1295 // except for container flip.
1283 1296
1284 if (ancestor == this) 1297 if (ancestor == this)
1285 return true; 1298 return true;
1286 1299
1287 if (LayoutObject* parent = this->parent()) { 1300 if (LayoutObject* parent = this->parent()) {
1288 if (parent->isBox()) { 1301 if (parent->isBox()) {
1289 LayoutBox* parentBox = toLayoutBox(parent); 1302 LayoutBox* parentBox = toLayoutBox(parent);
1290 1303
1291 // Never flip for SVG as it handles writing modes itself. 1304 // Never flip for SVG as it handles writing modes itself.
1292 if (!isSVG()) 1305 if (!isSVG()) {
1306 transformState.flatten();
1307 LayoutRect rect(transformState.lastPlanarQuad().boundingBox());
1293 parentBox->flipForWritingMode(rect); 1308 parentBox->flipForWritingMode(rect);
1309 transformState.setQuad(FloatQuad(FloatRect(rect)));
1310 }
1311
1312 bool preserve3D = (parent->style()->preserves3D() && !parent->isText()) ||
Xianzhu 2017/03/03 01:24:42 Ditto about !parent->isText().
chrishtr 2017/03/03 02:45:11 I copied this conditional from: https://cs.chromi
1313 (style()->preserves3D() && !isText());
1314
1315 TransformState::TransformAccumulation accumulation =
1316 preserve3D ? TransformState::AccumulateTransform
1317 : TransformState::FlattenTransform;
1294 1318
1295 if (parent != ancestor && 1319 if (parent != ancestor &&
1296 !parentBox->mapScrollingContentsRectToBoxSpace(rect, visualRectFlags)) 1320 !parentBox->mapScrollingContentsRectToBoxSpace(
1321 transformState, accumulation, visualRectFlags))
1297 return false; 1322 return false;
1298 } 1323 }
1299 return parent->mapToVisualRectInAncestorSpace(ancestor, rect, 1324 return parent->mapToVisualRectInAncestorSpaceInternal(
1300 visualRectFlags); 1325 ancestor, transformState, visualRectFlags);
1301 } 1326 }
1302 return true; 1327 return true;
1303 } 1328 }
1304 1329
1305 void LayoutObject::dirtyLinesFromChangedChild(LayoutObject*, MarkingBehavior) {} 1330 void LayoutObject::dirtyLinesFromChangedChild(LayoutObject*, MarkingBehavior) {}
1306 1331
1307 #ifndef NDEBUG 1332 #ifndef NDEBUG
1308 1333
1309 void LayoutObject::showTreeForThis() const { 1334 void LayoutObject::showTreeForThis() const {
1310 if (node()) 1335 if (node())
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after
2262 } 2287 }
2263 2288
2264 FloatQuad LayoutObject::localToAncestorQuadInternal( 2289 FloatQuad LayoutObject::localToAncestorQuadInternal(
2265 const FloatQuad& localQuad, 2290 const FloatQuad& localQuad,
2266 const LayoutBoxModelObject* ancestor, 2291 const LayoutBoxModelObject* ancestor,
2267 MapCoordinatesFlags mode) const { 2292 MapCoordinatesFlags mode) const {
2268 // Track the point at the center of the quad's bounding box. As 2293 // Track the point at the center of the quad's bounding box. As
2269 // mapLocalToAncestor() calls offsetFromContainer(), it will use that point 2294 // mapLocalToAncestor() calls offsetFromContainer(), it will use that point
2270 // as the reference point to decide which column's transform to apply in 2295 // as the reference point to decide which column's transform to apply in
2271 // multiple-column blocks. 2296 // multiple-column blocks.
2297 // TODO(chrishtr): the second argument to this constructor is unnecessary,
2298 // since we never call lastPlanarPoint().
2272 TransformState transformState(TransformState::ApplyTransformDirection, 2299 TransformState transformState(TransformState::ApplyTransformDirection,
2273 localQuad.boundingBox().center(), localQuad); 2300 localQuad.boundingBox().center(), localQuad);
2274 mapLocalToAncestor(ancestor, transformState, mode | ApplyContainerFlip); 2301 mapLocalToAncestor(ancestor, transformState, mode | ApplyContainerFlip);
2275 transformState.flatten(); 2302 transformState.flatten();
2276 2303
2277 return transformState.lastPlanarQuad(); 2304 return transformState.lastPlanarQuad();
2278 } 2305 }
2279 2306
2280 FloatPoint LayoutObject::localToAncestorPoint( 2307 FloatPoint LayoutObject::localToAncestorPoint(
2281 const FloatPoint& localPoint, 2308 const FloatPoint& localPoint,
(...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after
3529 const blink::LayoutObject* root = object1; 3556 const blink::LayoutObject* root = object1;
3530 while (root->parent()) 3557 while (root->parent())
3531 root = root->parent(); 3558 root = root->parent();
3532 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); 3559 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0);
3533 } else { 3560 } else {
3534 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)"); 3561 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)");
3535 } 3562 }
3536 } 3563 }
3537 3564
3538 #endif 3565 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698