Commit ec8d1045 authored by shend's avatar shend Committed by Commit bot

Make RubyPosition an enum class.

This patch makes RubyPosition an enum class for better type safety.

BUG=684966

Review-Url: https://codereview.chromium.org/2897883002
Cr-Commit-Position: refs/heads/master@{#474923}
parent 301b00f0
......@@ -1514,10 +1514,10 @@ template <>
inline CSSIdentifierValue::CSSIdentifierValue(RubyPosition position)
: CSSValue(kIdentifierClass) {
switch (position) {
case kRubyPositionBefore:
case RubyPosition::kBefore:
value_id_ = CSSValueBefore;
break;
case kRubyPositionAfter:
case RubyPosition::kAfter:
value_id_ = CSSValueAfter;
break;
}
......@@ -1527,15 +1527,15 @@ template <>
inline RubyPosition CSSIdentifierValue::ConvertTo() const {
switch (value_id_) {
case CSSValueBefore:
return kRubyPositionBefore;
return RubyPosition::kBefore;
case CSSValueAfter:
return kRubyPositionAfter;
return RubyPosition::kAfter;
default:
break;
}
NOTREACHED();
return kRubyPositionBefore;
return RubyPosition::kBefore;
}
template <>
......
......@@ -2539,7 +2539,7 @@
inherited: true,
field_template: "storage_only",
type_name: "RubyPosition",
default_value: "kRubyPositionBefore",
default_value: "RubyPosition::kBefore",
field_size: 1,
field_group: "rare-inherited",
},
......
......@@ -211,11 +211,12 @@ TEST_F(ElementTest, StickySubtreesAreTrackedCorrectly) {
document.View()->UpdateAllLifecyclePhases();
EXPECT_EQ(DocumentLifecycle::kPaintClean, document.Lifecycle().GetState());
EXPECT_EQ(kRubyPositionBefore, outer_sticky->StyleRef().GetRubyPosition());
EXPECT_EQ(kRubyPositionAfter, child->StyleRef().GetRubyPosition());
EXPECT_EQ(kRubyPositionAfter, grandchild->StyleRef().GetRubyPosition());
EXPECT_EQ(kRubyPositionAfter, inner_sticky->StyleRef().GetRubyPosition());
EXPECT_EQ(kRubyPositionAfter, great_grandchild->StyleRef().GetRubyPosition());
EXPECT_EQ(RubyPosition::kBefore, outer_sticky->StyleRef().GetRubyPosition());
EXPECT_EQ(RubyPosition::kAfter, child->StyleRef().GetRubyPosition());
EXPECT_EQ(RubyPosition::kAfter, grandchild->StyleRef().GetRubyPosition());
EXPECT_EQ(RubyPosition::kAfter, inner_sticky->StyleRef().GetRubyPosition());
EXPECT_EQ(RubyPosition::kAfter,
great_grandchild->StyleRef().GetRubyPosition());
// Setting -webkit-ruby value shouldn't have affected the sticky subtree bit.
EXPECT_TRUE(outer_sticky->StyleRef().SubtreeIsSticky());
......
......@@ -236,7 +236,7 @@ void LayoutRubyRun::UpdateLayout() {
}
if (Style()->IsFlippedLinesWritingMode() ==
(Style()->GetRubyPosition() == kRubyPositionAfter)) {
(Style()->GetRubyPosition() == RubyPosition::kAfter)) {
LayoutUnit first_line_top;
if (LayoutRubyBase* rb = RubyBase()) {
RootInlineBox* root_box = rb->FirstRootBox();
......
......@@ -794,7 +794,7 @@ void InlineFlowBox::PlaceBoxesInBlockDirection(
// been done as line layout and not done using inline-block.
if (GetLineLayoutItem().Style()->IsFlippedLinesWritingMode() ==
(curr->GetLineLayoutItem().Style()->GetRubyPosition() ==
kRubyPositionAfter))
RubyPosition::kAfter))
has_annotations_before = true;
else
has_annotations_after = true;
......@@ -1513,7 +1513,7 @@ LayoutUnit InlineFlowBox::ComputeOverAnnotationAdjustment(
if (curr->GetLineLayoutItem().IsAtomicInlineLevel() &&
curr->GetLineLayoutItem().IsRubyRun() &&
curr->GetLineLayoutItem().Style()->GetRubyPosition() ==
kRubyPositionBefore) {
RubyPosition::kBefore) {
LineLayoutRubyRun ruby_run = LineLayoutRubyRun(curr->GetLineLayoutItem());
LineLayoutRubyText ruby_text = ruby_run.RubyText();
if (!ruby_text)
......@@ -1584,7 +1584,7 @@ LayoutUnit InlineFlowBox::ComputeUnderAnnotationAdjustment(
if (curr->GetLineLayoutItem().IsAtomicInlineLevel() &&
curr->GetLineLayoutItem().IsRubyRun() &&
curr->GetLineLayoutItem().Style()->GetRubyPosition() ==
kRubyPositionAfter) {
RubyPosition::kAfter) {
LineLayoutRubyRun ruby_run = LineLayoutRubyRun(curr->GetLineLayoutItem());
LineLayoutRubyText ruby_text = ruby_run.RubyText();
if (!ruby_text)
......
......@@ -1814,12 +1814,13 @@ class CORE_EXPORT ComputedStyle : public ComputedStyleBase<ComputedStyle>,
}
// -webkit-ruby-position
static RubyPosition InitialRubyPosition() { return kRubyPositionBefore; }
static RubyPosition InitialRubyPosition() { return RubyPosition::kBefore; }
RubyPosition GetRubyPosition() const {
return static_cast<RubyPosition>(rare_inherited_data_->ruby_position_);
}
void SetRubyPosition(RubyPosition position) {
SET_VAR(rare_inherited_data_, ruby_position_, position);
SET_VAR(rare_inherited_data_, ruby_position_,
static_cast<unsigned>(position));
}
// -webkit-tap-highlight-color
......
......@@ -321,7 +321,7 @@ enum EImageRendering {
kImageRenderingPixelated
};
enum RubyPosition { kRubyPositionBefore, kRubyPositionAfter };
enum class RubyPosition { kBefore, kAfter };
static const size_t kGridAutoFlowBits = 4;
enum InternalGridAutoFlowAlgorithm {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment