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 platforms pack ComputedStyle differently, re-create the same | |
Timothy Loh
2016/07/19 01:29:32
Are you sure this gets packed differently on diffe
sashab
2016/07/19 03:31:35
Done.
| |
68 // 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 { |
77 unsigned m_bitfields[3]; | 79 unsigned m_bitfields[3]; |
78 } m_nonInheritedData; | 80 } m_nonInheritedData; |
81 | |
82 struct IsInheritedFlags { | |
83 unsigned m_bitfields[1]; | |
84 } m_isInheritedFlags; | |
esprehn
2016/07/19 03:46:26
merge this into m_nonInheritedData and it doesn't
sashab
2016/07/19 06:32:38
Woo done. :)
| |
79 }; | 85 }; |
80 | 86 |
81 static_assert(sizeof(ComputedStyle) == sizeof(SameSizeAsComputedStyle), "Compute dStyle should stay small"); | 87 static_assert(sizeof(ComputedStyle) == sizeof(SameSizeAsComputedStyle), "Compute dStyle should stay small"); |
82 | 88 |
83 PassRefPtr<ComputedStyle> ComputedStyle::create() | 89 PassRefPtr<ComputedStyle> ComputedStyle::create() |
84 { | 90 { |
85 return adoptRef(new ComputedStyle()); | 91 return adoptRef(new ComputedStyle()); |
86 } | 92 } |
87 | 93 |
88 PassRefPtr<ComputedStyle> ComputedStyle::createInitialStyle() | 94 PassRefPtr<ComputedStyle> ComputedStyle::createInitialStyle() |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 , m_box(o.m_box) | 159 , m_box(o.m_box) |
154 , m_visual(o.m_visual) | 160 , m_visual(o.m_visual) |
155 , m_background(o.m_background) | 161 , m_background(o.m_background) |
156 , m_surround(o.m_surround) | 162 , m_surround(o.m_surround) |
157 , m_rareNonInheritedData(o.m_rareNonInheritedData) | 163 , m_rareNonInheritedData(o.m_rareNonInheritedData) |
158 , m_rareInheritedData(o.m_rareInheritedData) | 164 , m_rareInheritedData(o.m_rareInheritedData) |
159 , m_styleInheritedData(o.m_styleInheritedData) | 165 , m_styleInheritedData(o.m_styleInheritedData) |
160 , m_svgStyle(o.m_svgStyle) | 166 , m_svgStyle(o.m_svgStyle) |
161 , m_inheritedData(o.m_inheritedData) | 167 , m_inheritedData(o.m_inheritedData) |
162 , m_nonInheritedData(o.m_nonInheritedData) | 168 , m_nonInheritedData(o.m_nonInheritedData) |
169 , m_isInheritedFlags(o.m_isInheritedFlags) | |
163 { | 170 { |
164 } | 171 } |
165 | 172 |
166 static StyleRecalcChange diffPseudoStyles(const ComputedStyle& oldStyle, const C omputedStyle& newStyle) | 173 static StyleRecalcChange diffPseudoStyles(const ComputedStyle& oldStyle, const C omputedStyle& newStyle) |
167 { | 174 { |
168 // If the pseudoStyles have changed, we want any StyleRecalcChange that is n ot NoChange | 175 // If the pseudoStyles have changed, we want any StyleRecalcChange that is n ot NoChange |
169 // because setStyle will do the right thing with anything else. | 176 // because setStyle will do the right thing with anything else. |
170 if (!oldStyle.hasAnyPublicPseudoStyles()) | 177 if (!oldStyle.hasAnyPublicPseudoStyles()) |
171 return NoChange; | 178 return NoChange; |
172 for (PseudoId pseudoId = FirstPublicPseudoId; pseudoId < FirstInternalPseudo Id; pseudoId = static_cast<PseudoId>(pseudoId + 1)) { | 179 for (PseudoId pseudoId = FirstPublicPseudoId; pseudoId < FirstInternalPseudo Id; pseudoId = static_cast<PseudoId>(pseudoId + 1)) { |
(...skipping 17 matching lines...) Expand all Loading... | |
190 if (!oldStyle && !newStyle) | 197 if (!oldStyle && !newStyle) |
191 return NoChange; | 198 return NoChange; |
192 | 199 |
193 if (oldStyle->display() != newStyle->display() | 200 if (oldStyle->display() != newStyle->display() |
194 || oldStyle->hasPseudoStyle(PseudoIdFirstLetter) != newStyle->hasPseudoS tyle(PseudoIdFirstLetter) | 201 || oldStyle->hasPseudoStyle(PseudoIdFirstLetter) != newStyle->hasPseudoS tyle(PseudoIdFirstLetter) |
195 || !oldStyle->contentDataEquivalent(newStyle) | 202 || !oldStyle->contentDataEquivalent(newStyle) |
196 || oldStyle->hasTextCombine() != newStyle->hasTextCombine() | 203 || oldStyle->hasTextCombine() != newStyle->hasTextCombine() |
197 || oldStyle->justifyItems() != newStyle->justifyItems()) // TODO (lajava ): We must avoid this Reattach. | 204 || oldStyle->justifyItems() != newStyle->justifyItems()) // TODO (lajava ): We must avoid this Reattach. |
198 return Reattach; | 205 return Reattach; |
199 | 206 |
207 if (!oldStyle->independentInheritedEqual(*newStyle) | |
208 && oldStyle->nonIndependentInheritedEqual(*newStyle) | |
esprehn
2016/07/19 03:46:26
this is a duplicate check with the inheritedEqual
sashab
2016/07/19 06:32:38
Unfortunately that doesn't quite work... See new c
| |
209 && !oldStyle->hasExplicitlyInheritedProperties()) | |
210 return IndependentInherit; | |
211 | |
200 if (!oldStyle->inheritedEqual(*newStyle) | 212 if (!oldStyle->inheritedEqual(*newStyle) |
201 || !oldStyle->loadingCustomFontsEqual(*newStyle)) | 213 || !oldStyle->loadingCustomFontsEqual(*newStyle)) |
202 return Inherit; | 214 return Inherit; |
203 | 215 |
204 if (*oldStyle == *newStyle) | 216 if (*oldStyle == *newStyle) |
205 return diffPseudoStyles(*oldStyle, *newStyle); | 217 return diffPseudoStyles(*oldStyle, *newStyle); |
206 | 218 |
207 if (oldStyle->hasExplicitlyInheritedProperties()) | 219 if (oldStyle->hasExplicitlyInheritedProperties()) |
208 return Inherit; | 220 return Inherit; |
209 | 221 |
210 return NoInherit; | 222 return NoInherit; |
211 } | 223 } |
212 | 224 |
225 // TODO(sashab): Generate this function. | |
226 void ComputedStyle::propagateIndependentInheritedProperties(const ComputedStyle& parent, ComputedStyle& child) | |
227 { | |
228 if (child.m_isInheritedFlags.m_isPointerEventsInherited) | |
esprehn
2016/07/19 03:46:26
I do wonder how fast this will be if there's a ton
sashab
2016/07/19 06:32:38
Yeah, that's why the TODO to generate :)
| |
229 child.setPointerEvents(parent.pointerEvents()); | |
230 if (child.m_isInheritedFlags.m_isVisibilityInherited) | |
231 child.setVisibility(parent.visibility()); | |
232 } | |
233 | |
213 ItemPosition ComputedStyle::resolveAlignment(const ComputedStyle& parentStyle, c onst ComputedStyle& childStyle, ItemPosition resolvedAutoPositionForLayoutObject ) | 234 ItemPosition ComputedStyle::resolveAlignment(const ComputedStyle& parentStyle, c onst ComputedStyle& childStyle, ItemPosition resolvedAutoPositionForLayoutObject ) |
214 { | 235 { |
215 // The auto keyword computes to the parent's align-items computed value, or to "stretch", if not set or "auto". | 236 // 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) | 237 if (childStyle.alignSelfPosition() == ItemPositionAuto) |
217 return (parentStyle.alignItemsPosition() == ItemPositionAuto) ? resolved AutoPositionForLayoutObject : parentStyle.alignItemsPosition(); | 238 return (parentStyle.alignItemsPosition() == ItemPositionAuto) ? resolved AutoPositionForLayoutObject : parentStyle.alignItemsPosition(); |
218 return childStyle.alignSelfPosition(); | 239 return childStyle.alignSelfPosition(); |
219 } | 240 } |
220 | 241 |
221 const StyleSelfAlignmentData ComputedStyle::resolvedAlignment(const ComputedStyl e& parentStyle, ItemPosition resolvedAutoPositionForLayoutObject) const | 242 const StyleSelfAlignmentData ComputedStyle::resolvedAlignment(const ComputedStyl e& parentStyle, ItemPosition resolvedAutoPositionForLayoutObject) const |
222 { | 243 { |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
334 // properties here, but the affectedBy flags will be set differently based o n | 355 // properties here, but the affectedBy flags will be set differently based o n |
335 // the matching order of the :-webkit-any components. | 356 // the matching order of the :-webkit-any components. |
336 // | 357 // |
337 // m_nonInheritedData.m_emptyState | 358 // m_nonInheritedData.m_emptyState |
338 // m_nonInheritedData.m_affectedByFocus | 359 // m_nonInheritedData.m_affectedByFocus |
339 // m_nonInheritedData.m_affectedByHover | 360 // m_nonInheritedData.m_affectedByHover |
340 // m_nonInheritedData.m_affectedByActive | 361 // m_nonInheritedData.m_affectedByActive |
341 // m_nonInheritedData.m_affectedByDrag | 362 // m_nonInheritedData.m_affectedByDrag |
342 // m_nonInheritedData.m_isLink | 363 // m_nonInheritedData.m_isLink |
343 | 364 |
365 // Any properties that are inherited on a style are also inherited on elemen ts | |
366 // that share this style. | |
367 m_isInheritedFlags = other.m_isInheritedFlags; | |
368 | |
344 if (m_svgStyle != other.m_svgStyle) | 369 if (m_svgStyle != other.m_svgStyle) |
345 m_svgStyle.access()->copyNonInheritedFromCached(other.m_svgStyle.get()); | 370 m_svgStyle.access()->copyNonInheritedFromCached(other.m_svgStyle.get()); |
346 DCHECK_EQ(zoom(), initialZoom()); | 371 DCHECK_EQ(zoom(), initialZoom()); |
347 } | 372 } |
348 | 373 |
349 bool ComputedStyle::operator==(const ComputedStyle& o) const | 374 bool ComputedStyle::operator==(const ComputedStyle& o) const |
350 { | 375 { |
351 return inheritedEqual(o) | 376 return inheritedEqual(o) |
352 && nonInheritedEqual(o); | 377 && nonInheritedEqual(o); |
353 } | 378 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
413 ComputedStyle* pseudoStyle = m_cachedPseudoStyles->at(i).get(); | 438 ComputedStyle* pseudoStyle = m_cachedPseudoStyles->at(i).get(); |
414 if (pseudoStyle->styleType() == pid) { | 439 if (pseudoStyle->styleType() == pid) { |
415 m_cachedPseudoStyles->remove(i); | 440 m_cachedPseudoStyles->remove(i); |
416 return; | 441 return; |
417 } | 442 } |
418 } | 443 } |
419 } | 444 } |
420 | 445 |
421 bool ComputedStyle::inheritedEqual(const ComputedStyle& other) const | 446 bool ComputedStyle::inheritedEqual(const ComputedStyle& other) const |
422 { | 447 { |
423 return m_inheritedData == other.m_inheritedData | 448 return independentInheritedEqual(other) |
449 && nonIndependentInheritedEqual(other); | |
450 } | |
451 | |
452 bool ComputedStyle::independentInheritedEqual(const ComputedStyle& other) const | |
453 { | |
454 return m_inheritedData.compareEqualIndependent(other.m_inheritedData); | |
455 } | |
456 | |
457 bool ComputedStyle::nonIndependentInheritedEqual(const ComputedStyle& other) con st | |
458 { | |
459 return m_inheritedData.compareEqualNonIndependent(other.m_inheritedData) | |
424 && m_styleInheritedData == other.m_styleInheritedData | 460 && m_styleInheritedData == other.m_styleInheritedData |
425 && m_svgStyle->inheritedEqual(*other.m_svgStyle) | 461 && m_svgStyle->inheritedEqual(*other.m_svgStyle) |
426 && m_rareInheritedData == other.m_rareInheritedData; | 462 && m_rareInheritedData == other.m_rareInheritedData; |
427 } | 463 } |
428 | 464 |
429 bool ComputedStyle::loadingCustomFontsEqual(const ComputedStyle& other) const | 465 bool ComputedStyle::loadingCustomFontsEqual(const ComputedStyle& other) const |
430 { | 466 { |
431 return font().loadingCustomFonts() == other.font().loadingCustomFonts(); | 467 return font().loadingCustomFonts() == other.font().loadingCustomFonts(); |
432 } | 468 } |
433 | 469 |
(...skipping 1500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1934 if (value < 0) | 1970 if (value < 0) |
1935 fvalue -= 0.5f; | 1971 fvalue -= 0.5f; |
1936 else | 1972 else |
1937 fvalue += 0.5f; | 1973 fvalue += 0.5f; |
1938 } | 1974 } |
1939 | 1975 |
1940 return roundForImpreciseConversion<int>(fvalue / zoomFactor); | 1976 return roundForImpreciseConversion<int>(fvalue / zoomFactor); |
1941 } | 1977 } |
1942 | 1978 |
1943 } // namespace blink | 1979 } // namespace blink |
OLD | NEW |