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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 | 57 |
58 namespace blink { | 58 namespace blink { |
59 | 59 |
60 struct SameSizeAsBorderValue { | 60 struct SameSizeAsBorderValue { |
61 RGBA32 m_color; | 61 RGBA32 m_color; |
62 unsigned m_width; | 62 unsigned m_width; |
63 }; | 63 }; |
64 | 64 |
65 static_assert(sizeof(BorderValue) == sizeof(SameSizeAsBorderValue), "BorderValue
should stay small"); | 65 static_assert(sizeof(BorderValue) == sizeof(SameSizeAsBorderValue), "BorderValue
should stay small"); |
66 | 66 |
| 67 // Since different compilers/architectures pack ComputedStyle differently, |
| 68 // re-create the same structure for an accurate size comparison. |
67 struct SameSizeAsComputedStyle : public RefCounted<SameSizeAsComputedStyle> { | 69 struct SameSizeAsComputedStyle : public RefCounted<SameSizeAsComputedStyle> { |
68 void* dataRefs[7]; | 70 void* dataRefs[7]; |
69 void* ownPtrs[1]; | 71 void* ownPtrs[1]; |
70 void* dataRefSvgStyle; | 72 void* dataRefSvgStyle; |
71 | 73 |
72 struct InheritedData { | 74 struct InheritedData { |
73 unsigned m_bitfields[2]; | 75 unsigned m_bitfields[2]; |
74 } m_inheritedData; | 76 } m_inheritedData; |
75 | 77 |
76 struct NonInheritedData { | 78 struct NonInheritedData { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 if (!oldStyle && !newStyle) | 192 if (!oldStyle && !newStyle) |
191 return NoChange; | 193 return NoChange; |
192 | 194 |
193 if (oldStyle->display() != newStyle->display() | 195 if (oldStyle->display() != newStyle->display() |
194 || oldStyle->hasPseudoStyle(PseudoIdFirstLetter) != newStyle->hasPseudoS
tyle(PseudoIdFirstLetter) | 196 || oldStyle->hasPseudoStyle(PseudoIdFirstLetter) != newStyle->hasPseudoS
tyle(PseudoIdFirstLetter) |
195 || !oldStyle->contentDataEquivalent(newStyle) | 197 || !oldStyle->contentDataEquivalent(newStyle) |
196 || oldStyle->hasTextCombine() != newStyle->hasTextCombine() | 198 || oldStyle->hasTextCombine() != newStyle->hasTextCombine() |
197 || oldStyle->justifyItems() != newStyle->justifyItems()) // TODO (lajava
): We must avoid this Reattach. | 199 || oldStyle->justifyItems() != newStyle->justifyItems()) // TODO (lajava
): We must avoid this Reattach. |
198 return Reattach; | 200 return Reattach; |
199 | 201 |
200 if (!oldStyle->inheritedEqual(*newStyle) | 202 bool independentEqual = oldStyle->independentInheritedEqual(*newStyle); |
201 || !oldStyle->loadingCustomFontsEqual(*newStyle)) | 203 bool nonIndependentEqual = oldStyle->nonIndependentInheritedEqual(*newStyle)
; |
| 204 if (!independentEqual || !nonIndependentEqual) { |
| 205 if (nonIndependentEqual && !oldStyle->hasExplicitlyInheritedProperties()
) |
| 206 return IndependentInherit; |
| 207 return Inherit; |
| 208 } |
| 209 |
| 210 if (!oldStyle->loadingCustomFontsEqual(*newStyle)) |
202 return Inherit; | 211 return Inherit; |
203 | 212 |
204 if (*oldStyle == *newStyle) | 213 if (*oldStyle == *newStyle) |
205 return diffPseudoStyles(*oldStyle, *newStyle); | 214 return diffPseudoStyles(*oldStyle, *newStyle); |
206 | 215 |
207 if (oldStyle->hasExplicitlyInheritedProperties()) | 216 if (oldStyle->hasExplicitlyInheritedProperties()) |
208 return Inherit; | 217 return Inherit; |
209 | 218 |
210 return NoInherit; | 219 return NoInherit; |
211 } | 220 } |
212 | 221 |
| 222 // TODO(sashab): Generate this function. |
| 223 void ComputedStyle::propagateIndependentInheritedProperties(const ComputedStyle&
parentStyle) |
| 224 { |
| 225 if (m_nonInheritedData.m_isPointerEventsInherited) |
| 226 setPointerEvents(parentStyle.pointerEvents()); |
| 227 if (m_nonInheritedData.m_isVisibilityInherited) |
| 228 setVisibility(parentStyle.visibility()); |
| 229 } |
| 230 |
213 ItemPosition ComputedStyle::resolveAlignment(const ComputedStyle& parentStyle, c
onst ComputedStyle& childStyle, ItemPosition resolvedAutoPositionForLayoutObject
) | 231 ItemPosition ComputedStyle::resolveAlignment(const ComputedStyle& parentStyle, c
onst ComputedStyle& childStyle, ItemPosition resolvedAutoPositionForLayoutObject
) |
214 { | 232 { |
215 // The auto keyword computes to the parent's align-items computed value, or
to "stretch", if not set or "auto". | 233 // The auto keyword computes to the parent's align-items computed value, or
to "stretch", if not set or "auto". |
216 if (childStyle.alignSelfPosition() == ItemPositionAuto) | 234 if (childStyle.alignSelfPosition() == ItemPositionAuto) |
217 return (parentStyle.alignItemsPosition() == ItemPositionAuto) ? resolved
AutoPositionForLayoutObject : parentStyle.alignItemsPosition(); | 235 return (parentStyle.alignItemsPosition() == ItemPositionAuto) ? resolved
AutoPositionForLayoutObject : parentStyle.alignItemsPosition(); |
218 return childStyle.alignSelfPosition(); | 236 return childStyle.alignSelfPosition(); |
219 } | 237 } |
220 | 238 |
221 const StyleSelfAlignmentData ComputedStyle::resolvedAlignment(const ComputedStyl
e& parentStyle, ItemPosition resolvedAutoPositionForLayoutObject) const | 239 const StyleSelfAlignmentData ComputedStyle::resolvedAlignment(const ComputedStyl
e& parentStyle, ItemPosition resolvedAutoPositionForLayoutObject) const |
222 { | 240 { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 // properties here, but the affectedBy flags will be set differently based o
n | 353 // properties here, but the affectedBy flags will be set differently based o
n |
336 // the matching order of the :-webkit-any components. | 354 // the matching order of the :-webkit-any components. |
337 // | 355 // |
338 // m_nonInheritedData.m_emptyState | 356 // m_nonInheritedData.m_emptyState |
339 // m_nonInheritedData.m_affectedByFocus | 357 // m_nonInheritedData.m_affectedByFocus |
340 // m_nonInheritedData.m_affectedByHover | 358 // m_nonInheritedData.m_affectedByHover |
341 // m_nonInheritedData.m_affectedByActive | 359 // m_nonInheritedData.m_affectedByActive |
342 // m_nonInheritedData.m_affectedByDrag | 360 // m_nonInheritedData.m_affectedByDrag |
343 // m_nonInheritedData.m_isLink | 361 // m_nonInheritedData.m_isLink |
344 | 362 |
| 363 // Any properties that are inherited on a style are also inherited on elemen
ts |
| 364 // that share this style. |
| 365 m_nonInheritedData.m_isPointerEventsInherited = other.m_nonInheritedData.m_i
sPointerEventsInherited; |
| 366 m_nonInheritedData.m_isVisibilityInherited = other.m_nonInheritedData.m_isVi
sibilityInherited; |
| 367 |
345 if (m_svgStyle != other.m_svgStyle) | 368 if (m_svgStyle != other.m_svgStyle) |
346 m_svgStyle.access()->copyNonInheritedFromCached(other.m_svgStyle.get()); | 369 m_svgStyle.access()->copyNonInheritedFromCached(other.m_svgStyle.get()); |
347 DCHECK_EQ(zoom(), initialZoom()); | 370 DCHECK_EQ(zoom(), initialZoom()); |
348 } | 371 } |
349 | 372 |
350 bool ComputedStyle::operator==(const ComputedStyle& o) const | 373 bool ComputedStyle::operator==(const ComputedStyle& o) const |
351 { | 374 { |
352 return inheritedEqual(o) | 375 return inheritedEqual(o) |
353 && nonInheritedEqual(o); | 376 && nonInheritedEqual(o); |
354 } | 377 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 ComputedStyle* pseudoStyle = m_cachedPseudoStyles->at(i).get(); | 437 ComputedStyle* pseudoStyle = m_cachedPseudoStyles->at(i).get(); |
415 if (pseudoStyle->styleType() == pid) { | 438 if (pseudoStyle->styleType() == pid) { |
416 m_cachedPseudoStyles->remove(i); | 439 m_cachedPseudoStyles->remove(i); |
417 return; | 440 return; |
418 } | 441 } |
419 } | 442 } |
420 } | 443 } |
421 | 444 |
422 bool ComputedStyle::inheritedEqual(const ComputedStyle& other) const | 445 bool ComputedStyle::inheritedEqual(const ComputedStyle& other) const |
423 { | 446 { |
424 return m_inheritedData == other.m_inheritedData | 447 return independentInheritedEqual(other) |
| 448 && nonIndependentInheritedEqual(other); |
| 449 } |
| 450 |
| 451 bool ComputedStyle::independentInheritedEqual(const ComputedStyle& other) const |
| 452 { |
| 453 return m_inheritedData.compareEqualIndependent(other.m_inheritedData); |
| 454 } |
| 455 |
| 456 bool ComputedStyle::nonIndependentInheritedEqual(const ComputedStyle& other) con
st |
| 457 { |
| 458 return m_inheritedData.compareEqualNonIndependent(other.m_inheritedData) |
425 && m_styleInheritedData == other.m_styleInheritedData | 459 && m_styleInheritedData == other.m_styleInheritedData |
426 && m_svgStyle->inheritedEqual(*other.m_svgStyle) | 460 && m_svgStyle->inheritedEqual(*other.m_svgStyle) |
427 && m_rareInheritedData == other.m_rareInheritedData; | 461 && m_rareInheritedData == other.m_rareInheritedData; |
428 } | 462 } |
429 | 463 |
430 bool ComputedStyle::loadingCustomFontsEqual(const ComputedStyle& other) const | 464 bool ComputedStyle::loadingCustomFontsEqual(const ComputedStyle& other) const |
431 { | 465 { |
432 return font().loadingCustomFonts() == other.font().loadingCustomFonts(); | 466 return font().loadingCustomFonts() == other.font().loadingCustomFonts(); |
433 } | 467 } |
434 | 468 |
(...skipping 1523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1958 if (value < 0) | 1992 if (value < 0) |
1959 fvalue -= 0.5f; | 1993 fvalue -= 0.5f; |
1960 else | 1994 else |
1961 fvalue += 0.5f; | 1995 fvalue += 0.5f; |
1962 } | 1996 } |
1963 | 1997 |
1964 return roundForImpreciseConversion<int>(fvalue / zoomFactor); | 1998 return roundForImpreciseConversion<int>(fvalue / zoomFactor); |
1965 } | 1999 } |
1966 | 2000 |
1967 } // namespace blink | 2001 } // namespace blink |
OLD | NEW |