| // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #ifndef ComputedStyleBase_h |
| #define ComputedStyleBase_h |
| |
| #include "core/style/ComputedStyleConstants.h" |
| #include "core/CoreExport.h" |
| #include "core/style/DataRef.h" |
| #include "core/css/StyleColor.h" |
| #include "core/style/BorderData.h" |
| #include "core/style/FillLayer.h" |
| #include "platform/Length.h" |
| #include "platform/text/TextDirection.h" |
| #include "platform/text/UnicodeBidi.h" |
| #include "platform/text/WritingMode.h" |
| |
| |
| namespace blink { |
| |
| // The generated portion of ComputedStyle. For more info, see the header comment |
| // in ComputedStyle.h. |
| class CORE_EXPORT ComputedStyleBase { |
| public: |
| inline bool IndependentInheritedEqual(const ComputedStyleBase& o) const { |
| return ( |
| pointer_events_ == o.pointer_events_ && |
| text_align_ == o.text_align_ && |
| white_space_ == o.white_space_ && |
| text_transform_ == o.text_transform_ && |
| visibility_ == o.visibility_ && |
| border_collapse_ == o.border_collapse_ && |
| box_direction_ == o.box_direction_ && |
| caption_side_ == o.caption_side_ && |
| empty_cells_ == o.empty_cells_ && |
| list_style_position_ == o.list_style_position_ && |
| print_color_adjust_ == o.print_color_adjust_ && |
| rtl_ordering_ == o.rtl_ordering_ && |
| true |
| ); |
| } |
| |
| inline bool NonIndependentInheritedEqual(const ComputedStyleBase& o) const { |
| return ( |
| cursor_ == o.cursor_ && |
| list_style_type_ == o.list_style_type_ && |
| inside_link_ == o.inside_link_ && |
| writing_mode_ == o.writing_mode_ && |
| direction_ == o.direction_ && |
| has_simple_underline_ == o.has_simple_underline_ && |
| true |
| ); |
| } |
| |
| inline bool InheritedEqual(const ComputedStyleBase& o) const { |
| return IndependentInheritedEqual(o) && NonIndependentInheritedEqual(o); |
| } |
| |
| inline bool NonInheritedEqual(const ComputedStyleBase& o) const { |
| return ( |
| background_data_ == o.background_data_ && |
| surround_data_ == o.surround_data_ && |
| display_ == o.display_ && |
| original_display_ == o.original_display_ && |
| break_after_ == o.break_after_ && |
| break_before_ == o.break_before_ && |
| vertical_align_ == o.vertical_align_ && |
| overflow_x_ == o.overflow_x_ && |
| overflow_y_ == o.overflow_y_ && |
| position_ == o.position_ && |
| unicode_bidi_ == o.unicode_bidi_ && |
| break_inside_ == o.break_inside_ && |
| clear_ == o.clear_ && |
| floating_ == o.floating_ && |
| overflow_anchor_ == o.overflow_anchor_ && |
| transform_box_ == o.transform_box_ && |
| table_layout_ == o.table_layout_ && |
| true |
| ); |
| } |
| |
| enum IsAtShadowBoundary { |
| kAtShadowBoundary, |
| kNotAtShadowBoundary, |
| }; |
| void InheritFrom(const ComputedStyleBase& inheritParent, |
| IsAtShadowBoundary isAtShadowBoundary = kNotAtShadowBoundary); |
| |
| void CopyNonInheritedFromCached(const ComputedStyleBase& other); |
| |
| // Copies the values of any independent inherited properties from the parent |
| // style that are marked as inherited by this style. |
| void PropagateIndependentInheritedProperties( |
| const ComputedStyleBase& parentStyle); |
| |
| // Fields. |
| // TODO(sashab): Remove initialFoo() static methods and update callers to |
| // use resetFoo(), which can be more efficient. |
| |
| // Background |
| // Getters and setters not generated |
| |
| // BackgroundColor |
| // Getters and setters not generated |
| |
| // padding-bottom |
| inline static Length InitialPaddingBottom() { |
| return Length(kFixed); |
| } |
| const Length& PaddingBottom() const { |
| return surround_data_->padding_bottom_; |
| } |
| void SetPaddingBottom(const Length& v) { |
| surround_data_.Access()->padding_bottom_ = v; |
| } |
| void SetPaddingBottom(Length&& v) { |
| surround_data_.Access()->padding_bottom_ = std::move(v); |
| } |
| inline void ResetPaddingBottom() { |
| surround_data_.Access()->padding_bottom_ = Length(kFixed); |
| } |
| |
| // margin-right |
| inline static Length InitialMarginRight() { |
| return Length(kFixed); |
| } |
| const Length& MarginRight() const { |
| return surround_data_->margin_right_; |
| } |
| void SetMarginRight(const Length& v) { |
| surround_data_.Access()->margin_right_ = v; |
| } |
| void SetMarginRight(Length&& v) { |
| surround_data_.Access()->margin_right_ = std::move(v); |
| } |
| inline void ResetMarginRight() { |
| surround_data_.Access()->margin_right_ = Length(kFixed); |
| } |
| |
| // padding-right |
| inline static Length InitialPaddingRight() { |
| return Length(kFixed); |
| } |
| const Length& PaddingRight() const { |
| return surround_data_->padding_right_; |
| } |
| void SetPaddingRight(const Length& v) { |
| surround_data_.Access()->padding_right_ = v; |
| } |
| void SetPaddingRight(Length&& v) { |
| surround_data_.Access()->padding_right_ = std::move(v); |
| } |
| inline void ResetPaddingRight() { |
| surround_data_.Access()->padding_right_ = Length(kFixed); |
| } |
| |
| // bottom |
| inline static Length InitialBottom() { |
| return Length(); |
| } |
| const Length& Bottom() const { |
| return surround_data_->bottom_; |
| } |
| void SetBottom(const Length& v) { |
| surround_data_.Access()->bottom_ = v; |
| } |
| void SetBottom(Length&& v) { |
| surround_data_.Access()->bottom_ = std::move(v); |
| } |
| inline void ResetBottom() { |
| surround_data_.Access()->bottom_ = Length(); |
| } |
| |
| // top |
| inline static Length InitialTop() { |
| return Length(); |
| } |
| const Length& Top() const { |
| return surround_data_->top_; |
| } |
| void SetTop(const Length& v) { |
| surround_data_.Access()->top_ = v; |
| } |
| void SetTop(Length&& v) { |
| surround_data_.Access()->top_ = std::move(v); |
| } |
| inline void ResetTop() { |
| surround_data_.Access()->top_ = Length(); |
| } |
| |
| // margin-top |
| inline static Length InitialMarginTop() { |
| return Length(kFixed); |
| } |
| const Length& MarginTop() const { |
| return surround_data_->margin_top_; |
| } |
| void SetMarginTop(const Length& v) { |
| surround_data_.Access()->margin_top_ = v; |
| } |
| void SetMarginTop(Length&& v) { |
| surround_data_.Access()->margin_top_ = std::move(v); |
| } |
| inline void ResetMarginTop() { |
| surround_data_.Access()->margin_top_ = Length(kFixed); |
| } |
| |
| // padding-left |
| inline static Length InitialPaddingLeft() { |
| return Length(kFixed); |
| } |
| const Length& PaddingLeft() const { |
| return surround_data_->padding_left_; |
| } |
| void SetPaddingLeft(const Length& v) { |
| surround_data_.Access()->padding_left_ = v; |
| } |
| void SetPaddingLeft(Length&& v) { |
| surround_data_.Access()->padding_left_ = std::move(v); |
| } |
| inline void ResetPaddingLeft() { |
| surround_data_.Access()->padding_left_ = Length(kFixed); |
| } |
| |
| // left |
| inline static Length InitialLeft() { |
| return Length(); |
| } |
| const Length& Left() const { |
| return surround_data_->left_; |
| } |
| void SetLeft(const Length& v) { |
| surround_data_.Access()->left_ = v; |
| } |
| void SetLeft(Length&& v) { |
| surround_data_.Access()->left_ = std::move(v); |
| } |
| inline void ResetLeft() { |
| surround_data_.Access()->left_ = Length(); |
| } |
| |
| // margin-bottom |
| inline static Length InitialMarginBottom() { |
| return Length(kFixed); |
| } |
| const Length& MarginBottom() const { |
| return surround_data_->margin_bottom_; |
| } |
| void SetMarginBottom(const Length& v) { |
| surround_data_.Access()->margin_bottom_ = v; |
| } |
| void SetMarginBottom(Length&& v) { |
| surround_data_.Access()->margin_bottom_ = std::move(v); |
| } |
| inline void ResetMarginBottom() { |
| surround_data_.Access()->margin_bottom_ = Length(kFixed); |
| } |
| |
| // right |
| inline static Length InitialRight() { |
| return Length(); |
| } |
| const Length& Right() const { |
| return surround_data_->right_; |
| } |
| void SetRight(const Length& v) { |
| surround_data_.Access()->right_ = v; |
| } |
| void SetRight(Length&& v) { |
| surround_data_.Access()->right_ = std::move(v); |
| } |
| inline void ResetRight() { |
| surround_data_.Access()->right_ = Length(); |
| } |
| |
| // margin-left |
| inline static Length InitialMarginLeft() { |
| return Length(kFixed); |
| } |
| const Length& MarginLeft() const { |
| return surround_data_->margin_left_; |
| } |
| void SetMarginLeft(const Length& v) { |
| surround_data_.Access()->margin_left_ = v; |
| } |
| void SetMarginLeft(Length&& v) { |
| surround_data_.Access()->margin_left_ = std::move(v); |
| } |
| inline void ResetMarginLeft() { |
| surround_data_.Access()->margin_left_ = Length(kFixed); |
| } |
| |
| // padding-top |
| inline static Length InitialPaddingTop() { |
| return Length(kFixed); |
| } |
| const Length& PaddingTop() const { |
| return surround_data_->padding_top_; |
| } |
| void SetPaddingTop(const Length& v) { |
| surround_data_.Access()->padding_top_ = v; |
| } |
| void SetPaddingTop(Length&& v) { |
| surround_data_.Access()->padding_top_ = std::move(v); |
| } |
| inline void ResetPaddingTop() { |
| surround_data_.Access()->padding_top_ = Length(kFixed); |
| } |
| |
| // border |
| // Getters and setters not generated |
| |
| // PseudoBits |
| // Getters and setters not generated |
| |
| // cursor |
| inline static ECursor InitialCursor() { |
| return ECursor::kAuto; |
| } |
| ECursor Cursor() const { |
| return static_cast<ECursor>(cursor_); |
| } |
| void SetCursor(ECursor v) { |
| cursor_ = static_cast<unsigned>(v); |
| } |
| inline void ResetCursor() { |
| cursor_ = static_cast<unsigned>(ECursor::kAuto); |
| } |
| |
| // list-style-type |
| inline static EListStyleType InitialListStyleType() { |
| return EListStyleType::kDisc; |
| } |
| EListStyleType ListStyleType() const { |
| return static_cast<EListStyleType>(list_style_type_); |
| } |
| void SetListStyleType(EListStyleType v) { |
| list_style_type_ = static_cast<unsigned>(v); |
| } |
| inline void ResetListStyleType() { |
| list_style_type_ = static_cast<unsigned>(EListStyleType::kDisc); |
| } |
| |
| // StyleType |
| // Getters and setters not generated |
| |
| // display |
| inline static EDisplay InitialDisplay() { |
| return EDisplay::kInline; |
| } |
| EDisplay Display() const { |
| return static_cast<EDisplay>(display_); |
| } |
| void SetDisplay(EDisplay v) { |
| display_ = static_cast<unsigned>(v); |
| } |
| inline void ResetDisplay() { |
| display_ = static_cast<unsigned>(EDisplay::kInline); |
| } |
| |
| // AffectedByActive |
| bool AffectedByActive() const { |
| return static_cast<bool>(affected_by_active_); |
| } |
| void SetAffectedByActive() { |
| affected_by_active_ = static_cast<unsigned>(true); |
| } |
| |
| // OriginalDisplay |
| inline static EDisplay InitialOriginalDisplay() { |
| return EDisplay::kInline; |
| } |
| EDisplay OriginalDisplay() const { |
| return static_cast<EDisplay>(original_display_); |
| } |
| void SetOriginalDisplay(EDisplay v) { |
| original_display_ = static_cast<unsigned>(v); |
| } |
| inline void ResetOriginalDisplay() { |
| original_display_ = static_cast<unsigned>(EDisplay::kInline); |
| } |
| |
| // break-after |
| inline static EBreakBetween InitialBreakAfter() { |
| return EBreakBetween::kAuto; |
| } |
| EBreakBetween BreakAfter() const { |
| return static_cast<EBreakBetween>(break_after_); |
| } |
| void SetBreakAfter(EBreakBetween v) { |
| break_after_ = static_cast<unsigned>(v); |
| } |
| inline void ResetBreakAfter() { |
| break_after_ = static_cast<unsigned>(EBreakBetween::kAuto); |
| } |
| |
| // break-before |
| inline static EBreakBetween InitialBreakBefore() { |
| return EBreakBetween::kAuto; |
| } |
| EBreakBetween BreakBefore() const { |
| return static_cast<EBreakBetween>(break_before_); |
| } |
| void SetBreakBefore(EBreakBetween v) { |
| break_before_ = static_cast<unsigned>(v); |
| } |
| inline void ResetBreakBefore() { |
| break_before_ = static_cast<unsigned>(EBreakBetween::kAuto); |
| } |
| |
| // pointer-events |
| inline static EPointerEvents InitialPointerEvents() { |
| return EPointerEvents::kAuto; |
| } |
| EPointerEvents PointerEvents() const { |
| return static_cast<EPointerEvents>(pointer_events_); |
| } |
| void SetPointerEvents(EPointerEvents v) { |
| pointer_events_ = static_cast<unsigned>(v); |
| } |
| inline void ResetPointerEvents() { |
| pointer_events_ = static_cast<unsigned>(EPointerEvents::kAuto); |
| } |
| |
| // text-align |
| inline static ETextAlign InitialTextAlign() { |
| return ETextAlign::kStart; |
| } |
| ETextAlign GetTextAlign() const { |
| return static_cast<ETextAlign>(text_align_); |
| } |
| void SetTextAlign(ETextAlign v) { |
| text_align_ = static_cast<unsigned>(v); |
| } |
| inline void ResetTextAlign() { |
| text_align_ = static_cast<unsigned>(ETextAlign::kStart); |
| } |
| |
| // VerticalAlign |
| // Getters and setters not generated |
| |
| // overflow-x |
| inline static EOverflow InitialOverflowX() { |
| return EOverflow::kVisible; |
| } |
| EOverflow OverflowX() const { |
| return static_cast<EOverflow>(overflow_x_); |
| } |
| void SetOverflowX(EOverflow v) { |
| overflow_x_ = static_cast<unsigned>(v); |
| } |
| inline void ResetOverflowX() { |
| overflow_x_ = static_cast<unsigned>(EOverflow::kVisible); |
| } |
| |
| // overflow-y |
| inline static EOverflow InitialOverflowY() { |
| return EOverflow::kVisible; |
| } |
| EOverflow OverflowY() const { |
| return static_cast<EOverflow>(overflow_y_); |
| } |
| void SetOverflowY(EOverflow v) { |
| overflow_y_ = static_cast<unsigned>(v); |
| } |
| inline void ResetOverflowY() { |
| overflow_y_ = static_cast<unsigned>(EOverflow::kVisible); |
| } |
| |
| // AffectedByDrag |
| bool AffectedByDrag() const { |
| return static_cast<bool>(affected_by_drag_); |
| } |
| void SetAffectedByDrag() { |
| affected_by_drag_ = static_cast<unsigned>(true); |
| } |
| |
| // position |
| inline static EPosition InitialPosition() { |
| return EPosition::kStatic; |
| } |
| EPosition GetPosition() const { |
| return static_cast<EPosition>(position_); |
| } |
| void SetPosition(EPosition v) { |
| position_ = static_cast<unsigned>(v); |
| } |
| inline void ResetPosition() { |
| position_ = static_cast<unsigned>(EPosition::kStatic); |
| } |
| |
| // unicode-bidi |
| inline static UnicodeBidi InitialUnicodeBidi() { |
| return UnicodeBidi::kNormal; |
| } |
| UnicodeBidi GetUnicodeBidi() const { |
| return static_cast<UnicodeBidi>(unicode_bidi_); |
| } |
| void SetUnicodeBidi(UnicodeBidi v) { |
| unicode_bidi_ = static_cast<unsigned>(v); |
| } |
| inline void ResetUnicodeBidi() { |
| unicode_bidi_ = static_cast<unsigned>(UnicodeBidi::kNormal); |
| } |
| |
| // white-space |
| inline static EWhiteSpace InitialWhiteSpace() { |
| return EWhiteSpace::kNormal; |
| } |
| EWhiteSpace WhiteSpace() const { |
| return static_cast<EWhiteSpace>(white_space_); |
| } |
| void SetWhiteSpace(EWhiteSpace v) { |
| white_space_ = static_cast<unsigned>(v); |
| } |
| inline void ResetWhiteSpace() { |
| white_space_ = static_cast<unsigned>(EWhiteSpace::kNormal); |
| } |
| |
| // break-inside |
| inline static EBreakInside InitialBreakInside() { |
| return EBreakInside::kAuto; |
| } |
| EBreakInside BreakInside() const { |
| return static_cast<EBreakInside>(break_inside_); |
| } |
| void SetBreakInside(EBreakInside v) { |
| break_inside_ = static_cast<unsigned>(v); |
| } |
| inline void ResetBreakInside() { |
| break_inside_ = static_cast<unsigned>(EBreakInside::kAuto); |
| } |
| |
| // clear |
| inline static EClear InitialClear() { |
| return EClear::kNone; |
| } |
| EClear Clear() const { |
| return static_cast<EClear>(clear_); |
| } |
| void SetClear(EClear v) { |
| clear_ = static_cast<unsigned>(v); |
| } |
| inline void ResetClear() { |
| clear_ = static_cast<unsigned>(EClear::kNone); |
| } |
| |
| // float |
| inline static EFloat InitialFloating() { |
| return EFloat::kNone; |
| } |
| EFloat Floating() const { |
| return static_cast<EFloat>(floating_); |
| } |
| void SetFloating(EFloat v) { |
| floating_ = static_cast<unsigned>(v); |
| } |
| inline void ResetFloating() { |
| floating_ = static_cast<unsigned>(EFloat::kNone); |
| } |
| |
| // InsideLink |
| inline static EInsideLink InitialInsideLink() { |
| return EInsideLink::kNotInsideLink; |
| } |
| EInsideLink InsideLink() const { |
| return static_cast<EInsideLink>(inside_link_); |
| } |
| void SetInsideLink(EInsideLink v) { |
| inside_link_ = static_cast<unsigned>(v); |
| } |
| inline void ResetInsideLink() { |
| inside_link_ = static_cast<unsigned>(EInsideLink::kNotInsideLink); |
| } |
| |
| // overflow-anchor |
| inline static EOverflowAnchor InitialOverflowAnchor() { |
| return EOverflowAnchor::kAuto; |
| } |
| EOverflowAnchor OverflowAnchor() const { |
| return static_cast<EOverflowAnchor>(overflow_anchor_); |
| } |
| void SetOverflowAnchor(EOverflowAnchor v) { |
| overflow_anchor_ = static_cast<unsigned>(v); |
| } |
| inline void ResetOverflowAnchor() { |
| overflow_anchor_ = static_cast<unsigned>(EOverflowAnchor::kAuto); |
| } |
| |
| // text-transform |
| inline static ETextTransform InitialTextTransform() { |
| return ETextTransform::kNone; |
| } |
| ETextTransform TextTransform() const { |
| return static_cast<ETextTransform>(text_transform_); |
| } |
| void SetTextTransform(ETextTransform v) { |
| text_transform_ = static_cast<unsigned>(v); |
| } |
| inline void ResetTextTransform() { |
| text_transform_ = static_cast<unsigned>(ETextTransform::kNone); |
| } |
| |
| // transform-box |
| inline static ETransformBox InitialTransformBox() { |
| return ETransformBox::kBorderBox; |
| } |
| ETransformBox TransformBox() const { |
| return static_cast<ETransformBox>(transform_box_); |
| } |
| void SetTransformBox(ETransformBox v) { |
| transform_box_ = static_cast<unsigned>(v); |
| } |
| inline void ResetTransformBox() { |
| transform_box_ = static_cast<unsigned>(ETransformBox::kBorderBox); |
| } |
| |
| // visibility |
| inline static EVisibility InitialVisibility() { |
| return EVisibility::kVisible; |
| } |
| EVisibility Visibility() const { |
| return static_cast<EVisibility>(visibility_); |
| } |
| void SetVisibility(EVisibility v) { |
| visibility_ = static_cast<unsigned>(v); |
| } |
| inline void ResetVisibility() { |
| visibility_ = static_cast<unsigned>(EVisibility::kVisible); |
| } |
| |
| // writing-mode |
| inline static WritingMode InitialWritingMode() { |
| return WritingMode::kHorizontalTb; |
| } |
| WritingMode GetWritingMode() const { |
| return static_cast<WritingMode>(writing_mode_); |
| } |
| void SetWritingMode(WritingMode v) { |
| writing_mode_ = static_cast<unsigned>(v); |
| } |
| inline void ResetWritingMode() { |
| writing_mode_ = static_cast<unsigned>(WritingMode::kHorizontalTb); |
| } |
| |
| // AffectedByFocus |
| bool AffectedByFocus() const { |
| return static_cast<bool>(affected_by_focus_); |
| } |
| void SetAffectedByFocus() { |
| affected_by_focus_ = static_cast<unsigned>(true); |
| } |
| |
| // AffectedByFocusWithin |
| bool AffectedByFocusWithin() const { |
| return static_cast<bool>(affected_by_focus_within_); |
| } |
| void SetAffectedByFocusWithin() { |
| affected_by_focus_within_ = static_cast<unsigned>(true); |
| } |
| |
| // AffectedByHover |
| bool AffectedByHover() const { |
| return static_cast<bool>(affected_by_hover_); |
| } |
| void SetAffectedByHover() { |
| affected_by_hover_ = static_cast<unsigned>(true); |
| } |
| |
| // border-collapse |
| inline static EBorderCollapse InitialBorderCollapse() { |
| return EBorderCollapse::kSeparate; |
| } |
| EBorderCollapse BorderCollapse() const { |
| return static_cast<EBorderCollapse>(border_collapse_); |
| } |
| void SetBorderCollapse(EBorderCollapse v) { |
| border_collapse_ = static_cast<unsigned>(v); |
| } |
| inline void ResetBorderCollapse() { |
| border_collapse_ = static_cast<unsigned>(EBorderCollapse::kSeparate); |
| } |
| |
| // border-collapse |
| inline static bool InitialBorderCollapseIsInherited() { |
| return true; |
| } |
| bool BorderCollapseIsInherited() const { |
| return static_cast<bool>(border_collapse_is_inherited_); |
| } |
| void SetBorderCollapseIsInherited(bool v) { |
| border_collapse_is_inherited_ = static_cast<unsigned>(v); |
| } |
| inline void ResetBorderCollapseIsInherited() { |
| border_collapse_is_inherited_ = static_cast<unsigned>(true); |
| } |
| |
| // -webkit-box-direction |
| inline static EBoxDirection InitialBoxDirection() { |
| return EBoxDirection::kNormal; |
| } |
| EBoxDirection BoxDirection() const { |
| return static_cast<EBoxDirection>(box_direction_); |
| } |
| void SetBoxDirection(EBoxDirection v) { |
| box_direction_ = static_cast<unsigned>(v); |
| } |
| inline void ResetBoxDirection() { |
| box_direction_ = static_cast<unsigned>(EBoxDirection::kNormal); |
| } |
| |
| // -webkit-box-direction |
| inline static bool InitialBoxDirectionIsInherited() { |
| return true; |
| } |
| bool BoxDirectionIsInherited() const { |
| return static_cast<bool>(box_direction_is_inherited_); |
| } |
| void SetBoxDirectionIsInherited(bool v) { |
| box_direction_is_inherited_ = static_cast<unsigned>(v); |
| } |
| inline void ResetBoxDirectionIsInherited() { |
| box_direction_is_inherited_ = static_cast<unsigned>(true); |
| } |
| |
| // caption-side |
| inline static ECaptionSide InitialCaptionSide() { |
| return ECaptionSide::kTop; |
| } |
| ECaptionSide CaptionSide() const { |
| return static_cast<ECaptionSide>(caption_side_); |
| } |
| void SetCaptionSide(ECaptionSide v) { |
| caption_side_ = static_cast<unsigned>(v); |
| } |
| inline void ResetCaptionSide() { |
| caption_side_ = static_cast<unsigned>(ECaptionSide::kTop); |
| } |
| |
| // caption-side |
| inline static bool InitialCaptionSideIsInherited() { |
| return true; |
| } |
| bool CaptionSideIsInherited() const { |
| return static_cast<bool>(caption_side_is_inherited_); |
| } |
| void SetCaptionSideIsInherited(bool v) { |
| caption_side_is_inherited_ = static_cast<unsigned>(v); |
| } |
| inline void ResetCaptionSideIsInherited() { |
| caption_side_is_inherited_ = static_cast<unsigned>(true); |
| } |
| |
| // direction |
| inline static TextDirection InitialDirection() { |
| return TextDirection::kLtr; |
| } |
| TextDirection Direction() const { |
| return static_cast<TextDirection>(direction_); |
| } |
| void SetDirection(TextDirection v) { |
| direction_ = static_cast<unsigned>(v); |
| } |
| inline void ResetDirection() { |
| direction_ = static_cast<unsigned>(TextDirection::kLtr); |
| } |
| |
| // empty-cells |
| inline static EEmptyCells InitialEmptyCells() { |
| return EEmptyCells::kShow; |
| } |
| EEmptyCells EmptyCells() const { |
| return static_cast<EEmptyCells>(empty_cells_); |
| } |
| void SetEmptyCells(EEmptyCells v) { |
| empty_cells_ = static_cast<unsigned>(v); |
| } |
| inline void ResetEmptyCells() { |
| empty_cells_ = static_cast<unsigned>(EEmptyCells::kShow); |
| } |
| |
| // empty-cells |
| inline static bool InitialEmptyCellsIsInherited() { |
| return true; |
| } |
| bool EmptyCellsIsInherited() const { |
| return static_cast<bool>(empty_cells_is_inherited_); |
| } |
| void SetEmptyCellsIsInherited(bool v) { |
| empty_cells_is_inherited_ = static_cast<unsigned>(v); |
| } |
| inline void ResetEmptyCellsIsInherited() { |
| empty_cells_is_inherited_ = static_cast<unsigned>(true); |
| } |
| |
| // EmptyState |
| // Getters and setters not generated |
| |
| // HasExplicitlyInheritedProperties |
| bool HasExplicitlyInheritedProperties() const { |
| return static_cast<bool>(has_explicitly_inherited_properties_); |
| } |
| void SetHasExplicitlyInheritedProperties() { |
| has_explicitly_inherited_properties_ = static_cast<unsigned>(true); |
| } |
| |
| // HasRemUnits |
| bool HasRemUnits() const { |
| return static_cast<bool>(has_rem_units_); |
| } |
| void SetHasRemUnits() { |
| has_rem_units_ = static_cast<unsigned>(true); |
| } |
| |
| // HasSimpleUnderline |
| // Getters and setters not generated |
| |
| // HasVariableReferenceFromNonInheritedProperty |
| bool HasVariableReferenceFromNonInheritedProperty() const { |
| return static_cast<bool>(has_variable_reference_from_non_inherited_property_); |
| } |
| void SetHasVariableReferenceFromNonInheritedProperty() { |
| has_variable_reference_from_non_inherited_property_ = static_cast<unsigned>(true); |
| } |
| |
| // HasViewportUnits |
| inline static bool InitialHasViewportUnits() { |
| return false; |
| } |
| bool HasViewportUnits() const { |
| return static_cast<bool>(has_viewport_units_); |
| } |
| void SetHasViewportUnits(bool v) { |
| has_viewport_units_ = static_cast<unsigned>(v); |
| } |
| inline void ResetHasViewportUnits() { |
| has_viewport_units_ = static_cast<unsigned>(false); |
| } |
| |
| // IsLink |
| bool IsLink() const { |
| return static_cast<bool>(is_link_); |
| } |
| void SetIsLink() { |
| is_link_ = static_cast<unsigned>(true); |
| } |
| |
| // list-style-position |
| inline static EListStylePosition InitialListStylePosition() { |
| return EListStylePosition::kOutside; |
| } |
| EListStylePosition ListStylePosition() const { |
| return static_cast<EListStylePosition>(list_style_position_); |
| } |
| void SetListStylePosition(EListStylePosition v) { |
| list_style_position_ = static_cast<unsigned>(v); |
| } |
| inline void ResetListStylePosition() { |
| list_style_position_ = static_cast<unsigned>(EListStylePosition::kOutside); |
| } |
| |
| // list-style-position |
| inline static bool InitialListStylePositionIsInherited() { |
| return true; |
| } |
| bool ListStylePositionIsInherited() const { |
| return static_cast<bool>(list_style_position_is_inherited_); |
| } |
| void SetListStylePositionIsInherited(bool v) { |
| list_style_position_is_inherited_ = static_cast<unsigned>(v); |
| } |
| inline void ResetListStylePositionIsInherited() { |
| list_style_position_is_inherited_ = static_cast<unsigned>(true); |
| } |
| |
| // pointer-events |
| inline static bool InitialPointerEventsIsInherited() { |
| return true; |
| } |
| bool PointerEventsIsInherited() const { |
| return static_cast<bool>(pointer_events_is_inherited_); |
| } |
| void SetPointerEventsIsInherited(bool v) { |
| pointer_events_is_inherited_ = static_cast<unsigned>(v); |
| } |
| inline void ResetPointerEventsIsInherited() { |
| pointer_events_is_inherited_ = static_cast<unsigned>(true); |
| } |
| |
| // -webkit-print-color-adjust |
| inline static EPrintColorAdjust InitialPrintColorAdjust() { |
| return EPrintColorAdjust::kEconomy; |
| } |
| EPrintColorAdjust PrintColorAdjust() const { |
| return static_cast<EPrintColorAdjust>(print_color_adjust_); |
| } |
| void SetPrintColorAdjust(EPrintColorAdjust v) { |
| print_color_adjust_ = static_cast<unsigned>(v); |
| } |
| inline void ResetPrintColorAdjust() { |
| print_color_adjust_ = static_cast<unsigned>(EPrintColorAdjust::kEconomy); |
| } |
| |
| // -webkit-print-color-adjust |
| inline static bool InitialPrintColorAdjustIsInherited() { |
| return true; |
| } |
| bool PrintColorAdjustIsInherited() const { |
| return static_cast<bool>(print_color_adjust_is_inherited_); |
| } |
| void SetPrintColorAdjustIsInherited(bool v) { |
| print_color_adjust_is_inherited_ = static_cast<unsigned>(v); |
| } |
| inline void ResetPrintColorAdjustIsInherited() { |
| print_color_adjust_is_inherited_ = static_cast<unsigned>(true); |
| } |
| |
| // -webkit-rtl-ordering |
| inline static EOrder InitialRtlOrdering() { |
| return EOrder::kLogical; |
| } |
| EOrder RtlOrdering() const { |
| return static_cast<EOrder>(rtl_ordering_); |
| } |
| void SetRtlOrdering(EOrder v) { |
| rtl_ordering_ = static_cast<unsigned>(v); |
| } |
| inline void ResetRtlOrdering() { |
| rtl_ordering_ = static_cast<unsigned>(EOrder::kLogical); |
| } |
| |
| // -webkit-rtl-ordering |
| inline static bool InitialRtlOrderingIsInherited() { |
| return true; |
| } |
| bool RtlOrderingIsInherited() const { |
| return static_cast<bool>(rtl_ordering_is_inherited_); |
| } |
| void SetRtlOrderingIsInherited(bool v) { |
| rtl_ordering_is_inherited_ = static_cast<unsigned>(v); |
| } |
| inline void ResetRtlOrderingIsInherited() { |
| rtl_ordering_is_inherited_ = static_cast<unsigned>(true); |
| } |
| |
| // table-layout |
| inline static ETableLayout InitialTableLayout() { |
| return ETableLayout::kAuto; |
| } |
| ETableLayout TableLayout() const { |
| return static_cast<ETableLayout>(table_layout_); |
| } |
| void SetTableLayout(ETableLayout v) { |
| table_layout_ = static_cast<unsigned>(v); |
| } |
| inline void ResetTableLayout() { |
| table_layout_ = static_cast<unsigned>(ETableLayout::kAuto); |
| } |
| |
| // text-align |
| inline static bool InitialTextAlignIsInherited() { |
| return true; |
| } |
| bool TextAlignIsInherited() const { |
| return static_cast<bool>(text_align_is_inherited_); |
| } |
| void SetTextAlignIsInherited(bool v) { |
| text_align_is_inherited_ = static_cast<unsigned>(v); |
| } |
| inline void ResetTextAlignIsInherited() { |
| text_align_is_inherited_ = static_cast<unsigned>(true); |
| } |
| |
| // text-transform |
| inline static bool InitialTextTransformIsInherited() { |
| return true; |
| } |
| bool TextTransformIsInherited() const { |
| return static_cast<bool>(text_transform_is_inherited_); |
| } |
| void SetTextTransformIsInherited(bool v) { |
| text_transform_is_inherited_ = static_cast<unsigned>(v); |
| } |
| inline void ResetTextTransformIsInherited() { |
| text_transform_is_inherited_ = static_cast<unsigned>(true); |
| } |
| |
| // Unique |
| bool Unique() const { |
| return static_cast<bool>(unique_); |
| } |
| void SetUnique() { |
| unique_ = static_cast<unsigned>(true); |
| } |
| |
| // visibility |
| inline static bool InitialVisibilityIsInherited() { |
| return true; |
| } |
| bool VisibilityIsInherited() const { |
| return static_cast<bool>(visibility_is_inherited_); |
| } |
| void SetVisibilityIsInherited(bool v) { |
| visibility_is_inherited_ = static_cast<unsigned>(v); |
| } |
| inline void ResetVisibilityIsInherited() { |
| visibility_is_inherited_ = static_cast<unsigned>(true); |
| } |
| |
| // white-space |
| inline static bool InitialWhiteSpaceIsInherited() { |
| return true; |
| } |
| bool WhiteSpaceIsInherited() const { |
| return static_cast<bool>(white_space_is_inherited_); |
| } |
| void SetWhiteSpaceIsInherited(bool v) { |
| white_space_is_inherited_ = static_cast<unsigned>(v); |
| } |
| inline void ResetWhiteSpaceIsInherited() { |
| white_space_is_inherited_ = static_cast<unsigned>(true); |
| } |
| |
| private: |
| class StyleBackgroundData : public RefCountedCopyable<StyleBackgroundData> { |
| public: |
| static PassRefPtr<StyleBackgroundData> Create() { |
| return AdoptRef(new StyleBackgroundData); |
| } |
| PassRefPtr<StyleBackgroundData> Copy() const { |
| return AdoptRef(new StyleBackgroundData(*this)); |
| } |
| |
| bool operator==(const StyleBackgroundData& other) const { |
| return ( |
| background_ == other.background_ && |
| background_color_ == other.background_color_ |
| ); |
| } |
| bool operator!=(const StyleBackgroundData& other) const { return !(*this == other); } |
| |
| FillLayer background_; |
| StyleColor background_color_; |
| |
| private: |
| StyleBackgroundData() : |
| background_(FillLayer(kBackgroundFillLayer, true)), |
| background_color_(Color::kTransparent) |
| {} |
| |
| StyleBackgroundData(const StyleBackgroundData&) = default; |
| }; |
| |
| class StyleSurroundData : public RefCountedCopyable<StyleSurroundData> { |
| public: |
| static PassRefPtr<StyleSurroundData> Create() { |
| return AdoptRef(new StyleSurroundData); |
| } |
| PassRefPtr<StyleSurroundData> Copy() const { |
| return AdoptRef(new StyleSurroundData(*this)); |
| } |
| |
| bool operator==(const StyleSurroundData& other) const { |
| return ( |
| padding_bottom_ == other.padding_bottom_ && |
| margin_right_ == other.margin_right_ && |
| padding_right_ == other.padding_right_ && |
| bottom_ == other.bottom_ && |
| top_ == other.top_ && |
| margin_top_ == other.margin_top_ && |
| padding_left_ == other.padding_left_ && |
| left_ == other.left_ && |
| margin_bottom_ == other.margin_bottom_ && |
| right_ == other.right_ && |
| margin_left_ == other.margin_left_ && |
| padding_top_ == other.padding_top_ && |
| border_ == other.border_ |
| ); |
| } |
| bool operator!=(const StyleSurroundData& other) const { return !(*this == other); } |
| |
| Length padding_bottom_; |
| Length margin_right_; |
| Length padding_right_; |
| Length bottom_; |
| Length top_; |
| Length margin_top_; |
| Length padding_left_; |
| Length left_; |
| Length margin_bottom_; |
| Length right_; |
| Length margin_left_; |
| Length padding_top_; |
| BorderData border_; |
| |
| private: |
| StyleSurroundData() : |
| padding_bottom_(Length(kFixed)), |
| margin_right_(Length(kFixed)), |
| padding_right_(Length(kFixed)), |
| bottom_(Length()), |
| top_(Length()), |
| margin_top_(Length(kFixed)), |
| padding_left_(Length(kFixed)), |
| left_(Length()), |
| margin_bottom_(Length(kFixed)), |
| right_(Length()), |
| margin_left_(Length(kFixed)), |
| padding_top_(Length(kFixed)), |
| border_(BorderData()) |
| {} |
| |
| StyleSurroundData(const StyleSurroundData&) = default; |
| }; |
| |
| |
| protected: |
| // Constructor and destructor are protected so that only the parent class ComputedStyle |
| // can instantiate this class. |
| ALWAYS_INLINE ComputedStyleBase() : |
| pseudo_bits_(static_cast<unsigned>(kPseudoIdNone)), |
| cursor_(static_cast<unsigned>(ECursor::kAuto)), |
| list_style_type_(static_cast<unsigned>(EListStyleType::kDisc)), |
| style_type_(static_cast<unsigned>(0)), |
| display_(static_cast<unsigned>(EDisplay::kInline)), |
| affected_by_active_(static_cast<unsigned>(false)), |
| original_display_(static_cast<unsigned>(EDisplay::kInline)), |
| break_after_(static_cast<unsigned>(EBreakBetween::kAuto)), |
| break_before_(static_cast<unsigned>(EBreakBetween::kAuto)), |
| pointer_events_(static_cast<unsigned>(EPointerEvents::kAuto)), |
| text_align_(static_cast<unsigned>(ETextAlign::kStart)), |
| vertical_align_(static_cast<unsigned>(EVerticalAlign::kBaseline)), |
| overflow_x_(static_cast<unsigned>(EOverflow::kVisible)), |
| overflow_y_(static_cast<unsigned>(EOverflow::kVisible)), |
| affected_by_drag_(static_cast<unsigned>(false)), |
| position_(static_cast<unsigned>(EPosition::kStatic)), |
| unicode_bidi_(static_cast<unsigned>(UnicodeBidi::kNormal)), |
| white_space_(static_cast<unsigned>(EWhiteSpace::kNormal)), |
| break_inside_(static_cast<unsigned>(EBreakInside::kAuto)), |
| clear_(static_cast<unsigned>(EClear::kNone)), |
| floating_(static_cast<unsigned>(EFloat::kNone)), |
| inside_link_(static_cast<unsigned>(EInsideLink::kNotInsideLink)), |
| overflow_anchor_(static_cast<unsigned>(EOverflowAnchor::kAuto)), |
| text_transform_(static_cast<unsigned>(ETextTransform::kNone)), |
| transform_box_(static_cast<unsigned>(ETransformBox::kBorderBox)), |
| visibility_(static_cast<unsigned>(EVisibility::kVisible)), |
| writing_mode_(static_cast<unsigned>(WritingMode::kHorizontalTb)), |
| affected_by_focus_(static_cast<unsigned>(false)), |
| affected_by_focus_within_(static_cast<unsigned>(false)), |
| affected_by_hover_(static_cast<unsigned>(false)), |
| border_collapse_(static_cast<unsigned>(EBorderCollapse::kSeparate)), |
| border_collapse_is_inherited_(static_cast<unsigned>(true)), |
| box_direction_(static_cast<unsigned>(EBoxDirection::kNormal)), |
| box_direction_is_inherited_(static_cast<unsigned>(true)), |
| caption_side_(static_cast<unsigned>(ECaptionSide::kTop)), |
| caption_side_is_inherited_(static_cast<unsigned>(true)), |
| direction_(static_cast<unsigned>(TextDirection::kLtr)), |
| empty_cells_(static_cast<unsigned>(EEmptyCells::kShow)), |
| empty_cells_is_inherited_(static_cast<unsigned>(true)), |
| empty_state_(static_cast<unsigned>(false)), |
| has_explicitly_inherited_properties_(static_cast<unsigned>(false)), |
| has_rem_units_(static_cast<unsigned>(false)), |
| has_simple_underline_(static_cast<unsigned>(false)), |
| has_variable_reference_from_non_inherited_property_(static_cast<unsigned>(false)), |
| has_viewport_units_(static_cast<unsigned>(false)), |
| is_link_(static_cast<unsigned>(false)), |
| list_style_position_(static_cast<unsigned>(EListStylePosition::kOutside)), |
| list_style_position_is_inherited_(static_cast<unsigned>(true)), |
| pointer_events_is_inherited_(static_cast<unsigned>(true)), |
| print_color_adjust_(static_cast<unsigned>(EPrintColorAdjust::kEconomy)), |
| print_color_adjust_is_inherited_(static_cast<unsigned>(true)), |
| rtl_ordering_(static_cast<unsigned>(EOrder::kLogical)), |
| rtl_ordering_is_inherited_(static_cast<unsigned>(true)), |
| table_layout_(static_cast<unsigned>(ETableLayout::kAuto)), |
| text_align_is_inherited_(static_cast<unsigned>(true)), |
| text_transform_is_inherited_(static_cast<unsigned>(true)), |
| unique_(static_cast<unsigned>(false)), |
| visibility_is_inherited_(static_cast<unsigned>(true)), |
| white_space_is_inherited_(static_cast<unsigned>(true)) |
| { |
| background_data_.Init(); |
| surround_data_.Init(); |
| } |
| |
| // PseudoBits |
| PseudoId PseudoBitsInternal() const { |
| return static_cast<PseudoId>(pseudo_bits_); |
| } |
| void SetPseudoBitsInternal(PseudoId v) { |
| pseudo_bits_ = static_cast<unsigned>(v); |
| } |
| |
| // StyleType |
| PseudoId StyleTypeInternal() const { |
| return static_cast<PseudoId>(style_type_); |
| } |
| void SetStyleTypeInternal(PseudoId v) { |
| style_type_ = static_cast<unsigned>(v); |
| } |
| |
| // AffectedByActive |
| void SetAffectedByActiveInternal(bool v) { |
| affected_by_active_ = static_cast<unsigned>(v); |
| } |
| |
| // VerticalAlign |
| EVerticalAlign VerticalAlignInternal() const { |
| return static_cast<EVerticalAlign>(vertical_align_); |
| } |
| void SetVerticalAlignInternal(EVerticalAlign v) { |
| vertical_align_ = static_cast<unsigned>(v); |
| } |
| |
| // AffectedByDrag |
| void SetAffectedByDragInternal(bool v) { |
| affected_by_drag_ = static_cast<unsigned>(v); |
| } |
| |
| // AffectedByFocus |
| void SetAffectedByFocusInternal(bool v) { |
| affected_by_focus_ = static_cast<unsigned>(v); |
| } |
| |
| // AffectedByFocusWithin |
| void SetAffectedByFocusWithinInternal(bool v) { |
| affected_by_focus_within_ = static_cast<unsigned>(v); |
| } |
| |
| // AffectedByHover |
| void SetAffectedByHoverInternal(bool v) { |
| affected_by_hover_ = static_cast<unsigned>(v); |
| } |
| |
| // EmptyState |
| bool EmptyStateInternal() const { |
| return static_cast<bool>(empty_state_); |
| } |
| void SetEmptyStateInternal(bool v) { |
| empty_state_ = static_cast<unsigned>(v); |
| } |
| |
| // HasExplicitlyInheritedProperties |
| void SetHasExplicitlyInheritedPropertiesInternal(bool v) { |
| has_explicitly_inherited_properties_ = static_cast<unsigned>(v); |
| } |
| |
| // HasRemUnits |
| void SetHasRemUnitsInternal(bool v) { |
| has_rem_units_ = static_cast<unsigned>(v); |
| } |
| |
| // HasSimpleUnderline |
| bool HasSimpleUnderlineInternal() const { |
| return static_cast<bool>(has_simple_underline_); |
| } |
| void SetHasSimpleUnderlineInternal(bool v) { |
| has_simple_underline_ = static_cast<unsigned>(v); |
| } |
| |
| // HasVariableReferenceFromNonInheritedProperty |
| void SetHasVariableReferenceFromNonInheritedPropertyInternal(bool v) { |
| has_variable_reference_from_non_inherited_property_ = static_cast<unsigned>(v); |
| } |
| |
| // IsLink |
| void SetIsLinkInternal(bool v) { |
| is_link_ = static_cast<unsigned>(v); |
| } |
| |
| // Unique |
| void SetUniqueInternal(bool v) { |
| unique_ = static_cast<unsigned>(v); |
| } |
| |
| |
| ~ComputedStyleBase() = default; |
| |
| // Storage. |
| DataRef<StyleBackgroundData> background_data_; |
| DataRef<StyleSurroundData> surround_data_; |
| |
| private: |
| unsigned pseudo_bits_ : 8; // PseudoId |
| unsigned cursor_ : 6; // ECursor |
| unsigned list_style_type_ : 6; // EListStyleType |
| unsigned style_type_ : 6; // PseudoId |
| unsigned display_ : 5; // EDisplay |
| unsigned affected_by_active_ : 1; // bool |
| unsigned original_display_ : 5; // EDisplay |
| unsigned break_after_ : 4; // EBreakBetween |
| unsigned break_before_ : 4; // EBreakBetween |
| unsigned pointer_events_ : 4; // EPointerEvents |
| unsigned text_align_ : 4; // ETextAlign |
| unsigned vertical_align_ : 4; // EVerticalAlign |
| unsigned overflow_x_ : 3; // EOverflow |
| unsigned overflow_y_ : 3; // EOverflow |
| unsigned affected_by_drag_ : 1; // bool |
| unsigned position_ : 3; // EPosition |
| unsigned unicode_bidi_ : 3; // UnicodeBidi |
| unsigned white_space_ : 3; // EWhiteSpace |
| unsigned break_inside_ : 2; // EBreakInside |
| unsigned clear_ : 2; // EClear |
| unsigned floating_ : 2; // EFloat |
| unsigned inside_link_ : 2; // EInsideLink |
| unsigned overflow_anchor_ : 2; // EOverflowAnchor |
| unsigned text_transform_ : 2; // ETextTransform |
| unsigned transform_box_ : 2; // ETransformBox |
| unsigned visibility_ : 2; // EVisibility |
| unsigned writing_mode_ : 2; // WritingMode |
| unsigned affected_by_focus_ : 1; // bool |
| unsigned affected_by_focus_within_ : 1; // bool |
| unsigned affected_by_hover_ : 1; // bool |
| unsigned border_collapse_ : 1; // EBorderCollapse |
| unsigned border_collapse_is_inherited_ : 1; // bool |
| unsigned box_direction_ : 1; // EBoxDirection |
| unsigned box_direction_is_inherited_ : 1; // bool |
| unsigned caption_side_ : 1; // ECaptionSide |
| unsigned caption_side_is_inherited_ : 1; // bool |
| unsigned direction_ : 1; // TextDirection |
| unsigned empty_cells_ : 1; // EEmptyCells |
| unsigned empty_cells_is_inherited_ : 1; // bool |
| unsigned empty_state_ : 1; // bool |
| unsigned has_explicitly_inherited_properties_ : 1; // bool |
| unsigned has_rem_units_ : 1; // bool |
| unsigned has_simple_underline_ : 1; // bool |
| unsigned has_variable_reference_from_non_inherited_property_ : 1; // bool |
| unsigned has_viewport_units_ : 1; // bool |
| unsigned is_link_ : 1; // bool |
| unsigned list_style_position_ : 1; // EListStylePosition |
| unsigned list_style_position_is_inherited_ : 1; // bool |
| unsigned pointer_events_is_inherited_ : 1; // bool |
| unsigned print_color_adjust_ : 1; // EPrintColorAdjust |
| unsigned print_color_adjust_is_inherited_ : 1; // bool |
| unsigned rtl_ordering_ : 1; // EOrder |
| unsigned rtl_ordering_is_inherited_ : 1; // bool |
| unsigned table_layout_ : 1; // ETableLayout |
| unsigned text_align_is_inherited_ : 1; // bool |
| unsigned text_transform_is_inherited_ : 1; // bool |
| unsigned unique_ : 1; // bool |
| unsigned visibility_is_inherited_ : 1; // bool |
| unsigned white_space_is_inherited_ : 1; // bool |
| }; |
| |
| } // namespace blink |
| |
| #endif // ComputedStyleBase_h |