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

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

Issue 2115803002: Clean up naming in ComputedStyle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 RefCounted<SameSizeAsComputedStyle> { 67 struct SameSizeAsComputedStyle : public RefCounted<SameSizeAsComputedStyle> {
68 void* dataRefs[7]; 68 void* dataRefs[7];
69 void* ownPtrs[1]; 69 void* ownPtrs[1];
70 void* dataRefSvgStyle; 70 void* dataRefSvgStyle;
71 71
72 struct InheritedFlags { 72 struct InheritedData {
73 unsigned m_bitfields[2]; 73 unsigned m_bitfields[2];
74 } inherited_flags; 74 } inherited_data;
75 75
76 struct NonInheritedFlags { 76 struct NonInheritedData {
77 unsigned m_bitfields[3]; 77 unsigned m_bitfields[3];
78 } noninherited_flags; 78 } noninherited_data;
79 }; 79 };
80 80
81 static_assert(sizeof(ComputedStyle) == sizeof(SameSizeAsComputedStyle), "Compute dStyle should stay small"); 81 static_assert(sizeof(ComputedStyle) == sizeof(SameSizeAsComputedStyle), "Compute dStyle should stay small");
82 82
83 PassRefPtr<ComputedStyle> ComputedStyle::create() 83 PassRefPtr<ComputedStyle> ComputedStyle::create()
84 { 84 {
85 return adoptRef(new ComputedStyle()); 85 return adoptRef(new ComputedStyle());
86 } 86 }
87 87
88 PassRefPtr<ComputedStyle> ComputedStyle::createInitialStyle() 88 PassRefPtr<ComputedStyle> ComputedStyle::createInitialStyle()
(...skipping 24 matching lines...) Expand all
113 : m_box(initialStyle().m_box) 113 : m_box(initialStyle().m_box)
114 , visual(initialStyle().visual) 114 , visual(initialStyle().visual)
115 , m_background(initialStyle().m_background) 115 , m_background(initialStyle().m_background)
116 , surround(initialStyle().surround) 116 , surround(initialStyle().surround)
117 , rareNonInheritedData(initialStyle().rareNonInheritedData) 117 , rareNonInheritedData(initialStyle().rareNonInheritedData)
118 , rareInheritedData(initialStyle().rareInheritedData) 118 , rareInheritedData(initialStyle().rareInheritedData)
119 , inherited(initialStyle().inherited) 119 , inherited(initialStyle().inherited)
120 , m_svgStyle(initialStyle().m_svgStyle) 120 , m_svgStyle(initialStyle().m_svgStyle)
121 { 121 {
122 setBitDefaults(); // Would it be faster to copy this from the default style? 122 setBitDefaults(); // Would it be faster to copy this from the default style?
123 static_assert((sizeof(InheritedFlags) <= 8), "InheritedFlags should not grow "); 123 static_assert((sizeof(InheritedData) <= 8), "InheritedData should not grow") ;
124 static_assert((sizeof(NonInheritedFlags) <= 12), "NonInheritedFlags should n ot grow"); 124 static_assert((sizeof(NonInheritedData) <= 12), "NonInheritedData should not grow");
125 } 125 }
126 126
127 ALWAYS_INLINE ComputedStyle::ComputedStyle(InitialStyleTag) 127 ALWAYS_INLINE ComputedStyle::ComputedStyle(InitialStyleTag)
128 { 128 {
129 setBitDefaults(); 129 setBitDefaults();
130 130
131 m_box.init(); 131 m_box.init();
132 visual.init(); 132 visual.init();
133 m_background.init(); 133 m_background.init();
134 surround.init(); 134 surround.init();
(...skipping 16 matching lines...) Expand all
151 ALWAYS_INLINE ComputedStyle::ComputedStyle(const ComputedStyle& o) 151 ALWAYS_INLINE ComputedStyle::ComputedStyle(const ComputedStyle& o)
152 : RefCounted<ComputedStyle>() 152 : RefCounted<ComputedStyle>()
153 , m_box(o.m_box) 153 , m_box(o.m_box)
154 , visual(o.visual) 154 , visual(o.visual)
155 , m_background(o.m_background) 155 , m_background(o.m_background)
156 , surround(o.surround) 156 , surround(o.surround)
157 , rareNonInheritedData(o.rareNonInheritedData) 157 , rareNonInheritedData(o.rareNonInheritedData)
158 , rareInheritedData(o.rareInheritedData) 158 , rareInheritedData(o.rareInheritedData)
159 , inherited(o.inherited) 159 , inherited(o.inherited)
160 , m_svgStyle(o.m_svgStyle) 160 , m_svgStyle(o.m_svgStyle)
161 , inherited_flags(o.inherited_flags) 161 , inherited_data(o.inherited_data)
162 , noninherited_flags(o.noninherited_flags) 162 , noninherited_data(o.noninherited_data)
163 { 163 {
164 } 164 }
165 165
166 static StyleRecalcChange diffPseudoStyles(const ComputedStyle& oldStyle, const C omputedStyle& newStyle) 166 static StyleRecalcChange diffPseudoStyles(const ComputedStyle& oldStyle, const C omputedStyle& newStyle)
167 { 167 {
168 // If the pseudoStyles have changed, we want any StyleRecalcChange that is n ot NoChange 168 // 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. 169 // because setStyle will do the right thing with anything else.
170 if (!oldStyle.hasAnyPublicPseudoStyles()) 170 if (!oldStyle.hasAnyPublicPseudoStyles())
171 return NoChange; 171 return NoChange;
172 for (PseudoId pseudoId = FirstPublicPseudoId; pseudoId < FirstInternalPseudo Id; pseudoId = static_cast<PseudoId>(pseudoId + 1)) { 172 for (PseudoId pseudoId = FirstPublicPseudoId; pseudoId < FirstInternalPseudo Id; pseudoId = static_cast<PseudoId>(pseudoId + 1)) {
(...skipping 17 matching lines...) Expand all
190 if (!oldStyle && !newStyle) 190 if (!oldStyle && !newStyle)
191 return NoChange; 191 return NoChange;
192 192
193 if (oldStyle->display() != newStyle->display() 193 if (oldStyle->display() != newStyle->display()
194 || oldStyle->hasPseudoStyle(PseudoIdFirstLetter) != newStyle->hasPseudoS tyle(PseudoIdFirstLetter) 194 || oldStyle->hasPseudoStyle(PseudoIdFirstLetter) != newStyle->hasPseudoS tyle(PseudoIdFirstLetter)
195 || !oldStyle->contentDataEquivalent(newStyle) 195 || !oldStyle->contentDataEquivalent(newStyle)
196 || oldStyle->hasTextCombine() != newStyle->hasTextCombine() 196 || oldStyle->hasTextCombine() != newStyle->hasTextCombine()
197 || oldStyle->justifyItems() != newStyle->justifyItems()) // TODO (lajava ): We must avoid this Reattach. 197 || oldStyle->justifyItems() != newStyle->justifyItems()) // TODO (lajava ): We must avoid this Reattach.
198 return Reattach; 198 return Reattach;
199 199
200 if (oldStyle->inheritedNotEqual(*newStyle)) 200 if (!oldStyle->inheritedEqual(*newStyle))
201 return Inherit; 201 return Inherit;
202 202
203 if (*oldStyle == *newStyle) 203 if (*oldStyle == *newStyle)
204 return diffPseudoStyles(*oldStyle, *newStyle); 204 return diffPseudoStyles(*oldStyle, *newStyle);
205 205
206 if (oldStyle->hasExplicitlyInheritedProperties()) 206 if (oldStyle->hasExplicitlyInheritedProperties())
207 return Inherit; 207 return Inherit;
208 208
209 return NoInherit; 209 return NoInherit;
210 } 210 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 { 269 {
270 if (isAtShadowBoundary == AtShadowBoundary) { 270 if (isAtShadowBoundary == AtShadowBoundary) {
271 // Even if surrounding content is user-editable, shadow DOM should act a s a single unit, and not necessarily be editable 271 // Even if surrounding content is user-editable, shadow DOM should act a s a single unit, and not necessarily be editable
272 EUserModify currentUserModify = userModify(); 272 EUserModify currentUserModify = userModify();
273 rareInheritedData = inheritParent.rareInheritedData; 273 rareInheritedData = inheritParent.rareInheritedData;
274 setUserModify(currentUserModify); 274 setUserModify(currentUserModify);
275 } else { 275 } else {
276 rareInheritedData = inheritParent.rareInheritedData; 276 rareInheritedData = inheritParent.rareInheritedData;
277 } 277 }
278 inherited = inheritParent.inherited; 278 inherited = inheritParent.inherited;
279 inherited_flags = inheritParent.inherited_flags; 279 inherited_data = inheritParent.inherited_data;
280 if (m_svgStyle != inheritParent.m_svgStyle) 280 if (m_svgStyle != inheritParent.m_svgStyle)
281 m_svgStyle.access()->inheritFrom(inheritParent.m_svgStyle.get()); 281 m_svgStyle.access()->inheritFrom(inheritParent.m_svgStyle.get());
282 } 282 }
283 283
284 void ComputedStyle::copyNonInheritedFromCached(const ComputedStyle& other) 284 void ComputedStyle::copyNonInheritedFromCached(const ComputedStyle& other)
285 { 285 {
286 m_box = other.m_box; 286 m_box = other.m_box;
287 visual = other.visual; 287 visual = other.visual;
288 m_background = other.m_background; 288 m_background = other.m_background;
289 surround = other.surround; 289 surround = other.surround;
290 rareNonInheritedData = other.rareNonInheritedData; 290 rareNonInheritedData = other.rareNonInheritedData;
291 291
292 // The flags are copied one-by-one because noninherited_flags contains a bun ch of stuff other than real style data. 292 // The flags are copied one-by-one because noninherited_data.m_contains a bu nch of stuff other than real style data.
293 // See comments for each skipped flag below. 293 // See comments for each skipped flag below.
294 noninherited_flags.effectiveDisplay = other.noninherited_flags.effectiveDisp lay; 294 noninherited_data.m_effectiveDisplay = other.noninherited_data.m_effectiveDi splay;
295 noninherited_flags.originalDisplay = other.noninherited_flags.originalDispla y; 295 noninherited_data.m_originalDisplay = other.noninherited_data.m_originalDisp lay;
296 noninherited_flags.overflowX = other.noninherited_flags.overflowX; 296 noninherited_data.m_overflowX = other.noninherited_data.m_overflowX;
297 noninherited_flags.overflowY = other.noninherited_flags.overflowY; 297 noninherited_data.m_overflowY = other.noninherited_data.m_overflowY;
298 noninherited_flags.verticalAlign = other.noninherited_flags.verticalAlign; 298 noninherited_data.m_verticalAlign = other.noninherited_data.m_verticalAlign;
299 noninherited_flags.clear = other.noninherited_flags.clear; 299 noninherited_data.m_clear = other.noninherited_data.m_clear;
300 noninherited_flags.position = other.noninherited_flags.position; 300 noninherited_data.m_position = other.noninherited_data.m_position;
301 noninherited_flags.floating = other.noninherited_flags.floating; 301 noninherited_data.m_floating = other.noninherited_data.m_floating;
302 noninherited_flags.tableLayout = other.noninherited_flags.tableLayout; 302 noninherited_data.m_tableLayout = other.noninherited_data.m_tableLayout;
303 noninherited_flags.unicodeBidi = other.noninherited_flags.unicodeBidi; 303 noninherited_data.m_unicodeBidi = other.noninherited_data.m_unicodeBidi;
304 noninherited_flags.hasViewportUnits = other.noninherited_flags.hasViewportUn its; 304 noninherited_data.m_hasViewportUnits = other.noninherited_data.m_hasViewport Units;
305 noninherited_flags.breakBefore = other.noninherited_flags.breakBefore; 305 noninherited_data.m_breakBefore = other.noninherited_data.m_breakBefore;
306 noninherited_flags.breakAfter = other.noninherited_flags.breakAfter; 306 noninherited_data.m_breakAfter = other.noninherited_data.m_breakAfter;
307 noninherited_flags.breakInside = other.noninherited_flags.breakInside; 307 noninherited_data.m_breakInside = other.noninherited_data.m_breakInside;
308 noninherited_flags.hasRemUnits = other.noninherited_flags.hasRemUnits; 308 noninherited_data.m_hasRemUnits = other.noninherited_data.m_hasRemUnits;
309 309
310 // Correctly set during selector matching: 310 // Correctly set during selector matching:
311 // noninherited_flags.styleType 311 // noninherited_data.m_styleType
312 // noninherited_flags.pseudoBits 312 // noninherited_data.m_pseudoBits
313 313
314 // Set correctly while computing style for children: 314 // Set correctly while computing style for children:
315 // noninherited_flags.explicitInheritance 315 // noninherited_data.m_explicitInheritance
316 316
317 // unique() styles are not cacheable. 317 // unique() styles are not cacheable.
318 ASSERT(!other.noninherited_flags.unique); 318 DCHECK(!other.noninherited_data.m_unique);
319 319
320 // styles with non inherited properties that reference variables are not 320 // styles with non inherited properties that reference variables are not
321 // cacheable. 321 // cacheable.
322 ASSERT(!other.noninherited_flags.variableReference); 322 DCHECK(!other.noninherited_data.m_variableReference);
323 323
324 // The following flags are set during matching before we decide that we get a 324 // The following flags are set during matching before we decide that we get a
325 // match in the MatchedPropertiesCache which in turn calls this method. The 325 // match in the MatchedPropertiesCache which in turn calls this method. The
326 // reason why we don't copy these flags is that they're already correctly se t 326 // reason why we don't copy these flags is that they're already correctly se t
327 // and that they may differ between elements which have the same set of matc hed 327 // and that they may differ between elements which have the same set of matc hed
328 // properties. For instance, given the rule: 328 // properties. For instance, given the rule:
329 // 329 //
330 // :-webkit-any(:hover, :focus) { background-color: green }" 330 // :-webkit-any(:hover, :focus) { background-color: green }"
331 // 331 //
332 // A hovered element, and a focused element may use the same cached matched 332 // A hovered element, and a focused element may use the same cached matched
333 // properties here, but the affectedBy flags will be set differently based o n 333 // properties here, but the affectedBy flags will be set differently based o n
334 // the matching order of the :-webkit-any components. 334 // the matching order of the :-webkit-any components.
335 // 335 //
336 // noninherited_flags.emptyState 336 // noninherited_data.m_emptyState
337 // noninherited_flags.affectedByFocus 337 // noninherited_data.m_affectedByFocus
338 // noninherited_flags.affectedByHover 338 // noninherited_data.m_affectedByHover
339 // noninherited_flags.affectedByActive 339 // noninherited_data.m_affectedByActive
340 // noninherited_flags.affectedByDrag 340 // noninherited_data.m_affectedByDrag
341 // noninherited_flags.isLink 341 // noninherited_data.m_isLink
342 342
343 if (m_svgStyle != other.m_svgStyle) 343 if (m_svgStyle != other.m_svgStyle)
344 m_svgStyle.access()->copyNonInheritedFromCached(other.m_svgStyle.get()); 344 m_svgStyle.access()->copyNonInheritedFromCached(other.m_svgStyle.get());
345 ASSERT(zoom() == initialZoom()); 345 DCHECK_EQ(zoom(), initialZoom());
346 } 346 }
347 347
348 bool ComputedStyle::operator==(const ComputedStyle& o) const 348 bool ComputedStyle::operator==(const ComputedStyle& o) const
349 { 349 {
sashab 2016/07/01 06:59:50 This method is identical (all comparisons are in t
rune 2016/07/01 08:45:41 That will cause an assert in the baseComputedStyle
350 // compare everything except the pseudoStyle pointer 350 return inheritedEqual(o)
351 return inherited_flags == o.inherited_flags 351 && nonInheritedEqual(o);
352 && noninherited_flags == o.noninherited_flags
353 && m_box == o.m_box
354 && visual == o.visual
355 && m_background == o.m_background
356 && surround == o.surround
357 && rareNonInheritedData == o.rareNonInheritedData
358 && rareInheritedData == o.rareInheritedData
359 && inherited == o.inherited
360 && m_svgStyle == o.m_svgStyle;
361 } 352 }
362 353
363 bool ComputedStyle::isStyleAvailable() const 354 bool ComputedStyle::isStyleAvailable() const
364 { 355 {
365 return this != StyleResolver::styleNotYetAvailable(); 356 return this != StyleResolver::styleNotYetAvailable();
366 } 357 }
367 358
368 bool ComputedStyle::hasUniquePseudoStyle() const 359 bool ComputedStyle::hasUniquePseudoStyle() const
369 { 360 {
370 if (!m_cachedPseudoStyles || styleType() != PseudoIdNone) 361 if (!m_cachedPseudoStyles || styleType() != PseudoIdNone)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 return; 410 return;
420 for (size_t i = 0; i < m_cachedPseudoStyles->size(); ++i) { 411 for (size_t i = 0; i < m_cachedPseudoStyles->size(); ++i) {
421 ComputedStyle* pseudoStyle = m_cachedPseudoStyles->at(i).get(); 412 ComputedStyle* pseudoStyle = m_cachedPseudoStyles->at(i).get();
422 if (pseudoStyle->styleType() == pid) { 413 if (pseudoStyle->styleType() == pid) {
423 m_cachedPseudoStyles->remove(i); 414 m_cachedPseudoStyles->remove(i);
424 return; 415 return;
425 } 416 }
426 } 417 }
427 } 418 }
428 419
429 bool ComputedStyle::inheritedNotEqual(const ComputedStyle& other) const 420 bool ComputedStyle::inheritedEqual(const ComputedStyle& other) const
sashab 2016/07/01 06:59:50 It's less confusing if it's an inheritedEqual() me
430 { 421 {
431 return inherited_flags != other.inherited_flags 422 return inherited_data == other.inherited_data
432 || inherited != other.inherited 423 && inherited == other.inherited
433 || font().loadingCustomFonts() != other.font().loadingCustomFonts() 424 && font().loadingCustomFonts() == other.font().loadingCustomFonts()
434 || m_svgStyle->inheritedNotEqual(other.m_svgStyle.get()) 425 && m_svgStyle->inheritedEqual(*other.m_svgStyle)
435 || rareInheritedData != other.rareInheritedData; 426 && rareInheritedData == other.rareInheritedData;
427 }
428
429 bool ComputedStyle::nonInheritedEqual(const ComputedStyle& other) const
430 {
431 // compare everything except the pseudoStyle pointer
432 return noninherited_data == other.noninherited_data
433 && m_box == other.m_box
434 && visual == other.visual
435 && m_background == other.m_background
436 && surround == other.surround
437 && rareNonInheritedData == other.rareNonInheritedData
438 && m_svgStyle->nonInheritedEqual(*other.m_svgStyle);
436 } 439 }
437 440
438 bool ComputedStyle::inheritedDataShared(const ComputedStyle& other) const 441 bool ComputedStyle::inheritedDataShared(const ComputedStyle& other) const
439 { 442 {
440 // This is a fast check that only looks if the data structures are shared. 443 // This is a fast check that only looks if the data structures are shared.
441 return inherited_flags == other.inherited_flags 444 return inherited_data == other.inherited_data
442 && inherited.get() == other.inherited.get() 445 && inherited.get() == other.inherited.get()
443 && m_svgStyle.get() == other.m_svgStyle.get() 446 && m_svgStyle.get() == other.m_svgStyle.get()
444 && rareInheritedData.get() == other.rareInheritedData.get(); 447 && rareInheritedData.get() == other.rareInheritedData.get();
445 } 448 }
446 449
447 static bool dependenceOnContentHeightHasChanged(const ComputedStyle& a, const Co mputedStyle& b) 450 static bool dependenceOnContentHeightHasChanged(const ComputedStyle& a, const Co mputedStyle& b)
448 { 451 {
449 // If top or bottom become auto/non-auto then it means we either have to sol ve height based 452 // If top or bottom become auto/non-auto then it means we either have to sol ve height based
450 // on the content or stop doing so (http://www.w3.org/TR/CSS2/visudet.html#a bs-non-replaced-height) 453 // on the content or stop doing so (http://www.w3.org/TR/CSS2/visudet.html#a bs-non-replaced-height)
451 // - either way requires a layout. 454 // - either way requires a layout.
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 return true; 611 return true;
609 612
610 if (inherited.get() != other.inherited.get()) { 613 if (inherited.get() != other.inherited.get()) {
611 if (inherited->line_height != other.inherited->line_height 614 if (inherited->line_height != other.inherited->line_height
612 || inherited->font != other.inherited->font 615 || inherited->font != other.inherited->font
613 || inherited->horizontal_border_spacing != other.inherited->horizont al_border_spacing 616 || inherited->horizontal_border_spacing != other.inherited->horizont al_border_spacing
614 || inherited->vertical_border_spacing != other.inherited->vertical_b order_spacing) 617 || inherited->vertical_border_spacing != other.inherited->vertical_b order_spacing)
615 return true; 618 return true;
616 } 619 }
617 620
618 if (inherited_flags._box_direction != other.inherited_flags._box_direction 621 if (inherited_data.m_boxDirection != other.inherited_data.m_boxDirection
619 || inherited_flags.m_rtlOrdering != other.inherited_flags.m_rtlOrdering 622 || inherited_data.m_rtlOrdering != other.inherited_data.m_rtlOrdering
620 || inherited_flags._text_align != other.inherited_flags._text_align 623 || inherited_data.m_textAlign != other.inherited_data.m_textAlign
621 || inherited_flags._text_transform != other.inherited_flags._text_transf orm 624 || inherited_data.m_textTransform != other.inherited_data.m_textTransfor m
622 || inherited_flags._direction != other.inherited_flags._direction 625 || inherited_data.m_direction != other.inherited_data.m_direction
623 || inherited_flags._white_space != other.inherited_flags._white_space 626 || inherited_data.m_whiteSpace != other.inherited_data.m_whiteSpace
624 || inherited_flags.m_writingMode != other.inherited_flags.m_writingMode) 627 || inherited_data.m_writingMode != other.inherited_data.m_writingMode)
625 return true; 628 return true;
626 629
627 if (noninherited_flags.overflowX != other.noninherited_flags.overflowX 630 if (noninherited_data.m_overflowX != other.noninherited_data.m_overflowX
628 || noninherited_flags.overflowY != other.noninherited_flags.overflowY 631 || noninherited_data.m_overflowY != other.noninherited_data.m_overflowY
629 || noninherited_flags.clear != other.noninherited_flags.clear 632 || noninherited_data.m_clear != other.noninherited_data.m_clear
630 || noninherited_flags.unicodeBidi != other.noninherited_flags.unicodeBid i 633 || noninherited_data.m_unicodeBidi != other.noninherited_data.m_unicodeB idi
631 || noninherited_flags.floating != other.noninherited_flags.floating 634 || noninherited_data.m_floating != other.noninherited_data.m_floating
632 || noninherited_flags.originalDisplay != other.noninherited_flags.origin alDisplay) 635 || noninherited_data.m_originalDisplay != other.noninherited_data.m_orig inalDisplay)
633 return true; 636 return true;
634 637
635 if (noninherited_flags.effectiveDisplay >= FIRST_TABLE_DISPLAY && noninherit ed_flags.effectiveDisplay <= LAST_TABLE_DISPLAY) { 638 if (noninherited_data.m_effectiveDisplay >= FIRST_TABLE_DISPLAY && noninheri ted_data.m_effectiveDisplay <= LAST_TABLE_DISPLAY) {
636 if (inherited_flags._border_collapse != other.inherited_flags._border_co llapse 639 if (inherited_data.m_borderCollapse != other.inherited_data.m_borderColl apse
637 || inherited_flags._empty_cells != other.inherited_flags._empty_cell s 640 || inherited_data.m_emptyCells != other.inherited_data.m_emptyCells
638 || inherited_flags._caption_side != other.inherited_flags._caption_s ide 641 || inherited_data.m_captionSide != other.inherited_data.m_captionSid e
639 || noninherited_flags.tableLayout != other.noninherited_flags.tableL ayout) 642 || noninherited_data.m_tableLayout != other.noninherited_data.m_tabl eLayout)
640 return true; 643 return true;
641 644
642 // In the collapsing border model, 'hidden' suppresses other borders, wh ile 'none' 645 // In the collapsing border model, 'hidden' suppresses other borders, wh ile 'none'
643 // does not, so these style differences can be width differences. 646 // does not, so these style differences can be width differences.
644 if (inherited_flags._border_collapse 647 if (inherited_data.m_borderCollapse
645 && ((borderTopStyle() == BorderStyleHidden && other.borderTopStyle() == BorderStyleNone) 648 && ((borderTopStyle() == BorderStyleHidden && other.borderTopStyle() == BorderStyleNone)
646 || (borderTopStyle() == BorderStyleNone && other.borderTopStyle( ) == BorderStyleHidden) 649 || (borderTopStyle() == BorderStyleNone && other.borderTopStyle( ) == BorderStyleHidden)
647 || (borderBottomStyle() == BorderStyleHidden && other.borderBott omStyle() == BorderStyleNone) 650 || (borderBottomStyle() == BorderStyleHidden && other.borderBott omStyle() == BorderStyleNone)
648 || (borderBottomStyle() == BorderStyleNone && other.borderBottom Style() == BorderStyleHidden) 651 || (borderBottomStyle() == BorderStyleNone && other.borderBottom Style() == BorderStyleHidden)
649 || (borderLeftStyle() == BorderStyleHidden && other.borderLeftSt yle() == BorderStyleNone) 652 || (borderLeftStyle() == BorderStyleHidden && other.borderLeftSt yle() == BorderStyleNone)
650 || (borderLeftStyle() == BorderStyleNone && other.borderLeftStyl e() == BorderStyleHidden) 653 || (borderLeftStyle() == BorderStyleNone && other.borderLeftStyl e() == BorderStyleHidden)
651 || (borderRightStyle() == BorderStyleHidden && other.borderRight Style() == BorderStyleNone) 654 || (borderRightStyle() == BorderStyleHidden && other.borderRight Style() == BorderStyleNone)
652 || (borderRightStyle() == BorderStyleNone && other.borderRightSt yle() == BorderStyleHidden))) 655 || (borderRightStyle() == BorderStyleNone && other.borderRightSt yle() == BorderStyleHidden)))
653 return true; 656 return true;
654 } else if (noninherited_flags.effectiveDisplay == LIST_ITEM) { 657 } else if (noninherited_data.m_effectiveDisplay == LIST_ITEM) {
655 if (inherited_flags._list_style_type != other.inherited_flags._list_styl e_type 658 if (inherited_data.m_listStyleType != other.inherited_data.m_listStyleTy pe
656 || inherited_flags._list_style_position != other.inherited_flags._li st_style_position) 659 || inherited_data.m_listStylePosition != other.inherited_data.m_list StylePosition)
657 return true; 660 return true;
658 } 661 }
659 662
660 if ((visibility() == COLLAPSE) != (other.visibility() == COLLAPSE)) 663 if ((visibility() == COLLAPSE) != (other.visibility() == COLLAPSE))
661 return true; 664 return true;
662 665
663 if (hasPseudoStyle(PseudoIdScrollbar) != other.hasPseudoStyle(PseudoIdScroll bar)) 666 if (hasPseudoStyle(PseudoIdScrollbar) != other.hasPseudoStyle(PseudoIdScroll bar))
664 return true; 667 return true;
665 668
666 // Movement of non-static-positioned object is special cased in ComputedStyl e::visualInvalidationDiff(). 669 // Movement of non-static-positioned object is special cased in ComputedStyl e::visualInvalidationDiff().
(...skipping 12 matching lines...) Expand all
679 || m_box->maxHeight() != other.m_box->maxHeight()) 682 || m_box->maxHeight() != other.m_box->maxHeight())
680 return true; 683 return true;
681 684
682 if (m_box->verticalAlign() != other.m_box->verticalAlign()) 685 if (m_box->verticalAlign() != other.m_box->verticalAlign())
683 return true; 686 return true;
684 687
685 if (m_box->boxSizing() != other.m_box->boxSizing()) 688 if (m_box->boxSizing() != other.m_box->boxSizing())
686 return true; 689 return true;
687 } 690 }
688 691
689 if (noninherited_flags.verticalAlign != other.noninherited_flags.verticalAli gn 692 if (noninherited_data.m_verticalAlign != other.noninherited_data.m_verticalA lign
690 || noninherited_flags.position != other.noninherited_flags.position) 693 || noninherited_data.m_position != other.noninherited_data.m_position)
691 return true; 694 return true;
692 695
693 if (surround.get() != other.surround.get()) { 696 if (surround.get() != other.surround.get()) {
694 if (surround->padding != other.surround->padding) 697 if (surround->padding != other.surround->padding)
695 return true; 698 return true;
696 } 699 }
697 700
698 if (rareNonInheritedData.get() != other.rareNonInheritedData.get()) { 701 if (rareNonInheritedData.get() != other.rareNonInheritedData.get()) {
699 if (rareNonInheritedData->m_alignContent != other.rareNonInheritedData-> m_alignContent 702 if (rareNonInheritedData->m_alignContent != other.rareNonInheritedData-> m_alignContent
700 || rareNonInheritedData->m_alignItems != other.rareNonInheritedData- >m_alignItems 703 || rareNonInheritedData->m_alignItems != other.rareNonInheritedData- >m_alignItems
(...skipping 30 matching lines...) Expand all
731 } 734 }
732 735
733 return false; 736 return false;
734 } 737 }
735 738
736 bool ComputedStyle::diffNeedsPaintInvalidationObject(const ComputedStyle& other) const 739 bool ComputedStyle::diffNeedsPaintInvalidationObject(const ComputedStyle& other) const
737 { 740 {
738 if (!m_background->outline().visuallyEqual(other.m_background->outline())) 741 if (!m_background->outline().visuallyEqual(other.m_background->outline()))
739 return true; 742 return true;
740 743
741 if (inherited_flags._visibility != other.inherited_flags._visibility 744 if (inherited_data.m_visibility != other.inherited_data.m_visibility
742 || inherited_flags.m_printColorAdjust != other.inherited_flags.m_printCo lorAdjust 745 || inherited_data.m_printColorAdjust != other.inherited_data.m_printColo rAdjust
743 || inherited_flags._insideLink != other.inherited_flags._insideLink 746 || inherited_data.m_insideLink != other.inherited_data.m_insideLink
744 || !surround->border.visuallyEqual(other.surround->border) 747 || !surround->border.visuallyEqual(other.surround->border)
745 || !m_background->visuallyEqual(*other.m_background)) 748 || !m_background->visuallyEqual(*other.m_background))
746 return true; 749 return true;
747 750
748 if (rareInheritedData.get() != other.rareInheritedData.get()) { 751 if (rareInheritedData.get() != other.rareInheritedData.get()) {
749 if (rareInheritedData->userModify != other.rareInheritedData->userModify 752 if (rareInheritedData->userModify != other.rareInheritedData->userModify
750 || rareInheritedData->userSelect != other.rareInheritedData->userSel ect 753 || rareInheritedData->userSelect != other.rareInheritedData->userSel ect
751 || rareInheritedData->m_imageRendering != other.rareInheritedData->m _imageRendering) 754 || rareInheritedData->m_imageRendering != other.rareInheritedData->m _imageRendering)
752 return true; 755 return true;
753 } 756 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 if (RuntimeEnabledFeatures::cssBoxReflectFilterEnabled() && !rareNonInhe ritedData->reflectionDataEquivalent(*other.rareNonInheritedData.get())) 839 if (RuntimeEnabledFeatures::cssBoxReflectFilterEnabled() && !rareNonInhe ritedData->reflectionDataEquivalent(*other.rareNonInheritedData.get()))
837 diff.setFilterChanged(); 840 diff.setFilterChanged();
838 } 841 }
839 842
840 if (!m_background->outline().visuallyEqual(other.m_background->outline()) || !surround->border.visualOverflowEqual(other.surround->border)) 843 if (!m_background->outline().visuallyEqual(other.m_background->outline()) || !surround->border.visualOverflowEqual(other.surround->border))
841 diff.setNeedsRecomputeOverflow(); 844 diff.setNeedsRecomputeOverflow();
842 845
843 if (!diff.needsPaintInvalidation()) { 846 if (!diff.needsPaintInvalidation()) {
844 if (inherited->color != other.inherited->color 847 if (inherited->color != other.inherited->color
845 || inherited->visitedLinkColor != other.inherited->visitedLinkColor 848 || inherited->visitedLinkColor != other.inherited->visitedLinkColor
846 || inherited_flags.m_textUnderline != other.inherited_flags.m_textUn derline 849 || inherited_data.m_textUnderline != other.inherited_data.m_textUnde rline
847 || visual->textDecoration != other.visual->textDecoration) { 850 || visual->textDecoration != other.visual->textDecoration) {
848 diff.setTextDecorationOrColorChanged(); 851 diff.setTextDecorationOrColorChanged();
849 } else if (rareNonInheritedData.get() != other.rareNonInheritedData.get( ) 852 } else if (rareNonInheritedData.get() != other.rareNonInheritedData.get( )
850 && (rareNonInheritedData->m_textDecorationStyle != other.rareNonInhe ritedData->m_textDecorationStyle 853 && (rareNonInheritedData->m_textDecorationStyle != other.rareNonInhe ritedData->m_textDecorationStyle
851 || rareNonInheritedData->m_textDecorationColor != other.rareNonI nheritedData->m_textDecorationColor 854 || rareNonInheritedData->m_textDecorationColor != other.rareNonI nheritedData->m_textDecorationColor
852 || rareNonInheritedData->m_visitedLinkTextDecorationColor != oth er.rareNonInheritedData->m_visitedLinkTextDecorationColor)) { 855 || rareNonInheritedData->m_visitedLinkTextDecorationColor != oth er.rareNonInheritedData->m_visitedLinkTextDecorationColor)) {
853 diff.setTextDecorationOrColorChanged(); 856 diff.setTextDecorationOrColorChanged();
854 } else if (rareInheritedData.get() != other.rareInheritedData.get() 857 } else if (rareInheritedData.get() != other.rareInheritedData.get()
855 && (rareInheritedData->textFillColor() != other.rareInheritedData->t extFillColor() 858 && (rareInheritedData->textFillColor() != other.rareInheritedData->t extFillColor()
856 || rareInheritedData->textStrokeColor() != other.rareInheritedDa ta->textStrokeColor() 859 || rareInheritedData->textStrokeColor() != other.rareInheritedDa ta->textStrokeColor()
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 const Vector<AppliedTextDecoration>& applied = appliedTextDecorations(); 1282 const Vector<AppliedTextDecoration>& applied = appliedTextDecorations();
1280 1283
1281 for (size_t i = 0; i < applied.size(); ++i) 1284 for (size_t i = 0; i < applied.size(); ++i)
1282 decorations |= applied[i].line(); 1285 decorations |= applied[i].line();
1283 1286
1284 return static_cast<TextDecoration>(decorations); 1287 return static_cast<TextDecoration>(decorations);
1285 } 1288 }
1286 1289
1287 const Vector<AppliedTextDecoration>& ComputedStyle::appliedTextDecorations() con st 1290 const Vector<AppliedTextDecoration>& ComputedStyle::appliedTextDecorations() con st
1288 { 1291 {
1289 if (!inherited_flags.m_textUnderline && !rareInheritedData->appliedTextDecor ations) { 1292 if (!inherited_data.m_textUnderline && !rareInheritedData->appliedTextDecora tions) {
1290 DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, empty, ()); 1293 DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, empty, ());
1291 return empty; 1294 return empty;
1292 } 1295 }
1293 if (inherited_flags.m_textUnderline) { 1296 if (inherited_data.m_textUnderline) {
1294 DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, underline, (1, Applie dTextDecoration(TextDecorationUnderline))); 1297 DEFINE_STATIC_LOCAL(Vector<AppliedTextDecoration>, underline, (1, Applie dTextDecoration(TextDecorationUnderline)));
1295 return underline; 1298 return underline;
1296 } 1299 }
1297 1300
1298 return rareInheritedData->appliedTextDecorations->vector(); 1301 return rareInheritedData->appliedTextDecorations->vector();
1299 } 1302 }
1300 1303
1301 StyleVariableData* ComputedStyle::variables() const 1304 StyleVariableData* ComputedStyle::variables() const
1302 { 1305 {
1303 ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled()); 1306 ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 1421
1419 void ComputedStyle::addAppliedTextDecoration(const AppliedTextDecoration& decora tion) 1422 void ComputedStyle::addAppliedTextDecoration(const AppliedTextDecoration& decora tion)
1420 { 1423 {
1421 RefPtr<AppliedTextDecorationList>& list = rareInheritedData.access()->applie dTextDecorations; 1424 RefPtr<AppliedTextDecorationList>& list = rareInheritedData.access()->applie dTextDecorations;
1422 1425
1423 if (!list) 1426 if (!list)
1424 list = AppliedTextDecorationList::create(); 1427 list = AppliedTextDecorationList::create();
1425 else if (!list->hasOneRef()) 1428 else if (!list->hasOneRef())
1426 list = list->copy(); 1429 list = list->copy();
1427 1430
1428 if (inherited_flags.m_textUnderline) { 1431 if (inherited_data.m_textUnderline) {
1429 inherited_flags.m_textUnderline = false; 1432 inherited_data.m_textUnderline = false;
1430 list->append(AppliedTextDecoration(TextDecorationUnderline)); 1433 list->append(AppliedTextDecoration(TextDecorationUnderline));
1431 } 1434 }
1432 1435
1433 list->append(decoration); 1436 list->append(decoration);
1434 } 1437 }
1435 1438
1436 void ComputedStyle::applyTextDecorations() 1439 void ComputedStyle::applyTextDecorations()
1437 { 1440 {
1438 if (getTextDecoration() == TextDecorationNone) 1441 if (getTextDecoration() == TextDecorationNone)
1439 return; 1442 return;
1440 1443
1441 TextDecorationStyle style = getTextDecorationStyle(); 1444 TextDecorationStyle style = getTextDecorationStyle();
1442 StyleColor styleColor = decorationColorIncludingFallback(insideLink() == Ins ideVisitedLink); 1445 StyleColor styleColor = decorationColorIncludingFallback(insideLink() == Ins ideVisitedLink);
1443 1446
1444 int decorations = getTextDecoration(); 1447 int decorations = getTextDecoration();
1445 1448
1446 if (decorations & TextDecorationUnderline) { 1449 if (decorations & TextDecorationUnderline) {
1447 // To save memory, we don't use AppliedTextDecoration objects in the 1450 // To save memory, we don't use AppliedTextDecoration objects in the
1448 // common case of a single simple underline. 1451 // common case of a single simple underline.
1449 AppliedTextDecoration underline(TextDecorationUnderline, style, styleCol or); 1452 AppliedTextDecoration underline(TextDecorationUnderline, style, styleCol or);
1450 1453
1451 if (!rareInheritedData->appliedTextDecorations && underline.isSimpleUnde rline()) 1454 if (!rareInheritedData->appliedTextDecorations && underline.isSimpleUnde rline())
1452 inherited_flags.m_textUnderline = true; 1455 inherited_data.m_textUnderline = true;
1453 else 1456 else
1454 addAppliedTextDecoration(underline); 1457 addAppliedTextDecoration(underline);
1455 } 1458 }
1456 if (decorations & TextDecorationOverline) 1459 if (decorations & TextDecorationOverline)
1457 addAppliedTextDecoration(AppliedTextDecoration(TextDecorationOverline, s tyle, styleColor)); 1460 addAppliedTextDecoration(AppliedTextDecoration(TextDecorationOverline, s tyle, styleColor));
1458 if (decorations & TextDecorationLineThrough) 1461 if (decorations & TextDecorationLineThrough)
1459 addAppliedTextDecoration(AppliedTextDecoration(TextDecorationLineThrough , style, styleColor)); 1462 addAppliedTextDecoration(AppliedTextDecoration(TextDecorationLineThrough , style, styleColor));
1460 } 1463 }
1461 1464
1462 void ComputedStyle::clearAppliedTextDecorations() 1465 void ComputedStyle::clearAppliedTextDecorations()
1463 { 1466 {
1464 inherited_flags.m_textUnderline = false; 1467 inherited_data.m_textUnderline = false;
1465 1468
1466 if (rareInheritedData->appliedTextDecorations) 1469 if (rareInheritedData->appliedTextDecorations)
1467 rareInheritedData.access()->appliedTextDecorations = nullptr; 1470 rareInheritedData.access()->appliedTextDecorations = nullptr;
1468 } 1471 }
1469 1472
1470 void ComputedStyle::clearMultiCol() 1473 void ComputedStyle::clearMultiCol()
1471 { 1474 {
1472 rareNonInheritedData.access()->m_multiCol = nullptr; 1475 rareNonInheritedData.access()->m_multiCol = nullptr;
1473 rareNonInheritedData.access()->m_multiCol.init(); 1476 rareNonInheritedData.access()->m_multiCol.init();
1474 } 1477 }
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
1874 if (value < 0) 1877 if (value < 0)
1875 fvalue -= 0.5f; 1878 fvalue -= 0.5f;
1876 else 1879 else
1877 fvalue += 0.5f; 1880 fvalue += 0.5f;
1878 } 1881 }
1879 1882
1880 return roundForImpreciseConversion<int>(fvalue / zoomFactor); 1883 return roundForImpreciseConversion<int>(fvalue / zoomFactor);
1881 } 1884 }
1882 1885
1883 } // namespace blink 1886 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698