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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 namespace blink { | 59 namespace blink { |
60 | 60 |
61 struct SameSizeAsBorderValue { | 61 struct SameSizeAsBorderValue { |
62 RGBA32 m_color; | 62 RGBA32 m_color; |
63 unsigned m_width; | 63 unsigned m_width; |
64 }; | 64 }; |
65 | 65 |
66 static_assert(sizeof(BorderValue) == sizeof(SameSizeAsBorderValue), "BorderValue
should stay small"); | 66 static_assert(sizeof(BorderValue) == sizeof(SameSizeAsBorderValue), "BorderValue
should stay small"); |
67 | 67 |
| 68 // Since different compilers/architectures pack ComputedStyle differently, |
| 69 // re-create the same structure for an accurate size comparison. |
68 struct SameSizeAsComputedStyle : public RefCounted<SameSizeAsComputedStyle> { | 70 struct SameSizeAsComputedStyle : public RefCounted<SameSizeAsComputedStyle> { |
69 void* dataRefs[7]; | 71 void* dataRefs[7]; |
70 void* ownPtrs[1]; | 72 void* ownPtrs[1]; |
71 void* dataRefSvgStyle; | 73 void* dataRefSvgStyle; |
72 | 74 |
73 struct InheritedData { | 75 struct InheritedData { |
74 unsigned m_bitfields[2]; | 76 unsigned m_bitfields[2]; |
75 } m_inheritedData; | 77 } m_inheritedData; |
76 | 78 |
77 struct NonInheritedData { | 79 struct NonInheritedData { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 | 192 |
191 if (!oldStyle && !newStyle) | 193 if (!oldStyle && !newStyle) |
192 return NoChange; | 194 return NoChange; |
193 | 195 |
194 if (oldStyle->display() != newStyle->display() | 196 if (oldStyle->display() != newStyle->display() |
195 || oldStyle->hasPseudoStyle(PseudoIdFirstLetter) != newStyle->hasPseudoS
tyle(PseudoIdFirstLetter) | 197 || oldStyle->hasPseudoStyle(PseudoIdFirstLetter) != newStyle->hasPseudoS
tyle(PseudoIdFirstLetter) |
196 || !oldStyle->contentDataEquivalent(newStyle) | 198 || !oldStyle->contentDataEquivalent(newStyle) |
197 || oldStyle->hasTextCombine() != newStyle->hasTextCombine()) | 199 || oldStyle->hasTextCombine() != newStyle->hasTextCombine()) |
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 || oldStyle->alignItems() != newStyle->alignItems() | 211 || oldStyle->alignItems() != newStyle->alignItems() |
203 || oldStyle->justifyItems() != newStyle->justifyItems()) | 212 || oldStyle->justifyItems() != newStyle->justifyItems()) |
204 return Inherit; | 213 return Inherit; |
205 | 214 |
206 if (*oldStyle == *newStyle) | 215 if (*oldStyle == *newStyle) |
207 return diffPseudoStyles(*oldStyle, *newStyle); | 216 return diffPseudoStyles(*oldStyle, *newStyle); |
208 | 217 |
209 if (oldStyle->hasExplicitlyInheritedProperties()) | 218 if (oldStyle->hasExplicitlyInheritedProperties()) |
210 return Inherit; | 219 return Inherit; |
211 | 220 |
212 return NoInherit; | 221 return NoInherit; |
213 } | 222 } |
214 | 223 |
| 224 // TODO(sashab): Generate this function. |
| 225 void ComputedStyle::propagateIndependentInheritedProperties(const ComputedStyle&
parentStyle) |
| 226 { |
| 227 if (m_nonInheritedData.m_isPointerEventsInherited) |
| 228 setPointerEvents(parentStyle.pointerEvents()); |
| 229 if (m_nonInheritedData.m_isVisibilityInherited) |
| 230 setVisibility(parentStyle.visibility()); |
| 231 } |
| 232 |
215 StyleSelfAlignmentData resolvedSelfAlignment(const StyleSelfAlignmentData& value
, ItemPosition normalValueBehavior) | 233 StyleSelfAlignmentData resolvedSelfAlignment(const StyleSelfAlignmentData& value
, ItemPosition normalValueBehavior) |
216 { | 234 { |
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. | 235 // 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. |
218 if (value.position() == ItemPositionNormal || value.position() == ItemPositi
onAuto) | 236 if (value.position() == ItemPositionNormal || value.position() == ItemPositi
onAuto) |
219 return {normalValueBehavior, OverflowAlignmentDefault}; | 237 return {normalValueBehavior, OverflowAlignmentDefault}; |
220 return value; | 238 return value; |
221 } | 239 } |
222 | 240 |
223 StyleSelfAlignmentData ComputedStyle::resolvedAlignItems(ItemPosition normalValu
eBehaviour) const | 241 StyleSelfAlignmentData ComputedStyle::resolvedAlignItems(ItemPosition normalValu
eBehaviour) const |
224 { | 242 { |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 // properties here, but the affectedBy flags will be set differently based o
n | 373 // properties here, but the affectedBy flags will be set differently based o
n |
356 // the matching order of the :-webkit-any components. | 374 // the matching order of the :-webkit-any components. |
357 // | 375 // |
358 // m_nonInheritedData.m_emptyState | 376 // m_nonInheritedData.m_emptyState |
359 // m_nonInheritedData.m_affectedByFocus | 377 // m_nonInheritedData.m_affectedByFocus |
360 // m_nonInheritedData.m_affectedByHover | 378 // m_nonInheritedData.m_affectedByHover |
361 // m_nonInheritedData.m_affectedByActive | 379 // m_nonInheritedData.m_affectedByActive |
362 // m_nonInheritedData.m_affectedByDrag | 380 // m_nonInheritedData.m_affectedByDrag |
363 // m_nonInheritedData.m_isLink | 381 // m_nonInheritedData.m_isLink |
364 | 382 |
| 383 // Any properties that are inherited on a style are also inherited on elemen
ts |
| 384 // that share this style. |
| 385 m_nonInheritedData.m_isPointerEventsInherited = other.m_nonInheritedData.m_i
sPointerEventsInherited; |
| 386 m_nonInheritedData.m_isVisibilityInherited = other.m_nonInheritedData.m_isVi
sibilityInherited; |
| 387 |
365 if (m_svgStyle != other.m_svgStyle) | 388 if (m_svgStyle != other.m_svgStyle) |
366 m_svgStyle.access()->copyNonInheritedFromCached(other.m_svgStyle.get()); | 389 m_svgStyle.access()->copyNonInheritedFromCached(other.m_svgStyle.get()); |
367 DCHECK_EQ(zoom(), initialZoom()); | 390 DCHECK_EQ(zoom(), initialZoom()); |
368 } | 391 } |
369 | 392 |
370 bool ComputedStyle::operator==(const ComputedStyle& o) const | 393 bool ComputedStyle::operator==(const ComputedStyle& o) const |
371 { | 394 { |
372 return inheritedEqual(o) | 395 return inheritedEqual(o) |
373 && nonInheritedEqual(o); | 396 && nonInheritedEqual(o); |
374 } | 397 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 ComputedStyle* pseudoStyle = m_cachedPseudoStyles->at(i).get(); | 457 ComputedStyle* pseudoStyle = m_cachedPseudoStyles->at(i).get(); |
435 if (pseudoStyle->styleType() == pid) { | 458 if (pseudoStyle->styleType() == pid) { |
436 m_cachedPseudoStyles->remove(i); | 459 m_cachedPseudoStyles->remove(i); |
437 return; | 460 return; |
438 } | 461 } |
439 } | 462 } |
440 } | 463 } |
441 | 464 |
442 bool ComputedStyle::inheritedEqual(const ComputedStyle& other) const | 465 bool ComputedStyle::inheritedEqual(const ComputedStyle& other) const |
443 { | 466 { |
444 return m_inheritedData == other.m_inheritedData | 467 return independentInheritedEqual(other) |
| 468 && nonIndependentInheritedEqual(other); |
| 469 } |
| 470 |
| 471 bool ComputedStyle::independentInheritedEqual(const ComputedStyle& other) const |
| 472 { |
| 473 return m_inheritedData.compareEqualIndependent(other.m_inheritedData); |
| 474 } |
| 475 |
| 476 bool ComputedStyle::nonIndependentInheritedEqual(const ComputedStyle& other) con
st |
| 477 { |
| 478 return m_inheritedData.compareEqualNonIndependent(other.m_inheritedData) |
445 && m_styleInheritedData == other.m_styleInheritedData | 479 && m_styleInheritedData == other.m_styleInheritedData |
446 && m_svgStyle->inheritedEqual(*other.m_svgStyle) | 480 && m_svgStyle->inheritedEqual(*other.m_svgStyle) |
447 && m_rareInheritedData == other.m_rareInheritedData; | 481 && m_rareInheritedData == other.m_rareInheritedData; |
448 } | 482 } |
449 | 483 |
450 bool ComputedStyle::loadingCustomFontsEqual(const ComputedStyle& other) const | 484 bool ComputedStyle::loadingCustomFontsEqual(const ComputedStyle& other) const |
451 { | 485 { |
452 return font().loadingCustomFonts() == other.font().loadingCustomFonts(); | 486 return font().loadingCustomFonts() == other.font().loadingCustomFonts(); |
453 } | 487 } |
454 | 488 |
(...skipping 1533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1988 if (value < 0) | 2022 if (value < 0) |
1989 fvalue -= 0.5f; | 2023 fvalue -= 0.5f; |
1990 else | 2024 else |
1991 fvalue += 0.5f; | 2025 fvalue += 0.5f; |
1992 } | 2026 } |
1993 | 2027 |
1994 return roundForImpreciseConversion<int>(fvalue / zoomFactor); | 2028 return roundForImpreciseConversion<int>(fvalue / zoomFactor); |
1995 } | 2029 } |
1996 | 2030 |
1997 } // namespace blink | 2031 } // namespace blink |
OLD | NEW |