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

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

Issue 2392503003: Fix LayoutBox::topLeftLocation for table rows and table cells (Closed)
Patch Set: virtual Created 4 years, 2 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. All rights reserv ed. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 2264 matching lines...) Expand 10 before | Expand all | Expand 10 after
2275 inflateVisualRectForFilter(rect); 2275 inflateVisualRectForFilter(rect);
2276 2276
2277 if (ancestor == this) 2277 if (ancestor == this)
2278 return true; 2278 return true;
2279 2279
2280 bool ancestorSkipped; 2280 bool ancestorSkipped;
2281 bool filterSkipped; 2281 bool filterSkipped;
2282 LayoutObject* container = 2282 LayoutObject* container =
2283 this->container(ancestor, &ancestorSkipped, &filterSkipped); 2283 this->container(ancestor, &ancestorSkipped, &filterSkipped);
2284 LayoutBox* tableRowContainer = nullptr; 2284 LayoutBox* tableRowContainer = nullptr;
2285 // Skip table row because cells and rows are in the same coordinate space 2285 // Skip table row because cells and rows are in the same coordinate space (see
2286 // (see below, however for more comments about when |ancestor| is the table ro w). 2286 // below, however for more comments about when |ancestor| is the table row).
2287 // The second and third conditionals below are to skip cases where content has display: table-row or display: table-cell but is not 2287 if (isTableCell()) {
2288 // parented like a cell/row combo. 2288 DCHECK(container->isTableRow() && parentBox() == container);
chrishtr 2016/10/04 17:32:17 I changed the code to remove the DCHECK just last
Xianzhu 2016/10/04 17:48:02 Based on my test, we create anonymous LayoutTable,
2289 if (container->isTableRow() && isTableCell() && parentBox() == container) {
2290 if (container != ancestor) 2289 if (container != ancestor)
2291 container = container->parent(); 2290 container = container->parent();
2292 else 2291 else
2293 tableRowContainer = toLayoutBox(container); 2292 tableRowContainer = toLayoutBox(container);
2294 } 2293 }
2295 if (!container) 2294 if (!container)
2296 return true; 2295 return true;
2297 2296
2298 if (filterSkipped) 2297 if (filterSkipped)
2299 inflateVisualRectForFilterUnderContainer(rect, *container, ancestor); 2298 inflateVisualRectForFilterUnderContainer(rect, *container, ancestor);
(...skipping 2740 matching lines...) Expand 10 before | Expand all | Expand 10 after
5040 if (!style()->isFlippedBlocksWritingMode()) 5039 if (!style()->isFlippedBlocksWritingMode())
5041 return point; 5040 return point;
5042 5041
5043 // The child is going to add in its x(), so we have to make sure it ends up in 5042 // The child is going to add in its x(), so we have to make sure it ends up in
5044 // the right place. 5043 // the right place.
5045 return LayoutPoint(point.x() + size().width() - child->size().width() - 5044 return LayoutPoint(point.x() + size().width() - child->size().width() -
5046 (2 * child->location().x()), 5045 (2 * child->location().x()),
5047 point.y()); 5046 point.y());
5048 } 5047 }
5049 5048
5049 LayoutBox* LayoutBox::locationContainer() const {
chrishtr 2016/10/04 18:25:59 Please add a unittest that tests this method direc
Xianzhu 2016/10/04 19:20:30 Done.
5050 // Normally the box's location is relative to its containing box.
5051 LayoutObject* container = this->container();
5052 while (container && !container->isBox())
5053 container = container->container();
5054 return toLayoutBox(container);
5055 }
5056
5050 LayoutPoint LayoutBox::topLeftLocation( 5057 LayoutPoint LayoutBox::topLeftLocation(
5051 const LayoutBox* flippedBlocksContainer) const { 5058 const LayoutBox* flippedBlocksContainer) const {
5052 const LayoutBox* containerBox = 5059 const LayoutBox* containerBox;
5053 flippedBlocksContainer ? flippedBlocksContainer : containingBlock(); 5060 if (flippedBlocksContainer) {
5054 if (!containerBox || containerBox == this) 5061 DCHECK(flippedBlocksContainer == locationContainer());
5062 containerBox = flippedBlocksContainer;
5063 } else {
5064 containerBox = locationContainer();
5065 }
5066 if (!containerBox)
5055 return location(); 5067 return location();
5056 return containerBox->flipForWritingModeForChild(this, location()); 5068 return containerBox->flipForWritingModeForChild(this, location());
5057 } 5069 }
5058 5070
5059 bool LayoutBox::hasRelativeLogicalWidth() const { 5071 bool LayoutBox::hasRelativeLogicalWidth() const {
5060 return style()->logicalWidth().isPercentOrCalc() || 5072 return style()->logicalWidth().isPercentOrCalc() ||
5061 style()->logicalMinWidth().isPercentOrCalc() || 5073 style()->logicalMinWidth().isPercentOrCalc() ||
5062 style()->logicalMaxWidth().isPercentOrCalc(); 5074 style()->logicalMaxWidth().isPercentOrCalc();
5063 } 5075 }
5064 5076
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
5464 LayoutRect rect = frameRect(); 5476 LayoutRect rect = frameRect();
5465 5477
5466 LayoutBlock* block = containingBlock(); 5478 LayoutBlock* block = containingBlock();
5467 if (block) 5479 if (block)
5468 block->adjustChildDebugRect(rect); 5480 block->adjustChildDebugRect(rect);
5469 5481
5470 return rect; 5482 return rect;
5471 } 5483 }
5472 5484
5473 } // namespace blink 5485 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBox.h ('k') | third_party/WebKit/Source/core/layout/LayoutBoxTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698