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