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

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

Issue 2904453002: Use LayoutUnit for all border-*-width logic (Closed)
Patch Set: Change to using LayoutUnit 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/css/CSSProperties.json5 ('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) 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 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 void SetStyleType(PseudoId style_type) { SetStyleTypeInternal(style_type); } 505 void SetStyleType(PseudoId style_type) { SetStyleTypeInternal(style_type); }
506 506
507 ComputedStyle* GetCachedPseudoStyle(PseudoId) const; 507 ComputedStyle* GetCachedPseudoStyle(PseudoId) const;
508 ComputedStyle* AddCachedPseudoStyle(RefPtr<ComputedStyle>); 508 ComputedStyle* AddCachedPseudoStyle(RefPtr<ComputedStyle>);
509 void RemoveCachedPseudoStyle(PseudoId); 509 void RemoveCachedPseudoStyle(PseudoId);
510 510
511 const PseudoStyleCache* CachedPseudoStyles() const { 511 const PseudoStyleCache* CachedPseudoStyles() const {
512 return cached_pseudo_styles_.get(); 512 return cached_pseudo_styles_.get();
513 } 513 }
514 514
515 bool BorderWidthEquals(float border_width_first,
516 float border_width_second) const {
517 return WidthToFixedPoint(border_width_first) ==
518 WidthToFixedPoint(border_width_second);
519 }
520
521 /** 515 /**
522 * ComputedStyle properties 516 * ComputedStyle properties
523 * 517 *
524 * Each property stored in ComputedStyle is made up of fields. Fields have 518 * Each property stored in ComputedStyle is made up of fields. Fields have
525 * initial value functions, getters and setters. A field is preferably a 519 * initial value functions, getters and setters. A field is preferably a
526 * basic data type or enum, but can be any type. A set of fields should be 520 * basic data type or enum, but can be any type. A set of fields should be
527 * preceded by the property the field is stored for. 521 * preceded by the property the field is stored for.
528 * 522 *
529 * Field method naming should be done like so: 523 * Field method naming should be done like so:
530 * // name-of-property 524 * // name-of-property
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 704
711 // Border width properties. 705 // Border width properties.
712 static float InitialBorderWidth() { return 3; } 706 static float InitialBorderWidth() { return 3; }
713 707
714 // TODO(nainar): Move all fixed point logic to a separate class. 708 // TODO(nainar): Move all fixed point logic to a separate class.
715 // border-top-width 709 // border-top-width
716 float BorderTopWidth() const { 710 float BorderTopWidth() const {
717 if (BorderTopStyle() == EBorderStyle::kNone || 711 if (BorderTopStyle() == EBorderStyle::kNone ||
718 BorderTopStyle() == EBorderStyle::kHidden) 712 BorderTopStyle() == EBorderStyle::kHidden)
719 return 0; 713 return 0;
720 return static_cast<float>(BorderTopWidthInternal()) / 714 return BorderTopWidthInternal().ToFloat();
721 kBorderWidthDenominator;
722 } 715 }
723 void SetBorderTopWidth(float v) { 716 void SetBorderTopWidth(float v) { SetBorderTopWidthInternal(LayoutUnit(v)); }
724 SetBorderTopWidthInternal(WidthToFixedPoint(v));
725 }
726 bool BorderTopNonZero() const { 717 bool BorderTopNonZero() const {
727 return BorderTopWidth() && (BorderTopStyle() != EBorderStyle::kNone); 718 return BorderTopWidth() && (BorderTopStyle() != EBorderStyle::kNone);
728 } 719 }
729 720
730 // border-bottom-width 721 // border-bottom-width
731 float BorderBottomWidth() const { 722 float BorderBottomWidth() const {
732 if (BorderBottomStyle() == EBorderStyle::kNone || 723 if (BorderBottomStyle() == EBorderStyle::kNone ||
733 BorderBottomStyle() == EBorderStyle::kHidden) 724 BorderBottomStyle() == EBorderStyle::kHidden)
734 return 0; 725 return 0;
735 return static_cast<float>(BorderBottomWidthInternal()) / 726 return BorderBottomWidthInternal().ToFloat();
736 kBorderWidthDenominator;
737 } 727 }
738 void SetBorderBottomWidth(float v) { 728 void SetBorderBottomWidth(float v) {
739 SetBorderBottomWidthInternal(WidthToFixedPoint(v)); 729 SetBorderBottomWidthInternal(LayoutUnit(v));
740 } 730 }
741 bool BorderBottomNonZero() const { 731 bool BorderBottomNonZero() const {
742 return BorderBottomWidth() && (BorderBottomStyle() != EBorderStyle::kNone); 732 return BorderBottomWidth() && (BorderBottomStyle() != EBorderStyle::kNone);
743 } 733 }
744 734
745 // border-left-width 735 // border-left-width
746 float BorderLeftWidth() const { 736 float BorderLeftWidth() const {
747 if (BorderLeftStyle() == EBorderStyle::kNone || 737 if (BorderLeftStyle() == EBorderStyle::kNone ||
748 BorderLeftStyle() == EBorderStyle::kHidden) 738 BorderLeftStyle() == EBorderStyle::kHidden)
749 return 0; 739 return 0;
750 return static_cast<float>(BorderLeftWidthInternal()) / 740 return BorderLeftWidthInternal().ToFloat();
751 kBorderWidthDenominator;
752 } 741 }
753 void SetBorderLeftWidth(float v) { 742 void SetBorderLeftWidth(float v) {
754 SetBorderLeftWidthInternal(WidthToFixedPoint(v)); 743 SetBorderLeftWidthInternal(LayoutUnit(v));
755 } 744 }
756 bool BorderLeftNonZero() const { 745 bool BorderLeftNonZero() const {
757 return BorderLeftWidth() && (BorderLeftStyle() != EBorderStyle::kNone); 746 return BorderLeftWidth() && (BorderLeftStyle() != EBorderStyle::kNone);
758 } 747 }
759 748
760 // border-right-width 749 // border-right-width
761 float BorderRightWidth() const { 750 float BorderRightWidth() const {
762 if (BorderRightStyle() == EBorderStyle::kNone || 751 if (BorderRightStyle() == EBorderStyle::kNone ||
763 BorderRightStyle() == EBorderStyle::kHidden) 752 BorderRightStyle() == EBorderStyle::kHidden)
764 return 0; 753 return 0;
765 return static_cast<float>(BorderRightWidthInternal()) / 754 return BorderRightWidthInternal().ToFloat();
766 kBorderWidthDenominator;
767 } 755 }
768 void SetBorderRightWidth(float v) { 756 void SetBorderRightWidth(float v) {
769 SetBorderRightWidthInternal(WidthToFixedPoint(v)); 757 SetBorderRightWidthInternal(LayoutUnit(v));
770 } 758 }
771 bool BorderRightNonZero() const { 759 bool BorderRightNonZero() const {
772 return BorderRightWidth() && (BorderRightStyle() != EBorderStyle::kNone); 760 return BorderRightWidth() && (BorderRightStyle() != EBorderStyle::kNone);
773 } 761 }
774 762
775 static EBorderStyle InitialColumnRuleStyle() { return EBorderStyle::kNone; } 763 static EBorderStyle InitialColumnRuleStyle() { return EBorderStyle::kNone; }
776 764
777 // Border color properties. 765 // Border color properties.
778 // border-left-color 766 // border-left-color
779 void SetBorderLeftColor(const StyleColor& color) { 767 void SetBorderLeftColor(const StyleColor& color) {
(...skipping 2251 matching lines...) Expand 10 before | Expand all | Expand 10 after
3031 bool HasBorderImageOutsets() const { 3019 bool HasBorderImageOutsets() const {
3032 return BorderImage().HasImage() && BorderImage().Outset().NonZero(); 3020 return BorderImage().HasImage() && BorderImage().Outset().NonZero();
3033 } 3021 }
3034 LayoutRectOutsets BorderImageOutsets() const { 3022 LayoutRectOutsets BorderImageOutsets() const {
3035 return ImageOutsets(BorderImage()); 3023 return ImageOutsets(BorderImage());
3036 } 3024 }
3037 bool BorderImageSlicesFill() const { return BorderImage().Fill(); } 3025 bool BorderImageSlicesFill() const { return BorderImage().Fill(); }
3038 3026
3039 void SetBorderImageSlicesFill(bool); 3027 void SetBorderImageSlicesFill(bool);
3040 const BorderValue BorderLeft() const { 3028 const BorderValue BorderLeft() const {
3041 return BorderValue( 3029 return BorderValue(BorderLeftStyle(), BorderLeftColor(),
3042 BorderLeftStyle(), BorderLeftColor(), 3030 BorderLeftWidthInternal().ToFloat(),
3043 static_cast<float>(BorderLeftWidthInternal()) / kBorderWidthDenominator, 3031 OutlineStyleIsAuto());
3044 OutlineStyleIsAuto());
3045 } 3032 }
3046 const BorderValue BorderRight() const { 3033 const BorderValue BorderRight() const {
3047 return BorderValue(BorderRightStyle(), BorderRightColor(), 3034 return BorderValue(BorderRightStyle(), BorderRightColor(),
3048 static_cast<float>(BorderRightWidthInternal()) / 3035 BorderRightWidthInternal().ToFloat(),
3049 kBorderWidthDenominator,
3050 OutlineStyleIsAuto()); 3036 OutlineStyleIsAuto());
3051 } 3037 }
3052 const BorderValue BorderTop() const { 3038 const BorderValue BorderTop() const {
3053 return BorderValue( 3039 return BorderValue(BorderTopStyle(), BorderTopColor(),
3054 BorderTopStyle(), BorderTopColor(), 3040 BorderTopWidthInternal().ToFloat(),
3055 static_cast<float>(BorderTopWidthInternal()) / kBorderWidthDenominator, 3041 OutlineStyleIsAuto());
3056 OutlineStyleIsAuto());
3057 } 3042 }
3058 const BorderValue BorderBottom() const { 3043 const BorderValue BorderBottom() const {
3059 return BorderValue(BorderBottomStyle(), BorderBottomColor(), 3044 return BorderValue(BorderBottomStyle(), BorderBottomColor(),
3060 static_cast<float>(BorderBottomWidthInternal()) / 3045 BorderBottomWidthInternal().ToFloat(),
3061 kBorderWidthDenominator,
3062 OutlineStyleIsAuto()); 3046 OutlineStyleIsAuto());
3063 } 3047 }
3064 3048
3065 bool BorderSizeEquals(const ComputedStyle& o) const { 3049 bool BorderSizeEquals(const ComputedStyle& o) const {
3066 return BorderWidthEquals(BorderLeftWidth(), o.BorderLeftWidth()) && 3050 return BorderLeftWidthInternal() == o.BorderLeftWidthInternal() &&
3067 BorderWidthEquals(BorderTopWidth(), o.BorderTopWidth()) && 3051 BorderTopWidthInternal() == o.BorderTopWidthInternal() &&
3068 BorderWidthEquals(BorderRightWidth(), o.BorderRightWidth()) && 3052 BorderRightWidthInternal() == o.BorderRightWidthInternal() &&
3069 BorderWidthEquals(BorderBottomWidth(), o.BorderBottomWidth()); 3053 BorderBottomWidthInternal() == o.BorderBottomWidthInternal();
3070 } 3054 }
3071 3055
3072 BorderValue BorderBefore() const; 3056 BorderValue BorderBefore() const;
3073 BorderValue BorderAfter() const; 3057 BorderValue BorderAfter() const;
3074 BorderValue BorderStart() const; 3058 BorderValue BorderStart() const;
3075 BorderValue BorderEnd() const; 3059 BorderValue BorderEnd() const;
3076 float BorderAfterWidth() const; 3060 float BorderAfterWidth() const;
3077 float BorderBeforeWidth() const; 3061 float BorderBeforeWidth() const;
3078 float BorderEndWidth() const; 3062 float BorderEndWidth() const;
3079 float BorderStartWidth() const; 3063 float BorderStartWidth() const;
(...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after
4037 PseudoBitsInternal() | 1 << (pseudo - kFirstPublicPseudoId))); 4021 PseudoBitsInternal() | 1 << (pseudo - kFirstPublicPseudoId)));
4038 } 4022 }
4039 4023
4040 inline bool ComputedStyle::HasPseudoElementStyle() const { 4024 inline bool ComputedStyle::HasPseudoElementStyle() const {
4041 return PseudoBitsInternal() & kElementPseudoIdMask; 4025 return PseudoBitsInternal() & kElementPseudoIdMask;
4042 } 4026 }
4043 4027
4044 } // namespace blink 4028 } // namespace blink
4045 4029
4046 #endif // ComputedStyle_h 4030 #endif // ComputedStyle_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSProperties.json5 ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698