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

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

Issue 2187493004: Add a generated ComputedStyleBase class that ComputedStyle extends (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@_make_visibility_enum_class_rebase
Patch Set: 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // struct SameSizeAsComputedStyle : public BaseComputedStyle {
67 struct SameSizeAsComputedStyle : public RefCounted<SameSizeAsComputedStyle> { 68 struct SameSizeAsComputedStyle : public RefCounted<SameSizeAsComputedStyle> {
69 // The size of ComputedStyle increases by 1 pointer since we are now
70 // inheriting from the generated parent class. This change is temporary and
71 // will go away once BaseComputedStyle becomes ComputedStyle.
72 void* parentClass[1];
68 void* dataRefs[7]; 73 void* dataRefs[7];
69 void* ownPtrs[1]; 74 void* ownPtrs[1];
70 void* dataRefSvgStyle; 75 void* dataRefSvgStyle;
71 76
72 struct InheritedData { 77 struct InheritedData {
73 unsigned m_bitfields[2]; 78 unsigned m_bitfields[2];
74 } m_inheritedData; 79 } m_inheritedData;
75 80
76 struct NonInheritedData { 81 struct NonInheritedData {
77 unsigned m_bitfields[3]; 82 unsigned m_bitfields[3];
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 m_rareNonInheritedData.access()->m_backdropFilter.init(); 147 m_rareNonInheritedData.access()->m_backdropFilter.init();
143 m_rareNonInheritedData.access()->m_grid.init(); 148 m_rareNonInheritedData.access()->m_grid.init();
144 m_rareNonInheritedData.access()->m_gridItem.init(); 149 m_rareNonInheritedData.access()->m_gridItem.init();
145 m_rareNonInheritedData.access()->m_scrollSnap.init(); 150 m_rareNonInheritedData.access()->m_scrollSnap.init();
146 m_rareInheritedData.init(); 151 m_rareInheritedData.init();
147 m_styleInheritedData.init(); 152 m_styleInheritedData.init();
148 m_svgStyle.init(); 153 m_svgStyle.init();
149 } 154 }
150 155
151 ALWAYS_INLINE ComputedStyle::ComputedStyle(const ComputedStyle& o) 156 ALWAYS_INLINE ComputedStyle::ComputedStyle(const ComputedStyle& o)
152 : RefCounted<ComputedStyle>() 157 : BaseComputedStyle(o)
153 , m_box(o.m_box) 158 , m_box(o.m_box)
154 , m_visual(o.m_visual) 159 , m_visual(o.m_visual)
155 , m_background(o.m_background) 160 , m_background(o.m_background)
156 , m_surround(o.m_surround) 161 , m_surround(o.m_surround)
157 , m_rareNonInheritedData(o.m_rareNonInheritedData) 162 , m_rareNonInheritedData(o.m_rareNonInheritedData)
158 , m_rareInheritedData(o.m_rareInheritedData) 163 , m_rareInheritedData(o.m_rareInheritedData)
159 , m_styleInheritedData(o.m_styleInheritedData) 164 , m_styleInheritedData(o.m_styleInheritedData)
160 , m_svgStyle(o.m_svgStyle) 165 , m_svgStyle(o.m_svgStyle)
161 , m_inheritedData(o.m_inheritedData) 166 , m_inheritedData(o.m_inheritedData)
162 , m_nonInheritedData(o.m_nonInheritedData) 167 , m_nonInheritedData(o.m_nonInheritedData)
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 return resolvedContentAlignmentPosition(alignContent(), normalValueBehavior) ; 266 return resolvedContentAlignmentPosition(alignContent(), normalValueBehavior) ;
262 } 267 }
263 268
264 ContentDistributionType ComputedStyle::resolvedAlignContentDistribution(const St yleContentAlignmentData& normalValueBehavior) const 269 ContentDistributionType ComputedStyle::resolvedAlignContentDistribution(const St yleContentAlignmentData& normalValueBehavior) const
265 { 270 {
266 return resolvedContentAlignmentDistribution(alignContent(), normalValueBehav ior); 271 return resolvedContentAlignmentDistribution(alignContent(), normalValueBehav ior);
267 } 272 }
268 273
269 void ComputedStyle::inheritFrom(const ComputedStyle& inheritParent, IsAtShadowBo undary isAtShadowBoundary) 274 void ComputedStyle::inheritFrom(const ComputedStyle& inheritParent, IsAtShadowBo undary isAtShadowBoundary)
270 { 275 {
276 BaseComputedStyle::inheritFrom(inheritParent, isAtShadowBoundary);
271 if (isAtShadowBoundary == AtShadowBoundary) { 277 if (isAtShadowBoundary == AtShadowBoundary) {
272 // Even if surrounding content is user-editable, shadow DOM should act a s a single unit, and not necessarily be editable 278 // Even if surrounding content is user-editable, shadow DOM should act a s a single unit, and not necessarily be editable
273 EUserModify currentUserModify = userModify(); 279 EUserModify currentUserModify = userModify();
274 m_rareInheritedData = inheritParent.m_rareInheritedData; 280 m_rareInheritedData = inheritParent.m_rareInheritedData;
275 setUserModify(currentUserModify); 281 setUserModify(currentUserModify);
276 } else { 282 } else {
277 m_rareInheritedData = inheritParent.m_rareInheritedData; 283 m_rareInheritedData = inheritParent.m_rareInheritedData;
278 } 284 }
279 m_styleInheritedData = inheritParent.m_styleInheritedData; 285 m_styleInheritedData = inheritParent.m_styleInheritedData;
280 m_inheritedData = inheritParent.m_inheritedData; 286 m_inheritedData = inheritParent.m_inheritedData;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 ComputedStyle* pseudoStyle = m_cachedPseudoStyles->at(i).get(); 420 ComputedStyle* pseudoStyle = m_cachedPseudoStyles->at(i).get();
415 if (pseudoStyle->styleType() == pid) { 421 if (pseudoStyle->styleType() == pid) {
416 m_cachedPseudoStyles->remove(i); 422 m_cachedPseudoStyles->remove(i);
417 return; 423 return;
418 } 424 }
419 } 425 }
420 } 426 }
421 427
422 bool ComputedStyle::inheritedEqual(const ComputedStyle& other) const 428 bool ComputedStyle::inheritedEqual(const ComputedStyle& other) const
423 { 429 {
424 return m_inheritedData == other.m_inheritedData 430 return BaseComputedStyle::inheritedEqual(other)
431 && m_inheritedData == other.m_inheritedData
425 && m_styleInheritedData == other.m_styleInheritedData 432 && m_styleInheritedData == other.m_styleInheritedData
426 && m_svgStyle->inheritedEqual(*other.m_svgStyle) 433 && m_svgStyle->inheritedEqual(*other.m_svgStyle)
427 && m_rareInheritedData == other.m_rareInheritedData; 434 && m_rareInheritedData == other.m_rareInheritedData;
428 } 435 }
429 436
430 bool ComputedStyle::loadingCustomFontsEqual(const ComputedStyle& other) const 437 bool ComputedStyle::loadingCustomFontsEqual(const ComputedStyle& other) const
431 { 438 {
432 return font().loadingCustomFonts() == other.font().loadingCustomFonts(); 439 return font().loadingCustomFonts() == other.font().loadingCustomFonts();
433 } 440 }
434 441
435 bool ComputedStyle::nonInheritedEqual(const ComputedStyle& other) const 442 bool ComputedStyle::nonInheritedEqual(const ComputedStyle& other) const
436 { 443 {
437 // compare everything except the pseudoStyle pointer 444 // compare everything except the pseudoStyle pointer
438 return m_nonInheritedData == other.m_nonInheritedData 445 return m_nonInheritedData == other.m_nonInheritedData
439 && m_box == other.m_box 446 && m_box == other.m_box
440 && m_visual == other.m_visual 447 && m_visual == other.m_visual
441 && m_background == other.m_background 448 && m_background == other.m_background
442 && m_surround == other.m_surround 449 && m_surround == other.m_surround
443 && m_rareNonInheritedData == other.m_rareNonInheritedData 450 && m_rareNonInheritedData == other.m_rareNonInheritedData
444 && m_svgStyle->nonInheritedEqual(*other.m_svgStyle); 451 && m_svgStyle->nonInheritedEqual(*other.m_svgStyle);
445 } 452 }
446 453
447 bool ComputedStyle::inheritedDataShared(const ComputedStyle& other) const 454 bool ComputedStyle::inheritedDataShared(const ComputedStyle& other) const
448 { 455 {
449 // This is a fast check that only looks if the data structures are shared. 456 // This is a fast check that only looks if the data structures are shared.
450 return m_inheritedData == other.m_inheritedData 457 return BaseComputedStyle::inheritedEqual(other)
458 && m_inheritedData == other.m_inheritedData
451 && m_styleInheritedData.get() == other.m_styleInheritedData.get() 459 && m_styleInheritedData.get() == other.m_styleInheritedData.get()
452 && m_svgStyle.get() == other.m_svgStyle.get() 460 && m_svgStyle.get() == other.m_svgStyle.get()
453 && m_rareInheritedData.get() == other.m_rareInheritedData.get(); 461 && m_rareInheritedData.get() == other.m_rareInheritedData.get();
454 } 462 }
455 463
456 static bool dependenceOnContentHeightHasChanged(const ComputedStyle& a, const Co mputedStyle& b) 464 static bool dependenceOnContentHeightHasChanged(const ComputedStyle& a, const Co mputedStyle& b)
457 { 465 {
458 // If top or bottom become auto/non-auto then it means we either have to sol ve height based 466 // If top or bottom become auto/non-auto then it means we either have to sol ve height based
459 // on the content or stop doing so (http://www.w3.org/TR/CSS2/visudet.html#a bs-non-replaced-height) 467 // on the content or stop doing so (http://www.w3.org/TR/CSS2/visudet.html#a bs-non-replaced-height)
460 // - either way requires a layout. 468 // - either way requires a layout.
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 } 748 }
741 749
742 return false; 750 return false;
743 } 751 }
744 752
745 bool ComputedStyle::diffNeedsPaintInvalidationObject(const ComputedStyle& other) const 753 bool ComputedStyle::diffNeedsPaintInvalidationObject(const ComputedStyle& other) const
746 { 754 {
747 if (!m_background->outline().visuallyEqual(other.m_background->outline())) 755 if (!m_background->outline().visuallyEqual(other.m_background->outline()))
748 return true; 756 return true;
749 757
750 if (m_inheritedData.m_visibility != other.m_inheritedData.m_visibility 758 if (visibility() != other.visibility()
751 || m_inheritedData.m_printColorAdjust != other.m_inheritedData.m_printCo lorAdjust 759 || m_inheritedData.m_printColorAdjust != other.m_inheritedData.m_printCo lorAdjust
752 || m_inheritedData.m_insideLink != other.m_inheritedData.m_insideLink 760 || m_inheritedData.m_insideLink != other.m_inheritedData.m_insideLink
753 || !m_surround->border.visuallyEqual(other.m_surround->border) 761 || !m_surround->border.visuallyEqual(other.m_surround->border)
754 || !m_background->visuallyEqual(*other.m_background)) 762 || !m_background->visuallyEqual(*other.m_background))
755 return true; 763 return true;
756 764
757 if (m_rareInheritedData.get() != other.m_rareInheritedData.get()) { 765 if (m_rareInheritedData.get() != other.m_rareInheritedData.get()) {
758 if (m_rareInheritedData->userModify != other.m_rareInheritedData->userMo dify 766 if (m_rareInheritedData->userModify != other.m_rareInheritedData->userMo dify
759 || m_rareInheritedData->userSelect != other.m_rareInheritedData->use rSelect 767 || m_rareInheritedData->userSelect != other.m_rareInheritedData->use rSelect
760 || m_rareInheritedData->m_imageRendering != other.m_rareInheritedDat a->m_imageRendering) 768 || m_rareInheritedData->m_imageRendering != other.m_rareInheritedDat a->m_imageRendering)
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1958 if (value < 0) 1966 if (value < 0)
1959 fvalue -= 0.5f; 1967 fvalue -= 0.5f;
1960 else 1968 else
1961 fvalue += 0.5f; 1969 fvalue += 0.5f;
1962 } 1970 }
1963 1971
1964 return roundForImpreciseConversion<int>(fvalue / zoomFactor); 1972 return roundForImpreciseConversion<int>(fvalue / zoomFactor);
1965 } 1973 }
1966 1974
1967 } // namespace blink 1975 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698