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

Unified Diff: third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp

Issue 2102843002: Fix getComputedStyle for non-box-layout elements (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix getComputedStyle for non-box-layout elements 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
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/css/getComputedStyle/getComputedStyle-resolved-values-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp
diff --git a/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp b/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp
index f0fb3cf80a337606b58d189a656e63a7acaf3002..e0abfd71065805c183a3edb6840eac782cfcf3c8 100644
--- a/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp
+++ b/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp
@@ -207,17 +207,24 @@ static CSSValue* valueForPositionOffset(const ComputedStyle& style, CSSPropertyI
if (opposite.isAuto())
return CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Pixels);
- if (opposite.hasPercent()) {
- LayoutUnit containingBlockSize =
- (propertyID == CSSPropertyLeft || propertyID == CSSPropertyRight) ?
- toLayoutBox(layoutObject)->containingBlockLogicalWidthForContent() :
- toLayoutBox(layoutObject)->containingBlockLogicalHeightForGetComputedStyle();
- return zoomAdjustedPixelValue(-floatValueForLength(opposite, containingBlockSize), style);
+ if (opposite.hasPercent() || opposite.isCalculated()) {
+ if (layoutObject->isBox()) {
+ LayoutUnit containingBlockSize =
+ (propertyID == CSSPropertyLeft || propertyID == CSSPropertyRight) ?
+ toLayoutBox(layoutObject)->containingBlockLogicalWidthForContent() :
+ toLayoutBox(layoutObject)->containingBlockLogicalHeightForGetComputedStyle();
+ return zoomAdjustedPixelValue(-floatValueForLength(opposite, containingBlockSize), style);
+ }
+ // FIXME: fall back to auto for position:relative, display:inline
+ return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
}
- return zoomAdjustedPixelValue(-opposite.pixels(), style);
+
+ // Length doesn't provide operator -, so multiply by -1.
+ opposite *= -1.f;
+ return zoomAdjustedPixelValueForLength(opposite, style);
}
- if (layoutObject->isOutOfFlowPositioned()) {
+ if (layoutObject->isOutOfFlowPositioned() && layoutObject->isBox()) {
// For fixed and absolute positioned elements, the top, left, bottom, and right
// are defined relative to the corresponding sides of the containing block.
LayoutBlock* container = layoutObject->containingBlock();
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/css/getComputedStyle/getComputedStyle-resolved-values-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698