Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 void SetStyleType(PseudoId style_type) { SetStyleTypeInternal(style_type); } | 287 void SetStyleType(PseudoId style_type) { SetStyleTypeInternal(style_type); } |
| 288 | 288 |
| 289 ComputedStyle* GetCachedPseudoStyle(PseudoId) const; | 289 ComputedStyle* GetCachedPseudoStyle(PseudoId) const; |
| 290 ComputedStyle* AddCachedPseudoStyle(PassRefPtr<ComputedStyle>); | 290 ComputedStyle* AddCachedPseudoStyle(PassRefPtr<ComputedStyle>); |
| 291 void RemoveCachedPseudoStyle(PseudoId); | 291 void RemoveCachedPseudoStyle(PseudoId); |
| 292 | 292 |
| 293 const PseudoStyleCache* CachedPseudoStyles() const { | 293 const PseudoStyleCache* CachedPseudoStyles() const { |
| 294 return cached_pseudo_styles_.get(); | 294 return cached_pseudo_styles_.get(); |
| 295 } | 295 } |
| 296 | 296 |
| 297 bool BorderWidthEquals(float border_width_first, | |
| 298 float border_width_second) const { | |
| 299 return WidthToFixedPoint(border_width_first) == | |
| 300 WidthToFixedPoint(border_width_second); | |
| 301 } | |
| 302 | |
| 297 /** | 303 /** |
| 298 * ComputedStyle properties | 304 * ComputedStyle properties |
| 299 * | 305 * |
| 300 * Each property stored in ComputedStyle is made up of fields. Fields have | 306 * Each property stored in ComputedStyle is made up of fields. Fields have |
| 301 * initial value functions, getters and setters. A field is preferably a | 307 * initial value functions, getters and setters. A field is preferably a |
| 302 * basic data type or enum, but can be any type. A set of fields should be | 308 * basic data type or enum, but can be any type. A set of fields should be |
| 303 * preceded by the property the field is stored for. | 309 * preceded by the property the field is stored for. |
| 304 * | 310 * |
| 305 * Field method naming should be done like so: | 311 * Field method naming should be done like so: |
| 306 * // name-of-property | 312 * // name-of-property |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 495 const BorderImageLengthBox& BorderImageOutset() const { | 501 const BorderImageLengthBox& BorderImageOutset() const { |
| 496 return surround_data_->border_.GetImage().Outset(); | 502 return surround_data_->border_.GetImage().Outset(); |
| 497 } | 503 } |
| 498 void SetBorderImageOutset(const BorderImageLengthBox&); | 504 void SetBorderImageOutset(const BorderImageLengthBox&); |
| 499 | 505 |
| 500 // Border width properties. | 506 // Border width properties. |
| 501 static float InitialBorderWidth() { return 3; } | 507 static float InitialBorderWidth() { return 3; } |
| 502 | 508 |
| 503 // border-top-width | 509 // border-top-width |
| 504 float BorderTopWidth() const { | 510 float BorderTopWidth() const { |
| 505 return surround_data_->border_.BorderTopWidth(); | 511 if (surround_data_->border_.top_.Style() == kBorderStyleNone || |
| 512 surround_data_->border_.top_.Style() == kBorderStyleHidden) | |
| 513 return 0; | |
| 514 return static_cast<float>(BorderTopWidthInternal()) / | |
| 515 kBorderWidthDenominator; | |
| 506 } | 516 } |
| 507 void SetBorderTopWidth(float v) { | 517 void SetBorderTopWidth(float v) { |
| 508 SET_BORDER_WIDTH(surround_data_, border_.top_, v); | 518 surround_data_.Access()->border_top_width_ = WidthToFixedPoint(v); |
| 509 } | 519 } |
| 510 | 520 |
| 511 // border-bottom-width | 521 // border-bottom-width |
| 512 float BorderBottomWidth() const { | 522 float BorderBottomWidth() const { |
| 513 return surround_data_->border_.BorderBottomWidth(); | 523 if (surround_data_->border_.bottom_.Style() == kBorderStyleNone || |
| 524 surround_data_->border_.bottom_.Style() == kBorderStyleHidden) | |
| 525 return 0; | |
| 526 return static_cast<float>(BorderBottomWidthInternal()) / | |
| 527 kBorderWidthDenominator; | |
| 514 } | 528 } |
| 515 void SetBorderBottomWidth(float v) { | 529 void SetBorderBottomWidth(float v) { |
| 516 SET_BORDER_WIDTH(surround_data_, border_.bottom_, v); | 530 surround_data_.Access()->border_bottom_width_ = WidthToFixedPoint(v); |
| 517 } | 531 } |
| 518 | 532 |
| 519 // border-left-width | 533 // border-left-width |
| 520 float BorderLeftWidth() const { | 534 float BorderLeftWidth() const { |
| 521 return surround_data_->border_.BorderLeftWidth(); | 535 if (surround_data_->border_.left_.Style() == kBorderStyleNone || |
| 536 surround_data_->border_.left_.Style() == kBorderStyleHidden) | |
| 537 return 0; | |
| 538 return static_cast<float>(BorderLeftWidthInternal()) / | |
| 539 kBorderWidthDenominator; | |
| 522 } | 540 } |
| 523 void SetBorderLeftWidth(float v) { | 541 void SetBorderLeftWidth(float v) { |
| 524 SET_BORDER_WIDTH(surround_data_, border_.left_, v); | 542 surround_data_.Access()->border_left_width_ = WidthToFixedPoint(v); |
| 525 } | 543 } |
| 526 | 544 |
| 527 // border-right-width | 545 // border-right-width |
| 528 float BorderRightWidth() const { | 546 float BorderRightWidth() const { |
| 529 return surround_data_->border_.BorderRightWidth(); | 547 if (surround_data_->border_.right_.Style() == kBorderStyleNone || |
| 548 surround_data_->border_.right_.Style() == kBorderStyleHidden) | |
| 549 return 0; | |
| 550 return static_cast<float>(BorderRightWidthInternal()) / | |
|
shend
2017/05/07 23:08:31
The fixed point stuff feels like it should be a cl
nainar
2017/05/08 00:59:57
Yes. Added a todo here on me to take a look at thi
| |
| 551 kBorderWidthDenominator; | |
| 530 } | 552 } |
| 531 void SetBorderRightWidth(float v) { | 553 void SetBorderRightWidth(float v) { |
| 532 SET_BORDER_WIDTH(surround_data_, border_.right_, v); | 554 surround_data_.Access()->border_right_width_ = WidthToFixedPoint(v); |
| 533 } | 555 } |
| 534 | 556 |
| 535 // Border style properties. | 557 // Border style properties. |
| 536 static EBorderStyle InitialBorderStyle() { return kBorderStyleNone; } | 558 static EBorderStyle InitialBorderStyle() { return kBorderStyleNone; } |
| 537 | 559 |
| 538 // border-top-style | 560 // border-top-style |
| 539 EBorderStyle BorderTopStyle() const { | 561 EBorderStyle BorderTopStyle() const { |
| 540 return surround_data_->border_.Top().Style(); | 562 return surround_data_->border_.Top().Style(); |
| 541 } | 563 } |
| 542 void SetBorderTopStyle(EBorderStyle v) { | 564 void SetBorderTopStyle(EBorderStyle v) { |
| (...skipping 2303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2846 return BorderImage().HasImage() && BorderImage().Outset().NonZero(); | 2868 return BorderImage().HasImage() && BorderImage().Outset().NonZero(); |
| 2847 } | 2869 } |
| 2848 LayoutRectOutsets BorderImageOutsets() const { | 2870 LayoutRectOutsets BorderImageOutsets() const { |
| 2849 return ImageOutsets(BorderImage()); | 2871 return ImageOutsets(BorderImage()); |
| 2850 } | 2872 } |
| 2851 bool BorderImageSlicesFill() const { return Border().GetImage().Fill(); } | 2873 bool BorderImageSlicesFill() const { return Border().GetImage().Fill(); } |
| 2852 | 2874 |
| 2853 void SetBorderImageSlicesFill(bool); | 2875 void SetBorderImageSlicesFill(bool); |
| 2854 const BorderData& Border() const { return surround_data_->border_; } | 2876 const BorderData& Border() const { return surround_data_->border_; } |
| 2855 const BorderValue& BorderLeft() const { | 2877 const BorderValue& BorderLeft() const { |
| 2856 return surround_data_->border_.Left(); | 2878 BorderValue* border_value = |
|
shend
2017/05/07 23:08:30
Have we measured the perf impact of this dynamic a
nainar
2017/05/08 00:59:57
Done.
| |
| 2879 new BorderValue(surround_data_->border_.Left(), BorderLeftWidth()); | |
| 2880 return *border_value; | |
| 2857 } | 2881 } |
| 2858 const BorderValue& BorderRight() const { | 2882 const BorderValue& BorderRight() const { |
| 2859 return surround_data_->border_.Right(); | 2883 BorderValue* border_value = |
| 2884 new BorderValue(surround_data_->border_.Right(), BorderRightWidth()); | |
| 2885 return *border_value; | |
| 2860 } | 2886 } |
| 2861 const BorderValue& BorderTop() const { return surround_data_->border_.Top(); } | 2887 const BorderValue& BorderTop() const { |
| 2888 BorderValue* border_value = | |
| 2889 new BorderValue(surround_data_->border_.Top(), BorderTopWidth()); | |
| 2890 return *border_value; | |
| 2891 } | |
| 2862 const BorderValue& BorderBottom() const { | 2892 const BorderValue& BorderBottom() const { |
| 2863 return surround_data_->border_.Bottom(); | 2893 BorderValue* border_value = |
| 2894 new BorderValue(surround_data_->border_.Bottom(), BorderBottomWidth()); | |
| 2895 return *border_value; | |
| 2896 } | |
| 2897 bool BorderSizeEquals(const ComputedStyle& o) const { | |
| 2898 return BorderWidthEquals(BorderLeftWidth(), o.BorderLeftWidth()) && | |
| 2899 BorderWidthEquals(BorderTopWidth(), o.BorderTopWidth()) && | |
| 2900 BorderWidthEquals(BorderRightWidth(), o.BorderRightWidth()) && | |
| 2901 BorderWidthEquals(BorderBottomWidth(), o.BorderBottomWidth()); | |
| 2864 } | 2902 } |
| 2865 const BorderValue& BorderBefore() const; | 2903 const BorderValue& BorderBefore() const; |
| 2866 const BorderValue& BorderAfter() const; | 2904 const BorderValue& BorderAfter() const; |
| 2867 const BorderValue& BorderStart() const; | 2905 const BorderValue& BorderStart() const; |
| 2868 const BorderValue& BorderEnd() const; | 2906 const BorderValue& BorderEnd() const; |
| 2869 float BorderAfterWidth() const; | 2907 float BorderAfterWidth() const; |
| 2870 float BorderBeforeWidth() const; | 2908 float BorderBeforeWidth() const; |
| 2871 float BorderEndWidth() const; | 2909 float BorderEndWidth() const; |
| 2872 float BorderStartWidth() const; | 2910 float BorderStartWidth() const; |
| 2873 float BorderOverWidth() const; | 2911 float BorderOverWidth() const; |
| 2874 float BorderUnderWidth() const; | 2912 float BorderUnderWidth() const; |
| 2875 | 2913 |
| 2876 bool HasBorderFill() const { return Border().HasBorderFill(); } | 2914 bool HasBorderFill() const { return Border().HasBorderFill(); } |
| 2877 bool HasBorder() const { return Border().HasBorder(); } | 2915 bool HasBorder() const { |
| 2916 return Border().HasBorder() || BorderLeftWidth() || BorderRightWidth() || | |
| 2917 BorderTopWidth() || BorderBottomWidth(); | |
| 2918 } | |
| 2878 bool HasBorderDecoration() const { return HasBorder() || HasBorderFill(); } | 2919 bool HasBorderDecoration() const { return HasBorder() || HasBorderFill(); } |
| 2879 bool HasBorderRadius() const { | 2920 bool HasBorderRadius() const { |
| 2880 if (!BorderTopLeftRadius().Width().IsZero()) | 2921 if (!BorderTopLeftRadius().Width().IsZero()) |
| 2881 return true; | 2922 return true; |
| 2882 if (!BorderTopRightRadius().Width().IsZero()) | 2923 if (!BorderTopRightRadius().Width().IsZero()) |
| 2883 return true; | 2924 return true; |
| 2884 if (!BorderBottomLeftRadius().Width().IsZero()) | 2925 if (!BorderBottomLeftRadius().Width().IsZero()) |
| 2885 return true; | 2926 return true; |
| 2886 if (!BorderBottomRightRadius().Width().IsZero()) | 2927 if (!BorderBottomRightRadius().Width().IsZero()) |
| 2887 return true; | 2928 return true; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 2903 ResetBorderTop(); | 2944 ResetBorderTop(); |
| 2904 ResetBorderRight(); | 2945 ResetBorderRight(); |
| 2905 ResetBorderBottom(); | 2946 ResetBorderBottom(); |
| 2906 ResetBorderLeft(); | 2947 ResetBorderLeft(); |
| 2907 ResetBorderTopLeftRadius(); | 2948 ResetBorderTopLeftRadius(); |
| 2908 ResetBorderTopRightRadius(); | 2949 ResetBorderTopRightRadius(); |
| 2909 ResetBorderBottomLeftRadius(); | 2950 ResetBorderBottomLeftRadius(); |
| 2910 ResetBorderBottomRightRadius(); | 2951 ResetBorderBottomRightRadius(); |
| 2911 } | 2952 } |
| 2912 void ResetBorderTop() { | 2953 void ResetBorderTop() { |
| 2913 SET_VAR(surround_data_, border_.top_, BorderValue()); | 2954 SET_VAR(surround_data_, border_.top_, BorderColorAndStyle()); |
|
nainar
2017/05/05 07:16:50
hmm on second thought this should probably also re
shend
2017/05/07 23:08:31
Hmm, good question. I would do it here, since Bord
nainar
2017/05/08 00:59:57
Yup. Agreed. Done.
| |
| 2914 } | 2955 } |
| 2915 void ResetBorderRight() { | 2956 void ResetBorderRight() { |
| 2916 SET_VAR(surround_data_, border_.right_, BorderValue()); | 2957 SET_VAR(surround_data_, border_.right_, BorderColorAndStyle()); |
| 2917 } | 2958 } |
| 2918 void ResetBorderBottom() { | 2959 void ResetBorderBottom() { |
| 2919 SET_VAR(surround_data_, border_.bottom_, BorderValue()); | 2960 SET_VAR(surround_data_, border_.bottom_, BorderColorAndStyle()); |
| 2920 } | 2961 } |
| 2921 void ResetBorderLeft() { | 2962 void ResetBorderLeft() { |
| 2922 SET_VAR(surround_data_, border_.left_, BorderValue()); | 2963 SET_VAR(surround_data_, border_.left_, BorderColorAndStyle()); |
| 2923 } | 2964 } |
| 2924 void ResetBorderImage() { | 2965 void ResetBorderImage() { |
| 2925 SET_VAR(surround_data_, border_.image_, NinePieceImage()); | 2966 SET_VAR(surround_data_, border_.image_, NinePieceImage()); |
| 2926 } | 2967 } |
| 2927 | 2968 |
| 2928 void SetBorderRadius(const LengthSize& s) { | 2969 void SetBorderRadius(const LengthSize& s) { |
| 2929 SetBorderTopLeftRadius(s); | 2970 SetBorderTopLeftRadius(s); |
| 2930 SetBorderTopRightRadius(s); | 2971 SetBorderTopRightRadius(s); |
| 2931 SetBorderBottomLeftRadius(s); | 2972 SetBorderBottomLeftRadius(s); |
| 2932 SetBorderBottomRightRadius(s); | 2973 SetBorderBottomRightRadius(s); |
| (...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3684 PseudoBitsInternal() | 1 << (pseudo - kFirstPublicPseudoId))); | 3725 PseudoBitsInternal() | 1 << (pseudo - kFirstPublicPseudoId))); |
| 3685 } | 3726 } |
| 3686 | 3727 |
| 3687 inline bool ComputedStyle::HasPseudoElementStyle() const { | 3728 inline bool ComputedStyle::HasPseudoElementStyle() const { |
| 3688 return PseudoBitsInternal() & kElementPseudoIdMask; | 3729 return PseudoBitsInternal() & kElementPseudoIdMask; |
| 3689 } | 3730 } |
| 3690 | 3731 |
| 3691 } // namespace blink | 3732 } // namespace blink |
| 3692 | 3733 |
| 3693 #endif // ComputedStyle_h | 3734 #endif // ComputedStyle_h |
| OLD | NEW |