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

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

Issue 1820483002: Untangle multicol coordinate space conversion from offsetFromContainer(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address code review comment. Created 4 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. All rights reserv ed. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2009 Google Inc. All rights reserved. 7 * Copyright (C) 2009 Google Inc. All rights reserved.
8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
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 2245 matching lines...) Expand 10 before | Expand all | Expand 10 after
2256 mode &= ~ApplyContainerFlip; 2256 mode &= ~ApplyContainerFlip;
2257 } else if (o->isBox()) { 2257 } else if (o->isBox()) {
2258 if (o->style()->isFlippedBlocksWritingMode()) { 2258 if (o->style()->isFlippedBlocksWritingMode()) {
2259 IntPoint centerPoint = roundedIntPoint(transformState.mappedPoin t()); 2259 IntPoint centerPoint = roundedIntPoint(transformState.mappedPoin t());
2260 transformState.move(toLayoutBox(o)->flipForWritingMode(LayoutPoi nt(centerPoint)) - centerPoint); 2260 transformState.move(toLayoutBox(o)->flipForWritingMode(LayoutPoi nt(centerPoint)) - centerPoint);
2261 } 2261 }
2262 mode &= ~ApplyContainerFlip; 2262 mode &= ~ApplyContainerFlip;
2263 } 2263 }
2264 } 2264 }
2265 2265
2266 LayoutSize containerOffset = offsetFromContainer(o, roundedLayoutPoint(trans formState.mappedPoint())); 2266 LayoutSize containerOffset = offsetFromContainer(o);
2267 if (o->isLayoutFlowThread()) {
2268 // So far the point has been in flow thread coordinates (i.e. as if ever ything in
2269 // the fragmentation context lived in one tall single column). Convert i t to a
2270 // visual point now.
2271 LayoutPoint pointInContainer = roundedLayoutPoint(transformState.mappedP oint()) + containerOffset;
2272 containerOffset += o->columnOffset(pointInContainer);
2273 }
2267 2274
2268 // Text objects just copy their parent's computed style, so we need to ignor e them. 2275 // Text objects just copy their parent's computed style, so we need to ignor e them.
2269 bool preserve3D = mode & UseTransforms && ((o->style()->preserves3D() && !o- >isText()) || (style()->preserves3D() && !isText())); 2276 bool preserve3D = mode & UseTransforms && ((o->style()->preserves3D() && !o- >isText()) || (style()->preserves3D() && !isText()));
2270 if (mode & UseTransforms && shouldUseTransformFromContainer(o)) { 2277 if (mode & UseTransforms && shouldUseTransformFromContainer(o)) {
2271 TransformationMatrix t; 2278 TransformationMatrix t;
2272 getTransformFromContainer(o, containerOffset, t); 2279 getTransformFromContainer(o, containerOffset, t);
2273 transformState.applyTransform(t, preserve3D ? TransformState::Accumulate Transform : TransformState::FlattenTransform); 2280 transformState.applyTransform(t, preserve3D ? TransformState::Accumulate Transform : TransformState::FlattenTransform);
2274 } else { 2281 } else {
2275 transformState.move(containerOffset.width(), containerOffset.height(), p reserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTransfo rm); 2282 transformState.move(containerOffset.width(), containerOffset.height(), p reserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTransfo rm);
2276 } 2283 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2308 mode &= ~ApplyContainerFlip; 2315 mode &= ~ApplyContainerFlip;
2309 } else if (o->isBox()) { 2316 } else if (o->isBox()) {
2310 applyContainerFlip = o->style()->isFlippedBlocksWritingMode(); 2317 applyContainerFlip = o->style()->isFlippedBlocksWritingMode();
2311 mode &= ~ApplyContainerFlip; 2318 mode &= ~ApplyContainerFlip;
2312 } 2319 }
2313 } 2320 }
2314 2321
2315 if (!containerSkipped) 2322 if (!containerSkipped)
2316 o->mapAncestorToLocal(ancestor, transformState, mode); 2323 o->mapAncestorToLocal(ancestor, transformState, mode);
2317 2324
2318 LayoutSize containerOffset = offsetFromContainer(o, LayoutPoint()); 2325 LayoutSize containerOffset = offsetFromContainer(o);
2319 if (o->isLayoutFlowThread()) { 2326 if (o->isLayoutFlowThread()) {
2320 // Descending into a flow thread. Convert to the local coordinate space, i.e. flow thread coordinates. 2327 // Descending into a flow thread. Convert to the local coordinate space, i.e. flow thread coordinates.
2321 const LayoutFlowThread* flowThread = toLayoutFlowThread(o);
2322 LayoutPoint visualPoint = LayoutPoint(transformState.mappedPoint()); 2328 LayoutPoint visualPoint = LayoutPoint(transformState.mappedPoint());
2323 transformState.move(visualPoint - flowThread->visualPointToFlowThreadPoi nt(visualPoint)); 2329 transformState.move(visualPoint - toLayoutFlowThread(o)->visualPointToFl owThreadPoint(visualPoint));
2324 // |containerOffset| is also in visual coordinates. Convert to flow thre ad coordinates.
2325 // TODO(mstensho): Wouldn't it be better add a parameter to instruct off setFromContainer()
2326 // to return flowthread coordinates in the first place? We're effectivel y performing two
2327 // conversions here, when in fact none is needed.
2328 containerOffset = toLayoutSize(flowThread->visualPointToFlowThreadPoint( toLayoutPoint(containerOffset)));
2329 } 2330 }
2330 2331
2331 bool preserve3D = mode & UseTransforms && (o->style()->preserves3D() || styl e()->preserves3D()); 2332 bool preserve3D = mode & UseTransforms && (o->style()->preserves3D() || styl e()->preserves3D());
2332 if (mode & UseTransforms && shouldUseTransformFromContainer(o)) { 2333 if (mode & UseTransforms && shouldUseTransformFromContainer(o)) {
2333 TransformationMatrix t; 2334 TransformationMatrix t;
2334 getTransformFromContainer(o, containerOffset, t); 2335 getTransformFromContainer(o, containerOffset, t);
2335 transformState.applyTransform(t, preserve3D ? TransformState::Accumulate Transform : TransformState::FlattenTransform); 2336 transformState.applyTransform(t, preserve3D ? TransformState::Accumulate Transform : TransformState::FlattenTransform);
2336 } else { 2337 } else {
2337 transformState.move(containerOffset.width(), containerOffset.height(), p reserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTransfo rm); 2338 transformState.move(containerOffset.width(), containerOffset.height(), p reserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTransfo rm);
2338 } 2339 }
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
2431 2432
2432 // A layoutObject can have no invalidation backing if it is from a detached frame, 2433 // A layoutObject can have no invalidation backing if it is from a detached frame,
2433 // or when forced compositing is disabled. 2434 // or when forced compositing is disabled.
2434 if (paintInvalidationContainer.layer()->compositingState() == NotComposited) 2435 if (paintInvalidationContainer.layer()->compositingState() == NotComposited)
2435 return containerPoint; 2436 return containerPoint;
2436 2437
2437 PaintLayer::mapPointToPaintBackingCoordinates(&paintInvalidationContainer, c ontainerPoint); 2438 PaintLayer::mapPointToPaintBackingCoordinates(&paintInvalidationContainer, c ontainerPoint);
2438 return containerPoint; 2439 return containerPoint;
2439 } 2440 }
2440 2441
2441 LayoutSize LayoutObject::offsetFromContainer(const LayoutObject* o, const Layout Point& point, bool* offsetDependsOnPoint) const 2442 LayoutSize LayoutObject::offsetFromContainer(const LayoutObject* o) const
2442 { 2443 {
2443 ASSERT(o == container()); 2444 ASSERT(o == container());
2444 2445 return o->hasOverflowClip() ? LayoutSize(-toLayoutBox(o)->scrolledContentOff set()) : LayoutSize();
2445 LayoutSize offset = o->columnOffset(point);
2446
2447 if (o->hasOverflowClip())
2448 offset -= toLayoutBox(o)->scrolledContentOffset();
2449
2450 if (offsetDependsOnPoint)
2451 *offsetDependsOnPoint = o->isLayoutFlowThread();
2452
2453 return offset;
2454 } 2446 }
2455 2447
2456 LayoutSize LayoutObject::offsetFromAncestorContainer(const LayoutObject* ancesto rContainer) const 2448 LayoutSize LayoutObject::offsetFromAncestorContainer(const LayoutObject* ancesto rContainer) const
2457 { 2449 {
2458 if (ancestorContainer == this) 2450 if (ancestorContainer == this)
2459 return LayoutSize(); 2451 return LayoutSize();
2460 2452
2461 LayoutSize offset; 2453 LayoutSize offset;
2462 LayoutPoint referencePoint; 2454 LayoutPoint referencePoint;
2463 const LayoutObject* currContainer = this; 2455 const LayoutObject* currContainer = this;
2464 do { 2456 do {
2465 const LayoutObject* nextContainer = currContainer->container(); 2457 const LayoutObject* nextContainer = currContainer->container();
2466 ASSERT(nextContainer); // This means we reached the top without finding container. 2458 ASSERT(nextContainer); // This means we reached the top without finding container.
2467 if (!nextContainer) 2459 if (!nextContainer)
2468 break; 2460 break;
2469 ASSERT(!currContainer->hasTransformRelatedProperty()); 2461 ASSERT(!currContainer->hasTransformRelatedProperty());
2470 LayoutSize currentOffset = currContainer->offsetFromContainer(nextContai ner, referencePoint); 2462 LayoutSize currentOffset = currContainer->offsetFromContainer(nextContai ner);
2471 offset += currentOffset; 2463 offset += currentOffset;
2472 referencePoint.move(currentOffset); 2464 referencePoint.move(currentOffset);
2473 currContainer = nextContainer; 2465 currContainer = nextContainer;
2474 } while (currContainer != ancestorContainer); 2466 } while (currContainer != ancestorContainer);
2475 2467
2476 return offset; 2468 return offset;
2477 } 2469 }
2478 2470
2479 LayoutRect LayoutObject::localCaretRect(InlineBox*, int, LayoutUnit* extraWidthT oEndOfLine) 2471 LayoutRect LayoutObject::localCaretRect(InlineBox*, int, LayoutUnit* extraWidthT oEndOfLine)
2480 { 2472 {
(...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after
3733 const blink::LayoutObject* root = object1; 3725 const blink::LayoutObject* root = object1;
3734 while (root->parent()) 3726 while (root->parent())
3735 root = root->parent(); 3727 root = root->parent();
3736 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); 3728 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0);
3737 } else { 3729 } else {
3738 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n"); 3730 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n");
3739 } 3731 }
3740 } 3732 }
3741 3733
3742 #endif 3734 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutObject.h ('k') | third_party/WebKit/Source/core/layout/LayoutTableCell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698