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

Side by Side Diff: Source/core/rendering/RenderInline.cpp

Issue 423173003: Incorrect Static Position of Absolute Positioned Elements inside Rel-Positioned Containers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « LayoutTests/fast/css/abs-pos-child-inside-rel-pos-inline-offset-001-expected.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 1291 matching lines...) Expand 10 before | Expand all | Expand 10 after
1302 LayoutUnit inlinePosition; 1302 LayoutUnit inlinePosition;
1303 LayoutUnit blockPosition; 1303 LayoutUnit blockPosition;
1304 if (firstLineBox()) { 1304 if (firstLineBox()) {
1305 inlinePosition = LayoutUnit::fromFloatRound(firstLineBox()->logicalLeft( )); 1305 inlinePosition = LayoutUnit::fromFloatRound(firstLineBox()->logicalLeft( ));
1306 blockPosition = firstLineBox()->logicalTop(); 1306 blockPosition = firstLineBox()->logicalTop();
1307 } else { 1307 } else {
1308 inlinePosition = layer()->staticInlinePosition(); 1308 inlinePosition = layer()->staticInlinePosition();
1309 blockPosition = layer()->staticBlockPosition(); 1309 blockPosition = layer()->staticBlockPosition();
1310 } 1310 }
1311 1311
1312 if (!child.style()->hasStaticInlinePosition(style()->isHorizontalWritingMode ())) 1312 // Per http://www.w3.org/TR/CSS2/visudet.html#abs-non-replaced-width an abso lute positioned box
1313 // with a static position should locate itself as though it is a normal flow box in relation to
1314 // its containing block. If this relative-positioned inline has a negative o ffset we need to
1315 // compensate for it so that we align the positioned object with the edge of its containing block.
1316 if (child.style()->hasStaticInlinePosition(style()->isHorizontalWritingMode( )))
1317 logicalOffset.setWidth(std::max(LayoutUnit(), -offsetForInFlowPosition() .width()));
1318 else
1313 logicalOffset.setWidth(inlinePosition); 1319 logicalOffset.setWidth(inlinePosition);
1314 1320
1315 // This is not terribly intuitive, but we have to match other browsers. Des pite being a block display type inside
1316 // an inline, we still keep our x locked to the left of the relative positio ned inline. Arguably the correct
1317 // behavior would be to go flush left to the block that contains the inline, but that isn't what other browsers
1318 // do.
1319 else if (!child.style()->isOriginalDisplayInlineType())
1320 // Avoid adding in the left border/padding of the containing block twice . Subtract it out.
1321 logicalOffset.setWidth(inlinePosition - child.containingBlock()->borderA ndPaddingLogicalLeft());
1322
1323 if (!child.style()->hasStaticBlockPosition(style()->isHorizontalWritingMode( ))) 1321 if (!child.style()->hasStaticBlockPosition(style()->isHorizontalWritingMode( )))
1324 logicalOffset.setHeight(blockPosition); 1322 logicalOffset.setHeight(blockPosition);
1325 1323
1326 return style()->isHorizontalWritingMode() ? logicalOffset : logicalOffset.tr ansposedSize(); 1324 return style()->isHorizontalWritingMode() ? logicalOffset : logicalOffset.tr ansposedSize();
1327 } 1325 }
1328 1326
1329 void RenderInline::imageChanged(WrappedImagePtr, const IntRect*) 1327 void RenderInline::imageChanged(WrappedImagePtr, const IntRect*)
1330 { 1328 {
1331 if (!parent()) 1329 if (!parent())
1332 return; 1330 return;
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1562 1560
1563 void RenderInline::invalidateTreeIfNeeded(const PaintInvalidationState& paintInv alidationState) 1561 void RenderInline::invalidateTreeIfNeeded(const PaintInvalidationState& paintInv alidationState)
1564 { 1562 {
1565 bool establishesNewPaintInvalidationContainer = isPaintInvalidationContainer (); 1563 bool establishesNewPaintInvalidationContainer = isPaintInvalidationContainer ();
1566 const RenderLayerModelObject& newPaintInvalidationContainer = *adjustComposi tedContainerForSpecialAncestors(establishesNewPaintInvalidationContainer ? this : &paintInvalidationState.paintInvalidationContainer()); 1564 const RenderLayerModelObject& newPaintInvalidationContainer = *adjustComposi tedContainerForSpecialAncestors(establishesNewPaintInvalidationContainer ? this : &paintInvalidationState.paintInvalidationContainer());
1567 PaintInvalidationState childPaintInvalidationState(paintInvalidationState, * this, newPaintInvalidationContainer); 1565 PaintInvalidationState childPaintInvalidationState(paintInvalidationState, * this, newPaintInvalidationContainer);
1568 RenderObject::invalidateTreeIfNeeded(childPaintInvalidationState); 1566 RenderObject::invalidateTreeIfNeeded(childPaintInvalidationState);
1569 } 1567 }
1570 1568
1571 } // namespace blink 1569 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/css/abs-pos-child-inside-rel-pos-inline-offset-001-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698