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

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

Issue 2869043002: Store border-*-color on SurroundData in ComputedStyle not BorderColorAndStyle (Closed)
Patch Set: Change unsinged to bool in CachedUAStyle Created 3 years, 7 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 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 // border-bottom-style 553 // border-bottom-style
554 EBorderStyle BorderBottomStyle() const { 554 EBorderStyle BorderBottomStyle() const {
555 return surround_data_->border_.Bottom().Style(); 555 return surround_data_->border_.Bottom().Style();
556 } 556 }
557 void SetBorderBottomStyle(EBorderStyle v) { 557 void SetBorderBottomStyle(EBorderStyle v) {
558 SET_VAR(surround_data_, border_.bottom_.style_, v); 558 SET_VAR(surround_data_, border_.bottom_.style_, v);
559 } 559 }
560 560
561 // Border color properties. 561 // Border color properties.
562 // border-left-color 562 // border-left-color
563 void SetBorderLeftColor(const StyleColor& v) { 563 void SetBorderLeftColor(const StyleColor& color) {
564 SET_BORDERVALUE_COLOR(surround_data_, border_.left_, v); 564 SetBorderLeftColorInternal(color.Resolve(Color()));
565 SetBorderLeftColorIsCurrentColor(color.IsCurrentColor());
565 } 566 }
566 567
567 // border-right-color 568 // border-right-color
568 void SetBorderRightColor(const StyleColor& v) { 569 void SetBorderRightColor(const StyleColor& color) {
569 SET_BORDERVALUE_COLOR(surround_data_, border_.right_, v); 570 SetBorderRightColorInternal(color.Resolve(Color()));
571 SetBorderRightColorIsCurrentColor(color.IsCurrentColor());
570 } 572 }
571 573
572 // border-top-color 574 // border-top-color
573 void SetBorderTopColor(const StyleColor& v) { 575 void SetBorderTopColor(const StyleColor& color) {
574 SET_BORDERVALUE_COLOR(surround_data_, border_.top_, v); 576 SetBorderTopColorInternal(color.Resolve(Color()));
577 SetBorderTopColorIsCurrentColor(color.IsCurrentColor());
575 } 578 }
576 579
577 // border-bottom-color 580 // border-bottom-color
578 void SetBorderBottomColor(const StyleColor& v) { 581 void SetBorderBottomColor(const StyleColor& color) {
579 SET_BORDERVALUE_COLOR(surround_data_, border_.bottom_, v); 582 SetBorderBottomColorInternal(color.Resolve(Color()));
583 SetBorderBottomColorIsCurrentColor(color.IsCurrentColor());
580 } 584 }
581 585
582 // box-shadow (aka -webkit-box-shadow) 586 // box-shadow (aka -webkit-box-shadow)
583 static ShadowList* InitialBoxShadow() { return 0; } 587 static ShadowList* InitialBoxShadow() { return 0; }
584 ShadowList* BoxShadow() const { 588 ShadowList* BoxShadow() const {
585 return rare_non_inherited_data_->box_shadow_.Get(); 589 return rare_non_inherited_data_->box_shadow_.Get();
586 } 590 }
587 void SetBoxShadow(PassRefPtr<ShadowList>); 591 void SetBoxShadow(PassRefPtr<ShadowList>);
588 592
589 // box-sizing (aka -webkit-box-sizing) 593 // box-sizing (aka -webkit-box-sizing)
(...skipping 2248 matching lines...) Expand 10 before | Expand all | Expand 10 after
2838 return BorderImage().HasImage() && BorderImage().Outset().NonZero(); 2842 return BorderImage().HasImage() && BorderImage().Outset().NonZero();
2839 } 2843 }
2840 LayoutRectOutsets BorderImageOutsets() const { 2844 LayoutRectOutsets BorderImageOutsets() const {
2841 return ImageOutsets(BorderImage()); 2845 return ImageOutsets(BorderImage());
2842 } 2846 }
2843 bool BorderImageSlicesFill() const { return Border().GetImage().Fill(); } 2847 bool BorderImageSlicesFill() const { return Border().GetImage().Fill(); }
2844 2848
2845 void SetBorderImageSlicesFill(bool); 2849 void SetBorderImageSlicesFill(bool);
2846 const BorderData& Border() const { return surround_data_->border_; } 2850 const BorderData& Border() const { return surround_data_->border_; }
2847 const BorderValue BorderLeft() const { 2851 const BorderValue BorderLeft() const {
2848 return BorderValue(surround_data_->border_.Left(), BorderLeftWidth()); 2852 return BorderValue(surround_data_->border_.Left(),
nainar 2017/05/11 04:33:22 Changed these to use the public getters instead.
2853 VisitedDependentColor(CSSPropertyBorderLeftColor),
2854 BorderLeftWidth());
2849 } 2855 }
2850 const BorderValue BorderRight() const { 2856 const BorderValue BorderRight() const {
2851 return BorderValue(surround_data_->border_.Right(), BorderRightWidth()); 2857 return BorderValue(surround_data_->border_.Right(),
2858 VisitedDependentColor(CSSPropertyBorderRightColor),
2859 BorderRightWidth());
2852 } 2860 }
2853 const BorderValue BorderTop() const { 2861 const BorderValue BorderTop() const {
2854 return BorderValue(surround_data_->border_.Top(), BorderTopWidth()); 2862 return BorderValue(surround_data_->border_.Top(),
2863 VisitedDependentColor(CSSPropertyBorderTopColor),
2864 BorderTopWidth());
2855 } 2865 }
2856 const BorderValue BorderBottom() const { 2866 const BorderValue BorderBottom() const {
2857 return BorderValue(surround_data_->border_.Bottom(), BorderBottomWidth()); 2867 return BorderValue(surround_data_->border_.Bottom(),
2868 VisitedDependentColor(CSSPropertyBorderBottomColor),
2869 BorderBottomWidth());
2858 } 2870 }
2859 bool BorderSizeEquals(const ComputedStyle& o) const { 2871 bool BorderSizeEquals(const ComputedStyle& o) const {
2860 return BorderWidthEquals(BorderLeftWidth(), o.BorderLeftWidth()) && 2872 return BorderWidthEquals(BorderLeftWidth(), o.BorderLeftWidth()) &&
2861 BorderWidthEquals(BorderTopWidth(), o.BorderTopWidth()) && 2873 BorderWidthEquals(BorderTopWidth(), o.BorderTopWidth()) &&
2862 BorderWidthEquals(BorderRightWidth(), o.BorderRightWidth()) && 2874 BorderWidthEquals(BorderRightWidth(), o.BorderRightWidth()) &&
2863 BorderWidthEquals(BorderBottomWidth(), o.BorderBottomWidth()); 2875 BorderWidthEquals(BorderBottomWidth(), o.BorderBottomWidth());
2864 } 2876 }
2865 const BorderValue BorderBefore() const; 2877 const BorderValue BorderBefore() const;
2866 const BorderValue BorderAfter() const; 2878 const BorderValue BorderAfter() const;
2867 const BorderValue BorderStart() const; 2879 const BorderValue BorderStart() const;
(...skipping 16 matching lines...) Expand all
2884 return true; 2896 return true;
2885 if (!BorderTopRightRadius().Width().IsZero()) 2897 if (!BorderTopRightRadius().Width().IsZero())
2886 return true; 2898 return true;
2887 if (!BorderBottomLeftRadius().Width().IsZero()) 2899 if (!BorderBottomLeftRadius().Width().IsZero())
2888 return true; 2900 return true;
2889 if (!BorderBottomRightRadius().Width().IsZero()) 2901 if (!BorderBottomRightRadius().Width().IsZero())
2890 return true; 2902 return true;
2891 return false; 2903 return false;
2892 } 2904 }
2893 bool HasBorderColorReferencingCurrentColor() const { 2905 bool HasBorderColorReferencingCurrentColor() const {
2894 return Border().HasBorderColorReferencingCurrentColor(); 2906 return (BorderLeft().NonZero() && BorderLeftColor().IsCurrentColor()) ||
2907 (BorderRight().NonZero() && BorderRightColor().IsCurrentColor()) ||
2908 (BorderTop().NonZero() && BorderTopColor().IsCurrentColor()) ||
2909 (BorderBottom().NonZero() && BorderBottomColor().IsCurrentColor());
2895 } 2910 }
2896 2911
2897 bool RadiiEqual(const ComputedStyle& o) const { 2912 bool RadiiEqual(const ComputedStyle& o) const {
2898 return BorderTopLeftRadius() == o.BorderTopLeftRadius() && 2913 return BorderTopLeftRadius() == o.BorderTopLeftRadius() &&
2899 BorderTopRightRadius() == o.BorderTopRightRadius() && 2914 BorderTopRightRadius() == o.BorderTopRightRadius() &&
2900 BorderBottomLeftRadius() == o.BorderBottomLeftRadius() && 2915 BorderBottomLeftRadius() == o.BorderBottomLeftRadius() &&
2901 BorderBottomRightRadius() == o.BorderBottomRightRadius(); 2916 BorderBottomRightRadius() == o.BorderBottomRightRadius();
2902 } 2917 }
2903 2918
2919 bool BorderColorEquals(const ComputedStyle& o) const {
2920 return (BorderLeftColorInternal() == o.BorderLeftColorInternal() &&
2921 BorderRightColorInternal() == o.BorderRightColorInternal() &&
2922 BorderTopColorInternal() == o.BorderTopColorInternal() &&
2923 BorderBottomColorInternal() == o.BorderBottomColorInternal()) &&
2924 (BorderLeftColorIsCurrentColor() ==
2925 o.BorderLeftColorIsCurrentColor() &&
2926 BorderRightColorIsCurrentColor() ==
2927 o.BorderRightColorIsCurrentColor() &&
2928 BorderTopColorIsCurrentColor() ==
2929 o.BorderTopColorIsCurrentColor() &&
2930 BorderBottomColorIsCurrentColor() ==
2931 o.BorderBottomColorIsCurrentColor());
2932 }
2933
2904 void ResetBorder() { 2934 void ResetBorder() {
2905 ResetBorderImage(); 2935 ResetBorderImage();
2906 ResetBorderTop(); 2936 ResetBorderTop();
2907 ResetBorderRight(); 2937 ResetBorderRight();
2908 ResetBorderBottom(); 2938 ResetBorderBottom();
2909 ResetBorderLeft(); 2939 ResetBorderLeft();
2910 ResetBorderTopLeftRadius(); 2940 ResetBorderTopLeftRadius();
2911 ResetBorderTopRightRadius(); 2941 ResetBorderTopRightRadius();
2912 ResetBorderBottomLeftRadius(); 2942 ResetBorderBottomLeftRadius();
2913 ResetBorderBottomRightRadius(); 2943 ResetBorderBottomRightRadius();
2914 } 2944 }
2945
2946 // todo - reset border colors here
meade_UTC10 2017/05/11 03:39:24 Is this still meant to be here?
nainar 2017/05/11 04:33:22 Nope. This is something that should have been remo
2915 void ResetBorderTop() { 2947 void ResetBorderTop() {
2916 SET_VAR(surround_data_, border_.top_, BorderColorAndStyle()); 2948 SET_VAR(surround_data_, border_.top_, BorderStyle());
2917 SetBorderTopWidth(3); 2949 SetBorderTopWidth(3);
2950 SetBorderTopColorInternal(0);
2951 SetBorderTopColorInternal(true);
2918 } 2952 }
2919 void ResetBorderRight() { 2953 void ResetBorderRight() {
2920 SET_VAR(surround_data_, border_.right_, BorderColorAndStyle()); 2954 SET_VAR(surround_data_, border_.right_, BorderStyle());
2921 SetBorderRightWidth(3); 2955 SetBorderRightWidth(3);
2956 SetBorderRightColorInternal(0);
2957 SetBorderRightColorInternal(true);
2922 } 2958 }
2923 void ResetBorderBottom() { 2959 void ResetBorderBottom() {
2924 SET_VAR(surround_data_, border_.bottom_, BorderColorAndStyle()); 2960 SET_VAR(surround_data_, border_.bottom_, BorderStyle());
2925 SetBorderBottomWidth(3); 2961 SetBorderBottomWidth(3);
2962 SetBorderBottomColorInternal(0);
2963 SetBorderBottomColorInternal(true);
2926 } 2964 }
2927 void ResetBorderLeft() { 2965 void ResetBorderLeft() {
2928 SET_VAR(surround_data_, border_.left_, BorderColorAndStyle()); 2966 SET_VAR(surround_data_, border_.left_, BorderStyle());
2929 SetBorderLeftWidth(3); 2967 SetBorderLeftWidth(3);
2968 SetBorderLeftColorInternal(0);
2969 SetBorderLeftColorInternal(true);
2930 } 2970 }
2931 void ResetBorderImage() { 2971 void ResetBorderImage() {
2932 SET_VAR(surround_data_, border_.image_, NinePieceImage()); 2972 SET_VAR(surround_data_, border_.image_, NinePieceImage());
2933 } 2973 }
2934 2974
2935 void SetBorderRadius(const LengthSize& s) { 2975 void SetBorderRadius(const LengthSize& s) {
2936 SetBorderTopLeftRadius(s); 2976 SetBorderTopLeftRadius(s);
2937 SetBorderTopRightRadius(s); 2977 SetBorderTopRightRadius(s);
2938 SetBorderBottomLeftRadius(s); 2978 SetBorderBottomLeftRadius(s);
2939 SetBorderBottomRightRadius(s); 2979 SetBorderBottomRightRadius(s);
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
3481 display == EDisplay::kTableRow || 3521 display == EDisplay::kTableRow ||
3482 display == EDisplay::kTableColumnGroup || 3522 display == EDisplay::kTableColumnGroup ||
3483 display == EDisplay::kTableColumn || 3523 display == EDisplay::kTableColumn ||
3484 display == EDisplay::kTableCell || 3524 display == EDisplay::kTableCell ||
3485 display == EDisplay::kTableCaption; 3525 display == EDisplay::kTableCaption;
3486 } 3526 }
3487 3527
3488 // Color accessors are all private to make sure callers use 3528 // Color accessors are all private to make sure callers use
3489 // VisitedDependentColor instead to access them. 3529 // VisitedDependentColor instead to access them.
3490 StyleColor BorderLeftColor() const { 3530 StyleColor BorderLeftColor() const {
3491 return surround_data_->border_.Left().GetColor(); 3531 return BorderLeftColorIsCurrentColor()
3532 ? StyleColor::CurrentColor()
3533 : StyleColor(BorderLeftColorInternal());
3492 } 3534 }
3493 StyleColor BorderRightColor() const { 3535 StyleColor BorderRightColor() const {
3494 return surround_data_->border_.Right().GetColor(); 3536 return BorderRightColorIsCurrentColor()
3537 ? StyleColor::CurrentColor()
3538 : StyleColor(BorderRightColorInternal());
3495 } 3539 }
3496 StyleColor BorderTopColor() const { 3540 StyleColor BorderTopColor() const {
3497 return surround_data_->border_.Top().GetColor(); 3541 return BorderTopColorIsCurrentColor()
3542 ? StyleColor::CurrentColor()
3543 : StyleColor(BorderTopColorInternal());
3498 } 3544 }
3499 StyleColor BorderBottomColor() const { 3545 StyleColor BorderBottomColor() const {
3500 return surround_data_->border_.Bottom().GetColor(); 3546 return BorderBottomColorIsCurrentColor()
3547 ? StyleColor::CurrentColor()
3548 : StyleColor(BorderBottomColorInternal());
3501 } 3549 }
3550
3502 StyleColor BackgroundColor() const { 3551 StyleColor BackgroundColor() const {
3503 return background_data_->background_color_; 3552 return background_data_->background_color_;
3504 } 3553 }
3505 StyleAutoColor CaretColor() const { 3554 StyleAutoColor CaretColor() const {
3506 return rare_inherited_data_->CaretColor(); 3555 return rare_inherited_data_->CaretColor();
3507 } 3556 }
3508 Color GetColor() const; 3557 Color GetColor() const;
3509 StyleColor ColumnRuleColor() const { 3558 StyleColor ColumnRuleColor() const {
3510 return rare_non_inherited_data_->multi_col_->rule_.GetColor(); 3559 return rare_non_inherited_data_->multi_col_->rule_.GetColor();
3511 } 3560 }
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
3691 PseudoBitsInternal() | 1 << (pseudo - kFirstPublicPseudoId))); 3740 PseudoBitsInternal() | 1 << (pseudo - kFirstPublicPseudoId)));
3692 } 3741 }
3693 3742
3694 inline bool ComputedStyle::HasPseudoElementStyle() const { 3743 inline bool ComputedStyle::HasPseudoElementStyle() const {
3695 return PseudoBitsInternal() & kElementPseudoIdMask; 3744 return PseudoBitsInternal() & kElementPseudoIdMask;
3696 } 3745 }
3697 3746
3698 } // namespace blink 3747 } // namespace blink
3699 3748
3700 #endif // ComputedStyle_h 3749 #endif // ComputedStyle_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/style/CachedUAStyle.h ('k') | third_party/WebKit/Source/core/style/ComputedStyle.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698