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

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

Issue 2906253003: Replace call sites to BorderValue functions to save the BorderValue construction cost (Closed)
Patch Set: Redo LayoutTable/LayoutTableSection 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Antti Koivisto (koivisto@kde.org) 3 * (C) 2000 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All 5 * Copyright (C) 2003, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
6 * rights reserved. 6 * rights reserved.
7 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) 7 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 2744 matching lines...) Expand 10 before | Expand all | Expand 10 after
2755 return BorderLeftWidthInternal() == o.BorderLeftWidthInternal() && 2755 return BorderLeftWidthInternal() == o.BorderLeftWidthInternal() &&
2756 BorderTopWidthInternal() == o.BorderTopWidthInternal() && 2756 BorderTopWidthInternal() == o.BorderTopWidthInternal() &&
2757 BorderRightWidthInternal() == o.BorderRightWidthInternal() && 2757 BorderRightWidthInternal() == o.BorderRightWidthInternal() &&
2758 BorderBottomWidthInternal() == o.BorderBottomWidthInternal(); 2758 BorderBottomWidthInternal() == o.BorderBottomWidthInternal();
2759 } 2759 }
2760 2760
2761 BorderValue BorderBefore() const; 2761 BorderValue BorderBefore() const;
2762 BorderValue BorderAfter() const; 2762 BorderValue BorderAfter() const;
2763 BorderValue BorderStart() const; 2763 BorderValue BorderStart() const;
2764 BorderValue BorderEnd() const; 2764 BorderValue BorderEnd() const;
2765
2765 float BorderAfterWidth() const; 2766 float BorderAfterWidth() const;
2766 float BorderBeforeWidth() const; 2767 float BorderBeforeWidth() const;
2767 float BorderEndWidth() const; 2768 float BorderEndWidth() const;
2768 float BorderStartWidth() const; 2769 float BorderStartWidth() const;
2769 float BorderOverWidth() const; 2770 float BorderOverWidth() const;
2770 float BorderUnderWidth() const; 2771 float BorderUnderWidth() const;
2771 2772
2773 EBorderStyle BorderAfterStyle() const;
2774 EBorderStyle BorderBeforeStyle() const;
2775 EBorderStyle BorderEndStyle() const;
2776 EBorderStyle BorderStartStyle() const;
2777
2772 bool HasBorderFill() const { 2778 bool HasBorderFill() const {
2773 return BorderImage().HasImage() && BorderImage().Fill(); 2779 return BorderImage().HasImage() && BorderImage().Fill();
2774 } 2780 }
2775 bool HasBorder() const { 2781 bool HasBorder() const {
2776 return BorderLeftNonZero() || BorderRightNonZero() || BorderTopNonZero() || 2782 return BorderLeftNonZero() || BorderRightNonZero() || BorderTopNonZero() ||
2777 BorderBottomNonZero(); 2783 BorderBottomNonZero();
2778 } 2784 }
2779 bool HasBorderDecoration() const { return HasBorder() || HasBorderFill(); } 2785 bool HasBorderDecoration() const { return HasBorder() || HasBorderFill(); }
2780 bool HasBorderRadius() const { 2786 bool HasBorderRadius() const {
2781 if (!BorderTopLeftRadius().Width().IsZero()) 2787 if (!BorderTopLeftRadius().Width().IsZero())
2782 return true; 2788 return true;
2783 if (!BorderTopRightRadius().Width().IsZero()) 2789 if (!BorderTopRightRadius().Width().IsZero())
2784 return true; 2790 return true;
2785 if (!BorderBottomLeftRadius().Width().IsZero()) 2791 if (!BorderBottomLeftRadius().Width().IsZero())
2786 return true; 2792 return true;
2787 if (!BorderBottomRightRadius().Width().IsZero()) 2793 if (!BorderBottomRightRadius().Width().IsZero())
2788 return true; 2794 return true;
2789 return false; 2795 return false;
2790 } 2796 }
2791 bool HasBorderColorReferencingCurrentColor() const { 2797 bool HasBorderColorReferencingCurrentColor() const {
2792 return (BorderLeft().NonZero() && BorderLeftColor().IsCurrentColor()) || 2798 return (BorderLeftNonZero() && BorderLeftColor().IsCurrentColor()) ||
2793 (BorderRight().NonZero() && BorderRightColor().IsCurrentColor()) || 2799 (BorderRightNonZero() && BorderRightColor().IsCurrentColor()) ||
2794 (BorderTop().NonZero() && BorderTopColor().IsCurrentColor()) || 2800 (BorderTopNonZero() && BorderTopColor().IsCurrentColor()) ||
2795 (BorderBottom().NonZero() && BorderBottomColor().IsCurrentColor()); 2801 (BorderBottomNonZero() && BorderBottomColor().IsCurrentColor());
2796 } 2802 }
2797 2803
2798 bool RadiiEqual(const ComputedStyle& o) const { 2804 bool RadiiEqual(const ComputedStyle& o) const {
2799 return BorderTopLeftRadius() == o.BorderTopLeftRadius() && 2805 return BorderTopLeftRadius() == o.BorderTopLeftRadius() &&
2800 BorderTopRightRadius() == o.BorderTopRightRadius() && 2806 BorderTopRightRadius() == o.BorderTopRightRadius() &&
2801 BorderBottomLeftRadius() == o.BorderBottomLeftRadius() && 2807 BorderBottomLeftRadius() == o.BorderBottomLeftRadius() &&
2802 BorderBottomRightRadius() == o.BorderBottomRightRadius(); 2808 BorderBottomRightRadius() == o.BorderBottomRightRadius();
2803 } 2809 }
2804 2810
2805 bool BorderLeftEquals(const ComputedStyle& o) const { 2811 bool BorderLeftEquals(const ComputedStyle& o) const {
2806 return BorderLeftWidthInternal() == o.BorderLeftWidthInternal() && 2812 return BorderLeftWidthInternal() == o.BorderLeftWidthInternal() &&
2807 BorderLeftStyle() == o.BorderLeftStyle() && 2813 BorderLeftStyle() == o.BorderLeftStyle() &&
2808 BorderLeftColor() == o.BorderLeftColor() && 2814 BorderLeftColor() == o.BorderLeftColor() &&
2809 BorderLeftColorIsCurrentColor() == o.BorderLeftColorIsCurrentColor(); 2815 BorderLeftColorIsCurrentColor() == o.BorderLeftColorIsCurrentColor();
2810 } 2816 }
2817 bool BorderLeftEquals(const BorderValue& o) const {
2818 return BorderLeftWidthInternal().ToFloat() == o.Width() &&
2819 BorderLeftStyle() == o.Style() &&
2820 BorderLeftColor() == o.GetColor() &&
2821 BorderLeftColorIsCurrentColor() == o.ColorIsCurrentColor();
2822 }
2811 2823
2812 bool BorderLeftVisuallyEqual(const ComputedStyle& o) const { 2824 bool BorderLeftVisuallyEqual(const ComputedStyle& o) const {
2813 if (BorderLeftStyle() == EBorderStyle::kNone && 2825 if (BorderLeftStyle() == EBorderStyle::kNone &&
2814 o.BorderLeftStyle() == EBorderStyle::kNone) 2826 o.BorderLeftStyle() == EBorderStyle::kNone)
2815 return true; 2827 return true;
2816 if (BorderLeftStyle() == EBorderStyle::kHidden && 2828 if (BorderLeftStyle() == EBorderStyle::kHidden &&
2817 o.BorderLeftStyle() == EBorderStyle::kHidden) 2829 o.BorderLeftStyle() == EBorderStyle::kHidden)
2818 return true; 2830 return true;
2819 return BorderLeftEquals(o); 2831 return BorderLeftEquals(o);
2820 } 2832 }
2821 2833
2822 bool BorderRightEquals(const ComputedStyle& o) const { 2834 bool BorderRightEquals(const ComputedStyle& o) const {
2823 return BorderRightWidthInternal() == o.BorderRightWidthInternal() && 2835 return BorderRightWidthInternal() == o.BorderRightWidthInternal() &&
2824 BorderRightStyle() == o.BorderRightStyle() && 2836 BorderRightStyle() == o.BorderRightStyle() &&
2825 BorderRightColor() == o.BorderRightColor() && 2837 BorderRightColor() == o.BorderRightColor() &&
2826 BorderRightColorIsCurrentColor() == 2838 BorderRightColorIsCurrentColor() ==
2827 o.BorderRightColorIsCurrentColor(); 2839 o.BorderRightColorIsCurrentColor();
2828 } 2840 }
2841 bool BorderRightEquals(const BorderValue& o) const {
2842 return BorderRightWidthInternal().ToFloat() == o.Width() &&
2843 BorderRightStyle() == o.Style() &&
2844 BorderRightColor() == o.GetColor() &&
2845 BorderRightColorIsCurrentColor() == o.ColorIsCurrentColor();
2846 }
2829 2847
2830 bool BorderRightVisuallyEqual(const ComputedStyle& o) const { 2848 bool BorderRightVisuallyEqual(const ComputedStyle& o) const {
2831 if (BorderRightStyle() == EBorderStyle::kNone && 2849 if (BorderRightStyle() == EBorderStyle::kNone &&
2832 o.BorderRightStyle() == EBorderStyle::kNone) 2850 o.BorderRightStyle() == EBorderStyle::kNone)
2833 return true; 2851 return true;
2834 if (BorderRightStyle() == EBorderStyle::kHidden && 2852 if (BorderRightStyle() == EBorderStyle::kHidden &&
2835 o.BorderRightStyle() == EBorderStyle::kHidden) 2853 o.BorderRightStyle() == EBorderStyle::kHidden)
2836 return true; 2854 return true;
2837 return BorderRightEquals(o); 2855 return BorderRightEquals(o);
2838 } 2856 }
2839 2857
2840 bool BorderTopVisuallyEqual(const ComputedStyle& o) const { 2858 bool BorderTopVisuallyEqual(const ComputedStyle& o) const {
2841 if (BorderTopStyle() == EBorderStyle::kNone && 2859 if (BorderTopStyle() == EBorderStyle::kNone &&
2842 o.BorderTopStyle() == EBorderStyle::kNone) 2860 o.BorderTopStyle() == EBorderStyle::kNone)
2843 return true; 2861 return true;
2844 if (BorderTopStyle() == EBorderStyle::kHidden && 2862 if (BorderTopStyle() == EBorderStyle::kHidden &&
2845 o.BorderTopStyle() == EBorderStyle::kHidden) 2863 o.BorderTopStyle() == EBorderStyle::kHidden)
2846 return true; 2864 return true;
2847 return BorderTopEquals(o); 2865 return BorderTopEquals(o);
2848 } 2866 }
2849 2867
2850 bool BorderTopEquals(const ComputedStyle& o) const { 2868 bool BorderTopEquals(const ComputedStyle& o) const {
2851 return BorderTopWidthInternal() == o.BorderTopWidthInternal() && 2869 return BorderTopWidthInternal() == o.BorderTopWidthInternal() &&
2852 BorderTopStyle() == o.BorderTopStyle() && 2870 BorderTopStyle() == o.BorderTopStyle() &&
2853 BorderTopColor() == o.BorderTopColor() && 2871 BorderTopColor() == o.BorderTopColor() &&
2854 BorderTopColorIsCurrentColor() == o.BorderTopColorIsCurrentColor(); 2872 BorderTopColorIsCurrentColor() == o.BorderTopColorIsCurrentColor();
2855 } 2873 }
2874 bool BorderTopEquals(const BorderValue& o) const {
2875 return BorderTopWidthInternal().ToFloat() == o.Width() &&
2876 BorderTopStyle() == o.Style() && BorderTopColor() == o.GetColor() &&
2877 BorderTopColorIsCurrentColor() == o.ColorIsCurrentColor();
2878 }
2856 2879
2857 bool BorderBottomVisuallyEqual(const ComputedStyle& o) const { 2880 bool BorderBottomVisuallyEqual(const ComputedStyle& o) const {
2858 if (BorderBottomStyle() == EBorderStyle::kNone && 2881 if (BorderBottomStyle() == EBorderStyle::kNone &&
2859 o.BorderBottomStyle() == EBorderStyle::kNone) 2882 o.BorderBottomStyle() == EBorderStyle::kNone)
2860 return true; 2883 return true;
2861 if (BorderBottomStyle() == EBorderStyle::kHidden && 2884 if (BorderBottomStyle() == EBorderStyle::kHidden &&
2862 o.BorderBottomStyle() == EBorderStyle::kHidden) 2885 o.BorderBottomStyle() == EBorderStyle::kHidden)
2863 return true; 2886 return true;
2864 return BorderBottomEquals(o); 2887 return BorderBottomEquals(o);
2865 } 2888 }
2866 2889
2867 bool BorderBottomEquals(const ComputedStyle& o) const { 2890 bool BorderBottomEquals(const ComputedStyle& o) const {
2868 return BorderBottomWidthInternal() == o.BorderBottomWidthInternal() && 2891 return BorderBottomWidthInternal() == o.BorderBottomWidthInternal() &&
2869 BorderBottomStyle() == o.BorderBottomStyle() && 2892 BorderBottomStyle() == o.BorderBottomStyle() &&
2870 BorderBottomColor() == o.BorderBottomColor() && 2893 BorderBottomColor() == o.BorderBottomColor() &&
2871 BorderBottomColorIsCurrentColor() == 2894 BorderBottomColorIsCurrentColor() ==
2872 o.BorderBottomColorIsCurrentColor(); 2895 o.BorderBottomColorIsCurrentColor();
2873 } 2896 }
2897 bool BorderBottomEquals(const BorderValue& o) const {
2898 return BorderBottomWidthInternal().ToFloat() == o.Width() &&
2899 BorderBottomStyle() == o.Style() &&
2900 BorderBottomColor() == o.GetColor() &&
2901 BorderBottomColorIsCurrentColor() == o.ColorIsCurrentColor();
2902 }
2874 2903
2875 bool BorderEquals(const ComputedStyle& o) const { 2904 bool BorderEquals(const ComputedStyle& o) const {
2876 return BorderLeftEquals(o) && BorderRightEquals(o) && BorderTopEquals(o) && 2905 return BorderLeftEquals(o) && BorderRightEquals(o) && BorderTopEquals(o) &&
2877 BorderBottomEquals(o) && BorderImage() == o.BorderImage(); 2906 BorderBottomEquals(o) && BorderImage() == o.BorderImage();
2878 } 2907 }
2879 2908
2880 bool BorderVisuallyEqual(const ComputedStyle& o) const { 2909 bool BorderVisuallyEqual(const ComputedStyle& o) const {
2881 return BorderLeftVisuallyEqual(o) && BorderRightVisuallyEqual(o) && 2910 return BorderLeftVisuallyEqual(o) && BorderRightVisuallyEqual(o) &&
2882 BorderTopVisuallyEqual(o) && BorderBottomVisuallyEqual(o) && 2911 BorderTopVisuallyEqual(o) && BorderBottomVisuallyEqual(o) &&
2883 BorderImage() == o.BorderImage(); 2912 BorderImage() == o.BorderImage();
(...skipping 12 matching lines...) Expand all
2896 ResetBorderTopLeftRadius(); 2925 ResetBorderTopLeftRadius();
2897 ResetBorderTopRightRadius(); 2926 ResetBorderTopRightRadius();
2898 ResetBorderBottomLeftRadius(); 2927 ResetBorderBottomLeftRadius();
2899 ResetBorderBottomRightRadius(); 2928 ResetBorderBottomRightRadius();
2900 } 2929 }
2901 2930
2902 void ResetBorderTop() { 2931 void ResetBorderTop() {
2903 SetBorderTopStyle(EBorderStyle::kNone); 2932 SetBorderTopStyle(EBorderStyle::kNone);
2904 SetBorderTopWidth(3); 2933 SetBorderTopWidth(3);
2905 SetBorderTopColorInternal(0); 2934 SetBorderTopColorInternal(0);
2906 SetBorderTopColorInternal(true); 2935 SetBorderTopColorIsCurrentColor(true);
2907 } 2936 }
2908 void ResetBorderRight() { 2937 void ResetBorderRight() {
2909 SetBorderRightStyle(EBorderStyle::kNone); 2938 SetBorderRightStyle(EBorderStyle::kNone);
2910 SetBorderRightWidth(3); 2939 SetBorderRightWidth(3);
2911 SetBorderRightColorInternal(0); 2940 SetBorderRightColorInternal(0);
2912 SetBorderRightColorInternal(true); 2941 SetBorderRightColorIsCurrentColor(true);
2913 } 2942 }
2914 void ResetBorderBottom() { 2943 void ResetBorderBottom() {
2915 SetBorderBottomStyle(EBorderStyle::kNone); 2944 SetBorderBottomStyle(EBorderStyle::kNone);
2916 SetBorderBottomWidth(3); 2945 SetBorderBottomWidth(3);
2917 SetBorderBottomColorInternal(0); 2946 SetBorderBottomColorInternal(0);
2918 SetBorderBottomColorInternal(true); 2947 SetBorderBottomColorIsCurrentColor(true);
2919 } 2948 }
2920 void ResetBorderLeft() { 2949 void ResetBorderLeft() {
2921 SetBorderLeftStyle(EBorderStyle::kNone); 2950 SetBorderLeftStyle(EBorderStyle::kNone);
2922 SetBorderLeftWidth(3); 2951 SetBorderLeftWidth(3);
2923 SetBorderLeftColorInternal(0); 2952 SetBorderLeftColorInternal(0);
2924 SetBorderLeftColorInternal(true); 2953 SetBorderLeftColorIsCurrentColor(true);
2925 } 2954 }
2926 2955
2927 void SetBorderRadius(const LengthSize& s) { 2956 void SetBorderRadius(const LengthSize& s) {
2928 SetBorderTopLeftRadius(s); 2957 SetBorderTopLeftRadius(s);
2929 SetBorderTopRightRadius(s); 2958 SetBorderTopRightRadius(s);
2930 SetBorderBottomLeftRadius(s); 2959 SetBorderBottomLeftRadius(s);
2931 SetBorderBottomRightRadius(s); 2960 SetBorderBottomRightRadius(s);
2932 } 2961 }
2933 void SetBorderRadius(const IntSize& s) { 2962 void SetBorderRadius(const IntSize& s) {
2934 SetBorderRadius( 2963 SetBorderRadius(
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
3728 PseudoBitsInternal() | 1 << (pseudo - kFirstPublicPseudoId))); 3757 PseudoBitsInternal() | 1 << (pseudo - kFirstPublicPseudoId)));
3729 } 3758 }
3730 3759
3731 inline bool ComputedStyle::HasPseudoElementStyle() const { 3760 inline bool ComputedStyle::HasPseudoElementStyle() const {
3732 return PseudoBitsInternal() & kElementPseudoIdMask; 3761 return PseudoBitsInternal() & kElementPseudoIdMask;
3733 } 3762 }
3734 3763
3735 } // namespace blink 3764 } // namespace blink
3736 3765
3737 #endif // ComputedStyle_h 3766 #endif // ComputedStyle_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698