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

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

Issue 2861773004: Move border-*-width out of BorderValue and store on SurroundData in ComputedStyle instead (Closed)
Patch Set: meade@'s suggestion 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 void SetStyleType(PseudoId style_type) { SetStyleTypeInternal(style_type); } 257 void SetStyleType(PseudoId style_type) { SetStyleTypeInternal(style_type); }
258 258
259 ComputedStyle* GetCachedPseudoStyle(PseudoId) const; 259 ComputedStyle* GetCachedPseudoStyle(PseudoId) const;
260 ComputedStyle* AddCachedPseudoStyle(PassRefPtr<ComputedStyle>); 260 ComputedStyle* AddCachedPseudoStyle(PassRefPtr<ComputedStyle>);
261 void RemoveCachedPseudoStyle(PseudoId); 261 void RemoveCachedPseudoStyle(PseudoId);
262 262
263 const PseudoStyleCache* CachedPseudoStyles() const { 263 const PseudoStyleCache* CachedPseudoStyles() const {
264 return cached_pseudo_styles_.get(); 264 return cached_pseudo_styles_.get();
265 } 265 }
266 266
267 bool BorderWidthEquals(float border_width_first,
268 float border_width_second) const {
269 return WidthToFixedPoint(border_width_first) ==
270 WidthToFixedPoint(border_width_second);
271 }
272
267 /** 273 /**
268 * ComputedStyle properties 274 * ComputedStyle properties
269 * 275 *
270 * Each property stored in ComputedStyle is made up of fields. Fields have 276 * Each property stored in ComputedStyle is made up of fields. Fields have
271 * initial value functions, getters and setters. A field is preferably a 277 * initial value functions, getters and setters. A field is preferably a
272 * basic data type or enum, but can be any type. A set of fields should be 278 * basic data type or enum, but can be any type. A set of fields should be
273 * preceded by the property the field is stored for. 279 * preceded by the property the field is stored for.
274 * 280 *
275 * Field method naming should be done like so: 281 * Field method naming should be done like so:
276 * // name-of-property 282 * // name-of-property
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 469
464 // border-image-outset 470 // border-image-outset
465 const BorderImageLengthBox& BorderImageOutset() const { 471 const BorderImageLengthBox& BorderImageOutset() const {
466 return surround_data_->border_.GetImage().Outset(); 472 return surround_data_->border_.GetImage().Outset();
467 } 473 }
468 void SetBorderImageOutset(const BorderImageLengthBox&); 474 void SetBorderImageOutset(const BorderImageLengthBox&);
469 475
470 // Border width properties. 476 // Border width properties.
471 static float InitialBorderWidth() { return 3; } 477 static float InitialBorderWidth() { return 3; }
472 478
479 // TODO(nainar): Move all fixed point logic to a separate class.
473 // border-top-width 480 // border-top-width
474 float BorderTopWidth() const { 481 float BorderTopWidth() const {
475 return surround_data_->border_.BorderTopWidth(); 482 if (surround_data_->border_.top_.Style() == kBorderStyleNone ||
483 surround_data_->border_.top_.Style() == kBorderStyleHidden)
484 return 0;
485 return static_cast<float>(BorderTopWidthInternal()) /
486 kBorderWidthDenominator;
476 } 487 }
477 void SetBorderTopWidth(float v) { 488 void SetBorderTopWidth(float v) {
478 SET_BORDER_WIDTH(surround_data_, border_.top_, v); 489 surround_data_.Access()->border_top_width_ = WidthToFixedPoint(v);
479 } 490 }
480 491
481 // border-bottom-width 492 // border-bottom-width
482 float BorderBottomWidth() const { 493 float BorderBottomWidth() const {
483 return surround_data_->border_.BorderBottomWidth(); 494 if (surround_data_->border_.bottom_.Style() == kBorderStyleNone ||
495 surround_data_->border_.bottom_.Style() == kBorderStyleHidden)
496 return 0;
497 return static_cast<float>(BorderBottomWidthInternal()) /
498 kBorderWidthDenominator;
484 } 499 }
485 void SetBorderBottomWidth(float v) { 500 void SetBorderBottomWidth(float v) {
486 SET_BORDER_WIDTH(surround_data_, border_.bottom_, v); 501 surround_data_.Access()->border_bottom_width_ = WidthToFixedPoint(v);
487 } 502 }
488 503
489 // border-left-width 504 // border-left-width
490 float BorderLeftWidth() const { 505 float BorderLeftWidth() const {
491 return surround_data_->border_.BorderLeftWidth(); 506 if (surround_data_->border_.left_.Style() == kBorderStyleNone ||
507 surround_data_->border_.left_.Style() == kBorderStyleHidden)
508 return 0;
509 return static_cast<float>(BorderLeftWidthInternal()) /
510 kBorderWidthDenominator;
492 } 511 }
493 void SetBorderLeftWidth(float v) { 512 void SetBorderLeftWidth(float v) {
494 SET_BORDER_WIDTH(surround_data_, border_.left_, v); 513 surround_data_.Access()->border_left_width_ = WidthToFixedPoint(v);
495 } 514 }
496 515
497 // border-right-width 516 // border-right-width
498 float BorderRightWidth() const { 517 float BorderRightWidth() const {
499 return surround_data_->border_.BorderRightWidth(); 518 if (surround_data_->border_.right_.Style() == kBorderStyleNone ||
519 surround_data_->border_.right_.Style() == kBorderStyleHidden)
520 return 0;
521 return static_cast<float>(BorderRightWidthInternal()) /
522 kBorderWidthDenominator;
500 } 523 }
501 void SetBorderRightWidth(float v) { 524 void SetBorderRightWidth(float v) {
502 SET_BORDER_WIDTH(surround_data_, border_.right_, v); 525 surround_data_.Access()->border_right_width_ = WidthToFixedPoint(v);
503 } 526 }
504 527
505 // Border style properties. 528 // Border style properties.
506 static EBorderStyle InitialBorderStyle() { return kBorderStyleNone; } 529 static EBorderStyle InitialBorderStyle() { return kBorderStyleNone; }
507 530
508 // border-top-style 531 // border-top-style
509 EBorderStyle BorderTopStyle() const { 532 EBorderStyle BorderTopStyle() const {
510 return surround_data_->border_.Top().Style(); 533 return surround_data_->border_.Top().Style();
511 } 534 }
512 void SetBorderTopStyle(EBorderStyle v) { 535 void SetBorderTopStyle(EBorderStyle v) {
(...skipping 2302 matching lines...) Expand 10 before | Expand all | Expand 10 after
2815 bool HasBorderImageOutsets() const { 2838 bool HasBorderImageOutsets() const {
2816 return BorderImage().HasImage() && BorderImage().Outset().NonZero(); 2839 return BorderImage().HasImage() && BorderImage().Outset().NonZero();
2817 } 2840 }
2818 LayoutRectOutsets BorderImageOutsets() const { 2841 LayoutRectOutsets BorderImageOutsets() const {
2819 return ImageOutsets(BorderImage()); 2842 return ImageOutsets(BorderImage());
2820 } 2843 }
2821 bool BorderImageSlicesFill() const { return Border().GetImage().Fill(); } 2844 bool BorderImageSlicesFill() const { return Border().GetImage().Fill(); }
2822 2845
2823 void SetBorderImageSlicesFill(bool); 2846 void SetBorderImageSlicesFill(bool);
2824 const BorderData& Border() const { return surround_data_->border_; } 2847 const BorderData& Border() const { return surround_data_->border_; }
2825 const BorderValue& BorderLeft() const { 2848 const BorderValue BorderLeft() const {
2826 return surround_data_->border_.Left(); 2849 return BorderValue(surround_data_->border_.Left(), BorderLeftWidth());
2827 } 2850 }
2828 const BorderValue& BorderRight() const { 2851 const BorderValue BorderRight() const {
2829 return surround_data_->border_.Right(); 2852 return BorderValue(surround_data_->border_.Right(), BorderRightWidth());
2830 } 2853 }
2831 const BorderValue& BorderTop() const { return surround_data_->border_.Top(); } 2854 const BorderValue BorderTop() const {
2832 const BorderValue& BorderBottom() const { 2855 return BorderValue(surround_data_->border_.Top(), BorderTopWidth());
2833 return surround_data_->border_.Bottom();
2834 } 2856 }
2835 const BorderValue& BorderBefore() const; 2857 const BorderValue BorderBottom() const {
2836 const BorderValue& BorderAfter() const; 2858 return BorderValue(surround_data_->border_.Bottom(), BorderBottomWidth());
2837 const BorderValue& BorderStart() const; 2859 }
2838 const BorderValue& BorderEnd() const; 2860 bool BorderSizeEquals(const ComputedStyle& o) const {
2861 return BorderWidthEquals(BorderLeftWidth(), o.BorderLeftWidth()) &&
2862 BorderWidthEquals(BorderTopWidth(), o.BorderTopWidth()) &&
2863 BorderWidthEquals(BorderRightWidth(), o.BorderRightWidth()) &&
2864 BorderWidthEquals(BorderBottomWidth(), o.BorderBottomWidth());
2865 }
2866 const BorderValue BorderBefore() const;
2867 const BorderValue BorderAfter() const;
2868 const BorderValue BorderStart() const;
2869 const BorderValue BorderEnd() const;
2839 float BorderAfterWidth() const; 2870 float BorderAfterWidth() const;
2840 float BorderBeforeWidth() const; 2871 float BorderBeforeWidth() const;
2841 float BorderEndWidth() const; 2872 float BorderEndWidth() const;
2842 float BorderStartWidth() const; 2873 float BorderStartWidth() const;
2843 float BorderOverWidth() const; 2874 float BorderOverWidth() const;
2844 float BorderUnderWidth() const; 2875 float BorderUnderWidth() const;
2845 2876
2846 bool HasBorderFill() const { return Border().HasBorderFill(); } 2877 bool HasBorderFill() const { return Border().HasBorderFill(); }
2847 bool HasBorder() const { return Border().HasBorder(); } 2878 bool HasBorder() const {
2879 return Border().HasBorder() || BorderLeftWidth() || BorderRightWidth() ||
2880 BorderTopWidth() || BorderBottomWidth();
2881 }
2848 bool HasBorderDecoration() const { return HasBorder() || HasBorderFill(); } 2882 bool HasBorderDecoration() const { return HasBorder() || HasBorderFill(); }
2849 bool HasBorderRadius() const { 2883 bool HasBorderRadius() const {
2850 if (!BorderTopLeftRadius().Width().IsZero()) 2884 if (!BorderTopLeftRadius().Width().IsZero())
2851 return true; 2885 return true;
2852 if (!BorderTopRightRadius().Width().IsZero()) 2886 if (!BorderTopRightRadius().Width().IsZero())
2853 return true; 2887 return true;
2854 if (!BorderBottomLeftRadius().Width().IsZero()) 2888 if (!BorderBottomLeftRadius().Width().IsZero())
2855 return true; 2889 return true;
2856 if (!BorderBottomRightRadius().Width().IsZero()) 2890 if (!BorderBottomRightRadius().Width().IsZero())
2857 return true; 2891 return true;
(...skipping 15 matching lines...) Expand all
2873 ResetBorderTop(); 2907 ResetBorderTop();
2874 ResetBorderRight(); 2908 ResetBorderRight();
2875 ResetBorderBottom(); 2909 ResetBorderBottom();
2876 ResetBorderLeft(); 2910 ResetBorderLeft();
2877 ResetBorderTopLeftRadius(); 2911 ResetBorderTopLeftRadius();
2878 ResetBorderTopRightRadius(); 2912 ResetBorderTopRightRadius();
2879 ResetBorderBottomLeftRadius(); 2913 ResetBorderBottomLeftRadius();
2880 ResetBorderBottomRightRadius(); 2914 ResetBorderBottomRightRadius();
2881 } 2915 }
2882 void ResetBorderTop() { 2916 void ResetBorderTop() {
2883 SET_VAR(surround_data_, border_.top_, BorderValue()); 2917 SET_VAR(surround_data_, border_.top_, BorderColorAndStyle());
2918 SetBorderTopWidth(3);
2884 } 2919 }
2885 void ResetBorderRight() { 2920 void ResetBorderRight() {
2886 SET_VAR(surround_data_, border_.right_, BorderValue()); 2921 SET_VAR(surround_data_, border_.right_, BorderColorAndStyle());
2922 SetBorderRightWidth(3);
2887 } 2923 }
2888 void ResetBorderBottom() { 2924 void ResetBorderBottom() {
2889 SET_VAR(surround_data_, border_.bottom_, BorderValue()); 2925 SET_VAR(surround_data_, border_.bottom_, BorderColorAndStyle());
2926 SetBorderBottomWidth(3);
2890 } 2927 }
2891 void ResetBorderLeft() { 2928 void ResetBorderLeft() {
2892 SET_VAR(surround_data_, border_.left_, BorderValue()); 2929 SET_VAR(surround_data_, border_.left_, BorderColorAndStyle());
2930 SetBorderLeftWidth(3);
2893 } 2931 }
2894 void ResetBorderImage() { 2932 void ResetBorderImage() {
2895 SET_VAR(surround_data_, border_.image_, NinePieceImage()); 2933 SET_VAR(surround_data_, border_.image_, NinePieceImage());
2896 } 2934 }
2897 2935
2898 void SetBorderRadius(const LengthSize& s) { 2936 void SetBorderRadius(const LengthSize& s) {
2899 SetBorderTopLeftRadius(s); 2937 SetBorderTopLeftRadius(s);
2900 SetBorderTopRightRadius(s); 2938 SetBorderTopRightRadius(s);
2901 SetBorderBottomLeftRadius(s); 2939 SetBorderBottomLeftRadius(s);
2902 SetBorderBottomRightRadius(s); 2940 SetBorderBottomRightRadius(s);
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
3654 PseudoBitsInternal() | 1 << (pseudo - kFirstPublicPseudoId))); 3692 PseudoBitsInternal() | 1 << (pseudo - kFirstPublicPseudoId)));
3655 } 3693 }
3656 3694
3657 inline bool ComputedStyle::HasPseudoElementStyle() const { 3695 inline bool ComputedStyle::HasPseudoElementStyle() const {
3658 return PseudoBitsInternal() & kElementPseudoIdMask; 3696 return PseudoBitsInternal() & kElementPseudoIdMask;
3659 } 3697 }
3660 3698
3661 } // namespace blink 3699 } // namespace blink
3662 3700
3663 #endif // ComputedStyle_h 3701 #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