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 | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights |
4 * reserved. | 4 * reserved. |
5 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. | 5 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 // Since different compilers/architectures pack ComputedStyle differently, | 71 // Since different compilers/architectures pack ComputedStyle differently, |
72 // re-create the same structure for an accurate size comparison. | 72 // re-create the same structure for an accurate size comparison. |
73 struct SameSizeAsComputedStyle : public RefCounted<SameSizeAsComputedStyle> { | 73 struct SameSizeAsComputedStyle : public RefCounted<SameSizeAsComputedStyle> { |
74 struct ComputedStyleBase { | 74 struct ComputedStyleBase { |
75 unsigned m_bitfields[4]; | 75 unsigned m_bitfields[4]; |
76 } m_base; | 76 } m_base; |
77 | 77 |
78 void* dataRefs[7]; | 78 void* dataRefs[7]; |
79 void* ownPtrs[1]; | 79 void* ownPtrs[1]; |
80 void* dataRefSvgStyle; | 80 void* dataRefSvgStyle; |
| 81 |
| 82 struct NonInheritedData { |
| 83 unsigned m_bitfields[1]; |
| 84 } m_nonInheritedData; |
81 }; | 85 }; |
82 | 86 |
83 // If this assert fails, it means that size of ComputedStyle has changed. Please | 87 // If this assert fails, it means that size of ComputedStyle has changed. Please |
84 // check that you really *do* what to increase the size of ComputedStyle, then | 88 // check that you really *do* what to increase the size of ComputedStyle, then |
85 // update the SameSizeAsComputedStyle struct to match the updated storage of | 89 // update the SameSizeAsComputedStyle struct to match the updated storage of |
86 // ComputedStyle. | 90 // ComputedStyle. |
87 ASSERT_SIZE(ComputedStyle, SameSizeAsComputedStyle); | 91 ASSERT_SIZE(ComputedStyle, SameSizeAsComputedStyle); |
88 | 92 |
89 PassRefPtr<ComputedStyle> ComputedStyle::create() { | 93 PassRefPtr<ComputedStyle> ComputedStyle::create() { |
90 return adoptRef(new ComputedStyle(initialStyle())); | 94 return adoptRef(new ComputedStyle(initialStyle())); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 ALWAYS_INLINE ComputedStyle::ComputedStyle(const ComputedStyle& o) | 141 ALWAYS_INLINE ComputedStyle::ComputedStyle(const ComputedStyle& o) |
138 : ComputedStyleBase(o), | 142 : ComputedStyleBase(o), |
139 RefCounted<ComputedStyle>(), | 143 RefCounted<ComputedStyle>(), |
140 m_box(o.m_box), | 144 m_box(o.m_box), |
141 m_visual(o.m_visual), | 145 m_visual(o.m_visual), |
142 m_background(o.m_background), | 146 m_background(o.m_background), |
143 m_surround(o.m_surround), | 147 m_surround(o.m_surround), |
144 m_rareNonInheritedData(o.m_rareNonInheritedData), | 148 m_rareNonInheritedData(o.m_rareNonInheritedData), |
145 m_rareInheritedData(o.m_rareInheritedData), | 149 m_rareInheritedData(o.m_rareInheritedData), |
146 m_styleInheritedData(o.m_styleInheritedData), | 150 m_styleInheritedData(o.m_styleInheritedData), |
147 m_svgStyle(o.m_svgStyle) {} | 151 m_svgStyle(o.m_svgStyle), |
| 152 m_nonInheritedData(o.m_nonInheritedData) {} |
148 | 153 |
149 static StyleRecalcChange diffPseudoStyles(const ComputedStyle& oldStyle, | 154 static StyleRecalcChange diffPseudoStyles(const ComputedStyle& oldStyle, |
150 const ComputedStyle& newStyle) { | 155 const ComputedStyle& newStyle) { |
151 // If the pseudoStyles have changed, ensure layoutObject triggers setStyle. | 156 // If the pseudoStyles have changed, ensure layoutObject triggers setStyle. |
152 if (!oldStyle.hasAnyPublicPseudoStyles() && | 157 if (!oldStyle.hasAnyPublicPseudoStyles() && |
153 !newStyle.hasAnyPublicPseudoStyles()) | 158 !newStyle.hasAnyPublicPseudoStyles()) |
154 return NoChange; | 159 return NoChange; |
155 for (PseudoId pseudoId = FirstPublicPseudoId; | 160 for (PseudoId pseudoId = FirstPublicPseudoId; |
156 pseudoId < FirstInternalPseudoId; | 161 pseudoId < FirstInternalPseudoId; |
157 pseudoId = static_cast<PseudoId>(pseudoId + 1)) { | 162 pseudoId = static_cast<PseudoId>(pseudoId + 1)) { |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 } | 335 } |
331 | 336 |
332 void ComputedStyle::copyNonInheritedFromCached(const ComputedStyle& other) { | 337 void ComputedStyle::copyNonInheritedFromCached(const ComputedStyle& other) { |
333 ComputedStyleBase::copyNonInheritedFromCached(other); | 338 ComputedStyleBase::copyNonInheritedFromCached(other); |
334 m_box = other.m_box; | 339 m_box = other.m_box; |
335 m_visual = other.m_visual; | 340 m_visual = other.m_visual; |
336 m_background = other.m_background; | 341 m_background = other.m_background; |
337 m_surround = other.m_surround; | 342 m_surround = other.m_surround; |
338 m_rareNonInheritedData = other.m_rareNonInheritedData; | 343 m_rareNonInheritedData = other.m_rareNonInheritedData; |
339 | 344 |
340 // The flags are copied one-by-one because they contain | 345 // The flags are copied one-by-one because m_nonInheritedData.m_contains a |
341 // bunch of stuff other than real style data. | 346 // bunch of stuff other than real style data. |
342 // See comments for each skipped flag below. | 347 // See comments for each skipped flag below. |
343 | 348 setOriginalDisplay( |
344 // These are not generated in ComputedStyleBase | 349 other.originalDisplay()); // Not generated in ComputedStyleBase. |
345 setOriginalDisplay(other.originalDisplay()); | 350 setVerticalAlign( |
346 setVerticalAlign(other.verticalAlign()); | 351 other.verticalAlign()); // Not generated in ComputedStyleBase |
347 setHasViewportUnits(other.hasViewportUnits()); | 352 m_nonInheritedData.m_hasViewportUnits = |
348 m_hasRemUnits = other.hasRemUnits(); | 353 other.m_nonInheritedData.m_hasViewportUnits; |
| 354 m_nonInheritedData.m_hasRemUnits = other.m_nonInheritedData.m_hasRemUnits; |
349 | 355 |
350 // Correctly set during selector matching: | 356 // Correctly set during selector matching: |
351 // m_styleType | 357 // m_nonInheritedData.m_styleType |
352 // m_pseudoBits | 358 // m_nonInheritedData.m_pseudoBits |
353 | 359 |
354 // Set correctly while computing style for children: | 360 // Set correctly while computing style for children: |
355 // m_explicitInheritance | 361 // m_nonInheritedData.m_explicitInheritance |
356 | 362 |
357 // unique() styles are not cacheable. | 363 // unique() styles are not cacheable. |
358 DCHECK(!other.unique()); | 364 DCHECK(!other.unique()); |
359 | 365 |
360 // styles with non inherited properties that reference variables are not | 366 // styles with non inherited properties that reference variables are not |
361 // cacheable. | 367 // cacheable. |
362 DCHECK(!other.hasVariableReferenceFromNonInheritedProperty()); | 368 DCHECK(!other.hasVariableReferenceFromNonInheritedProperty()); |
363 | 369 |
364 // The following flags are set during matching before we decide that we get a | 370 // The following flags are set during matching before we decide that we get a |
365 // match in the MatchedPropertiesCache which in turn calls this method. The | 371 // match in the MatchedPropertiesCache which in turn calls this method. The |
366 // reason why we don't copy these flags is that they're already correctly set | 372 // reason why we don't copy these flags is that they're already correctly set |
367 // and that they may differ between elements which have the same set of | 373 // and that they may differ between elements which have the same set of |
368 // matched properties. For instance, given the rule: | 374 // matched properties. For instance, given the rule: |
369 // | 375 // |
370 // :-webkit-any(:hover, :focus) { background-color: green }" | 376 // :-webkit-any(:hover, :focus) { background-color: green }" |
371 // | 377 // |
372 // A hovered element, and a focused element may use the same cached matched | 378 // A hovered element, and a focused element may use the same cached matched |
373 // properties here, but the affectedBy flags will be set differently based on | 379 // properties here, but the affectedBy flags will be set differently based on |
374 // the matching order of the :-webkit-any components. | 380 // the matching order of the :-webkit-any components. |
375 // | 381 // |
376 // m_emptyState | 382 // m_nonInheritedData.m_emptyState |
377 // m_affectedByFocus | 383 // m_nonInheritedData.m_affectedByFocus |
378 // m_affectedByHover | 384 // m_nonInheritedData.m_affectedByHover |
379 // m_affectedByActive | 385 // m_nonInheritedData.m_affectedByActive |
380 // m_affectedByDrag | 386 // m_nonInheritedData.m_affectedByDrag |
381 // m_isLink | 387 // m_nonInheritedData.m_isLink |
382 | 388 |
383 if (m_svgStyle != other.m_svgStyle) | 389 if (m_svgStyle != other.m_svgStyle) |
384 m_svgStyle.access()->copyNonInheritedFromCached(other.m_svgStyle.get()); | 390 m_svgStyle.access()->copyNonInheritedFromCached(other.m_svgStyle.get()); |
385 DCHECK_EQ(zoom(), initialZoom()); | 391 DCHECK_EQ(zoom(), initialZoom()); |
386 } | 392 } |
387 | 393 |
388 bool ComputedStyle::operator==(const ComputedStyle& o) const { | 394 bool ComputedStyle::operator==(const ComputedStyle& o) const { |
389 return inheritedEqual(o) && nonInheritedEqual(o); | 395 return inheritedEqual(o) && nonInheritedEqual(o); |
390 } | 396 } |
391 | 397 |
(...skipping 2098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2490 if (value < 0) | 2496 if (value < 0) |
2491 fvalue -= 0.5f; | 2497 fvalue -= 0.5f; |
2492 else | 2498 else |
2493 fvalue += 0.5f; | 2499 fvalue += 0.5f; |
2494 } | 2500 } |
2495 | 2501 |
2496 return roundForImpreciseConversion<int>(fvalue / zoomFactor); | 2502 return roundForImpreciseConversion<int>(fvalue / zoomFactor); |
2497 } | 2503 } |
2498 | 2504 |
2499 } // namespace blink | 2505 } // namespace blink |
OLD | NEW |