Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(536)

Side by Side Diff: third_party/WebKit/Source/core/style/ComputedStyle.cpp

Issue 2220873002: Add a fast-path for independent inherited properties (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix for shadow roots Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 || oldStyle->justifyItems() != newStyle->justifyItems()) // TODO (lajava ): We must avoid this Reattach. 200 || oldStyle->justifyItems() != newStyle->justifyItems()) // TODO (lajava ): We must avoid this Reattach.
199 return Reattach; 201 return Reattach;
200 202
201 if (!oldStyle->inheritedEqual(*newStyle) 203 bool independentEqual = oldStyle->independentInheritedEqual(*newStyle);
202 || !oldStyle->loadingCustomFontsEqual(*newStyle)) 204 bool nonIndependentEqual = oldStyle->nonIndependentInheritedEqual(*newStyle) ;
205 if (!independentEqual || !nonIndependentEqual) {
206 if (nonIndependentEqual && !oldStyle->hasExplicitlyInheritedProperties() )
207 return IndependentInherit;
208 return Inherit;
209 }
210
211 if (!oldStyle->loadingCustomFontsEqual(*newStyle))
203 return Inherit; 212 return Inherit;
204 213
205 if (*oldStyle == *newStyle) 214 if (*oldStyle == *newStyle)
206 return diffPseudoStyles(*oldStyle, *newStyle); 215 return diffPseudoStyles(*oldStyle, *newStyle);
207 216
208 if (oldStyle->hasExplicitlyInheritedProperties()) 217 if (oldStyle->hasExplicitlyInheritedProperties())
209 return Inherit; 218 return Inherit;
210 219
211 return NoInherit; 220 return NoInherit;
212 } 221 }
213 222
223 // TODO(sashab): Generate this function.
224 void ComputedStyle::propagateIndependentInheritedProperties(const ComputedStyle& parentStyle)
225 {
226 if (m_nonInheritedData.m_isPointerEventsInherited)
227 setPointerEvents(parentStyle.pointerEvents());
228 if (m_nonInheritedData.m_isVisibilityInherited)
229 setVisibility(parentStyle.visibility());
230 }
231
214 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 )
215 { 233 {
216 // 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".
217 if (childStyle.alignSelfPosition() == ItemPositionAuto) 235 if (childStyle.alignSelfPosition() == ItemPositionAuto)
218 return (parentStyle.alignItemsPosition() == ItemPositionAuto) ? resolved AutoPositionForLayoutObject : parentStyle.alignItemsPosition(); 236 return (parentStyle.alignItemsPosition() == ItemPositionAuto) ? resolved AutoPositionForLayoutObject : parentStyle.alignItemsPosition();
219 return childStyle.alignSelfPosition(); 237 return childStyle.alignSelfPosition();
220 } 238 }
221 239
222 const StyleSelfAlignmentData ComputedStyle::resolvedAlignment(const ComputedStyl e& parentStyle, ItemPosition resolvedAutoPositionForLayoutObject) const 240 const StyleSelfAlignmentData ComputedStyle::resolvedAlignment(const ComputedStyl e& parentStyle, ItemPosition resolvedAutoPositionForLayoutObject) const
223 { 241 {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 // properties here, but the affectedBy flags will be set differently based o n 354 // properties here, but the affectedBy flags will be set differently based o n
337 // the matching order of the :-webkit-any components. 355 // the matching order of the :-webkit-any components.
338 // 356 //
339 // m_nonInheritedData.m_emptyState 357 // m_nonInheritedData.m_emptyState
340 // m_nonInheritedData.m_affectedByFocus 358 // m_nonInheritedData.m_affectedByFocus
341 // m_nonInheritedData.m_affectedByHover 359 // m_nonInheritedData.m_affectedByHover
342 // m_nonInheritedData.m_affectedByActive 360 // m_nonInheritedData.m_affectedByActive
343 // m_nonInheritedData.m_affectedByDrag 361 // m_nonInheritedData.m_affectedByDrag
344 // m_nonInheritedData.m_isLink 362 // m_nonInheritedData.m_isLink
345 363
364 // Any properties that are inherited on a style are also inherited on elemen ts
365 // that share this style.
366 m_nonInheritedData.m_isPointerEventsInherited = other.m_nonInheritedData.m_i sPointerEventsInherited;
367 m_nonInheritedData.m_isVisibilityInherited = other.m_nonInheritedData.m_isVi sibilityInherited;
368
346 if (m_svgStyle != other.m_svgStyle) 369 if (m_svgStyle != other.m_svgStyle)
347 m_svgStyle.access()->copyNonInheritedFromCached(other.m_svgStyle.get()); 370 m_svgStyle.access()->copyNonInheritedFromCached(other.m_svgStyle.get());
348 DCHECK_EQ(zoom(), initialZoom()); 371 DCHECK_EQ(zoom(), initialZoom());
349 } 372 }
350 373
351 bool ComputedStyle::operator==(const ComputedStyle& o) const 374 bool ComputedStyle::operator==(const ComputedStyle& o) const
352 { 375 {
353 return inheritedEqual(o) 376 return inheritedEqual(o)
354 && nonInheritedEqual(o); 377 && nonInheritedEqual(o);
355 } 378 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 ComputedStyle* pseudoStyle = m_cachedPseudoStyles->at(i).get(); 438 ComputedStyle* pseudoStyle = m_cachedPseudoStyles->at(i).get();
416 if (pseudoStyle->styleType() == pid) { 439 if (pseudoStyle->styleType() == pid) {
417 m_cachedPseudoStyles->remove(i); 440 m_cachedPseudoStyles->remove(i);
418 return; 441 return;
419 } 442 }
420 } 443 }
421 } 444 }
422 445
423 bool ComputedStyle::inheritedEqual(const ComputedStyle& other) const 446 bool ComputedStyle::inheritedEqual(const ComputedStyle& other) const
424 { 447 {
425 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)
426 && m_styleInheritedData == other.m_styleInheritedData 460 && m_styleInheritedData == other.m_styleInheritedData
427 && m_svgStyle->inheritedEqual(*other.m_svgStyle) 461 && m_svgStyle->inheritedEqual(*other.m_svgStyle)
428 && m_rareInheritedData == other.m_rareInheritedData; 462 && m_rareInheritedData == other.m_rareInheritedData;
429 } 463 }
430 464
431 bool ComputedStyle::loadingCustomFontsEqual(const ComputedStyle& other) const 465 bool ComputedStyle::loadingCustomFontsEqual(const ComputedStyle& other) const
432 { 466 {
433 return font().loadingCustomFonts() == other.font().loadingCustomFonts(); 467 return font().loadingCustomFonts() == other.font().loadingCustomFonts();
434 } 468 }
435 469
(...skipping 1530 matching lines...) Expand 10 before | Expand all | Expand 10 after
1966 if (value < 0) 2000 if (value < 0)
1967 fvalue -= 0.5f; 2001 fvalue -= 0.5f;
1968 else 2002 else
1969 fvalue += 0.5f; 2003 fvalue += 0.5f;
1970 } 2004 }
1971 2005
1972 return roundForImpreciseConversion<int>(fvalue / zoomFactor); 2006 return roundForImpreciseConversion<int>(fvalue / zoomFactor);
1973 } 2007 }
1974 2008
1975 } // namespace blink 2009 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698