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

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: rune@ renames 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 2647 matching lines...) Expand 10 before | Expand all | Expand 10 after
2658 return BorderLeftWidthInternal() == o.BorderLeftWidthInternal() && 2658 return BorderLeftWidthInternal() == o.BorderLeftWidthInternal() &&
2659 BorderTopWidthInternal() == o.BorderTopWidthInternal() && 2659 BorderTopWidthInternal() == o.BorderTopWidthInternal() &&
2660 BorderRightWidthInternal() == o.BorderRightWidthInternal() && 2660 BorderRightWidthInternal() == o.BorderRightWidthInternal() &&
2661 BorderBottomWidthInternal() == o.BorderBottomWidthInternal(); 2661 BorderBottomWidthInternal() == o.BorderBottomWidthInternal();
2662 } 2662 }
2663 2663
2664 BorderValue BorderBefore() const; 2664 BorderValue BorderBefore() const;
2665 BorderValue BorderAfter() const; 2665 BorderValue BorderAfter() const;
2666 BorderValue BorderStart() const; 2666 BorderValue BorderStart() const;
2667 BorderValue BorderEnd() const; 2667 BorderValue BorderEnd() const;
2668
2668 float BorderAfterWidth() const; 2669 float BorderAfterWidth() const;
2669 float BorderBeforeWidth() const; 2670 float BorderBeforeWidth() const;
2670 float BorderEndWidth() const; 2671 float BorderEndWidth() const;
2671 float BorderStartWidth() const; 2672 float BorderStartWidth() const;
2672 float BorderOverWidth() const; 2673 float BorderOverWidth() const;
2673 float BorderUnderWidth() const; 2674 float BorderUnderWidth() const;
2674 2675
2676 EBorderStyle BorderAfterStyle() const;
2677 EBorderStyle BorderBeforeStyle() const;
2678 EBorderStyle BorderEndStyle() const;
2679 EBorderStyle BorderStartStyle() const;
2680
2675 bool HasBorderFill() const { 2681 bool HasBorderFill() const {
2676 return BorderImage().HasImage() && BorderImage().Fill(); 2682 return BorderImage().HasImage() && BorderImage().Fill();
2677 } 2683 }
2678 bool HasBorder() const { 2684 bool HasBorder() const {
2679 return BorderLeftNonZero() || BorderRightNonZero() || BorderTopNonZero() || 2685 return BorderLeftNonZero() || BorderRightNonZero() || BorderTopNonZero() ||
2680 BorderBottomNonZero(); 2686 BorderBottomNonZero();
2681 } 2687 }
2682 bool HasBorderDecoration() const { return HasBorder() || HasBorderFill(); } 2688 bool HasBorderDecoration() const { return HasBorder() || HasBorderFill(); }
2683 bool HasBorderRadius() const { 2689 bool HasBorderRadius() const {
2684 if (!BorderTopLeftRadius().Width().IsZero()) 2690 if (!BorderTopLeftRadius().Width().IsZero())
2685 return true; 2691 return true;
2686 if (!BorderTopRightRadius().Width().IsZero()) 2692 if (!BorderTopRightRadius().Width().IsZero())
2687 return true; 2693 return true;
2688 if (!BorderBottomLeftRadius().Width().IsZero()) 2694 if (!BorderBottomLeftRadius().Width().IsZero())
2689 return true; 2695 return true;
2690 if (!BorderBottomRightRadius().Width().IsZero()) 2696 if (!BorderBottomRightRadius().Width().IsZero())
2691 return true; 2697 return true;
2692 return false; 2698 return false;
2693 } 2699 }
2694 bool HasBorderColorReferencingCurrentColor() const { 2700 bool HasBorderColorReferencingCurrentColor() const {
2695 return (BorderLeft().NonZero() && BorderLeftColor().IsCurrentColor()) || 2701 return (BorderLeftNonZero() && BorderLeftColor().IsCurrentColor()) ||
2696 (BorderRight().NonZero() && BorderRightColor().IsCurrentColor()) || 2702 (BorderRightNonZero() && BorderRightColor().IsCurrentColor()) ||
2697 (BorderTop().NonZero() && BorderTopColor().IsCurrentColor()) || 2703 (BorderTopNonZero() && BorderTopColor().IsCurrentColor()) ||
2698 (BorderBottom().NonZero() && BorderBottomColor().IsCurrentColor()); 2704 (BorderBottomNonZero() && BorderBottomColor().IsCurrentColor());
2699 } 2705 }
2700 2706
2701 bool RadiiEqual(const ComputedStyle& o) const { 2707 bool RadiiEqual(const ComputedStyle& o) const {
2702 return BorderTopLeftRadius() == o.BorderTopLeftRadius() && 2708 return BorderTopLeftRadius() == o.BorderTopLeftRadius() &&
2703 BorderTopRightRadius() == o.BorderTopRightRadius() && 2709 BorderTopRightRadius() == o.BorderTopRightRadius() &&
2704 BorderBottomLeftRadius() == o.BorderBottomLeftRadius() && 2710 BorderBottomLeftRadius() == o.BorderBottomLeftRadius() &&
2705 BorderBottomRightRadius() == o.BorderBottomRightRadius(); 2711 BorderBottomRightRadius() == o.BorderBottomRightRadius();
2706 } 2712 }
2707 2713
2708 bool BorderLeftEquals(const ComputedStyle& o) const { 2714 bool BorderLeftEquals(const ComputedStyle& o) const {
2709 return BorderLeftWidthInternal() == o.BorderLeftWidthInternal() && 2715 return BorderLeftWidthInternal() == o.BorderLeftWidthInternal() &&
2710 BorderLeftStyle() == o.BorderLeftStyle() && 2716 BorderLeftStyle() == o.BorderLeftStyle() &&
2711 BorderLeftColor() == o.BorderLeftColor() && 2717 BorderLeftColor() == o.BorderLeftColor() &&
2712 BorderLeftColorIsCurrentColor() == o.BorderLeftColorIsCurrentColor(); 2718 BorderLeftColorIsCurrentColor() == o.BorderLeftColorIsCurrentColor();
2713 } 2719 }
2720 bool BorderLeftEquals(const BorderValue& o) const {
2721 return BorderLeftWidthInternal().ToFloat() == o.Width() &&
2722 BorderLeftStyle() == o.Style() &&
2723 BorderLeftColor() == o.GetColor() &&
2724 BorderLeftColorIsCurrentColor() == o.ColorIsCurrentColor();
2725 }
2714 2726
2715 bool BorderLeftVisuallyEqual(const ComputedStyle& o) const { 2727 bool BorderLeftVisuallyEqual(const ComputedStyle& o) const {
2716 if (BorderLeftStyle() == EBorderStyle::kNone && 2728 if (BorderLeftStyle() == EBorderStyle::kNone &&
2717 o.BorderLeftStyle() == EBorderStyle::kNone) 2729 o.BorderLeftStyle() == EBorderStyle::kNone)
2718 return true; 2730 return true;
2719 if (BorderLeftStyle() == EBorderStyle::kHidden && 2731 if (BorderLeftStyle() == EBorderStyle::kHidden &&
2720 o.BorderLeftStyle() == EBorderStyle::kHidden) 2732 o.BorderLeftStyle() == EBorderStyle::kHidden)
2721 return true; 2733 return true;
2722 return BorderLeftEquals(o); 2734 return BorderLeftEquals(o);
2723 } 2735 }
2724 2736
2725 bool BorderRightEquals(const ComputedStyle& o) const { 2737 bool BorderRightEquals(const ComputedStyle& o) const {
2726 return BorderRightWidthInternal() == o.BorderRightWidthInternal() && 2738 return BorderRightWidthInternal() == o.BorderRightWidthInternal() &&
2727 BorderRightStyle() == o.BorderRightStyle() && 2739 BorderRightStyle() == o.BorderRightStyle() &&
2728 BorderRightColor() == o.BorderRightColor() && 2740 BorderRightColor() == o.BorderRightColor() &&
2729 BorderRightColorIsCurrentColor() == 2741 BorderRightColorIsCurrentColor() ==
2730 o.BorderRightColorIsCurrentColor(); 2742 o.BorderRightColorIsCurrentColor();
2731 } 2743 }
2744 bool BorderRightEquals(const BorderValue& o) const {
2745 return BorderRightWidthInternal().ToFloat() == o.Width() &&
2746 BorderRightStyle() == o.Style() &&
2747 BorderRightColor() == o.GetColor() &&
2748 BorderRightColorIsCurrentColor() == o.ColorIsCurrentColor();
2749 }
2732 2750
2733 bool BorderRightVisuallyEqual(const ComputedStyle& o) const { 2751 bool BorderRightVisuallyEqual(const ComputedStyle& o) const {
2734 if (BorderRightStyle() == EBorderStyle::kNone && 2752 if (BorderRightStyle() == EBorderStyle::kNone &&
2735 o.BorderRightStyle() == EBorderStyle::kNone) 2753 o.BorderRightStyle() == EBorderStyle::kNone)
2736 return true; 2754 return true;
2737 if (BorderRightStyle() == EBorderStyle::kHidden && 2755 if (BorderRightStyle() == EBorderStyle::kHidden &&
2738 o.BorderRightStyle() == EBorderStyle::kHidden) 2756 o.BorderRightStyle() == EBorderStyle::kHidden)
2739 return true; 2757 return true;
2740 return BorderRightEquals(o); 2758 return BorderRightEquals(o);
2741 } 2759 }
2742 2760
2743 bool BorderTopVisuallyEqual(const ComputedStyle& o) const { 2761 bool BorderTopVisuallyEqual(const ComputedStyle& o) const {
2744 if (BorderTopStyle() == EBorderStyle::kNone && 2762 if (BorderTopStyle() == EBorderStyle::kNone &&
2745 o.BorderTopStyle() == EBorderStyle::kNone) 2763 o.BorderTopStyle() == EBorderStyle::kNone)
2746 return true; 2764 return true;
2747 if (BorderTopStyle() == EBorderStyle::kHidden && 2765 if (BorderTopStyle() == EBorderStyle::kHidden &&
2748 o.BorderTopStyle() == EBorderStyle::kHidden) 2766 o.BorderTopStyle() == EBorderStyle::kHidden)
2749 return true; 2767 return true;
2750 return BorderTopEquals(o); 2768 return BorderTopEquals(o);
2751 } 2769 }
2752 2770
2753 bool BorderTopEquals(const ComputedStyle& o) const { 2771 bool BorderTopEquals(const ComputedStyle& o) const {
2754 return BorderTopWidthInternal() == o.BorderTopWidthInternal() && 2772 return BorderTopWidthInternal() == o.BorderTopWidthInternal() &&
2755 BorderTopStyle() == o.BorderTopStyle() && 2773 BorderTopStyle() == o.BorderTopStyle() &&
2756 BorderTopColor() == o.BorderTopColor() && 2774 BorderTopColor() == o.BorderTopColor() &&
2757 BorderTopColorIsCurrentColor() == o.BorderTopColorIsCurrentColor(); 2775 BorderTopColorIsCurrentColor() == o.BorderTopColorIsCurrentColor();
2758 } 2776 }
2777 bool BorderTopEquals(const BorderValue& o) const {
2778 return BorderTopWidthInternal().ToFloat() == o.Width() &&
2779 BorderTopStyle() == o.Style() && BorderTopColor() == o.GetColor() &&
2780 BorderTopColorIsCurrentColor() == o.ColorIsCurrentColor();
2781 }
2759 2782
2760 bool BorderBottomVisuallyEqual(const ComputedStyle& o) const { 2783 bool BorderBottomVisuallyEqual(const ComputedStyle& o) const {
2761 if (BorderBottomStyle() == EBorderStyle::kNone && 2784 if (BorderBottomStyle() == EBorderStyle::kNone &&
2762 o.BorderBottomStyle() == EBorderStyle::kNone) 2785 o.BorderBottomStyle() == EBorderStyle::kNone)
2763 return true; 2786 return true;
2764 if (BorderBottomStyle() == EBorderStyle::kHidden && 2787 if (BorderBottomStyle() == EBorderStyle::kHidden &&
2765 o.BorderBottomStyle() == EBorderStyle::kHidden) 2788 o.BorderBottomStyle() == EBorderStyle::kHidden)
2766 return true; 2789 return true;
2767 return BorderBottomEquals(o); 2790 return BorderBottomEquals(o);
2768 } 2791 }
2769 2792
2770 bool BorderBottomEquals(const ComputedStyle& o) const { 2793 bool BorderBottomEquals(const ComputedStyle& o) const {
2771 return BorderBottomWidthInternal() == o.BorderBottomWidthInternal() && 2794 return BorderBottomWidthInternal() == o.BorderBottomWidthInternal() &&
2772 BorderBottomStyle() == o.BorderBottomStyle() && 2795 BorderBottomStyle() == o.BorderBottomStyle() &&
2773 BorderBottomColor() == o.BorderBottomColor() && 2796 BorderBottomColor() == o.BorderBottomColor() &&
2774 BorderBottomColorIsCurrentColor() == 2797 BorderBottomColorIsCurrentColor() ==
2775 o.BorderBottomColorIsCurrentColor(); 2798 o.BorderBottomColorIsCurrentColor();
2776 } 2799 }
2800 bool BorderBottomEquals(const BorderValue& o) const {
2801 return BorderBottomWidthInternal().ToFloat() == o.Width() &&
2802 BorderBottomStyle() == o.Style() &&
2803 BorderBottomColor() == o.GetColor() &&
2804 BorderBottomColorIsCurrentColor() == o.ColorIsCurrentColor();
2805 }
2777 2806
2778 bool BorderEquals(const ComputedStyle& o) const { 2807 bool BorderEquals(const ComputedStyle& o) const {
2779 return BorderLeftEquals(o) && BorderRightEquals(o) && BorderTopEquals(o) && 2808 return BorderLeftEquals(o) && BorderRightEquals(o) && BorderTopEquals(o) &&
2780 BorderBottomEquals(o) && BorderImage() == o.BorderImage(); 2809 BorderBottomEquals(o) && BorderImage() == o.BorderImage();
2781 } 2810 }
2782 2811
2783 bool BorderVisuallyEqual(const ComputedStyle& o) const { 2812 bool BorderVisuallyEqual(const ComputedStyle& o) const {
2784 return BorderLeftVisuallyEqual(o) && BorderRightVisuallyEqual(o) && 2813 return BorderLeftVisuallyEqual(o) && BorderRightVisuallyEqual(o) &&
2785 BorderTopVisuallyEqual(o) && BorderBottomVisuallyEqual(o) && 2814 BorderTopVisuallyEqual(o) && BorderBottomVisuallyEqual(o) &&
2786 BorderImage() == o.BorderImage(); 2815 BorderImage() == o.BorderImage();
(...skipping 12 matching lines...) Expand all
2799 ResetBorderTopLeftRadius(); 2828 ResetBorderTopLeftRadius();
2800 ResetBorderTopRightRadius(); 2829 ResetBorderTopRightRadius();
2801 ResetBorderBottomLeftRadius(); 2830 ResetBorderBottomLeftRadius();
2802 ResetBorderBottomRightRadius(); 2831 ResetBorderBottomRightRadius();
2803 } 2832 }
2804 2833
2805 void ResetBorderTop() { 2834 void ResetBorderTop() {
2806 SetBorderTopStyle(EBorderStyle::kNone); 2835 SetBorderTopStyle(EBorderStyle::kNone);
2807 SetBorderTopWidth(3); 2836 SetBorderTopWidth(3);
2808 SetBorderTopColorInternal(0); 2837 SetBorderTopColorInternal(0);
2809 SetBorderTopColorInternal(true); 2838 SetBorderTopColorIsCurrentColor(true);
2810 } 2839 }
2811 void ResetBorderRight() { 2840 void ResetBorderRight() {
2812 SetBorderRightStyle(EBorderStyle::kNone); 2841 SetBorderRightStyle(EBorderStyle::kNone);
2813 SetBorderRightWidth(3); 2842 SetBorderRightWidth(3);
2814 SetBorderRightColorInternal(0); 2843 SetBorderRightColorInternal(0);
2815 SetBorderRightColorInternal(true); 2844 SetBorderRightColorIsCurrentColor(true);
2816 } 2845 }
2817 void ResetBorderBottom() { 2846 void ResetBorderBottom() {
2818 SetBorderBottomStyle(EBorderStyle::kNone); 2847 SetBorderBottomStyle(EBorderStyle::kNone);
2819 SetBorderBottomWidth(3); 2848 SetBorderBottomWidth(3);
2820 SetBorderBottomColorInternal(0); 2849 SetBorderBottomColorInternal(0);
2821 SetBorderBottomColorInternal(true); 2850 SetBorderBottomColorIsCurrentColor(true);
2822 } 2851 }
2823 void ResetBorderLeft() { 2852 void ResetBorderLeft() {
2824 SetBorderLeftStyle(EBorderStyle::kNone); 2853 SetBorderLeftStyle(EBorderStyle::kNone);
2825 SetBorderLeftWidth(3); 2854 SetBorderLeftWidth(3);
2826 SetBorderLeftColorInternal(0); 2855 SetBorderLeftColorInternal(0);
2827 SetBorderLeftColorInternal(true); 2856 SetBorderLeftColorIsCurrentColor(true);
2828 } 2857 }
2829 2858
2830 void SetBorderRadius(const LengthSize& s) { 2859 void SetBorderRadius(const LengthSize& s) {
2831 SetBorderTopLeftRadius(s); 2860 SetBorderTopLeftRadius(s);
2832 SetBorderTopRightRadius(s); 2861 SetBorderTopRightRadius(s);
2833 SetBorderBottomLeftRadius(s); 2862 SetBorderBottomLeftRadius(s);
2834 SetBorderBottomRightRadius(s); 2863 SetBorderBottomRightRadius(s);
2835 } 2864 }
2836 void SetBorderRadius(const IntSize& s) { 2865 void SetBorderRadius(const IntSize& s) {
2837 SetBorderRadius( 2866 SetBorderRadius(
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after
3632 PseudoBitsInternal() | 1 << (pseudo - kFirstPublicPseudoId))); 3661 PseudoBitsInternal() | 1 << (pseudo - kFirstPublicPseudoId)));
3633 } 3662 }
3634 3663
3635 inline bool ComputedStyle::HasPseudoElementStyle() const { 3664 inline bool ComputedStyle::HasPseudoElementStyle() const {
3636 return PseudoBitsInternal() & kElementPseudoIdMask; 3665 return PseudoBitsInternal() & kElementPseudoIdMask;
3637 } 3666 }
3638 3667
3639 } // namespace blink 3668 } // namespace blink
3640 3669
3641 #endif // ComputedStyle_h 3670 #endif // ComputedStyle_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutTreeAsText.cpp ('k') | third_party/WebKit/Source/core/style/ComputedStyle.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698