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