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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutBox.cpp

Issue 2073563002: Rework mapToVisualRectInAncestorSpace to handle flipped blocks correctly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync to head. Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/LayoutBox.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBox.cpp b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
index 4fc4b88d0b30ee3b40066ef8b3237f68d14340cc..f4207c33f105c750ae51cd98f201d40b552f5dd7 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBox.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
@@ -991,15 +991,11 @@ bool LayoutBox::mapScrollingContentsRectToBoxSpace(LayoutRect& rect, ApplyOverfl
return true;
LayoutSize offset = LayoutSize(-scrolledContentOffset());
- if (UNLIKELY(hasFlippedBlocksWritingMode()))
- offset.setWidth(-offset.width());
rect.move(offset);
if (applyOverflowClip == ApplyNonScrollOverflowClip && scrollsOverflow())
return true;
- flipForWritingMode(rect);
-
LayoutRect clipRect = overflowClipRect(LayoutPoint());
bool doesIntersect;
@@ -1009,8 +1005,6 @@ bool LayoutBox::mapScrollingContentsRectToBoxSpace(LayoutRect& rect, ApplyOverfl
rect.intersect(clipRect);
doesIntersect = !rect.isEmpty();
}
- if (doesIntersect)
- flipForWritingMode(rect);
return doesIntersect;
}
@@ -2043,34 +2037,25 @@ bool LayoutBox::mapToVisualRectInAncestorSpace(const LayoutBoxModelObject* ances
{
inflateVisualRectForReflectionAndFilter(rect);
- if (ancestor == this) {
- // The final rect returned is always in the physical coordinate space of the ancestor.
- flipForWritingMode(rect);
+ if (ancestor == this)
return true;
- }
bool ancestorSkipped;
bool filterOrReflectionSkipped;
LayoutObject* container = this->container(ancestor, &ancestorSkipped, &filterOrReflectionSkipped);
+ LayoutBox* localContainingBlock = containingBlock();
+ // Skip table row because cells and rows are in the same coordinate space.
+ if (container->isTableRow()) {
+ DCHECK(isTableCell());
+ localContainingBlock = toLayoutBox(container->parent());
+ container = container->parent();
+ }
if (!container)
return true;
if (filterOrReflectionSkipped)
inflateVisualRectForReflectionAndFilterUnderContainer(rect, *container, ancestor);
- // The rect we compute at each step is shifted by our x/y offset in the parent container's coordinate space.
- // Only when we cross a writing mode boundary will we have to possibly flipForWritingMode (to convert into a more
- // appropriate offset corner for the enclosing container).
- if (isWritingModeRoot()) {
- flipForWritingMode(rect);
- // Then flip rect currently in physical direction to container's block direction.
- if (container->styleRef().isFlippedBlocksWritingMode())
- rect.setX(m_frameRect.width() - rect.maxX());
- }
-
- LayoutPoint topLeft = rect.location();
- topLeft.move(locationOffset());
-
// We are now in our parent container's coordinate space. Apply our transform to obtain a bounding box
// in the parent's coordinate space that encloses us.
if (hasLayer() && layer()->transform()) {
@@ -2078,9 +2063,12 @@ bool LayoutBox::mapToVisualRectInAncestorSpace(const LayoutBoxModelObject* ances
// the transform since we don't know the desired subpixel accumulation at this point, and the transform may
// include a scale.
rect = LayoutRect(layer()->transform()->mapRect(enclosingIntRect(rect)));
- topLeft = rect.location();
- topLeft.move(locationOffset());
}
+ LayoutPoint topLeft = rect.location();
+ // TODO(wkorman): Look into and document why this conditional is needed.
+ // Currently present following logic in PaintLayer::updateLayerPosition.
+ if (!(isInline() && isLayoutInline()))
+ topLeft.moveBy(topLeftLocation(localContainingBlock));
const ComputedStyle& styleToUse = styleRef();
EPosition position = styleToUse.position();
@@ -2102,7 +2090,7 @@ bool LayoutBox::mapToVisualRectInAncestorSpace(const LayoutBoxModelObject* ances
return false;
if (ancestorSkipped) {
- // If the ancestor is below o, then we need to map the rect into ancestor's coordinates.
+ // If the ancestor is below the container, then we need to map the rect into ancestor's coordinates.
LayoutSize containerOffset = ancestor->offsetFromAncestorContainer(container);
rect.move(-containerOffset);
// If the ancestor is fixed, then the rect is already in its coordinates so doesn't need viewport-adjusting.
@@ -4475,12 +4463,12 @@ LayoutPoint LayoutBox::flipForWritingModeForChild(const LayoutBox* child, const
return LayoutPoint(point.x() + size().width() - child->size().width() - (2 * child->location().x()), point.y());
}
-LayoutPoint LayoutBox::topLeftLocation() const
+LayoutPoint LayoutBox::topLeftLocation(const LayoutBox* flippedBlocksContainer) const
{
- LayoutBlock* containerBlock = containingBlock();
- if (!containerBlock || containerBlock == this)
+ const LayoutBox* containerBox = flippedBlocksContainer ? flippedBlocksContainer : containingBlock();
+ if (!containerBox || containerBox == this)
return location();
- return containerBlock->flipForWritingModeForChild(this, location());
+ return containerBox->flipForWritingModeForChild(this, location());
}
bool LayoutBox::hasRelativeLogicalWidth() const
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBox.h ('k') | third_party/WebKit/Source/core/layout/LayoutFlowThread.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698