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

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

Issue 2919343002: Remove template parameter on ComputedStyleBase. (Closed)
Patch Set: Address comments Created 3 years, 6 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
« no previous file with comments | « third_party/WebKit/Source/core/style/ComputedStyle.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
4 * reserved. 4 * reserved.
5 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. 5 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 struct ComputedStyleBase { 74 struct ComputedStyleBase {
75 void* data_refs[6]; 75 void* data_refs[6];
76 unsigned bitfields_[4]; 76 unsigned bitfields_[4];
77 } base_; 77 } base_;
78 78
79 void* data_refs[1]; 79 void* data_refs[1];
80 void* own_ptrs[1]; 80 void* own_ptrs[1];
81 void* data_ref_svg_style; 81 void* data_ref_svg_style;
82 }; 82 };
83 83
84 // If this fails, the packing algorithm in make_computed_style_base.py has
85 // failed to produce the optimal packed size. To fix, update the algorithm to
86 // ensure that the buckets are placed so that each takes up at most 1 word.
87 ASSERT_SIZE(ComputedStyleBase<ComputedStyle>, SameSizeAsComputedStyleBase);
88
89 // If this assert fails, it means that size of ComputedStyle has changed. Please 84 // If this assert fails, it means that size of ComputedStyle has changed. Please
90 // check that you really *do* what to increase the size of ComputedStyle, then 85 // check that you really *do* what to increase the size of ComputedStyle, then
91 // update the SameSizeAsComputedStyle struct to match the updated storage of 86 // update the SameSizeAsComputedStyle struct to match the updated storage of
92 // ComputedStyle. 87 // ComputedStyle.
93 ASSERT_SIZE(ComputedStyle, SameSizeAsComputedStyle); 88 ASSERT_SIZE(ComputedStyle, SameSizeAsComputedStyle);
94 89
95 RefPtr<ComputedStyle> ComputedStyle::Create() { 90 RefPtr<ComputedStyle> ComputedStyle::Create() {
96 return AdoptRef(new ComputedStyle(InitialStyle())); 91 return AdoptRef(new ComputedStyle(InitialStyle()));
97 } 92 }
98 93
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 // Animations don't need to be checked either. We always set the new style on 524 // Animations don't need to be checked either. We always set the new style on
530 // the layoutObject, so we will get a chance to fire off the resulting 525 // the layoutObject, so we will get a chance to fire off the resulting
531 // transition properly. 526 // transition properly.
532 527
533 return diff; 528 return diff;
534 } 529 }
535 530
536 bool ComputedStyle::ScrollAnchorDisablingPropertyChanged( 531 bool ComputedStyle::ScrollAnchorDisablingPropertyChanged(
537 const ComputedStyle& other, 532 const ComputedStyle& other,
538 const StyleDifference& diff) const { 533 const StyleDifference& diff) const {
539 if (ComputedStyleBase::ScrollAnchorDisablingPropertyChanged(other)) 534 if (ComputedStyleBase::ScrollAnchorDisablingPropertyChanged(*this, other))
540 return true; 535 return true;
541 536
542 if (diff.TransformChanged()) 537 if (diff.TransformChanged())
543 return true; 538 return true;
544 539
545 return false; 540 return false;
546 } 541 }
547 542
548 bool ComputedStyle::DiffNeedsFullLayoutAndPaintInvalidation( 543 bool ComputedStyle::DiffNeedsFullLayoutAndPaintInvalidation(
549 const ComputedStyle& other) const { 544 const ComputedStyle& other) const {
550 // FIXME: Not all cases in this method need both full layout and paint 545 // FIXME: Not all cases in this method need both full layout and paint
551 // invalidation. 546 // invalidation.
552 // Should move cases into DiffNeedsFullLayout() if 547 // Should move cases into DiffNeedsFullLayout() if
553 // - don't need paint invalidation at all; 548 // - don't need paint invalidation at all;
554 // - or the layoutObject knows how to exactly invalidate paints caused by the 549 // - or the layoutObject knows how to exactly invalidate paints caused by the
555 // layout change instead of forced full paint invalidation. 550 // layout change instead of forced full paint invalidation.
556 551
557 if (ComputedStyleBase::DiffNeedsFullLayoutAndPaintInvalidation(other)) 552 if (ComputedStyleBase::DiffNeedsFullLayoutAndPaintInvalidation(*this, other))
558 return true; 553 return true;
559 554
560 if (rare_non_inherited_data_.Get() != other.rare_non_inherited_data_.Get()) { 555 if (rare_non_inherited_data_.Get() != other.rare_non_inherited_data_.Get()) {
561 if (rare_non_inherited_data_->appearance_ != 556 if (rare_non_inherited_data_->appearance_ !=
562 other.rare_non_inherited_data_->appearance_ || 557 other.rare_non_inherited_data_->appearance_ ||
563 rare_non_inherited_data_->margin_before_collapse_ != 558 rare_non_inherited_data_->margin_before_collapse_ !=
564 other.rare_non_inherited_data_->margin_before_collapse_ || 559 other.rare_non_inherited_data_->margin_before_collapse_ ||
565 rare_non_inherited_data_->margin_after_collapse_ != 560 rare_non_inherited_data_->margin_after_collapse_ !=
566 other.rare_non_inherited_data_->margin_after_collapse_ || 561 other.rare_non_inherited_data_->margin_after_collapse_ ||
567 rare_non_inherited_data_->line_clamp_ != 562 rare_non_inherited_data_->line_clamp_ !=
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 // selfNeedsSimplifiedLayout bit in order to not get confused and taint 622 // selfNeedsSimplifiedLayout bit in order to not get confused and taint
628 // every line). In addition we need to solve the floating object issue 623 // every line). In addition we need to solve the floating object issue
629 // when layers come and go. Right now a full layout is necessary to keep 624 // when layers come and go. Right now a full layout is necessary to keep
630 // floating object lists sane. 625 // floating object lists sane.
631 return true; 626 return true;
632 } 627 }
633 } 628 }
634 629
635 if (IsDisplayTableType(Display())) { 630 if (IsDisplayTableType(Display())) {
636 if (ComputedStyleBase:: 631 if (ComputedStyleBase::
637 DiffNeedsFullLayoutAndPaintInvalidationDisplayTableType(other)) 632 DiffNeedsFullLayoutAndPaintInvalidationDisplayTableType(*this,
633 other))
638 return true; 634 return true;
639 635
640 // In the collapsing border model, 'hidden' suppresses other borders, while 636 // In the collapsing border model, 'hidden' suppresses other borders, while
641 // 'none' does not, so these style differences can be width differences. 637 // 'none' does not, so these style differences can be width differences.
642 if ((BorderCollapse() == EBorderCollapse::kCollapse) && 638 if ((BorderCollapse() == EBorderCollapse::kCollapse) &&
643 ((BorderTopStyle() == EBorderStyle::kHidden && 639 ((BorderTopStyle() == EBorderStyle::kHidden &&
644 other.BorderTopStyle() == EBorderStyle::kNone) || 640 other.BorderTopStyle() == EBorderStyle::kNone) ||
645 (BorderTopStyle() == EBorderStyle::kNone && 641 (BorderTopStyle() == EBorderStyle::kNone &&
646 other.BorderTopStyle() == EBorderStyle::kHidden) || 642 other.BorderTopStyle() == EBorderStyle::kHidden) ||
647 (BorderBottomStyle() == EBorderStyle::kHidden && 643 (BorderBottomStyle() == EBorderStyle::kHidden &&
648 other.BorderBottomStyle() == EBorderStyle::kNone) || 644 other.BorderBottomStyle() == EBorderStyle::kNone) ||
649 (BorderBottomStyle() == EBorderStyle::kNone && 645 (BorderBottomStyle() == EBorderStyle::kNone &&
650 other.BorderBottomStyle() == EBorderStyle::kHidden) || 646 other.BorderBottomStyle() == EBorderStyle::kHidden) ||
651 (BorderLeftStyle() == EBorderStyle::kHidden && 647 (BorderLeftStyle() == EBorderStyle::kHidden &&
652 other.BorderLeftStyle() == EBorderStyle::kNone) || 648 other.BorderLeftStyle() == EBorderStyle::kNone) ||
653 (BorderLeftStyle() == EBorderStyle::kNone && 649 (BorderLeftStyle() == EBorderStyle::kNone &&
654 other.BorderLeftStyle() == EBorderStyle::kHidden) || 650 other.BorderLeftStyle() == EBorderStyle::kHidden) ||
655 (BorderRightStyle() == EBorderStyle::kHidden && 651 (BorderRightStyle() == EBorderStyle::kHidden &&
656 other.BorderRightStyle() == EBorderStyle::kNone) || 652 other.BorderRightStyle() == EBorderStyle::kNone) ||
657 (BorderRightStyle() == EBorderStyle::kNone && 653 (BorderRightStyle() == EBorderStyle::kNone &&
658 other.BorderRightStyle() == EBorderStyle::kHidden))) 654 other.BorderRightStyle() == EBorderStyle::kHidden)))
659 return true; 655 return true;
660 } else if (Display() == EDisplay::kListItem) { 656 } else if (Display() == EDisplay::kListItem) {
661 if (ComputedStyleBase:: 657 if (ComputedStyleBase::
662 DiffNeedsFullLayoutAndPaintInvalidationDisplayListItem(other)) 658 DiffNeedsFullLayoutAndPaintInvalidationDisplayListItem(*this,
659 other))
663 return true; 660 return true;
664 } 661 }
665 662
666 if ((Visibility() == EVisibility::kCollapse) != 663 if ((Visibility() == EVisibility::kCollapse) !=
667 (other.Visibility() == EVisibility::kCollapse)) 664 (other.Visibility() == EVisibility::kCollapse))
668 return true; 665 return true;
669 666
670 // Movement of non-static-positioned object is special cased in 667 // Movement of non-static-positioned object is special cased in
671 // ComputedStyle::VisualInvalidationDiff(). 668 // ComputedStyle::VisualInvalidationDiff().
672 669
673 return false; 670 return false;
674 } 671 }
675 672
676 bool ComputedStyle::DiffNeedsFullLayout(const ComputedStyle& other) const { 673 bool ComputedStyle::DiffNeedsFullLayout(const ComputedStyle& other) const {
677 if (ComputedStyleBase::DiffNeedsFullLayout(other)) 674 if (ComputedStyleBase::DiffNeedsFullLayout(*this, other))
678 return true; 675 return true;
679 676
680 if (box_data_.Get() != other.box_data_.Get()) { 677 if (box_data_.Get() != other.box_data_.Get()) {
681 if (box_data_->vertical_align_length_ != 678 if (box_data_->vertical_align_length_ !=
682 other.box_data_->vertical_align_length_) 679 other.box_data_->vertical_align_length_)
683 return true; 680 return true;
684 } 681 }
685 682
686 if (VerticalAlign() != other.VerticalAlign() || 683 if (VerticalAlign() != other.VerticalAlign() ||
687 GetPosition() != other.GetPosition()) 684 GetPosition() != other.GetPosition())
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 rare_non_inherited_data_->mask_box_image_ != 719 rare_non_inherited_data_->mask_box_image_ !=
723 other.rare_non_inherited_data_->mask_box_image_) 720 other.rare_non_inherited_data_->mask_box_image_)
724 return true; 721 return true;
725 } 722 }
726 723
727 return false; 724 return false;
728 } 725 }
729 726
730 bool ComputedStyle::DiffNeedsPaintInvalidationObject( 727 bool ComputedStyle::DiffNeedsPaintInvalidationObject(
731 const ComputedStyle& other) const { 728 const ComputedStyle& other) const {
732 if (ComputedStyleBase::DiffNeedsPaintInvalidationObject(other)) 729 if (ComputedStyleBase::DiffNeedsPaintInvalidationObject(*this, other))
733 return true; 730 return true;
734 731
735 if (!BorderVisuallyEqual(other) || !RadiiEqual(other) || 732 if (!BorderVisuallyEqual(other) || !RadiiEqual(other) ||
736 *background_data_ != *other.background_data_) 733 *background_data_ != *other.background_data_)
737 return true; 734 return true;
738 735
739 if (rare_non_inherited_data_.Get() != other.rare_non_inherited_data_.Get()) { 736 if (rare_non_inherited_data_.Get() != other.rare_non_inherited_data_.Get()) {
740 if (rare_non_inherited_data_->user_drag_ != 737 if (rare_non_inherited_data_->user_drag_ !=
741 other.rare_non_inherited_data_->user_drag_ || 738 other.rare_non_inherited_data_->user_drag_ ||
742 rare_non_inherited_data_->object_fit_ != 739 rare_non_inherited_data_->object_fit_ !=
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 } 803 }
807 804
808 return false; 805 return false;
809 } 806 }
810 807
811 // This doesn't include conditions needing layout or overflow recomputation 808 // This doesn't include conditions needing layout or overflow recomputation
812 // which implies visual rect update. 809 // which implies visual rect update.
813 bool ComputedStyle::DiffNeedsVisualRectUpdate( 810 bool ComputedStyle::DiffNeedsVisualRectUpdate(
814 const ComputedStyle& other) const { 811 const ComputedStyle& other) const {
815 // Visual rect is empty if visibility is hidden. 812 // Visual rect is empty if visibility is hidden.
816 if (ComputedStyleBase::DiffNeedsVisualRectUpdate(other)) 813 if (ComputedStyleBase::DiffNeedsVisualRectUpdate(*this, other))
817 return true; 814 return true;
818 815
819 // Need to update visual rect of the resizer. 816 // Need to update visual rect of the resizer.
820 if (Resize() != other.Resize()) 817 if (Resize() != other.Resize())
821 return true; 818 return true;
822 819
823 return false; 820 return false;
824 } 821 }
825 822
826 void ComputedStyle::UpdatePropertySpecificDifferences( 823 void ComputedStyle::UpdatePropertySpecificDifferences(
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 (rare_non_inherited_data_.Get() != 879 (rare_non_inherited_data_.Get() !=
883 other.rare_non_inherited_data_.Get() && 880 other.rare_non_inherited_data_.Get() &&
884 (rare_non_inherited_data_->text_decoration_style_ != 881 (rare_non_inherited_data_->text_decoration_style_ !=
885 other.rare_non_inherited_data_->text_decoration_style_ || 882 other.rare_non_inherited_data_->text_decoration_style_ ||
886 rare_non_inherited_data_->text_decoration_color_ != 883 rare_non_inherited_data_->text_decoration_color_ !=
887 other.rare_non_inherited_data_->text_decoration_color_ || 884 other.rare_non_inherited_data_->text_decoration_color_ ||
888 rare_non_inherited_data_->visited_link_text_decoration_color_ != 885 rare_non_inherited_data_->visited_link_text_decoration_color_ !=
889 other.rare_non_inherited_data_ 886 other.rare_non_inherited_data_
890 ->visited_link_text_decoration_color_)) || 887 ->visited_link_text_decoration_color_)) ||
891 ComputedStyleBase:: 888 ComputedStyleBase::
892 UpdatePropertySpecificDifferencesTextDecorationOrColor(other)) { 889 UpdatePropertySpecificDifferencesTextDecorationOrColor(*this,
890 other)) {
893 diff.SetTextDecorationOrColorChanged(); 891 diff.SetTextDecorationOrColorChanged();
894 } 892 }
895 } 893 }
896 894
897 bool has_clip = HasOutOfFlowPosition() && !visual_data_->has_auto_clip_; 895 bool has_clip = HasOutOfFlowPosition() && !visual_data_->has_auto_clip_;
898 bool other_has_clip = 896 bool other_has_clip =
899 other.HasOutOfFlowPosition() && !other.visual_data_->has_auto_clip_; 897 other.HasOutOfFlowPosition() && !other.visual_data_->has_auto_clip_;
900 if (has_clip != other_has_clip || 898 if (has_clip != other_has_clip ||
901 (has_clip && visual_data_->clip_ != other.visual_data_->clip_)) 899 (has_clip && visual_data_->clip_ != other.visual_data_->clip_))
902 diff.SetCSSClipChanged(); 900 diff.SetCSSClipChanged();
(...skipping 1450 matching lines...) Expand 10 before | Expand all | Expand 10 after
2353 if (value < 0) 2351 if (value < 0)
2354 fvalue -= 0.5f; 2352 fvalue -= 0.5f;
2355 else 2353 else
2356 fvalue += 0.5f; 2354 fvalue += 0.5f;
2357 } 2355 }
2358 2356
2359 return RoundForImpreciseConversion<int>(fvalue / zoom_factor); 2357 return RoundForImpreciseConversion<int>(fvalue / zoom_factor);
2360 } 2358 }
2361 2359
2362 } // namespace blink 2360 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/style/ComputedStyle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698