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

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

Issue 2870983002: Update return value of getComputedStyle for sticky elements (Closed)
Patch Set: Created 3 years, 7 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) 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. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 5 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
6 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> 6 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
7 * Copyright (C) 2011 Sencha, Inc. All rights reserved. 7 * Copyright (C) 2011 Sencha, Inc. All rights reserved.
8 * Copyright (C) 2015 Google Inc. All rights reserved. 8 * Copyright (C) 2015 Google Inc. All rights reserved.
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 (property_id == CSSPropertyLeft || property_id == CSSPropertyRight) 215 (property_id == CSSPropertyLeft || property_id == CSSPropertyRight)
216 ? ToLayoutBox(layout_object) 216 ? ToLayoutBox(layout_object)
217 ->ContainingBlockLogicalWidthForContent() 217 ->ContainingBlockLogicalWidthForContent()
218 : ToLayoutBox(layout_object) 218 : ToLayoutBox(layout_object)
219 ->ContainingBlockLogicalHeightForGetComputedStyle(); 219 ->ContainingBlockLogicalHeightForGetComputedStyle();
220 return ZoomAdjustedPixelValue(ValueForLength(offset, containing_block_size), 220 return ZoomAdjustedPixelValue(ValueForLength(offset, containing_block_size),
221 style); 221 style);
222 } 222 }
223 223
224 if (offset.IsAuto() && layout_object) { 224 if (offset.IsAuto() && layout_object) {
225 // "top:auto" and "top:0px" have very different meaning for sticky elements.
226 // Therefore "auto" should be returned regardless the opposite.
flackr 2017/05/09 20:26:34 nit: Add a link to the bug for reference.
yigu 2017/05/09 20:43:58 Done.
227 if (layout_object->IsStickyPositioned())
228 return CSSIdentifierValue::Create(CSSValueAuto);
229
225 // If the property applies to a positioned element and the resolved value of 230 // If the property applies to a positioned element and the resolved value of
226 // the display property is not none, the resolved value is the used value. 231 // the display property is not none, the resolved value is the used value.
227 if (layout_object->IsInFlowPositioned()) { 232 if (layout_object->IsInFlowPositioned()) {
flackr 2017/05/09 20:26:35 Sticky is in flow positioned, let's change this co
yigu 2017/05/09 20:43:58 Done.
228 // If e.g. left is auto and right is not auto, then left's computed value 233 // If e.g. left is auto and right is not auto, then left's computed value
229 // is negative right. So we get the opposite length unit and see if it is 234 // is negative right. So we get the opposite length unit and see if it is
230 // auto. 235 // auto.
231 if (opposite.IsAuto()) 236 if (opposite.IsAuto())
232 return CSSPrimitiveValue::Create(0, 237 return CSSPrimitiveValue::Create(0,
233 CSSPrimitiveValue::UnitType::kPixels); 238 CSSPrimitiveValue::UnitType::kPixels);
234 239
235 if (opposite.IsPercentOrCalc()) { 240 if (opposite.IsPercentOrCalc()) {
236 if (layout_object->IsBox()) { 241 if (layout_object->IsBox()) {
237 LayoutUnit containing_block_size = 242 LayoutUnit containing_block_size =
(...skipping 3507 matching lines...) Expand 10 before | Expand all | Expand 10 after
3745 case CSSPropertyAll: 3750 case CSSPropertyAll:
3746 return nullptr; 3751 return nullptr;
3747 default: 3752 default:
3748 break; 3753 break;
3749 } 3754 }
3750 NOTREACHED(); 3755 NOTREACHED();
3751 return nullptr; 3756 return nullptr;
3752 } 3757 }
3753 3758
3754 } // namespace blink 3759 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698