| 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 void SetStyleType(PseudoId style_type) { SetStyleTypeInternal(style_type); } | 246 void SetStyleType(PseudoId style_type) { SetStyleTypeInternal(style_type); } |
| 247 | 247 |
| 248 ComputedStyle* GetCachedPseudoStyle(PseudoId) const; | 248 ComputedStyle* GetCachedPseudoStyle(PseudoId) const; |
| 249 ComputedStyle* AddCachedPseudoStyle(RefPtr<ComputedStyle>); | 249 ComputedStyle* AddCachedPseudoStyle(RefPtr<ComputedStyle>); |
| 250 void RemoveCachedPseudoStyle(PseudoId); | 250 void RemoveCachedPseudoStyle(PseudoId); |
| 251 | 251 |
| 252 const PseudoStyleCache* CachedPseudoStyles() const { | 252 const PseudoStyleCache* CachedPseudoStyles() const { |
| 253 return cached_pseudo_styles_.get(); | 253 return cached_pseudo_styles_.get(); |
| 254 } | 254 } |
| 255 | 255 |
| 256 bool BorderWidthEquals(float border_width_first, | |
| 257 float border_width_second) const { | |
| 258 return WidthToFixedPoint(border_width_first) == | |
| 259 WidthToFixedPoint(border_width_second); | |
| 260 } | |
| 261 | |
| 262 /** | 256 /** |
| 263 * ComputedStyle properties | 257 * ComputedStyle properties |
| 264 * | 258 * |
| 265 * Each property stored in ComputedStyle is made up of fields. Fields have | 259 * Each property stored in ComputedStyle is made up of fields. Fields have |
| 266 * initial value functions, getters and setters. A field is preferably a | 260 * initial value functions, getters and setters. A field is preferably a |
| 267 * basic data type or enum, but can be any type. A set of fields should be | 261 * basic data type or enum, but can be any type. A set of fields should be |
| 268 * preceded by the property the field is stored for. | 262 * preceded by the property the field is stored for. |
| 269 * | 263 * |
| 270 * Field method naming should be done like so: | 264 * Field method naming should be done like so: |
| 271 * // name-of-property | 265 * // name-of-property |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 | 445 |
| 452 // Border width properties. | 446 // Border width properties. |
| 453 static float InitialBorderWidth() { return 3; } | 447 static float InitialBorderWidth() { return 3; } |
| 454 | 448 |
| 455 // TODO(nainar): Move all fixed point logic to a separate class. | 449 // TODO(nainar): Move all fixed point logic to a separate class. |
| 456 // border-top-width | 450 // border-top-width |
| 457 float BorderTopWidth() const { | 451 float BorderTopWidth() const { |
| 458 if (BorderTopStyle() == EBorderStyle::kNone || | 452 if (BorderTopStyle() == EBorderStyle::kNone || |
| 459 BorderTopStyle() == EBorderStyle::kHidden) | 453 BorderTopStyle() == EBorderStyle::kHidden) |
| 460 return 0; | 454 return 0; |
| 461 return static_cast<float>(BorderTopWidthInternal()) / | 455 return BorderTopWidthInternal().Width(); |
| 462 kBorderWidthDenominator; | |
| 463 } | 456 } |
| 464 void SetBorderTopWidth(float v) { | 457 void SetBorderTopWidth(float v) { |
| 465 SetBorderTopWidthInternal(WidthToFixedPoint(v)); | 458 MutableBorderTopWidthInternal().SetWidth(v); |
| 466 } | 459 } |
| 467 bool BorderTopNonZero() const { | 460 bool BorderTopNonZero() const { |
| 468 return BorderTopWidth() && (BorderTopStyle() != EBorderStyle::kNone); | 461 return BorderTopWidth() && (BorderTopStyle() != EBorderStyle::kNone); |
| 469 } | 462 } |
| 470 | 463 |
| 471 // border-bottom-width | 464 // border-bottom-width |
| 472 float BorderBottomWidth() const { | 465 float BorderBottomWidth() const { |
| 473 if (BorderBottomStyle() == EBorderStyle::kNone || | 466 if (BorderBottomStyle() == EBorderStyle::kNone || |
| 474 BorderBottomStyle() == EBorderStyle::kHidden) | 467 BorderBottomStyle() == EBorderStyle::kHidden) |
| 475 return 0; | 468 return 0; |
| 476 return static_cast<float>(BorderBottomWidthInternal()) / | 469 return BorderBottomWidthInternal().Width(); |
| 477 kBorderWidthDenominator; | |
| 478 } | 470 } |
| 479 void SetBorderBottomWidth(float v) { | 471 void SetBorderBottomWidth(float v) { |
| 480 SetBorderBottomWidthInternal(WidthToFixedPoint(v)); | 472 MutableBorderBottomWidthInternal().SetWidth(v); |
| 481 } | 473 } |
| 482 bool BorderBottomNonZero() const { | 474 bool BorderBottomNonZero() const { |
| 483 return BorderBottomWidth() && (BorderBottomStyle() != EBorderStyle::kNone); | 475 return BorderBottomWidth() && (BorderBottomStyle() != EBorderStyle::kNone); |
| 484 } | 476 } |
| 485 | 477 |
| 486 // border-left-width | 478 // border-left-width |
| 487 float BorderLeftWidth() const { | 479 float BorderLeftWidth() const { |
| 488 if (BorderLeftStyle() == EBorderStyle::kNone || | 480 if (BorderLeftStyle() == EBorderStyle::kNone || |
| 489 BorderLeftStyle() == EBorderStyle::kHidden) | 481 BorderLeftStyle() == EBorderStyle::kHidden) |
| 490 return 0; | 482 return 0; |
| 491 return static_cast<float>(BorderLeftWidthInternal()) / | 483 return BorderLeftWidthInternal().Width(); |
| 492 kBorderWidthDenominator; | |
| 493 } | 484 } |
| 494 void SetBorderLeftWidth(float v) { | 485 void SetBorderLeftWidth(float v) { |
| 495 SetBorderLeftWidthInternal(WidthToFixedPoint(v)); | 486 MutableBorderLeftWidthInternal().SetWidth(v); |
| 496 } | 487 } |
| 497 bool BorderLeftNonZero() const { | 488 bool BorderLeftNonZero() const { |
| 498 return BorderLeftWidth() && (BorderLeftStyle() != EBorderStyle::kNone); | 489 return BorderLeftWidth() && (BorderLeftStyle() != EBorderStyle::kNone); |
| 499 } | 490 } |
| 500 | 491 |
| 501 // border-right-width | 492 // border-right-width |
| 502 float BorderRightWidth() const { | 493 float BorderRightWidth() const { |
| 503 if (BorderRightStyle() == EBorderStyle::kNone || | 494 if (BorderRightStyle() == EBorderStyle::kNone || |
| 504 BorderRightStyle() == EBorderStyle::kHidden) | 495 BorderRightStyle() == EBorderStyle::kHidden) |
| 505 return 0; | 496 return 0; |
| 506 return static_cast<float>(BorderRightWidthInternal()) / | 497 return BorderRightWidthInternal().Width(); |
| 507 kBorderWidthDenominator; | |
| 508 } | 498 } |
| 509 void SetBorderRightWidth(float v) { | 499 void SetBorderRightWidth(float v) { |
| 510 SetBorderRightWidthInternal(WidthToFixedPoint(v)); | 500 MutableBorderRightWidthInternal().SetWidth(v); |
| 511 } | 501 } |
| 512 bool BorderRightNonZero() const { | 502 bool BorderRightNonZero() const { |
| 513 return BorderRightWidth() && (BorderRightStyle() != EBorderStyle::kNone); | 503 return BorderRightWidth() && (BorderRightStyle() != EBorderStyle::kNone); |
| 514 } | 504 } |
| 515 | 505 |
| 516 static EBorderStyle InitialColumnRuleStyle() { return EBorderStyle::kNone; } | 506 static EBorderStyle InitialColumnRuleStyle() { return EBorderStyle::kNone; } |
| 517 | 507 |
| 518 // Border color properties. | 508 // Border color properties. |
| 519 // border-left-color | 509 // border-left-color |
| 520 void SetBorderLeftColor(const StyleColor& color) { | 510 void SetBorderLeftColor(const StyleColor& color) { |
| (...skipping 2251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2772 bool HasBorderImageOutsets() const { | 2762 bool HasBorderImageOutsets() const { |
| 2773 return BorderImage().HasImage() && BorderImage().Outset().NonZero(); | 2763 return BorderImage().HasImage() && BorderImage().Outset().NonZero(); |
| 2774 } | 2764 } |
| 2775 LayoutRectOutsets BorderImageOutsets() const { | 2765 LayoutRectOutsets BorderImageOutsets() const { |
| 2776 return ImageOutsets(BorderImage()); | 2766 return ImageOutsets(BorderImage()); |
| 2777 } | 2767 } |
| 2778 bool BorderImageSlicesFill() const { return BorderImage().Fill(); } | 2768 bool BorderImageSlicesFill() const { return BorderImage().Fill(); } |
| 2779 | 2769 |
| 2780 void SetBorderImageSlicesFill(bool); | 2770 void SetBorderImageSlicesFill(bool); |
| 2781 const BorderValue BorderLeft() const { | 2771 const BorderValue BorderLeft() const { |
| 2782 return BorderValue( | 2772 return BorderValue(BorderLeftStyle(), BorderLeftColor(), |
| 2783 BorderLeftStyle(), BorderLeftColor(), | 2773 BorderLeftWidthInternal().Width(), OutlineStyleIsAuto()); |
| 2784 static_cast<float>(BorderLeftWidthInternal()) / kBorderWidthDenominator, | |
| 2785 OutlineStyleIsAuto()); | |
| 2786 } | 2774 } |
| 2787 const BorderValue BorderRight() const { | 2775 const BorderValue BorderRight() const { |
| 2788 return BorderValue(BorderRightStyle(), BorderRightColor(), | 2776 return BorderValue(BorderRightStyle(), BorderRightColor(), |
| 2789 static_cast<float>(BorderRightWidthInternal()) / | 2777 BorderRightWidthInternal().Width(), |
| 2790 kBorderWidthDenominator, | |
| 2791 OutlineStyleIsAuto()); | 2778 OutlineStyleIsAuto()); |
| 2792 } | 2779 } |
| 2793 const BorderValue BorderTop() const { | 2780 const BorderValue BorderTop() const { |
| 2794 return BorderValue( | 2781 return BorderValue(BorderTopStyle(), BorderTopColor(), |
| 2795 BorderTopStyle(), BorderTopColor(), | 2782 BorderTopWidthInternal().Width(), OutlineStyleIsAuto()); |
| 2796 static_cast<float>(BorderTopWidthInternal()) / kBorderWidthDenominator, | |
| 2797 OutlineStyleIsAuto()); | |
| 2798 } | 2783 } |
| 2799 const BorderValue BorderBottom() const { | 2784 const BorderValue BorderBottom() const { |
| 2800 return BorderValue(BorderBottomStyle(), BorderBottomColor(), | 2785 return BorderValue(BorderBottomStyle(), BorderBottomColor(), |
| 2801 static_cast<float>(BorderBottomWidthInternal()) / | 2786 BorderBottomWidthInternal().Width(), |
| 2802 kBorderWidthDenominator, | |
| 2803 OutlineStyleIsAuto()); | 2787 OutlineStyleIsAuto()); |
| 2804 } | 2788 } |
| 2805 | 2789 |
| 2806 bool BorderSizeEquals(const ComputedStyle& o) const { | 2790 bool BorderSizeEquals(const ComputedStyle& o) const { |
| 2807 return BorderWidthEquals(BorderLeftWidth(), o.BorderLeftWidth()) && | 2791 return BorderLeftWidthInternal().WidthEquals( |
| 2808 BorderWidthEquals(BorderTopWidth(), o.BorderTopWidth()) && | 2792 o.BorderLeftWidthInternal().Width()) && |
| 2809 BorderWidthEquals(BorderRightWidth(), o.BorderRightWidth()) && | 2793 BorderTopWidthInternal().WidthEquals( |
| 2810 BorderWidthEquals(BorderBottomWidth(), o.BorderBottomWidth()); | 2794 o.BorderTopWidthInternal().Width()) && |
| 2795 BorderRightWidthInternal().WidthEquals( |
| 2796 o.BorderRightWidthInternal().Width()) && |
| 2797 BorderBottomWidthInternal().WidthEquals( |
| 2798 o.BorderBottomWidthInternal().Width()); |
| 2811 } | 2799 } |
| 2812 | 2800 |
| 2813 BorderValue BorderBefore() const; | 2801 BorderValue BorderBefore() const; |
| 2814 BorderValue BorderAfter() const; | 2802 BorderValue BorderAfter() const; |
| 2815 BorderValue BorderStart() const; | 2803 BorderValue BorderStart() const; |
| 2816 BorderValue BorderEnd() const; | 2804 BorderValue BorderEnd() const; |
| 2817 float BorderAfterWidth() const; | 2805 float BorderAfterWidth() const; |
| 2818 float BorderBeforeWidth() const; | 2806 float BorderBeforeWidth() const; |
| 2819 float BorderEndWidth() const; | 2807 float BorderEndWidth() const; |
| 2820 float BorderStartWidth() const; | 2808 float BorderStartWidth() const; |
| (...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3774 PseudoBitsInternal() | 1 << (pseudo - kFirstPublicPseudoId))); | 3762 PseudoBitsInternal() | 1 << (pseudo - kFirstPublicPseudoId))); |
| 3775 } | 3763 } |
| 3776 | 3764 |
| 3777 inline bool ComputedStyle::HasPseudoElementStyle() const { | 3765 inline bool ComputedStyle::HasPseudoElementStyle() const { |
| 3778 return PseudoBitsInternal() & kElementPseudoIdMask; | 3766 return PseudoBitsInternal() & kElementPseudoIdMask; |
| 3779 } | 3767 } |
| 3780 | 3768 |
| 3781 } // namespace blink | 3769 } // namespace blink |
| 3782 | 3770 |
| 3783 #endif // ComputedStyle_h | 3771 #endif // ComputedStyle_h |
| OLD | NEW |