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

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

Issue 2890733002: Make EBorderStyle an enum class. (Closed)
Patch Set: Build for Mac 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 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 return surround_data_->border_.GetImage().Outset(); 509 return surround_data_->border_.GetImage().Outset();
510 } 510 }
511 void SetBorderImageOutset(const BorderImageLengthBox&); 511 void SetBorderImageOutset(const BorderImageLengthBox&);
512 512
513 // Border width properties. 513 // Border width properties.
514 static float InitialBorderWidth() { return 3; } 514 static float InitialBorderWidth() { return 3; }
515 515
516 // TODO(nainar): Move all fixed point logic to a separate class. 516 // TODO(nainar): Move all fixed point logic to a separate class.
517 // border-top-width 517 // border-top-width
518 float BorderTopWidth() const { 518 float BorderTopWidth() const {
519 if (surround_data_->border_.top_.Style() == kBorderStyleNone || 519 if (surround_data_->border_.top_.Style() == EBorderStyle::kNone ||
520 surround_data_->border_.top_.Style() == kBorderStyleHidden) 520 surround_data_->border_.top_.Style() == EBorderStyle::kHidden)
521 return 0; 521 return 0;
522 return static_cast<float>(BorderTopWidthInternal()) / 522 return static_cast<float>(BorderTopWidthInternal()) /
523 kBorderWidthDenominator; 523 kBorderWidthDenominator;
524 } 524 }
525 void SetBorderTopWidth(float v) { 525 void SetBorderTopWidth(float v) {
526 SetBorderTopWidthInternal(WidthToFixedPoint(v)); 526 SetBorderTopWidthInternal(WidthToFixedPoint(v));
527 } 527 }
528 528
529 // border-bottom-width 529 // border-bottom-width
530 float BorderBottomWidth() const { 530 float BorderBottomWidth() const {
531 if (surround_data_->border_.bottom_.Style() == kBorderStyleNone || 531 if (surround_data_->border_.bottom_.Style() == EBorderStyle::kNone ||
532 surround_data_->border_.bottom_.Style() == kBorderStyleHidden) 532 surround_data_->border_.bottom_.Style() == EBorderStyle::kHidden)
533 return 0; 533 return 0;
534 return static_cast<float>(BorderBottomWidthInternal()) / 534 return static_cast<float>(BorderBottomWidthInternal()) /
535 kBorderWidthDenominator; 535 kBorderWidthDenominator;
536 } 536 }
537 void SetBorderBottomWidth(float v) { 537 void SetBorderBottomWidth(float v) {
538 SetBorderBottomWidthInternal(WidthToFixedPoint(v)); 538 SetBorderBottomWidthInternal(WidthToFixedPoint(v));
539 } 539 }
540 540
541 // border-left-width 541 // border-left-width
542 float BorderLeftWidth() const { 542 float BorderLeftWidth() const {
543 if (surround_data_->border_.left_.Style() == kBorderStyleNone || 543 if (surround_data_->border_.left_.Style() == EBorderStyle::kNone ||
544 surround_data_->border_.left_.Style() == kBorderStyleHidden) 544 surround_data_->border_.left_.Style() == EBorderStyle::kHidden)
545 return 0; 545 return 0;
546 return static_cast<float>(BorderLeftWidthInternal()) / 546 return static_cast<float>(BorderLeftWidthInternal()) /
547 kBorderWidthDenominator; 547 kBorderWidthDenominator;
548 } 548 }
549 void SetBorderLeftWidth(float v) { 549 void SetBorderLeftWidth(float v) {
550 SetBorderLeftWidthInternal(WidthToFixedPoint(v)); 550 SetBorderLeftWidthInternal(WidthToFixedPoint(v));
551 } 551 }
552 552
553 // border-right-width 553 // border-right-width
554 float BorderRightWidth() const { 554 float BorderRightWidth() const {
555 if (surround_data_->border_.right_.Style() == kBorderStyleNone || 555 if (surround_data_->border_.right_.Style() == EBorderStyle::kNone ||
556 surround_data_->border_.right_.Style() == kBorderStyleHidden) 556 surround_data_->border_.right_.Style() == EBorderStyle::kHidden)
557 return 0; 557 return 0;
558 return static_cast<float>(BorderRightWidthInternal()) / 558 return static_cast<float>(BorderRightWidthInternal()) /
559 kBorderWidthDenominator; 559 kBorderWidthDenominator;
560 } 560 }
561 void SetBorderRightWidth(float v) { 561 void SetBorderRightWidth(float v) {
562 SetBorderRightWidthInternal(WidthToFixedPoint(v)); 562 SetBorderRightWidthInternal(WidthToFixedPoint(v));
563 } 563 }
564 564
565 // Border style properties. 565 // Border style properties.
566 static EBorderStyle InitialBorderStyle() { return kBorderStyleNone; } 566 static EBorderStyle InitialBorderStyle() { return EBorderStyle::kNone; }
567 567
568 // border-top-style 568 // border-top-style
569 EBorderStyle BorderTopStyle() const { 569 EBorderStyle BorderTopStyle() const {
570 return surround_data_->border_.Top().Style(); 570 return surround_data_->border_.Top().Style();
571 } 571 }
572 void SetBorderTopStyle(EBorderStyle v) { 572 void SetBorderTopStyle(EBorderStyle v) {
573 SET_VAR(surround_data_, border_.top_.style_, v); 573 SET_VAR(surround_data_, border_.top_.style_, static_cast<unsigned>(v));
574 } 574 }
575 575
576 // border-right-style 576 // border-right-style
577 EBorderStyle BorderRightStyle() const { 577 EBorderStyle BorderRightStyle() const {
578 return surround_data_->border_.Right().Style(); 578 return surround_data_->border_.Right().Style();
579 } 579 }
580 void SetBorderRightStyle(EBorderStyle v) { 580 void SetBorderRightStyle(EBorderStyle v) {
581 SET_VAR(surround_data_, border_.right_.style_, v); 581 SET_VAR(surround_data_, border_.right_.style_, static_cast<unsigned>(v));
582 } 582 }
583 583
584 // border-left-style 584 // border-left-style
585 EBorderStyle BorderLeftStyle() const { 585 EBorderStyle BorderLeftStyle() const {
586 return surround_data_->border_.Left().Style(); 586 return surround_data_->border_.Left().Style();
587 } 587 }
588 void SetBorderLeftStyle(EBorderStyle v) { 588 void SetBorderLeftStyle(EBorderStyle v) {
589 SET_VAR(surround_data_, border_.left_.style_, v); 589 SET_VAR(surround_data_, border_.left_.style_, static_cast<unsigned>(v));
590 } 590 }
591 591
592 // border-bottom-style 592 // border-bottom-style
593 EBorderStyle BorderBottomStyle() const { 593 EBorderStyle BorderBottomStyle() const {
594 return surround_data_->border_.Bottom().Style(); 594 return surround_data_->border_.Bottom().Style();
595 } 595 }
596 void SetBorderBottomStyle(EBorderStyle v) { 596 void SetBorderBottomStyle(EBorderStyle v) {
597 SET_VAR(surround_data_, border_.bottom_.style_, v); 597 SET_VAR(surround_data_, border_.bottom_.style_, static_cast<unsigned>(v));
598 } 598 }
599 599
600 // Border color properties. 600 // Border color properties.
601 // border-left-color 601 // border-left-color
602 void SetBorderLeftColor(const StyleColor& color) { 602 void SetBorderLeftColor(const StyleColor& color) {
603 if (!compareEqual(BorderLeftColor(), color)) { 603 if (!compareEqual(BorderLeftColor(), color)) {
604 SetBorderLeftColorInternal(color.Resolve(Color())); 604 SetBorderLeftColorInternal(color.Resolve(Color()));
605 SetBorderLeftColorIsCurrentColor(color.IsCurrentColor()); 605 SetBorderLeftColorIsCurrentColor(color.IsCurrentColor());
606 } 606 }
607 } 607 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 void SetColumnRuleColor(const StyleColor& c) { 696 void SetColumnRuleColor(const StyleColor& c) {
697 SET_BORDERVALUE_COLOR(rare_non_inherited_data_.Access()->multi_col_, rule_, 697 SET_BORDERVALUE_COLOR(rare_non_inherited_data_.Access()->multi_col_, rule_,
698 c); 698 c);
699 } 699 }
700 700
701 // column-rule-style (aka -webkit-column-rule-style) 701 // column-rule-style (aka -webkit-column-rule-style)
702 EBorderStyle ColumnRuleStyle() const { 702 EBorderStyle ColumnRuleStyle() const {
703 return rare_non_inherited_data_->multi_col_->rule_.Style(); 703 return rare_non_inherited_data_->multi_col_->rule_.Style();
704 } 704 }
705 void SetColumnRuleStyle(EBorderStyle b) { 705 void SetColumnRuleStyle(EBorderStyle b) {
706 SET_NESTED_VAR(rare_non_inherited_data_, multi_col_, rule_.style_, b); 706 SET_NESTED_VAR(rare_non_inherited_data_, multi_col_, rule_.style_,
707 static_cast<unsigned>(b));
707 } 708 }
708 709
709 // column-rule-width (aka -webkit-column-rule-width) 710 // column-rule-width (aka -webkit-column-rule-width)
710 static unsigned short InitialColumnRuleWidth() { return 3; } 711 static unsigned short InitialColumnRuleWidth() { return 3; }
711 unsigned short ColumnRuleWidth() const { 712 unsigned short ColumnRuleWidth() const {
712 return rare_non_inherited_data_->multi_col_->RuleWidth(); 713 return rare_non_inherited_data_->multi_col_->RuleWidth();
713 } 714 }
714 void SetColumnRuleWidth(unsigned short w) { 715 void SetColumnRuleWidth(unsigned short w) {
715 SET_NESTED_BORDER_WIDTH(rare_non_inherited_data_, multi_col_, rule_, w); 716 SET_NESTED_BORDER_WIDTH(rare_non_inherited_data_, multi_col_, rule_, w);
716 } 717 }
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 // outline-color 1187 // outline-color
1187 void SetOutlineColor(const StyleColor& v) { 1188 void SetOutlineColor(const StyleColor& v) {
1188 SET_BORDERVALUE_COLOR(rare_non_inherited_data_, outline_, v); 1189 SET_BORDERVALUE_COLOR(rare_non_inherited_data_, outline_, v);
1189 } 1190 }
1190 1191
1191 // outline-style 1192 // outline-style
1192 EBorderStyle OutlineStyle() const { 1193 EBorderStyle OutlineStyle() const {
1193 return rare_non_inherited_data_->outline_.Style(); 1194 return rare_non_inherited_data_->outline_.Style();
1194 } 1195 }
1195 void SetOutlineStyle(EBorderStyle v) { 1196 void SetOutlineStyle(EBorderStyle v) {
1196 SET_VAR(rare_non_inherited_data_, outline_.style_, v); 1197 SET_VAR(rare_non_inherited_data_, outline_.style_,
1198 static_cast<unsigned>(v));
1197 } 1199 }
1198 static OutlineIsAuto InitialOutlineStyleIsAuto() { return kOutlineIsAutoOff; } 1200 static OutlineIsAuto InitialOutlineStyleIsAuto() { return kOutlineIsAutoOff; }
1199 OutlineIsAuto OutlineStyleIsAuto() const { 1201 OutlineIsAuto OutlineStyleIsAuto() const {
1200 return static_cast<OutlineIsAuto>( 1202 return static_cast<OutlineIsAuto>(
1201 rare_non_inherited_data_->outline_.IsAuto()); 1203 rare_non_inherited_data_->outline_.IsAuto());
1202 } 1204 }
1203 void SetOutlineStyleIsAuto(OutlineIsAuto is_auto) { 1205 void SetOutlineStyleIsAuto(OutlineIsAuto is_auto) {
1204 SET_VAR(rare_non_inherited_data_, outline_.is_auto_, is_auto); 1206 SET_VAR(rare_non_inherited_data_, outline_.is_auto_, is_auto);
1205 } 1207 }
1206 1208
1207 // outline-width 1209 // outline-width
1208 static unsigned short InitialOutlineWidth() { return 3; } 1210 static unsigned short InitialOutlineWidth() { return 3; }
1209 unsigned short OutlineWidth() const { 1211 unsigned short OutlineWidth() const {
1210 if (rare_non_inherited_data_->outline_.Style() == kBorderStyleNone) 1212 if (rare_non_inherited_data_->outline_.Style() == EBorderStyle::kNone)
1211 return 0; 1213 return 0;
1212 return rare_non_inherited_data_->outline_.Width(); 1214 return rare_non_inherited_data_->outline_.Width();
1213 } 1215 }
1214 void SetOutlineWidth(unsigned short v) { 1216 void SetOutlineWidth(unsigned short v) {
1215 SET_BORDER_WIDTH(rare_non_inherited_data_, outline_, v); 1217 SET_BORDER_WIDTH(rare_non_inherited_data_, outline_, v);
1216 } 1218 }
1217 1219
1218 // outline-offset 1220 // outline-offset
1219 static int InitialOutlineOffset() { return 0; } 1221 static int InitialOutlineOffset() { return 0; }
1220 int OutlineOffset() const { 1222 int OutlineOffset() const {
1221 if (rare_non_inherited_data_->outline_.Style() == kBorderStyleNone) 1223 if (rare_non_inherited_data_->outline_.Style() == EBorderStyle::kNone)
1222 return 0; 1224 return 0;
1223 return rare_non_inherited_data_->outline_.Offset(); 1225 return rare_non_inherited_data_->outline_.Offset();
1224 } 1226 }
1225 void SetOutlineOffset(int v) { 1227 void SetOutlineOffset(int v) {
1226 SET_VAR(rare_non_inherited_data_, outline_.offset_, v); 1228 SET_VAR(rare_non_inherited_data_, outline_.offset_, v);
1227 } 1229 }
1228 1230
1229 // perspective (aka -webkit-perspective) 1231 // perspective (aka -webkit-perspective)
1230 static float InitialPerspective() { return 0; } 1232 static float InitialPerspective() { return 0; }
1231 float Perspective() const { return rare_non_inherited_data_->perspective_; } 1233 float Perspective() const { return rare_non_inherited_data_->perspective_; }
(...skipping 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after
2930 o.BorderLeftColorIsCurrentColor() && 2932 o.BorderLeftColorIsCurrentColor() &&
2931 BorderRightColorIsCurrentColor() == 2933 BorderRightColorIsCurrentColor() ==
2932 o.BorderRightColorIsCurrentColor() && 2934 o.BorderRightColorIsCurrentColor() &&
2933 BorderTopColorIsCurrentColor() == 2935 BorderTopColorIsCurrentColor() ==
2934 o.BorderTopColorIsCurrentColor() && 2936 o.BorderTopColorIsCurrentColor() &&
2935 BorderBottomColorIsCurrentColor() == 2937 BorderBottomColorIsCurrentColor() ==
2936 o.BorderBottomColorIsCurrentColor()); 2938 o.BorderBottomColorIsCurrentColor());
2937 } 2939 }
2938 2940
2939 bool BorderColorVisuallyEquals(const ComputedStyle& o) const { 2941 bool BorderColorVisuallyEquals(const ComputedStyle& o) const {
2940 if ((BorderLeftStyle() == kBorderStyleNone && 2942 if ((BorderLeftStyle() == EBorderStyle::kNone &&
2941 o.BorderLeftStyle() == kBorderStyleNone) && 2943 o.BorderLeftStyle() == EBorderStyle::kNone) &&
2942 (BorderRightStyle() == kBorderStyleNone && 2944 (BorderRightStyle() == EBorderStyle::kNone &&
2943 o.BorderRightStyle() == kBorderStyleNone) && 2945 o.BorderRightStyle() == EBorderStyle::kNone) &&
2944 (BorderTopStyle() == kBorderStyleNone && 2946 (BorderTopStyle() == EBorderStyle::kNone &&
2945 o.BorderTopStyle() == kBorderStyleNone) && 2947 o.BorderTopStyle() == EBorderStyle::kNone) &&
2946 (BorderBottomStyle() == kBorderStyleNone && 2948 (BorderBottomStyle() == EBorderStyle::kNone &&
2947 o.BorderBottomStyle() == kBorderStyleNone)) 2949 o.BorderBottomStyle() == EBorderStyle::kNone))
2948 return true; 2950 return true;
2949 if ((BorderLeftStyle() == kBorderStyleHidden && 2951 if ((BorderLeftStyle() == EBorderStyle::kHidden &&
2950 o.BorderLeftStyle() == kBorderStyleHidden) && 2952 o.BorderLeftStyle() == EBorderStyle::kHidden) &&
2951 (BorderRightStyle() == kBorderStyleHidden && 2953 (BorderRightStyle() == EBorderStyle::kHidden &&
2952 o.BorderRightStyle() == kBorderStyleHidden) && 2954 o.BorderRightStyle() == EBorderStyle::kHidden) &&
2953 (BorderTopStyle() == kBorderStyleHidden && 2955 (BorderTopStyle() == EBorderStyle::kHidden &&
2954 o.BorderTopStyle() == kBorderStyleHidden) && 2956 o.BorderTopStyle() == EBorderStyle::kHidden) &&
2955 (BorderBottomStyle() == kBorderStyleHidden && 2957 (BorderBottomStyle() == EBorderStyle::kHidden &&
2956 o.BorderBottomStyle() == kBorderStyleHidden)) 2958 o.BorderBottomStyle() == EBorderStyle::kHidden))
2957 return true; 2959 return true;
2958 return BorderColorEquals(o); 2960 return BorderColorEquals(o);
2959 } 2961 }
2960 2962
2961 void ResetBorder() { 2963 void ResetBorder() {
2962 ResetBorderImage(); 2964 ResetBorderImage();
2963 ResetBorderTop(); 2965 ResetBorderTop();
2964 ResetBorderRight(); 2966 ResetBorderRight();
2965 ResetBorderBottom(); 2967 ResetBorderBottom();
2966 ResetBorderLeft(); 2968 ResetBorderLeft();
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
3044 return rare_non_inherited_data_->perspective_ > 0; 3046 return rare_non_inherited_data_->perspective_ > 0;
3045 } 3047 }
3046 3048
3047 // Page size utility functions. 3049 // Page size utility functions.
3048 void ResetPageSizeType() { 3050 void ResetPageSizeType() {
3049 SET_VAR(rare_non_inherited_data_, page_size_type_, PAGE_SIZE_AUTO); 3051 SET_VAR(rare_non_inherited_data_, page_size_type_, PAGE_SIZE_AUTO);
3050 } 3052 }
3051 3053
3052 // Outline utility functions. 3054 // Outline utility functions.
3053 bool HasOutline() const { 3055 bool HasOutline() const {
3054 return OutlineWidth() > 0 && OutlineStyle() > kBorderStyleHidden; 3056 return OutlineWidth() > 0 && OutlineStyle() > EBorderStyle::kHidden;
3055 } 3057 }
3056 int OutlineOutsetExtent() const; 3058 int OutlineOutsetExtent() const;
3057 float GetOutlineStrokeWidthForFocusRing() const; 3059 float GetOutlineStrokeWidthForFocusRing() const;
3058 bool HasOutlineWithCurrentColor() const { 3060 bool HasOutlineWithCurrentColor() const {
3059 return HasOutline() && OutlineColor().IsCurrentColor(); 3061 return HasOutline() && OutlineColor().IsCurrentColor();
3060 } 3062 }
3061 3063
3062 // Position utility functions. 3064 // Position utility functions.
3063 bool HasOutOfFlowPosition() const { 3065 bool HasOutOfFlowPosition() const {
3064 return GetPosition() == EPosition::kAbsolute || 3066 return GetPosition() == EPosition::kAbsolute ||
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after
3798 PseudoBitsInternal() | 1 << (pseudo - kFirstPublicPseudoId))); 3800 PseudoBitsInternal() | 1 << (pseudo - kFirstPublicPseudoId)));
3799 } 3801 }
3800 3802
3801 inline bool ComputedStyle::HasPseudoElementStyle() const { 3803 inline bool ComputedStyle::HasPseudoElementStyle() const {
3802 return PseudoBitsInternal() & kElementPseudoIdMask; 3804 return PseudoBitsInternal() & kElementPseudoIdMask;
3803 } 3805 }
3804 3806
3805 } // namespace blink 3807 } // namespace blink
3806 3808
3807 #endif // ComputedStyle_h 3809 #endif // ComputedStyle_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/style/BorderValue.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