OLD | NEW |
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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 return cssValuePool().createIdentifierValue(CSSValueLuminance); | 155 return cssValuePool().createIdentifierValue(CSSValueLuminance); |
156 } | 156 } |
157 | 157 |
158 ASSERT_NOT_REACHED(); | 158 ASSERT_NOT_REACHED(); |
159 | 159 |
160 return nullptr; | 160 return nullptr; |
161 } | 161 } |
162 | 162 |
163 static CSSValue* valueForPositionOffset(const ComputedStyle& style, CSSPropertyI
D propertyID, const LayoutObject* layoutObject) | 163 static CSSValue* valueForPositionOffset(const ComputedStyle& style, CSSPropertyI
D propertyID, const LayoutObject* layoutObject) |
164 { | 164 { |
165 Length offset, opposite; | 165 Length offset; |
166 switch (propertyID) { | 166 switch (propertyID) { |
167 case CSSPropertyLeft: | 167 case CSSPropertyLeft: |
168 offset = style.left(); | 168 offset = style.left(); |
169 opposite = style.right(); | |
170 break; | 169 break; |
171 case CSSPropertyRight: | 170 case CSSPropertyRight: |
172 offset = style.right(); | 171 offset = style.right(); |
173 opposite = style.left(); | |
174 break; | 172 break; |
175 case CSSPropertyTop: | 173 case CSSPropertyTop: |
176 offset = style.top(); | 174 offset = style.top(); |
177 opposite = style.bottom(); | |
178 break; | 175 break; |
179 case CSSPropertyBottom: | 176 case CSSPropertyBottom: |
180 offset = style.bottom(); | 177 offset = style.bottom(); |
181 opposite = style.top(); | |
182 break; | 178 break; |
183 default: | 179 default: |
184 return nullptr; | 180 return nullptr; |
185 } | 181 } |
186 | 182 |
187 if (offset.hasPercent() && layoutObject && layoutObject->isBox() && layoutOb
ject->isPositioned()) { | 183 if (offset.hasPercent() && layoutObject && layoutObject->isBox() && layoutOb
ject->isPositioned()) { |
188 LayoutUnit containingBlockSize = (propertyID == CSSPropertyLeft || prope
rtyID == CSSPropertyRight) ? | 184 LayoutUnit containingBlockSize = (propertyID == CSSPropertyLeft || prope
rtyID == CSSPropertyRight) ? |
189 toLayoutBox(layoutObject)->containingBlockLogicalWidthForContent() : | 185 toLayoutBox(layoutObject)->containingBlockLogicalWidthForContent() : |
190 toLayoutBox(layoutObject)->containingBlockLogicalHeightForGetCompute
dStyle(); | 186 toLayoutBox(layoutObject)->containingBlockLogicalHeightForGetCompute
dStyle(); |
191 return zoomAdjustedPixelValue(valueForLength(offset, containingBlockSize
), style); | 187 return zoomAdjustedPixelValue(valueForLength(offset, containingBlockSize
), style); |
192 } | 188 } |
193 | 189 if (offset.isAuto()) { |
194 if (offset.isAuto() && layoutObject) { | 190 // FIXME: It's not enough to simply return "auto" values for one offset
if the other side is defined. |
195 // If the property applies to a positioned element and the resolved valu
e of the display | 191 // In other words if left is auto and right is not auto, then left's com
puted value is negative right(). |
196 // property is not none, the resolved value is the used value. | 192 // So we should get the opposite length unit and see if it is auto. |
197 if (layoutObject->isInFlowPositioned()) { | 193 return cssValuePool().createIdentifierValue(CSSValueAuto); |
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. | |
200 if (opposite.isAuto()) | |
201 return cssValuePool().createValue(0, CSSPrimitiveValue::UnitType
::Pixels); | |
202 | |
203 if (opposite.hasPercent()) { | |
204 LayoutUnit containingBlockSize = | |
205 (propertyID == CSSPropertyLeft || propertyID == CSSPropertyR
ight) ? | |
206 toLayoutBox(layoutObject)->containingBlockLogicalWidthForCon
tent() : | |
207 toLayoutBox(layoutObject)->containingBlockLogicalHeightForGe
tComputedStyle(); | |
208 return zoomAdjustedPixelValue(-floatValueForLength(opposite, con
tainingBlockSize), style); | |
209 } | |
210 return zoomAdjustedPixelValue(-opposite.pixels(), style); | |
211 } | |
212 | |
213 if (layoutObject->isOutOfFlowPositioned()) { | |
214 // For fixed and absolute positioned elements, the top, left, bottom
, and right | |
215 // are defined relative to the corresponding sides of the containing
block. | |
216 LayoutBlock* container = layoutObject->containingBlock(); | |
217 const LayoutBox* layoutBox = toLayoutBox(layoutObject); | |
218 | |
219 // 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. | |
221 const LayoutSize clientOffset = | |
222 layoutBox->locationOffset() - LayoutSize(container->clientLeft()
, container->clientTop()); | |
223 LayoutUnit position; | |
224 | |
225 switch (propertyID) { | |
226 case CSSPropertyLeft: | |
227 position = clientOffset.width() - layoutBox->marginLeft(); | |
228 break; | |
229 case CSSPropertyTop: | |
230 position = clientOffset.height() - layoutBox->marginTop(); | |
231 break; | |
232 case CSSPropertyRight: | |
233 position = container->clientWidth() - layoutBox->marginRight() - | |
234 (layoutBox->offsetWidth() + clientOffset.width()); | |
235 break; | |
236 case CSSPropertyBottom: | |
237 position = container->clientHeight() - layoutBox->marginBottom()
- | |
238 (layoutBox->offsetHeight() + clientOffset.height()); | |
239 break; | |
240 default: | |
241 ASSERT_NOT_REACHED(); | |
242 } | |
243 return zoomAdjustedPixelValue(position, style); | |
244 } | |
245 } | 194 } |
246 | 195 |
247 if (offset.isAuto()) | |
248 return cssValuePool().createIdentifierValue(CSSValueAuto); | |
249 | |
250 return zoomAdjustedPixelValueForLength(offset, style); | 196 return zoomAdjustedPixelValueForLength(offset, style); |
251 } | 197 } |
252 | 198 |
253 static CSSBorderImageSliceValue* valueForNinePieceImageSlice(const NinePieceImag
e& image) | 199 static CSSBorderImageSliceValue* valueForNinePieceImageSlice(const NinePieceImag
e& image) |
254 { | 200 { |
255 // Create the slices. | 201 // Create the slices. |
256 CSSPrimitiveValue* top = nullptr; | 202 CSSPrimitiveValue* top = nullptr; |
257 CSSPrimitiveValue* right = nullptr; | 203 CSSPrimitiveValue* right = nullptr; |
258 CSSPrimitiveValue* bottom = nullptr; | 204 CSSPrimitiveValue* bottom = nullptr; |
259 CSSPrimitiveValue* left = nullptr; | 205 CSSPrimitiveValue* left = nullptr; |
(...skipping 2552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2812 case CSSPropertyAll: | 2758 case CSSPropertyAll: |
2813 return nullptr; | 2759 return nullptr; |
2814 default: | 2760 default: |
2815 break; | 2761 break; |
2816 } | 2762 } |
2817 ASSERT_NOT_REACHED(); | 2763 ASSERT_NOT_REACHED(); |
2818 return nullptr; | 2764 return nullptr; |
2819 } | 2765 } |
2820 | 2766 |
2821 } // namespace blink | 2767 } // namespace blink |
OLD | NEW |