OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) | 2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
reserved. |
4 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. | 4 * Copyright (C) 2011 Adobe Systems Incorporated. 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 { | 187 { |
188 if ((!oldStyle && newStyle) || (oldStyle && !newStyle)) | 188 if ((!oldStyle && newStyle) || (oldStyle && !newStyle)) |
189 return Reattach; | 189 return Reattach; |
190 | 190 |
191 if (!oldStyle && !newStyle) | 191 if (!oldStyle && !newStyle) |
192 return NoChange; | 192 return NoChange; |
193 | 193 |
194 if (oldStyle->display() != newStyle->display() | 194 if (oldStyle->display() != newStyle->display() |
195 || oldStyle->hasPseudoStyle(PseudoIdFirstLetter) != newStyle->hasPseudoS
tyle(PseudoIdFirstLetter) | 195 || oldStyle->hasPseudoStyle(PseudoIdFirstLetter) != newStyle->hasPseudoS
tyle(PseudoIdFirstLetter) |
196 || !oldStyle->contentDataEquivalent(newStyle) | 196 || !oldStyle->contentDataEquivalent(newStyle) |
197 || oldStyle->hasTextCombine() != newStyle->hasTextCombine() | 197 || oldStyle->hasTextCombine() != newStyle->hasTextCombine()) |
198 || oldStyle->justifyItems() != newStyle->justifyItems()) // TODO (lajava
): We must avoid this Reattach. | |
199 return Reattach; | 198 return Reattach; |
200 | 199 |
201 if (!oldStyle->inheritedEqual(*newStyle) | 200 if (!oldStyle->inheritedEqual(*newStyle) |
202 || !oldStyle->loadingCustomFontsEqual(*newStyle)) | 201 || !oldStyle->loadingCustomFontsEqual(*newStyle) |
| 202 || oldStyle->alignItems() != newStyle->alignItems() |
| 203 || oldStyle->justifyItems() != newStyle->justifyItems()) |
203 return Inherit; | 204 return Inherit; |
204 | 205 |
205 if (*oldStyle == *newStyle) | 206 if (*oldStyle == *newStyle) |
206 return diffPseudoStyles(*oldStyle, *newStyle); | 207 return diffPseudoStyles(*oldStyle, *newStyle); |
207 | 208 |
208 if (oldStyle->hasExplicitlyInheritedProperties()) | 209 if (oldStyle->hasExplicitlyInheritedProperties()) |
209 return Inherit; | 210 return Inherit; |
210 | 211 |
211 return NoInherit; | 212 return NoInherit; |
212 } | 213 } |
213 | 214 |
214 ItemPosition ComputedStyle::resolveAlignment(const ComputedStyle& parentStyle, c
onst ComputedStyle& childStyle, ItemPosition resolvedAutoPositionForLayoutObject
) | 215 StyleSelfAlignmentData resolvedSelfAlignment(const StyleSelfAlignmentData& value
, ItemPosition normalValueBehavior) |
215 { | 216 { |
216 // The auto keyword computes to the parent's align-items computed value, or
to "stretch", if not set or "auto". | 217 // To avoid needing to copy the RareNonInheritedData, we repurpose the 'auto
' flag to not just mean 'auto' prior to running the StyleAdjuster but also mean
'normal' after running it. |
217 if (childStyle.alignSelfPosition() == ItemPositionAuto) | 218 if (value.position() == ItemPositionNormal || value.position() == ItemPositi
onAuto) |
218 return (parentStyle.alignItemsPosition() == ItemPositionAuto) ? resolved
AutoPositionForLayoutObject : parentStyle.alignItemsPosition(); | 219 return {normalValueBehavior, OverflowAlignmentDefault}; |
219 return childStyle.alignSelfPosition(); | 220 return value; |
220 } | 221 } |
221 | 222 |
222 const StyleSelfAlignmentData ComputedStyle::resolvedAlignment(const ComputedStyl
e& parentStyle, ItemPosition resolvedAutoPositionForLayoutObject) const | 223 StyleSelfAlignmentData ComputedStyle::resolvedAlignItems(ItemPosition normalValu
eBehaviour) const |
223 { | 224 { |
224 // The auto keyword computes to the parent's align-items computed value, or
to "stretch", if not set or "auto". | 225 // We will return the behaviour of 'normal' value if needed, which is specif
ic of each layout model. |
225 if (alignSelfPosition() == ItemPositionAuto) { | 226 return resolvedSelfAlignment(alignItems(), normalValueBehaviour); |
226 if (parentStyle.alignItemsPosition() == ItemPositionAuto) | |
227 return {resolvedAutoPositionForLayoutObject, OverflowAlignmentDefaul
t}; | |
228 return parentStyle.alignItems(); | |
229 } | |
230 return alignSelf(); | |
231 } | 227 } |
232 | 228 |
233 ItemPosition ComputedStyle::resolveJustification(const ComputedStyle& parentStyl
e, const ComputedStyle& childStyle, ItemPosition resolvedAutoPositionForLayoutOb
ject) | 229 StyleSelfAlignmentData ComputedStyle::resolvedAlignSelf(ItemPosition normalValue
Behaviour, const ComputedStyle* parentStyle) const |
234 { | 230 { |
235 if (childStyle.justifySelfPosition() == ItemPositionAuto) | 231 // We will return the behaviour of 'normal' value if needed, which is specif
ic of each layout model. |
236 return (parentStyle.justifyItemsPosition() == ItemPositionAuto) ? resolv
edAutoPositionForLayoutObject : parentStyle.justifyItemsPosition(); | 232 if (!parentStyle || alignSelfPosition() != ItemPositionAuto) |
237 return childStyle.justifySelfPosition(); | 233 return resolvedSelfAlignment(alignSelf(), normalValueBehaviour); |
| 234 |
| 235 // We shouldn't need to resolve any 'auto' value in post-adjusment ComputedS
tyle, but some layout models |
| 236 // can generate anonymous boxes that may need 'auto' value resolution during
layout. |
| 237 // The 'auto' keyword computes to the parent's align-items computed value. |
| 238 return parentStyle->resolvedAlignItems(normalValueBehaviour); |
| 239 } |
| 240 |
| 241 StyleSelfAlignmentData ComputedStyle::resolvedJustifyItems(ItemPosition normalVa
lueBehaviour) const |
| 242 { |
| 243 // We will return the behaviour of 'normal' value if needed, which is specif
ic of each layout model. |
| 244 return resolvedSelfAlignment(justifyItems(), normalValueBehaviour); |
| 245 } |
| 246 |
| 247 StyleSelfAlignmentData ComputedStyle::resolvedJustifySelf(ItemPosition normalVal
ueBehaviour, const ComputedStyle* parentStyle) const |
| 248 { |
| 249 // We will return the behaviour of 'normal' value if needed, which is specif
ic of each layout model. |
| 250 if (!parentStyle || justifySelfPosition() != ItemPositionAuto) |
| 251 return resolvedSelfAlignment(justifySelf(), normalValueBehaviour); |
| 252 |
| 253 // We shouldn't need to resolve any 'auto' value in post-adjusment ComputedS
tyle, but some layout models |
| 254 // can generate anonymous boxes that may need 'auto' value resolution during
layout. |
| 255 // The auto keyword computes to the parent's justify-items computed value. |
| 256 return parentStyle->resolvedJustifyItems(normalValueBehaviour); |
238 } | 257 } |
239 | 258 |
240 static inline ContentPosition resolvedContentAlignmentPosition(const StyleConten
tAlignmentData& value, const StyleContentAlignmentData& normalValueBehavior) | 259 static inline ContentPosition resolvedContentAlignmentPosition(const StyleConten
tAlignmentData& value, const StyleContentAlignmentData& normalValueBehavior) |
241 { | 260 { |
242 return (value.position() == ContentPositionNormal && value.distribution() ==
ContentDistributionDefault) ? normalValueBehavior.position() : value.position()
; | 261 return (value.position() == ContentPositionNormal && value.distribution() ==
ContentDistributionDefault) ? normalValueBehavior.position() : value.position()
; |
243 } | 262 } |
244 | 263 |
245 static inline ContentDistributionType resolvedContentAlignmentDistribution(const
StyleContentAlignmentData& value, const StyleContentAlignmentData& normalValueB
ehavior) | 264 static inline ContentDistributionType resolvedContentAlignmentDistribution(const
StyleContentAlignmentData& value, const StyleContentAlignmentData& normalValueB
ehavior) |
246 { | 265 { |
247 return (value.position() == ContentPositionNormal && value.distribution() ==
ContentDistributionDefault) ? normalValueBehavior.distribution() : value.distri
bution(); | 266 return (value.position() == ContentPositionNormal && value.distribution() ==
ContentDistributionDefault) ? normalValueBehavior.distribution() : value.distri
bution(); |
(...skipping 1718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1966 if (value < 0) | 1985 if (value < 0) |
1967 fvalue -= 0.5f; | 1986 fvalue -= 0.5f; |
1968 else | 1987 else |
1969 fvalue += 0.5f; | 1988 fvalue += 0.5f; |
1970 } | 1989 } |
1971 | 1990 |
1972 return roundForImpreciseConversion<int>(fvalue / zoomFactor); | 1991 return roundForImpreciseConversion<int>(fvalue / zoomFactor); |
1973 } | 1992 } |
1974 | 1993 |
1975 } // namespace blink | 1994 } // namespace blink |
OLD | NEW |