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

Side by Side Diff: third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp

Issue 2194933002: [Merge to M52] Fix getComputedStyle for non-box-layout elements (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 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
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004 Zack Rusin <zack@kde.org> 2 * Copyright (C) 2004 Zack Rusin <zack@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
6 * Copyright (C) 2011 Sencha, Inc. All rights reserved. 6 * Copyright (C) 2011 Sencha, Inc. All rights reserved.
7 * Copyright (C) 2015 Google Inc. All rights reserved. 7 * Copyright (C) 2015 Google Inc. 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 Lesser General Public 10 * modify it under the terms of the GNU Lesser General Public
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 193
194 if (offset.isAuto() && layoutObject) { 194 if (offset.isAuto() && layoutObject) {
195 // If the property applies to a positioned element and the resolved valu e of the display 195 // If the property applies to a positioned element and the resolved valu e of the display
196 // property is not none, the resolved value is the used value. 196 // property is not none, the resolved value is the used value.
197 if (layoutObject->isInFlowPositioned()) { 197 if (layoutObject->isInFlowPositioned()) {
198 // If e.g. left is auto and right is not auto, then left's computed value is negative right. 198 // If e.g. left is auto and right is not auto, then left's computed value is negative right.
199 // So we get the opposite length unit and see if it is auto. 199 // So we get the opposite length unit and see if it is auto.
200 if (opposite.isAuto()) 200 if (opposite.isAuto())
201 return cssValuePool().createValue(0, CSSPrimitiveValue::UnitType ::Pixels); 201 return cssValuePool().createValue(0, CSSPrimitiveValue::UnitType ::Pixels);
202 202
203 if (opposite.hasPercent()) { 203 if (opposite.hasPercent() || opposite.isCalculated()) {
204 LayoutUnit containingBlockSize = 204 if (layoutObject->isBox()) {
205 (propertyID == CSSPropertyLeft || propertyID == CSSPropertyR ight) ? 205 LayoutUnit containingBlockSize =
206 toLayoutBox(layoutObject)->containingBlockLogicalWidthForCon tent() : 206 (propertyID == CSSPropertyLeft || propertyID == CSSPrope rtyRight) ?
207 toLayoutBox(layoutObject)->containingBlockLogicalHeightForGe tComputedStyle(); 207 toLayoutBox(layoutObject)->containingBlockLogicalWidthFo rContent() :
208 return zoomAdjustedPixelValue(-floatValueForLength(opposite, con tainingBlockSize), style); 208 toLayoutBox(layoutObject)->containingBlockLogicalHeightF orGetComputedStyle();
209 return zoomAdjustedPixelValue(-floatValueForLength(opposite, containingBlockSize), style);
210 }
211 // FIXME: fall back to auto for position:relative, display:inli ne
212 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
209 } 213 }
210 return zoomAdjustedPixelValue(-opposite.pixels(), style); 214
215 // Length doesn't provide operator -, so multiply by -1.
216 opposite *= -1.f;
217 return zoomAdjustedPixelValueForLength(opposite, style);
211 } 218 }
212 219
213 if (layoutObject->isOutOfFlowPositioned()) { 220 if (layoutObject->isOutOfFlowPositioned() && layoutObject->isBox()) {
214 // For fixed and absolute positioned elements, the top, left, bottom , and right 221 // For fixed and absolute positioned elements, the top, left, bottom , and right
215 // are defined relative to the corresponding sides of the containing block. 222 // are defined relative to the corresponding sides of the containing block.
216 LayoutBlock* container = layoutObject->containingBlock(); 223 LayoutBlock* container = layoutObject->containingBlock();
217 const LayoutBox* layoutBox = toLayoutBox(layoutObject); 224 const LayoutBox* layoutBox = toLayoutBox(layoutObject);
218 225
219 // clientOffset is the distance from this object's border edge to th e container's 226 // clientOffset is the distance from this object's border edge to th e container's
220 // padding edge. Thus it includes margins which we subtract below. 227 // padding edge. Thus it includes margins which we subtract below.
221 const LayoutSize clientOffset = 228 const LayoutSize clientOffset =
222 layoutBox->locationOffset() - LayoutSize(container->clientLeft() , container->clientTop()); 229 layoutBox->locationOffset() - LayoutSize(container->clientLeft() , container->clientTop());
223 LayoutUnit position; 230 LayoutUnit position;
(...skipping 2772 matching lines...) Expand 10 before | Expand all | Expand 10 after
2996 case CSSPropertyAll: 3003 case CSSPropertyAll:
2997 return nullptr; 3004 return nullptr;
2998 default: 3005 default:
2999 break; 3006 break;
3000 } 3007 }
3001 ASSERT_NOT_REACHED(); 3008 ASSERT_NOT_REACHED();
3002 return nullptr; 3009 return nullptr;
3003 } 3010 }
3004 3011
3005 } // namespace blink 3012 } // namespace blink
OLDNEW
« 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