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. | |
69 struct SameSizeAsComputedStyle : public RefCounted<SameSizeAsComputedStyle> { | 67 struct SameSizeAsComputedStyle : public RefCounted<SameSizeAsComputedStyle> { |
70 void* dataRefs[7]; | 68 void* dataRefs[7]; |
71 void* ownPtrs[1]; | 69 void* ownPtrs[1]; |
72 void* dataRefSvgStyle; | 70 void* dataRefSvgStyle; |
73 | 71 |
74 struct InheritedData { | 72 struct InheritedData { |
75 unsigned m_bitfields[2]; | 73 unsigned m_bitfields[2]; |
76 } m_inheritedData; | 74 } m_inheritedData; |
77 | 75 |
78 struct NonInheritedData { | 76 struct NonInheritedData { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 if (!oldStyle && !newStyle) | 190 if (!oldStyle && !newStyle) |
193 return NoChange; | 191 return NoChange; |
194 | 192 |
195 if (oldStyle->display() != newStyle->display() | 193 if (oldStyle->display() != newStyle->display() |
196 || oldStyle->hasPseudoStyle(PseudoIdFirstLetter) != newStyle->hasPseudoS
tyle(PseudoIdFirstLetter) | 194 || oldStyle->hasPseudoStyle(PseudoIdFirstLetter) != newStyle->hasPseudoS
tyle(PseudoIdFirstLetter) |
197 || !oldStyle->contentDataEquivalent(newStyle) | 195 || !oldStyle->contentDataEquivalent(newStyle) |
198 || oldStyle->hasTextCombine() != newStyle->hasTextCombine() | 196 || oldStyle->hasTextCombine() != newStyle->hasTextCombine() |
199 || oldStyle->justifyItems() != newStyle->justifyItems()) // TODO (lajava
): We must avoid this Reattach. | 197 || oldStyle->justifyItems() != newStyle->justifyItems()) // TODO (lajava
): We must avoid this Reattach. |
200 return Reattach; | 198 return Reattach; |
201 | 199 |
202 bool independentEqual = oldStyle->independentInheritedEqual(*newStyle); | 200 if (!oldStyle->inheritedEqual(*newStyle) |
203 bool nonIndependentEqual = oldStyle->nonIndependentInheritedEqual(*newStyle)
; | 201 || !oldStyle->loadingCustomFontsEqual(*newStyle)) |
204 if (!independentEqual || !nonIndependentEqual) { | |
205 if (nonIndependentEqual && !oldStyle->hasExplicitlyInheritedProperties()
) | |
206 return IndependentInherit; | |
207 return Inherit; | |
208 } | |
209 | |
210 if (!oldStyle->loadingCustomFontsEqual(*newStyle)) | |
211 return Inherit; | 202 return Inherit; |
212 | 203 |
213 if (*oldStyle == *newStyle) | 204 if (*oldStyle == *newStyle) |
214 return diffPseudoStyles(*oldStyle, *newStyle); | 205 return diffPseudoStyles(*oldStyle, *newStyle); |
215 | 206 |
216 if (oldStyle->hasExplicitlyInheritedProperties()) | 207 if (oldStyle->hasExplicitlyInheritedProperties()) |
217 return Inherit; | 208 return Inherit; |
218 | 209 |
219 return NoInherit; | 210 return NoInherit; |
220 } | 211 } |
221 | 212 |
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 | |
231 ItemPosition ComputedStyle::resolveAlignment(const ComputedStyle& parentStyle, c
onst ComputedStyle& childStyle, ItemPosition resolvedAutoPositionForLayoutObject
) | 213 ItemPosition ComputedStyle::resolveAlignment(const ComputedStyle& parentStyle, c
onst ComputedStyle& childStyle, ItemPosition resolvedAutoPositionForLayoutObject
) |
232 { | 214 { |
233 // The auto keyword computes to the parent's align-items computed value, or
to "stretch", if not set or "auto". | 215 // The auto keyword computes to the parent's align-items computed value, or
to "stretch", if not set or "auto". |
234 if (childStyle.alignSelfPosition() == ItemPositionAuto) | 216 if (childStyle.alignSelfPosition() == ItemPositionAuto) |
235 return (parentStyle.alignItemsPosition() == ItemPositionAuto) ? resolved
AutoPositionForLayoutObject : parentStyle.alignItemsPosition(); | 217 return (parentStyle.alignItemsPosition() == ItemPositionAuto) ? resolved
AutoPositionForLayoutObject : parentStyle.alignItemsPosition(); |
236 return childStyle.alignSelfPosition(); | 218 return childStyle.alignSelfPosition(); |
237 } | 219 } |
238 | 220 |
239 const StyleSelfAlignmentData ComputedStyle::resolvedAlignment(const ComputedStyl
e& parentStyle, ItemPosition resolvedAutoPositionForLayoutObject) const | 221 const StyleSelfAlignmentData ComputedStyle::resolvedAlignment(const ComputedStyl
e& parentStyle, ItemPosition resolvedAutoPositionForLayoutObject) const |
240 { | 222 { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 // properties here, but the affectedBy flags will be set differently based o
n | 335 // properties here, but the affectedBy flags will be set differently based o
n |
354 // the matching order of the :-webkit-any components. | 336 // the matching order of the :-webkit-any components. |
355 // | 337 // |
356 // m_nonInheritedData.m_emptyState | 338 // m_nonInheritedData.m_emptyState |
357 // m_nonInheritedData.m_affectedByFocus | 339 // m_nonInheritedData.m_affectedByFocus |
358 // m_nonInheritedData.m_affectedByHover | 340 // m_nonInheritedData.m_affectedByHover |
359 // m_nonInheritedData.m_affectedByActive | 341 // m_nonInheritedData.m_affectedByActive |
360 // m_nonInheritedData.m_affectedByDrag | 342 // m_nonInheritedData.m_affectedByDrag |
361 // m_nonInheritedData.m_isLink | 343 // m_nonInheritedData.m_isLink |
362 | 344 |
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 | |
368 if (m_svgStyle != other.m_svgStyle) | 345 if (m_svgStyle != other.m_svgStyle) |
369 m_svgStyle.access()->copyNonInheritedFromCached(other.m_svgStyle.get()); | 346 m_svgStyle.access()->copyNonInheritedFromCached(other.m_svgStyle.get()); |
370 DCHECK_EQ(zoom(), initialZoom()); | 347 DCHECK_EQ(zoom(), initialZoom()); |
371 } | 348 } |
372 | 349 |
373 bool ComputedStyle::operator==(const ComputedStyle& o) const | 350 bool ComputedStyle::operator==(const ComputedStyle& o) const |
374 { | 351 { |
375 return inheritedEqual(o) | 352 return inheritedEqual(o) |
376 && nonInheritedEqual(o); | 353 && nonInheritedEqual(o); |
377 } | 354 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 ComputedStyle* pseudoStyle = m_cachedPseudoStyles->at(i).get(); | 414 ComputedStyle* pseudoStyle = m_cachedPseudoStyles->at(i).get(); |
438 if (pseudoStyle->styleType() == pid) { | 415 if (pseudoStyle->styleType() == pid) { |
439 m_cachedPseudoStyles->remove(i); | 416 m_cachedPseudoStyles->remove(i); |
440 return; | 417 return; |
441 } | 418 } |
442 } | 419 } |
443 } | 420 } |
444 | 421 |
445 bool ComputedStyle::inheritedEqual(const ComputedStyle& other) const | 422 bool ComputedStyle::inheritedEqual(const ComputedStyle& other) const |
446 { | 423 { |
447 return independentInheritedEqual(other) | 424 return m_inheritedData == other.m_inheritedData |
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) | |
459 && m_styleInheritedData == other.m_styleInheritedData | 425 && m_styleInheritedData == other.m_styleInheritedData |
460 && m_svgStyle->inheritedEqual(*other.m_svgStyle) | 426 && m_svgStyle->inheritedEqual(*other.m_svgStyle) |
461 && m_rareInheritedData == other.m_rareInheritedData; | 427 && m_rareInheritedData == other.m_rareInheritedData; |
462 } | 428 } |
463 | 429 |
464 bool ComputedStyle::loadingCustomFontsEqual(const ComputedStyle& other) const | 430 bool ComputedStyle::loadingCustomFontsEqual(const ComputedStyle& other) const |
465 { | 431 { |
466 return font().loadingCustomFonts() == other.font().loadingCustomFonts(); | 432 return font().loadingCustomFonts() == other.font().loadingCustomFonts(); |
467 } | 433 } |
468 | 434 |
(...skipping 1523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1992 if (value < 0) | 1958 if (value < 0) |
1993 fvalue -= 0.5f; | 1959 fvalue -= 0.5f; |
1994 else | 1960 else |
1995 fvalue += 0.5f; | 1961 fvalue += 0.5f; |
1996 } | 1962 } |
1997 | 1963 |
1998 return roundForImpreciseConversion<int>(fvalue / zoomFactor); | 1964 return roundForImpreciseConversion<int>(fvalue / zoomFactor); |
1999 } | 1965 } |
2000 | 1966 |
2001 } // namespace blink | 1967 } // namespace blink |
OLD | NEW |